add params for filtering LeafInputs
This commit is contained in:
+2
-13
@@ -50,22 +50,11 @@ namespace LeafWeb.Core.DAL
|
||||
return _db.LeafInputs.FirstOrDefault(li => li.Id == id);
|
||||
}
|
||||
|
||||
public IQueryable<LeafInput> GetLeafInputs(LeafInputStatusType status)
|
||||
public IQueryable<LeafInput> GetLeafInputs(params LeafInputStatusType[] statuses)
|
||||
{
|
||||
return
|
||||
from file in _db.LeafInputs
|
||||
where file.CurrentStatus == status
|
||||
select file;
|
||||
}
|
||||
|
||||
public IQueryable<LeafInput> GetRunningLeafInputs()
|
||||
{
|
||||
return
|
||||
from file in _db.LeafInputs
|
||||
where
|
||||
file.CurrentStatus == LeafInputStatusType.Running ||
|
||||
file.CurrentStatus == LeafInputStatusType.Starting ||
|
||||
file.CurrentStatus == LeafInputStatusType.Finishing
|
||||
where statuses.Contains(file.CurrentStatus)
|
||||
select file;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using Hangfire;
|
||||
using LeafWeb.Core.Entities;
|
||||
using LeafWeb.Core.Remote;
|
||||
using Polly;
|
||||
|
||||
namespace LeafWeb.Web.Services
|
||||
{
|
||||
@@ -40,10 +37,29 @@ namespace LeafWeb.Web.Services
|
||||
Logger.Trace("ProcessQueue locked, queue already processing");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ClearStalled()
|
||||
{
|
||||
var leafInputs =
|
||||
DataService.GetLeafInputs(
|
||||
LeafInputStatusType.Starting,
|
||||
LeafInputStatusType.Finishing
|
||||
)
|
||||
.Where(li =>
|
||||
li.StatusHistory.OrderBy(sh => sh.DateTime).First().DateTime
|
||||
> DateTime.Now.Subtract(TimeSpan.FromHours(1)))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private void StartNextPending()
|
||||
{
|
||||
var runningLeafInputs = DataService.GetRunningLeafInputs().ToList();
|
||||
var runningLeafInputs =
|
||||
DataService.GetLeafInputs(
|
||||
LeafInputStatusType.Starting,
|
||||
LeafInputStatusType.Running,
|
||||
LeafInputStatusType.Finishing
|
||||
).ToList();
|
||||
|
||||
if (runningLeafInputs.Any())
|
||||
{
|
||||
Logger.Trace("Leaf input(s) currently running");
|
||||
@@ -77,7 +93,6 @@ namespace LeafWeb.Web.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UpdateRunning()
|
||||
{
|
||||
var running = DataService.GetLeafInputs(LeafInputStatusType.Running).ToList();
|
||||
@@ -102,20 +117,7 @@ namespace LeafWeb.Web.Services
|
||||
case PiscalStatus.Complete:
|
||||
DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Finishing);
|
||||
BackgroundJobEnqueueRetry<FinishComplete>(s => s.DoWork(leafInputId));
|
||||
|
||||
//try
|
||||
//{
|
||||
//}
|
||||
//catch (PiscalClientException ex)
|
||||
//{
|
||||
// PiscalExceptionNotify(ex, leafInput);
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// var errorMessage = FormatException(ex, leafInput.Id);
|
||||
// Logger.Error(errorMessage);
|
||||
// DataService.SetLeafInputStatus(leafInput, LeafInputStatusType.Exception, ex.Message, errorMessage);
|
||||
//}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user