Add parsing for LeafInputData after retrieving CleanedInput files
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Parsers;
|
||||
|
||||
namespace LeafWeb.Web.Services.PiscalQueue
|
||||
{
|
||||
@@ -16,7 +18,13 @@ namespace LeafWeb.Web.Services.PiscalQueue
|
||||
foreach (var outputFile in leafOutputFiles)
|
||||
{
|
||||
if (leafInput.OutputFiles.All(file => file.Filename != outputFile.Filename))
|
||||
{
|
||||
DataService.AddLeafOutputFile(outputFile);
|
||||
|
||||
// parse cleaned input file data
|
||||
if (outputFile.FileType == LeafOutputFileType.CleanedInput)
|
||||
AddLeafInputData(outputFile, leafInput);
|
||||
}
|
||||
else
|
||||
Logger.Warn("LeafInput: {0}, RetrieveOutputFiles duplicate file name: {1}", leafInput.Id, outputFile.Filename);
|
||||
}
|
||||
@@ -34,5 +42,22 @@ namespace LeafWeb.Web.Services.PiscalQueue
|
||||
|
||||
HangfireStartup.TriggerPiscalProcessQueue();
|
||||
}
|
||||
|
||||
private void AddLeafInputData(LeafOutputFile outputFile, LeafInput leafInput)
|
||||
{
|
||||
try
|
||||
{
|
||||
var parser = new LeafInputCsvParser(outputFile.Contents);
|
||||
var data = parser.Parse();
|
||||
data.LeafInput = leafInput;
|
||||
data.LeafOutputFile = outputFile;
|
||||
leafInput.LeafInputData.Add(data);
|
||||
DataService.UpdateLeafInput(leafInput);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $"LeafInput: {leafInput.Id}, while parsing CleanedInput file: {outputFile.Filename}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user