|
|
|
@ -15,6 +15,9 @@ using System.Windows.Controls;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using StartServerWPF.Modules.Main.Model;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Timers;
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
|
|
|
|
|
namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
{
|
|
|
|
@ -94,8 +97,13 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
set { SetProperty(ref vPNIsConnect, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isIndeterminate=false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsIndeterminate
|
|
|
|
|
{
|
|
|
|
|
get { return isIndeterminate; }
|
|
|
|
|
set { SetProperty(ref isIndeterminate, value); }
|
|
|
|
|
}
|
|
|
|
|
private ObservableCollection<string> reciveDataSource=new ObservableCollection<string>();
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<string> ReciveDataSource
|
|
|
|
@ -119,14 +127,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
set { SetProperty(ref selectedIndex, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isEnabledStart;
|
|
|
|
|
|
|
|
|
|
public bool IsEnabledStart
|
|
|
|
|
{
|
|
|
|
|
get { return isEnabledStart; }
|
|
|
|
|
set { SetProperty(ref isEnabledStart, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int proMonInterval = 10;
|
|
|
|
|
public int ProMonInterval { get => proMonInterval;
|
|
|
|
|
set => SetProperty(ref proMonInterval, value);
|
|
|
|
@ -192,6 +192,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
@ -221,7 +222,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("VPN未连接!");
|
|
|
|
|
MessageBox.Show("VPN断开连接!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -233,7 +234,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
|
|
|
|
|
DialogParameters param = new DialogParameters();
|
|
|
|
|
param.Add("type", 1);// 编辑
|
|
|
|
|
param.Add("model", sc.vpnInfo);
|
|
|
|
|
param.Add("model", sc);
|
|
|
|
|
param.Add("moniTime", MoniStartTime);
|
|
|
|
|
|
|
|
|
|
_dialogService.ShowDialog(
|
|
|
|
@ -283,15 +284,14 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10);
|
|
|
|
|
// labelStartTime.Text = "启动时间:" + StartTime.ToString();
|
|
|
|
|
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
|
|
|
|
|
RunTime = DateDiff(DateTime.Now, StartTime);
|
|
|
|
|
string logStr = StartTime.ToString("s") + "\t服务器程序启动";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
// progressBar1.Style = ProgressBarStyle.Marquee;
|
|
|
|
|
|
|
|
|
|
IsEnabledStart = false;
|
|
|
|
|
IsIndeterminate =true;
|
|
|
|
|
// btnSetParams.Enabled = false;
|
|
|
|
|
timer1.Interval = ProMonInterval * 1000;
|
|
|
|
|
timer1.Interval = TimeSpan.FromSeconds(ProMonInterval);
|
|
|
|
|
timer1.Start();
|
|
|
|
|
timer1.Tick += timer1_Tick;
|
|
|
|
|
ReciveDataSource.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -335,14 +335,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
}
|
|
|
|
|
ReciveDataSource.Add("服务停止于:" + DateTime.Now.ToString());
|
|
|
|
|
timer1.Stop();
|
|
|
|
|
// progressBar1.Style = ProgressBarStyle.Continuous;
|
|
|
|
|
IsIndeterminate = false;
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t服务器程序关闭";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
|
|
|
|
|
// labelStartTime.Text = "启动时间:";
|
|
|
|
|
StartTime = new DateTime();
|
|
|
|
|
RunTime = "运行时间:";
|
|
|
|
|
isEnabledStart = true;
|
|
|
|
|
// buttonOneKeyStart.Enabled = true;
|
|
|
|
|
// btnSetParams.Enabled = true;
|
|
|
|
|
}
|
|
|
|
@ -452,12 +450,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
|
|
|
|
|
MySqlHelper remDb;
|
|
|
|
|
|
|
|
|
|
private System.Timers.Timer timer1=new System.Timers.Timer();
|
|
|
|
|
private DispatcherTimer timer1= new DispatcherTimer();
|
|
|
|
|
private readonly IDialogService _dialogService;
|
|
|
|
|
|
|
|
|
|
public void InitializeParams()
|
|
|
|
|
{
|
|
|
|
|
timer1.Interval = ProMonInterval * 1000;
|
|
|
|
|
timer1.Interval = TimeSpan.FromSeconds(ProMonInterval);
|
|
|
|
|
this.Message = "服务器版本:" + JsonParser.serverVision;
|
|
|
|
|
IntervalTimesSource.Add(5);
|
|
|
|
|
IntervalTimesSource.Add(10);
|
|
|
|
@ -574,7 +572,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
|
|
|
private void timer1_Tick(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ReciveDataSource.Clear();
|
|
|
|
|
ReciveDataSource.Add(DateTime.Now.ToString());
|
|
|
|
@ -638,7 +636,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
|
|
|
|
|
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
|
|
|
|
|
}
|
|
|
|
|
RunTime = "运行时间:" + DateDiff(DateTime.Now, StartTime);
|
|
|
|
|
RunTime = DateDiff(DateTime.Now, StartTime);
|
|
|
|
|
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
|
|
|
|
|
if (!vpnStatus)
|
|
|
|
|
{
|
|
|
|
@ -678,7 +676,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
// buttonDisconnectVPN.Enabled = true;
|
|
|
|
|
// labelVPNstatus.ForeColor = Color.Blue;
|
|
|
|
|
VPNIsConnect = true;
|
|
|
|
|
VPNStatusForeColor = "#FF0000FF";
|
|
|
|
|
|
|
|
|
|
VPNStatusForeColor = "#FF008000";
|
|
|
|
|
VPNStatus = "VPN已连接";
|
|
|
|
|
VpnIP = vpn.GetLocalIp();
|
|
|
|
|
}
|
|
|
|
@ -691,7 +690,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
|
// labelVPNstatus.ForeColor = Color.Red;
|
|
|
|
|
VPNIsConnect = false;
|
|
|
|
|
VPNStatusForeColor = "#FFFF0000";
|
|
|
|
|
VPNStatus = "VPN未连接";
|
|
|
|
|
VPNStatus = "VPN断开连接";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|