You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Hangfire.Dashboard.BasicAuthorization;
|
|
|
|
|
using Hangfire;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace DS.Module.HangfireModule
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class HangfireMiddleware
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static void UseHangfireMiddleware(this IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
if (app == null) throw new ArgumentNullException(nameof(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"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|