Fix: Risolto double-mapping negli External ID Relationships per Salesforce
- Implementata funzionalità completa External ID Relationships nell'interfaccia di mapping
- Corretto bug double-mapping: i campi sorgente usati per External ID non vengono più inclusi nei mapping normali
- Risolto errore MALFORMED_ID causato dall'invio duplicato di campi come proprietà dirette e nested objects
- Implementata logica corretta per relationship names: oggetti standard usano il nome diretto, custom objects usano suffisso __r
- Aggiunta UI a 3 colonne (Object, External ID Field, Source Field) per configurazione External ID Relationships
- Migrazione database per supporto External ID Relationships nei profili
- Aggiornato ProfileSaver.razor.cs per salvare/caricare External ID Relationships
- Aggiornato ScheduledProfileExecutionService.cs per gestire External ID nelle esecuzioni schedulate
- Formato JSON output corretto: { 'Account': { 'CardCode__c': 'V50000' } }
Documentazione: EXTERNAL_ID_RELATIONSHIPS_IMPLEMENTATION.md
This commit is contained in:
@@ -174,13 +174,51 @@ public static class ConnectionStringBuilder
|
||||
};
|
||||
} private static string BuildSqlServerConnectionString(DatabaseCredential credential)
|
||||
{
|
||||
var builder = new List<string>
|
||||
var builder = new List<string>();
|
||||
|
||||
// Gestione speciale per SQL Server locale e named instances
|
||||
// Se l'host contiene '\' (instance name) o '(localdb)', non aggiungere la porta
|
||||
bool hasInstanceName = credential.Host.Contains('\\') ||
|
||||
credential.Host.StartsWith("(localdb)", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (hasInstanceName)
|
||||
{
|
||||
$"Server={credential.Host},{credential.Port}",
|
||||
$"User Id={credential.Username}",
|
||||
$"Password={credential.Password}",
|
||||
$"Connection Timeout={credential.CommandTimeout}"
|
||||
};
|
||||
// Per named instances e LocalDB, non includere la porta
|
||||
builder.Add($"Server={credential.Host}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Per connessioni TCP/IP standard, include host e porta
|
||||
// Ma solo se la porta non è la default (1433) per localhost
|
||||
if ((credential.Host.Equals("localhost", StringComparison.OrdinalIgnoreCase) ||
|
||||
credential.Host == "." ||
|
||||
credential.Host == "127.0.0.1") && credential.Port == 1433)
|
||||
{
|
||||
// Per localhost con porta default, ometti la porta per usare Named Pipes
|
||||
builder.Add($"Server={credential.Host}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Per altri casi, usa host,porta
|
||||
builder.Add($"Server={credential.Host},{credential.Port}");
|
||||
}
|
||||
}
|
||||
|
||||
// Se username è vuoto o è "Integrated", usa Windows Authentication
|
||||
if (string.IsNullOrWhiteSpace(credential.Username) ||
|
||||
credential.Username.Equals("Integrated", StringComparison.OrdinalIgnoreCase) ||
|
||||
credential.Username.Equals("Windows", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
builder.Add("Integrated Security=True");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Usa SQL Server Authentication
|
||||
builder.Add($"User Id={credential.Username}");
|
||||
builder.Add($"Password={credential.Password}");
|
||||
}
|
||||
|
||||
builder.Add($"Connection Timeout={credential.CommandTimeout}");
|
||||
|
||||
// Aggiungi Database solo se specificato
|
||||
if (!string.IsNullOrEmpty(credential.DatabaseName))
|
||||
|
||||
@@ -59,6 +59,10 @@ public class DataCouplerProfile
|
||||
// Mapping dei campi salvato come JSON
|
||||
[MaxLength(4000)]
|
||||
public string? FieldMappingJson { get; set; }
|
||||
|
||||
// External ID Relationships per Salesforce salvate come JSON
|
||||
[MaxLength(4000)]
|
||||
public string? ExternalIdRelationshipsJson { get; set; }
|
||||
|
||||
// Configurazione chiave sorgente e associazioni
|
||||
[MaxLength(200)]
|
||||
|
||||
@@ -30,6 +30,9 @@ public class DataCouplerProfileDto
|
||||
// Mapping dei campi
|
||||
public List<FieldMappingDto>? FieldMappings { get; set; }
|
||||
|
||||
// External ID Relationships per Salesforce
|
||||
public List<ExternalIdRelationshipDto>? ExternalIdRelationships { get; set; }
|
||||
|
||||
// Configurazione chiave sorgente e associazioni
|
||||
public string? SourceKeyField { get; set; }
|
||||
public bool UseRecordAssociations { get; set; }
|
||||
@@ -47,6 +50,37 @@ public class FieldMappingDto
|
||||
public bool IsRequired { get; set; }
|
||||
public string? DefaultValue { get; set; }
|
||||
public string? Transformation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Lista di relazioni External ID associate a questo campo (per Salesforce)
|
||||
/// </summary>
|
||||
public List<ExternalIdRelationshipDto>? ExternalIdRelationships { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO per External ID Relationship (Salesforce)
|
||||
/// </summary>
|
||||
public class ExternalIdRelationshipDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Nome della relazione (es. "Account__r")
|
||||
/// </summary>
|
||||
public string RelationshipName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Nome dell'oggetto correlato (es. "Account")
|
||||
/// </summary>
|
||||
public string RelatedObjectName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Campo External ID dell'oggetto correlato (es. "Country__c")
|
||||
/// </summary>
|
||||
public string ExternalIdField { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Campo sorgente da cui prendere il valore per l'External ID
|
||||
/// </summary>
|
||||
public string SourceField { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user