NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.Process.JobScheduleDescription Class Reference

A description of job schedule rules. More...

Public Member Functions

 JobScheduleDescription (bool initialRun, bool fixedRun, int frequency)
 Initializes a new instance of the JobScheduleDescription class. More...
 
DateTime CalculateNextRun (DateTime start)
 Calculates the time of next run according to description parameters. More...
 
ScheduledJob CreateNew (Job job, DateTime start, double offset)
 Creates a new scheduled job based on description and parameters. More...
 
ScheduledJob CreatePostponed (Job job)
 Creates a postponed job schedule. More...
 

Public Attributes

bool CanMove => !(InitialRun && !initialRunDone) && !FixedRun
 Gets a value indicating whether this description allow schedules to be moved. More...
 

Properties

bool FixedRun [get]
 Gets a value indicating whether this JobScheduleDescription has a fixed schedule frequency, eg. cannot be moved. More...
 
int Frequency [get]
 Gets the schedule frequency in minutes. More...
 
bool InitialRun [get]
 Gets a value indicating whether this JobScheduleDescription should do an initial run upon first call. More...
 

Private Attributes

bool initialRunDone
 

Detailed Description

A description of job schedule rules.

Definition at line 29 of file JobScheduleDescription.cs.

Constructor & Destructor Documentation

Ntp.Common.Process.JobScheduleDescription.JobScheduleDescription ( bool  initialRun,
bool  fixedRun,
int  frequency 
)
inline

Initializes a new instance of the JobScheduleDescription class.

Parameters
initialRunIf set to true initial run.
fixedRunIf set to true fixed run.
frequencyFrequency in minutes.

Definition at line 37 of file JobScheduleDescription.cs.

38  {
39  InitialRun = initialRun || (frequency == 0);
40  FixedRun = fixedRun;
41  Frequency = frequency;
42  initialRunDone = false;
43  }
bool InitialRun
Gets a value indicating whether this JobScheduleDescription should do an initial run upon first call...
int Frequency
Gets the schedule frequency in minutes.
bool FixedRun
Gets a value indicating whether this JobScheduleDescription has a fixed schedule frequency, eg. cannot be moved.

Member Function Documentation

DateTime Ntp.Common.Process.JobScheduleDescription.CalculateNextRun ( DateTime  start)
inline

Calculates the time of next run according to description parameters.

Returns
The next run.
Parameters
startStart.

Definition at line 78 of file JobScheduleDescription.cs.

Referenced by Ntp.Common.Process.Scheduler.QueueJob().

79  {
80  if (Frequency == -1)
81  return DateTime.MaxValue;
82  if (Frequency == 0 || (InitialRun && !initialRunDone))
83  return start;
84 
85  int multiplier = Convert.ToInt32(Math.Truncate((double) (start.Hour*60 + start.Minute)/Frequency));
86  int startMinutes = multiplier*Frequency;
87 
88  int hour = (startMinutes + Frequency)/60;
89  int minute = (startMinutes + Frequency)%60;
90 
91  if (hour >= 24)
92  {
93  hour -= 24;
94  start = start.AddDays(1);
95  }
96 
97  if (minute >= 60)
98  {
99  minute -= 60;
100  start = start.AddHours(1);
101  }
102 
103  var next = new DateTime(start.Year, start.Month, start.Day, hour, minute, 0);
104 
105  return next;
106  }
bool InitialRun
Gets a value indicating whether this JobScheduleDescription should do an initial run upon first call...
int Frequency
Gets the schedule frequency in minutes.

Here is the caller graph for this function:

ScheduledJob Ntp.Common.Process.JobScheduleDescription.CreateNew ( Job  job,
DateTime  start,
double  offset 
)
inline

Creates a new scheduled job based on description and parameters.

Returns
The new.
Parameters
jobJob.
startStart.
offsetOffset.

Definition at line 115 of file JobScheduleDescription.cs.

Referenced by Ntp.Common.Process.Scheduler.QueueJob().

116  {
117  if (InitialRun && !initialRunDone)
118  {
119  initialRunDone = true;
120  return new ScheduledJob(job, start);
121  }
122 
123  return new ScheduledJob(job, CalculateNextRun(start).AddMinutes(offset));
124  }
bool InitialRun
Gets a value indicating whether this JobScheduleDescription should do an initial run upon first call...
DateTime CalculateNextRun(DateTime start)
Calculates the time of next run according to description parameters.

Here is the caller graph for this function:

ScheduledJob Ntp.Common.Process.JobScheduleDescription.CreatePostponed ( Job  job)
inline

Creates a postponed job schedule.

Returns
The postponed.
Parameters
jobJob.

Definition at line 131 of file JobScheduleDescription.cs.

Referenced by Ntp.Common.Process.Scheduler.PostponeJob().

132  {
133  double offset = Frequency/100.0;
134 
135  if (offset > 2)
136  {
137  offset = 2;
138  }
139  else if (offset < 0.5)
140  {
141  offset = 0.5;
142  }
143 
144  return new ScheduledJob(job, DateTime.Now.AddMinutes(offset));
145  }
int Frequency
Gets the schedule frequency in minutes.

Here is the caller graph for this function:

Member Data Documentation

bool Ntp.Common.Process.JobScheduleDescription.CanMove => !(InitialRun && !initialRunDone) && !FixedRun

Gets a value indicating whether this description allow schedules to be moved.

true if this instance can move; otherwise, false.

Definition at line 71 of file JobScheduleDescription.cs.

Referenced by Ntp.Common.Process.Scheduler.QueueJob().

bool Ntp.Common.Process.JobScheduleDescription.initialRunDone
private

Definition at line 45 of file JobScheduleDescription.cs.

Property Documentation

bool Ntp.Common.Process.JobScheduleDescription.FixedRun
get

Gets a value indicating whether this JobScheduleDescription has a fixed schedule frequency, eg. cannot be moved.

true if fixed run; otherwise, false.

Definition at line 59 of file JobScheduleDescription.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Jobs(), Ntp.Analyzer.Monitor.Server.Billboard.Proc(), Ntp.Analyzer.Monitor.Server.Billboard.Running(), Ntp.Analyzer.Monitor.Server.Billboard.Schedule(), and Ntp.Common.Log.LogExtensions.SchedulerJobAdded().

bool Ntp.Common.Process.JobScheduleDescription.InitialRun
get

Gets a value indicating whether this JobScheduleDescription should do an initial run upon first call.

true if initial run; otherwise, false.

Definition at line 52 of file JobScheduleDescription.cs.

Referenced by Ntp.Analyzer.Monitor.Server.Billboard.Jobs(), Ntp.Analyzer.Monitor.Server.Billboard.Proc(), Ntp.Analyzer.Monitor.Server.Billboard.Running(), and Ntp.Analyzer.Monitor.Server.Billboard.Schedule().


The documentation for this class was generated from the following file: