public async Task RunAsync(ShippingLabelHandlerOptions options) { DateTime cutOfTmstmp; if (options.PointInTimeFile.Exists == false) { cutOfTmstmp = DateTime.Now.AddDays(-1); File.WriteAllText(options.PointInTimeFile.FullName, cutOfTmstmp.ToString("o")); } else { var rc = DateTime.TryParse(File.ReadAllText(options.PointInTimeFile.FullName), out cutOfTmstmp); if (rc == false) { throw new InvalidDataException($"Invalid data in {options.PointInTimeFile.FullName}"); } } var list = ProcessFiles(options, (labels) => (labels.First().Tmstmp > cutOfTmstmp), (reader) => _mapper.Map(reader)); if (list.Count() == 0) { _logger.LogWarning("No records found.."); } else { await _outputWriter.OutputAsync(options, list); File.WriteAllText(options.PointInTimeFile.FullName, list.Max(i => i.Tmstmp).ToString("o")); } }
public async Task RunAsync(OrderHandlerOptions options) { _logger.LogInformation("Input: {0}", options.InputFile.FullName); _logger.LogInformation("Output: {0}", options.OutputFile.FullName); _logger.LogInformation("Worksheet: {0}", options.WorksheetName); var list = ProcessFiles(options, (orders) => true, (reader) => _mapper.Map(reader, options.Delimiter)); _logger.LogInformation($"Writing file: {options.OutputFile.FullName}"); await _outputWriter.OutputAsync(options, list); }