我使用以下方式在星期一每两周运行一次计划.
ITrigger trigger = TriggerBuilder.Create() .StartAt(DateBuilder.DateOf(StartHour,StartMinute,StartSeconds,StartDate,StartMonth,StartYear)) .WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(Int32.Parse(nWeekInterval))) .EndAt(DateBuilder.DateOf(0,EndDay,EndMonth,EndYear)) .Build();
但是我如何使用单一的时间表在星期一和星期二运行.请指教.
解决方法
您可以使用DailyTimeIntervalScheduleBuilder指定一周中的几天
var onMondayAndTuesday = DailyTimeIntervalScheduleBuilder.Create() .OnDaysOfTheWeek(new DayOfWeek[] { DayOfWeek.Monday,DayOfWeek.Tuesday }); var trigger = TriggerBuilder.Create() .StartAt(DateBuilder.DateOf(StartHour,StartYear)) .WithSchedule(onMondayAndTuesday) .WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(Int32.Parse(nWeekInterval))) .EndAt(DateBuilder.DateOf(0,EndYear)) .WithIdentity(triggerKey) .Build();