|
|
|
@ -18,6 +18,12 @@ using StartServerWPF.Modules.Main.Model;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Timers;
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using Org.BouncyCastle.Crypto.Modes.Gcm;
|
|
|
|
|
using System.Net.Http.Json;
|
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
using System.Text.Encodings.Web;
|
|
|
|
|
using System.Text.Unicode;
|
|
|
|
|
|
|
|
|
|
namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
{
|
|
|
|
@ -46,7 +52,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
+ "\t" + sc.remoteDb.UserName + "\t" + sc.remoteDb.Password);
|
|
|
|
|
this._dialogService = dialogService;
|
|
|
|
|
this._websocket = websocket;
|
|
|
|
|
_websocket.WebSocketInit();
|
|
|
|
|
_websocket.WebSocketInit(sc.remoteDb.WebsocketUrl);
|
|
|
|
|
CurrentItemsList = ApmsProcessSliceList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -134,8 +141,57 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
set => SetProperty(ref proMonInterval, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
private ObservableCollection<string> _OutPutItemsSource = new ObservableCollection<string>();
|
|
|
|
|
public ObservableCollection<string> OutPutItemsSource
|
|
|
|
|
{
|
|
|
|
|
get => _OutPutItemsSource;
|
|
|
|
|
set => SetProperty(ref _OutPutItemsSource, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<string> _apmsProcessSliceList= new List<string>();
|
|
|
|
|
public List<string> ApmsProcessSliceList
|
|
|
|
|
{
|
|
|
|
|
get => _apmsProcessSliceList;
|
|
|
|
|
set=> SetProperty(ref _apmsProcessSliceList, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private List<string> _apmsEventList = new List<string>();
|
|
|
|
|
public List<string> ApmsEventList
|
|
|
|
|
{
|
|
|
|
|
get => _apmsEventList;
|
|
|
|
|
set => SetProperty(ref _apmsEventList, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<string> _toolsProcessSliceList = new List<string>();
|
|
|
|
|
public List<string> ToolsProcessSliceList
|
|
|
|
|
{
|
|
|
|
|
get => _toolsProcessSliceList;
|
|
|
|
|
set => SetProperty(ref _toolsProcessSliceList, value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private List<string> _toolsEventList = new List<string>();
|
|
|
|
|
public List<string> ToolsEventList
|
|
|
|
|
{
|
|
|
|
|
get => _toolsEventList;
|
|
|
|
|
set => SetProperty(ref _toolsEventList, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void AddItems<T>(List<T> list, T t1)
|
|
|
|
|
{
|
|
|
|
|
if (list == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
list.Add(t1);
|
|
|
|
|
if (list.Count > 10)
|
|
|
|
|
{
|
|
|
|
|
T item = list[0];
|
|
|
|
|
list.RemoveAt(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
private List<string> CurrentItemsList;
|
|
|
|
|
#region 事件
|
|
|
|
|
public DelegateCommand LoadedCommand => new(Loaded);
|
|
|
|
|
public DelegateCommand UnloadedCommand => new(Unloaded);
|
|
|
|
@ -150,51 +206,55 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
public DelegateCommand DisplayRealWavesCommand => new(DisplayRealWaves);
|
|
|
|
|
public DelegateCommand QueryDataCommand => new(QueryData);
|
|
|
|
|
public DelegateCommand InsertDataCommand => new(InsertData);
|
|
|
|
|
public DelegateCommand<object> OutputItemsCommand => new((obj)=>
|
|
|
|
|
{
|
|
|
|
|
switch (obj.ToString())
|
|
|
|
|
{
|
|
|
|
|
case "apmsProcessSlice":
|
|
|
|
|
CurrentItemsList = ApmsProcessSliceList;
|
|
|
|
|
break;
|
|
|
|
|
case "apmsEvent":
|
|
|
|
|
CurrentItemsList = ApmsEventList;
|
|
|
|
|
OutPutItemsSource.Clear();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "toolsProcessSlice":
|
|
|
|
|
CurrentItemsList = ToolsProcessSliceList;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "toolsEvent":
|
|
|
|
|
CurrentItemsList = ToolsEventList;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
OutPutItemsSource.Clear();
|
|
|
|
|
CurrentItemsList.ForEach((item) =>
|
|
|
|
|
{
|
|
|
|
|
OutPutItemsSource.Add(item);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
private void Loaded()
|
|
|
|
|
{
|
|
|
|
|
IntilVPN();
|
|
|
|
|
SetControlstatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Unloaded()
|
|
|
|
|
public void Unloaded()
|
|
|
|
|
{
|
|
|
|
|
KillProcess(sc.proServer);
|
|
|
|
|
KillProcess(sc.proRecv);
|
|
|
|
|
KillProcess(sc.proApms);
|
|
|
|
|
KillProcess(sc.proMonitor);
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
//switch (kserindex)
|
|
|
|
|
//{
|
|
|
|
|
// case -1:
|
|
|
|
|
// Console.WriteLine(serProcInfo.ProName + "结束失败");
|
|
|
|
|
// break;
|
|
|
|
|
// case 0:
|
|
|
|
|
// Console.WriteLine(serProcInfo.ProName + "结束成功");
|
|
|
|
|
// break;
|
|
|
|
|
// case 1:
|
|
|
|
|
// Console.WriteLine(serProcInfo.ProName + "程序未启动");
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//int krecindex = KillProcess(recvProcInfo);
|
|
|
|
|
//switch (krecindex)
|
|
|
|
|
//{
|
|
|
|
|
// case -1:
|
|
|
|
|
// Console.WriteLine(recvProcInfo.ProName + "结束失败");
|
|
|
|
|
// break;
|
|
|
|
|
// case 0:
|
|
|
|
|
// Console.WriteLine(recvProcInfo.ProName + "结束成功");
|
|
|
|
|
// break;
|
|
|
|
|
// case 1:
|
|
|
|
|
// Console.WriteLine(recvProcInfo.ProName + "程序未启动");
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
//KillProcess(sc.proServer);
|
|
|
|
|
//KillProcess(sc.proRecv);
|
|
|
|
|
//KillProcess(sc.proApms);
|
|
|
|
|
//KillProcess(sc.proMonitor);
|
|
|
|
|
//KillProcess(sc.proTools);
|
|
|
|
|
//string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
|
|
|
|
|
//WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
OneKeyStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConnectVPN()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
vpn.CreateOrUpdateVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnIP);
|
|
|
|
|
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
@ -230,10 +290,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
|
|
|
|
|
private void SetVPNPara()
|
|
|
|
|
{
|
|
|
|
|
//FormSetParam fvi = new FormSetParam();
|
|
|
|
|
//fvi.fm = this;
|
|
|
|
|
//fvi.ShowDialog();
|
|
|
|
|
|
|
|
|
|
DialogParameters param = new DialogParameters();
|
|
|
|
|
param.Add("type", 1);// 编辑
|
|
|
|
|
param.Add("model", sc);
|
|
|
|
@ -255,36 +311,23 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
{
|
|
|
|
|
Process.Start("explorer.exe", sc.vpnInfo.SystemLogPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OneKeyStart()
|
|
|
|
|
{
|
|
|
|
|
StartTime = DateTime.Now;
|
|
|
|
|
sc.proServer.Pid = StartProcess(sc.proServer);
|
|
|
|
|
StartTime = DateTime.Now;
|
|
|
|
|
if (sc.proServer.Pid < 32)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("服务器程序启动失败:" + StartTime.ToString());
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10);
|
|
|
|
|
sc.proRecv.Pid = StartProcess(sc.proRecv);
|
|
|
|
|
if (sc.proRecv.Pid < 32)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("接收数据程序启动失败:" + StartTime.ToString());
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10);
|
|
|
|
|
sc.proApms.Pid = StartProcess(sc.proApms);
|
|
|
|
|
if (sc.proApms.Pid < 32)
|
|
|
|
|
foreach (var item in sc.GetType().GetProperties())
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("自动识别程序启动失败:" + StartTime.ToString());
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10);
|
|
|
|
|
sc.proMonitor.Pid = StartProcess(sc.proMonitor);
|
|
|
|
|
Console.WriteLine(sc.proMonitor.Pid);
|
|
|
|
|
if (sc.proMonitor.Pid < 32)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("网页服务程序启动失败:" + StartTime.ToString());
|
|
|
|
|
var pro = item.GetValue(sc) as ProcessInfo;
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
StartTime = DateTime.Now;
|
|
|
|
|
pro.Pid= StartProcess(pro);
|
|
|
|
|
if (sc.proServer.Pid < 32)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add( pro.ProName+"服务器程序启动失败:" + StartTime.ToString());
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10);
|
|
|
|
|
// labelStartTime.Text = "启动时间:" + StartTime.ToString();
|
|
|
|
|
RunTime = DateDiff(DateTime.Now, StartTime);
|
|
|
|
|
string logStr = StartTime.ToString("s") + "\t服务器程序启动";
|
|
|
|
@ -299,42 +342,23 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
|
|
|
|
|
private void OneKeyStop()
|
|
|
|
|
{
|
|
|
|
|
int kserindex = KillProcess(sc.proServer);
|
|
|
|
|
if (kserindex > -1)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proServer.ProName + "结束成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proServer.ProName + "结束失败");
|
|
|
|
|
}
|
|
|
|
|
int krecindex = KillProcess(sc.proRecv);
|
|
|
|
|
if (kserindex > -1)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proRecv.ProName + "结束成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proRecv.ProName + "结束失败");
|
|
|
|
|
}
|
|
|
|
|
int kampsindex = KillProcess(sc.proApms);
|
|
|
|
|
if (kampsindex > -1)
|
|
|
|
|
foreach (var item in sc.GetType().GetProperties())
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proApms.ProName + "结束成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proApms.ProName + "结束失败");
|
|
|
|
|
}
|
|
|
|
|
int kmonitorindex = KillProcess(sc.proMonitor);
|
|
|
|
|
if (kmonitorindex > -1)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proMonitor.ProName + "结束成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(sc.proMonitor.ProName + "结束失败");
|
|
|
|
|
var pro = item.GetValue(sc) as ProcessInfo;
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
int indexPro = KillProcess(pro);
|
|
|
|
|
if (indexPro > -1)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(pro.ProName + "结束成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(pro.ProName + "结束失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReciveDataSource.Add("服务停止于:" + DateTime.Now.ToString());
|
|
|
|
|
timer1.Stop();
|
|
|
|
|
IsIndeterminate = false;
|
|
|
|
@ -372,37 +396,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("已有该记录");
|
|
|
|
|
}
|
|
|
|
|
// dataGridView1.DataSource = remDb.MySqlSelect("select ETime,X,Y,Z,ML,LocSta,MLSta,Rms from " + sc.remoteDb.TableName).Tables[sc.remoteDb.TableName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
|
|
|
|
|
// Thread.Sleep(1000);
|
|
|
|
|
// string logStr = DateTime.Now.ToString("s") + "\tVPN手动连接";
|
|
|
|
|
// WriteSerLog(sc.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
|
// SetControlstatus();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private void button1_Click_1(object sender, EventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// JsonParser.WriteSystemConfigFile("SystemConfig.json", sc);
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private void button2_Click(object sender, EventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// ProcessStartInfo processStartInfo = new ProcessStartInfo(@"F:\Project\2021\河南理工\余吾预警项目\郑老师程序\v20210415\All\server.exe", "service.conf");
|
|
|
|
|
// processStartInfo.WindowStyle = ProcessWindowStyle.Normal;
|
|
|
|
|
// Process proc = Process.Start(processStartInfo);
|
|
|
|
|
|
|
|
|
|
// ProcessStartInfo processStartInfoRec = new ProcessStartInfo(@"F:\Project\2021\河南理工\余吾预警项目\郑老师程序\v20210415\All\gw.recvftp.exe", "-cfg gw.recvftp.json >outRecv.txt");
|
|
|
|
|
// processStartInfoRec.WindowStyle = ProcessWindowStyle.Normal;
|
|
|
|
|
// Process procRec = Process.Start(processStartInfoRec);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
private void ConnectVpn()
|
|
|
|
|
{
|
|
|
|
@ -473,6 +467,83 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
//CheckIp();
|
|
|
|
|
}
|
|
|
|
|
#region 方法
|
|
|
|
|
private bool CMDStartProcess(ProcessInfo proInfo)
|
|
|
|
|
{
|
|
|
|
|
//* Create your Process
|
|
|
|
|
Process process = new Process();
|
|
|
|
|
process.Exited += Process_Exited;
|
|
|
|
|
process.EnableRaisingEvents = true;
|
|
|
|
|
process.StartInfo.FileName = Path.GetFullPath(proInfo.ProPath + proInfo.ProName+".exe");
|
|
|
|
|
process.StartInfo.WorkingDirectory = Path.GetFullPath(proInfo.ProPath);
|
|
|
|
|
process.StartInfo.Arguments = proInfo.ProParams;
|
|
|
|
|
process.StartInfo.UseShellExecute = false;
|
|
|
|
|
process.StartInfo.RedirectStandardOutput = true;
|
|
|
|
|
process.StartInfo.RedirectStandardError = true;
|
|
|
|
|
|
|
|
|
|
process.StartInfo.CreateNoWindow = true;
|
|
|
|
|
//* Set your output and error (asynchronous) handlers
|
|
|
|
|
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
|
|
|
|
|
process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
|
|
|
|
|
//* Start process and handlers
|
|
|
|
|
bool res= process.Start();
|
|
|
|
|
process.BeginOutputReadLine();
|
|
|
|
|
process.BeginErrorReadLine();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
// process.WaitForExit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Process_Exited(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine("output*************:{0},{1}",sendingProcess.ToString(), outLine.Data);
|
|
|
|
|
if (string.IsNullOrEmpty(outLine.Data)) return;
|
|
|
|
|
if (outLine.Data.Contains("ProcessSlice:"))
|
|
|
|
|
{
|
|
|
|
|
var pro = sendingProcess as Process;
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
if (pro.MainModule.ModuleName.Contains(sc.proApms.ProName))
|
|
|
|
|
{
|
|
|
|
|
AddItems(ApmsProcessSliceList, outLine.Data);
|
|
|
|
|
}
|
|
|
|
|
else if (pro.MainModule.ModuleName.Contains(sc.proTools.ProName))
|
|
|
|
|
{
|
|
|
|
|
AddItems(ToolsProcessSliceList, outLine.Data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (outLine.Data.Contains("ML "))
|
|
|
|
|
{
|
|
|
|
|
var pro = sendingProcess as Process;
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
if (pro.MainModule.ModuleName.Contains(sc.proApms.ProName))
|
|
|
|
|
{
|
|
|
|
|
AddItems(ApmsEventList, outLine.Data);
|
|
|
|
|
}
|
|
|
|
|
else if (pro.MainModule.ModuleName.Contains(sc.proTools.ProName))
|
|
|
|
|
{
|
|
|
|
|
AddItems(ToolsEventList, outLine.Data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Application.Current.Dispatcher.BeginInvoke(() =>
|
|
|
|
|
{
|
|
|
|
|
OutPutItemsSource.Clear();
|
|
|
|
|
CurrentItemsList.ForEach((item) =>
|
|
|
|
|
{
|
|
|
|
|
OutPutItemsSource.Add(item);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启动进程
|
|
|
|
|
/// </summary>
|
|
|
|
@ -480,19 +551,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
/// <returns>进程启动返回值</returns>
|
|
|
|
|
private int StartProcess(ProcessInfo proInfo)
|
|
|
|
|
{
|
|
|
|
|
//using (Process compiler = new Process())
|
|
|
|
|
//{
|
|
|
|
|
// compiler.StartInfo.FileName = proInfo.ProName;
|
|
|
|
|
// compiler.StartInfo.Arguments = proInfo.ProPath + " -o " + proInfo.ProParams;
|
|
|
|
|
// compiler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
|
|
|
// compiler.Start();
|
|
|
|
|
// compiler.WaitForExit();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int seInd = ShellExecute(IntPtr.Zero, new StringBuilder("open"), new StringBuilder(proInfo.ProName + ".exe")
|
|
|
|
|
, new StringBuilder(proInfo.ProParams), new StringBuilder(proInfo.ProPath), proInfo.ShowState);
|
|
|
|
|
bool res= CMDStartProcess(proInfo);
|
|
|
|
|
int seInd = res ? 37 : 1;
|
|
|
|
|
//int seInd = ShellExecute(IntPtr.Zero, new StringBuilder("open"), new StringBuilder(proInfo.ProName + ".exe")
|
|
|
|
|
// , new StringBuilder(proInfo.ProParams), new StringBuilder(proInfo.ProPath), proInfo.ShowState);
|
|
|
|
|
return seInd;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 结束进程
|
|
|
|
@ -589,66 +653,105 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Clear();
|
|
|
|
|
ReciveDataSource.Add(DateTime.Now.ToString());
|
|
|
|
|
int sfp = FindProcess(sc.proServer);
|
|
|
|
|
if (sfp == 0)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("服务器程序运行正常");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("服务器程序未运行");
|
|
|
|
|
Thread.Sleep(2);
|
|
|
|
|
StartProcess(sc.proServer);
|
|
|
|
|
Thread.Sleep(20);
|
|
|
|
|
ReciveDataSource.Add("服务器程序重启成功");
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
}
|
|
|
|
|
sfp = FindProcess(sc.proRecv);
|
|
|
|
|
if (sfp == 0)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("接收数据程序运行正常");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("接收数据程序未运行");
|
|
|
|
|
Thread.Sleep(2);
|
|
|
|
|
StartProcess(sc.proRecv);
|
|
|
|
|
Thread.Sleep(20);
|
|
|
|
|
ReciveDataSource.Add("接收数据程序重启成功");
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
}
|
|
|
|
|
sfp = FindProcess(sc.proApms);
|
|
|
|
|
if (sfp == 0)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("自动识别程序运行正常");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("自动识别程序未运行");
|
|
|
|
|
Thread.Sleep(2);
|
|
|
|
|
StartProcess(sc.proApms);
|
|
|
|
|
Thread.Sleep(20);
|
|
|
|
|
ReciveDataSource.Add("自动识别程序重启成功");
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
}
|
|
|
|
|
sfp = FindProcess(sc.proMonitor);
|
|
|
|
|
if (sfp == 0)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("网页服务程序运行正常");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
foreach (var item in sc.GetType().GetProperties())
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add("网页服务程序未运行");
|
|
|
|
|
Thread.Sleep(2);
|
|
|
|
|
StartProcess(sc.proMonitor);
|
|
|
|
|
Thread.Sleep(20);
|
|
|
|
|
ReciveDataSource.Add("网页服务程序重启成功");
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
var pro = item.GetValue(sc) as ProcessInfo;
|
|
|
|
|
if (pro != null)
|
|
|
|
|
{
|
|
|
|
|
int sfp = FindProcess(pro);
|
|
|
|
|
if (sfp == 0)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(pro.ProName+"服务器程序运行正常");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Add(pro.ProName + "服务器程序未运行");
|
|
|
|
|
Thread.Sleep(2);
|
|
|
|
|
StartProcess(pro);
|
|
|
|
|
Thread.Sleep(20);
|
|
|
|
|
ReciveDataSource.Add(pro.ProName + "服务器程序重启成功");
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + pro.ProName + "重启";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
|
|
|
|
|
string jsonStr= JsonSerializer.Serialize<CSDeviceWebhook>(new CSDeviceWebhook
|
|
|
|
|
{
|
|
|
|
|
type= CSMessage.webhook,
|
|
|
|
|
message=logStr,
|
|
|
|
|
|
|
|
|
|
}, new JsonSerializerOptions
|
|
|
|
|
{
|
|
|
|
|
// 整齐打印
|
|
|
|
|
WriteIndented = true,
|
|
|
|
|
//重新编码,解决中文乱码问题
|
|
|
|
|
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
|
|
|
|
|
});
|
|
|
|
|
_websocket.SendMes(jsonStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 注释
|
|
|
|
|
//int sfp = FindProcess(sc.proServer);
|
|
|
|
|
//if (sfp == 0)
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("服务器程序运行正常");
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("服务器程序未运行");
|
|
|
|
|
// Thread.Sleep(2);
|
|
|
|
|
// StartProcess(sc.proServer);
|
|
|
|
|
// Thread.Sleep(20);
|
|
|
|
|
// ReciveDataSource.Add("服务器程序重启成功");
|
|
|
|
|
// string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
|
|
|
|
|
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
//}
|
|
|
|
|
//sfp = FindProcess(sc.proRecv);
|
|
|
|
|
//if (sfp == 0)
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("接收数据程序运行正常");
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("接收数据程序未运行");
|
|
|
|
|
// Thread.Sleep(2);
|
|
|
|
|
// StartProcess(sc.proRecv);
|
|
|
|
|
// Thread.Sleep(20);
|
|
|
|
|
// ReciveDataSource.Add("接收数据程序重启成功");
|
|
|
|
|
// string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
|
|
|
|
|
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
//}
|
|
|
|
|
//sfp = FindProcess(sc.proApms);
|
|
|
|
|
//if (sfp == 0)
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("自动识别程序运行正常");
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("自动识别程序未运行");
|
|
|
|
|
// Thread.Sleep(2);
|
|
|
|
|
// StartProcess(sc.proApms);
|
|
|
|
|
// Thread.Sleep(20);
|
|
|
|
|
// ReciveDataSource.Add("自动识别程序重启成功");
|
|
|
|
|
// string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
|
|
|
|
|
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
//}
|
|
|
|
|
//sfp = FindProcess(sc.proMonitor);
|
|
|
|
|
//if (sfp == 0)
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("网页服务程序运行正常");
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// ReciveDataSource.Add("网页服务程序未运行");
|
|
|
|
|
// Thread.Sleep(2);
|
|
|
|
|
// StartProcess(sc.proMonitor);
|
|
|
|
|
// Thread.Sleep(20);
|
|
|
|
|
// ReciveDataSource.Add("网页服务程序重启成功");
|
|
|
|
|
// string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
|
|
|
|
|
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
RunTime = DateDiff(DateTime.Now, StartTime);
|
|
|
|
|
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
|
|
|
|
|
if (!vpnStatus)
|
|
|
|
@ -657,6 +760,21 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN断开,重连";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
|
|
|
|
|
string jsonStr = JsonSerializer.Serialize<CSDeviceWebhook>(new CSDeviceWebhook
|
|
|
|
|
{
|
|
|
|
|
type = CSMessage.webhook,
|
|
|
|
|
message = logStr,
|
|
|
|
|
|
|
|
|
|
}, new JsonSerializerOptions
|
|
|
|
|
{
|
|
|
|
|
// 整齐打印
|
|
|
|
|
WriteIndented = true,
|
|
|
|
|
//重新编码,解决中文乱码问题
|
|
|
|
|
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
|
|
|
|
|
});
|
|
|
|
|
_websocket.SendMes(jsonStr);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void GetLocalIp()
|
|
|
|
@ -683,11 +801,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
|
|
|
|
|
if (vpnStatus)
|
|
|
|
|
{
|
|
|
|
|
//gbServerControl.Enabled = true;
|
|
|
|
|
// buttonConnectVPN.Enabled = false;
|
|
|
|
|
|
|
|
|
|
// buttonDisconnectVPN.Enabled = true;
|
|
|
|
|
// labelVPNstatus.ForeColor = Color.Blue;
|
|
|
|
|
VPNIsConnect = true;
|
|
|
|
|
|
|
|
|
|
VPNStatusForeColor = "#FF008000";
|
|
|
|
@ -696,11 +809,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// gbServerControl.Enabled = false;
|
|
|
|
|
// buttonConnectVPN.Enabled = true;
|
|
|
|
|
|
|
|
|
|
// buttonDisconnectVPN.Enabled = false;
|
|
|
|
|
// labelVPNstatus.ForeColor = Color.Red;
|
|
|
|
|
VPNIsConnect = false;
|
|
|
|
|
VPNStatusForeColor = "#FFFF0000";
|
|
|
|
|
VPNStatus = "VPN断开连接";
|
|
|
|
|