Service1.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Quartz;
  2. using Quartz.Impl;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.ServiceProcess;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Timers;
  13. using System.IO;
  14. using TimeSchedule;
  15. using cuidian.Sql;
  16. namespace Service1
  17. {
  18. public partial class Service1 : ServiceBase
  19. {
  20. public Service1()
  21. {
  22. InitializeComponent();
  23. }
  24. protected override void OnStart(string[] args)
  25. {
  26. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\启动时间.txt", true))
  27. {
  28. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "Start.");
  29. }
  30. Time_U8_to_Wang.GoU8_to_Wang();
  31. //Time_U8_to_Wang.GoWang_to_U8();
  32. //Time_U8_to_Wang.GoWang_to_U8Two();
  33. //Time_U8_to_Wang.GoWang_to_U8Three();
  34. Console.WriteLine("启动成功 ");
  35. }
  36. protected override void OnStop()
  37. {
  38. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\启动时间.txt", true))
  39. {
  40. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "Stop.");
  41. }
  42. }
  43. private void aa()
  44. {
  45. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\log.txt", true))
  46. {
  47. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "aa().");
  48. }
  49. }
  50. private void bb()
  51. {
  52. string dtNow = DateTime.Now.ToString("HH");
  53. if (DateTime.Now.ToString("HH") == "22")
  54. {
  55. Console.WriteLine(dtNow);
  56. }
  57. }
  58. }
  59. }