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

            while (true)
            {
                JobExecutionException result  = null;
                ScheduledJobContext   context = new ScheduledJobContext();
                try
                {
                    job.Execute(context);
                }
                catch (JobExecutionException exception2)
                {
                    result = exception2;
                    log.Info(string.Format(CultureInfo.InvariantCulture, "Job {0} threw a JobExecutionException: ", new object[] { job.Name }), exception2);
                }
                catch (Exception exception3)
                {
                    log.Error(string.Format(CultureInfo.InvariantCulture, "Job {0} threw an unhandled Exception: ", new object[] { job.Name }), exception3);
                    SchedulerException cause = new SchedulerException("Job threw an unhandled exception.", exception3)
                    {
                        ErrorCode = 800
                    };
                    result = new JobExecutionException(cause, false)
                    {
                        ErrorCode = 800
                    };
                }
                SchedulerInstruction noInstruction = SchedulerInstruction.NoInstruction;
                try
                {
                    noInstruction = trigger.ExecutionComplete(context, result);
                }
                catch (Exception)
                {
                }
                if (noInstruction == SchedulerInstruction.ReExecuteJob)
                {
                    if (log.get_IsDebugEnabled())
                    {
                        log.Debug("Rescheduling trigger to reexecute");
                    }
                }
                else
                {
                    this.TriggeredJobComplete(trigger, job, noInstruction);
                    break;
                }
            }
            this.NotifySchedulerThread();
        }
Esempio n. 2
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();
        }
        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. 4
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. 5
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);
 }