Add run time to queue
This commit is contained in:
@@ -2,25 +2,23 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Hangfire;
|
||||
using log4net;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Utility;
|
||||
using LeafWeb.WebCms.App_Start;
|
||||
using LeafWeb.WebCms.Models;
|
||||
using LeafWeb.WebCms.Services;
|
||||
using LeafWeb.WebCms.Services.PiscalQueue;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace LeafWeb.WebCms.Controllers
|
||||
{
|
||||
[MemberAuthorize]
|
||||
public class QueueController : BaseController
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
var resultItems =
|
||||
DataService.GetLeafInputs()
|
||||
.OrderByDescending(f => f.Id)
|
||||
.ToList()
|
||||
.Select(leafInput => new QueueItemViewModel(leafInput));
|
||||
.OrderByDescending(f => f.Id);
|
||||
|
||||
string serviceDescription;
|
||||
try
|
||||
@@ -134,27 +132,16 @@ namespace LeafWeb.WebCms.Controllers
|
||||
return RedirectToUmbracoPage(LeafWebPageIds.ManageQueue);
|
||||
}
|
||||
|
||||
if (leafInput.IsPending)
|
||||
{
|
||||
LogManager.GetLogger(LoggerName(RouteData)).DebugFormat("LeafInput: {0}, Set Cancelled from Pending", leafInput.Id);
|
||||
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Cancelled,
|
||||
"Emailing cancellation notification to user",
|
||||
$"Email: \'{leafInput.Email}\'");
|
||||
var cancelPendingSuccess = new PiscalQueueManager().CancelPending(id);
|
||||
|
||||
// send notification immediately
|
||||
BackgroundJob.Enqueue<EmailNotificationService>(email => email.SendLeafWebCancelled(leafInput.Id));
|
||||
SetStatusMessage($"Cancelling LeafInput '{leafInput.Identifier}'", StatusType.Success);
|
||||
}
|
||||
else if (leafInput.IsRunning)
|
||||
if (cancelPendingSuccess)
|
||||
{
|
||||
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.CancelPending);
|
||||
SetStatusMessage($"Cancelling LeafInput '{leafInput.Identifier}'", StatusType.Success);
|
||||
HangfireStartup.TriggerPiscalProcessQueue();
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't allow to be cancelled if it isn't currently running
|
||||
SetStatusMessage($"LeafInput '{leafInput.Identifier}' is not currently running!", StatusType.Error);
|
||||
SetStatusMessage($"Couldn't cancel '{leafInput.Identifier}', is it currently running?", StatusType.Error);
|
||||
}
|
||||
return RedirectToCurrentUmbracoUrl();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user