using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace CredentialManager.Models; /// /// Modello per salvare le configurazioni dei profili di Data Coupler /// public class DataCouplerProfile { [Key] public int Id { get; set; } [Required] [MaxLength(100)] public string Name { get; set; } = string.Empty; [MaxLength(500)] public string? Description { get; set; } // Configurazione Fonte Dati [Required] [MaxLength(20)] public string SourceType { get; set; } = string.Empty; // "database" o "file" public int? SourceCredentialId { get; set; } [MaxLength(200)] public string? SourceDatabaseName { get; set; } [MaxLength(200)] public string? SourceSchema { get; set; } [MaxLength(200)] public string? SourceTable { get; set; } [MaxLength(2000)] public string? SourceCustomQuery { get; set; } [MaxLength(500)] public string? SourceFilePath { get; set; } // Configurazione Destinazione [Required] [MaxLength(20)] public string DestinationType { get; set; } = string.Empty; // "database" o "rest" public int? DestinationCredentialId { get; set; } [MaxLength(200)] public string? DestinationSchema { get; set; } [MaxLength(200)] public string? DestinationTable { get; set; } [MaxLength(500)] public string? DestinationEndpoint { get; set; } // Mapping dei campi salvato come JSON [MaxLength(4000)] public string? FieldMappingJson { get; set; } // Default values per i campi di destinazione salvati come JSON // Formato: { "DestinationField": { "Value": "defaultValue", "Type": "string" } } [MaxLength(4000)] public string? DefaultValuesJson { get; set; } // External ID Relationships per Salesforce salvate come JSON [MaxLength(4000)] public string? ExternalIdRelationshipsJson { get; set; } // Configurazione chiave sorgente e associazioni [MaxLength(200)] public string? SourceKeyField { get; set; } public bool UseRecordAssociations { get; set; } = false; // Configurazione gestione cancellazioni /// /// Indica se sincronizzare le cancellazioni dalla sorgente alla destinazione /// public bool SyncDeletions { get; set; } = false; /// /// Tipo di azione da eseguire per i record cancellati: /// - "delete": Elimina fisicamente il record dalla destinazione /// - "deactivate": Marca il record come inattivo (se supportato) /// - "mark": Imposta un flag personalizzato (campo configurabile) /// [MaxLength(20)] public string? DeletionAction { get; set; } = "delete"; /// /// Nome del campo da utilizzare per marcare i record come cancellati (se DeletionAction = "mark") /// Es: "IsDeleted", "Status", "Active" /// [MaxLength(200)] public string? DeletionMarkField { get; set; } /// /// Valore da impostare nel campo di marcatura quando un record รจ cancellato /// Es: "true", "Deleted", "false" (per Active) /// [MaxLength(100)] public string? DeletionMarkValue { get; set; } // Metadati [MaxLength(100)] public string? CreatedBy { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime? LastUsedAt { get; set; } public bool IsActive { get; set; } = true; // Relazioni opzionali con le credenziali [ForeignKey(nameof(SourceCredentialId))] public virtual CredentialEntity? SourceCredential { get; set; } [ForeignKey(nameof(DestinationCredentialId))] public virtual CredentialEntity? DestinationCredential { get; set; } }