123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using Aitex.Common.Util;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using MECF.Framework.Common.OperationCenter;
- using MECF.Framework.UI.Client.ClientBase;
- using OpenSEMI.ClientBase;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Windows;
- namespace MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig
- {
- public class ShutDonwControlViewModel : UiViewModelBase
- {
- private bool _uIAndRTControlVisibility = false;
- public bool UIAndRTControlVisibility
- {
- get => _uIAndRTControlVisibility;
- set
- {
- _uIAndRTControlVisibility = value;
- NotifyOfPropertyChange(nameof(UIAndRTControlVisibility));
- }
- }
- private bool _uIControlVisibility = false;
- public bool UIControlVisibility
- {
- get => _uIControlVisibility;
- set
- {
- _uIControlVisibility = value;
- NotifyOfPropertyChange(nameof(UIControlVisibility));
- }
- }
- private bool _allControlVisibility = false;
- public bool AllControlVisibility
- {
- get => _allControlVisibility;
- set
- {
- _allControlVisibility = value;
- NotifyOfPropertyChange(nameof(AllControlVisibility));
- }
- }
- public void ReStartRTAndUI()
- {
- if (DialogBox.Confirm("Are you sure you want to Restart UI and RT?"))
- Process.Start($"{Path.GetDirectoryName(PathManager.GetAppDir())}\\FurnaceBat\\startFurnace.bat");
- }
- public void ShutDownUIAndRT()
- {
- if (DialogBox.Confirm("Are you sure you want to shut down UI and RT?"))
- Process.Start($"{Path.GetDirectoryName(PathManager.GetAppDir())}\\FurnaceBat\\stopFurnace.bat");
- }
- public void ReStartUI()
- {
- if (DialogBox.Confirm("Are you sure you want to ReStart UI?"))
- Process.Start($"{Path.GetDirectoryName(PathManager.GetAppDir())}\\FurnaceBat\\restartUI.bat");
- }
- public void ShutDownUI()
- {
- if (DialogBox.Confirm("Are you sure you want to shut down UI?"))
- Process.Start($"{Path.GetDirectoryName(PathManager.GetAppDir())}\\FurnaceBat\\shutDownUI.bat");
- }
- public void AllControlPowerOff()
- {
- if (DialogBox.Confirm("Are you sure you want to shut down your computer in 60 seconds?"))
- ExecuteCommand("shutdown", "/s /f /t 60");
- }
- public void RestartComputer()
- {
- if (DialogBox.Confirm("Are you sure you want to restart your computer in 60 seconds?"))
- ExecuteCommand("shutdown", "/r /f /t 60");
- }
- public void AllControlReStart()
- {
- if (DialogBox.Confirm("Are you sure you want to restart All Control ?"))
- {
- ReStartRTAndUI();
- }
- }
- public void AllControlShutDown()
- {
- if (DialogBox.Confirm("Are you sure you want to restart All ShutDown ?"))
- {
- ShutDownUIAndRT();
- }
- }
- private void ExecuteCommand(string fileName, string arguments)
- {
- LOG.Info($"{fileName} {arguments}");
- try
- {
- System.Diagnostics.Process.Start(new ProcessStartInfo(fileName, arguments)
- {
- UseShellExecute = false,
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- CreateNoWindow = true,
- });
- }
- catch (Exception ex)
- {
- LOG.Info($"{fileName} {arguments},An error occurred: {ex.Message}");
- }
- }
- }
- }
|