using DS.WMS.Core.HangfireJob.Interface; using Hangfire; using Hangfire.Dashboard.BasicAuthorization; using Microsoft.AspNetCore.Builder; namespace DS.WMS.Core.HangfireJob.Method { /// /// 注册Hangfire定时任务的中间件 /// public static class JobMiddleware { /// /// 注册Hangfire定时任务的中间件 /// /// /// public static WebApplication UseJobMiddlewares(this WebApplication app) { //app.UseHangfireServer(); // 用于将 Hangfire 任务处理服务器添加到请求处理管道中 // 将 Hangfire 仪表板添加到应用程序的请求处理管道中 app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] {new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions { RequireSsl = false, SslRedirect = false, LoginCaseSensitive = true, Users = new [] { new BasicAuthAuthorizationUser { Login = "admin", PasswordClear = "ds2024" } } })} }); RecurringJob.AddOrUpdate(nameof(IFeeCustTemplateJobService), s => s.GenerateFeesAsync(), Cron.Daily(23, 30)); return app; } } }