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.
 
 
 
 
 
 

33 lines
889 B

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