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