I'm using the Quartz.net scheduler for the first time. I'm trying to run a specific process for different locations based on the locations time zone. I wanted to pass the schedule dynamically say the time and the location details to the scheduler. How can I achieve that. Any help here is much appreciated. Below is the code that I'm at right now. My Problem right now is that if do a for loop of all the below code I can process only one record at a time which is going to hit the performance or if I just include the datamap logic in the for loop only the last record will be send when the scheduler is actually started and I don't know how to pass the time to the trigger as it is out of the loop.
public ISchedulerFactory objSchedulerFact;
private IScheduler objScheduler;
protected override void OnStart(string[] args)
{
objScheduler = objSchedulerFact.GetScheduler();
IJobDetail objEslJobDet = JobBuilder.Create<ESLPriceAuditProcessor>()
.WithIdentity("ESLJob", "ESL")
.Build();
objEslJobDet.JobDataMap.Put("Location", 100); // Pass the value here dynamically by taking the data from a table
IJobDetail objSignJobDet = JobBuilder.Create<SignPriceAuditProcessor>()
.WithIdentity("SignJob", "Sign")
.Build();
objSignJobDet.JobDataMap.Put("Location", 200);
ITrigger objESLJobTrigger = TriggerBuilder.Create()
.WithIdentity("ESLTrigger", "ESL")
.StartAt(DateTime.Today.AddHours(2)) //Pass the time hours dynamically. I wanted execute the process for the given location based on the location time, say 4 AM at their respective timezone. Example, if i'm running the code on the server in CST time zone and I want to run this process for a EST location at current time CST Time + 2 hours and so on. I can configure the number of hours difference in the database based on the location, but how can I pass that dynamically.
.EndAt(DateTime.Today.AddHours(22))
.WithSchedule(SimpleScheduleBuilder.Create().WithIntervalInHours(4))
.Build();
ITrigger objSignJobTrigger = TriggerBuilder.Create()
.WithIdentity("SignTrigger", "SIGN")
.StartAt(DateTime.Today.AddHours(4))
.EndAt(DateTime.Today.AddHours(22))
.WithSchedule(SimpleScheduleBuilder.Create().WithIntervalInHours(4))
.Build();
objScheduler.ScheduleJob(objEslJobDet, objESLJobTrigger);
objScheduler.ScheduleJob(objSignJobDet, objSignJobTrigger);
objScheduler.Start();
}