buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
global class LogAutoSendScheduleProduct implements Schedulable {
    global void execute(SchedulableContext SC) {
        Id execBTId = Database.executeBatch(new LogAutoSendBatchProduct(), 1);
    }
 
    public static void assignOneMinute() {
        // delete 実行済み
        Datetime addOneM = System.now().addMinutes(2);
        String CRON_EXP = '0 ' + 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 'LogAutoSendProduct%'];
        if (oldcron.size() == 0) {
            System.schedule('LogAutoSendProduct' + CRON_EXP, CRON_EXP, new LogAutoSendScheduleProduct());
        }
        for (CronTrigger ct :
                [SELECT Id FROM CronTrigger WHERE State = 'DELETED' and CronJobDetail.Name like 'LogAutoSendProduct%']) {
            System.abortJob(ct.id);
        }
    }
}