/// <summary> /// 显示骷颅头界面 /// </summary> /// <param name="state">程序状态</param> /// <param name="action">骷髅头图片和内容</param> void hackSkullView(AppState state, IAction action) { var hackAction = (HookActions.HackAppSkullView)action; App.Store.Dispatch(new SysActions.ChangeWindowBackgroundImage(AssetsHelper.GetAssets().ImageSkull)); App.Store.Dispatch(new SysActions.SetLoadingViewState(Visibility.Visible, SystemParameters.PrimaryScreenHeight, hackAction.Message)); }
/// <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()); }
public void CloseScreen(object secObj) { if (secObj == null) { YUtil.CloseScreen(AssetsHelper.GetAssets().ExeNirCmd); } else { int sec = int.Parse(secObj.ToString()); var ms = sec * 1000; Task.Run(() => { YUtil.CloseScreen(AssetsHelper.GetAssets().ExeNirCmd); YUtil.SetTimeout(ms, () => { YUtil.OpenScreen(AssetsHelper.GetAssets().ExeNirCmd); }); }); } }
public MqCallViewModel() { MqCallDict = new Dictionary <string, List <MqCall> >(); foreach (var pair in MachineConfig.MachineDict) { var machineCode = pair.Key; if (!MqCallDict.ContainsKey(machineCode)) { MqCallDict[machineCode] = new List <MqCall>(); } var callRepair = new MqCall() { CallIcon = AssetsHelper.GetAssets().IconRepair, CallTxt = $"{machineCode} 报修", MachineCode = machineCode, Data = null, CallType = MqCallType.Repair, }; var callForklift = new MqCall() { CallIcon = AssetsHelper.GetAssets().IconForklift, CallTxt = $"{machineCode} 叉车", MachineCode = machineCode, Data = null, CallType = MqCallType.Forklift }; var callRepairComplete = new MqCall() { CallIcon = AssetsHelper.GetAssets().IconV, CallTxt = $"{machineCode} 完成维修", MachineCode = machineCode, Data = null, CallType = MqCallType.RepairComplete }; MqCallDict[machineCode].Add(callRepair); MqCallDict[machineCode].Add(callForklift); MqCallDict[machineCode].Add(callRepairComplete); } }
public void OnLoaded() { if (AppState.IsCompleteInited) { return; } //更新启动日志 App.StartupLog.IsStartSuccess = true; App.StartupLog.StartDurationMs = (long)(DateTime.Now - App.StartupLog.StartTime).TotalMilliseconds; SqliteHelper.DoAsync(ctx => { ctx.StartupLogs.Add(App.StartupLog); ctx.SaveChanges(); }); var dbEffects = UnityIocService.ResolveDepend <DbEffects>(); App.Store.Dispatch(dbEffects.UploadDocToMongo(new DbActions.UploadDocToMongo(MongoHelper.LogsDb, MongoHelper.StartupLogsCollection, App.StartupLog))); App.Store.Dispatch(new SysActions.CloseLoadingSplash()); App.Store.Dispatch(new SysActions.ChangeWindowBackgroundImage(AssetsHelper.GetAssets().ImageBackground)); //置位程序初始化完成 AppState.IsCompleteInited = true; }
/// <summary> /// 派发模拟排产任务 /// </summary> public static void DispatchMockSchTask(string machineCode, int id = 0) { var mockEffects = UnityIocService.ResolveDepend <MockEffects>(); var task = YUtil.GetJsonObjectFromFile <MqSchTask>(AssetsHelper.GetAssets().MockMqSchTaskJson); task.workcode = YUtil.GetRandomString(8); task.id = id; task.taskId = id.ToString(); task.maccode = machineCode; foreach (var axis in task.axisParam) { axis.maccode = task.maccode; axis.axiscode = YUtil.GetRandomString(10); axis.taskId = task.taskId; } JavaTime startTime = new JavaTime() { time = YUtil.GetUtcTimestampMs(YUtil.GetRandomTime(DateTime.Now.AddDays(-1), DateTime.Now)) }; task.pstime = startTime; task.pdtime = startTime; App.Store.Dispatch(mockEffects.MockSchTaskAccept(new MockActions.MockSchTaskAccpet(task))); }
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; })); }
private void initTaskbarIcon() { taskbar = new TaskbarIcon(); taskbar.Icon = new System.Drawing.Icon(Application.GetResourceStream(AssetsHelper.GetAssets("fly.ico")).Stream); taskbar.ContextMenu = (ContextMenu)FindResource("SysTrayMenu"); taskbar.DoubleClickCommand = new MdCommand(maximazeExec); }
public void ShowDesktop() { YUtil.ShowDesktop(AssetsHelper.GetAssets().ExeNirCmd); }
public void HideDesktop() { YUtil.HideDesktop(AssetsHelper.GetAssets().ExeNirCmd); }
public void OpenScreen() { YUtil.OpenScreen(AssetsHelper.GetAssets().ExeNirCmd); }
/// <summary> /// 去除骷髅头界面,恢复正常 /// </summary> /// <param name="state">程序状态</param> /// <param name="action">移除骷髅头界面动作</param> void rescueSkullView(AppState state, IAction action) { App.Store.Dispatch(new SysActions.ChangeWindowBackgroundImage(AssetsHelper.GetAssets().ImageBackground)); App.Store.Dispatch(new SysActions.SetLoadingViewState(Visibility.Collapsed, 0, "")); }
public static MqScanMaterial CreateScanMaterial() { return(YUtil.GetJsonObjectFromFile <MqScanMaterial>(AssetsHelper.GetAssets().MockMqScanMaterial)); }