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.
 
 
 
 
 
 

34 lines
903 B

  1. using System;
  2. using System.ServiceProcess;
  3. using Hangfire;
  4. namespace Quanjiang.DigitalScholl.JobService
  5. {
  6. public partial class QuanjiangDigitalSchollJobService : ServiceBase
  7. {
  8. private BackgroundJobServer _server;
  9. public QuanjiangDigitalSchollJobService()
  10. {
  11. InitializeComponent();
  12. GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireConnString");
  13. }
  14. protected override void OnStart(string[] args)
  15. {
  16. var options = new BackgroundJobServerOptions
  17. {
  18. ServerName = "QuanjiangDigitalSchollJobService"
  19. };
  20. _server = new BackgroundJobServer(options);
  21. //自动运行连接考勤机
  22. RecurringJob.Trigger("HKAttendance");
  23. }
  24. protected override void OnStop()
  25. {
  26. _server.Dispose();
  27. }
  28. }
  29. }