Add parsing for LeafInputData after retrieving CleanedInput files

This commit is contained in:
2016-05-19 07:45:53 -04:00
parent 77ae03534e
commit cff6a0d96f
18 changed files with 433 additions and 8 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
using System.Linq;
using System.Web.Mvc;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
using LeafWeb.Web.Attributes;
using LeafWeb.Web.ViewModels.Results;
@@ -26,7 +27,7 @@ namespace LeafWeb.Web.Controllers
if (leafInput == null)
return View("DownloadNotFound");
var zip = leafInput.GetOutputFileZip();
var zip = leafInput.GetOutputFileZip(LeafOutputFileType.ToUser);
var filename = leafInput.Identifier.FilterValidFilename() + ".zip";
@@ -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}");
}
}
}
}