| | |
| | | /// </summary> |
| | | public static event EventHandler<SystemSetting> SystemSettingChanged; |
| | | |
| | | private static string FilePath = Path.Combine(PathHelper.SettingFolder, "SystemConfig.xml"); |
| | | |
| | | static SystemSetting() |
| | | { |
| | | LoadFromXml(); |
| | |
| | | |
| | | } |
| | | |
| | | public string LogoPath { get; private set; } |
| | | public string WindowTitle { get; private set; } |
| | | public string LogoPath { get; private set; } = ".\\JingCeLogo.png"; |
| | | public string WindowTitle { get; private set; } = "产品测试平台"; |
| | | public string PlcIp { get; private set; } |
| | | public bool PlcEnabled { get; private set; } |
| | | public string CurrentLanguage { get; private set; } = "zh-CN"; |
| | | public int LogExpiredDays { get; private set; } = 7; |
| | | |
| | | private static void LoadFromXml() |
| | | { |
| | | if (Instance != null) return; |
| | | string XmlFilePath = PathHelper.ConfigFolder + "\\SystemConfig.xml"; |
| | | if (!File.Exists(XmlFilePath)) |
| | | if (!File.Exists(FilePath)) |
| | | { |
| | | Instance = new SystemSetting(); |
| | | } |
| | | else |
| | | { |
| | | SystemSettingModel model = XmlHelper.DeserializeFromXml<SystemSettingModel>(XmlFilePath); |
| | | SystemSettingModel model = XmlHelper.DeserializeFromXml<SystemSettingModel>(FilePath); |
| | | SystemSetting setting = new SystemSetting(); |
| | | BeanUtil.Copy(model, setting); |
| | | Instance = setting; |
| | | } |
| | | } |
| | | |
| | | public static SystemSettingModel GetModel() |
| | | { |
| | | return XmlHelper.DeserializeFromXml<SystemSettingModel>(FilePath); |
| | | } |
| | | |
| | | public static void ReLoad() |
| | | { |
| | | string XmlFilePath = PathHelper.ConfigFolder + "\\SystemConfig.xml"; |
| | | if (!File.Exists(XmlFilePath)) |
| | | if (!File.Exists(FilePath)) |
| | | { |
| | | Instance = new SystemSetting(); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | SystemSettingModel model = XmlHelper.DeserializeFromXml<SystemSettingModel>(XmlFilePath); |
| | | SystemSettingModel model = XmlHelper.DeserializeFromXml<SystemSettingModel>(FilePath); |
| | | SystemSetting setting = new SystemSetting(); |
| | | BeanUtil.Copy(model, setting); |
| | | Instance = setting; |
| | |
| | | get => plcEnabled; |
| | | set { Set(ref plcEnabled, value); } |
| | | } |
| | | |
| | | private string currentLanguage; |
| | | public string CurrentLanguage |
| | | { |
| | | get => currentLanguage; |
| | | set { Set(ref currentLanguage, value); } |
| | | } |
| | | |
| | | private int logExpiredDays; |
| | | public int LogExpiredDays |
| | | { |
| | | get => logExpiredDays; |
| | | set { Set(ref logExpiredDays, value); } |
| | | } |
| | | } |
| | | } |