public without sharing class NFM501Schedule implements Schedulable {
|
public void execute(SchedulableContext SC) {
|
System.enqueueJob(new NFM501Controller());
|
}
|
|
public static void assignOneMinute() {
|
// delete 実行済み
|
Datetime addOneM = System.now().addSeconds(30);
|
String CRON_EXP = addOneM.second() + ' ' + addOneM.minute() + ' ' + addOneM.hour() + ' '
|
+ addOneM.day() + ' ' + addOneM.month() + ' ? ' + addOneM.year();
|
List<CronTrigger> oldcron = [select Id from CronTrigger where CronExpression = :CRON_EXP
|
and CronJobDetail.Name like 'NFM501Schedulex%'];
|
if (oldcron.size() == 0) {
|
System.schedule('NFM501Schedulex' + CRON_EXP, CRON_EXP, new NFM501Schedule());
|
}
|
for (CronTrigger ct :
|
[SELECT Id FROM CronTrigger WHERE State = 'DELETED'
|
and CronJobDetail.Name like 'NFM501Schedulex%']) {
|
System.abortJob(ct.id);
|
}
|
}
|
|
public static void assignTwoMinute() {
|
// delete 実行済み
|
Datetime addOneM = System.now();
|
|
String CRON_EXP = '0 ' + '0 ' + '12' + ' '
|
+ addOneM.day() + ' ' + addOneM.month() + ' ? ' + addOneM.year();
|
List<CronTrigger> oldcron = [select Id from CronTrigger where CronExpression = :CRON_EXP
|
and CronJobDetail.Name like 'NFM501Schedulex%'];
|
if (oldcron.size() == 0) {
|
System.schedule('NFM501Schedulex' + CRON_EXP, CRON_EXP, new NFM501Schedule());
|
}
|
|
for (CronTrigger ct :
|
[SELECT Id FROM CronTrigger WHERE State = 'DELETED'
|
and CronJobDetail.Name like 'NFM501Schedulex%']) {
|
System.abortJob(ct.id);
|
}
|
}
|
}
|