feat: implementa campo Data_Hash per ottimizzazione trasferimenti
- Aggiunge colonna "Hash Dati" nella tabella delle associazioni con visualizzazione troncata - Implementa generazione hash SHA256 che include signature dei mapping per rilevare modifiche configurazione - Modifica logica trasferimento per saltare record con hash identico (ottimizzazione prestazioni) - Corregge UpdateAssociationAsync per persistere correttamente Data_Hash e LastVerifiedAt nel database - Aggiorna hash solo in caso di trasferimento riuscito, mantenendo coerenza tra Salesforce e database locale - Migliora logging per debug del sistema di hash e associazioni Risolve il problema dei trasferimenti continui quando i mapping cambiano e ottimizza le prestazioni saltando record non modificati.
This commit is contained in:
@@ -31,6 +31,7 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
var sourceKeyField = association.SourceKeyField;
|
||||
var destinationKeyField = association.DestinationKeyField;
|
||||
var additionalInfo = association.AdditionalInfo;
|
||||
var dataHash = association.Data_Hash;
|
||||
var currentTime = DateTime.UtcNow;
|
||||
|
||||
try
|
||||
@@ -47,12 +48,13 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
DestinationKeyField = {2},
|
||||
UpdatedAt = {3},
|
||||
LastVerifiedAt = {4},
|
||||
AdditionalInfo = {5}
|
||||
WHERE KeyValue = {6}
|
||||
AND DestinationEntity = {7}
|
||||
AND RestCredentialName = {8}
|
||||
AdditionalInfo = {5},
|
||||
Data_Hash = {6}
|
||||
WHERE KeyValue = {7}
|
||||
AND DestinationEntity = {8}
|
||||
AND RestCredentialName = {9}
|
||||
AND IsActive = 1",
|
||||
destinationId, sourceKeyField, destinationKeyField, currentTime, currentTime, additionalInfo ?? (object)DBNull.Value,
|
||||
destinationId, sourceKeyField, destinationKeyField, currentTime, currentTime, additionalInfo ?? (object)DBNull.Value, dataHash ?? (object)DBNull.Value,
|
||||
keyValue, destinationEntity, restCredentialName);
|
||||
|
||||
if (rowsAffected > 0)
|
||||
@@ -92,6 +94,7 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
CreatedAt = currentTime,
|
||||
LastVerifiedAt = currentTime,
|
||||
AdditionalInfo = additionalInfo,
|
||||
Data_Hash = dataHash,
|
||||
IsActive = true
|
||||
};
|
||||
|
||||
@@ -125,6 +128,7 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
existing.UpdatedAt = currentTime;
|
||||
existing.LastVerifiedAt = currentTime;
|
||||
existing.AdditionalInfo = additionalInfo;
|
||||
existing.Data_Hash = dataHash;
|
||||
|
||||
UpdateSourcesInfo(existing, association);
|
||||
|
||||
@@ -162,6 +166,7 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
var sourceKeyField = association.SourceKeyField;
|
||||
var destinationKeyField = association.DestinationKeyField;
|
||||
var additionalInfo = association.AdditionalInfo;
|
||||
var dataHash = association.Data_Hash;
|
||||
var currentTime = DateTime.UtcNow;
|
||||
|
||||
// Crea un nuovo DbContext per questa operazione parallela
|
||||
@@ -185,12 +190,13 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
DestinationKeyField = {2},
|
||||
UpdatedAt = {3},
|
||||
LastVerifiedAt = {4},
|
||||
AdditionalInfo = {5}
|
||||
WHERE KeyValue = {6}
|
||||
AND DestinationEntity = {7}
|
||||
AND RestCredentialName = {8}
|
||||
AdditionalInfo = {5},
|
||||
Data_Hash = {6}
|
||||
WHERE KeyValue = {7}
|
||||
AND DestinationEntity = {8}
|
||||
AND RestCredentialName = {9}
|
||||
AND IsActive = 1",
|
||||
destinationId, sourceKeyField, destinationKeyField, currentTime, currentTime, additionalInfo ?? (object)DBNull.Value,
|
||||
destinationId, sourceKeyField, destinationKeyField, currentTime, currentTime, additionalInfo ?? (object)DBNull.Value, dataHash ?? (object)DBNull.Value,
|
||||
keyValue, destinationEntity, restCredentialName);
|
||||
|
||||
if (rowsAffected > 0)
|
||||
@@ -230,6 +236,7 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
CreatedAt = currentTime,
|
||||
LastVerifiedAt = currentTime,
|
||||
AdditionalInfo = additionalInfo,
|
||||
Data_Hash = dataHash,
|
||||
IsActive = true
|
||||
};
|
||||
|
||||
@@ -549,9 +556,11 @@ public class KeyAssociationService : IKeyAssociationService
|
||||
existing.DestinationId = association.DestinationId;
|
||||
existing.RestCredentialName = association.RestCredentialName;
|
||||
existing.UpdatedAt = DateTime.UtcNow;
|
||||
existing.LastVerifiedAt = association.LastVerifiedAt;
|
||||
existing.AdditionalInfo = association.AdditionalInfo;
|
||||
existing.SourcesInfo = association.SourcesInfo;
|
||||
existing.IsActive = association.IsActive;
|
||||
existing.Data_Hash = association.Data_Hash;
|
||||
|
||||
_context.KeyAssociations.Update(existing);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
Reference in New Issue
Block a user