NBHistoryJobRunning.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using LeaRun.Application.Web.QuartzJob;
  2. using Quartz;
  3. using Quartz.Impl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. namespace LeaRun.Application.Web.Common
  9. {
  10. public class NBHistoryJobRunning
  11. {
  12. static IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
  13. public static void JobRunning()
  14. {
  15. IJobDetail job = JobBuilder.Create<NBHistotyUploadJob>()
  16. .WithIdentity("nbHis", "group1")
  17. .Build();
  18. ITrigger trigger = TriggerBuilder.Create()
  19. .WithIdentity("nbHis", "group1")
  20. .StartNow()
  21. .WithSimpleSchedule(x => x
  22. .WithIntervalInSeconds(7200)
  23. .RepeatForever())
  24. .Build();
  25. scheduler.ScheduleJob(job, trigger);
  26. scheduler.Start();
  27. }
  28. public static void JobEndding()
  29. {
  30. if (scheduler.IsStarted)
  31. {
  32. scheduler.Shutdown(false);
  33. }
  34. }
  35. }
  36. }