21-12-2022
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using DigitalData.Modules.Logging;
|
||||
using ECM.JobRunner.Common.JobRunnerReference;
|
||||
using System;
|
||||
|
||||
namespace ECM.JobRunner.Web.Data
|
||||
{
|
||||
@@ -8,13 +9,59 @@ namespace ECM.JobRunner.Web.Data
|
||||
private readonly Logger logger;
|
||||
private readonly IEDMIServiceChannel channel;
|
||||
|
||||
public string Title = "No Title";
|
||||
public event EventHandler<string>? PageTitleChanged;
|
||||
|
||||
public HelperService(LoggingService Logging, WcfService Wcf)
|
||||
{
|
||||
logger = Logging.LogConfig.GetLogger();
|
||||
channel = Wcf.Channel;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPageTitle(string title)
|
||||
{
|
||||
PageTitleChanged?.Invoke(this, title);
|
||||
}
|
||||
|
||||
public List<StatusItem> GetItemsForTimespan(List<StatusItem> items, TimeSpan timespan)
|
||||
{
|
||||
return items.
|
||||
Where(s => (DateTime.Now - s.CompleteTime) < timespan).
|
||||
ToList();
|
||||
}
|
||||
|
||||
public List<StatusItem> GetItemsForLastMinutes(List<StatusItem> items, int minutes) =>
|
||||
GetItemsForTimespan(items, new TimeSpan(0, minutes, 0));
|
||||
|
||||
public List<StatusItem> GetItemsForLastHours(List<StatusItem> items, int hours) =>
|
||||
GetItemsForTimespan(items, new TimeSpan(hours, 0, 0));
|
||||
|
||||
public List<StatusItem> GetItemsForLastSeconds(List<StatusItem> items, int seconds) =>
|
||||
GetItemsForTimespan(items, new TimeSpan(0, 0, seconds));
|
||||
|
||||
public class JobHistory
|
||||
{
|
||||
public List<StatusItem> items;
|
||||
public int total;
|
||||
public int success;
|
||||
public int failed;
|
||||
public int waiting;
|
||||
}
|
||||
|
||||
public JobHistory GetJobHistory(List<StatusItem> items, int sinceMinutes)
|
||||
{
|
||||
var filteredItems = GetItemsForLastMinutes(items, sinceMinutes);
|
||||
var executingItems = filteredItems.Where(s => s.Executing == false);
|
||||
|
||||
return new JobHistory()
|
||||
{
|
||||
items = executingItems.ToList(),
|
||||
total = executingItems.Count(),
|
||||
success = executingItems.Where(i => i.Successful && i.Waiting == false).Count(),
|
||||
failed = executingItems.Where(i => i.Successful == false).Count(),
|
||||
waiting = executingItems.Where(i => i.Successful && i.Waiting == true).Count()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public DateTime GetNextExecutionTime(string pCronExpression)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user