コード例 #1
0
 public object Create()
 {
     return(new DataChangesDetector <T>(
                _metadata.MapSpecificationProviderForSource,
                _metadata.MapSpecificationProviderForTarget,
                _equalityComparerFactory.CreateCompleteComparer <T>(),
                _query));
 }
コード例 #2
0
 public SyncEntityNameActor(IQuery query,
                            IBulkRepository <EntityName> bulkRepository,
                            IEqualityComparerFactory equalityComparerFactory)
 {
     _query            = query;
     _bulkRepository   = bulkRepository;
     _identityComparer = equalityComparerFactory.CreateIdentityComparer <EntityName>();
     _completeComparer = equalityComparerFactory.CreateCompleteComparer <EntityName>();
 }
コード例 #3
0
 public ValueObjectChangesProvider(IQuery query,
                                   IStorageBasedDataObjectAccessor <TDataObject> storageBasedDataObjectAccessor,
                                   IEqualityComparerFactory equalityComparerFactory)
 {
     _storageBasedDataObjectAccessor = storageBasedDataObjectAccessor;
     _dataChangesDetector            = new DataChangesDetector <TDataObject>(
         specification => storageBasedDataObjectAccessor.GetSource().WhereMatched(specification),
         specification => query.For <TDataObject>().WhereMatched(specification),
         equalityComparerFactory.CreateCompleteComparer <TDataObject>());
 }
コード例 #4
0
        private HashSet <T> GetTable <T>()
        {
            if (_store.TryGetValue(typeof(T), out var table))
            {
                return((HashSet <T>)table);
            }

            var collection = new HashSet <T>(_equalityComparerFactory.CreateCompleteComparer <T>());

            _store.Add(typeof(T), collection);
            return(collection);
        }
コード例 #5
0
 public ValidationRuleActor(IQuery query,
                            IRepository <Version> versionRepository,
                            SyncInMemoryDataObjectsActor <Version.ErmState> syncInMemoryErmStates,
                            IRepository <Version.AmsState> amsStatesRepository,
                            IBulkRepository <Version.ValidationResult> validationResultRepository,
                            IEqualityComparerFactory equalityComparerFactory,
                            ValidationResultCache cache)
 {
     _query                      = query;
     _versionRepository          = versionRepository;
     _syncInMemoryErmStates      = syncInMemoryErmStates;
     _validationResultRepository = validationResultRepository;
     _amsStatesRepository        = amsStatesRepository;
     _accessors                  = new ValidationRuleRegistry(query).CreateAccessors().ToDictionary(x => (MessageTypeCode)x.MessageTypeId, x => x);
     _equalityComparer           = equalityComparerFactory.CreateCompleteComparer <Version.ValidationResult>();
     _cache                      = cache;
 }
コード例 #6
0
 public ValidationRuleActor(IQuery query,
                            IRepository <Version> versionRepository,
                            IBulkRepository <Version.ErmState> ermStatesRepository,
                            IRepository <Version.AmsState> amsStatesRepository,
                            IBulkRepository <Version.ValidationResult> validationResultRepository,
                            IEqualityComparerFactory equalityComparerFactory,
                            ValidationResultCache cache)
 {
     _query                      = query;
     _versionRepository          = versionRepository;
     _ermStatesRepository        = ermStatesRepository;
     _validationResultRepository = validationResultRepository;
     _amsStatesRepository        = amsStatesRepository;
     _accessors                  = new ValidationRuleRegistry(query).CreateAccessors().ToDictionary(x => (MessageTypeCode)x.MessageTypeId, x => x);
     _equalityComparer           = equalityComparerFactory.CreateCompleteComparer <Version.ValidationResult>();
     _cache                      = cache;
     _transactionOptions         = new TransactionOptions {
         IsolationLevel = IsolationLevel.ReadCommitted, Timeout = TimeSpan.Zero
     };
 }
コード例 #7
0
 public StatisticsProcessor(StatisticsRecalculationMetadata <T, StatisticsKey> metadata, IQuery query, IBulkRepository <T> repository, IEqualityComparerFactory equalityComparerFactory)
 {
     _repository = repository;
     _metadata   = metadata;
     _equalityComparerFactory = equalityComparerFactory;
     _changesDetector         = new DataChangesDetector <T>(_metadata.MapSpecificationProviderForSource, _metadata.MapSpecificationProviderForTarget, _equalityComparerFactory.CreateCompleteComparer <T>(), query);
 }
コード例 #8
0
        public void RecalculateStatistics(long projectId, IReadOnlyCollection <long?> categoryIds)
        {
            var filter = _metadata.FindSpecificationProvider.Invoke(projectId, categoryIds);

            // Сначала сравниением получаем различающиеся записи,
            // затем получаем те из различающихся, которые совпадают по идентификатору.
            var intermediateResult = _changesDetector.DetectChanges(Specs.Map.ZeroMapping <T>(), filter, _equalityComparerFactory.CreateCompleteComparer <T>());
            var changes            = MergeTool.Merge(intermediateResult.Difference, intermediateResult.Complement, _equalityComparerFactory.CreateIdentityComparer <T>());

            // Наличие или отсутствие статистики - не повод создавать или удалять рубрики у фирм.
            // Поэтому только обновление.
            _repository.Update(changes.Intersection);
        }
 public TwoPhaseDataChangesDetector(IEqualityComparerFactory equalityComparerFactory)
 {
     _identityComparer = equalityComparerFactory.CreateIdentityComparer <TDataObject>();
     _completeComparer = equalityComparerFactory.CreateCompleteComparer <TDataObject>();
 }