fix 代码命名修改,格式调整
This commit is contained in:
@@ -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>
|
||||
|
||||
37
Src/Dlhis.ScheduledTask/HangfirePack.cs
Normal file
37
Src/Dlhis.ScheduledTask/HangfirePack.cs
Normal 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."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using Hangfire;
|
||||
|
||||
namespace Dlhis.ScheduledTask
|
||||
{
|
||||
public class MyBackgroundJobService
|
||||
{
|
||||
public void EnqueueMyJob()
|
||||
{
|
||||
BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,5 +16,4 @@ public class Startup : DefaultStartup
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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服务
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user