|
|
@ -16,29 +16,32 @@ using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
using System.Windows.Media.Animation;
|
|
|
|
|
|
|
|
|
|
|
|
namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class SetParamViewModel : BindableBase
|
|
|
|
public class SetParamViewModel : BindableBase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public SetParamViewModel(SystemConfigModel configModel, WorkareaModelArray workareaModelArray)
|
|
|
|
public SetParamViewModel(IDialogService dialogService, SystemConfigModel configModel,
|
|
|
|
|
|
|
|
WorkareaModel workareaModel, WorkareasModelArray workareasModelArray)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
this._dialogService = dialogService;
|
|
|
|
_systemConfig = configModel;
|
|
|
|
_systemConfig = configModel;
|
|
|
|
this._workareaModelArray = workareaModelArray;
|
|
|
|
WareaModel = workareaModel;
|
|
|
|
|
|
|
|
this._workareasModelArray = workareasModelArray;
|
|
|
|
MainModel = _systemConfig.vpnInfo;
|
|
|
|
MainModel = _systemConfig.vpnInfo;
|
|
|
|
WorkareaNameSource = new ObservableCollection<string>();
|
|
|
|
WorkareaNameSource = new ObservableCollection<string>();
|
|
|
|
_workareaModelArray.workarea.Select(n=>n.workareaname).ToList().ForEach(a=> WorkareaNameSource.Add(a));
|
|
|
|
_workareasModelArray.workarea.Select(n=>n.workareaname).ToList().ForEach(a=> WorkareaNameSource.Add(a));
|
|
|
|
|
|
|
|
WareaSelectedIndex = _workareasModelArray.selectIndex;
|
|
|
|
WareaSelectedIndex = _workareaModelArray.selectIndex;
|
|
|
|
|
|
|
|
WareaModel = _workareaModelArray.workarea[WareaSelectedIndex];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string _title = "应用列表";
|
|
|
|
private string _title = "应用列表";
|
|
|
|
public string Title => _title;
|
|
|
|
public string Title => _title;
|
|
|
|
|
|
|
|
|
|
|
|
string apmStationFile = string.Empty;
|
|
|
|
string apmStationFile = string.Empty;
|
|
|
|
string apmttime2dFile = string.Empty;
|
|
|
|
string apmttime2dFile = string.Empty;
|
|
|
|
|
|
|
|
private readonly IDialogService _dialogService;
|
|
|
|
private SystemConfigModel _systemConfig;
|
|
|
|
private SystemConfigModel _systemConfig;
|
|
|
|
private readonly WorkareaModelArray _workareaModelArray;
|
|
|
|
private readonly WorkareasModelArray _workareasModelArray;
|
|
|
|
private ObservableCollection<string> _workareaNameSource;
|
|
|
|
private ObservableCollection<string> _workareaNameSource;
|
|
|
|
public ObservableCollection<string> WorkareaNameSource
|
|
|
|
public ObservableCollection<string> WorkareaNameSource
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -53,7 +56,16 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
set {
|
|
|
|
set {
|
|
|
|
if (value >= 0)
|
|
|
|
if (value >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WareaModel = _workareaModelArray.workarea[value];
|
|
|
|
string file = Path.Combine(_workareasModelArray.workarea[value].filepath, "workarea.json");
|
|
|
|
|
|
|
|
if (!File.Exists(file))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
JsonParser.WriteSystemConfigFile(file, WareaModel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string json = File.ReadAllText(file);
|
|
|
|
|
|
|
|
WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(json);
|
|
|
|
|
|
|
|
WareaModel.apmModel.station = string.Empty;
|
|
|
|
|
|
|
|
WareaModel.apmModel.ttime[0].ttime2d = string.Empty;
|
|
|
|
|
|
|
|
_workareasModelArray.selectIndex = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetProperty(ref _wareaSelectedIndex, value);
|
|
|
|
SetProperty(ref _wareaSelectedIndex, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -84,26 +96,27 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
apmttime2dFile = string.Empty;
|
|
|
|
apmttime2dFile = string.Empty;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand AddItemCommand => new(() =>
|
|
|
|
public DelegateCommand AddItemCommand => new(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string strJson= JsonConvert.SerializeObject(WareaModel, Formatting.Indented);
|
|
|
|
|
|
|
|
WorkareaModel workarea = JsonConvert.DeserializeObject<WorkareaModel>(strJson);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workarea.workareaname = AddWorkareaName;
|
|
|
|
|
|
|
|
var mod = _workareaModelArray.workarea.Where(w => w.workareaname == _addWorkareaName).FirstOrDefault();
|
|
|
|
|
|
|
|
if (mod != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MessageBox.Show($"名称:{AddWorkareaName}已存在");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
workarea.chartsavepath = "EVT2014";
|
|
|
|
|
|
|
|
workarea.apmsavepath = "NET2014";
|
|
|
|
|
|
|
|
workarea.toolsavepath = "post";
|
|
|
|
|
|
|
|
workarea.StationConfig.Stations.ForEach(w => { w.IsEnable= true; });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_workareaModelArray.workarea.Add(workarea);
|
|
|
|
DialogParameters param = new DialogParameters();
|
|
|
|
WorkareaNameSource.Add(AddWorkareaName);
|
|
|
|
// param.Add("type", 1);// 编辑
|
|
|
|
|
|
|
|
_dialogService.ShowDialog("AddWorkAreaDialog",
|
|
|
|
|
|
|
|
param,
|
|
|
|
|
|
|
|
new Action<IDialogResult>(result =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (result != null && result.Result == ButtonResult.OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var area = result.Parameters.GetValue<Workareas>("param1");
|
|
|
|
|
|
|
|
WareaModel.savepath = area.filepath;
|
|
|
|
|
|
|
|
var file = _workareasModelArray.workarea.Where(f => f.filepath == area.filepath).FirstOrDefault();
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_workareasModelArray.workarea.Add(area);
|
|
|
|
|
|
|
|
WorkareaNameSource.Add(area.workareaname);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
public DelegateCommand<object> SelectFileCommand => new((obj) =>
|
|
|
|
public DelegateCommand<object> SelectFileCommand => new((obj) =>
|
|
|
@ -117,7 +130,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
switch (para)
|
|
|
|
switch (para)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case "apmsStation":
|
|
|
|
case "apmsStation":
|
|
|
|
WareaModel.apmModel.savepath = fbd.SafeFileName;
|
|
|
|
WareaModel.apmModel.station = fbd.SafeFileName;
|
|
|
|
apmStationFile = fbd.FileName;
|
|
|
|
apmStationFile = fbd.FileName;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "apmsttime2d":
|
|
|
|
case "apmsttime2d":
|
|
|
@ -162,18 +175,21 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
get => new DelegateCommand(() =>
|
|
|
|
get => new DelegateCommand(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 数据校验(关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查(自定义特性检查)
|
|
|
|
// 数据校验(关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查(自定义特性检查)
|
|
|
|
if (string.IsNullOrEmpty(MainModel.VpnName) || string.IsNullOrEmpty(MainModel.VpnIP))
|
|
|
|
if (string.IsNullOrEmpty(WareaModel.savepath)
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(WareaModel.apmModel.station)
|
|
|
|
|
|
|
|
|| string.IsNullOrEmpty(WareaModel.apmModel.ttime[0].ttime2d))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MessageBox.Show("内容不能为空", "提示", MessageBoxButton.OK);
|
|
|
|
MessageBox.Show("目录内容不能为空", "提示", MessageBoxButton.OK);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
|
|
|
|
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//1 Workarea配置更新
|
|
|
|
|
|
|
|
string wmJson = JsonConvert.SerializeObject(_workareaModelArray, Formatting.Indented);
|
|
|
|
//1 Workarea配置更新,选择的索引
|
|
|
|
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray);
|
|
|
|
_wareaModel.apmModel.channels = new List<StationChannelsModel>
|
|
|
|
_wareaModel.apmModel.channels = new List<StationChannelsModel>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new StationChannelsModel()
|
|
|
|
new StationChannelsModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
location = _wareaModel.StationConfig.Location,
|
|
|
|
location = _wareaModel.StationConfig.Location,
|
|
|
@ -181,49 +197,65 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
channels = _wareaModel.StationConfig.Channels,
|
|
|
|
channels = _wareaModel.StationConfig.Channels,
|
|
|
|
station = string.Join(",", _wareaModel.StationConfig.Stations.Where(p => p.IsEnable).Select(n => n.Name))
|
|
|
|
station = string.Join(",", _wareaModel.StationConfig.Stations.Where(p => p.IsEnable).Select(n => n.Name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
File.WriteAllText(Path.Combine(JsonParser.workareaPath, "Workarea.json"), wmJson);
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, "Workarea.json"), _wareaModel);
|
|
|
|
|
|
|
|
string wareaJson = JsonConvert.SerializeObject(_wareaModel);
|
|
|
|
|
|
|
|
var curWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(wareaJson);
|
|
|
|
if (!string.IsNullOrEmpty(apmStationFile))
|
|
|
|
if (!string.IsNullOrEmpty(apmStationFile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string destFileName = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.savepath));
|
|
|
|
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station));
|
|
|
|
File.Copy(apmStationFile, destFileName, true);
|
|
|
|
if (destFileName != apmStationFile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
File.Copy(apmStationFile, destFileName, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
apmStationFile = null;
|
|
|
|
apmStationFile = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!string.IsNullOrEmpty(apmttime2dFile))
|
|
|
|
if(!string.IsNullOrEmpty(apmttime2dFile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string destFileName = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.ttime[0].ttime2d));
|
|
|
|
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d));
|
|
|
|
File.Copy(apmttime2dFile, destFileName, true);
|
|
|
|
if (destFileName != apmttime2dFile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
File.Copy(apmttime2dFile, destFileName, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
apmttime2dFile = null;
|
|
|
|
apmttime2dFile = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//2 gw.apms.exe配置更新
|
|
|
|
//2 gw.apms.exe配置更新
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ApmsModel apms = _wareaModel.apmModel;
|
|
|
|
ApmsModel apms = curWorkarea.apmModel;
|
|
|
|
apms.station = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.station)).Replace("\\","/");
|
|
|
|
apms.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
|
|
|
|
apms.ttime[0].ttime2d= Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); ;
|
|
|
|
apms.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
|
|
|
|
apms.savepath = _wareaModel.savepath + "/" + _wareaModel.apmsavepath;
|
|
|
|
apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath);
|
|
|
|
apms.push2wx = _wareaModel.apmpush2wx ? "YES" : "NO";
|
|
|
|
apms.push2wx = curWorkarea.apmpush2wx ? "YES" : "NO";
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proApms.ProPath, "apms.json"), apms);
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proApms.ProPath, "apms.json"), apms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//3 gw.tools.exe配置更新
|
|
|
|
//3 gw.tools.exe配置更新
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ApmsModel tools = _wareaModel.apmModel;
|
|
|
|
ApmsModel tools = curWorkarea.apmModel;
|
|
|
|
tools.station = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.station)).Replace("\\", "/");
|
|
|
|
tools.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
|
|
|
|
tools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); ;
|
|
|
|
tools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
|
|
|
|
tools.savepath = _wareaModel.savepath+"/"+ _wareaModel.toolsavepath;
|
|
|
|
tools.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.toolsavepath);
|
|
|
|
tools.push2wx = _wareaModel.toolpush2wx ? "YES" : "NO"; ;
|
|
|
|
tools.push2wx = curWorkarea.toolpush2wx ? "YES" : "NO"; ;
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proTools.ProPath, "apms.json"), tools);
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proTools.ProPath, "apms.json"), tools);
|
|
|
|
|
|
|
|
|
|
|
|
//4 SystemConfig.json配置更新
|
|
|
|
//4 SystemConfig.json配置更新
|
|
|
|
int index = _systemConfig.proTools.ProParams.IndexOf("-savepath");
|
|
|
|
int index = _systemConfig.proTools.ProParams.IndexOf("-savepath");
|
|
|
|
string str = _systemConfig.proTools.ProParams.Substring(0, index) + "-savepath";
|
|
|
|
string str = _systemConfig.proTools.ProParams.Substring(0, index) + "-savepath";
|
|
|
|
_systemConfig.proTools.ProParams = $"{str} {tools.savepath} -delay {_wareaModel.delayTime * 60}";
|
|
|
|
_systemConfig.proTools.ProParams = $"{str} {tools.savepath} -delay {curWorkarea.delayTime * 60}";
|
|
|
|
JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig);
|
|
|
|
JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//dataProTools配置更新
|
|
|
|
|
|
|
|
ApmsModel protools = curWorkarea.apmModel;
|
|
|
|
|
|
|
|
// tools.savepath = SavePath; // _workareaModel.savepath + "/" +SavePath;;
|
|
|
|
|
|
|
|
protools.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
|
|
|
|
|
|
|
|
protools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
|
|
|
|
|
|
|
|
// protools.push2wx = _workareaModel.toolpush2wx ? "YES" : "NO";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.dataProTools.ProPath, "apms.json"), protools);
|
|
|
|
|
|
|
|
|
|
|
|
//5 gw.recvftp.exe配置更新
|
|
|
|
//5 gw.recvftp.exe配置更新
|
|
|
|
JsonParser.UpdateRecvJson(Path.Combine(_systemConfig.proRecv.ProPath, _systemConfig.proRecv.JsonPath), _wareaModel.savepath + "/" + _wareaModel.chartsavepath);
|
|
|
|
JsonParser.UpdateRecvJson(Path.Combine(_systemConfig.proRecv.ProPath, _systemConfig.proRecv.JsonPath), Path.Combine(curWorkarea.savepath, curWorkarea.chartsavepath).Replace("\\", "/"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|