24 namespace Ntp.Common.Process
39 InitialRun = initialRun || (frequency == 0);
41 Frequency = frequency;
42 initialRunDone =
false;
52 public bool InitialRun {
get; }
59 public bool FixedRun {
get; }
65 public int Frequency {
get; }
71 public bool CanMove => !(InitialRun && !initialRunDone) && !FixedRun;
81 return DateTime.MaxValue;
82 if (Frequency == 0 || (InitialRun && !initialRunDone))
85 int multiplier = Convert.ToInt32(Math.Truncate((
double) (start.Hour*60 + start.Minute)/Frequency));
86 int startMinutes = multiplier*Frequency;
88 int hour = (startMinutes + Frequency)/60;
89 int minute = (startMinutes + Frequency)%60;
94 start = start.AddDays(1);
100 start = start.AddHours(1);
103 var next =
new DateTime(start.Year, start.Month, start.Day, hour, minute, 0);
117 if (InitialRun && !initialRunDone)
119 initialRunDone =
true;
123 return new ScheduledJob(job, CalculateNextRun(start).AddMinutes(offset));
133 double offset = Frequency/100.0;
139 else if (offset < 0.5)
144 return new ScheduledJob(job, DateTime.Now.AddMinutes(offset));
ScheduledJob CreatePostponed(Job job)
Creates a postponed job schedule.
JobScheduleDescription(bool initialRun, bool fixedRun, int frequency)
Initializes a new instance of the JobScheduleDescription class.
ScheduledJob CreateNew(Job job, DateTime start, double offset)
Creates a new scheduled job based on description and parameters.
A description of job schedule rules.
DateTime CalculateNextRun(DateTime start)
Calculates the time of next run according to description parameters.
A job which have been scheduled for execution.