public Reschedule ( System.DateTime lastRun, Kudu.Core.Jobs.Schedule schedule = null ) : void | ||
lastRun | System.DateTime | |
schedule | Kudu.Core.Jobs.Schedule | |
return | void |
private void OnSchedule(TriggeredJobSchedule triggeredJobSchedule) { bool invoked = false; try { string triggeredJobName = triggeredJobSchedule.TriggeredJob.Name; TriggeredJobRun latestTriggeredJobRun = _triggeredJobsManager.GetLatestJobRun(triggeredJobName); DateTime lastRun = latestTriggeredJobRun != null ? latestTriggeredJobRun.StartTime : DateTime.Now.AddMinutes(-1); // Make sure we are on schedule // Check for the next occurence after the last run (as of now) // If it is still now, invoke the triggered job // If it's not now (in the future) reschedule the triggered job schedule starting with the last triggered job run TimeSpan currentSchedule = triggeredJobSchedule.Schedule.GetNextInterval(lastRun, ignoreMissed: true); if (currentSchedule == TimeSpan.Zero) { _triggeredJobsManager.InvokeTriggeredJob(triggeredJobName, null, "Schedule - " + triggeredJobSchedule.Schedule); invoked = true; } else { triggeredJobSchedule.Reschedule(lastRun); return; } } catch (ConflictException) { // Ignore as this is expected when running multiple instances } catch (Exception ex) { _traceFactory.GetTracer().TraceError(ex); } if (invoked) { triggeredJobSchedule.Logger.LogInformation("WebJob invoked"); } triggeredJobSchedule.Reschedule(DateTime.Now); }
private void OnSchedule(TriggeredJobSchedule triggeredJobSchedule) { bool invoked = false; try { string triggeredJobName = triggeredJobSchedule.TriggeredJob.Name; TriggeredJobRun latestTriggeredJobRun = _triggeredJobsManager.GetLatestJobRun(triggeredJobName); DateTime lastRun = latestTriggeredJobRun != null ? latestTriggeredJobRun.StartTime : DateTime.Now.AddMinutes(-1); // Make sure we are on schedule // Check for the next occurence after the last run (as of now) // If it is still now, invoke the triggered job // If it's not now (in the future) reschedule the triggered job schedule starting with the last triggered job run TimeSpan currentSchedule = triggeredJobSchedule.Schedule.GetNextInterval(lastRun, ignoreMissed: true); if (currentSchedule == TimeSpan.Zero) { _triggeredJobsManager.InvokeTriggeredJob(triggeredJobName, null, "Schedule - " + triggeredJobSchedule.Schedule); invoked = true; } else { triggeredJobSchedule.Reschedule(lastRun); return; } } catch (ConflictException) { // Ignore as this is expected when running multiple instances } catch (Exception ex) { _traceFactory.GetTracer().TraceError(ex); } if (invoked) { triggeredJobSchedule.Logger.LogInformation("WebJob invoked"); } triggeredJobSchedule.Reschedule(DateTime.Now); }