master
mzhifa 8 months ago
parent f303948b48
commit 329bd34efd

@ -17,14 +17,14 @@ namespace StartServerWPF.Models
private List<TTime> ttime1;
private string push2wx1;
private string savepath1;
private string xmin1;
private string xmax1;
private string ymin1;
private string ymax1;
private string zref1;
private string zmin1;
private string zmax1;
private string minstep1;
private float xmin1;
private float xmax1;
private float ymin1;
private float ymax1;
private float zref1;
private float zmin1;
private float zmax1;
private float minstep1;
private List<StationChannelsModel> channels1;
[JsonProperty("station")]
@ -34,19 +34,19 @@ namespace StartServerWPF.Models
[JsonProperty("Main.log_level")]
public string log_level { get; set; }
[JsonProperty("Main.slice_seconds")]
public string slice_seconds { get; set; }
public int slice_seconds { get; set; }
[JsonProperty("Main.overlap_seconds")]
public string overlap_seconds { get; set; }
public int overlap_seconds { get; set; }
[JsonProperty("Main.is_mag")]
public string is_mag { get; set; }
[JsonProperty("Main.is_write_slice")]
public string is_write_slice { get; set; }
[JsonProperty("Main.lon")]
public string lon { get; set; }
public double lon { get; set; }
[JsonProperty("Main.lat")]
public string lat { get; set; }
public double lat { get; set; }
[JsonProperty("Main.height")]
public string height { get; set; }
public double height { get; set; }
[JsonProperty("Main.savepath")]
public string savepath { get => savepath1; set => SetProperty(ref savepath1, value); }
[JsonProperty("Main.push2wx")]
@ -54,13 +54,13 @@ namespace StartServerWPF.Models
[JsonProperty("Main.push_url")]
public string push_url { get; set; }
[JsonProperty("Main.push_mag")]
public string push_mag { get; set; }
public double push_mag { get; set; }
[JsonProperty("Main.message_id")]
public string message_id { get; set; }
public int message_id { get; set; }
[JsonProperty("Main.company_id")]
public string company_id { get; set; }
public int company_id { get; set; }
[JsonProperty("Main.area_id")]
public string area_id { get; set; }
public int area_id { get; set; }
[JsonProperty("Main.content")]
public string content { get; set; }
[JsonProperty("Main.push_key")]
@ -74,25 +74,25 @@ namespace StartServerWPF.Models
[JsonProperty("Locate.work_path")]
public string work_path { get; set; }
[JsonProperty("Locate.xmin")]
public string xmin { get => xmin1; set => SetProperty(ref xmin1, value); }
public float xmin { get => xmin1; set => SetProperty(ref xmin1, value); }
[JsonProperty("Locate.xmax")]
public string xmax { get => xmax1; set => SetProperty(ref xmax1, value); }
public float xmax { get => xmax1; set => SetProperty(ref xmax1, value); }
[JsonProperty("Locate.ymin")]
public string ymin { get => ymin1; set => SetProperty(ref ymin1, value); }
public float ymin { get => ymin1; set => SetProperty(ref ymin1, value); }
[JsonProperty("Locate.ymax")]
public string ymax { get => ymax1; set => SetProperty(ref ymax1, value); }
public float ymax { get => ymax1; set => SetProperty(ref ymax1, value); }
[JsonProperty("Locate.zref")]
public string zref { get => zref1; set => SetProperty(ref zref1, value); }
public float zref { get => zref1; set => SetProperty(ref zref1, value); }
[JsonProperty("Locate.zmin")]
public string zmin { get => zmin1; set => SetProperty(ref zmin1, value); }
public float zmin { get => zmin1; set => SetProperty(ref zmin1, value); }
[JsonProperty("Locate.zmax")]
public string zmax { get => zmax1; set => SetProperty(ref zmax1, value); }
public float zmax { get => zmax1; set => SetProperty(ref zmax1, value); }
[JsonProperty("Locate.minstep")]
public string minstep { get => minstep1; set => SetProperty(ref minstep1, value); }
public float minstep { get => minstep1; set => SetProperty(ref minstep1, value); }
[JsonProperty("Locate.method")]
public string method { get; set; }
[JsonProperty("Locate.clusted_otime")]
public string clusted_otime { get; set; }
public double clusted_otime { get; set; }
}

@ -11,48 +11,17 @@ using Prism.Mvvm;
namespace StartServerWPF.Models
{
public class WorkareaModelArray
public class WorkareasModelArray
{
public int selectIndex { get; set; }
public List<WorkareaModel> workarea { get;set;}
public List<StationControlModel> CreateStationFromCSV(string fn,string location)
{
if (!File.Exists(fn)) return null;
List<StationControlModel> stations = new List<StationControlModel>();
Aspose.Cells.TxtLoadOptions lo = new TxtLoadOptions();
//Debug.WriteLine(Encoding.Default.ToString());
lo.Encoding = Encoding.Default;//设置编码方式
Workbook workbook = new Workbook(fn, lo);
//配置读取文件的类型CSV
workbook.FileFormat = FileFormatType.Csv;//可在此配置Excel文件类型
Worksheet worksheet = workbook.Worksheets[0];//默认第一个Sheet页
Cells cells = worksheet.Cells;
//读取到DataTable中
DataTable dt = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, true);
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow row = dt.Rows[i];
StationControlModel model = new StationControlModel();
model.NetWork = row[0].ToString();
model.Num = row[1].ToString();
model.Coordinate = new Coordinate3D(double.Parse(row[2].ToString()), double.Parse(row[3].ToString()), double.Parse(row[4].ToString()));
model.Sens = double.Parse(row[5].ToString());
model.BeginUseTime = DateTime.Parse(row[6].ToString());
model.StopUseTime = DateTime.Parse(row[7].ToString());
model.Location = location;
stations.Add(model);
}
//释放资源
workbook = null;
worksheet = null;
return stations;
}
public List<Workareas> workarea { get; set; }
}
public class Workareas
{
public string workareaname { get; set; }
public string filepath { get; set; }
}
public class WorkareaModel : BindableBase
{
private string workareaname1;
@ -92,6 +61,42 @@ namespace StartServerWPF.Models
public ApmsModel apmModel { get => apmModel1; set => SetProperty(ref apmModel1, value); }
public StationConfigModel StationConfig { get; set; }
public List<StationControlModel> CreateStationFromCSV(string fn, string location)
{
if (!File.Exists(fn)) return null;
List<StationControlModel> stations = new List<StationControlModel>();
Aspose.Cells.TxtLoadOptions lo = new TxtLoadOptions();
//Debug.WriteLine(Encoding.Default.ToString());
lo.Encoding = Encoding.Default;//设置编码方式
Workbook workbook = new Workbook(fn, lo);
//配置读取文件的类型CSV
workbook.FileFormat = FileFormatType.Csv;//可在此配置Excel文件类型
Worksheet worksheet = workbook.Worksheets[0];//默认第一个Sheet页
Cells cells = worksheet.Cells;
//读取到DataTable中
DataTable dt = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxColumn + 1, true);
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow row = dt.Rows[i];
StationControlModel model = new StationControlModel();
model.NetWork = row[0].ToString();
model.Num = row[1].ToString();
model.Coordinate = new Coordinate3D(double.Parse(row[2].ToString()), double.Parse(row[3].ToString()), double.Parse(row[4].ToString()));
model.Sens = double.Parse(row[5].ToString());
model.BeginUseTime = DateTime.Parse(row[6].ToString());
model.StopUseTime = DateTime.Parse(row[7].ToString());
model.Location = location;
stations.Add(model);
}
//释放资源
workbook = null;
worksheet = null;
return stations;
}
}
public class StationConfigModel: BindableBase

@ -25,7 +25,7 @@ namespace StartServerWPF.Modules.Main
containerRegistry.RegisterForNavigation<LogManagementView>();
containerRegistry.RegisterForNavigation<FilesWatcherView>();
containerRegistry.RegisterDialog<SetParamDialog>();
containerRegistry.RegisterDialog<AddWorkAreaDialog>();
containerRegistry.RegisterDialog<LoginViewDialog>();
containerRegistry.RegisterSingleton<MainViewModel>();

@ -5,6 +5,7 @@ using StartServerWPF.Models;
using StartServerWPF.Modules.Main.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -13,12 +14,12 @@ using System.Windows.Input;
namespace StartServerWPF.Modules.Main.ViewModels
{
public class SetParamDialogViewModel : BindableBase, IDialogAware
public class AddWorkAreaDialogViewModel : BindableBase, IDialogAware
{
public SetParamDialogViewModel()
public AddWorkAreaDialogViewModel()
{
}
private string _title = "参数设置";
private string _title = "添加工区";
public string Title => _title;
public event Action<IDialogResult> RequestClose;
@ -32,71 +33,60 @@ namespace StartServerWPF.Modules.Main.ViewModels
public void OnDialogOpened(IDialogParameters parameters)
{
// _title = "编辑" + _title;
var _type = parameters.GetValue<int>("type");
// _title = (_type == 0 ? "新增" : "修改") + _title;
_systemConfig = parameters.GetValue<SystemConfigModel>("model");
MainModel= _systemConfig.vpnInfo;
MoniTime= parameters.GetValue<DateTime>("moniTime");
}
private SystemConfigModel _systemConfig;
private VpnInfo _mainModel = new VpnInfo();
public VpnInfo MainModel
private string _workAreaName;
public string WorkAreaName
{
get => _mainModel;
set { SetProperty(ref _mainModel, value); }
get => _workAreaName;
set { SetProperty(ref _workAreaName, value); }
}
private DateTime _moniTime ;
public DateTime MoniTime
private string _workAreaPath;
public string WorkAreaPath
{
get => _moniTime;
set { SetProperty(ref _moniTime, value); }
get => _workAreaPath;
set { SetProperty(ref _workAreaPath, value); }
}
public DelegateCommand FilePathSaveCommand=> new(()=>
{
updateJson = false;
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if(string.IsNullOrEmpty(WorkAreaName))
{
MessageBox.Show("工区名称不能为空");
return;
}
});
public DelegateCommand LogPathSaveCommand=> new(() =>
{
System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
fbd.SelectedPath = System.Environment.CurrentDirectory + "\\" + MainModel.SystemLogPath;
fbd.ShowNewFolderButton = true;
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
//if (fbd.SelectedPath != textBoxLogPath.Text)
//{
// textBoxLogPath.Text = fbd.SelectedPath;
//}
MainModel.SystemLogPath = fbd.SelectedPath;
string path = Path.Combine(fbd.SelectedPath, WorkAreaName);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
WorkAreaPath = path;
}
});
bool updateJson = false;
public ICommand ConfirmCommand
{
get => new DelegateCommand(() =>
{
// 确认操作
// 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查
if (string.IsNullOrEmpty(MainModel.VpnName) || string.IsNullOrEmpty(MainModel.VpnIP))
if (string.IsNullOrEmpty(WorkAreaName) || string.IsNullOrEmpty(WorkAreaPath))
{
MessageBox.Show("内容不能为空", "提示", MessageBoxButton.OK);
MessageBox.Show("工区名称和目录不能为空", "提示", MessageBoxButton.OK);
return;
}
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
{
JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig);
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
var dialog = new DialogResult(ButtonResult.OK);
Workareas workareas = new Workareas();
workareas.workareaname = WorkAreaName;
workareas.filepath = WorkAreaPath;
dialog.Parameters.Add("param1", workareas);
RequestClose?.Invoke( dialog);
}
});
}

@ -15,24 +15,26 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
namespace StartServerWPF.Modules.Main.ViewModels
{
public class DataProcessViewModel : BindableBase
{
public DataProcessViewModel(MainViewModel mainViewModel, SystemConfigModel configModel, WorkareaModelArray modelArray)
public DataProcessViewModel(MainViewModel mainViewModel, SystemConfigModel configModel, WorkareaModel workareaModel, WorkareasModelArray workareasModelArray)
{
this._mainViewModel = mainViewModel;
this._systemConfig = configModel;
this.modelArray = modelArray;
this._workareaModel = workareaModel;
this._workareasModelArray = workareasModelArray;
}
private string _title = "应用列表";
public string Title => _title;
private readonly MainViewModel _mainViewModel;
private SystemConfigModel _systemConfig;
private readonly WorkareaModelArray modelArray;
private WorkareaModel _workareaModel;
private readonly WorkareaModel _workareaModel;
private readonly WorkareasModelArray _workareasModelArray;
private string _dataPath;
public string DataPath
{
@ -69,7 +71,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
{
if (value >= 0)
{
_workareaModel = modelArray.workarea[value];
// _workareaModel = modelArray.workarea[value];
}
SetProperty(ref _wareaSelectedIndex, value);
}
@ -88,14 +90,28 @@ namespace StartServerWPF.Modules.Main.ViewModels
set => SetProperty(ref _apmsEventSource, value);
}
private ObservableCollection<ProcessingInformationModel> _processSliceSource = new ObservableCollection<ProcessingInformationModel>();
public ObservableCollection<ProcessingInformationModel> ProcessSliceSource
{
get => _processSliceSource;
set => SetProperty(ref _processSliceSource, value);
}
private bool _IsBusy = true;
public bool IsBusy
{
get => _IsBusy;
set { SetProperty(ref _IsBusy, value); }
}
public DelegateCommand LoadedCommand => new(() =>
{
StartSelectedDate = DateTime.Now;
EndSelectedDate = DateTime.Now;
this._workareaModel = modelArray.workarea[modelArray.selectIndex];
WorkareaNameSource = new ObservableCollection<string>();
modelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
WareaSelectedIndex = modelArray.selectIndex;
_workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
WareaSelectedIndex = _workareasModelArray.selectIndex;
});
@ -125,12 +141,13 @@ namespace StartServerWPF.Modules.Main.ViewModels
{
get => new DelegateCommand(() =>
{
// 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查
if (string.IsNullOrEmpty(DataPath) || string.IsNullOrEmpty(SavePath))
{
MessageBox.Show("内容不能为空", "提示", MessageBoxButton.OK);
return;
}
// 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查
if (string.IsNullOrEmpty(DataPath) || string.IsNullOrEmpty(SavePath))
{
MessageBox.Show("内容不能为空", "提示", MessageBoxButton.OK);
return;
}
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation) == MessageBoxResult.OK)
{
@ -141,53 +158,56 @@ namespace StartServerWPF.Modules.Main.ViewModels
return;
}
DateTime dateTime = StartSelectedDate;
string temPath = Path.GetPathRoot( _workareaModel.savepath) + "temPath";
string temPath = Path.GetPathRoot(_workareaModel.savepath) + "temPath";
if (!Directory.Exists(temPath))
{
Directory.CreateDirectory(temPath);
}
while ((EndSelectedDate - dateTime).TotalMinutes >= 1)
Task.Run(() =>
{
string path = Path.GetFullPath($"{DataPath}\\{dateTime.Month.ToString().PadLeft(2, '0')}\\{dateTime.Day.ToString().PadLeft(2, '0')}\\{dateTime.Hour.ToString().PadLeft(2, '0')}\\{dateTime.Minute.ToString().PadLeft(2, '0')}");
dateTime= dateTime.AddMinutes(1);
if( !Directory.Exists(path))
IsBusy = false;
while ((EndSelectedDate - dateTime).TotalMinutes >= 1)
{
continue;
string path = Path.GetFullPath($"{DataPath}\\{dateTime.Month.ToString().PadLeft(2, '0')}\\{dateTime.Day.ToString().PadLeft(2, '0')}\\{dateTime.Hour.ToString().PadLeft(2, '0')}\\{dateTime.Minute.ToString().PadLeft(2, '0')}");
dateTime = dateTime.AddMinutes(1);
if (!Directory.Exists(path))
{
continue;
}
var mseedFiles = new DirectoryInfo(path).EnumerateFiles("*.mseed");
// var mseedFiles = files.Where(i => i.Extension == ".mseed");
Parallel.ForEach(mseedFiles, (item) =>
{
Debug.WriteLine($"***************path:{path},{item.FullName}");
File.Copy(item.FullName, Path.Combine(temPath, item.Name), true);
});
}
var mseedFiles = new DirectoryInfo(path).EnumerateFiles("*.mseed");
// var mseedFiles = files.Where(i => i.Extension == ".mseed");
Parallel.ForEach(mseedFiles, (item) =>
{
Debug.WriteLine($"***************path:{path},{item.FullName}");
File.Copy(item.FullName, Path.Combine( temPath, item.Name), true);
});
}
ProcessInfo process = _systemConfig.dataProTools;
int index = process.ProParams.IndexOf("-wave");
string str = process.ProParams.Substring(0, index) + "-wave";
process.ProParams = $"{str} {temPath}";
ProcessInfo process = _systemConfig.dataProTools;
int index = process.ProParams.IndexOf("-wave");
string str = process.ProParams.Substring(0, index) + "-wave";
process.ProParams = $"{str} {temPath}";
//gw.tools.exe配置更新
ApmsModel tools = _workareaModel.apmModel;
// tools.savepath = SavePath; // _workareaModel.savepath + "/" +SavePath;;
tools.station = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, _workareaModel.apmModel.station)).Replace("\\", "/");
tools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, _workareaModel.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
//dataProtools配置更新
ApmsModel tools = _workareaModel.apmModel;
tools.savepath = SavePath;
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.dataProTools.ProPath, "apms.json"), tools);
tools.push2wx = _workareaModel.toolpush2wx ? "YES" : "NO";
tools.channels = new List<StationChannelsModel>
var mfile = new DirectoryInfo(temPath).EnumerateFiles("*.mseed");
if (mfile.Any())
{
isStart = true;
if (fileDic.Count != 0) fileDic.Clear();
this.StartProcess(process);
}
else
{
new StationChannelsModel()
Application.Current.Dispatcher.InvokeAsync(() =>
{
location = _workareaModel.StationConfig.Location,
network = _workareaModel.StationConfig.Network,
channels = _workareaModel.StationConfig.Channels,
station = string.Join(",", _workareaModel.StationConfig.Stations.Where(p => p.IsEnable).Select(n => n.Name))
}
};
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.dataProTools.ProPath, "apms.json"), tools);
this.StartProcess(process);
AddItems(ProcessSliceSource, new ProcessingInformationModel { ProcessMes = "没有需要处理的文件", MonitorTime = DateTime.Now.ToString() });
}, DispatcherPriority.ApplicationIdle);
}
});
}
});
}
@ -207,15 +227,73 @@ namespace StartServerWPF.Modules.Main.ViewModels
process.StartInfo.CreateNoWindow = true;
//* Set your output and error (asynchronous) handlers
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
//* Start process and handlers
bool res = process.Start();
// process.WaitForExit();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
return res;
}
private void AddItems<T>(ObservableCollection<T> list, T t1)
{
if (list == null)
{
return;
}
list.Add(t1);
if (list.Count > 30)
{
T item = list[0];
list.RemoveAt(0);
}
}
Dictionary<string, string> fileDic=new Dictionary<string, string>();
bool isStart = false;
void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
Debug.WriteLine("output*************:{0},{1}", sendingProcess.ToString(), outLine.Data);
if (string.IsNullOrEmpty(outLine.Data)) return;
var pro = sendingProcess as Process;
if (pro != null && pro.MainModule.ModuleName.Contains(_systemConfig.dataProTools.ProName))
{
string mes = outLine.Data;
if (outLine.Data.Contains("run time cost="))
{
int index = mes.IndexOf('[');
string str = mes.Substring(index + 1).Replace("]", "");
mes = $"处理完成,共耗时{str}";
}
else if (outLine.Data.Contains("read HA"))
{
int index = mes.IndexOf("read ");
string str = mes.Substring(index + 8).Substring(index, 3);
fileDic[str] = outLine.Data;
return;
}
else if(isStart && outLine.Data.Contains("ProcessSlice: "))
{
isStart = false;
Application.Current.Dispatcher.InvokeAsync(() =>
{
AddItems(ProcessSliceSource, new ProcessingInformationModel { ProcessMes = $"共载入{fileDic.Keys.Count}组台站数据", MonitorTime = DateTime.Now.ToString() });
AddItems(ProcessSliceSource, new ProcessingInformationModel { ProcessMes = "开始处理", MonitorTime = DateTime.Now.ToString() });
}, DispatcherPriority.ApplicationIdle);
}
Application.Current.Dispatcher.InvokeAsync(() =>
{
AddItems(ProcessSliceSource, new ProcessingInformationModel { ProcessMes =mes, MonitorTime = DateTime.Now.ToString() });
}, DispatcherPriority.ApplicationIdle);
}
}
private void Process_Exited(object? sender, EventArgs e)
{
IsBusy = true;
var fileName = Directory.GetFiles(SavePath, "*.index");
if (!File.Exists( fileName.FirstOrDefault()))
{

@ -252,7 +252,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
set => SetProperty(ref _toolsEventSource, value);
}
public static void AddItems<T>(ObservableCollection<T> list, T t1)
private void AddItems<T>(ObservableCollection<T> list, T t1)
{
if (list == null)
{

@ -16,29 +16,32 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace StartServerWPF.Modules.Main.ViewModels
{
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;
this._workareaModelArray = workareaModelArray;
WareaModel = workareaModel;
this._workareasModelArray = workareasModelArray;
MainModel = _systemConfig.vpnInfo;
WorkareaNameSource = new ObservableCollection<string>();
_workareaModelArray.workarea.Select(n=>n.workareaname).ToList().ForEach(a=> WorkareaNameSource.Add(a));
WareaSelectedIndex = _workareaModelArray.selectIndex;
WareaModel = _workareaModelArray.workarea[WareaSelectedIndex];
_workareasModelArray.workarea.Select(n=>n.workareaname).ToList().ForEach(a=> WorkareaNameSource.Add(a));
WareaSelectedIndex = _workareasModelArray.selectIndex;
}
private string _title = "应用列表";
public string Title => _title;
string apmStationFile = string.Empty;
string apmttime2dFile = string.Empty;
private readonly IDialogService _dialogService;
private SystemConfigModel _systemConfig;
private readonly WorkareaModelArray _workareaModelArray;
private readonly WorkareasModelArray _workareasModelArray;
private ObservableCollection<string> _workareaNameSource;
public ObservableCollection<string> WorkareaNameSource
{
@ -53,7 +56,16 @@ namespace StartServerWPF.Modules.Main.ViewModels
set {
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);
}
@ -84,26 +96,27 @@ namespace StartServerWPF.Modules.Main.ViewModels
apmttime2dFile = string.Empty;
});
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);
WorkareaNameSource.Add(AddWorkareaName);
DialogParameters param = new DialogParameters();
// 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) =>
@ -117,7 +130,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
switch (para)
{
case "apmsStation":
WareaModel.apmModel.savepath = fbd.SafeFileName;
WareaModel.apmModel.station = fbd.SafeFileName;
apmStationFile = fbd.FileName;
break;
case "apmsttime2d":
@ -162,18 +175,21 @@ namespace StartServerWPF.Modules.Main.ViewModels
get => new DelegateCommand(() =>
{
// 数据校验关键字段不能为空、年龄做数字区间的校验、做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;
}
if (MessageBox.Show("确认修改?", "参数设置", MessageBoxButton.OKCancel,
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>
{
{
new StationChannelsModel()
{
location = _wareaModel.StationConfig.Location,
@ -181,49 +197,65 @@ namespace StartServerWPF.Modules.Main.ViewModels
channels = _wareaModel.StationConfig.Channels,
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))
{
string destFileName = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.savepath));
File.Copy(apmStationFile, destFileName, true);
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station));
if (destFileName != apmStationFile)
{
File.Copy(apmStationFile, destFileName, true);
}
apmStationFile = null;
}
if(!string.IsNullOrEmpty(apmttime2dFile))
{
string destFileName = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.ttime[0].ttime2d));
File.Copy(apmttime2dFile, destFileName, true);
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d));
if (destFileName != apmttime2dFile)
{
File.Copy(apmttime2dFile, destFileName, true);
}
apmttime2dFile = null;
}
//2 gw.apms.exe配置更新
{
ApmsModel apms = _wareaModel.apmModel;
apms.station = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.station)).Replace("\\","/");
apms.ttime[0].ttime2d= Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); ;
apms.savepath = _wareaModel.savepath + "/" + _wareaModel.apmsavepath;
apms.push2wx = _wareaModel.apmpush2wx ? "YES" : "NO";
ApmsModel apms = curWorkarea.apmModel;
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.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath);
apms.push2wx = curWorkarea.apmpush2wx ? "YES" : "NO";
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proApms.ProPath, "apms.json"), apms);
}
//3 gw.tools.exe配置更新
{
ApmsModel tools = _wareaModel.apmModel;
tools.station = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.station)).Replace("\\", "/");
tools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(JsonParser.workareaPath, WareaModel.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); ;
tools.savepath = _wareaModel.savepath+"/"+ _wareaModel.toolsavepath;
tools.push2wx = _wareaModel.toolpush2wx ? "YES" : "NO"; ;
ApmsModel tools = curWorkarea.apmModel;
tools.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
tools.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
tools.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.toolsavepath);
tools.push2wx = curWorkarea.toolpush2wx ? "YES" : "NO"; ;
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proTools.ProPath, "apms.json"), tools);
//4 SystemConfig.json配置更新
//4 SystemConfig.json配置更新
int index = _systemConfig.proTools.ProParams.IndexOf("-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);
}
//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配置更新
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("\\", "/"));
}
});
}

@ -0,0 +1,55 @@
<UserControl x:Class="StartServerWPF.Modules.Main.Views.AddWorkAreaDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="400">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<prism:Dialog.WindowStyle>
<Style TargetType="Window">
<Setter Property="Width" Value="400"/>
<Setter Property="Height" Value="200"/>
</Style>
</prism:Dialog.WindowStyle>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="工区名称:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"/>
<TextBlock DockPanel.Dock="Right" Width="30" Visibility="Hidden"/>
<TextBox Text="{Binding WorkAreaName}" Grid.Row="0" Grid.Column="1" />
</DockPanel>
<DockPanel Grid.Row="1" Margin="0,5,0,0">
<TextBlock Text="工区目录:" VerticalAlignment="Center"/>
<Button Content="..." Command="{Binding FilePathSaveCommand}" DockPanel.Dock="Right"/>
<TextBox Text="{Binding WorkAreaPath}" IsReadOnly="True" />
</DockPanel>
</Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2" >
<Button Content="确认" Width="100" Height="30" Margin="5,0"
Background="#FF0ABEFF"
Command="{Binding ConfirmCommand}"/>
<Button Content="取消" Width="100" Height="30"
Background="#DDD" Foreground="#666"
Command="{Binding CancelCommand}"/>
</StackPanel>
</Grid>
</UserControl>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace StartServerWPF.Modules.Main.Views
{
/// <summary>
/// ModifyDeviceView.xaml 的交互逻辑
/// </summary>
public partial class AddWorkAreaDialog : UserControl
{
public AddWorkAreaDialog()
{
InitializeComponent();
}
}
}

@ -7,6 +7,7 @@
xmlns:prism="http://prismlibrary.com/"
xmlns:hc="https://handyorg.github.io/handycontrol"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:local="clr-namespace:StartServerWPF.Modules.Main.Views"
mc:Ignorable="d" Background="#FFEEF1F3"
d:DesignHeight="600" d:DesignWidth="900">
<UserControl.Resources>
@ -72,7 +73,31 @@
</DockPanel>
</UniformGrid>
</Border>
<Button Grid.Row="1" Content="开始" Command="{Binding StartCommand}"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding ProcessSliceSource}" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding MonitorTime}" />
<TextBlock Grid.Column="1" Text="{Binding ProcessMes}" TextWrapping="Wrap" HorizontalAlignment="Center"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="开始" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/>
<hc:LoadingCircle Height="30" Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityReConverter}}"/>
</StackPanel>
</Grid>
<Grid Grid.Column="2" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>

@ -1,92 +0,0 @@
<UserControl x:Class="StartServerWPF.Modules.Main.Views.SetParamDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="500">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<prism:Dialog.WindowStyle>
<Style TargetType="Window">
<Setter Property="Width" Value="500"/>
<Setter Property="Height" Value="300"/>
</Style>
</prism:Dialog.WindowStyle>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Title}" FontSize="20" VerticalAlignment="Center" Foreground="#888" Margin="10,0,10,0"/>
<Grid Grid.Row="1" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="VPN名称" Grid.Row="0" Grid.Column="0"/>
<TextBox Text="{Binding MainModel.VpnName}" Grid.Row="0" Grid.Column="1" Margin="0,0,10,0"/>
<TextBlock Text="IP地址" Grid.Row="0" Grid.Column="2"/>
<TextBox Text="{Binding MainModel.VpnIP}" Grid.Row="0" Grid.Column="3"/>
<TextBlock Text="用户名:" Grid.Row="1" Grid.Column="0" />
<TextBox Text="{Binding MainModel.VpnPsw}" Grid.Row="1" Grid.Column="1" Margin="0,0,10,0"/>
<TextBlock Text="密码:" Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="2" />
<TextBox Text="{Binding MainModel.VpnPsw}" Grid.Row="1" Grid.Column="3" />
</Grid>
<Grid Grid.Row="2" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<TextBlock Text="存储路径:" Grid.Row="0" Grid.Column="0"/>
<TextBox Text="{Binding MainModel.DataSavePath}" IsReadOnly="True" Grid.Row="0" Grid.Column="1"/>
<Button Content="设置路径" Command="{Binding FilePathSaveCommand}" Grid.Row="0" Grid.Column="2"/>
<TextBlock Text="日志路径:" Grid.Row="1" Grid.Column="0" />
<TextBox Text="{Binding MainModel.SystemLogPath}" IsReadOnly="True" Grid.Row="1" Grid.Column="1"/>
<Button Content="设置路径" Command="{Binding LogPathSaveCommand}" Grid.Row="1" Grid.Column="2"/>
</Grid>
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<TextBlock>
<Run Text="监控日期:"/>
<Run Text="{Binding MoniTime,StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</TextBlock>
<Image Name="tb_calendar_img" Source="/Images/calendar.png" Grid.Column="1" Width="18" Height="18" Margin="0,0,0,0" PreviewMouseLeftButtonUp="tb_calendar_img_MouseLeftButtonUp"/>
</StackPanel>
<Popup x:Name="Pop" PopupAnimation="None" Width="200" Height="210" PlacementTarget="{Binding ElementName=tb_calendar}" Placement="Bottom" AllowsTransparency="True" StaysOpen="False" VerticalAlignment="Top" Margin="-200,0,0,0">
<Calendar Name="calendar" SelectedDate="{Binding MoniTime}" HorizontalAlignment="Left" Margin="0,44,0,0" VerticalAlignment="Top" />
</Popup>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="4" >
<Button Content="确认" Width="100" Height="30" Margin="5,0"
Background="#FF0ABEFF"
Command="{Binding ConfirmCommand}"/>
<Button Content="取消" Width="100" Height="30"
Background="#DDD" Foreground="#666"
Command="{Binding CancelCommand}"/>
</StackPanel>
</Grid>
</UserControl>

@ -1,64 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace StartServerWPF.Modules.Main.Views
{
/// <summary>
/// ModifyDeviceView.xaml 的交互逻辑
/// </summary>
public partial class SetParamDialog : UserControl
{
public SetParamDialog()
{
InitializeComponent();
}
private void calendar_DisplayModeChanged(object sender, CalendarModeChangedEventArgs e)
{
if (calendar.DisplayMode == CalendarMode.Month || calendar.DisplayMode == CalendarMode.Decade)
{
calendar.DisplayMode = CalendarMode.Year;
}
}
/// <summary>
/// 点击日历图标显示Calendar控件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tb_calendar_img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (Pop.IsOpen)
{
Pop.IsOpen = false;
}
else
{
Pop.IsOpen = true;
}
}
///// <summary>
///// 监听日期变化隐藏Calendar控件
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void calendar_DisplayDateChanged(object sender, CalendarDateChangedEventArgs e)
//{
// var year = calendar.DisplayDate.Date.Year;
// var month = calendar.DisplayDate.Date.Month;
// tb_calendar.Text = year + "年" + month + "月";
// Pop.IsOpen = false;
//}
}
}

@ -50,24 +50,22 @@
<TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Top" Height="30" FontSize="18"/>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="工区名称:" Width="65" VerticalAlignment="Center"/>
<Button Content="+" DockPanel.Dock="Right" Command="{Binding AddItemCommand}" CommandParameter="1" ></Button>
<TextBox Text="{Binding AddWorkareaName}" DockPanel.Dock="Right" Width="60" Height="30"></TextBox>
<ComboBox DockPanel.Dock="Left" ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}"/>
<ComboBox ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}" Margin="0,0,60,0"/>
</DockPanel>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="工区路径:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding FilePathSaveCommand}" CommandParameter="savepath" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.savepath}" IsReadOnly="True"/>
</DockPanel>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="station:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="apmsStation" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.apmModel.station}"/>
<TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.apmModel.station}" IsReadOnly="True"/>
</DockPanel>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="ttime2d:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="apmsttime2d" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.apmModel.ttime[0].ttime2d}"/>
</DockPanel>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="存储路径:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding FilePathSaveCommand}" CommandParameter="savepath" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.savepath}"/>
<TextBox DockPanel.Dock="Left" Text="{Binding WareaModel.apmModel.ttime[0].ttime2d}" IsReadOnly="True"/>
</DockPanel>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="波形路径:" Width="65" VerticalAlignment="Center"/>
@ -201,13 +199,8 @@
</Popup>-->
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Grid.Row="3" Grid.Column="2" Margin="0,0,0,30">
<Button Content="应用" Width="100" Height="30"
Background="#FF0ABEFF"
Command="{Binding ConfirmCommand}"/>
<!--<Button Content="取消" Width="100" Height="30"
Background="#DDD" Foreground="#666"
Command="{Binding CancelCommand}"/>-->
<Button Content="添加工区" Width="100" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding AddItemCommand}"/>
<Button Content="应用" Margin="30,0,0,0" Width="100" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ConfirmCommand}"/>
</StackPanel>
</Grid>
</Border>

@ -35,7 +35,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
Mseed2asciiApi.LoopCallbackHandler loopCallback;
WorkareaModel workarea;
public ChartPlotRealDataViewModel(SystemConfigModel configModel,WorkareaModelArray workareaModel, IDialogService dialogService)
public ChartPlotRealDataViewModel(SystemConfigModel configModel,WorkareaModel workareaModel, IDialogService dialogService)
{
(Application.Current.MainWindow as System.Windows.Window).Closing += ApplicationClosingDispose;
_dispatcher = Application.Current.Dispatcher;
@ -43,7 +43,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
loopCallback = new Mseed2asciiApi.LoopCallbackHandler(Mseed2AsciiEvent);
Mseed2asciiApi.MseedDatasCallFun(loopCallback);
GC.KeepAlive(loopCallback);
workarea= workareaModel.workarea[workareaModel.selectIndex];
workarea= workareaModel;
_wavesModel = new WavesModel();
if (workarea.StationConfig.Stations != null)
{

@ -20,7 +20,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
{
public class ChartStationDialogViewModel : BindableBase, IDialogAware
{
public ChartStationDialogViewModel(WorkareaModelArray workareaModel)
public ChartStationDialogViewModel(WorkareaModel workareaModel)
{
this._workareaModel = workareaModel;
}
@ -59,7 +59,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
set { SetProperty(ref _mainModel, value); }
}
private DateTime _moniTime ;
private readonly WorkareaModelArray _workareaModel;
private readonly WorkareaModel _workareaModel;
public DateTime MoniTime
{

@ -42,21 +42,24 @@ namespace StartServerWPF
SystemConfigModel sc = JsonConvert.DeserializeObject<SystemConfigModel>(str);
containerRegistry.RegisterSingleton<SystemConfigModel>(() => sc);
string st = File.ReadAllText(Path.Combine(JsonParser.workareaPath, "Workarea.json"));
string st = File.ReadAllText(Path.Combine(JsonParser.workareaPath, "Workareas.json"));
var wm = JsonConvert.DeserializeObject<WorkareaModelArray>(st);
foreach (var item in wm.workarea)
var wm = JsonConvert.DeserializeObject<WorkareasModelArray>(st);
var item = wm.workarea[wm.selectIndex];
string workarea = File.ReadAllText(Path.Combine(item.filepath, "Workarea.json"));
var currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
if (currentWorkarea.StationConfig.Stations == null)
{
if (item.StationConfig.Stations == null)
{
item.StationConfig.Stations = wm.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, item.apmModel.station), item.StationConfig.Location)
?.Select(a => new StationState { IsEnable = a.Enable, Name = a.Num }).ToList();
}
currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location)
?.Select(a => new StationState { IsEnable = a.Enable, Name = a.Num }).ToList();
}
// string wmJson= JsonConvert.SerializeObject(wm, Formatting.Indented);
// File.WriteAllText("serverprogram\\workarea\\Workarea.json", wmJson);
containerRegistry.RegisterSingleton<WorkareaModelArray>(() => wm);
containerRegistry.RegisterSingleton<WorkareasModelArray>(() => wm);
containerRegistry.RegisterSingleton<WorkareaModel>(() => currentWorkarea);
}
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)

@ -34,9 +34,15 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Update="serverprogram\workarea\2017\Workarea.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="serverprogram\workarea\N3102_staion_20230403.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="serverprogram\workarea\Workareas.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="serverprogram\workarea\Workarea.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

@ -19,20 +19,20 @@
}
],
"Main.log_level": "DEBUG",
"Main.slice_seconds": "30",
"Main.overlap_seconds": "10",
"Main.slice_seconds": 30,
"Main.overlap_seconds": 10,
"Main.is_mag": "YES",
"Main.is_write_slice": "NO",
"Main.lon": "38398463.49",
"Main.lat": "4031112.103",
"Main.height": "1102.63",
"Main.lon": 38398463.49,
"Main.lat": 4031112.103,
"Main.height": 1102.63,
"Main.savepath": "I://yuwuN3102mseed//post",
"Main.push2wx": "NO",
"Main.push_url": "http://www.txgy.cloud/api/index/push",
"Main.push_mag": "-1.0",
"Main.message_id": "1",
"Main.company_id": "1",
"Main.area_id": "8",
"Main.push_mag": -1.0,
"Main.message_id": 1,
"Main.company_id": 1,
"Main.area_id": 8,
"Main.content": "通知事件",
"Main.push_key": "Y3qYFBQPMbfTt6m",
"RServer.host": "127.0.0.1",
@ -46,16 +46,16 @@
],
"Locate.log_level": "DEBUG",
"Locate.work_path": ".",
"Locate.xmin": "38396517",
"Locate.xmax": "38398317",
"Locate.ymin": "4029418",
"Locate.ymax": "4031218",
"Locate.zref": "1039",
"Locate.zmin": "300",
"Locate.zmax": "800",
"Locate.minstep": "10",
"Locate.xmin": 38396517,
"Locate.xmax": 38398317,
"Locate.ymin": 4029418,
"Locate.ymax": 4031218,
"Locate.zref": 1039,
"Locate.zmin": 300,
"Locate.zmax": 800,
"Locate.minstep": 10,
"Locate.method": "",
"Locate.clusted_otime": "0.5"
"Locate.clusted_otime": 0.5
},
"StationConfig": {
"network": "HA",

@ -0,0 +1,13 @@
{
"selectIndex": 0,
"workarea": [
{
"workareaname": "n2017",
"filepath": "I:\\DATA\\workarea\\n2017"
},
{
"workareaname": "n2018",
"filepath": "I:\\DATA\\workarea\\n2018"
}
]
}
Loading…
Cancel
Save