Chris
Chris

Reputation: 7611

Editting jobs CronExpression programatically in Quartz.NET - what methods?

what methods are there for a CronTrigger to modify its CronExpression? I've tried to set it in the CronExpressionString but that doesn't seem to update it, and I can't convert my string to a CronExpression to use in the CronExpression method.

Upvotes: 2

Views: 1546

Answers (2)

jvilalta
jvilalta

Reputation: 6769

There really is no way to modify a trigger's cron expression through the API. The "normal" way to do what you want is to create a new trigger with the new cron expression and then either reschedule the job with the new trigger or delete and create the job with the new trigger.

If you're using a database as your job store, the cron expression is stored in the CRON_EXPRESSION column of the QRTZ_CRON_TRIGGERS table. Changing it directly in the database is probably not the best option but you could give it a try and see what happens.

Upvotes: 0

Brad Bruce
Brad Bruce

Reputation: 7807

You would load the job to a local variable using GetJobDetail().
Then UnscheduleJob()
Finally, you'd create a new CronTrigger and call ScheduleJob().

-- Edit --
It has come to may attention that an easier way is Create a new trigger (of any type) and call RescheduleJob() using the same trigger name and group.

Upvotes: 1

Related Questions