plugins.scheduler - checking for existence of a job entry

Questions and answers on developing, deploying and using plugins and JavaBeans

plugins.scheduler - checking for existence of a job entry

Postby huber » Mon Mar 09, 2015 5:00 pm

Calling the same batch process in two forms in the onLoad method, I check if the batch process name already exists.
This works but periodically I get the attached error. I assume it's because the check (if condition) is made in the moment the new batch process is just about to be called but it's name not yet in the currentJobNames array. Can this be somehow avoided?

This ist my code:

Code: Select all
var currentJobNames = plugins.scheduler.getCurrentJobNames();
if (currentJobNames.indexOf('timTimetableBatchProcess') < 0) {
   globals.timTimetableBatchProcess(); // Batch process 'timTimetableBatchProcess' is not running, start it
}


... and the batch process code.

Code: Select all
function timTimetableBatchProcess() {
   var startDate = new Date();
   startDate.setTime(startDate.getTime() + 10000); // Start the batch job every 10'000 milliseconds
   var endDate = new Date(startDate.getTime() + 100000); // Set end time greater than start time to avoid running multiple copies of this method

   plugins.scheduler.addJob('timTimetableBatchProcess', startDate, globals.timTimetableBatchProcess, 0, 0, endDate);
   
   if ('TimClassTimetable' in forms) {
      forms.TimClassTimetable.refresh(); // Refresh the class timetable
   }

   if ('TimTeacherTimetable' in forms) {
      forms.TimTeacherTimetable.refresh(); // Refresh the teacher timetable
   }
}
Attachments
Screen Shot 2015-03-09 at 15.44.50.png
Screen Shot 2015-03-09 at 15.44.50.png (33.17 KiB) Viewed 2313 times
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 516
Joined: Mon May 14, 2012 11:31 pm

Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 15 guests

cron