You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

2 years ago
  1. using log4net;
  2. using Quartz;
  3. using Quartz.Impl;
  4. using System;
  5. using System.Threading.Tasks;
  6. namespace WebApp.Jobs.Outlook
  7. {
  8. public class RunSyn : RJob
  9. {
  10. private static ILog log = LogManager.GetLogger(typeof(RunSyn));
  11. public virtual async Task Run()
  12. {
  13. // First we must get a reference to a scheduler
  14. ISchedulerFactory sf = new StdSchedulerFactory();
  15. var sched = await sf.GetScheduler();
  16. // get a "nice round" time a few seconds in the future...
  17. var startTime = DateBuilder.NextGivenSecondDate(null, 35);
  18. // job1 will only fire once at date/time "ts"
  19. var job = JobBuilder.Create<RunSynJob>()
  20. .WithIdentity("job1", "group1")
  21. .Build();
  22. var trigger = (ISimpleTrigger)TriggerBuilder.Create()
  23. .WithIdentity("trigger1", "group1")
  24. .StartAt(startTime)
  25. //.WithSimpleSchedule(x => x.WithIntervalInSeconds(40).RepeatForever())
  26. .Build();
  27. DateTimeOffset? ft = await sched.ScheduleJob(job, trigger);
  28. await sched.Start();
  29. await sched.Shutdown(true);
  30. }
  31. }
  32. }