配合hangfire 周期任务暂时有问题 --待解决
This commit is contained in:
@@ -207,7 +207,7 @@ app.UseExceptionHandler(o => { });
|
||||
app.UseIRacisHostStaticFileStore(env);
|
||||
|
||||
//本地化
|
||||
app.UseLocalization(app.Services);
|
||||
await app.UseLocalization(app.Services);
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using IRaCIS.Core.Domain.BaseModel;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
@@ -30,12 +31,13 @@ namespace IRaCIS.Core.API
|
||||
// 自动扫描程序集中的消费者并进行注册
|
||||
cfg.AddConsumers(typeof(UserSiteSurveySubmitedEventConsumer).Assembly);
|
||||
|
||||
//// 注册消费者
|
||||
//cfg.AddConsumer<AddSubjectTriggerConsumer>(); // 替换为你的消费者类
|
||||
//cfg.AddConsumer<AddSubjectTriggerConsumer2>();
|
||||
|
||||
|
||||
//Uri schedulerEndpoint = new Uri("queue:scheduler");
|
||||
//cfg.AddMessageScheduler(schedulerEndpoint);
|
||||
|
||||
cfg.AddPublishMessageScheduler();
|
||||
//cfg.AddHangfireConsumers();
|
||||
cfg.AddHangfireConsumers();
|
||||
|
||||
|
||||
|
||||
@@ -45,8 +47,11 @@ namespace IRaCIS.Core.API
|
||||
//https://github.com/MassTransit/Sample-Hangfire/blob/master/src/Sample.Hangfire.Console/Program.cs
|
||||
cfg.UsePublishMessageScheduler();
|
||||
|
||||
//cfg.UseMessageScheduler(schedulerEndpoint);
|
||||
|
||||
|
||||
//使用 Hangfire 进行消息调度
|
||||
cfg.UseHangfireScheduler();
|
||||
//cfg.UseHangfireScheduler();
|
||||
|
||||
cfg.UseConsumeFilter(typeof(CultureInfoFilter<>), context,
|
||||
x => x.Include(type => type.IsAssignableTo(typeof(DomainEvent))));
|
||||
|
||||
Reference in New Issue
Block a user