|
|
@ -10,6 +10,7 @@ using StartServerWPF.Modules.Main.Models;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
|
|
using System.Diagnostics.Metrics;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
using System.Runtime.Serialization;
|
|
|
@ -33,8 +34,9 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
wareaModelSingleton = workareaModel;
|
|
|
|
wareaModelSingleton = workareaModel;
|
|
|
|
this._workareasModelArray = workareasModelArray;
|
|
|
|
this._workareasModelArray = workareasModelArray;
|
|
|
|
MainModel = _systemConfig.vpnInfo;
|
|
|
|
MainModel = _systemConfig.vpnInfo;
|
|
|
|
WorkareaNameSource = new ObservableCollection<string>();
|
|
|
|
WorkareaNameSource = new ObservableCollection<Workareas>();
|
|
|
|
_workareasModelArray.workarea.Select(n=>n.workareaname).ToList().ForEach(a=> WorkareaNameSource.Add(a));
|
|
|
|
|
|
|
|
|
|
|
|
_workareasModelArray.workarea.ForEach(a => WorkareaNameSource.Add(a));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string _title = "应用列表";
|
|
|
|
private string _title = "应用列表";
|
|
|
|
public string Title => _title;
|
|
|
|
public string Title => _title;
|
|
|
@ -44,8 +46,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
private readonly IDialogService _dialogService;
|
|
|
|
private readonly IDialogService _dialogService;
|
|
|
|
private SystemConfigModel _systemConfig;
|
|
|
|
private SystemConfigModel _systemConfig;
|
|
|
|
private WorkareasModelArray _workareasModelArray;
|
|
|
|
private WorkareasModelArray _workareasModelArray;
|
|
|
|
private ObservableCollection<string> _workareaNameSource;
|
|
|
|
private ObservableCollection<Workareas> _workareaNameSource;
|
|
|
|
public ObservableCollection<string> WorkareaNameSource
|
|
|
|
public ObservableCollection<Workareas> WorkareaNameSource
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get => _workareaNameSource;
|
|
|
|
get => _workareaNameSource;
|
|
|
|
set { SetProperty(ref _workareaNameSource, value); }
|
|
|
|
set { SetProperty(ref _workareaNameSource, value); }
|
|
|
@ -75,8 +77,10 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
WareaModel.savepath = path;
|
|
|
|
WareaModel.savepath = path;
|
|
|
|
string file = Path.Combine(path, Path.GetFileName(path) + ".json");
|
|
|
|
string file = Path.Combine(path, Path.GetFileName(path) + ".json");
|
|
|
|
WareaModel.workareaname = Path.GetFileName(WareaModel.savepath);
|
|
|
|
WareaModel.workareaname = Path.GetFileName(WareaModel.savepath);
|
|
|
|
|
|
|
|
if (File.Exists(file))
|
|
|
|
|
|
|
|
{
|
|
|
|
File.WriteAllText(file, JsonConvert.SerializeObject(WareaModel));
|
|
|
|
File.WriteAllText(file, JsonConvert.SerializeObject(WareaModel));
|
|
|
|
|
|
|
|
}
|
|
|
|
//MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
|
|
|
|
//MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -122,12 +126,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
if (result != null && result.Result == ButtonResult.OK)
|
|
|
|
if (result != null && result.Result == ButtonResult.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var area = result.Parameters.GetValue<Workareas>("param1");
|
|
|
|
var area = result.Parameters.GetValue<Workareas>("param1");
|
|
|
|
var file = _workareasModelArray.workarea.Where(f => f.workareaname == area.workareaname).FirstOrDefault();
|
|
|
|
var file = WorkareaNameSource.Where(f => f.workareaname == area.workareaname).FirstOrDefault();
|
|
|
|
if (file == null)
|
|
|
|
if (file == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_workareasModelArray.workarea.Add(area);
|
|
|
|
// _workareasModelArray.workarea.Add(area);
|
|
|
|
WorkareaNameSource.Add(area.workareaname);
|
|
|
|
WorkareaNameSource.Add(area);
|
|
|
|
WareaSelectedIndex= WorkareaNameSource.Count()-1;
|
|
|
|
WareaSelectedIndex = WorkareaNameSource.Count()-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -149,17 +153,17 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string jsonStr = File.ReadAllText(fbd.FileName);
|
|
|
|
string jsonStr = File.ReadAllText(fbd.FileName);
|
|
|
|
_workareasModelArray = JsonConvert.DeserializeObject<WorkareasModelArray>(jsonStr);
|
|
|
|
var _workareasArray = JsonConvert.DeserializeObject<WorkareasModelArray>(jsonStr);
|
|
|
|
WorkareaNameSource = new ObservableCollection<string>();
|
|
|
|
WorkareaNameSource = new ObservableCollection<Workareas>();
|
|
|
|
_workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
|
|
|
|
_workareasArray.workarea.ForEach(a => WorkareaNameSource.Add(a));
|
|
|
|
WareaSelectedIndex = _workareasModelArray.selectIndex;
|
|
|
|
WareaSelectedIndex = _workareasArray.selectIndex;
|
|
|
|
var item = _workareasModelArray.workarea[_workareasModelArray.selectIndex];
|
|
|
|
|
|
|
|
|
|
|
|
var item = _workareasArray.workarea[_workareasArray.selectIndex];
|
|
|
|
string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath) + ".json");
|
|
|
|
string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath) + ".json");
|
|
|
|
var currentWorkarea = new WorkareaModel();
|
|
|
|
|
|
|
|
if (File.Exists(areaPath))
|
|
|
|
if (File.Exists(areaPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string workarea = File.ReadAllText(areaPath);
|
|
|
|
string workarea = File.ReadAllText(areaPath);
|
|
|
|
currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
|
|
|
|
var currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
|
|
|
|
if (currentWorkarea.StationConfig.Stations == null)
|
|
|
|
if (currentWorkarea.StationConfig.Stations == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location)
|
|
|
|
currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location)
|
|
|
@ -174,7 +178,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("导入工区失败," + ex);
|
|
|
|
MessageBox.Show("导入工区失败," + ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -185,14 +188,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel,
|
|
|
|
if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel,
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Directory.Exists(WareaModel.savepath))
|
|
|
|
var area= WorkareaNameSource.Where(a => a.workareaname == WareaModel.workareaname).FirstOrDefault();
|
|
|
|
|
|
|
|
if (area != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Directory.Delete(WareaModel.savepath, true);
|
|
|
|
WorkareaNameSource.Remove(area);
|
|
|
|
|
|
|
|
WareaSelectedIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var area= _workareasModelArray.workarea.Where(a => a.workareaname == WareaModel.workareaname).FirstOrDefault();
|
|
|
|
|
|
|
|
WorkareaNameSource.Remove(WareaModel.workareaname);
|
|
|
|
|
|
|
|
_workareasModelArray.workarea.Remove(area);
|
|
|
|
|
|
|
|
WareaSelectedIndex =0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -255,6 +256,11 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
get => new DelegateCommand(() =>
|
|
|
|
get => new DelegateCommand(() =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 数据校验(关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查(自定义特性检查)
|
|
|
|
// 数据校验(关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查(自定义特性检查)
|
|
|
|
|
|
|
|
//if(WareaSelectedIndex == -1)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// MessageBox.Show("工区名称不能为空", "提示", MessageBoxButton.OK);
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
//}
|
|
|
|
if (string.IsNullOrEmpty(WareaModel.savepath)
|
|
|
|
if (string.IsNullOrEmpty(WareaModel.savepath)
|
|
|
|
|| string.IsNullOrEmpty(WareaModel.apmModel.station)
|
|
|
|
|| string.IsNullOrEmpty(WareaModel.apmModel.station)
|
|
|
|
|| string.IsNullOrEmpty(WareaModel.apmModel.ttime[0].ttime2d))
|
|
|
|
|| string.IsNullOrEmpty(WareaModel.apmModel.ttime[0].ttime2d))
|
|
|
@ -267,6 +273,33 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//1 Workarea配置更新,选择的索引
|
|
|
|
//1 Workarea配置更新,选择的索引
|
|
|
|
_workareasModelArray.selectIndex = WareaSelectedIndex;
|
|
|
|
_workareasModelArray.selectIndex = WareaSelectedIndex;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = _workareasModelArray.workarea.Count;
|
|
|
|
|
|
|
|
int wIndex = count-1;
|
|
|
|
|
|
|
|
while (wIndex < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//清除目录保存文件
|
|
|
|
|
|
|
|
var item = _workareasModelArray.workarea[wIndex];
|
|
|
|
|
|
|
|
var model = WorkareaNameSource.Where(p => p.workareaname == item.workareaname).FirstOrDefault();
|
|
|
|
|
|
|
|
if (model == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_workareasModelArray.workarea.Remove(item);
|
|
|
|
|
|
|
|
if (Directory.Exists(item.filepath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Directory.Delete(item.filepath, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wIndex--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(_workareasModelArray.workarea.Count<= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//没有数据直接删除文件;
|
|
|
|
|
|
|
|
WareaModel.savepath = string.Empty;
|
|
|
|
|
|
|
|
File.Delete(Path.Combine(JsonParser.workareaPath, "Workareas.json"));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_workareasModelArray.workarea[WareaSelectedIndex].filepath = WareaModel.savepath;
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray);
|
|
|
|
JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray);
|
|
|
|
_wareaModel.apmModel.channels = new List<StationChannelsModel>
|
|
|
|
_wareaModel.apmModel.channels = new List<StationChannelsModel>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -318,7 +351,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
|
|
|
|
ApmsModel apms = curWorkarea.apmModel;
|
|
|
|
ApmsModel apms = curWorkarea.apmModel;
|
|
|
|
apms.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
|
|
|
|
apms.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
|
|
|
|
apms.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
|
|
|
|
apms.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
|
|
|
|
apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath);
|
|
|
|
apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath).Replace("\\", "/"); ;
|
|
|
|
apms.push2wx = curWorkarea.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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|