Search the FirstSpirit Knowledge Base
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
Try first "lock()", than do your modification, than "save()" and "unlock()".
"execute()" is for immediate execution, so it's behaving correctly.
Try first "lock()", than do your modification, than "save()" and "unlock()".
"execute()" is for immediate execution, so it's behaving correctly.
Hi Peter,
Thank you. It worked for me
Hello,
do you need further help or did Peters's reply already help you? If so, it would be great if you marked
his reply as "correct answer" so that other community users find the solution easily. If you have
already found a solution by yourself, it would be very kind of you, if you posted it here.
Best regards
Thorsten