本文整理汇总了C#中SchedulerException类的典型用法代码示例。如果您正苦于以下问题:C# SchedulerException类的具体用法?C# SchedulerException怎么用?C# SchedulerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SchedulerException类属于命名空间,在下文中一共展示了SchedulerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewJob
/// <summary>
/// Called by the scheduler at the time of the trigger firing, in order to
/// produce a <see cref="IJob" /> instance on which to call Execute.
/// </summary>
/// <remarks>
/// It should be extremely rare for this method to throw an exception -
/// basically only the the case where there is no way at all to instantiate
/// and prepare the Job for execution. When the exception is thrown, the
/// Scheduler will move all triggers associated with the Job into the
/// <see cref="TriggerState.Error" /> state, which will require human
/// intervention (e.g. an application restart after fixing whatever
/// configuration problem led to the issue wih instantiating the Job.
/// </remarks>
/// <param name="bundle">The TriggerFiredBundle from which the <see cref="IJobDetail" />
/// and other info relating to the trigger firing can be obtained.</param>
/// <param name="scheduler"></param>
/// <returns>the newly instantiated Job</returns>
/// <throws> SchedulerException if there is a problem instantiating the Job. </throws>
public virtual IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
{
IJobDetail jobDetail = bundle.JobDetail;
Type jobType = jobDetail.JobType;
try
{
return ObjectUtils.InstantiateType<IJob>(jobType);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "Problem instantiating class '{0}'", jobDetail.JobType.FullName), e);
throw se;
}
}
示例2: SchedulerError
public Task SchedulerError(string msg, SchedulerException cause)
{
return TaskUtil.CompletedTask;
}
示例3: Initialize
/// <summary>
/// Initializes the job execution context with given scheduler and bundle.
/// </summary>
/// <param name="sched">The scheduler.</param>
public virtual async Task Initialize(QuartzScheduler sched)
{
qs = sched;
IJob job;
IJobDetail jobDetail = firedTriggerBundle.JobDetail;
try
{
job = sched.JobFactory.NewJob(firedTriggerBundle, scheduler);
}
catch (SchedulerException se)
{
await sched.NotifySchedulerListenersError($"An error occurred instantiating job to be executed. job= '{jobDetail.Key}'", se).ConfigureAwait(false);
throw;
}
catch (Exception e)
{
SchedulerException se = new SchedulerException($"Problem instantiating type '{jobDetail.JobType.FullName}'", e);
await sched.NotifySchedulerListenersError($"An error occurred instantiating job to be executed. job= '{jobDetail.Key}'", se).ConfigureAwait(false);
throw se;
}
jec = new JobExecutionContextImpl(scheduler, firedTriggerBundle, job);
}
示例4: NotifyJobListenersWasVetoed
/// <summary>
/// Notifies the job listeners that job exucution was vetoed.
/// </summary>
/// <param name="jec">The job execution context.</param>
public virtual void NotifyJobListenersWasVetoed(IJobExecutionContext jec)
{
// build a list of all job listeners that are to be notified...
IEnumerable<IJobListener> listeners = BuildJobListenerList();
// notify all job listeners
foreach (IJobListener jl in listeners)
{
if (!MatchJobListener(jl, jec.JobDetail.Key))
{
continue;
}
try
{
jl.JobExecutionVetoed(jec);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "JobListener '{0}' threw exception: {1}", jl.Name, e.Message), e);
throw se;
}
}
}
示例5: NotifyTriggerListenersMisfired
/// <summary>
/// Notifies the trigger listeners about misfired trigger.
/// </summary>
/// <param name="trigger">The trigger.</param>
public virtual void NotifyTriggerListenersMisfired(ITrigger trigger)
{
// build a list of all trigger listeners that are to be notified...
IEnumerable<ITriggerListener> listeners = BuildTriggerListenerList();
// notify all trigger listeners in the list
foreach (ITriggerListener tl in listeners)
{
if (!MatchTriggerListener(tl, trigger.Key))
{
continue;
}
try
{
tl.TriggerMisfired(trigger);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "TriggerListener '{0}' threw exception: {1}", tl.Name, e.Message), e);
throw se;
}
}
}
示例6: NotifyTriggerListenersComplete
/// <summary>
/// Notifies the trigger listeners of completion.
/// </summary>
/// <param name="jec">The job executution context.</param>
/// <param name="instCode">The instruction code to report to triggers.</param>
public virtual void NotifyTriggerListenersComplete(IJobExecutionContext jec, SchedulerInstruction instCode)
{
// build a list of all trigger listeners that are to be notified...
IEnumerable<ITriggerListener> listeners = BuildTriggerListenerList();
// notify all trigger listeners in the list
foreach (ITriggerListener tl in listeners)
{
if (!MatchTriggerListener(tl, jec.Trigger.Key))
{
continue;
}
try
{
tl.TriggerComplete(jec.Trigger, jec, instCode);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException(string.Format(CultureInfo.InvariantCulture, "TriggerListener '{0}' threw exception: {1}", tl.Name, e.Message), e);
throw se;
}
}
}
示例7: InvalidateHandleCreateException
protected virtual SchedulerException InvalidateHandleCreateException(string msg, Exception cause)
{
rsched = null;
SchedulerException ex = new SchedulerException(msg, cause);
return ex;
}
示例8: Instantiate
/// <summary> </summary>
private IScheduler Instantiate()
{
if (cfg == null)
{
Initialize();
}
if (initException != null)
{
throw initException;
}
ISchedulerExporter exporter = null;
IJobStore js;
IThreadPool tp;
QuartzScheduler qs = null;
DBConnectionManager dbMgr = null;
Type instanceIdGeneratorType = null;
NameValueCollection tProps;
bool autoId = false;
TimeSpan idleWaitTime = TimeSpan.Zero;
TimeSpan dbFailureRetry = TimeSpan.FromSeconds(15);
IThreadExecutor threadExecutor;
SchedulerRepository schedRep = SchedulerRepository.Instance;
// Get Scheduler Properties
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string schedName = cfg.GetStringProperty(PropertySchedulerInstanceName, "QuartzScheduler");
string threadName = cfg.GetStringProperty(PropertySchedulerThreadName, "{0}_QuartzSchedulerThread".FormatInvariant(schedName));
string schedInstId = cfg.GetStringProperty(PropertySchedulerInstanceId, DefaultInstanceId);
if (schedInstId.Equals(AutoGenerateInstanceId))
{
autoId = true;
instanceIdGeneratorType = LoadType(cfg.GetStringProperty(PropertySchedulerInstanceIdGeneratorType)) ?? typeof(SimpleInstanceIdGenerator);
}
else if (schedInstId.Equals(SystemPropertyAsInstanceId))
{
autoId = true;
instanceIdGeneratorType = typeof(SystemPropertyInstanceIdGenerator);
}
Type typeLoadHelperType = LoadType(cfg.GetStringProperty(PropertySchedulerTypeLoadHelperType));
Type jobFactoryType = LoadType(cfg.GetStringProperty(PropertySchedulerJobFactoryType, null));
idleWaitTime = cfg.GetTimeSpanProperty(PropertySchedulerIdleWaitTime, idleWaitTime);
if (idleWaitTime > TimeSpan.Zero && idleWaitTime < TimeSpan.FromMilliseconds(1000))
{
throw new SchedulerException("quartz.scheduler.idleWaitTime of less than 1000ms is not legal.");
}
dbFailureRetry = cfg.GetTimeSpanProperty(PropertySchedulerDbFailureRetryInterval, dbFailureRetry);
if (dbFailureRetry < TimeSpan.Zero)
{
throw new SchedulerException(PropertySchedulerDbFailureRetryInterval + " of less than 0 ms is not legal.");
}
bool makeSchedulerThreadDaemon = cfg.GetBooleanProperty(PropertySchedulerMakeSchedulerThreadDaemon);
long batchTimeWindow = cfg.GetLongProperty(PropertySchedulerBatchTimeWindow, 0L);
int maxBatchSize = cfg.GetIntProperty(PropertySchedulerMaxBatchSize, 1);
bool interruptJobsOnShutdown = cfg.GetBooleanProperty(PropertySchedulerInterruptJobsOnShutdown, false);
bool interruptJobsOnShutdownWithWait = cfg.GetBooleanProperty(PropertySchedulerInterruptJobsOnShutdownWithWait, false);
NameValueCollection schedCtxtProps = cfg.GetPropertyGroup(PropertySchedulerContextPrefix, true);
bool proxyScheduler = cfg.GetBooleanProperty(PropertySchedulerProxy, false);
// Create type load helper
ITypeLoadHelper loadHelper;
try
{
loadHelper = ObjectUtils.InstantiateType<ITypeLoadHelper>(typeLoadHelperType ?? typeof(SimpleTypeLoadHelper));
}
catch (Exception e)
{
throw new SchedulerConfigException("Unable to instantiate type load helper: {0}".FormatInvariant(e.Message), e);
}
loadHelper.Initialize();
// If Proxying to remote scheduler, short-circuit here...
// ~~~~~~~~~~~~~~~~~~
if (proxyScheduler)
{
if (autoId)
{
schedInstId = DefaultInstanceId;
}
Type proxyType = loadHelper.LoadType(cfg.GetStringProperty(PropertySchedulerProxyType)) ?? typeof(RemotingSchedulerProxyFactory);
IRemotableSchedulerProxyFactory factory;
try
{
factory = ObjectUtils.InstantiateType<IRemotableSchedulerProxyFactory>(proxyType);
ObjectUtils.SetObjectProperties(factory, cfg.GetPropertyGroup(PropertySchedulerProxy, true));
}
catch (Exception e)
//.........这里部分代码省略.........
示例9: NotifyTriggerListenersComplete
/// <summary>
/// Notifies the trigger listeners of completion.
/// </summary>
/// <param name="jec">The job execution context.</param>
/// <param name="instCode">The instruction code to report to triggers.</param>
public virtual async Task NotifyTriggerListenersComplete(IJobExecutionContext jec, SchedulerInstruction instCode)
{
// build a list of all trigger listeners that are to be notified...
var listeners = BuildTriggerListenerList();
// notify all trigger listeners in the list
foreach (ITriggerListener tl in listeners)
{
if (!MatchTriggerListener(tl, jec.Trigger.Key))
{
continue;
}
try
{
await tl.TriggerComplete(jec.Trigger, jec, instCode).ConfigureAwait(false);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException($"TriggerListener '{tl.Name}' threw exception: {e.Message}", e);
throw se;
}
}
}
示例10: NotifyTriggerListenersMisfired
/// <summary>
/// Notifies the trigger listeners about misfired trigger.
/// </summary>
/// <param name="trigger">The trigger.</param>
public virtual async Task NotifyTriggerListenersMisfired(ITrigger trigger)
{
// build a list of all trigger listeners that are to be notified...
var listeners = BuildTriggerListenerList();
// notify all trigger listeners in the list
foreach (ITriggerListener tl in listeners)
{
if (!MatchTriggerListener(tl, trigger.Key))
{
continue;
}
try
{
await tl.TriggerMisfired(trigger).ConfigureAwait(false);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException($"TriggerListener '{tl.Name}' threw exception: {e.Message}", e);
throw se;
}
}
}
示例11: NotifyTriggerListenersFired
/// <summary>
/// Notifies the trigger listeners about fired trigger.
/// </summary>
/// <param name="jec">The job execution context.</param>
/// <returns></returns>
public virtual async Task<bool> NotifyTriggerListenersFired(IJobExecutionContext jec)
{
bool vetoedExecution = false;
// build a list of all trigger listeners that are to be notified...
IEnumerable<ITriggerListener> listeners = BuildTriggerListenerList();
// notify all trigger listeners in the list
foreach (ITriggerListener tl in listeners)
{
if (!MatchTriggerListener(tl, jec.Trigger.Key))
{
continue;
}
try
{
await tl.TriggerFired(jec.Trigger, jec).ConfigureAwait(false);
if (await tl.VetoJobExecution(jec.Trigger, jec).ConfigureAwait(false))
{
vetoedExecution = true;
}
}
catch (Exception e)
{
SchedulerException se = new SchedulerException($"TriggerListener '{tl.Name}' threw exception: {e.Message}", e);
throw se;
}
}
return vetoedExecution;
}
示例12: SchedulerError
public void SchedulerError(string msg, SchedulerException cause)
{
Write("{0} -- {1} -- SchedulerError() was called", Name, DateTime.Now);
}
示例13: NotifySchedulerListenersError
/// <summary>
/// Notifies the scheduler listeners about scheduler error.
/// </summary>
/// <param name="msg">The MSG.</param>
/// <param name="se">The se.</param>
public virtual void NotifySchedulerListenersError(string msg, SchedulerException se)
{
// build a list of all scheduler listeners that are to be notified...
IList<ISchedulerListener> schedListeners = BuildSchedulerListenerList();
// notify all scheduler listeners
foreach (ISchedulerListener sl in schedListeners)
{
try
{
sl.SchedulerError(msg, se);
}
catch (Exception)
{
}
}
}
示例14: InvalidateHandleCreateException
protected virtual SchedulerException InvalidateHandleCreateException(string msg, Exception cause)
{
rsched = null;
SchedulerException ex = new SchedulerException(msg, cause);
ex.ErrorCode = SchedulerException.ErrorCommunicationFailure;
return ex;
}
示例15: NotifyJobListenersWasExecuted
/// <summary>
/// Notifies the job listeners that job was executed.
/// </summary>
/// <param name="jec">The jec.</param>
/// <param name="je">The je.</param>
public virtual async Task NotifyJobListenersWasExecuted(IJobExecutionContext jec, JobExecutionException je)
{
// build a list of all job listeners that are to be notified...
IEnumerable<IJobListener> listeners = BuildJobListenerList();
// notify all job listeners
foreach (IJobListener jl in listeners)
{
if (!MatchJobListener(jl, jec.JobDetail.Key))
{
continue;
}
try
{
await jl.JobWasExecuted(jec, je).ConfigureAwait(false);
}
catch (Exception e)
{
SchedulerException se = new SchedulerException($"JobListener '{jl.Name}' threw exception: {e.Message}", e);
throw se;
}
}
}