In quartz_jobs.xml, I can set some parameters for the job.....
<job>
<name>MyJob</name>
<group>MyJob</group>
<description>My Job</description>
<job-type>MyAssembly.MyJob, MyAssembly</job-type>
<durable>true</durable>
<recover>false</recover>
<job-data-map>
<entry>
<key>JobMapDataKeyOne</key>
<value>JobMapDataValueOne</value>
</entry>
<entry>
<key>JobMapDataKeyTwo</key>
<value>JobMapDataValueTwo</value>
</entry>
</job-data-map>
</job>
and here is the code:
public class MyJob: IJob
{
public virtual void Execute(IJobExecutionContext context)
{
JobKey key = context.JobDetail.Key;
JobDataMap jbDataMap = context.JobDetail.JobDataMap;
string jobMapDataValueOne = jbDataMap.GetString("JobMapDataKeyOne");
string jobMapDataValueTwo = jbDataMap.GetString("JobMapDataKeyOne");
}
}
Now, I can "code up a job and trigger" (not using .xml setup) (code not seen).... and I can get the below to work. (And have populated values for triggerParameter001Value and triggerParameter002Value ).
public class MyJob: IJob
{
public virtual void Execute(IJobExecutionContext context)
{
JobKey key = context.JobDetail.Key;
JobDataMap trgDataMap = context.Trigger.JobDataMap;
string triggerParameter001Value = trgDataMap.GetString("TriggerParameter001Key");
string triggerParameter002Value = trgDataMap.GetString("TriggerParameter002Key");
}
}
But I don't see a way to pass parameters for the Trigger...defined in the xml.
I searched for
"trigger-data-map"
and
"jobtrigger-data-map"
to no avail.
I fished around the "http://quartznet.sourceforge.net/JobSchedulingData" xsd as well. Is this just missing in the xml? Am I missing something?
Ok. This one was SNEAKY!
The below will NOT work: (note the position of "job-data-map" element ~under the "simple" element)
The above xml was giving me an error like this:
Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin.ProcessFile Error Error scheduling jobs: The element 'simple' in namespace 'http://quartznet.sourceforge.net/JobSchedulingData' has invalid child element 'job-data-map' in namespace 'http://quartznet.sourceforge.net/JobSchedulingData'.
........................
The below WILL work (note the position change of "job-data-map" (still under "simple" element, but moved "up" some)
Why?
The xsd uses an abstractType
So everything that is a part of the abstract has to be defined ~before~ any of the concrete properties.
That is sneaky!