Configure a CronString for a BiWeekly job in Quartz.Net

给你一囗甜甜゛ 提交于 2019-12-02 02:23:13

Actually what you might be looking for is CalenderIntervalTrigger, which is capable to do this easily.

var trigger = TriggerBuilder.Create()
    .StartAt(new DateTime(2012, 11, 19, 12, 0, 0).ToUniversalTime())
    .WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(2))
    .Build();

A "cron expresssion" can be created as follows for any frequency of the week.

int repeatInterval = 2;
int weeklyInterval = repeatInterval*7;
String cronExp="0 0 12 1/ " +weeklyInterval " * ? *";

Creates a cron expression which repeats bi-weekly at 12.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!