Esempio n. 1
0
        public INotificationDataReader Prepare(ConfigManager.Models.Reader reader, ConfigManager.ConfigManager configManager)
        {
            var exitReaderParams = new ExitDataReaderParams {
                LogicalStorage = reader.LogicalName
            };
            var setCounterReader = new CounterReader(configManager, reader.ReaderId);

            return(new ExitReader.ExitReader(exitReaderParams, setCounterReader));
        }
 /// <summary>
 /// Remove AutoCAD String format symbols
 /// </summary>
 /// <param name="str">string to clean</param>
 /// <returns>cleared string</returns>
 public static string removeAutoCADFormat(this String str)
 {
     ConfigManager.ConfigManager conf = ConfigManager.ConfigManager.Instance;
     foreach (string pat in conf.Configuration.AutoCADPatterns)
     {
         str = str.removePattern(pat);
     }
     return(str);
 }
Esempio n. 3
0
        internal Params(ConfigManager.ConfigManager configManager, ISerializer serializer)
        {
            CheckParams(configManager, serializer);

            PrepareReaders(configManager);
            PrepareClients(configManager, serializer);
            PrepareClientsManagerParams(configManager);
            PrepareFiltersValidatorRepository(configManager);
            PrepareAggregatorsValidatorRepository(configManager);
        }
        /// <summary>
        /// Clean string according to whitelist
        /// </summary>
        /// <param name="str">string to clean</param>
        /// <returns>cleared string</returns>
        public static string cleanAllWithWhiteList(this String str)
        {
            ConfigManager.ConfigManager conf = ConfigManager.ConfigManager.Instance;

            foreach (string white in conf.Configuration.WhiteList)
            {
                str = str.cleanBeforeWhiteListValue(white);
            }
            return(str);
        }
Esempio n. 5
0
 void CheckParams(ConfigManager.ConfigManager configManager, ISerializer serializer)
 {
     if (configManager is null)
     {
         throw new ArgumentNullException($"{nameof(configManager)} cannot be null");
     }
     if (serializer is null)
     {
         throw new ArgumentNullException($"{nameof(serializer)} cannot be null");
     }
 }
Esempio n. 6
0
        public INotificationDataReader Prepare(ConfigManager.Models.Reader reader, ConfigManager.ConfigManager configManager)
        {
            var pingReaderParams = new PingDataReaderParams
            {
                LogicalStorage = reader.LogicalName,
                StartTime      = reader.ReaderAdditionalParams.StartTime,
                Interval       = reader.ReaderAdditionalParams.Interval,
                Occurs         = reader.ReaderAdditionalParams.Occurs
            };

            var setCounterReader = new CounterReader(configManager, reader.ReaderId);

            return(new PingLivingReader(pingReaderParams, setCounterReader));
        }
Esempio n. 7
0
        private void PrepareClientsManagerParams(ConfigManager.ConfigManager configManager)
        {
            if (configManager.Config.Rules is null)
            {
                return;
            }

            ClientsManagerParams = new ClientsManagerParams {
                Clients = Clients, Rules = new Dictionary <int, int[]>()
            };
            foreach (var rule in configManager.Config.Rules)
            {
                ClientsManagerParams.Rules.Add(rule.ClientId, rule.ReaderId);
            }
        }
Esempio n. 8
0
        public INotificationDataReader Prepare(ConfigManager.Models.Reader reader, ConfigManager.ConfigManager configManager)
        {
            var databaseDataReaderParams = new DatabaseDataReaderParams
            {
                LogicalStorage        = reader.LogicalName,
                Schema                = reader.ReaderAdditionalParams.Schema ?? "dbo",
                TableName             = reader.ReaderAdditionalParams.TableName,
                OrderByColumnName     = reader.ReaderAdditionalParams.OrderByColumnName,
                InitialCounter        = reader.InitialCounter,
                MessageTypeColumnName = reader.ReaderAdditionalParams.MessageTypeColumnName,
                ColumnsNames          = reader.ColumnNames
            };

            var setCounterReader = new CounterReader(configManager, reader.ReaderId);

            var notificationDataReaderDecorator = new NotificationDataReaderDecorator(
                new DatabaseDataReader.DatabaseDataReader(reader.ConnectionString, databaseDataReaderParams, setCounterReader), reader.ReaderId);

            return(notificationDataReaderDecorator);
        }
Esempio n. 9
0
        private void PrepareClients(ConfigManager.ConfigManager configManager, ISerializer serializer)
        {
            Clients = new List <INotificationClient>();

            if (configManager.Config.Clients is null)
            {
                return;
            }

            var clientFactory = new PrepareClientFactory();

            foreach (var client in configManager.Config.Clients)
            {
                if (Clients.Any(x => x is AClient && ((AClient)x).Id == client.ClientId))
                {
                    continue;
                }
                var pClient = clientFactory.Create(client.ClientType.ToEnum <ClientType>());
                Clients.Add(pClient.Prepare(client, serializer));
            }
        }
Esempio n. 10
0
        private static void Main()
        {
            var jsonSerializer = new JsonSerializer();
            var configManager  = new ConfigManager.ConfigManager(ConfigProvider.FileName, jsonSerializer);

            var logger = ConfigProvider.Log4NetLogger ? (ILogger) new Log4NetLogger(ConfigProvider.Log4NetLoggerDaysToKeepLogs) : new ConsoleLogger();

            try
            {
                var param = new Params(configManager, jsonSerializer);

                new PrepareNotifierProcessorFactory().Create(NotifierProcessorType.NotifierProcessorDecoratorType).Prepare(
                    new HostFactoryNotifierProcessor.HostFactoryNotifierProcessor(new HostFactoryNotifierProcessorParams(param.Readers.ToArray(),
                                                                                                                         new NotificationsClientsManager(param.ClientsManagerParams), new NotificationFiltersValidator(), param.FiltersValidatorRepository,
                                                                                                                         new NotificationAggregatorsValidator(), param.AggregatorsValidatorRepository, logger, ConfigProvider.SendNotificationInterval)),
                    param.ExitReader, new NotificationsClientsManager(param.ClientsManagerParams), logger, ConfigProvider.ApplicationLifetime,
                    ConfigProvider.CheckApplicationLifetimeInterval);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Esempio n. 11
0
        private void PrepareReaders(ConfigManager.ConfigManager configManager)
        {
            Readers    = new List <INotificationDataReader>();
            ExitReader = null;

            if (configManager.Config.Readers is null)
            {
                return;
            }

            foreach (var reader in configManager.Config.Readers)
            {
                if (!reader.ReaderType.ToEnum <DataReaderType>().Equals(DataReaderType.ExitReader))
                {
                    var pDataReader = new PrepareDataReaderFactory().Create(reader.ReaderType.ToEnum <DataReaderType>());
                    Readers.Add(pDataReader.Prepare(reader, configManager));
                }
                else
                {
                    ExitReader = new PrepareDataReaderFactory().Create(reader.ReaderType.ToEnum <DataReaderType>())
                                 .Prepare(reader, configManager);
                }
            }
        }
Esempio n. 12
0
        private void PrepareAggregatorsValidatorRepository(ConfigManager.ConfigManager configManager)
        {
            if (configManager.Config.Aggregators is null || configManager.Config.AggregatorRules is null)
            {
                return;
            }

            var aggregators = new List <AAggregators>();

            foreach (var a in configManager.Config.Aggregators)
            {
                aggregators.Add(new Aggregators {
                    Id = a.AggregatorId, AggregationParams = a.AggregationParams
                });
            }

            AggregatorsValidatorRepository = new AggregatorsValidatorRepository {
                Aggregators = aggregators, Rules = new Dictionary <int, int[]>()
            };
            foreach (var aggregatorRules in configManager.Config.AggregatorRules)
            {
                AggregatorsValidatorRepository.Rules.Add(aggregatorRules.AggregatorId, aggregatorRules.ReaderId);
            }
        }
Esempio n. 13
0
        private void PrepareFiltersValidatorRepository(ConfigManager.ConfigManager configManager)
        {
            if (configManager.Config.Filters is null || configManager.Config.FilterRules is null)
            {
                return;
            }

            var filters = new List <AFilters>();

            foreach (var f in configManager.Config.Filters)
            {
                filters.Add(new Filters {
                    Id = f.FilterId, FilterParams = f.FilterParams
                });
            }

            FiltersValidatorRepository = new FiltersValidatorRepository {
                Filters = filters, Rules = new Dictionary <int, int[]>()
            };
            foreach (var filterRules in configManager.Config.FilterRules)
            {
                FiltersValidatorRepository.Rules.Add(filterRules.FilterId, filterRules.ReaderId);
            }
        }
Esempio n. 14
0
        public static INotificationDataReader Prepare(ConfigManager.Models.Reader reader, ConfigManager.ConfigManager configManager)
        {
            var databaseDataReaderParams = new DatabaseDataReaderParams {
                LogicalStorage = reader.LogicalName, TableName = reader.AdditionalParams.TableName, InitialCounter = reader.InitialCounter, MessageTypeColumnName = reader.AdditionalParams.MessageTypeColumnName, ColumnsNames = reader.ColumnNames
            };
            var setCounterReader = new Reader(configManager, reader.ReaderId);

            return(new DatabaseDataReader.DatabaseDataReader(reader.ConnectionString, databaseDataReaderParams, setCounterReader));
        }