修改国际化 和 scp 缩略图日志
	
		
			
	
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
					Details
				
			
		
	
				
					
				
			
				
	
				continuous-integration/drone/push Build is passing
				
					Details
				
			
		
	
							parent
							
								
									4f5d89732d
								
							
						
					
					
						commit
						3b92aaf61c
					
				| 
						 | 
					@ -331,6 +331,10 @@ namespace IRaCIS.Core.SCP.Service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        Log.Logger.Information($"ImageResizePath:{series.ImageResizePath} and series is null:{series == null} ");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    await _seriesRepository.SaveChangesAsync();
 | 
					                    await _seriesRepository.SaveChangesAsync();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,8 +25,6 @@ namespace IRaCIS.Application.Services.BackGroundJob
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources);
 | 
					        public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static FileSystemWatcher FileSystemWatcher_US { get; set; }
 | 
					 | 
				
			||||||
        public static FileSystemWatcher FileSystemWatcher_CN { get; set; }
 | 
					 | 
				
			||||||
        private readonly IRepository<Trial> _trialRepository;
 | 
					        private readonly IRepository<Trial> _trialRepository;
 | 
				
			||||||
        private readonly IEasyCachingProvider _provider;
 | 
					        private readonly IEasyCachingProvider _provider;
 | 
				
			||||||
        private readonly ILogger<IRaCISCHangfireJob> _logger;
 | 
					        private readonly ILogger<IRaCISCHangfireJob> _logger;
 | 
				
			||||||
| 
						 | 
					@ -62,7 +60,7 @@ namespace IRaCIS.Application.Services.BackGroundJob
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //初始化
 | 
					            //初始化
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await InitInternationlizationDataAndWatchJsonFileAsync();
 | 
					            await InternationalizationHelper.InitInternationlizationDataAndWatchJsonFileAsync(_internationalizationRepository);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //创建邮件定时任务
 | 
					            //创建邮件定时任务
 | 
				
			||||||
            await InitSysAndTrialCronJobAsync();
 | 
					            await InitSysAndTrialCronJobAsync();
 | 
				
			||||||
| 
						 | 
					@ -96,93 +94,8 @@ namespace IRaCIS.Application.Services.BackGroundJob
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region 国际化 初始化
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async Task InitInternationlizationDataAndWatchJsonFileAsync()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            //查询数据库的数据
 | 
					 | 
				
			||||||
            var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                t.Code,
 | 
					 | 
				
			||||||
                t.Value,
 | 
					 | 
				
			||||||
                t.ValueCN
 | 
					 | 
				
			||||||
            }).ToListAsync();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //组织成json 文件
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            var usJsonPath = Path.Combine(JsonFileFolder, StaticData.En_US_Json);
 | 
					 | 
				
			||||||
            var cnJsonPath = Path.Combine(JsonFileFolder, StaticData.Zh_CN_Json);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //本地静态文件国际化需要
 | 
					 | 
				
			||||||
            foreach (var tojsonItem in toJsonList)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                StaticData.En_US_Dic[tojsonItem.Code] = tojsonItem.Value;
 | 
					 | 
				
			||||||
                StaticData.Zh_CN_Dic[tojsonItem.Code] = tojsonItem.ValueCN;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            File.WriteAllText(usJsonPath, JsonConvert.SerializeObject(StaticData.En_US_Dic));
 | 
					 | 
				
			||||||
            File.WriteAllText(cnJsonPath, JsonConvert.SerializeObject(StaticData.Zh_CN_Dic));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //监测Json文件变更 实时刷新数据
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (!File.Exists(usJsonPath)|| !File.Exists(cnJsonPath))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound"));
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            FileSystemWatcher_US = new FileSystemWatcher
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Path = Path.GetDirectoryName(usJsonPath)!,
 | 
					 | 
				
			||||||
                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size,
 | 
					 | 
				
			||||||
                Filter = Path.GetFileName(usJsonPath),
 | 
					 | 
				
			||||||
                EnableRaisingEvents = true,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
            // 添加文件更改事件的处理程序
 | 
					 | 
				
			||||||
            FileSystemWatcher_US.Changed += (sender, e) => LoadJsonFile(StaticData.Folder.Resources+"\\"+ StaticData.En_US_Json);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            FileSystemWatcher_CN = new FileSystemWatcher
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Path = Path.GetDirectoryName(cnJsonPath)!,
 | 
					 | 
				
			||||||
                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size,
 | 
					 | 
				
			||||||
                Filter = Path.GetFileName(cnJsonPath),
 | 
					 | 
				
			||||||
                EnableRaisingEvents = true,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
            FileSystemWatcher_CN.Changed += (sender, e) => LoadJsonFile(StaticData.Folder.Resources + "\\" + StaticData.Zh_CN_Json);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void LoadJsonFile(string filePath)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Console.WriteLine("刷新json内存数据");
 | 
					 | 
				
			||||||
            IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath,false,false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            IConfigurationRoot enConfiguration = builder.Build();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            foreach (IConfigurationSection section in enConfiguration.GetChildren())
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if (filePath.Contains(StaticData.En_US_Json))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    StaticData.En_US_Dic[section.Key] = section.Value;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    StaticData.Zh_CN_Dic[section.Key] = section.Value;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        #endregion
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public async Task InitSysAndTrialCronJobAsync()
 | 
					        public async Task InitSysAndTrialCronJobAsync()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //var deleteJobIdList = await _trialEmailNoticeConfigRepository.Where(t => t.Trial.TrialStatusStr != StaticData.TrialState.TrialOngoing && t.EmailCron != string.Empty && t.IsAutoSend)
 | 
					            //var deleteJobIdList = await _trialEmailNoticeConfigRepository.Where(t => t.Trial.TrialStatusStr != StaticData.TrialState.TrialOngoing && t.EmailCron != string.Empty && t.IsAutoSend)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,9 @@ namespace IRaCIS.Core.Application.Helper
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources);
 | 
					        public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static FileSystemWatcher FileSystemWatcher_US { get; set; }
 | 
				
			||||||
 | 
					        public static FileSystemWatcher FileSystemWatcher_CN { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static void VerifyFolder()
 | 
					        private static void VerifyFolder()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!Directory.Exists(JsonFileFolder) ||
 | 
					            if (!Directory.Exists(JsonFileFolder) ||
 | 
				
			||||||
| 
						 | 
					@ -107,10 +110,11 @@ namespace IRaCIS.Core.Application.Helper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static async Task InitInternationlizationDataAndWatchJsonFileAsync(IRepository _repository)
 | 
					
 | 
				
			||||||
 | 
					        public static async Task InitInternationlizationDataAndWatchJsonFileAsync(IRepository<Internationalization> _internationalizationRepository)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //查询数据库的数据
 | 
					            //查询数据库的数据
 | 
				
			||||||
            var toJsonList = await _repository.Where<Internationalization>(t => t.InternationalizationType == 1).Select(t => new
 | 
					            var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                t.Code,
 | 
					                t.Code,
 | 
				
			||||||
                t.Value,
 | 
					                t.Value,
 | 
				
			||||||
| 
						 | 
					@ -136,29 +140,45 @@ namespace IRaCIS.Core.Application.Helper
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //监测Json文件变更 实时刷新数据
 | 
					            //监测Json文件变更 实时刷新数据
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            WatchJsonFile(usJsonPath);
 | 
					            if (!File.Exists(usJsonPath) || !File.Exists(cnJsonPath))
 | 
				
			||||||
            WatchJsonFile(cnJsonPath);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        public static void WatchJsonFile(string filePath)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (!File.Exists(filePath))
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                throw new BusinessValidationFailedException("国际化Json文件不存在");
 | 
					                throw new BusinessValidationFailedException(StaticData.International("IRaCISCHangfireJob_FileNotFound"));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            FileSystemWatcher watcher = new FileSystemWatcher(Path.GetDirectoryName(filePath), Path.GetFileName(filePath));
 | 
					
 | 
				
			||||||
            watcher.Changed += (sender, e) => LoadJsonFile(filePath);
 | 
					            //    //监测Json文件变更 实时刷新数据
 | 
				
			||||||
            watcher.EnableRaisingEvents = true;
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            FileSystemWatcher_US = new FileSystemWatcher
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Path = Path.GetDirectoryName(usJsonPath)!,
 | 
				
			||||||
 | 
					                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size,
 | 
				
			||||||
 | 
					                Filter = Path.GetFileName(usJsonPath),
 | 
				
			||||||
 | 
					                EnableRaisingEvents = true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            // 添加文件更改事件的处理程序
 | 
				
			||||||
 | 
					            FileSystemWatcher_US.Changed += (sender, e) => LoadJsonFile(StaticData.Folder.Resources + "\\" + StaticData.En_US_Json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            FileSystemWatcher_CN = new FileSystemWatcher
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Path = Path.GetDirectoryName(cnJsonPath)!,
 | 
				
			||||||
 | 
					                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size,
 | 
				
			||||||
 | 
					                Filter = Path.GetFileName(cnJsonPath),
 | 
				
			||||||
 | 
					                EnableRaisingEvents = true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            FileSystemWatcher_CN.Changed += (sender, e) => LoadJsonFile(StaticData.Folder.Resources + "\\" + StaticData.Zh_CN_Json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private static void LoadJsonFile(string filePath)
 | 
					        private static void LoadJsonFile(string filePath)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            Console.WriteLine("刷新json内存数据");
 | 
				
			||||||
            IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath);
 | 
					            IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile(filePath, false, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            IConfigurationRoot enConfiguration = builder.Build();
 | 
					            IConfigurationRoot enConfiguration = builder.Build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -175,5 +195,11 @@ namespace IRaCIS.Core.Application.Helper
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue