diff --git a/StartServerWPF.Models/DataProModelArray.cs b/StartServerWPF.Models/DataProModelArray.cs index 18f3716..276a00e 100644 --- a/StartServerWPF.Models/DataProModelArray.cs +++ b/StartServerWPF.Models/DataProModelArray.cs @@ -7,10 +7,12 @@ using System.Threading.Tasks; namespace StartServerWPF.Models { - public class DataProModelArray + public class DataProModelArray : BindableBase { + private List dataProModels1; + public int selectIndex { get; set; } - public List dataProModels { get; set; } + public List DataProModels { get => dataProModels1; set => dataProModels1 = value; } } public class DataProModel: BindableBase @@ -18,8 +20,8 @@ namespace StartServerWPF.Models private string name; private string dataPath; private string resultPath; - private string startTime; - private string endTime; + private DateTime startTime; + private DateTime endTime; public string Name { get => name; set => SetProperty(ref name, value); } @@ -27,8 +29,8 @@ namespace StartServerWPF.Models public string ResultPath { get => resultPath; set => SetProperty(ref resultPath, value); } - public string StartTime { get => startTime; set => SetProperty(ref startTime, value); } + public DateTime StartTime { get => startTime; set => SetProperty(ref startTime, value); } - public string EndTime { get => endTime; set => SetProperty(ref endTime, value); } + public DateTime EndTime { get => endTime; set => SetProperty(ref endTime, value); } } } diff --git a/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs index 1f84947..b51c754 100644 --- a/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/DataProcessViewModel.cs @@ -70,9 +70,13 @@ namespace StartServerWPF.Modules.Main.ViewModels get => _wareaSelectedIndex; set { - if (value >= 0) + if(value >= 0) { - // _workareaModel = modelArray.workarea[value]; + var model = _workareasModelArray.workarea[value]; + string jsonStr = File.ReadAllText(Path.Combine(model.filepath, "datapro.json")); + var datas = JsonConvert.DeserializeObject>(jsonStr); + NameSource = new ObservableCollection(); + datas.ForEach(d => { NameSource.Add(d); }); } SetProperty(ref _wareaSelectedIndex, value); } @@ -84,6 +88,30 @@ namespace StartServerWPF.Modules.Main.ViewModels set { SetProperty(ref _workareaNameSource, value); } } + private ObservableCollection _nameSource=new ObservableCollection(); + public ObservableCollection NameSource + { + get => _nameSource; + set { SetProperty(ref _nameSource, value); } + } + private int _dataSelectedIndex; + public int DataSelectedIndex + { + get => _dataSelectedIndex; + set + { + if (value >= 0) + { + var item = NameSource[value]; + StartSelectedDate = item.StartTime; + EndSelectedDate = item.EndTime; + DataPath = item.DataPath; + SavePath = item.ResultPath; + } + SetProperty(ref _dataSelectedIndex, value); + } + } + private ObservableCollection _apmsEventSource = new ObservableCollection(); public ObservableCollection ApmsEventSource { @@ -109,39 +137,47 @@ namespace StartServerWPF.Modules.Main.ViewModels { StartSelectedDate = DateTime.Now; EndSelectedDate = DateTime.Now; - WorkareaNameSource = new ObservableCollection(); _workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a)); WareaSelectedIndex = _workareasModelArray.selectIndex; + + var model = _workareasModelArray.workarea[WareaSelectedIndex]; + string jsonStr= File.ReadAllText(Path.Combine(model.filepath, "datapro.json")); + var datas= JsonConvert.DeserializeObject>(jsonStr); + NameSource = new ObservableCollection(); + datas.ForEach(d => { NameSource.Add(d); }); + DataSelectedIndex = 0; }); - public DelegateCommand SaveCommand => new(() => + public DelegateCommand AddItemCommand => new(() => { - - DataProModelArray dataProModelArray = new DataProModelArray(); - dataProModelArray.selectIndex = 0; - dataProModelArray.dataProModels = new List(); - dataProModelArray.dataProModels.Add(new DataProModel + int count = NameSource.Count()+1; + NameSource.Add(new DataProModel { - Name = DateTime.Now.ToString("d"), - DataPath = DataPath, - ResultPath = SavePath, - StartTime = DateTime.Now.ToString("G"), - EndTime = DateTime.Now.ToString("G") + Name = DateTime.Now.ToString("d") +" "+ count.ToString("D2"), + DataPath = "", + ResultPath = "", + StartTime = DateTime.Now, + EndTime = DateTime.Now }); - string jsonStr = JsonConvert.SerializeObject(dataProModelArray, Formatting.Indented); - var model = _workareasModelArray.workarea[WareaSelectedIndex]; - - File.WriteAllText(Path.Combine( model.filepath, "datapro.json"), jsonStr); + DataSelectedIndex = NameSource.Count()-1; }); - - public DelegateCommand DeleteCommand => new(() => { - + if (MessageBox.Show("确认删除?", "警告", MessageBoxButton.OKCancel, + MessageBoxImage.Exclamation) == MessageBoxResult.OK) + { + NameSource.RemoveAt(DataSelectedIndex); + DataSelectedIndex = 0; + }; + }); + public DelegateCommand SaveCommand => new(() => + { + string jsonStr = JsonConvert.SerializeObject(NameSource, Formatting.Indented); + var model = _workareasModelArray.workarea[WareaSelectedIndex]; + File.WriteAllText(Path.Combine(model.filepath, "datapro.json"), jsonStr); }); - public DelegateCommand SelectFileCommand => new((obj) => { @@ -217,7 +253,9 @@ namespace StartServerWPF.Modules.Main.ViewModels process.ProParams = $"{str} {temPath}"; //dataProtools 配置更新 - var area = JsonParser.DeepCopy(_workareaModel); + string temJson= JsonConvert.SerializeObject(_workareaModel); + var area = JsonConvert.DeserializeObject(temJson); //JsonParser.DeepCopy(_workareaModel); + ApmsModel tools = area.apmModel; tools.savepath = SavePath; tools.station = Path.GetFullPath(Path.Combine(area.savepath, area.apmModel.station)).Replace("\\", "/"); diff --git a/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs index 4790a6d..c7ae7b5 100644 --- a/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/MainViewModel.cs @@ -524,13 +524,13 @@ namespace StartServerWPF.Modules.Main.ViewModels process.StartInfo.FileName = Path.GetFullPath(proInfo.ProPath + proInfo.ProName+".exe"); process.StartInfo.WorkingDirectory = Path.GetFullPath(proInfo.ProPath); process.StartInfo.Arguments = proInfo.ProParams; + Debug.WriteLine($"*******name:{process.StartInfo.FileName}, arguments:{process.StartInfo.Arguments}*********"); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; - process.StartInfo.CreateNoWindow = true; //* Set your output and error (asynchronous) handlers - if (!proInfo.ProName.Contains("gw.apms")) + // if (!proInfo.ProName.Contains("gw.apms")) { process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler); @@ -555,15 +555,15 @@ namespace StartServerWPF.Modules.Main.ViewModels if (outLine.Data.Contains("ProcessSlice:")) { var pro = sendingProcess as Process; - if (pro != null&& pro.MainModule.ModuleName.Contains(_systemConfig.proTools.ProName)) + if (pro != null) { Application.Current.Dispatcher.InvokeAsync(() => { - //if (pro.MainModule.ModuleName.Contains(_systemConfig.proApms.ProName)) - //{ - // AddItems(ApmsProcessSliceSource, new ProcessingInformationModel { ProcessMes = outLine.Data, MonitorTime = DateTime.Now.ToString() }); - //} - //else + if (pro.MainModule.ModuleName.Contains(_systemConfig.proApms.ProName)) + { + AddItems(ApmsProcessSliceSource, new ProcessingInformationModel { ProcessMes = outLine.Data, MonitorTime = DateTime.Now.ToString() }); + } + else if (pro.MainModule.ModuleName.Contains(_systemConfig.proTools.ProName)) { AddItems(ToolsProcessSliceSource, new ProcessingInformationModel { ProcessMes = outLine.Data, MonitorTime = DateTime.Now.ToString() }); diff --git a/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs b/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs index ffa8f0e..01db09e 100644 --- a/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs +++ b/StartServerWPF.Modules.Main/ViewModels/SetParamViewModel.cs @@ -273,8 +273,9 @@ namespace StartServerWPF.Modules.Main.ViewModels } }; JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, Path.GetFileName(_wareaModel.savepath) + ".json"), _wareaModel); - - var curWorkarea = JsonParser.DeepCopy(_wareaModel); + + string temJson = JsonConvert.SerializeObject(_wareaModel); + var curWorkarea = JsonConvert.DeserializeObject(temJson); if (!string.IsNullOrEmpty(apmStationFile)) { string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)); @@ -309,7 +310,7 @@ namespace StartServerWPF.Modules.Main.ViewModels 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.savepath =curWorkarea.savepath+"/"+ curWorkarea.toolsavepath; tools.push2wx = curWorkarea.toolpush2wx ? "YES" : "NO"; ; JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proTools.ProPath, "apms.json"), tools); diff --git a/StartServerWPF.Modules.Main/Views/DataProcessView.xaml b/StartServerWPF.Modules.Main/Views/DataProcessView.xaml index 35bc126..0f49deb 100644 --- a/StartServerWPF.Modules.Main/Views/DataProcessView.xaml +++ b/StartServerWPF.Modules.Main/Views/DataProcessView.xaml @@ -56,8 +56,8 @@