修改国际化准备
parent
0fd1b52036
commit
1a6ffa5d84
|
@ -52,29 +52,27 @@ namespace IRaCIS.Core.API
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
//// Serilog
|
||||||
|
SerilogExtension.AddSerilogSetup(enviromentName, host.Services);
|
||||||
|
Log.Logger.Warning($"µ±Ç°»·¾³£º{enviromentName}");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NewId.SetProcessIdProvider(new CurrentProcessIdProvider());
|
NewId.SetProcessIdProvider(new CurrentProcessIdProvider());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// Serilog
|
|
||||||
SerilogExtension.AddSerilogSetup(enviromentName, host.Services);
|
|
||||||
|
|
||||||
//缓存项目的状态 匿名化数据
|
//缓存项目的状态 匿名化数据
|
||||||
await InitCache(host);
|
await InitCache(host);
|
||||||
|
|
||||||
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, "en-US.json") );
|
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, StaticData.En_US_Json) );
|
||||||
|
|
||||||
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, "zh-CN.json"));
|
WatchJsonFile(Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, StaticData.Zh_CN_Json));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
host.Run();
|
host.Run();
|
||||||
|
|
||||||
Log.Logger.Warning($"当前环境:{enviromentName}");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -83,46 +81,6 @@ namespace IRaCIS.Core.API
|
||||||
Log.Logger.Error(e.InnerException is null ? e.Message + e.StackTrace : e.InnerException?.Message + e.InnerException?.StackTrace);
|
Log.Logger.Error(e.InnerException is null ? e.Message + e.StackTrace : e.InnerException?.Message + e.InnerException?.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Nlog 废弃
|
|
||||||
//var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
|
|
||||||
//try
|
|
||||||
//{
|
|
||||||
// var ihostBuilder = CreateHostBuilder(args);
|
|
||||||
|
|
||||||
// ihostBuilder.UseEnvironment(environment);
|
|
||||||
|
|
||||||
// ihostBuilder.ConfigureAppConfiguration((hostContext, config) =>
|
|
||||||
// {
|
|
||||||
|
|
||||||
// //Console.WriteLine(hostContext.HostingEnvironment.EnvironmentName);
|
|
||||||
// config.AddJsonFile("appsettings.json", false, true)
|
|
||||||
// .AddJsonFile($"appsettings.{environment}.json", false, true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// var host = ihostBuilder.Build();
|
|
||||||
|
|
||||||
// CacheTrialStatus(host);
|
|
||||||
|
|
||||||
// host.Run();
|
|
||||||
|
|
||||||
//}
|
|
||||||
//catch (Exception exception)
|
|
||||||
//{
|
|
||||||
// //NLog: catch setup errors
|
|
||||||
// logger.Error(exception, "Stopped program because of exception");
|
|
||||||
//}
|
|
||||||
//finally
|
|
||||||
//{
|
|
||||||
// // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
||||||
// NLog.LogManager.Shutdown();
|
|
||||||
//}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
@ -141,17 +99,8 @@ namespace IRaCIS.Core.API
|
||||||
//webBuilder.UseSerilog();//在宿主机启动的时候配置serilog,与微软ILogger进行整合
|
//webBuilder.UseSerilog();//在宿主机启动的时候配置serilog,与微软ILogger进行整合
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>();
|
||||||
}).UseSerilog()
|
}).UseSerilog()
|
||||||
.UseServiceProviderFactory(new AutofacServiceProviderFactory());//使用Autofac替代本身容器
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||||
//ConfigureLogging(logging =>
|
|
||||||
//{
|
|
||||||
// logging.ClearProviders();
|
|
||||||
// logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
|
||||||
//})
|
|
||||||
//.UseNLog()
|
|
||||||
// NLog: Setup NLog for Dependency injection;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static async Task InitCache(IHost host)
|
private static async Task InitCache(IHost host)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +125,7 @@ namespace IRaCIS.Core.API
|
||||||
|
|
||||||
foreach (IConfigurationSection section in enConfiguration.GetChildren())
|
foreach (IConfigurationSection section in enConfiguration.GetChildren())
|
||||||
{
|
{
|
||||||
if (filePath.Contains("en-US.json") )
|
if (filePath.Contains(StaticData.En_US_Json) )
|
||||||
{
|
{
|
||||||
StaticData.En_US_Dic[section.Key] = section.Value;
|
StaticData.En_US_Dic[section.Key] = section.Value;
|
||||||
|
|
||||||
|
@ -195,11 +144,13 @@ namespace IRaCIS.Core.API
|
||||||
}
|
}
|
||||||
public static void WatchJsonFile(string filePath)
|
public static void WatchJsonFile(string filePath)
|
||||||
{
|
{
|
||||||
|
LoadJsonFile(filePath);
|
||||||
|
|
||||||
|
|
||||||
FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath));
|
FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath));
|
||||||
watcher.Changed += (sender, e) => LoadJsonFile(filePath);
|
watcher.Changed += (sender, e) => LoadJsonFile(filePath);
|
||||||
watcher.EnableRaisingEvents = true;
|
watcher.EnableRaisingEvents = true;
|
||||||
|
|
||||||
LoadJsonFile(filePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@ namespace IRaCIS.Core.API
|
||||||
config.WriteTo.Email(new EmailConnectionInfo()
|
config.WriteTo.Email(new EmailConnectionInfo()
|
||||||
{
|
{
|
||||||
EmailSubject = "系统警告,请速速查看!",//邮件标题
|
EmailSubject = "系统警告,请速速查看!",//邮件标题
|
||||||
FromEmail = "iracis_grr@163.com",//发件人邮箱
|
FromEmail = "test@extimaging.com",//发件人邮箱
|
||||||
MailServer = "smtp.163.com",//smtp服务器地址
|
MailServer = "smtp.qiye.aliyun.com",//smtp服务器地址
|
||||||
NetworkCredentials = new NetworkCredential("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"),//两个参数分别是发件人邮箱与客户端授权码
|
NetworkCredentials = new NetworkCredential("test@extimaging.com", "SHzyyl2021"),//两个参数分别是发件人邮箱与客户端授权码
|
||||||
Port = 25,//端口号
|
Port = 465,//端口号
|
||||||
ToEmail = "872297557@qq.com"//收件人
|
ToEmail = "872297557@qq.com"//收件人
|
||||||
}, restrictedToMinimumLevel: LogEventLevel.Error,
|
}, restrictedToMinimumLevel: LogEventLevel.Error,
|
||||||
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [ {Level} {ClientIp} {ClientAgent} {TokenUserRealName} {TokenUserType} ] || [path: {RequestPath} arguments: {RequestBody}] {SourceContext:l} || {Message} || {Exception} ||end {NewLine})");
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [ {Level} {ClientIp} {ClientAgent} {TokenUserRealName} {TokenUserType} ] || [path: {RequestPath} arguments: {RequestBody}] {SourceContext:l} || {Message} || {Exception} ||end {NewLine})");
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Domain.Share;
|
namespace IRaCIS.Core.Domain.Share;
|
||||||
|
|
||||||
|
@ -10,6 +12,12 @@ public static class StaticData
|
||||||
public static Dictionary<string, string> Zh_CN_Dic = new Dictionary<string, string>();
|
public static Dictionary<string, string> Zh_CN_Dic = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
|
||||||
|
public static readonly string En_US_Json = "en-US.json";
|
||||||
|
public static readonly string Zh_CN_Json = "zh-CN.json";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 字典表项固定值
|
#region 字典表项固定值
|
||||||
public static readonly string Title = "Title";
|
public static readonly string Title = "Title";
|
||||||
|
|
Loading…
Reference in New Issue