feat Hnagfire初步搭建
This commit is contained in:
34
Src/Dlhis.ScheduledTask/SqlSugarPack1.cs
Normal file
34
Src/Dlhis.ScheduledTask/SqlSugarPack1.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Hangfire;
|
||||
using Hangfire.MySql;
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
|
||||
namespace Dlhis.ScheduledTask
|
||||
{
|
||||
public class SqlSugarPack1 : BaseAppPack
|
||||
{
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddHangfire(configuration => configuration
|
||||
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||
.UseSimpleAssemblyNameTypeSerializer()
|
||||
.UseRecommendedSerializerSettings()
|
||||
.UseStorage(
|
||||
new MySqlStorage(
|
||||
Configuration.GetConnectionString("HangfireConnection"),
|
||||
new MySqlStorageOptions
|
||||
{
|
||||
TablesPrefix = "Hangfire" // Adjust other options as needed
|
||||
}
|
||||
)
|
||||
));
|
||||
services.AddHangfireServer();
|
||||
}
|
||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
app.UseHangfireDashboard(); //使用hangfire面板
|
||||
app.UseHangfireServer(); //启动hangfire服务
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user