修改配置测试问题;

master
mzhifa 9 months ago
parent a7075d8608
commit b3180885ad

@ -130,19 +130,68 @@ namespace StartServerWPF.Modules.Main.ViewModels
set { SetProperty(ref _moniTime, value); } set { SetProperty(ref _moniTime, value); }
} }
public DelegateCommand FilePathSaveCommand=> new(()=> public DelegateCommand<object> SelectFileCommand => new((obj) =>
{ {
updateJson = false;
string para = obj.ToString();
System.Windows.Forms.OpenFileDialog fbd = new System.Windows.Forms.OpenFileDialog();
fbd.Multiselect = false;
if (para.Contains("apms"))
{
fbd.InitialDirectory = Path.GetFullPath(_systemConfig.proApms.ProPath);
}
else
{
fbd.InitialDirectory = Path.GetFullPath(_systemConfig.proTools.ProPath);
}
if (fbd.ShowDialog()== System.Windows.Forms.DialogResult.OK)
{
switch (para)
{
case "apmsStation":
AModel.station = fbd.SafeFileName;
break;
case "apmsttime2d":
AModel.ttime[0].ttime2d = fbd.SafeFileName;
break;
case "toolsStation":
ToolsModel.station = fbd.SafeFileName;
break;
case "toolsttime2d":
ToolsModel.ttime[0].ttime2d = fbd.SafeFileName;
break;
default:
break;
}
}
});
public DelegateCommand<object> FilePathSaveCommand=> new((obj)=>
{
string para= obj.ToString();
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.SelectedPath = MainModel.DataSavePath; fbd.SelectedPath = MainModel.DataSavePath;
fbd.ShowNewFolderButton = true; fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{ {
MainModel.DataSavePath = fbd.SelectedPath; if (para == "systemSavepath")
if (MainModel.DataSavePath != _systemConfig.vpnInfo.DataSavePath) {
MainModel.DataSavePath = fbd.SelectedPath;
}
else if(para == "apmssavepath")
{
AModel.savepath = fbd.SelectedPath;
}
else if(para == "toolssavepath")
{ {
updateJson = true; ToolsModel.savepath = fbd.SelectedPath;
} }
} }
}); });
public DelegateCommand LogPathSaveCommand=> new(() => public DelegateCommand LogPathSaveCommand=> new(() =>
@ -156,7 +205,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
MainModel.SystemLogPath = fbd.SelectedPath; MainModel.SystemLogPath = fbd.SelectedPath;
} }
}); });
bool updateJson = false;
public ICommand ConfirmCommand public ICommand ConfirmCommand
{ {
@ -173,7 +221,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
{ {
AModel.channels[0].station = string.Join(",", ApmsStationSource.Where(p => p.Enable).Select(a => a.Num)); AModel.channels[0].station = string.Join(",", ApmsStationSource.Where(p => p.Enable).Select(a => a.Num));
if(_systemConfig.proApms.JsonPath != ApmsJsonName) if (_systemConfig.proApms.JsonPath != ApmsJsonName)
{ {
_systemConfig.proApms.ProParams = _systemConfig.proApms.ProParams.Replace(_systemConfig.proApms.JsonPath, ApmsJsonName); _systemConfig.proApms.ProParams = _systemConfig.proApms.ProParams.Replace(_systemConfig.proApms.JsonPath, ApmsJsonName);
_systemConfig.proApms.JsonPath = ApmsJsonName; _systemConfig.proApms.JsonPath = ApmsJsonName;
@ -186,22 +234,22 @@ namespace StartServerWPF.Modules.Main.ViewModels
_systemConfig.proTools.ProParams = _systemConfig.proTools.ProParams.Replace(_systemConfig.proTools.JsonPath, ToolsJsonName); _systemConfig.proTools.ProParams = _systemConfig.proTools.ProParams.Replace(_systemConfig.proTools.JsonPath, ToolsJsonName);
_systemConfig.proTools.JsonPath = ToolsJsonName; _systemConfig.proTools.JsonPath = ToolsJsonName;
} }
if (_systemConfig.vpnInfo.DataSavePath != ToolsModel.savepath) //if (_systemConfig.vpnInfo.DataSavePath != ToolsModel.savepath)
{ //{
_systemConfig.proTools.ProParams= _systemConfig.proTools.ProParams.Replace(_systemConfig.vpnInfo.DataSavePath, ToolsModel.savepath); // _systemConfig.vpnInfo.DataSavePath = ToolsModel.savepath;
_systemConfig.vpnInfo.DataSavePath = ToolsModel.savepath; //}
}
JsonParser.WriteSystemConfigFile(_systemConfig.proTools.ProPath + ToolsJsonName, ToolsModel); JsonParser.WriteSystemConfigFile(_systemConfig.proTools.ProPath + ToolsJsonName, ToolsModel);
int index = _systemConfig.proTools.ProParams.IndexOf("-delay");
_systemConfig.proTools.ProParams= $"{_systemConfig.proTools.ProParams.Substring(0, index)} -delay {DelayTime*60}"; int index= _systemConfig.proTools.ProParams.IndexOf("-savepath");
// int index = _systemConfig.proTools.ProParams.IndexOf("-delay");
string st= _systemConfig.proTools.ProParams.Substring(0, index);
_systemConfig.proTools.ProParams = $"{_systemConfig.proTools.ProParams.Substring(0, index)}{ToolsModel.savepath} -delay {DelayTime * 60}";
JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig); JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig);
if (updateJson)
{ JsonParser.UpdateRecvJson(_systemConfig.proRecv.ProPath + _systemConfig.proRecv.JsonPath, _systemConfig.vpnInfo.DataSavePath);
JsonParser.UpdateRecvJson(_systemConfig.proRecv.ProPath + _systemConfig.proRecv.JsonPath, _systemConfig.vpnInfo.DataSavePath); //JsonParser.UpdateApmsJson(_systemConfig.proApms.ProPath + _systemConfig.proApms.JsonPath, _systemConfig.vpnInfo.DataSavePath);
//JsonParser.UpdateApmsJson(_systemConfig.proApms.ProPath + _systemConfig.proApms.JsonPath, _systemConfig.vpnInfo.DataSavePath); // RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
// RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
} }
}); });
} }

@ -45,17 +45,17 @@
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="station:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="station:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding }"/> <Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="apmsStation" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding AModel.station}"/> <TextBox DockPanel.Dock="Left" Text="{Binding AModel.station}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="ttime2d:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="ttime2d:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding }"/> <Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="apmsttime2d" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding AModel.ttime[0].ttime2d}"/> <TextBox DockPanel.Dock="Left" Text="{Binding AModel.ttime[0].ttime2d}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="savepath:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="savepath:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding }"/> <Button Content="..." DockPanel.Dock="Right" Command="{Binding FilePathSaveCommand}" CommandParameter="apmssavepath" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding AModel.savepath}"/> <TextBox DockPanel.Dock="Left" Text="{Binding AModel.savepath}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center" > <DockPanel VerticalAlignment="Center" >
@ -139,17 +139,17 @@
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="station:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="station:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding }"/> <Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="toolsStation" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding ToolsModel.station}"/> <TextBox DockPanel.Dock="Left" Text="{Binding ToolsModel.station}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="ttime2d:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="ttime2d:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding }"/> <Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="toolsttime2d" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding ToolsModel.ttime[0].ttime2d}"/> <TextBox DockPanel.Dock="Left" Text="{Binding ToolsModel.ttime[0].ttime2d}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="savepath:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="savepath:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding }"/> <Button Content="..." DockPanel.Dock="Right" Command="{Binding FilePathSaveCommand}" CommandParameter="toolssavepath" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding ToolsModel.savepath}"/> <TextBox DockPanel.Dock="Left" Text="{Binding ToolsModel.savepath}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center" > <DockPanel VerticalAlignment="Center" >
@ -253,10 +253,10 @@
<TextBlock Text="存储路径:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"/> <TextBlock Text="存储路径:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"/>
<TextBox Text="{Binding MainModel.DataSavePath}" IsReadOnly="True" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"/> <TextBox Text="{Binding MainModel.DataSavePath}" IsReadOnly="True" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"/>
<Button Content="..." Command="{Binding FilePathSaveCommand}" Grid.Row="5" Grid.Column="2"/> <Button Content="..." Command="{Binding FilePathSaveCommand}" CommandParameter="systemSavepath" Grid.Row="5" Grid.Column="2" Background="#FF0ABEFF"/>
<TextBlock Text="日志路径:" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" /> <TextBlock Text="日志路径:" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center" />
<TextBox Text="{Binding MainModel.SystemLogPath}" IsReadOnly="True" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" /> <TextBox Text="{Binding MainModel.SystemLogPath}" IsReadOnly="True" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" />
<Button Content="..." Command="{Binding LogPathSaveCommand}" Grid.Row="6" Grid.Column="2"/> <Button Content="..." Command="{Binding LogPathSaveCommand}" Grid.Row="6" Grid.Column="2" Background="#FF0ABEFF"/>
</Grid> </Grid>
</Border> </Border>
<StackPanel Grid.Row="3" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" Visibility="Collapsed"> <StackPanel Grid.Row="3" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" Visibility="Collapsed">

Loading…
Cancel
Save