Quartz.NET的簡單任務管理類:https://blog.csdn.net/weixin_42930928/article/details/85123007
1、首先擷取Scheduler
var scheduler = QuartzSchedulerMgr.GetScheduler()
2、擷取Scheduler中的JobGroupNames
var groups = scheduler.GetJobGroupNames();
3、for循環逐個對每個group進行處理,可以擷取到job的名稱資訊,以及觸發器trigger的下次執行時間等内容
foreach (var groupName in groups)
{
foreach (var jobKey in QuartzSchedulerMgr.GetScheduler().GetJobKeys(GroupMatcher<JobKey>.GroupEquals(groupName)))
{
string jobName = jobKey.Name;
string jobGroup = jobKey.Group;
var triggers = QuartzSchedulerMgr.GetScheduler().GetTriggersOfJob(jobKey);
foreach (ITrigger trigger in triggers)
{
trigger.GetNextFireTimeUtc();
}
}
}
注:下次觸發時間為UTC時間,我們這邊是中原標準時間,需要進行轉換
TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(triggers.ToList()[0].GetNextFireTimeUtc().ToString()))