Add debug tracing, email cleanup
This commit is contained in:
@@ -14,7 +14,7 @@ namespace LeafWeb.Web.App_Start
|
|||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: "Default",
|
name: "Default",
|
||||||
url: "{controller}/{action}/{id}",
|
url: "{controller}/{action}/{id}",
|
||||||
defaults: new { controller = "Pages", action = "Index", id = UrlParameter.Optional }
|
defaults: new { controller = "LeafInput", action = "Index", id = UrlParameter.Optional }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,12 @@ namespace LeafWeb.Web.Services
|
|||||||
leafInput.OutputFiles
|
leafInput.OutputFiles
|
||||||
select Tuple.Create(outputFile, new MemoryStream(outputFile.Contents))).ToList();
|
select Tuple.Create(outputFile, new MemoryStream(outputFile.Contents))).ToList();
|
||||||
|
|
||||||
var body = $"Your leaf analysis job, {leafInput.Identifier}, has completed." + Environment.NewLine;
|
var body = $"Your leaf analysis job, {leafInput.Identifier}, has completed. ";
|
||||||
if (leafInput.OutputWarningMessage != null)
|
|
||||||
body += "The following warning message was generated."
|
body += FormatWarningMessage(leafInput);
|
||||||
+ Environment.NewLine + Environment.NewLine
|
|
||||||
+ leafInput.OutputWarningMessage.Contents.GetString()
|
|
||||||
+ Environment.NewLine;
|
|
||||||
body += "Please see the attached results.";
|
body += "Please see the attached results.";
|
||||||
|
|
||||||
var message = new MailMessage(_emaialFromAddress, leafInput.Email, "LeafWeb results", body);
|
var message = new MailMessage(_emaialFromAddress, leafInput.Email, "LeafWeb results", body);
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -95,10 +94,24 @@ namespace LeafWeb.Web.Services
|
|||||||
+ errorMessage
|
+ errorMessage
|
||||||
+ Environment.NewLine + Environment.NewLine
|
+ Environment.NewLine + Environment.NewLine
|
||||||
+ "You will need to correct your input and resubmit.";
|
+ "You will need to correct your input and resubmit.";
|
||||||
|
|
||||||
|
body += FormatWarningMessage(leafInput);
|
||||||
|
|
||||||
var message = new MailMessage(_emaialFromAddress, leafInput.Email, "LeafWeb processing error", body);
|
var message = new MailMessage(_emaialFromAddress, leafInput.Email, "LeafWeb processing error", body);
|
||||||
SendMessage(message);
|
SendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string FormatWarningMessage(LeafInput leafInput)
|
||||||
|
{
|
||||||
|
if (leafInput.OutputWarningMessage != null)
|
||||||
|
return Environment.NewLine + Environment.NewLine
|
||||||
|
+ "The following warning message was generated."
|
||||||
|
+ Environment.NewLine + Environment.NewLine
|
||||||
|
+ leafInput.OutputWarningMessage.Contents.GetString()
|
||||||
|
+ Environment.NewLine;
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
private void SendMessage(MailMessage mailMessage)
|
private void SendMessage(MailMessage mailMessage)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ namespace LeafWeb.Web.Services
|
|||||||
{
|
{
|
||||||
var runningLeafInputs = _dataService.GetLeafInputs(LeafInputStatusType.Running).ToList();
|
var runningLeafInputs = _dataService.GetLeafInputs(LeafInputStatusType.Running).ToList();
|
||||||
if (runningLeafInputs.Any())
|
if (runningLeafInputs.Any())
|
||||||
|
{
|
||||||
|
logger.Trace("Leaf input currently running , don't enqueue any new");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var pending =
|
var pending =
|
||||||
_dataService
|
_dataService
|
||||||
@@ -66,7 +69,10 @@ namespace LeafWeb.Web.Services
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (pending == null)
|
if (pending == null)
|
||||||
|
{
|
||||||
|
logger.Trace("No pending leaf input");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
logger.Info("LeafInputFile: {0}, Start", pending.Id);
|
logger.Info("LeafInputFile: {0}, Start", pending.Id);
|
||||||
try
|
try
|
||||||
@@ -83,6 +89,7 @@ namespace LeafWeb.Web.Services
|
|||||||
// TODO: re-queue?
|
// TODO: re-queue?
|
||||||
//_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Queued, "Re-queuing LeafInput");
|
//_dataService.SetLeafInputFileStatus(queuedFile, LeafInputStatusType.Queued, "Re-queuing LeafInput");
|
||||||
}
|
}
|
||||||
|
logger.Trace("LeafInputFile: {0}, Set Pending", pending.Id);
|
||||||
_dataService.SetLeafInputStatus(pending, LeafInputStatusType.Running);
|
_dataService.SetLeafInputStatus(pending, LeafInputStatusType.Running);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +105,7 @@ namespace LeafWeb.Web.Services
|
|||||||
{
|
{
|
||||||
case PiscalStatus.NotStarted:
|
case PiscalStatus.NotStarted:
|
||||||
logger.Warn("LeafInputFile: {0}, Not Started, re-queueing", leafInput.Id);
|
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);
|
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Pending);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -111,6 +118,8 @@ namespace LeafWeb.Web.Services
|
|||||||
logger.Info("LeafInputFile: {0}, Complete", leafInput.Id);
|
logger.Info("LeafInputFile: {0}, Complete", leafInput.Id);
|
||||||
// collect the leaf output
|
// collect the leaf output
|
||||||
var leafOutputFiles = _piscalService.RetrieveOutputFiles(leafInput).ToList();
|
var leafOutputFiles = _piscalService.RetrieveOutputFiles(leafInput).ToList();
|
||||||
|
|
||||||
|
logger.Trace("LeafInputFile: {0}, saving output files", leafInput.Id);
|
||||||
foreach (var outputFile in leafOutputFiles)
|
foreach (var outputFile in leafOutputFiles)
|
||||||
_dataService.AddLeafOutputFile(outputFile);
|
_dataService.AddLeafOutputFile(outputFile);
|
||||||
|
|
||||||
@@ -118,6 +127,7 @@ namespace LeafWeb.Web.Services
|
|||||||
string.Join(", ", leafOutputFiles.Select(o => o.Filename)));
|
string.Join(", ", leafOutputFiles.Select(o => o.Filename)));
|
||||||
|
|
||||||
// update db
|
// update db
|
||||||
|
logger.Trace("LeafInputFile: {0}, Set Complete", leafInput.Id);
|
||||||
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Complete);
|
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Complete);
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _emailService.SendLeafWebComplete(leafInput.Id));
|
BackgroundJob.Enqueue(() => _emailService.SendLeafWebComplete(leafInput.Id));
|
||||||
@@ -128,9 +138,9 @@ namespace LeafWeb.Web.Services
|
|||||||
break;
|
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);
|
_dataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Exception, "Error occurred processing LeafInput", ex.Message);
|
||||||
|
|
||||||
// TODO: Send email
|
// TODO: Send email
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
@model LeafWeb.Web.ViewModels.LeafInput.CreateViewModel
|
@model LeafWeb.Web.ViewModels.LeafInput.CreateViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Submit Data";
|
||||||
|
}
|
||||||
|
|
||||||
@section Styles
|
@section Styles
|
||||||
{
|
{
|
||||||
@Styles.Render("~/backload/blueimp/bootstrap/BasicPlusUI/css")
|
@Styles.Render("~/backload/blueimp/bootstrap/BasicPlusUI/css")
|
||||||
|
|||||||
Reference in New Issue
Block a user