Exemplo n.º 1
0
        private void UpdatePlannedJobRun(JobRun plannedNextRun, JobTriggerBase trigger, DateTime calculatedNextRun)
        {
            // Is this value in sync with the schedule table?
            if (plannedNextRun.PlannedStartDateTimeUtc == calculatedNextRun)
            {
                Logger.DebugFormat(
                    "The previously planned startdate '{0}' is still correct for JobRun (id: {1}) triggered by trigger with id '{2}' (Type: '{3}', userId: '{4}', userName: '******')",
                    calculatedNextRun,
                    plannedNextRun.Id,
                    trigger.Id,
                    trigger.GetType().Name,
                    trigger.UserId,
                    trigger.UserDisplayName);

                return;
            }

            // Was the change too close before the execution date?
            var utcNow = this.dateTimeProvider.GetUtcNow();

            if (utcNow.AddSeconds(this.configuration.AllowChangesBeforeStartInSec) >= calculatedNextRun)
            {
                Logger.WarnFormat(
                    "The planned startdate '{0}' has changed to '{1}'. This change was done too close (less than {2} seconds) to the next planned run and cannot be adjusted",
                    plannedNextRun.PlannedStartDateTimeUtc,
                    calculatedNextRun,
                    this.configuration.AllowChangesBeforeStartInSec);

                return;
            }

            Logger.WarnFormat("The calculated startdate '{0}' has changed to '{1}', the planned jobRun needs to be updated as next step", plannedNextRun.PlannedStartDateTimeUtc, calculatedNextRun);

            plannedNextRun.PlannedStartDateTimeUtc = calculatedNextRun;
            this.repository.Update(plannedNextRun);
        }
Exemplo n.º 2
0
        private static void AddTrigger(IJobStorageProvider storage, JobTriggerBase trigger, JobDefinition jobDef, long jobId)
        {
            trigger.IsActive   = true;
            trigger.JobId      = jobId;
            trigger.Parameters = trigger.Parameters;

            Logger.InfoFormat("Adding trigger (type: '{0}' to job '{1}' (JobId: '{2}')", trigger.GetType().Name, jobDef.UniqueName, jobId);

            var scheduledTrigger = trigger as ScheduledTrigger;

            if (scheduledTrigger != null)
            {
                storage.AddTrigger(jobId, scheduledTrigger);
            }

            var recurringTrigger = trigger as RecurringTrigger;

            if (recurringTrigger != null)
            {
                storage.AddTrigger(jobId, recurringTrigger);
            }
        }