25 namespace Ntp.Common.Process
27 public sealed
class Job 42 Description = description;
49 private static readonly
object NextJobLocker =
new object();
50 private static int nextJobId = 1;
53 private TimeSpan time =
new TimeSpan(0);
59 public int JobId {
get; }
77 public bool Queued {
get;
internal set; }
83 public bool Postponed {
get;
internal set; }
89 public bool Running {
get;
private set; }
95 public DateTime Started {
get;
private set; }
101 public int RunCount {
get;
private set; }
116 return Queued ?
"queued" :
"stopped";
124 public string Runtime => Running ? DateTime.Now.Subtract(Started).
ToString() :
string.Empty;
130 public string TotalRuntime => Running ? (DateTime.Now.Subtract(Started) + time).ToString() : time.ToString();
137 Started = DateTime.Now;
140 var threadStart = DateTime.Now;
151 Description.Execute();
156 log.JobError(
this, e);
163 time += DateTime.Now.Subtract(threadStart);
164 log.JobExecutionStatus(
this, error);
181 var name =
string.IsNullOrWhiteSpace(Description.Name) ?
string.Empty :
" " + Description.Name;
182 return $
"{Description.JobType} job{name}";
override string ToString()
Returns a string that represents the current JobDescription.
override string ToString()
Returns a string that represents the current Job.
A description of job schedule rules.
Job(JobDescription description, JobScheduleDescription schedule, LogBase log)
Initializes a new instance of the Job class.
void Execute()
Execute this Job.
Base class for jobs following the GoF Command Pattern.