Calling schedule with ScheduleJobs

半腔热情 提交于 2019-11-30 23:09:51

Make sure you use the collections from Quartz's namespace, here's a version of your code that compiles:

IJobDetail jobDetail = JobBuilder.Create<ReportJob>()
    .WithIdentity("theJob")
    .Build();
ITrigger everydayTrigger = TriggerBuilder.Create()
    .WithIdentity("everydayTrigger")
    // fires 
    .WithCronSchedule("0 0 12 1/1 * ?")
    // start immediately
    .StartAt(DateBuilder.DateOf(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year))
    .Build();
ITrigger yearlyTrigger = TriggerBuilder.Create()
    .WithIdentity("yearlyTrigger")
    // fires 
    .WithCronSchedule("0 0 12 1 1 ? *")
    // start immediately
    .StartAt(DateBuilder.DateOf(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year))
    .Build();
var dictionary = new Dictionary<IJobDetail, Quartz.Collection.ISet<ITrigger>>();
dictionary.Add(jobDetail, new Quartz.Collection.HashSet<ITrigger>()
                            {
                                everydayTrigger,
                                yearlyTrigger
                            });
sched.ScheduleJobs(dictionary, true);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!