Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz.NET, Recur Every x Weeks

i need to implement the following scenario using Quartz.NET:

Recur every n week(s) on:
Sunday and/or Monday, Tuesday, Wednesday, Thursday, Friday, Saturday...

So for example i might select: monday and thursday, and recur every 2 weeks, is this possible?

I figure it out that the way to go might be using Cron Expressions, but i haven't had luck so far with the "Recur Every X Weeks"

Thanks!

like image 650
Bongo Sharp Avatar asked Feb 01 '11 17:02

Bongo Sharp


3 Answers

Is running Quartz.Net 2.0 and option for you? It has not been officially released yet, but in it there is a new trigger type that solves your problem. It's called the calendar interval trigger. Basically you define it just as you described in your question. You set the interval to 2 and the interval unit to weeks, and it fires every 2 weeks. I've written a post describing it here. You can access the source code documentation here.

like image 187
jvilalta Avatar answered Nov 10 '22 05:11

jvilalta


This is the solution that i used...

When there is no recurence i use a cron trigger and select the days and make it run every week

E.G. 0 0 * * 1,2,3

when there is recurence for each selected day i add a SimpleTrigger, bassically the start date is the day of the week, and then i calculate the recurrence by multiplying the recurence for 7

So i will end up wit one simpletrigger for each day.

I hope this helps someone else!

like image 31
Bongo Sharp Avatar answered Nov 10 '22 03:11

Bongo Sharp


It is a complext trigger, you can manage by 3 triggers;

  1. trigger 2 weeks sample cron: "0 0 0 1 *"
  2. trigger 2 weeks sample cron: "0 0 0 15 *"
  3. trigger trig selected days sample cron: "0 0 0 ? * SUN-SAT"

first trigger will create 3. second trigger will remove 3.

Good luck.

like image 33
Nuri YILMAZ Avatar answered Nov 10 '22 05:11

Nuri YILMAZ