public async Task Synchronize(ISynchronizationLogger logger, TContext synchronizationContext) { s_logger.InfoFormat("Entered. Syncstrategy '{0}' with Atype='{1}' and Btype='{2}'", _initialSyncStateCreationStrategy.GetType().Name, typeof(TAtypeEntity).Name, typeof(TBtypeEntity).Name); using (var totalProgress = _totalProgressFactory.Create()) { var knownEntityRelations = _entityRelationDataAccess.LoadEntityRelationData() ?? new IEntityRelationData <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion>[] { }; var stateTokens = _stateTokenDataAccess.LoadKnownStateTokens(); using (var interceptor = _synchronizationInterceptorFactory.Create()) { var aStatesTask = _atypeStateAwareEntityRepository.GetFullRepositoryState(knownEntityRelations.Select(r => r.AtypeId), stateTokens.AToken, synchronizationContext, logger.AGetVersionsEntityLogger); var bStatesTask = _btypeStateAwareEntityRepository.GetFullRepositoryState(knownEntityRelations.Select(r => r.BtypeId), stateTokens.BToken, synchronizationContext, logger.BGetVersionsEntityLogger); (var aStates, var newAToken) = await aStatesTask; (var bStates, var newBToken) = await bStatesTask; await Synchronize( totalProgress, knownEntityRelations, aStates, bStates, logger, synchronizationContext, interceptor, newEntityRelations => _entityRelationDataAccess.SaveEntityRelationData(newEntityRelations)); _stateTokenDataAccess.SaveKnownStateTokens(newAToken, newBToken); } } s_logger.DebugFormat("Exiting."); }
public async Task Synchronize(ISynchronizationLogger logger, TContext synchronizationContext) { s_logger.InfoFormat("Entered. Syncstrategy '{0}' with Atype='{1}' and Btype='{2}'", _initialSyncStateCreationStrategy.GetType().Name, typeof(TAtypeEntity).Name, typeof(TBtypeEntity).Name); using (var totalProgress = _totalProgressFactory.Create()) { var knownEntityRelations = _entityRelationDataAccess.LoadEntityRelationData() ?? new IEntityRelationData <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion>[] { }; using (var interceptor = _synchronizationInterceptorFactory.Create()) { var newAVersionsTask = _atypeRepository.GetAllVersions(knownEntityRelations.Select(r => r.AtypeId), synchronizationContext); var newBVersionsTask = _btypeRepository.GetAllVersions(knownEntityRelations.Select(r => r.BtypeId), synchronizationContext); var newAVersions = CreateDictionary( await newAVersionsTask, _atypeIdComparer); var newBVersions = CreateDictionary( await newBVersionsTask, _btypeIdComparer); await Synchronize( totalProgress, knownEntityRelations, newAVersions, newBVersions, logger, synchronizationContext, interceptor, newEntityRelations => _entityRelationDataAccess.SaveEntityRelationData(newEntityRelations)); } } s_logger.DebugFormat("Exiting."); }