Submit all LeafInputFiles together

This commit is contained in:
2016-03-28 10:20:50 -04:00
parent 4b2757b19a
commit 9e86b92f08
29 changed files with 353 additions and 268 deletions
+16 -16
View File
@@ -55,39 +55,39 @@ namespace LeafWeb.Web.Services
private void ProcessQueue(ILogger logger)
{
var runningLeafInputFiles = _dataService.GetLeafInputFiles(LeafInputStatusType.Running).ToList();
if (runningLeafInputFiles.Any())
var runningLeafInputs = _dataService.GetLeafInputs(LeafInputStatusType.Running).ToList();
if (runningLeafInputs.Any())
return;
var queuedFile =
var pending =
_dataService
.GetLeafInputFiles(LeafInputStatusType.Queued)
.GetLeafInputs(LeafInputStatusType.Pending)
.OrderBy(l => l.StatusHistory.Min(sh => sh.DateTime))
.FirstOrDefault();
if (queuedFile == null)
if (pending == null)
return;
logger.Info("LeafInputFile: {0}, Start", queuedFile.Id);
logger.Info("LeafInputFile: {0}, Start", pending.Id);
try
{
_piscalService.Run(queuedFile);
_piscalService.Run(pending);
}
catch (PiscalClientException ex)
{
logger.Error("LeafInputFile: {0}, ProcessQueue Exception: {1}", queuedFile.Id, ex.Message);
_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Error, "Error occurred submitting LeafInput");
logger.Error("LeafInputFile: {0}, ProcessQueue Exception: {1}", pending.Id, ex.Message);
_dataService.SetLeafInputStatus(pending, LeafInputStatusType.Error, "Error occurred submitting LeafInput");
// TODO: re-queue
//_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Queued, "Re-queuing LeafInput");
}
_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Running);
_dataService.SetLeafInputStatus(pending, LeafInputStatusType.Running);
}
private void ProcessRunning(ILogger logger)
{
var runningLeafInputFiles = _dataService.GetLeafInputFiles(LeafInputStatusType.Running).ToList();
foreach (var file in runningLeafInputFiles)
var running = _dataService.GetLeafInputs(LeafInputStatusType.Running).ToList();
foreach (var file in running)
{
var status = _piscalService.GetStatus(file);
try
@@ -110,7 +110,7 @@ namespace LeafWeb.Web.Services
string.Join(", ", leafOutputFiles.Select(o => o.Filename)));
// update db
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Complete);
_dataService.SetLeafInputStatus(file, LeafInputStatusType.Complete);
BackgroundJob.Enqueue(() => _emailService.SendLeafWebSuccess(file.Id));
@@ -122,7 +122,7 @@ namespace LeafWeb.Web.Services
case PiscalStatus.NotStarted:
logger.Warn("LeafInputFile: {0}, Not Started, re-queueing", file.Id);
// if it's not started, try to requeue the process - unusual state
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Queued);
_dataService.SetLeafInputStatus(file, LeafInputStatusType.Pending);
break;
case PiscalStatus.Error:
@@ -131,7 +131,7 @@ namespace LeafWeb.Web.Services
var errorMessage = _piscalService.GetErrorMessage(file);
logger.Info("LeafInputFile: {0}, Error Message: {1}", file.Id, errorMessage);
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Error, errorMessage);
_dataService.SetLeafInputStatus(file, LeafInputStatusType.Error, errorMessage);
BackgroundJob.Enqueue(() => _emailService.SendLeafWebError(file.Id, errorMessage));
@@ -144,7 +144,7 @@ namespace LeafWeb.Web.Services
catch (PiscalClientException ex)
{
logger.Error("LeafInputFile: {0}, ProcessRunning Exception: {1}", file.Id, ex.Message);
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Error, "Error occurred processing LeafInput");
_dataService.SetLeafInputStatus(file, LeafInputStatusType.Error, "Error occurred processing LeafInput");
// TODO: re-queue
}