I am new to Quartz and want to use it to schedule scripts in SQLServer using a service for clients using SQL Server Express.
I need a user to be able to schedule a task to run, say every second week starting from a particular date. eg: StartDate = 1/Jan/2013 12:00PM (Tuesday) and repeat every 14 days.
In the setup for the job, there is a StartTime (datetime), IntervalUnit (second, minute, hour, day, week, year) and RepeatsEvery (the number of intervals to fire after the start date).
eg: a setup of StartDate = "1/JAN/2013 12:00PM" and IntervalUnit = "DAY" and RepeatsEvery= 14, would fire the job every 2nd Tuesday at 12:00PM. If the StartDate is already passed, I need the job to fire on the next start date, eg: If I started the service today (18/JAN/2013), the next startdate would be 29/JAN/2013 12:00PM
I can't figure out how to make this work in Quartz, using the Calendar Trigger. Is this something that is built in to Quartz or do I need to calculate a new StartTime on startup?
Assuming I have to calculate a new StartTime, is there any built in function or neat shortcut for this, or do I need a function similar to this for each IntervalUnit:
'Days
Dim diff As Integer
diff = Now.Subtract(.StartTime).TotalDays
Dim offset As Integer
offset = .RepeatsEvery - (diff Mod .RepeatsEvery)
offset = Now.AddDays(offset).Subtract(.StartTime).TotalDays 'Get the days from Start t preserve time of day
Start = .StartTime.AddDays(offset)