Add debug tracing, email cleanup

This commit is contained in:
2016-04-13 10:48:32 -04:00
parent 123af4f44d
commit 064b86a37b
4 changed files with 38 additions and 10 deletions
+13 -3
View File
@@ -57,7 +57,10 @@ namespace LeafWeb.Web.Services
{
var runningLeafInputs = _dataService.GetLeafInputs(LeafInputStatusType.Running).ToList();
if (runningLeafInputs.Any())
{
logger.Trace("Leaf input currently running , don't enqueue any new");
return;
}
var pending =
_dataService
@@ -66,7 +69,10 @@ namespace LeafWeb.Web.Services
.FirstOrDefault();
if (pending == null)
{
logger.Trace("No pending leaf input");
return;
}
logger.Info("LeafInputFile: {0}, Start", pending.Id);
try
@@ -83,6 +89,7 @@ namespace LeafWeb.Web.Services
// TODO: re-queue?
//_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Queued, "Re-queuing LeafInput");
}
logger.Trace("LeafInputFile: {0}, Set Pending", pending.Id);
_dataService.SetLeafInputStatus(pending, LeafInputStatusType.Running);
}
@@ -98,7 +105,7 @@ namespace LeafWeb.Web.Services
{
case PiscalStatus.NotStarted:
logger.Warn("LeafInputFile: {0}, Not Started, re-queueing", leafInput.Id);
// if it's not started, try to requeue the process - unusual state
// if it's not started, try to requeue the process - this is unusual state
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Pending);
break;
@@ -111,6 +118,8 @@ namespace LeafWeb.Web.Services
logger.Info("LeafInputFile: {0}, Complete", leafInput.Id);
// collect the leaf output
var leafOutputFiles = _piscalService.RetrieveOutputFiles(leafInput).ToList();
logger.Trace("LeafInputFile: {0}, saving output files", leafInput.Id);
foreach (var outputFile in leafOutputFiles)
_dataService.AddLeafOutputFile(outputFile);
@@ -118,6 +127,7 @@ namespace LeafWeb.Web.Services
string.Join(", ", leafOutputFiles.Select(o => o.Filename)));
// update db
logger.Trace("LeafInputFile: {0}, Set Complete", leafInput.Id);
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Complete);
BackgroundJob.Enqueue(() => _emailService.SendLeafWebComplete(leafInput.Id));
@@ -128,9 +138,9 @@ namespace LeafWeb.Web.Services
break;
}
}
catch (PiscalClientException ex)
catch (Exception ex)
{
logger.Error("LeafInputFile: {0}, ProcessRunning Exception: {1}", leafInput.Id, ex.Message);
logger.Error("LeafInputFile: {0}, ProcessRunning Exception: {1}\r\n{2}\r\n{3}", leafInput.Id, ex.Message, ex.InnerException, ex.StackTrace);
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Exception, "Error occurred processing LeafInput", ex.Message);
// TODO: Send email