Files
sockeye/server/models/OpsJob.cs
2022-12-16 06:01:23 +00:00

70 lines
2.0 KiB
C#

using System;
using Sockeye.Biz;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
namespace Sockeye.Models
{
/// <summary>
/// Operations job
/// </summary>
public class OpsJob
{
[Key]
public Guid GId { get; set; }
[Required]
public DateTime Created { get; set; }
public uint Concurrency { get; set; }
[Required]
public string Name { get; set; }
//------------------------
[Required]
public bool Exclusive { get; set; }//true lock api and don't run other jobs until completed / false=run any time with other jobs async
public DateTime StartAfter { get; set; }
[Required]
public JobType JobType { get; set; }
public JobSubType SubType { get; set; }
public long ObjectId { get; set; }
public SockType SockType { get; set; }
[Required]
public JobStatus JobStatus { get; set; }
/// <summary>
/// Json string of any required extra info for job
/// </summary>
public string JobInfo { get; set; }//json as string of any required extra info for job
public string Progress {get;set;}//any type of text digestible by client showing progress of job, typically just a string i.e. "133/344"
public OpsJob()
{
GId = new Guid();
Created = DateTime.UtcNow;
Name = "new job";
Exclusive = false;
StartAfter = Created;
JobType = JobType.NotSet;
SubType = JobSubType.NotSet;
ObjectId = 0;
SockType = SockType.NoType;
JobStatus = JobStatus.Sleeping;
JobInfo = null;
Progress=string.Empty;
}
public override string ToString()
{
return JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.None);
}
}
}