public MainWindow() { InitializeComponent(); // 初始化主窗口 InitializeMainWindow(); // 设置通知栏图标 InitailizeNotifyIcon(); try { // 开发电脑上面就不用自启了 // 设置开机自启 if (!YUtil.GetWindowsUserName().ToUpper().Contains("SOMIAR")) { YUtil.SetAppAutoStart("PanyuVisualSystem", true); } else { UIMessageBox.Show("提示", "开发电脑无需自启", 5000); } } catch { UIMessageBox.Show("异常", "设置启动异常", 5000); // ignored } try { // 番禺的防火墙服务默认是禁用 // 这样就会封掉所有端口,所以只能打开防火墙服务,然后关闭防火墙才行 // 当然防火墙的状态是设置的为关闭 YUtil.SetWinServiceStartupType("MpsSvc", ServiceStartMode.Automatic); YUtil.StartWinService("MpsSvc"); } catch { // ignored } // 检查网络连接 if (OnlineDataCenter.IsNetwork2ServerOK()) { InitAndSetupMachineWindow(); try { // 同步服务器时间 var time = YUtil.GetNtpTime(Configuration.ServerIp); if (Math.Abs((DateTime.Now - time).TotalSeconds) > 10) { YUtil.SetLoadTimeByDateTime(time); } } catch { // ignored } } else { Task.Run(() => { SustainedNetworkTest(null); }); } }
public static void Load(string path) { var config = YUtil.GetJsonObjectFromFile <Dictionary <string, object> >(path); YUtil.SetStaticField(typeof(HmiConfig), config); bool isDevUserEnv = DevUser.ToLower().Contains(YUtil.GetWindowsUserName().ToLower()); var genDict = new Dictionary <string, object>(); genDict[nameof(IsDevUserEnv)] = isDevUserEnv; YUtil.SetStaticField(typeof(HmiConfig), genDict); YUtil.ValidRequiredConfig(typeof(HmiConfig)); CraftBomZhsDict = new Dictionary <string, string>(); }