If you're persisting your jobs (as you do) in a database you cannot create them all the time.
You have to check if they exists at the start-up.
Check my answer here for more details.
When Quartz.Net is initialized and you're using AdoJobStore, the scheduler fetches all the jobs/triggers save in the database.
In your IQuartzScheduler.Run()
you should check if the job is present:
this.Scheduler.GetJobDetail()
You can use this bit of code to test if it works:
IJobDetail helloJob = null;
ITrigger helloTrigger = null;
helloJob = this.Scheduler.GetJobDetail(new JobKey("HelloJob", "MyGroup"));
if (helloJob == null)
{
helloJob = JobBuilder.Create<Jobs.HelloJob>()
.WithIdentity("HelloJob", "MyGroup")
.RequestRecovery(true)
// .StoreDurably(true)
.Build();
helloTrigger = TriggerBuilder.Create()
.WithIdentity("HelloTrigger", "MyGroup")
.StartNow()
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInSeconds(20))
.Build();
this.Scheduler.ScheduleJob(helloJob, helloTrigger);
}
this.Scheduler.Start();
If you're using the latest Quartz.Net version there seem to be a problem with the database creation script.
I've noticed that the triggers don't fire. I've then created the database using the latest scripts from Quartz.Net repository on GitHub and it works properly.
Check this answer as well. There are few more details on Quartz.Net + AdoJobStore.