/// <summary> /// 启动 Hmi Pro /// </summary> /// <param name="data"></param> /// <returns></returns> ExecRest startHmiPro(object data) { var start = (CmdActions.StartHmiPro)data; var rest = new ExecRest(); try { rest.DebugMessage = YUtil.CheckProcessIsExist(hmiProName) ? "HmiPro 进程存在" : "HmiPro 进程不存在"; //强制启动 if (start.IsForced) { YUtil.KillProcess(hmiProName); YUtil.Exec(hmiProPath, start.StartArgs); rest.Message = "强制启动 HmiPro 成功"; //只有当进程不存在的时候才启动 } else if (!YUtil.CheckProcessIsExist(hmiProName)) { YUtil.Exec(hmiProPath, start.StartArgs); rest.Message = "启动 HmiPro 成功"; } rest.Code = ExecCode.Ok; } catch (Exception e) { rest.Message = "启动 HmiPro 失败"; rest.Code = ExecCode.StartHmiProFailed; rest.DebugMessage = e.Message; } return(rest); }
/// <summary> /// HmiPro 软件保活 /// </summary> void keepHmiAlive() { Logger.Debug("HmiPro 保活"); if ((DateTime.Now - HmiLastActiveTime).TotalMinutes > 3) { HmiLastActiveTime = DateTime.Now; var isExist = YUtil.CheckProcessIsExist(GlobalConfig.HmiProcessName); Logger.Error("HmiPro 已经无响应了,进程是否存在:" + isExist + ",最后活动时间:" + HmiLastActiveTime); YUtil.KillProcess(GlobalConfig.HmiProcessName); string startupArgs = string.Empty; if (GlobalConfig.IsDevEnv) { startupArgs = @"--console false --autostart false --splash false --config office --hmi DE_DF --mock true"; } Logger.Debug("HmiPro.exe 路径:" + GlobalConfig.StartupArgs.HmiProPath + " " + startupArgs); YUtil.Exec(GlobalConfig.StartupArgs.HmiProPath, startupArgs); } }
/// <summary> /// 对程序进行配置 /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ReduxIoc.Init(); if (!YUtil.CheckProcessIsExist(HmiConfig.AsylumProcessName)) { string asylumnArgs = ""; if (HmiConfig.IsDevUserEnv) { asylumnArgs = "--autostart false --HmiPath " + YUtil.GetAbsolutePath(".\\HmiPro.exe"); } //YUtil.Exec(YUtil.GetAbsolutePath(@".\Asylum\Asylum.exe"), asylumnArgs); } Store = UnityIocService.ResolveDepend <StorePro <AppState> >(); //异步初始化,直接进入 DxWindow Task.Run(() => { hmiConfigInit(e); initSubscribe(); //通知 DxWindow 初始化完毕 Store.Dispatch(new SysActions.AppXamlInited(e)); }); }