Beispiel #1
0
        internal static List <NotificationMessage> GetData(INotificationDataReader[] readers, INotificationFiltersValidator filtersValidator,
                                                           IFiltersValidatorRepository filtersValidatorRepository, INotificationAggregatorsValidator aggregatorsValidator,
                                                           IAggregatorsValidatorRepository aggregatorsValidatorRepository)
        {
            var ret = new List <NotificationMessage>();

            if (!readers.Any())
            {
                return(ret);
            }

            foreach (var r in readers)
            {
                if (r is NotificationDataReaderDecorator decorator)
                {
                    filtersValidator?.SetFilters(filtersValidatorRepository?.GetFilters(decorator.GetId()));
                    (r as INotificationValidator).SetValidator(filtersValidator);
                    aggregatorsValidator?.SetAggregators(aggregatorsValidatorRepository?.GetAggregators(decorator.GetId()));
                    (r as INotificationAggregator).SetAggregator(aggregatorsValidator);
                }
                ret.AddRange(r.GetData());
            }

            return(ret);
        }
Beispiel #2
0
        public HostFactoryNotifierProcessorParams(params object[] paramList)
        {
            foreach (var param in paramList)
            {
                switch (param)
                {
                case INotifierProcessor processor:
                    NotifierProcessor = processor;
                    break;

                case INotificationDataReader[] dataReaders:
                    DataReaders = dataReaders;
                    break;

                case INotificationClientsManager clientsManager:
                    ClientsManager = clientsManager;
                    break;

                case INotificationFiltersValidator notificationFiltersValidator:
                    FiltersValidator = notificationFiltersValidator;
                    break;

                case IFiltersValidatorRepository filtersRepository:
                    FiltersValidatorRepository = filtersRepository;
                    break;

                case INotificationAggregatorsValidator notificationAggregatorsValidator:
                    AggregatorsValidator = notificationAggregatorsValidator;
                    break;

                case IAggregatorsValidatorRepository aggregatorsRepository:
                    AggregatorsValidatorRepository = aggregatorsRepository;
                    break;

                case ILogger log:
                    Logger = log;
                    break;

                case int inter:
                    Interval = inter;
                    break;
                }
            }
        }
Beispiel #3
0
        public HostFactoryNotifierProcessor(ANotifierProcessorParams notifierProcessorParams)
        {
            _dataReaders                    = (notifierProcessorParams as HostFactoryNotifierProcessorParams)?.DataReaders;
            _clientsManager                 = notifierProcessorParams.ClientsManager;
            _logger                         = notifierProcessorParams.Logger;
            _filtersValidator               = (notifierProcessorParams as HostFactoryNotifierProcessorParams)?.FiltersValidator;
            _filtersValidatorRepository     = (notifierProcessorParams as HostFactoryNotifierProcessorParams)?.FiltersValidatorRepository;
            _aggregatorsValidator           = (notifierProcessorParams as HostFactoryNotifierProcessorParams)?.AggregatorsValidator;
            _aggregatorsValidatorRepository = (notifierProcessorParams as HostFactoryNotifierProcessorParams)?.AggregatorsValidatorRepository;

            _lock = false;

            _timer = new Timer(notifierProcessorParams.Interval)
            {
                AutoReset = true
            };
            _timer.Elapsed += (sender, eventArgs) =>
            {
                ProcessingData();
            };
        }