Add run time to queue

This commit is contained in:
2017-01-27 14:07:36 -05:00
parent 4338b4fee5
commit 0711ae0ac8
24 changed files with 198 additions and 209 deletions
@@ -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
+6 -19
View File
@@ -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();
}
+2 -3
View File
@@ -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);
}