Add run time to queue
This commit is contained in:
@@ -33,6 +33,10 @@ namespace LeafWeb.WebCms.Controllers
|
||||
if (!files.Any())
|
||||
ModelState.AddModelError("Files", "Must select at least one file");
|
||||
|
||||
// TODO: this keeps randomly not being mapable because string->bool binding fails. WHY
|
||||
if (ModelState.ContainsKey("TermsOfService"))
|
||||
ModelState["TermsOfService"].Errors.Clear();
|
||||
|
||||
if (ModelState.IsValid) // HttpParamMatch indicates it's backing out from Confirm
|
||||
{
|
||||
// convert viewModel into Model
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -12,14 +12,13 @@ namespace LeafWeb.WebCms.Controllers
|
||||
public ActionResult Index()
|
||||
{
|
||||
var dateThreshold = DateTime.Today.Subtract(TimeSpan.FromDays(90));
|
||||
var viewModel =
|
||||
var viewModel =
|
||||
(
|
||||
from li in DataService.GetLeafInputs()
|
||||
where li.Added >= dateThreshold
|
||||
orderby li.Id descending
|
||||
select li
|
||||
).ToList()
|
||||
.Select(leafInput => new QueueItemViewModel(leafInput));
|
||||
);
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user