private IEnumerable <IEvent> Handle(IReadOnlyCollection <ISyncDataObjectCommand> commands)
        {
            if (commands.Count == 0)
            {
                return(Enumerable.Empty <IEvent>());
            }

            var dataObjectTypes = commands.Select(x => x.DataObjectType).ToHashSet();
            var actors          = _dataObjectsActorFactory.Create(dataObjectTypes);

            var eventCollector = new FactsEventCollector();

            foreach (var actor in actors)
            {
                using (Probe.Create($"ETL1 {actor.GetType().GetFriendlyName()}"))
                {
                    var events = actor.ExecuteCommands(commands);
                    eventCollector.Add(events);
                }
            }

            _syncEntityNameActor.ExecuteCommands(commands);

            return(eventCollector.Events());
        }
예제 #2
0
        private void Process(IReadOnlyCollection <IInfoRussiaDto> dtos)
        {
            var actors = _dataObjectsActorFactory.Create(new []
            {
                typeof(Firm),
                typeof(FirmInactive),
                typeof(FirmAddress),
                typeof(FirmAddressInactive),
                typeof(FirmAddressCategory),
            });

            var commands = new[]
            {
                new SyncInMemoryDataObjectCommand(typeof(Firm), dtos),
                new SyncInMemoryDataObjectCommand(typeof(FirmInactive), dtos),
                new SyncInMemoryDataObjectCommand(typeof(FirmAddress), dtos),
                new SyncInMemoryDataObjectCommand(typeof(FirmAddressInactive), dtos),
                new SyncInMemoryDataObjectCommand(typeof(FirmAddressCategory), dtos),
            };

            var eventsCollector = new FactsEventCollector();

            foreach (var actor in actors)
            {
                var events = actor.ExecuteCommands(commands);
                eventsCollector.Add(events);
            }

            _syncEntityNameActor.ExecuteCommands(commands);

            _eventLogger.Log <IEvent>(eventsCollector.Events().Select(x => new FlowEvent(KafkaFactsFlow.Instance, x)).ToList());
        }
        private void Process(IReadOnlyCollection <RulesetDto> dtos)
        {
            var actors = _dataObjectsActorFactory.Create(new[]
            {
                typeof(Storage.Model.Facts.Ruleset),
                typeof(Storage.Model.Facts.Ruleset.AssociatedRule),
                typeof(Storage.Model.Facts.Ruleset.DeniedRule),
                typeof(Storage.Model.Facts.Ruleset.QuantitativeRule),
                typeof(Storage.Model.Facts.Ruleset.RulesetProject)
            });

            var commands = new[]
            {
                new SyncInMemoryDataObjectCommand(typeof(Storage.Model.Facts.Ruleset), dtos),
                new SyncInMemoryDataObjectCommand(typeof(Storage.Model.Facts.Ruleset.AssociatedRule), dtos),
                new SyncInMemoryDataObjectCommand(typeof(Storage.Model.Facts.Ruleset.DeniedRule), dtos),
                new SyncInMemoryDataObjectCommand(typeof(Storage.Model.Facts.Ruleset.QuantitativeRule), dtos),
                new SyncInMemoryDataObjectCommand(typeof(Storage.Model.Facts.Ruleset.RulesetProject), dtos),
            };

            var eventsCollector = new FactsEventCollector();

            foreach (var actor in actors)
            {
                var events = actor.ExecuteCommands(commands);
                eventsCollector.Add(events);
            }

            _eventLogger.Log <IEvent>(eventsCollector.Events().Select(x => new FlowEvent(KafkaFactsFlow.Instance, x)).ToList());
        }
예제 #4
0
        private IEnumerable <IEvent> Handle(IReadOnlyCollection <IReplaceDataObjectCommand> commands)
        {
            if (commands.Count == 0)
            {
                return(Enumerable.Empty <IEvent>());
            }

            var dataObjectTypes = commands.Select(x => x.DataObjectType).ToHashSet();
            var actors          = _dataObjectsActorFactory.Create(dataObjectTypes);
            var eventsCollector = new FactsEventCollector();

            foreach (var actor in actors)
            {
                var events = actor.ExecuteCommands(commands);
                eventsCollector.Add(events);
            }

            return(eventsCollector.Events());
        }
        private void Process(IReadOnlyCollection <AdvertisementDto> dtos)
        {
            var actors = _dataObjectsActorFactory.Create(new []
            {
                typeof(Advertisement)
            });

            var commands = new[]
            {
                new SyncInMemoryDataObjectCommand(typeof(Advertisement), dtos)
            };

            var eventsCollector = new FactsEventCollector();

            foreach (var actor in actors)
            {
                var events = actor.ExecuteCommands(commands);
                eventsCollector.Add(events);
            }

            _syncEntityNameActor.ExecuteCommands(commands);

            _eventLogger.Log <IEvent>(eventsCollector.Events().Select(x => new FlowEvent(KafkaFactsFlow.Instance, x)).ToList());
        }
예제 #6
0
        private void Process(IReadOnlyCollection <IFijiDto> dtos)
        {
            var actors = _dataObjectsActorFactory.Create(new []
            {
                typeof(Building),
                typeof(BuildingBulkDelete),
            });

            var commands = new ICommand[]
            {
                new SyncInMemoryDataObjectCommand(typeof(Building), dtos),
                new DeleteInMemoryDataObjectCommand(typeof(BuildingBulkDelete), dtos)
            };

            var eventsCollector = new FactsEventCollector();

            foreach (var actor in actors)
            {
                var events = actor.ExecuteCommands(commands);
                eventsCollector.Add(events);
            }

            _eventLogger.Log <IEvent>(eventsCollector.Events().Select(x => new FlowEvent(KafkaFactsFlow.Instance, x)).ToList());
        }