DemoU8_to_Wang.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using cuidian.Common;
  2. using Quartz;
  3. using Quartz.Impl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using TaskSchedule;
  10. namespace ConsoleApplication2
  11. {
  12. class DemoU8_to_Wang
  13. {
  14. //测试
  15. public static void aa()
  16. {
  17. //using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\log.txt", true))
  18. //{
  19. // sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "aa().");
  20. //}
  21. ISchedulerFactory sf = new StdSchedulerFactory();
  22. IScheduler scheduler = sf.GetScheduler(); //创建调度实例
  23. //创建任务实例
  24. IJobDetail job = JobBuilder.Create<U8_to_Wang>().WithIdentity(new JobKey("job1")).Build();
  25. //创建触发器实例"0 0 10 * * ? "
  26. ITrigger trigger = TriggerBuilder.Create().StartAt(DateTime.Now.AddSeconds(0)).WithCronSchedule(AppSeting.Instance.GetValue("U8_To_Wang")).Build();
  27. scheduler.ScheduleJob(job, trigger); //绑定触发器和任务
  28. scheduler.Start(); //启动监控
  29. }
  30. public static void bb()
  31. {
  32. ISchedulerFactory sf = new StdSchedulerFactory();
  33. IScheduler scheduler = sf.GetScheduler(); //创建调度实例
  34. //创建任务实例
  35. IJobDetail job = JobBuilder.Create<Wang_to_U8>().WithIdentity(new JobKey("job3")).Build();
  36. //IJobDetail job = JobBuilder.Create<EndU8_to_Wang>().WithIdentity(new JobKey("job2")).Build();
  37. //创建触发器实例
  38. ITrigger trigger = TriggerBuilder.Create().StartAt(DateTime.Now.AddSeconds(0)).WithCronSchedule(AppSeting.Instance.GetValue("Wang_To_U8")).Build();
  39. scheduler.ScheduleJob(job, trigger); //绑定触发器和任务
  40. scheduler.Start(); //启动监控
  41. }
  42. }
  43. }