82 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			C#
		
	
	
| using Microsoft.Extensions.Configuration;
 | |
| using Microsoft.Extensions.Configuration.Json;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| 
 | |
| namespace IRaCIS.Core.Domain.Share
 | |
| {
 | |
|     public class AppSettings
 | |
|     {
 | |
|         public static string RootUrl { get; set; }
 | |
|         public static string CodePrefix { get; set; }
 | |
|         public static string UserCodePrefix { get; set; }
 | |
|         public static string VisitPlanNumPrefix { get; set; }
 | |
| 
 | |
|         public static int CodeLength { get; private set; }
 | |
|         public static List<string> ExcludeCodeList { get; private set; }
 | |
|         public static List<AnonymizeTag> AnonymizeTagList = new List<AnonymizeTag>();
 | |
|         public static int LoginExpiredTimeSpan { get; private set; } = 15;
 | |
|         public static bool OpenLog { get; set; } = true;
 | |
|         public static bool AddClinicalInfo { get; set; } = true;
 | |
|         public static bool Share { get; set; } = true;
 | |
| 
 | |
| 
 | |
|         static AppSettings()
 | |
|         {
 | |
|             var configuration = new ConfigurationBuilder()
 | |
|                 .Add(new JsonConfigurationSource
 | |
|                 {
 | |
|                     Path = "appsettings.json",
 | |
|                     ReloadOnChange = true
 | |
|                 })
 | |
|                 .Add(new JsonConfigurationSource
 | |
|                 {
 | |
|                     Path = "AnonymizeTagSetting.json",
 | |
|                     ReloadOnChange = true
 | |
|                 })
 | |
|                 .Build();
 | |
| 
 | |
|             RootUrl = configuration.GetSection("RootUrl").Value;
 | |
| 
 | |
|             CodePrefix = configuration.GetSection("CodePrefix").Value;
 | |
| 
 | |
|             UserCodePrefix = configuration.GetSection("UserCodePrefix").Value;
 | |
| 
 | |
|             VisitPlanNumPrefix = configuration.GetSection("VisitPlanNumPrefix").Value;
 | |
|             try
 | |
|             {
 | |
|                 int tempLoginExpiredTimeSpan = 15;
 | |
|                 if (int.TryParse(configuration.GetSection("LoginExpiredTimeSpan").Value, out tempLoginExpiredTimeSpan))
 | |
|                 {
 | |
|                     LoginExpiredTimeSpan = tempLoginExpiredTimeSpan;
 | |
|                 }
 | |
|                 OpenLog = Convert.ToBoolean(configuration.GetSection("OpenLog").Value);
 | |
|                 AddClinicalInfo = Convert.ToBoolean(configuration.GetSection("AddClinicalInfo").Value);
 | |
|                 configuration.GetSection("needAnonymizeTag").Bind(AnonymizeTagList);
 | |
|                 Share = Convert.ToBoolean(configuration.GetSection("OpenLog").Value);
 | |
|             }
 | |
|             catch (Exception)
 | |
|             {
 | |
| 
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|     }
 | |
| 
 | |
|     public class AnonymizeTag
 | |
|     {
 | |
|         public string Group { get; set; }
 | |
|         public string Element { get; set; }
 | |
|         public string ReplaceValue { get; set; }
 | |
|         public bool Enable { get; set; }
 | |
|         public AnonymizeTag() { }
 | |
|         public AnonymizeTag(string group, string element, string value, bool enable)
 | |
|         {
 | |
|             Group = group;
 | |
|             Element = element;
 | |
|             ReplaceValue = value;
 | |
|             Enable = enable;
 | |
|         }
 | |
|     }
 | |
| } |