Schedule Entry Execution
Author: dhananjay_malpu
Publication Date: 2/19/2015 12:36
Hi All,
Greetings !!
Could you please let me know on following query :
I have existing schedule entry setup on the server. I am trying to update existing schedule entry execution time with future time (+5 minutes from current time) using below code snippet but I am unable to see updated entry in Scheduling -> planned schedule entries :
Code snippet :
executeUserFutureScheduleTask(String schedulename) {
currentProject = context.getProject();
scheduleStorage = context.requireSpecialist(ServicesBroker.TYPE).getService(AdminService.class).getScheduleStorage();
scheduleEntry = scheduleStorage.getScheduleEntry(currentProject,schedulename) ;
executionSchedule = scheduleEntry.getExecutionSchedule() ;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, 5); //increasing current time by 5 minutes
Date updatedScheduleDate = cal.getTime();
if(executionSchedule != null ) {
executionSchedule.setNextExecutionTime(updatedScheduleDate) ;
}
//control = scheduleEntry.execute();
//control.awaitTermination();
}
//calling the function by passing schedule name
schedulename = "Operationalsite Schedule Test";
executeUserFutureScheduleTask(schedulename) ;
Kindly note : If I uncomment below two commented lines ( from above code snippet ) then schedule task will be executed immediately even thought it's scheduled as a future schedule entry.
//control = scheduleEntry.execute();
//control.awaitTermination();
Many thank you in advance.
Cheers
Dhananjay
-
Author: Peter_Jodeleit - 2/19/2015 16:49
Try first "lock()", than do your modification, than "save()" and "unlock()".
"execute()" is for immediate execution, so it's behaving correctly.
0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
1 commentaire