|
|
@ -23,8 +23,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
public MainViewModel(IDialogService dialogService)
|
|
|
|
public MainViewModel(IDialogService dialogService)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Message = "View A from your Prism Module";
|
|
|
|
Message = "View A from your Prism Module";
|
|
|
|
Console.WriteLine(System.Environment.CurrentDirectory + "\\" + systemConfigPath);
|
|
|
|
Console.WriteLine(System.Environment.CurrentDirectory + "\\" + JsonParser.systemConfigPath);
|
|
|
|
sc = JsonParser.ReadSystemJsonFile(systemConfigPath);
|
|
|
|
sc = JsonParser.ReadSystemJsonFile(JsonParser.systemConfigPath);
|
|
|
|
int moniTimeInd = sc.proMonitor.ProParams.IndexOf("-btime");
|
|
|
|
int moniTimeInd = sc.proMonitor.ProParams.IndexOf("-btime");
|
|
|
|
string moniTimeStr = sc.proMonitor.ProParams.Substring(moniTimeInd + 7);
|
|
|
|
string moniTimeStr = sc.proMonitor.ProParams.Substring(moniTimeInd + 7);
|
|
|
|
int moniTimeIndEnd = moniTimeStr.IndexOf(">");
|
|
|
|
int moniTimeIndEnd = moniTimeStr.IndexOf(">");
|
|
|
@ -54,30 +54,47 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private DateTime startTime;
|
|
|
|
private DateTime startTime;
|
|
|
|
private DateTime moniStartTime;
|
|
|
|
private DateTime moniStartTime;
|
|
|
|
public DateTime StartTime { get => startTime; set => startTime = value; }
|
|
|
|
public DateTime StartTime { get => startTime; set => SetProperty(ref startTime, value); }
|
|
|
|
public DateTime MoniStartTime { get => moniStartTime; set => moniStartTime = value; }
|
|
|
|
public DateTime MoniStartTime { get => moniStartTime; set => SetProperty(ref moniStartTime, value); }
|
|
|
|
private string runTime;
|
|
|
|
private string runTime;
|
|
|
|
|
|
|
|
|
|
|
|
public string RunTime
|
|
|
|
public string RunTime
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return runTime; }
|
|
|
|
get { return runTime; }
|
|
|
|
set { runTime = value; }
|
|
|
|
set { SetProperty(ref runTime, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string vPNStatus;
|
|
|
|
private string vPNStatus;
|
|
|
|
|
|
|
|
|
|
|
|
public string VPNStatus
|
|
|
|
public string VPNStatus
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return vPNStatus; }
|
|
|
|
get { return vPNStatus; }
|
|
|
|
set { vPNStatus = value; }
|
|
|
|
set { SetProperty(ref vPNStatus, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string vpnIP;
|
|
|
|
private string vpnIP;
|
|
|
|
|
|
|
|
|
|
|
|
public string VpnIP
|
|
|
|
public string VpnIP
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return vpnIP; }
|
|
|
|
get { return vpnIP; }
|
|
|
|
set { vpnIP = value; }
|
|
|
|
set { SetProperty(ref vpnIP, value); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private string vPNStatusForeColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string VPNStatusForeColor
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return vPNStatusForeColor; }
|
|
|
|
|
|
|
|
set { SetProperty(ref vPNStatusForeColor, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool vPNIsConnect;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool VPNIsConnect
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return vPNIsConnect; }
|
|
|
|
|
|
|
|
set { SetProperty(ref vPNIsConnect, value); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<string> reciveDataSource=new ObservableCollection<string>();
|
|
|
|
private ObservableCollection<string> reciveDataSource=new ObservableCollection<string>();
|
|
|
|
|
|
|
|
|
|
|
@ -99,7 +116,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
public int SelectedIndex
|
|
|
|
public int SelectedIndex
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return selectedIndex; }
|
|
|
|
get { return selectedIndex; }
|
|
|
|
set { selectedIndex = value; }
|
|
|
|
set { SetProperty(ref selectedIndex, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool isEnabledStart;
|
|
|
|
private bool isEnabledStart;
|
|
|
@ -107,12 +124,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
public bool IsEnabledStart
|
|
|
|
public bool IsEnabledStart
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return isEnabledStart; }
|
|
|
|
get { return isEnabledStart; }
|
|
|
|
set { isEnabledStart = value; }
|
|
|
|
set { SetProperty(ref isEnabledStart, value); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int proMonInterval = 10;
|
|
|
|
private int proMonInterval = 10;
|
|
|
|
public int ProMonInterval { get => proMonInterval;
|
|
|
|
public int ProMonInterval { get => proMonInterval;
|
|
|
|
set => proMonInterval = value;
|
|
|
|
set => SetProperty(ref proMonInterval, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -144,7 +161,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
KillProcess(sc.proApms);
|
|
|
|
KillProcess(sc.proApms);
|
|
|
|
KillProcess(sc.proMonitor);
|
|
|
|
KillProcess(sc.proMonitor);
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
//switch (kserindex)
|
|
|
|
//switch (kserindex)
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// case -1:
|
|
|
|
// case -1:
|
|
|
@ -179,7 +196,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
|
|
|
|
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN手动连接";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN手动连接";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
SetControlstatus();
|
|
|
|
SetControlstatus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -192,7 +209,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
SetControlstatus();
|
|
|
|
SetControlstatus();
|
|
|
|
Thread.Sleep(100);
|
|
|
|
Thread.Sleep(100);
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN手动断开";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN手动断开";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -268,7 +285,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
// labelStartTime.Text = "启动时间:" + StartTime.ToString();
|
|
|
|
// labelStartTime.Text = "启动时间:" + StartTime.ToString();
|
|
|
|
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
|
|
|
|
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
|
|
|
|
string logStr = StartTime.ToString("s") + "\t服务器程序启动";
|
|
|
|
string logStr = StartTime.ToString("s") + "\t服务器程序启动";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
// progressBar1.Style = ProgressBarStyle.Marquee;
|
|
|
|
// progressBar1.Style = ProgressBarStyle.Marquee;
|
|
|
|
|
|
|
|
|
|
|
|
IsEnabledStart = false;
|
|
|
|
IsEnabledStart = false;
|
|
|
@ -320,7 +337,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
timer1.Stop();
|
|
|
|
timer1.Stop();
|
|
|
|
// progressBar1.Style = ProgressBarStyle.Continuous;
|
|
|
|
// progressBar1.Style = ProgressBarStyle.Continuous;
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序关闭";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序关闭";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
|
|
|
|
|
|
|
// labelStartTime.Text = "启动时间:";
|
|
|
|
// labelStartTime.Text = "启动时间:";
|
|
|
|
StartTime = new DateTime();
|
|
|
|
StartTime = new DateTime();
|
|
|
@ -427,14 +444,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
[DllImport("shell32.dll")]
|
|
|
|
[DllImport("shell32.dll")]
|
|
|
|
public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
|
|
|
|
public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
|
|
|
|
|
|
|
|
|
|
|
|
public string proPath;
|
|
|
|
|
|
|
|
public string zyProPath = @"\serverprogram";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string systemConfigPath = "SystemConfig.json";
|
|
|
|
|
|
|
|
public string systemLogFileName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int showState = 0;
|
|
|
|
|
|
|
|
public string serverVision = "20210629";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public VPNHelper vpn;
|
|
|
|
public VPNHelper vpn;
|
|
|
|
|
|
|
|
|
|
|
@ -449,7 +458,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
public void InitializeParams()
|
|
|
|
public void InitializeParams()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
timer1.Interval = ProMonInterval * 1000;
|
|
|
|
timer1.Interval = ProMonInterval * 1000;
|
|
|
|
this.Message = "服务器版本:" + serverVision;
|
|
|
|
this.Message = "服务器版本:" + JsonParser.serverVision;
|
|
|
|
IntervalTimesSource.Add(5);
|
|
|
|
IntervalTimesSource.Add(5);
|
|
|
|
IntervalTimesSource.Add(10);
|
|
|
|
IntervalTimesSource.Add(10);
|
|
|
|
IntervalTimesSource.Add(15);
|
|
|
|
IntervalTimesSource.Add(15);
|
|
|
@ -457,9 +466,9 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
IntervalTimesSource.Add(30);
|
|
|
|
IntervalTimesSource.Add(30);
|
|
|
|
IntervalTimesSource.Add(60);
|
|
|
|
IntervalTimesSource.Add(60);
|
|
|
|
SelectedIndex = 1;
|
|
|
|
SelectedIndex = 1;
|
|
|
|
systemLogFileName = "SerLog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|
|
|
JsonParser.systemLogFileName = "SerLog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t程序启动";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t程序启动";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
//CheckIp();
|
|
|
|
//CheckIp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#region 方法
|
|
|
|
#region 方法
|
|
|
@ -582,7 +591,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
Thread.Sleep(20);
|
|
|
|
Thread.Sleep(20);
|
|
|
|
ReciveDataSource.Add("服务器程序重启成功");
|
|
|
|
ReciveDataSource.Add("服务器程序重启成功");
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sfp = FindProcess(sc.proRecv);
|
|
|
|
sfp = FindProcess(sc.proRecv);
|
|
|
|
if (sfp == 0)
|
|
|
|
if (sfp == 0)
|
|
|
@ -597,7 +606,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
Thread.Sleep(20);
|
|
|
|
Thread.Sleep(20);
|
|
|
|
ReciveDataSource.Add("接收数据程序重启成功");
|
|
|
|
ReciveDataSource.Add("接收数据程序重启成功");
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sfp = FindProcess(sc.proApms);
|
|
|
|
sfp = FindProcess(sc.proApms);
|
|
|
|
if (sfp == 0)
|
|
|
|
if (sfp == 0)
|
|
|
@ -612,7 +621,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
Thread.Sleep(20);
|
|
|
|
Thread.Sleep(20);
|
|
|
|
ReciveDataSource.Add("自动识别程序重启成功");
|
|
|
|
ReciveDataSource.Add("自动识别程序重启成功");
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sfp = FindProcess(sc.proMonitor);
|
|
|
|
sfp = FindProcess(sc.proMonitor);
|
|
|
|
if (sfp == 0)
|
|
|
|
if (sfp == 0)
|
|
|
@ -627,7 +636,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
Thread.Sleep(20);
|
|
|
|
Thread.Sleep(20);
|
|
|
|
ReciveDataSource.Add("网页服务程序重启成功");
|
|
|
|
ReciveDataSource.Add("网页服务程序重启成功");
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
|
|
|
|
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
|
|
|
|
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
|
|
|
|
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
|
|
|
@ -636,7 +645,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
|
|
|
|
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN断开,重连";
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\tVPN断开,重连";
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + systemLogFileName, logStr);
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void GetLocalIp()
|
|
|
|
public void GetLocalIp()
|
|
|
@ -664,20 +673,24 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
if (vpnStatus)
|
|
|
|
if (vpnStatus)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//gbServerControl.Enabled = true;
|
|
|
|
//gbServerControl.Enabled = true;
|
|
|
|
// buttonConnectVPN.Enabled = false;
|
|
|
|
// buttonConnectVPN.Enabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
// buttonDisconnectVPN.Enabled = true;
|
|
|
|
// buttonDisconnectVPN.Enabled = true;
|
|
|
|
// labelVPNstatus.ForeColor = Color.Blue;
|
|
|
|
// labelVPNstatus.ForeColor = Color.Blue;
|
|
|
|
|
|
|
|
VPNIsConnect = true;
|
|
|
|
|
|
|
|
VPNStatusForeColor = "#FF0000FF";
|
|
|
|
VPNStatus = "VPN已连接";
|
|
|
|
VPNStatus = "VPN已连接";
|
|
|
|
VpnIP = "本机IP:" + vpn.GetLocalIp();
|
|
|
|
VpnIP = vpn.GetLocalIp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// gbServerControl.Enabled = false;
|
|
|
|
// gbServerControl.Enabled = false;
|
|
|
|
// buttonConnectVPN.Enabled = true;
|
|
|
|
// buttonConnectVPN.Enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
// buttonDisconnectVPN.Enabled = false;
|
|
|
|
// buttonDisconnectVPN.Enabled = false;
|
|
|
|
// labelVPNstatus.ForeColor = Color.Red;
|
|
|
|
// labelVPNstatus.ForeColor = Color.Red;
|
|
|
|
|
|
|
|
VPNIsConnect = false;
|
|
|
|
|
|
|
|
VPNStatusForeColor = "#FFFF0000";
|
|
|
|
VPNStatus = "VPN未连接";
|
|
|
|
VPNStatus = "VPN未连接";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|