Adding
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.DispatcherModels.Enums;
|
||||
using LCU.Library.Internal.DispatcherModels.Helpers;
|
||||
namespace LCU.Library.Internal.DispatcherModels.Entities;
|
||||
|
||||
public class WorkItem
|
||||
{
|
||||
public int WorkItemId { get; set; }
|
||||
public int JobId { get; set; }
|
||||
[Required]
|
||||
[StringLength(200, ErrorMessage = "Name Max Length is 200")]
|
||||
public string Name { get; set; }
|
||||
[StringLength(8000, ErrorMessage = "Description Max Length is 8000")]
|
||||
public string Description { get; set; }
|
||||
[Required]
|
||||
public int Order { get; set; }
|
||||
public string SerializedPayload { get; set; }
|
||||
public string Url { get; set; }
|
||||
public HttpMethodType HttpMethod { get; set; }
|
||||
[Required]
|
||||
public ActionType ActionType { get; set; }
|
||||
public bool CancelJobOnFailure { get; set; }
|
||||
public int CancelJobLimit { get; set; }
|
||||
public int CanceledJobCounter { get; set; }
|
||||
[ForeignKey("WorkItemId")]
|
||||
public ICollection<WorkItemExecution> WorkItemExecutions { get; set; }
|
||||
[NotMapped]
|
||||
public WorkItemExecution CurrentWorkItemExecution
|
||||
{
|
||||
get
|
||||
{
|
||||
var currentWorkItemExecution = WorkItemExecutions?.FirstOrDefault(wie => wie.CompletedTimestamp == null);
|
||||
if (currentWorkItemExecution != null)
|
||||
{
|
||||
currentWorkItemExecution = Clone.DeepClone(currentWorkItemExecution);
|
||||
}
|
||||
return currentWorkItemExecution;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public bool IsNewWorkItem => WorkItemId <= 0;
|
||||
|
||||
[NotMapped]
|
||||
public bool RequiresJobCancellation => CancelJobOnFailure && CanceledJobCounter <= CancelJobLimit;
|
||||
}
|
||||
Reference in New Issue
Block a user