feat:完成hangfire接入

This commit is contained in:
chenchun
2024-11-15 18:17:53 +08:00
parent 536c3cc56b
commit 6b47ae232d
9 changed files with 60 additions and 21 deletions

View File

@@ -35,6 +35,7 @@ using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee;
using Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
using Yi.Framework.BackgroundWorkers.Hangfire;
using Yi.Framework.Bbs.Application;
using Yi.Framework.Bbs.Application.Extensions;
using Yi.Framework.ChatHub.Application;
@@ -57,7 +58,7 @@ namespace Yi.Abp.Web
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAuditingModule),
typeof(AbpBackgroundWorkersHangfireModule),
typeof(YiFrameworkBackgroundWorkersHangfireModule),
typeof(AbpBackgroundJobsHangfireModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(YiFrameworkAspNetCoreModule),
@@ -309,10 +310,6 @@ namespace Yi.Abp.Web
return Task.CompletedTask;
}
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddConventionalRegistrar(new YiHangfireConventionalRegistrar());
}
public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{
@@ -368,17 +365,6 @@ namespace Yi.Abp.Web
//日志记录
app.UseAbpSerilogEnrichers();
//定时任务自动注入Abp默认只有在Quartz才实现
var backgroundWorkerManager = context.ServiceProvider.GetRequiredService<IBackgroundWorkerManager>();
var works = context.ServiceProvider.GetServices<IHangfireBackgroundWorker>();
foreach (var work in works)
{
await backgroundWorkerManager.AddAsync(work);
}
//Hangfire定时任务面板可配置授权
app.UseAbpHangfireDashboard("/hangfire", options =>