static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }

            string dataDirectoryPath = args[0];

            Console.WriteLine($"{DateTime.Now}: Инициализация чтения логов \"{dataDirectoryPath}\"...");

            using (EventLogReader reader = EventLogReader.CreateReader(dataDirectoryPath))
            {
                reader.AfterReadEvent  += Reader_AfterReadEvent;
                reader.AfterReadFile   += Reader_AfterReadFile;
                reader.BeforeReadEvent += Reader_BeforeReadEvent;
                reader.BeforeReadFile  += Reader_BeforeReadFile;
                reader.OnErrorEvent    += Reader_OnErrorEvent;

                Console.WriteLine($"{DateTime.Now}: Всего событий к обработке: ({reader.Count()})...");
                Console.WriteLine();
                Console.WriteLine();

                while (reader.Read())
                {
                    // reader.CurrentRow - данные текущего события
                    _eventNumber += 1;
                }
            }

            Console.WriteLine($"{DateTime.Now}: Для выхода нажмите любую клавишу...");
            Console.ReadKey();
        }
        private void GetAndSetPosition_Test(string eventLogPath)
        {
            long countRecords           = 0;
            long countRecordsStepByStep = 0;
            long countRecordsStepByStepAfterSetPosition = 0;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogPath))
            {
                countRecords = reader.Count();

                while (reader.Read())
                {
                    countRecordsStepByStep += 1;
                }

                reader.Reset();
                EventLogPosition position = reader.GetCurrentPosition();
                while (reader.Read())
                {
                    ;
                }
                reader.SetCurrentPosition(position);
                while (reader.Read())
                {
                    countRecordsStepByStepAfterSetPosition += 1;
                }
            }

            Assert.NotEqual(0, countRecords);
            Assert.NotEqual(0, countRecordsStepByStep);
            Assert.NotEqual(0, countRecordsStepByStepAfterSetPosition);
            Assert.Equal(countRecords, countRecordsStepByStep);
            Assert.Equal(countRecords, countRecordsStepByStepAfterSetPosition);
        }
        private void ExportToPostgreSQL(EventLogExportSettings eventLogSettings)
        {
            EventLogOnPostgreSQL target = new EventLogOnPostgreSQL(_optionsBuilder.Options, eventLogSettings.Portion);

            target.SetInformationSystem(new InformationSystemsBase()
            {
                Name        = eventLogSettings.InforamtionSystemName,
                Description = eventLogSettings.InforamtionSystemDescription
            });

            ExportHelper.ExportToTargetStorage(eventLogSettings, target);

            long rowsInDB;

            using (EventLogContext context = EventLogContext.Create(_optionsBuilder.Options, _settings.DBMSActions))
            {
                var informationSystem = context.InformationSystems
                                        .First(i => i.Name == eventLogSettings.InforamtionSystemName);
                var getCount = context.RowsData
                               .Where(r => r.InformationSystemId == informationSystem.Id)
                               .LongCountAsync();
                getCount.Wait();
                rowsInDB = getCount.Result;
            }

            long rowsInSourceFiles;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogSettings.EventLogPath))
                rowsInSourceFiles = reader.Count();

            Assert.NotEqual(0, rowsInSourceFiles);
            Assert.NotEqual(0, rowsInDB);
            Assert.Equal(rowsInSourceFiles, rowsInDB);
        }
        private void ExportToClickHouse(EventLogExportSettings eventLogSettings)
        {
            Console.WriteLine(_settings.ConnectionString);

            ClickHouseHelpers.DropDatabaseIfExist(_settings.ConnectionString);

            EventLogOnClickHouse target = new EventLogOnClickHouse(_settings.ConnectionString, eventLogSettings.Portion);

            target.SetInformationSystem(new InformationSystemsBase()
            {
                Name        = eventLogSettings.InforamtionSystemName,
                Description = eventLogSettings.InforamtionSystemDescription
            });

            ExportHelper.ExportToTargetStorage(eventLogSettings, target);

            long rowsInDB;

            using (var connection = new ClickHouseConnection(_settings.ConnectionString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText =
                        @"SELECT 
                            COUNT(*) CNT 
                        FROM RowsData rd
                        WHERE InformationSystem = {InformationSystem:String}";
                    cmd.Parameters.Add(new ClickHouseDbParameter
                    {
                        ParameterName = "InformationSystem",
                        Value         = eventLogSettings.InforamtionSystemName
                    });
                    using (var cmdReader = cmd.ExecuteReader())
                    {
                        if (cmdReader.Read())
                        {
                            rowsInDB = Convert.ToInt64(cmdReader.GetValue(0));
                        }
                        else
                        {
                            rowsInDB = 0;
                        }
                    }
                }
            }

            long rowsInSourceFiles;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogSettings.EventLogPath))
                rowsInSourceFiles = reader.Count();

            Assert.NotEqual(0, rowsInSourceFiles);
            Assert.NotEqual(0, rowsInDB);
            Assert.Equal(rowsInSourceFiles, rowsInDB);
        }
        private void ExportToElasticSearch(EventLogExportSettingsForElasticSearch eventLogSettings)
        {
            ConnectionSettings elasticSettings = new ConnectionSettings(eventLogSettings.NodeAddress)
                                                 .DefaultIndex(eventLogSettings.IndexName)
                                                 .MaximumRetries(eventLogSettings.MaximumRetries)
                                                 .MaxRetryTimeout(TimeSpan.FromSeconds(eventLogSettings.MaxRetryTimeout));

            EventLogOnElasticSearch target = new EventLogOnElasticSearch(elasticSettings, eventLogSettings.Portion);

            target.SetInformationSystem(new InformationSystemsBase()
            {
                Name        = eventLogSettings.InforamtionSystemName,
                Description = eventLogSettings.InforamtionSystemDescription
            });
            target.SetIndexName(eventLogSettings.IndexName);
            target.SetIndexSeparationPeriod(eventLogSettings.IndexSeparation);

            ElasticClient client     = new ElasticClient(elasticSettings);
            var           allIndices = client.Indices.Get(new GetIndexRequest(Indices.All));

            foreach (var indexInfo in allIndices.Indices)
            {
                if (indexInfo.Key.Name.StartsWith(eventLogSettings.IndexName))
                {
                    client.Indices.Delete(indexInfo.Key.Name);
                }
            }

            ExportHelperForElasticSearch.ExportToTargetStorage(eventLogSettings, target);

            Thread.Sleep(30000);

            long   rowsInES = 0;
            string indexNameLGF_WithData = $"{eventLogSettings.IndexName}-logdata";
            var    allIndicesCheckData   = client.Indices.Get(new GetIndexRequest(Indices.All));

            foreach (var indexInfo in allIndicesCheckData.Indices)
            {
                if (indexInfo.Key.Name.StartsWith(indexNameLGF_WithData))
                {
                    var countResponse = client.Count <LogDataElement>(c => c
                                                                      .Index(indexInfo.Key.Name));
                    rowsInES += countResponse.Count;
                }
            }

            long rowsInSourceFiles;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogSettings.EventLogPath))
                rowsInSourceFiles = reader.Count();

            Assert.NotEqual(0, rowsInSourceFiles);
            Assert.NotEqual(0, rowsInES);
            Assert.Equal(rowsInSourceFiles, rowsInES);
        }
        private void GetCount_Test(string eventLogPath)
        {
            long countRecords           = 0;
            long countRecordsStepByStep = 0;

            using (EventLogReader reader = EventLogReader.CreateReader(eventLogPath))
            {
                countRecords = reader.Count();

                while (reader.Read())
                {
                    countRecordsStepByStep += 1;
                }
            }

            Assert.NotEqual(0, countRecords);
            Assert.NotEqual(0, countRecordsStepByStep);
            Assert.Equal(countRecords, countRecordsStepByStep);
        }