using HMI.Core.Manager; using HMI.Core.Util; using System.Collections; using System.Configuration; using System.IO; using System.Runtime.CompilerServices; namespace HMI.Core.Setting { public class ParamSetting { private static Hashtable customConfig = (Hashtable)ConfigurationManager.GetSection("TestResultConfig"); private static string GetValue([CallerMemberName] string propertyName = null) { return (customConfig != null && customConfig.ContainsKey(propertyName)) ? customConfig[propertyName].ToString() : null; } /// /// MesAddress /// public static string MesAddress { get; private set; } = "127.0.0.1:8080"; /// /// 老化导出行转列 /// public static bool ReverseCSV { get; private set; } = false; /// /// 客户编码 /// public static string CustomerCode { get; private set; } /// /// 生产数据DB存放目录 /// public static string DataLogFolder { get; private set; } = null; /// /// 是否开启水冷机设置 /// public static bool ShowCoolerSetting { get; private set; } = false; public static bool ShowWaterChart { get; private set; } = false; /// /// 按型号计算探针 /// public static bool ProbeByModel { get; private set; } = false; public static int ReverseCSVSkipRow { get; private set; } = 3; /// /// 操作是否需要密码 /// public static bool IsOptRequirePassword { get; private set; } = false; /// /// 启用扫码换型 /// public static bool EnableAutoModel { get; private set; } = false; public const string ShareConfigKey = "ShareConfig"; public static string ShareConfig { get; private set; } = null; public static bool ShowBurnInAbort { get; private set; } = true; public static string SocketNames { get; private set; } = string.Empty; public static string StationName { get; private set; } = string.Empty; public static string MainSeqPath { get; private set; } = string.Empty; public static string EngineType { get { var data = GetValue(); return data == null ? "TestStand" : data.ToString(); } } static ParamSetting() { try { var value = ParameterManager.GetCommonParameterByName("MesAddress"); if (value != null) { MesAddress = value.Value; } } catch { } try { var value = ParameterManager.GetCommonParameterByName("ReverseCSV"); if (value != null) { ReverseCSV = bool.Parse(value.Value); } } catch { } try { var value = ParameterManager.GetCommonParameterByName("TS_DataLogPath"); DataLogFolder = value?.Value ?? Path.Combine(PathHelper.ConfigFolder, "DataBoard"); } catch { DataLogFolder = Path.Combine(PathHelper.ConfigFolder, "DataBoard"); } try { var value = ParameterManager.GetCommonParameterByName("ShowWaterChart"); if (value != null) { ShowWaterChart = bool.Parse(value.Value); } } catch { } try { var value = ParameterManager.GetCommonParameterByName("ShowCoolerSetting"); if (value != null) { ShowCoolerSetting = bool.Parse(value.Value); } } catch { } try { var value = ParameterManager.GetCommonParameterByName("CustomerCode"); if (value != null) { CustomerCode = value.Value; } } catch { } try { var value = ParameterManager.GetCommonParameterByName("ProbeByModel"); if (value != null) { ProbeByModel = bool.Parse(value.Value); } } catch { } try { var value = ParameterManager.GetCommonParameterByName("ReverseCSVSkipRow"); if (value != null) { ReverseCSVSkipRow = int.Parse(value.Value); } } catch { } try { IsOptRequirePassword = ParameterManager.GetCommonParameterByName("IsOptRequirePassword", false); } catch { } try { EnableAutoModel = ParameterManager.GetCommonParameterByName("EnableAutoModel", false); } catch { } try { ShareConfig = ParameterManager.GetCommonParameterByName(ShareConfigKey, null); } catch { } try { ShowBurnInAbort = ParameterManager.GetCommonParameterByName("ShowBurnInAbort", true); } catch { } try { SocketNames = ParameterManager.GetCommonParameterByName("SocketNames", string.Empty); } catch { } try { StationName = ParameterManager.GetCommonParameterByName("StationName", string.Empty); } catch { } try { MainSeqPath = ParameterManager.GetCommonParameterByName("BurnInMainSeq", string.Empty); } catch { } } } }