我是Quartz的新手。我不知道是否有任何解决方案可以获得将在特定日期解雇的所有工作?
说,我创建了以下几项工作:
现在,是否有任何解决方案可以帮助我获得在特定日期开火的所有工作?
例如:
在下一个星期一,将返回作业“A”,“B”和“C”。并且应该有多个“C”,因为它将每小时被解雇。
在下一个星期五,将返回作业“A”和“C”。并且应该有多个“C”,因为它将每小时被解雇。
答案 0 :(得分:0)
如果您获得了用于作业的触发器实例,则可以使用ITrigger
interface中定义的以下方法:
// Returns the next time at which the Quartz.ITrigger will fire, after the given
// time. If the trigger will not fire after the given time, null will be returned.
DateTimeOffset? GetFireTimeAfter(DateTimeOffset? afterTime);
// Summary:
// Returns the next time at which the Quartz.ITrigger is scheduled to fire. If the
// trigger will not fire again, null will be returned. Note that the time returned
// can possibly be in the past, if the time that was computed for the trigger to
// next fire has already arrived, but the scheduler has not yet been able to fire
// the trigger (which would likely be due to lack of resources e.g. threads).
//
// Remarks:
// The value returned is not guaranteed to be valid until after the Quartz.ITrigger
// has been added to the scheduler.
DateTimeOffset? GetNextFireTimeUtc();
使用作业名称获取触发器:
JobKey jobKey = new JobKey("<job name>");
var triggers = await scheduler.GetTriggersOfJob(jobKey);