本文整理汇总了C#中SchedulerInstruction类的典型用法代码示例。如果您正苦于以下问题:C# SchedulerInstruction类的具体用法?C# SchedulerInstruction怎么用?C# SchedulerInstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SchedulerInstruction类属于命名空间,在下文中一共展示了SchedulerInstruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TriggerComplete
public override void TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
Log.TraceFormat("Trigger complete for job {0} with scheduler instruction {1}",
context.JobDetail.JobType,
triggerInstructionCode
);
}
示例2: TriggerComplete
/// <summary>
/// Called by the <see cref="IScheduler" /> when a <see cref="ITrigger" />
/// has fired, it's associated <see cref="IJobDetail" />
/// has been executed, and it's <see cref="IOperableTrigger.Triggered" /> method has been
/// called.
/// </summary>
/// <param name="trigger"></param>
/// <param name="context"></param>
/// <param name="triggerInstructionCode"></param>
public void TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
Logger.InfoFormat("TriggerComplete: {0}, {1}", trigger.Key.Name, trigger.Key.Group);
var auditLog = GetAuditLog(trigger, "TriggerComplete", context);
_persistanceStore.InsertAuditLog(auditLog);
}
示例3: TriggerComplete
public void TriggerComplete(Trigger trigger, JobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
if (!trigger.Name.Equals("TimerTrigger"))
{
Account account = (Account)trigger.JobDataMap.Get("account");
if (account != null)
{
SimpleTrigger triggerObject = new SimpleTrigger(account.Login + "Trigger", "account", DateTime.MinValue, null, 0, TimeSpan.Zero);
triggerObject.JobName = account.Login + "Job";
triggerObject.StartTimeUtc = DateTime.UtcNow.AddSeconds(new Random().Next(account.Settings.NextTimeLoginMin, account.Settings.NextTimeLoginMax));
account.SchedulerTrigger = triggerObject;
triggerObject.JobDataMap.Add("account", account);
m_accountManager.SetNextLoginTimeForAccount(account);
}
}
}
示例4: TriggerComplete
public void TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
try
{
//var executationDuration = (DateTime.UtcNow - trigger.GetPreviousFireTimeUtc()).Value.TotalSeconds;
var executionDuration = context.JobRunTime.TotalSeconds;
TriggerStatistic triggerStat = new TriggerStatistic()
{
Group = trigger.Key.Group,
JobKey = trigger.JobKey.Name,
TriggerKey = trigger.Key.Name,
ExecutionDurationInSeconds = executionDuration,
StartTime = trigger.GetPreviousFireTimeUtc().Value.DateTime.ToLocalTime(),
FinishTime = DateTime.Now
};
Sitecore.Diagnostics.Log.Info(String.Format("Job {0} with trigger {1} Completed @ {2} and it took {3} seconds ", triggerStat.JobKey, triggerStat.TriggerKey, DateTime.Now, triggerStat.ExecutionDurationInSeconds), this);
string triggerStatProviderType = Settings.GetSetting("Sitecore.QuartzScheduler.TriggerStatisticsStoreProvider");
if (!String.IsNullOrEmpty(triggerStatProviderType))
{
var triggerStatsProvider = Activator.CreateInstance(Type.GetType(triggerStatProviderType)) as ITriggerStatisticsStore;
triggerStatsProvider.SaveTriggerStatistic(triggerStat);
}
else
{
Sitecore.Diagnostics.Log.Warn("Sitecore.QuartzScheuler: Missing App Setting value for Sitecore.QuartzScheduler.TriggerStatisticsStoreProvider", this);
}
}
catch(Exception ex)
{
Sitecore.Diagnostics.Log.Error("Exception in TriggerComplete: " + ex.Message + Environment.NewLine + ex.StackTrace, this);
}
}
示例5: 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;
}
}
}
示例6: TriggerComplete
public void TriggerComplete(ITrigger trigger,
IJobExecutionContext context,
SchedulerInstruction triggerInstructionCode)
{
}
示例7: TriggerComplete
public Task TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
return Task.WhenAll(listeners.Select(l => l.TriggerComplete(trigger, context, triggerInstructionCode)));
}
示例8: TriggeredJobComplete
protected virtual void TriggeredJobComplete(ConnectionAndTransactionHolder conn,
IOperableTrigger trigger,
IJobDetail jobDetail, SchedulerInstruction triggerInstCode)
{
try
{
if (triggerInstCode == SchedulerInstruction.DeleteTrigger)
{
if (!trigger.GetNextFireTimeUtc().HasValue)
{
// double check for possible reschedule within job
// execution, which would cancel the need to delete...
TriggerStatus stat = Delegate.SelectTriggerStatus(conn, trigger.Key);
if (stat != null && !stat.NextFireTimeUtc.HasValue)
{
RemoveTrigger(conn, trigger.Key);
}
}
else
{
RemoveTrigger(conn, trigger.Key);
SignalSchedulingChangeOnTxCompletion(null);
}
}
else if (triggerInstCode == SchedulerInstruction.SetTriggerComplete)
{
Delegate.UpdateTriggerState(conn, trigger.Key, StateComplete);
SignalSchedulingChangeOnTxCompletion(null);
}
else if (triggerInstCode == SchedulerInstruction.SetTriggerError)
{
Log.Info("Trigger " + trigger.Key + " set to ERROR state.");
Delegate.UpdateTriggerState(conn, trigger.Key, StateError);
SignalSchedulingChangeOnTxCompletion(null);
}
else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersComplete)
{
Delegate.UpdateTriggerStatesForJob(conn, trigger.JobKey, StateComplete);
SignalSchedulingChangeOnTxCompletion(null);
}
else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersError)
{
Log.Info("All triggers of Job " + trigger.JobKey + " set to ERROR state.");
Delegate.UpdateTriggerStatesForJob(conn, trigger.JobKey, StateError);
SignalSchedulingChangeOnTxCompletion(null);
}
if (jobDetail.ConcurrentExecutionDisallowed)
{
Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jobDetail.Key, StateWaiting, StateBlocked);
Delegate.UpdateTriggerStatesForJobFromOtherState(conn, jobDetail.Key, StatePaused, StatePausedBlocked);
SignalSchedulingChangeOnTxCompletion(null);
}
if (jobDetail.PersistJobDataAfterExecution)
{
try
{
if (jobDetail.JobDataMap.Dirty)
{
Delegate.UpdateJobData(conn, jobDetail);
}
}
catch (IOException e)
{
throw new JobPersistenceException("Couldn't serialize job data: " + e.Message, e);
}
catch (Exception e)
{
throw new JobPersistenceException("Couldn't update job data: " + e.Message, e);
}
}
}
catch (Exception e)
{
throw new JobPersistenceException("Couldn't update trigger state(s): " + e.Message, e);
}
try
{
Delegate.DeleteFiredTrigger(conn, trigger.FireInstanceId);
}
catch (Exception e)
{
throw new JobPersistenceException("Couldn't delete fired trigger: " + e.Message, e);
}
}
示例9: TriggerComplete
public Task TriggerComplete(ITrigger trigger,
IJobExecutionContext context,
SchedulerInstruction triggerInstructionCode)
{
return TaskUtil.CompletedTask;
}
示例10: VetoedJobRetryLoop
/// <summary>
/// Vetoeds the job retry loop.
/// </summary>
/// <param name="trigger">The trigger.</param>
/// <param name="jobDetail">The job detail.</param>
/// <param name="instCode">The inst code.</param>
/// <returns></returns>
public bool VetoedJobRetryLoop(Trigger trigger, JobDetail jobDetail, SchedulerInstruction instCode)
{
while (!shutdownRequested)
{
try
{
Thread.Sleep(5 * 1000); // retry every 5 seconds (the db
// connection must be failed)
qs.NotifyJobStoreJobVetoed(schdCtxt, trigger, jobDetail, instCode);
return true;
}
catch (JobPersistenceException jpe)
{
qs.NotifySchedulerListenersError(
string.Format(CultureInfo.InvariantCulture, "An error occured while marking executed job vetoed. job= '{0}'", jobDetail.FullName), jpe);
}
catch (ThreadInterruptedException)
{
}
}
return false;
}
示例11: TriggeredJobComplete
public void TriggeredJobComplete(Trigger trigger, IScheduledJob job, SchedulerInstruction triggerInstCode)
{
lock (_triggerLock)
{
JobWrapper jw = _jobsDictionary[job.Name] as JobWrapper;
TriggerWrapper tw = _triggersDictionary[trigger.Name] as TriggerWrapper;
// even if it was deleted, there may be cleanup to do
_blockedJobs.Remove(job.Name);
// check for trigger deleted during execution...
if (tw != null)
{
if (triggerInstCode == SchedulerInstruction.DeleteTrigger)
{
//log.Debug("Deleting trigger");
NullableDateTime d = trigger.GetNextFireTimeUtc();
if (!d.HasValue)
{
// double check for possible reschedule within job
// execution, which would cancel the need to delete...
d = tw.Trigger.GetNextFireTimeUtc();
if (!d.HasValue)
{
RemoveTrigger(trigger.Name);
}
else
{
log.Debug("Deleting cancelled - trigger still active");
}
}
else
{
RemoveTrigger(trigger.Name);
}
}
else if (triggerInstCode == SchedulerInstruction.SetTriggerComplete)
{
tw.State = InternalTriggerState.Complete;
_timeTriggers.Remove(tw);
}
else if (triggerInstCode == SchedulerInstruction.SetTriggerError)
{
log.Info(string.Format(CultureInfo.InvariantCulture, "Trigger {0} set to ERROR state.", trigger.Name));
tw.State = InternalTriggerState.Error;
}
else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersError)
{
log.Info(string.Format(CultureInfo.InvariantCulture, "All triggers of Job {0} set to ERROR state.", trigger.Name));
SetAllTriggersOfJobToState(trigger.Name, InternalTriggerState.Error);
}
else if (triggerInstCode == SchedulerInstruction.SetAllJobTriggersComplete)
{
SetAllTriggersOfJobToState(trigger.Name, InternalTriggerState.Complete);
}
}
}
}
示例12: TriggerComplete
public void TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode)
{
Write("{0} -- {1} -- Trigger ({2}) completed", Name, DateTime.Now, trigger.Key);
}
示例13: NotifyJobStoreJobComplete
/// <summary>
/// Notifies the job store job complete.
/// </summary>
/// <param name="trigger">The trigger.</param>
/// <param name="detail">The detail.</param>
/// <param name="instCode">The instruction code.</param>
public virtual void NotifyJobStoreJobComplete(IOperableTrigger trigger, IJobDetail detail, SchedulerInstruction instCode)
{
resources.JobStore.TriggeredJobComplete(trigger, detail, instCode);
}
示例14: TriggeredJobCompleteCallback
public TriggeredJobCompleteCallback(JobStoreSupport js, SchedulingContext ctxt, Trigger trigger,
SchedulerInstruction triggerInstCode, JobDetail jobDetail)
: base(js)
{
this.ctxt = ctxt;
this.trigger = trigger;
this.triggerInstCode = triggerInstCode;
this.jobDetail = jobDetail;
}
示例15: TriggeredJobComplete
/// <summary>
/// Inform the <see cref="IJobStore" /> that the scheduler has completed the
/// firing of the given <see cref="Trigger" /> (and the execution its
/// associated <see cref="IJob" />), and that the <see cref="JobDataMap" />
/// in the given <see cref="JobDetail" /> should be updated if the <see cref="IJob" />
/// is stateful.
/// </summary>
public virtual void TriggeredJobComplete(SchedulingContext ctxt, Trigger trigger, JobDetail jobDetail,
SchedulerInstruction triggerInstCode)
{
ExecuteInNonManagedTXLock(LockTriggerAccess,
new TriggeredJobCompleteCallback(this, ctxt, trigger, triggerInstCode, jobDetail));
}