Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. using Quartz;
  2. using Quartz.Impl;
  3.  
  4. namespace Tasks
  5. {
  6. public class MaintenanceJob : IJob
  7. {
  8. public void Execute(IJobExecutionContext context)
  9. {
  10. var ftpLocation = context.JobDetail.JobDataMap.Get("ftp.location");
  11.  
  12. // zip old log files
  13. // delete the files once zip is completed
  14. // sftp the zip to another location
  15. }
  16. }
  17.  
  18. public class Triggers
  19. {
  20. public static ITrigger TimeTrigger()
  21. {
  22. return TriggerBuilder.Create()
  23. .WithDailyTimeIntervalSchedule
  24. (s =>
  25. s.WithIntervalInHours(24)
  26. .OnEveryDay()
  27. .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 0))
  28. )
  29. .Build();
  30. }
  31.  
  32. public static ITrigger CRONTrigger()
  33. {
  34. return TriggerBuilder.Create()
  35.  
  36. .WithCronSchedule("At 8:00am every Monday through Friday", s => s.WithMisfireHandlingInstructionDoNothing())
  37. .Build();
  38. }
  39. }
  40.  
  41. public class JobScheduler
  42. {
  43. public static void Start()
  44. {
  45. IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
  46. scheduler.Start();
  47.  
  48. IJobDetail job = JobBuilder.Create<MaintenanceJob>().Build();
  49. job.JobDataMap.Add("ftp.location", "ftp://SomeFileLocation");
  50.  
  51. scheduler.ScheduleJob(job, Triggers.TimeTrigger());
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement