Files
jinko.yikatong/Src/Dlhis.ScheduledTask/SqlSugarPack1.cs
2023-12-29 16:41:24 +08:00

35 lines
1.1 KiB
C#

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服务
}
}
}