I am trying to implement Quartz.NET as a Windows service in C #. My assignments do not work when I expect them to start working ... in general, in fact, as far as I can tell?
I have a schedule of my work, starting the next smooth minute after the "flight". However, when the next minute comes, I can’t say if something is really happening.
I would suggest that when my work starts, the CLI window will appear during the execution of the task, and the console operations will be visible (I even set it Console.ReadKey()there so that the window does not open and does not close so quickly I can’t see this), but as far as I can tell, the schedule simply does not complete the tasks.
I noticed that all the time in UTC and what StartTimeUtcwill be set to UTC, which is +6 hours from my local computer time, but I also assume that the Quartz scheduler handles this by calculating the runtime from my TimeZone setting, although I don’t know that I know to confirm this, or to confirm the ACTUAL time for which my schedule is set.
I suppose there is some way to configure the Common Logging assembly and use it to help me find out what my status is, but I still have to figure out what to do with this in order to enable some kind of log for feedback from my Windows Service, except for writing to the event log that I created for it.
My OnStart function of my windows service
protected override void OnStart(string[] args)
{
eventLog.WriteEntry("--- STARTING eLoyalty Scheduler Service ---");
ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler();
JobDetail jobDetail = new JobDetail("eLoyaltySchedulerService", null, typeof(PortalSchedulerJob));
jobDetail.JobDataMap["jobSays"] = "eLoyalty Scheduler Service Executing!";
jobDetail.JobDataMap["myStateData"] = new ArrayList();
Trigger trigger = TriggerUtils.MakeMinutelyTrigger();
trigger.StartTimeUtc = TriggerUtils.GetEvenMinuteDate(DateTime.UtcNow);
trigger.Name = "NextEvenMinute";
sched.ScheduleJob(jobDetail, trigger);
sched.Start();
eventLog.WriteEntry("--- STARTED eLoyalty Scheduler Service ---");
}
The function My Job Execute () is as follows:
public void Execute(JobExecutionContext context)
{
try
{
string instName = context.JobDetail.Name;
string instGroup = context.JobDetail.Group;
JobDataMap dataMap = context.MergedJobDataMap;
string jobSays = dataMap.GetString("jobSays");
ArrayList state = (ArrayList)dataMap["myStateData"];
state.Add(DateTime.UtcNow);
Console.WriteLine("Instance {0} of PortalSchedulerJob says: {1} @ {2}", instName, jobSays, DateTime.UtcNow);
Console.ReadKey();
}
catch (JobExecutionException Ex)
{
throw Ex;
}
}
, ACTUAL, ...?