fix 字段名称
This commit is contained in:
67
Src/Dlhis.ScheduledTask/Packs/HangfirePack.cs
Normal file
67
Src/Dlhis.ScheduledTask/Packs/HangfirePack.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Dlhis.ScheduledTask.Configurations;
|
||||
using Dlhis.ScheduledTask.Job;
|
||||
using Hangfire;
|
||||
using Hangfire.Dashboard.BasicAuthorization;
|
||||
using Hangfire.MySql;
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
public class HangfirePack : BaseAppPack
|
||||
{
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.Configure<ServiceSettings>(Configuration.GetSection("ServiceSettings"));
|
||||
services.AddHangfire(configuration =>
|
||||
{
|
||||
var options = new MySqlStorageOptions
|
||||
{
|
||||
TablesPrefix = "Hangfire"
|
||||
};
|
||||
|
||||
configuration.UseSimpleAssemblyNameTypeSerializer()
|
||||
.UseRecommendedSerializerSettings()
|
||||
.UseStorage(new MySqlStorage(Configuration.GetConnectionString("HangfireConnection"), options));
|
||||
|
||||
});
|
||||
services.UseHangfireto();
|
||||
services.AddHangfireServer();
|
||||
}
|
||||
|
||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
|
||||
app.UseHangfireDashboard("/hangfire", new DashboardOptions
|
||||
{
|
||||
AppPath = null,
|
||||
DashboardTitle = "hangfire",
|
||||
Authorization = new[]
|
||||
{
|
||||
new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
|
||||
{
|
||||
RequireSsl = false,
|
||||
SslRedirect = false,
|
||||
Users = new []
|
||||
{
|
||||
new BasicAuthAuthorizationUser
|
||||
{
|
||||
Login ="admin",
|
||||
PasswordClear = "admin"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
app.UseHangfireDashboard();
|
||||
|
||||
BackgroundJob.Enqueue(() => Console.WriteLine("This is a background job."));
|
||||
RecurringJob.AddOrUpdate<SyncOrgInfoJob>("SyncOrgInfoJob_id", s => s.SyncOrgInfo(), "0 0 0 * * ?");
|
||||
RecurringJob.AddOrUpdate<SyncPositionJob>("SyncPositionJob_id", s => s.SyncPositionInfo(), "0 0 1 * * ?");
|
||||
RecurringJob.AddOrUpdate<SyncPersonJob>("SyncPersonJob_id", s => s.SyncPersonInfo(), "0 0 2 * * ?");
|
||||
}
|
||||
}
|
||||
15
Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
Normal file
15
Src/Dlhis.ScheduledTask/Packs/SqlSugarPack.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
public class SqlSugarPack : BaseAppPack
|
||||
{
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user