fix 代码命名修改,格式调整

This commit is contained in:
2023-12-29 16:54:30 +08:00
parent 8169d7da5c
commit 25436c881c
5 changed files with 37 additions and 48 deletions

View File

@@ -19,7 +19,6 @@
<ItemGroup>
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.6" />
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
<PackageReference Include="Hangfire.MySql.Core_MySql.Data" Version="2.1.10" />
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.2" />
<PackageReference Include="Kurisu.AspNetCore" Version="0.4.7" />
</ItemGroup>

View File

@@ -0,0 +1,37 @@
using Hangfire;
using Hangfire.MySql;
using Kurisu.AspNetCore.Startup;
namespace Dlhis.ScheduledTask
{
public class HangfirePack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(configuration =>
{
var options = new MySqlStorageOptions
{
TablesPrefix = "Hangfire"
};
configuration.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseStorage(new MySqlStorage(Configuration.GetConnectionString("HangfireConnection"), options));
});
services.AddHangfireServer();
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHangfireDashboard(); //使用hangfire面板
//app.UseHangfireServer(); //启动hangfire服务
BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job."));
}
}
}

View File

@@ -1,12 +0,0 @@
using Hangfire;
namespace Dlhis.ScheduledTask
{
public class MyBackgroundJobService
{
public void EnqueueMyJob()
{
BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job."));
}
}
}

View File

@@ -16,5 +16,4 @@ public class Startup : DefaultStartup
{
}
}

View File

@@ -1,34 +0,0 @@
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服务
}
}
}