Guest User

Untitled

a guest
Dec 14th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. AgendarSchedulesCheckin abc = new AgendarSchedulesCheckin();
  2. abc.execute(null);
  3.  
  4. global class AgendarSchedulesCheckin Implements Schedulable {
  5.  
  6. global void execute(SchedulableContext sc)
  7. {
  8. Datetime horaAtual = datetime.now();
  9. Date dataAtual = horaAtual.date();
  10. Integer horaJob = horaAtual.hour();
  11. Integer diaJob;
  12. Integer mesJob;
  13.  
  14. if(horaJob == 23){
  15. dataAtual = dataAtual+1;
  16. horaJob = 0;
  17. }
  18.  
  19. diaJob = dataAtual.day();
  20. mesJob = dataAtual.month();
  21.  
  22. String cron_exp = '0 44 '+horaJob+' '+diaJob+' '+mesJob+' ?';
  23. String jobName = 'jobTeste';
  24. System.Schedule(jobName, cron_exp, new AgendarSchedulesCheckin());
  25.  
  26. Integer horaAux = 45;
  27.  
  28. for(Integer x = 0; x < 3; x++){
  29. cron_exp = '0 '+horaAux+' '+horaJob+' '+diaJob+' '+mesJob+' ?';
  30. jobName = 'jobTeste '+x;
  31. System.Schedule(jobName, cron_exp, new DeletarSemCheckinSchedule());
  32. horaAux = horaAux+3;
  33. }
  34. }
  35. }
Add Comment
Please, Sign In to add comment