private async Task <EventLogReaderSettings> GetReaderSettingsAsync(CancellationToken cancellationToken = default) { var eventLogReaderSettings = new EventLogReaderSettings { LogFolder = _logFolder, LiveMode = true, ReadingTimeout = _readingTimeout * 1000, TimeZone = _timeZone }; if (!_loadArchive) { var position = await _storage.ReadEventLogPositionAsync(cancellationToken); if (position != null) { var lgpFilePath = Path.Combine(_logFolder, position.FileName); if (!File.Exists(lgpFilePath)) { _logger?.LogWarning( $"Lgp file ({lgpFilePath}) doesn't exist. The reading will be started from the first found file"); } else { eventLogReaderSettings.LgpFileName = position.FileName; eventLogReaderSettings.LgpStartPosition = position.EndPosition; eventLogReaderSettings.LgfStartPosition = position.LgfEndPosition; eventLogReaderSettings.ItemId = position.Id; _logger?.LogInformation( $"File {position.FileName} will be read from {position.EndPosition} position, LGF file will be read from {position.LgfEndPosition} position"); } } else { _logger?.LogInformation( "There're no log items in the database, first found log file will be read from 0 position"); } } else { _logger?.LogWarning("LoadArchive parameter is true. Live mode will not be used"); eventLogReaderSettings.LiveMode = false; } return(eventLogReaderSettings); }
private async Task <EventLogReaderSetings> GetReaderSettingsAsync(CancellationToken cancellationToken = default) { var eventLogReaderSettings = new EventLogReaderSetings { LogFolder = _logFolder, LiveMode = true, ReadingTimeout = 1000, TimeZone = _timeZone }; if (!_loadArchive) { (string FileName, long EndPosition, long LgfEndPosition) = await _storage.ReadEventLogPositionAsync(cancellationToken); if (FileName != string.Empty) { var lgpFilePath = Path.Combine(_logFolder, FileName); if (!File.Exists(lgpFilePath)) { _logger.LogWarning($"Lgp file ({lgpFilePath}) doesn't exist. The reading will be started from the first found file"); } else { eventLogReaderSettings.LgpFileName = FileName; eventLogReaderSettings.StartPosition = EndPosition; eventLogReaderSettings.LgpStartPosition = LgfEndPosition; } } } else { eventLogReaderSettings.LiveMode = false; } return(eventLogReaderSettings); }