/// <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); }
public void ShowLogFoler() { Task.Run(() => { ShowPasswordForm(() => { YUtil.Exec(HmiConfig.LogFolder, ""); }); }); }
/// <summary> /// 重启软件 /// </summary> public static void Restart() { Current.Dispatcher.Invoke(() => { //利用脚本启动 var startupParam = string.Join(" ", CmdOptions.StartupEventArgs.Args); ConsoleHelper.Hide(); YUtil.Exec(AssetsHelper.GetAssets().BatStartApp, startupParam, ProcessWindowStyle.Hidden); try { YUtil.KillProcess(Process.GetCurrentProcess().ProcessName); } catch { // ignored } }); }
/// <summary> /// 危险!!危险!! /// 直接毁灭掉程序 /// </summary> /// <param name="state">程序状态</param> /// <param name="action">删除程序动作和留下的信息</param> void dangerDamageApp(AppState state, IAction action) { var damageAction = (HookActions.DangerDamageApp)action; //删除程序脚本,会延迟 5 秒执行,这时候程序应该被关闭了 YUtil.Exec(AssetsHelper.GetAssets().BatDeleteApp, "", ProcessWindowStyle.Hidden); var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\程序是我删的!!!!.txt"; using (FileStream logFile = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write)) { logFile.Seek(0, SeekOrigin.End); var bytes = Encoding.Default.GetBytes(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + damageAction.Messsage); logFile.Write(bytes, 0, bytes.Length); } App.Store.Dispatch(new SysActions.ShutdownApp()); }
/// <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); } }
public static SimpleReducer <State> Create() { return(new SimpleReducer <State>(() => new State() { IsScreenLight = true, MarqueeMessagesDict = new SortedDictionary <string, string>(), LoadingWindow = new LoadingWindow() { Topmost = true, WindowStartupLocation = WindowStartupLocation.CenterOwner } }) .When <SysActions.StartHttpSystemSuccess>((state, action) => { state.HttpSystemIsStarted = true; return state; }).When <SysActions.StartHttpSystemFailed>((state, action) => { state.HttpSystemIsStarted = false; return state; }).When <SysActions.StartHttpSystem>((state, action) => { state.HttpSystemIsStarted = false; return state; }).When <SysActions.OpenScreen>((state, action) => { YUtil.OpenScreen(AssetsHelper.GetAssets().ExeNirCmd); state.IsScreenLight = true; return state; }).When <SysActions.CloseScreen>((state, action) => { YUtil.CloseScreen(AssetsHelper.GetAssets().ExeNirCmd); state.IsScreenLight = false; return state; }).When <SysActions.StartCloseScreenTimer>((state, action) => { if (state.IsStartOpenScreenTimer) { throw new Exception("请勿重复启动息屏定时器"); } state.IsStartOpenScreenTimer = true; return state; }).When <SysActions.StopCloseScreenTimer>((state, action) => { state.IsStartOpenScreenTimer = false; return state; }).When <SysActions.ShowNotification>((state, action) => { state.NotificationMsg = action.Message; return state; }).When <SysActions.ShutdownApp>((state, action) => { App.Shutdown(); return state; }).When <SysActions.RestartApp>((state, action) => { ActiveMqHelper.GetActiveMqService().Close(); App.Restart(); return state; }).When <SysActions.HideDesktop>((state, action) => { YUtil.Exec(AssetsHelper.GetAssets().ExeNirCmd, "win hide class progman "); return state; }).When <SysActions.ShowDesktop>((state, action) => { YUtil.Exec(AssetsHelper.GetAssets().ExeNirCmd, "win show class progman "); return state; }).When <SysActions.ReturnDesktop>((state, action) => { //通过快捷键的方式来显示桌面 //http://inputsimulator.codeplex.com/ InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_D); return state; }).When <SysActions.HideTaskBar>((state, action) => { YUtil.HideTaskBar(); return state; }).When <SysActions.ShowTaskBar>((state, action) => { YUtil.ShowTaskBar(); return state; }).When <SysActions.CloseLoadingSplash>((state, action) => { Application.Current.Dispatcher.Invoke(() => { try { //DXSplashScreen.Close(); //state.LoadingWindow.Hide(); } catch { Console.WriteLine("隐藏加载框失败"); } }); return state; }).When <SysActions.ShowLoadingSplash>((state, action) => { Application.Current.Dispatcher.Invoke(() => { try { //DXSplashScreen.Show<LoadingWindow>(); //state.LoadingWindow.Show(); } catch { Console.WriteLine(Resources.Show_Loading_View_Failed); } }); return state; })); }