How can I run a quartz chart on Monday and Tuesday every two weeks?

I used the following method to run the schedule every two weeks on Monday.

ITrigger trigger = TriggerBuilder.Create() .StartAt(DateBuilder.DateOf(StartHour, StartMinute, StartSeconds, StartDate, StartMonth, StartYear)) .WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(Int32.Parse(nWeekInterval))) .EndAt(DateBuilder.DateOf(0, 0, 0, EndDay, EndMonth, EndYear)) .Build(); 

But how can I use one schedule to run on Monday and Tuesday. Please advice.

+6
source share
3 answers

You can specify days of the week with DailyTimeIntervalScheduleBuilder

 var onMondayAndTuesday = DailyTimeIntervalScheduleBuilder.Create() .OnDaysOfTheWeek(new DayOfWeek[] { DayOfWeek.Monday, DayOfWeek.Tuesday }); var trigger = TriggerBuilder.Create() .StartAt(DateBuilder.DateOf(StartHour, StartMinute, StartSeconds, StartDate, StartMonth, StartYear)) .WithSchedule(onMondayAndTuesday) .WithCalendarIntervalSchedule(x => x.WithIntervalInWeeks(Int32.Parse(nWeekInterval))) .EndAt(DateBuilder.DateOf(0, 0, 0, EndDay, EndMonth, EndYear)) .WithIdentity(triggerKey) .Build(); 
+5
source

I would create one task with two different triggers. Each trigger fires once every two weeks (or half a month).

+1
source

Use the following expression to schedule an assignment on alternate Mondays and Mondays.

 0 0 0 1-7,15-21,29-31 * 1,2 * 

This is how the expression is described.

0 - 0 sec

0 - 0 min

0 - 0th hr

1-7,15-21,29-31 - in the alternative week of the month

  • - any month

1.2 - Monday and Tuesday

  • - Any year.
0
source

Source: https://habr.com/ru/post/984411/


All Articles