2023-01-06 15:08:26 +00:00
|
|
|
|
using DTO;
|
|
|
|
|
using static Configuration.ApplicationConfigurationService;
|
2023-01-04 17:53:48 +00:00
|
|
|
|
|
|
|
|
|
namespace OrderParser
|
2023-01-04 12:41:53 +00:00
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2023-01-04 17:53:48 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2023-01-06 15:08:26 +00:00
|
|
|
|
var filesInfoConfig = Configuration.ApplicationConfigurationService.InitializeFrom(args);
|
|
|
|
|
var csvFileWriter = new CsvFileWriterService(filesInfoConfig.OutputFile);
|
2023-01-04 17:53:48 +00:00
|
|
|
|
|
|
|
|
|
foreach (var jsonFile in filesInfoConfig.JsonFilesInfo)
|
|
|
|
|
{
|
2023-01-06 15:08:26 +00:00
|
|
|
|
// Could have easily been another service, but only do that when it needs to be scaled.
|
2023-01-04 22:32:29 +00:00
|
|
|
|
var orderDTO = Newtonsoft.Json.JsonConvert.DeserializeObject<OrderDto>(File.ReadAllText(jsonFile.FullName));
|
|
|
|
|
|
|
|
|
|
var orderModel = new OrderModel(orderDTO);
|
2023-01-04 17:53:48 +00:00
|
|
|
|
|
|
|
|
|
csvFileWriter.writeOutRow(orderModel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (DemoApplicationConfigurationException e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
|
}
|
2023-01-04 12:41:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|