-3

I've inherited an application which uses Quartz.NET

I have no idea how to maintain/use this and need to add a new Job.

I created a new Job class and added it to the jobs xml file as an element under <schedule>.

Will this automatically add the appropriate row to the CRON_TRIGGERS table?
Or is there some other step?
Or do I need to manually insert a row into the CRON_TRIGGERS table?

Thanks

onefootswill
  • 3,707
  • 6
  • 47
  • 101

1 Answers1

-1

You can create a new job by using something like

var jobBuilder = new JobBuilder.Create<IJob>()
                               .SetJobDataMap(jobDataMap)
                               .Build();

IJob will be a class that will be derived from the IJob interface. The JobDataMap can be instantiated with a dictionary with the given data. You can retrieve the data from the IJob Execute method with something like IJobExecutionContext.JobDetail.JobDataMap["aKeyInYourDictionary"]

Now you'll have to set a trigger to run the job every x milliseconds.

var triggerBuilder = new TriggerBuilder.Create().StartNow().WithSimpleSchedule(x => x.WithInterval(timeInMilliSeconds).RepeatForever());

Finally use the IScheduler.ScheduleJob(jobBuilder, triggerBuilder) to schedule the job.

Prasanth Louis
  • 4,658
  • 2
  • 34
  • 47
  • @Prasanthe Thanks, but that will not work in the architecture of this application. It uses xml to schedule jobs and runs as a windows service. It gets the jobs like this `nameValueCollection[QuartzPluginXmlFilenamesKey] = @"~\Jobs.xml";` and passes `nameValueCollection` into StdSchedulerFactory like this `ISchedulerFactory stdSchedulerFactory = new StdSchedulerFactory(nameValueCollection);` – onefootswill Jun 26 '17 at 01:39