修改bug

This commit is contained in:
2023-04-28 09:23:12 +08:00
parent a86c43d8d9
commit 46c4416434
7 changed files with 167 additions and 21 deletions
+48
View File
@@ -9,6 +9,8 @@ using IRaCIS.Core.Application.MediatR.Handlers;
using System.Threading.Tasks;
using MassTransit;
using MassTransit.NewIdProviders;
using System.IO;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.API
{
@@ -56,14 +58,20 @@ namespace IRaCIS.Core.API
//// Serilog
SerilogExtension.AddSerilogSetup(enviromentName, host.Services);
//缓存项目的状态 匿名化数据
await InitCache(host);
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, "en-US.json") );
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, "zh-CN.json"));
host.Run();
Log.Logger.Warning($"当前环境:{enviromentName}");
@@ -154,5 +162,45 @@ namespace IRaCIS.Core.API
await _mediator.Send(new TrialStateCacheRequest());
}
private static void LoadJsonFile(string filePath)
{
IConfigurationBuilder builder = new ConfigurationBuilder()
.AddJsonFile(filePath);
IConfigurationRoot enConfiguration = builder.Build();
foreach (IConfigurationSection section in enConfiguration.GetChildren())
{
if (filePath.Contains("en-US.json") )
{
StaticData.En_US_Dic[section.Key] = section.Value;
}
else
{
StaticData.Zh_CN_Dic[section.Key] = section.Value;
}
}
}
public static void WatchJsonFile(string filePath)
{
FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath));
watcher.Changed += (sender, e) => LoadJsonFile(filePath);
watcher.EnableRaisingEvents = true;
LoadJsonFile(filePath);
}
}
}