Add output file type, collect all files

This commit is contained in:
2016-05-18 13:05:24 -04:00
parent 4343f08733
commit 77ae03534e
19 changed files with 288 additions and 48 deletions
+11
View File
@@ -19,6 +19,7 @@ namespace LeafWeb.Web.Services
private const string EmailSuccessSubject = "LeafWeb Results";
private const string EmailErrorSubject = "LeafWeb processing error";
private const string EmailSystemErrorSubject = "LeafWeb system error";
/// <summary>
/// Comma separated values
@@ -134,6 +135,16 @@ namespace LeafWeb.Web.Services
SendMessage(message);
}
public void SendLeafWebSystemException(string leafInputIdentifier, string leafInputEmail)
{
var body = $"A system error occured while processing your leaf analysis job, {leafInputIdentifier}." + Environment.NewLine
+ "System administrators have been notified. You will be notified again when the system error "
+ "has been resolved and your data has been processed.";
var message = new MailMessage(_emailFromAddress, leafInputEmail, EmailSystemErrorSubject, body);
SendMessage(message);
}
private string FormatWarningMessage(LeafInput leafInput)
{
if (leafInput.OutputWarningMessage != null)
+10 -6
View File
@@ -31,24 +31,28 @@ namespace LeafWeb.Web.Services.PiscalQueue
protected PiscalQueueBase() : this(new DataService(), new PiscalService()) { }
protected string FormatException(Exception ex, int leafInputId)
protected string FormatException(Exception ex)
{
return
$"LeafInput: {leafInputId}{Environment.NewLine}" +
(ex is PiscalClientException ? $"LeafInput: {((PiscalClientException) ex).LeafInputId}{Environment.NewLine}" : "") +
$"Class: {GetType().Name}{Environment.NewLine}" +
$"Exception: {ex.Message}{Environment.NewLine}" +
$"Exception message: {ex.Message}{Environment.NewLine}" +
(ex.InnerException != null ? $"InnerException: {ex.InnerException}{Environment.NewLine}" : string.Empty)
+ $"StackTrace: {ex.StackTrace}";
}
protected void PiscalExceptionHandle(PiscalClientException ex, LeafInput leafInput)
protected void PiscalExceptionHandler(PiscalClientException ex, LeafInput leafInput)
{
var errorMessage = FormatException(ex, ex.LeafInputId);
var errorMessage = FormatException(ex);
Logger.Error(errorMessage);
// send admin an email
BackgroundJobEnqueueRetry<EmailNotificationService>(
email => email.SendAdministratorMessage($"LeafWeb: PiscalQueue {GetType().Name} Exception", errorMessage));
// TODO send user email too
// send user email too
BackgroundJobEnqueueRetry<EmailNotificationService>(
email => email.SendLeafWebSystemException(leafInput.Identifier, leafInput.Email));
if (leafInput != null)
{
@@ -88,7 +88,7 @@ namespace LeafWeb.Web.Services.PiscalQueue
}
catch (Exception ex)
{
var errorMessage = FormatException(ex, pendingInputId);
var errorMessage = FormatException(ex);
Logger.Error(errorMessage);
DataService.SetLeafInputStatus(pendingInput, LeafInputStatusType.Exception, ex.Message, errorMessage);
}
@@ -124,11 +124,11 @@ namespace LeafWeb.Web.Services.PiscalQueue
}
catch (PiscalClientException ex)
{
PiscalExceptionHandle(ex, leafInput);
PiscalExceptionHandler(ex, leafInput);
}
catch (Exception ex)
{
var errorMessage = FormatException(ex, leafInput.Id);
var errorMessage = FormatException(ex);
Logger.Error(errorMessage);
}
}
@@ -16,19 +16,14 @@ namespace LeafWeb.Web.Services.PiscalQueue
}
catch (PiscalClientException ex)
{
PiscalExceptionHandle(ex, leafInput);
PiscalExceptionHandler(ex, leafInput);
if (leafInput != null)
{
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Exception, "Error occurred processing LeafInput",
ex.Message);
}
// signal to process next item
HangfireStartup.TriggerPiscalProcessQueue();
}
catch (Exception ex)
{
var errorMessage = FormatException(ex, leafInputId);
var errorMessage = FormatException(ex);
Logger.Error(errorMessage);
throw; // this will retry via HangFire
}