周口郸城医院 DanChengCallCenter_API

Startup.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Threading.Tasks;
  3. using Microsoft.Owin;
  4. using Owin;
  5. using Hangfire;
  6. using CallCenterApi.Interface.Controllers.His;
  7. using System.Collections.Generic;
  8. using Hangfire.Dashboard;
  9. using Hangfire.Annotations;
  10. [assembly: OwinStartup(typeof(CallCenterApi.Interface.Startup))]
  11. namespace CallCenterApi.Interface
  12. {
  13. public class Startup
  14. {
  15. public void Configuration(IAppBuilder app)
  16. {
  17. GlobalConfiguration.Configuration.UseSqlServerStorage("ConnectionString");
  18. app.UseHangfireDashboard("/hangfire", new DashboardOptions()
  19. {
  20. Authorization = new[] { new CustomAuthorizeFilter() }
  21. });
  22. app.UseHangfireServer(new BackgroundJobServerOptions()
  23. {
  24. Queues = new[] { "updatedata1", "updatedata2", "updatedata3", "updatedata4" }
  25. });
  26. RecurringJob.AddOrUpdate<GetController>(a => a.Data1(1), Cron.Hourly, TimeZoneInfo.Local,"updatedata1");
  27. RecurringJob.AddOrUpdate<GetController>(a => a.Data2(1), Cron.Hourly, TimeZoneInfo.Local, "updatedata2");
  28. RecurringJob.AddOrUpdate<GetController>(a => a.Data3(1), Cron.Hourly, TimeZoneInfo.Local, "updatedata3");
  29. RecurringJob.AddOrUpdate<GetController>(a => a.Data4(1), Cron.Hourly, TimeZoneInfo.Local, "updatedata4");
  30. }
  31. }
  32. public class CustomAuthorizeFilter : IDashboardAuthorizationFilter
  33. {
  34. public bool Authorize([NotNull] DashboardContext context)
  35. {
  36. return true;
  37. }
  38. }
  39. }