配合hangfire 周期任务暂时有问题 --待解决

This commit is contained in:
2024-10-17 13:37:57 +08:00
parent a03c11ae9d
commit f1acb787f5
9 changed files with 65 additions and 31 deletions
@@ -1,18 +1,24 @@
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
namespace IRaCIS.Core.API
{
public static class LocalizationConfig
{
public static void UseLocalization(this IApplicationBuilder app,IServiceProvider serviceProvider)
public static async Task UseLocalization(this IApplicationBuilder app,IServiceProvider serviceProvider)
{
var supportedCultures = new List<CultureInfo>
{
@@ -38,6 +44,24 @@ namespace IRaCIS.Core.API
//设置国际化I18n
var localizer = serviceProvider.GetRequiredService<IStringLocalizer>();
I18n.SetLocalizer(localizer);
//初始化国际化
var _internationalizationRepository = serviceProvider.GetRequiredService<IRepository<Internationalization>>();
//查询数据库的数据
var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new IRCGlobalInfoDTO()
{
Code = t.Code,
Value = t.Value,
ValueCN = t.ValueCN,
Description = t.Description
}).ToListAsync();
await InternationalizationHelper.BatchAddJsonKeyValueAsync(toJsonList);
}
}
}