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
+64 -7
View File
@@ -8,15 +8,13 @@ using System.Linq;
namespace LeafWeb.Core.Entities
{
public class LeafInput
public abstract class LeafInputBase
{
public int Id { get; set; }
public virtual ICollection<LeafInputFile> InputFiles { get; set; }
public virtual ICollection<LeafOutputFile> OutputFiles { get; set; }
public LeafOutputFile OutputErrorMessage => OutputFiles?.FirstOrDefault(f => f.IsErrorMessage);
public LeafOutputFile OutputWarningMessage => OutputFiles?.FirstOrDefault(f => f.IsWarningMessage);
public virtual ICollection<LeafInputData> LeafInputData { get; set; }
public bool HasOutputFiles => OutputFiles.Any();
public bool HasLeafChart => OutputFiles.Any(f => f.IsLeafChartFile);
public LeafInputStatusType CurrentStatus { get; set; }
public virtual ICollection<LeafInputStatus> StatusHistory { get; set; }
@@ -36,12 +34,71 @@ namespace LeafWeb.Core.Entities
|| IsFinishing
|| IsCancelPending
|| IsCancelling;
public bool IsDeletable => !IsInProgress;
public bool HasOutputFiles => OutputFiles.Any();
public bool IsCancellable =>
IsRunning
|| IsPending;
public bool IsDeletable => !IsInProgress;
public bool IsAtEndState => IsComplete || IsException || IsCancelled;
public DateTime? StartTime
{
get
{
if (IsPending)
{
return null;
}
return StatusHistory.FirstOrDefault(s => s.Status == LeafInputStatusType.Starting)?.DateTime;
}
}
public DateTime? EndTime
{
get
{
if (!IsAtEndState)
{
return null;
}
return StatusHistory.FirstOrDefault(
s =>
s.Status == LeafInputStatusType.Complete
|| s.Status == LeafInputStatusType.Exception
|| s.Status == LeafInputStatusType.Cancelled)?.DateTime;
}
}
public TimeSpan TotalInProgressTime
{
get
{
var start = StartTime;
if (!start.HasValue)
{
return TimeSpan.Zero;
}
var end = EndTime;
if (!end.HasValue)
{
return DateTime.Now - start.Value;
}
return end.Value - start.Value;
}
}
}
public class LeafInput : LeafInputBase
{
public int Id { get; set; }
public virtual ICollection<LeafInputFile> InputFiles { get; set; }
public virtual ICollection<LeafInputData> LeafInputData { get; set; }
[Required(ErrorMessage = "Name required")]
public string Name { get; set; }