Esempio n. 1
0
        public void ProcessJob(object state)
        {
            TriggerFiredBundle bundle  = state as TriggerFiredBundle;
            Trigger            trigger = bundle.Trigger;
            IScheduledJob      job     = bundle.Job;

            do
            {
                JobExecutionException jobExecutionException = null;
                ScheduledJobContext   scheduledJobContext   = new ScheduledJobContext();
                try {
                    job.Execute(scheduledJobContext);
                } catch (JobExecutionException jee) {
                    jobExecutionException = jee;
                    log.Info(string.Format(CultureInfo.InvariantCulture, "Job {0} threw a JobExecutionException: ", job.Name), jee);
                } catch (Exception ex) {
                    log.Error(string.Format(CultureInfo.InvariantCulture, "Job {0} threw an unhandled Exception: ", job.Name), ex);
                    SchedulerException se = new SchedulerException("Job threw an unhandled exception.", ex);
                    se.ErrorCode                    = SchedulerException.ErrorJobExecutionThrewException;
                    jobExecutionException           = new JobExecutionException(se, false);
                    jobExecutionException.ErrorCode = JobExecutionException.ErrorJobExecutionThrewException;
                }

                SchedulerInstruction instCode = SchedulerInstruction.NoInstruction;
                try {
                    instCode = trigger.ExecutionComplete(scheduledJobContext, jobExecutionException);
                } catch (Exception) {
                    // If this happens, there's a bug in the trigger...
                }
                // update job/trigger or re-Execute job
                if (instCode == SchedulerInstruction.ReExecuteJob)
                {
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Rescheduling trigger to reexecute");
                    }
                    continue;
                }
                TriggeredJobComplete(trigger, job, instCode);
                break;
            } while (true);
            NotifySchedulerThread();
        }
Esempio n. 2
0
		public virtual SchedulerInstruction ExecutionComplete(ScheduledJobContext context, JobExecutionException result) {
			if (result != null && result.RefireImmediately)
				return SchedulerInstruction.ReExecuteJob;
			if (result != null && result.UnscheduleFiringTrigger)
				return SchedulerInstruction.SetTriggerComplete;
			if (result != null && result.UnscheduleAllTriggers)
				return SchedulerInstruction.SetAllJobTriggersComplete;
			if (result != null && !result.RefireImmediately)
				return SchedulerInstruction.NoInstruction;
			if (!GetMayFireAgain())
				return SchedulerInstruction.DeleteTrigger;
			return SchedulerInstruction.NoInstruction;
		}
Esempio n. 3
0
 public virtual SchedulerInstruction ExecutionComplete(ScheduledJobContext context, JobExecutionException result)
 {
     if (result != null && result.RefireImmediately)
     {
         return(SchedulerInstruction.ReExecuteJob);
     }
     if (result != null && result.UnscheduleFiringTrigger)
     {
         return(SchedulerInstruction.SetTriggerComplete);
     }
     if (result != null && result.UnscheduleAllTriggers)
     {
         return(SchedulerInstruction.SetAllJobTriggersComplete);
     }
     if (result != null && !result.RefireImmediately)
     {
         return(SchedulerInstruction.NoInstruction);
     }
     if (!GetMayFireAgain())
     {
         return(SchedulerInstruction.DeleteTrigger);
     }
     return(SchedulerInstruction.NoInstruction);
 }
Esempio n. 4
0
		public void ProcessJob(object state) {
			TriggerFiredBundle bundle = state as TriggerFiredBundle;
			Trigger trigger = bundle.Trigger;
			IScheduledJob job = bundle.Job;
			do {
				JobExecutionException jobExecutionException = null;
				ScheduledJobContext scheduledJobContext = new ScheduledJobContext();
				try {
					job.Execute(scheduledJobContext);
				} catch (JobExecutionException jee) {
					jobExecutionException = jee;
					log.Info(string.Format(CultureInfo.InvariantCulture, "Job {0} threw a JobExecutionException: ", job.Name), jee);
				} catch (Exception ex) {
					log.Error(string.Format(CultureInfo.InvariantCulture, "Job {0} threw an unhandled Exception: ", job.Name), ex);
					SchedulerException se = new SchedulerException("Job threw an unhandled exception.", ex);
					se.ErrorCode = SchedulerException.ErrorJobExecutionThrewException;
					jobExecutionException = new JobExecutionException(se, false);
					jobExecutionException.ErrorCode = JobExecutionException.ErrorJobExecutionThrewException;
				}

				SchedulerInstruction instCode = SchedulerInstruction.NoInstruction;
				try {
					instCode = trigger.ExecutionComplete(scheduledJobContext, jobExecutionException);
				} catch (Exception) {
					// If this happens, there's a bug in the trigger...
				}
				// update job/trigger or re-Execute job
				if (instCode == SchedulerInstruction.ReExecuteJob) {
					if (log.IsDebugEnabled)
						log.Debug("Rescheduling trigger to reexecute");
					continue;
				}
				TriggeredJobComplete(trigger, job, instCode);
				break;
			} while (true);
			NotifySchedulerThread();
		}