Correct an error code for the first article.
The following is the error code, which does not know if the Jobid is already present in the system
// instantiates a job key object that is used to obtain a job object or to determine whether a job exists. New Jobkey (identity); // the same job has been added through the Job Ke object, if not null Ijobdetail job = Scheduler. Getjobdetail (Jobkey); // checks whether the job exists in the schedule, exists, and deletes the job if the parameters change. if (scheduler. Checkexists (Jobkey) && job. jobdatamap["cron"]. ToString () ! = Cron) { Scheduler. Deletejob (Jobkey);}
The correct way to get Jobkey and Ijobdetail objects is as follows
This method uses the job's groupname group name for matching lookups, first returning all of the group's Jobkey and then iterating through the lookup.
What the? You didn't set groupname?
GroupName is default if GroupName is not set
Of course, you can also use groupmatcher<jobkey> to match other methods such as
Anygroup ();
Groupcontains (string compareTo);
Groupstartswith (string compareTo);
Groupendswith (string compareTo);
Groupequals (string compareTo);
//you first need to find the Iset collection of Jobkey based on the group name. groupmatcher<jobkey> Matcher = groupmatcher<jobkey>. Groupequals (groupName);//Note: This is not the iset<t> in System.Collection. quartz.collection.iset<jobkey> keys =Scheduler. Getjobkeys (matcher);//using enumeration objects to loop through lookupsvarEn =keys. GetEnumerator (); while(en. MoveNext ()) {stringrowID = en. Current.Name.Replace ("Reporttime",""); if(dt. Select ("id= '"+ rowID +"'"). Length = =0) {Loghelper.addlog ("Timing Module","detects that the schedule configuration information does not already exist and will delete the scheduled calculation task. ",""); Scheduler. Deletejob (en. Current); }}
Open source Job scheduling framework-quartz.net-Practical use 2