更新 Hangfire mysql 包
This commit is contained in:
1 parent
96fed35907
commit
a87ebeaffb
2 files changed
+7
-8
No files matched your search
@@ -26,22 +26,21 @@ namespace Store.Modules.CloudProduct
|
||||
var hangfireConnection = configuration.GetValue<string>("CloudProductConnection")
|
||||
?? throw new InvalidOperationException("缺少配置 CloudProductConnection,CloudProduct 模块的 Hangfire 无法启动。");
|
||||
|
||||
// AllowUserVariables=true:Hangfire.MySqlStorage 的建表/查询语句依赖用户变量
|
||||
// 存储中的建表/查询语句依赖用户变量;与业务仓储共用 FreeSql。
|
||||
var connectionStringBuilder = new MySqlConnectionStringBuilder(hangfireConnection)
|
||||
{
|
||||
AllowUserVariables = true
|
||||
};
|
||||
|
||||
services.AddHangfire(config => config
|
||||
services.AddHangfire((provider, config) => config
|
||||
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
|
||||
.UseSimpleAssemblyNameTypeSerializer()
|
||||
.UseRecommendedSerializerSettings()
|
||||
.UseStorage(new MySqlStorage(connectionStringBuilder.ConnectionString, new MySqlStorageOptions() { TablesPrefix = "Hangfire_" })));
|
||||
.UseStorage(new MySqlStorage(provider.GetRequiredKeyedService<IFreeSql>("CloudProductConnection"), new MySqlStorageOptions() { TablesPrefix = "Hangfire_" })));
|
||||
services.AddHangfireServer();
|
||||
services.AddTransient<GoodsIndexJob>();
|
||||
var connection = RequireConfiguration("CloudProductConnection");
|
||||
services.AddKeyedSingleton<IFreeSql>("CloudProductConnection", (_, _) =>
|
||||
new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, connection)
|
||||
new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, connectionStringBuilder.ConnectionString)
|
||||
.UseAdoConnectionPool(true).Build());
|
||||
services.AddHostedService<CloudProductSearchStartup>();
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<SatelliteResourceLanguages>zh-Hans;zh-Hant;zh;en</SatelliteResourceLanguages>
|
||||
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
@@ -23,12 +25,10 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.25" />
|
||||
<PackageReference Include="Hangfire.Dashboard.Basic.Authentication" Version="8.0.0" />
|
||||
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
|
||||
<PackageReference Include="Hangfire.MySql" Version="1.0.0" />
|
||||
<PackageReference Include="OpenSearch.Client" Version="2.1.0" />
|
||||
<!-- 覆盖 Hangfire 的旧传递依赖,修复 CVE-2024-21907。 -->
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<!-- Hangfire.MySqlStorage -> Dapper 引入;修复 CVE-2024-0056、CVE-2022-41064。 -->
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user