|
|
|
@@ -34,13 +34,23 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
|
|
|
|
|
protected string FormatException(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
(ex is PiscalClientException ? $"LeafInput: {((PiscalClientException) ex).LeafInputId}{Environment.NewLine}" : "") +
|
|
|
|
|
(ex is PiscalClientException ? $"LeafInputId: {((PiscalClientException) ex).LeafInputId}{Environment.NewLine}" : "") +
|
|
|
|
|
$"Class: {GetType().Name}{Environment.NewLine}" +
|
|
|
|
|
$"Exception message: {ex.Message}{Environment.NewLine}" +
|
|
|
|
|
(ex.InnerException != null ? $"InnerException: {ex.InnerException}{Environment.NewLine}" : string.Empty)
|
|
|
|
|
+ $"StackTrace: {ex.StackTrace}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected string FormatLeafInputInfo(LeafInput leafInput)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
$"User name: {leafInput.Name}{Environment.NewLine}" +
|
|
|
|
|
$"User email: {leafInput.Email}{Environment.NewLine}" +
|
|
|
|
|
$"Identifier: {leafInput.Identifier}{Environment.NewLine}" +
|
|
|
|
|
$"Site Id: {leafInput.SiteId}{Environment.NewLine}" +
|
|
|
|
|
$"Photosynthesis Type: {leafInput.PhotosynthesisType}{Environment.NewLine}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void PiscalExceptionHandler(PiscalClientException ex, LeafInput leafInput)
|
|
|
|
|
{
|
|
|
|
|
var errorMessage = FormatException(ex);
|
|
|
|
@@ -48,7 +58,13 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
|
|
|
|
|
|
|
|
|
|
// send admin an email
|
|
|
|
|
BackgroundJobEnqueueRetry<EmailNotificationService>(
|
|
|
|
|
email => email.SendAdministratorMessage($"LeafWeb: PiscalQueue {GetType().Name} Exception", errorMessage));
|
|
|
|
|
email => email.SendAdministratorMessage(
|
|
|
|
|
$"LeafWeb: PiscalQueue {GetType().Name} Exception",
|
|
|
|
|
"Piscal exception reported. LeafInput info:" + Environment.NewLine
|
|
|
|
|
+ FormatLeafInputInfo(leafInput)
|
|
|
|
|
+ Environment.NewLine
|
|
|
|
|
+ "ErrorMessage:" + Environment.NewLine
|
|
|
|
|
+ errorMessage));
|
|
|
|
|
|
|
|
|
|
// send user email too
|
|
|
|
|
BackgroundJobEnqueueRetry<EmailNotificationService>(
|
|
|
|
@@ -67,7 +83,13 @@ namespace LeafWeb.WebCms.Services.PiscalQueue
|
|
|
|
|
|
|
|
|
|
// send admin an email
|
|
|
|
|
BackgroundJobEnqueueRetry<EmailNotificationService>(
|
|
|
|
|
email => email.SendAdministratorMessage($"LeafWeb: PiscalQueue {GetType().Name} Warning", warningMessage));
|
|
|
|
|
email => email.SendAdministratorMessage(
|
|
|
|
|
$"LeafWeb: PiscalQueue {GetType().Name} Warning",
|
|
|
|
|
"Piscal warning reported. LeafInput info:" + Environment.NewLine
|
|
|
|
|
+ FormatLeafInputInfo(leafInput)
|
|
|
|
|
+ Environment.NewLine
|
|
|
|
|
+ "Warning message:" + Environment.NewLine
|
|
|
|
|
+ warningMessage));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|