Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding and removing jobs dynamically to Quartz.NET Windows Service

I am developing an email marketing WinForm application. And for the scheduling of campaigns, I decided to use Quartz.NET. I need it to be running as a Windows Service. but I also want the user to be able to add a job (e.g. a campaign that needs to be run everyday at 8 AM which is basically running a .bat file) to the service through the program.

I am also saving all the job schedules in the database so that when you stop/start the OS or Windows Service it can still read from all the jobs that need to be run.

How can I add a job to the service while the service is running? The dynamic addition/removal of the job to the service is of course much preferred. Stopping the service and reading all the jobs again from the database is, to be frank, my last resort.

like image 632
disasterkid Avatar asked Sep 18 '14 08:09

disasterkid


1 Answers

You can install Quartz.Net as a windows service and configure it to use AdoJobStore.
Your WinForm application will be the interface where you can add, suspend and remove jobs and triggers.

You do not have to stop your windows services while you're doing that.

You do not need to read your database to figure out what's happening in Quartz but you must use the APIs provided.

I've done something similar long time ago; my quartz.net "manager" was a web application.

You can read my answer here.

I guess the steps to do what you're looking for a pretty much the same.

Reference to Quartz.net samples and a free book can be found here and here.

like image 77
LeftyX Avatar answered Oct 03 '22 01:10

LeftyX