修改提交数据

master
mzhifa 1 year ago
parent 1e05cacd3a
commit 0e98480a7c

@ -8,6 +8,7 @@
<None Remove="Images\calendar.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="HandyControl" Version="3.4.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="MySql.Data" Version="8.0.33" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

@ -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断开连接";
}
}

@ -19,16 +19,15 @@
</i:Interaction.Triggers>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="350"/>
<ColumnDefinition Width="23*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="52*"/>
<RowDefinition Height="75*"/>
<RowDefinition Height="112*"/>
<RowDefinition Height="30"/>
<RowDefinition Height="150"/>
<RowDefinition Height="150*"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<GroupBox Header="网络控制">
<GroupBox Header="网络控制" Style="{StaticResource GroupBoxOriginal}" BorderThickness="3" Margin="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
@ -39,11 +38,23 @@
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<RadioButton GroupName="con" IsChecked="{Binding VPNIsConnect}" x:Name="rtnConnect" Content="连接" Command="{Binding ConnectVPNCommand}" CommandParameter="{Binding RelativeSource={ RelativeSource Mode=Self},Path=IsChecked}" Grid.Row="0" VerticalAlignment="Center"/>
<RadioButton GroupName="con" Content="断开连接" Grid.Column="1" Command="{Binding DisConnectVPNCommand}" VerticalAlignment="Center" IsChecked="True"/>
<RadioButton GroupName="con" IsChecked="{Binding VPNIsConnect}" x:Name="rtnConnect" Content="连接" Grid.Row="0" VerticalAlignment="Center">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Checked">
<i:InvokeCommandAction Command="{Binding ConnectVPNCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton GroupName="con" Content="断开连接" Grid.Column="1" VerticalAlignment="Center" IsChecked="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Checked">
<i:InvokeCommandAction Command="{Binding DisConnectVPNCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" >
<Button Content="检查状态" Command="{Binding GetVPNStatusCommand}" Margin="5,0,5,0"/>
<TextBlock Text="{Binding VPNStatus}" Foreground="{Binding VPNStatusForeColor}"/>
<TextBlock Text="{Binding VPNStatus}" Foreground="{Binding VPNStatusForeColor}" VerticalAlignment="Center"/>
</StackPanel>
<Button Content="参数设置" Grid.Row="1" Command="{Binding SetVPNParaCommand}" VerticalAlignment="Center"/>
<Button Content="运行日志" Grid.Row="1" Grid.Column="1" Command="{Binding DisplayLogCommand}" VerticalAlignment="Center"/>
@ -53,43 +64,58 @@
</TextBlock>
</Grid>
</GroupBox>
<GroupBox IsEnabled="{Binding ElementName=rtnConnect,Path=IsChecked}" Grid.Row="1" Header="服务器控制">
<Grid>
<GroupBox Header="服务器控制" IsEnabled="{Binding ElementName=rtnConnect,Path=IsChecked}" Style="{StaticResource GroupBoxOriginal}" BorderThickness="3" Margin="1" Grid.Row="1" >
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="30"/>
<RowDefinition Height="100*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Button x:Name="btnStart" Content="一键启动" Command="{Binding OneKeyStartCommand}" IsEnabled="{Binding IsEnabledStart}" Grid.Column="0" VerticalAlignment="Center"/>
<Button Content="全部关闭" Command="{Binding OneKeyStopCommand}" Grid.Column="1" VerticalAlignment="Center"/>
<RadioButton GroupName="start" Content="一键启动" Grid.Column="0" VerticalAlignment="Center">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Checked">
<i:InvokeCommandAction Command="{Binding OneKeyStartCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton GroupName="start" Content="全部关闭" IsChecked="True" Grid.Column="1" VerticalAlignment="Center">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Checked">
<i:InvokeCommandAction Command="{Binding OneKeyStopCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<Button Content="实时波形" Command="{Binding DisplayRealWavesCommand}" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" Grid.ColumnSpan="2">
<TextBlock Grid.Row="1" VerticalAlignment="Center" Grid.ColumnSpan="3">
<Run Text="启动时间:"/>
<Run Text="{Binding StartTime}"/>
<Run Text="{Binding StartTime,StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</TextBlock>
<TextBlock Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Center">
<TextBlock Grid.Row="2" Grid.ColumnSpan="3" VerticalAlignment="Center">
<Run Text="运行时间:"/>
<Run Text="{Binding RunTime}"/>
<Run Text="{Binding RunTime,StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</TextBlock>
<DockPanel Grid.Row="2" Grid.Column="2" >
<ComboBox DockPanel.Dock="Right" ItemsSource="{Binding IntervalTimesSource}" SelectedIndex="{Binding selectedIndex}" Text="{Binding ProMonInterval}" VerticalAlignment="Center"/>
<TextBlock Text="监隔间隔(s):" DockPanel.Dock="Right" VerticalAlignment="Center"/>
</DockPanel>
<ListBox Grid.Row="3" Grid.ColumnSpan="3" ItemsSource="{Binding ReciveDataSource}">
</ListBox>
<ProgressBar Grid.Row="4" Grid.ColumnSpan="3" VerticalAlignment="Bottom" IsIndeterminate="{Binding IsIndeterminate}" Foreground="Green" Value="0"/>
</Grid>
</GroupBox>
<ListBox Grid.Row="2" ItemsSource="{Binding ReciveDataSource}">
</ListBox>
<ProgressBar Grid.Row="3"/>
<DataGrid Grid.Column="1" Grid.RowSpan="3" ItemsSource="{Binding DataGridSource}">
<DataGrid Grid.Column="1" Grid.RowSpan="2" ItemsSource="{Binding DataGridSource}">
</DataGrid>
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Bottom" IsEnabled="False">
<Button Content="查询" Command="{Binding QueryDataCommand}"/>
<Button Content="新增" Command="{Binding InsertDataCommand}"/>
</StackPanel>
<!--<TextBlock Grid.Row="2" Text="Version 2023.05.17" Margin="10,0,0,0"/>-->
</Grid>
</UserControl>

@ -4,6 +4,11 @@
xmlns:local="clr-namespace:StartServerWPF"
xmlns:prism="http://prismlibrary.com/" >
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</prism:PrismApplication>

Loading…
Cancel
Save