Email notification for LeafWeb jobs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Hangfire;
|
||||
using LeafWeb.Core.DAL;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Remote;
|
||||
@@ -12,14 +13,16 @@ namespace LeafWeb.Web.Services
|
||||
{
|
||||
private readonly DataService _dataService;
|
||||
private readonly PiscalService _piscalService;
|
||||
private readonly EmailNotificationService _emailService;
|
||||
|
||||
public PiscalQueueManager(DataService dataService, PiscalService piscalService)
|
||||
public PiscalQueueManager(DataService dataService, PiscalService piscalService, EmailNotificationService emailService)
|
||||
{
|
||||
_dataService = dataService;
|
||||
_piscalService = piscalService;
|
||||
_emailService = emailService;
|
||||
}
|
||||
|
||||
public PiscalQueueManager() : this(new DataService(), new PiscalService()) {}
|
||||
public PiscalQueueManager() : this(new DataService(), new PiscalService(), new EmailNotificationService()) {}
|
||||
|
||||
private static readonly object ProcessQueueLock = new object();
|
||||
|
||||
@@ -109,6 +112,8 @@ namespace LeafWeb.Web.Services
|
||||
// update db
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Complete);
|
||||
|
||||
BackgroundJob.Enqueue(() => _emailService.SendLeafWebSuccess(file.Id));
|
||||
|
||||
// remove working data from the server
|
||||
logger.Info("LeafInputFile: {0}, Cleanup", file.Id);
|
||||
_piscalService.Cleanup(file);
|
||||
@@ -127,6 +132,12 @@ namespace LeafWeb.Web.Services
|
||||
logger.Info("LeafInputFile: {0}, Error Message: {1}", file.Id, errorMessage);
|
||||
|
||||
_dataService.SetLeafInputFileStatus(file, LeafInputStatusType.Error, errorMessage);
|
||||
|
||||
BackgroundJob.Enqueue(() => _emailService.SendLeafWebError(file.Id, errorMessage));
|
||||
|
||||
// remove working data from the server
|
||||
logger.Info("LeafInputFile: {0}, Cleanup", file.Id);
|
||||
_piscalService.Cleanup(file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user