public void ApplyLastSync(IEntityConflict entityConflict) { var entity = GetSyncableEntity(); foreach (var row in LastSync) { var existing = FindExisting(row); if (existing == null) { ApplyInsertWhenNoExistInLocal(entityConflict, row); continue; } ApplyUpdateWhenExistInLocal(entityConflict, existing, entity, row); } }
public void ApplyDelete(IEntityConflict entityConflict) { var entity = GetSyncableEntity(); foreach (var row in Delete) { var existing = FindExisting(row); if (existing == null) { OrmDebug.Trace(string.Format("Entity:{0}. deleted on remote but does not exist locally.", EntityName)); continue; } ApplyDeletetWhenExistInLocal(entityConflict, existing, entity, row); } }
private void ApplyUpdateWhenExistInLocal(IEntityConflict entityConflict, EntityChange existing, ISyncableEntity entity, EntityChange row) { if (HasChangedOnBothSide(existing, entity)) { entityConflict.OnApplyUpdateExistingUpdatedToo(existing, row); return; } try { row.ApplyUpdate(_datastore, _entitySerialiazer); } catch { entityConflict.OnApplyUpdate(existing, row); } }
private void ApplyInsertWhenNoExistInLocal(IEntityConflict entityConflict, EntityChange row) { var deleted = FindDeleted(row); if (deleted != null) { entityConflict.OnApplyInsertDeletedOnRemote(row); return; } try { row.ApplyInsert(_datastore, _entitySerialiazer); } catch { entityConflict.OnApplyInsert(null, row); } }
public void ApplyInsert(IEntityConflict entityConflict, IConflictsManager conflictsManager) { foreach (var row in Insert) { conflictsManager.ApplyForeignKeyChange(row); var existing = FindExisting(row); if (existing != null) { entityConflict.OnApplyInsertAlreadyExisting(existing, row); continue; } if (conflictsManager.HasForeignKeyDeleted(row)) { continue; } ApplyInsertWhenNoExistInLocal(entityConflict, row); } }
private void ApplyDeletetWhenExistInLocal(IEntityConflict entityConflict, EntityChange existing, ISyncableEntity entity, EntityChange row) { if (HasInsertedOnTarget(existing, entity)) { entityConflict.OnApplyDeleteExistingInserted(existing); return; } if (HasChangedOnBothSide(existing, entity)) { entityConflict.OnApplyDeleteExistingUpdated(existing); return; } try { row.ApplyDelete(_datastore, EntityName, _entitySerialiazer); } catch { entityConflict.OnApplyDelete(existing, row); } }
public ChangeSet(EntityChangeset entityChangeset, IEntityConflict conflic, IConflictsManager conflictsManager) { _entityChangeset = entityChangeset; _conflic = conflic; _conflictsManager = conflictsManager; }