| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -42,7 +42,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        string apmttime2dFile = string.Empty;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private readonly IDialogService _dialogService;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private SystemConfigModel _systemConfig;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private readonly WorkareasModelArray _workareasModelArray;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private  WorkareasModelArray _workareasModelArray;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        private ObservableCollection<string> _workareaNameSource;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public ObservableCollection<string> WorkareaNameSource
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -60,13 +60,23 @@ namespace StartServerWPF.Modules.Main.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    try
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        var area = _workareasModelArray.workarea[value];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WareaModel.savepath = area.filepath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        string file = Path.Combine(area.filepath, Path.GetFileName(area.filepath) + ".json");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        string json = File.ReadAllText(file);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(json);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    catch (Exception ex)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        //生成工区默认配置文件
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        string str = File.ReadAllText(Path.Combine(JsonParser.workareaPath, "Workarea.json"));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        string path = WareaModel.savepath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(str);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WareaModel.savepath = path;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        string file = Path.Combine(path, Path.GetFileName(path) + ".json");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WareaModel.workareaname = Path.GetFileName(WareaModel.savepath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        File.WriteAllText(file, JsonConvert.SerializeObject(WareaModel));                     
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        //MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    _workareasModelArray.selectIndex = value;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -97,12 +107,10 @@ namespace StartServerWPF.Modules.Main.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            apmStationFile = string.Empty;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            apmttime2dFile = string.Empty;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				           // WareaModel.apmModel = ;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DelegateCommand AddItemCommand => new(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            DialogParameters param = new DialogParameters();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        //    param.Add("type", 1);// 编辑
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            _dialogService.ShowDialog("AddWorkAreaDialog",
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -129,6 +137,47 @@ namespace StartServerWPF.Modules.Main.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             }));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DelegateCommand ImportCommand => new(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            System.Windows.Forms.OpenFileDialog fbd = new System.Windows.Forms.OpenFileDialog();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            fbd.Multiselect = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            fbd.Filter = ".json|*.json|.txt|*.txt";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                try
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    string jsonStr = File.ReadAllText(fbd.FileName);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    _workareasModelArray = JsonConvert.DeserializeObject<WorkareasModelArray>(jsonStr);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    WorkareaNameSource = new ObservableCollection<string>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    _workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    WareaSelectedIndex = _workareasModelArray.selectIndex;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    var item = _workareasModelArray.workarea[_workareasModelArray.selectIndex];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath) + ".json");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    var currentWorkarea = new WorkareaModel();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    if (File.Exists(areaPath))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        string workarea = File.ReadAllText(areaPath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        if (currentWorkarea.StationConfig.Stations == null)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            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();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        WareaModel = currentWorkarea;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    else
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        MessageBox.Show("工区配置文件不存在!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                catch (Exception ex)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    MessageBox.Show("导入工区失败," + ex);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DelegateCommand DeleteItemCommand => new(() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel,
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -144,6 +193,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                WareaSelectedIndex =0;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public DelegateCommand<object> SelectFileCommand => new((obj) =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {      
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            string para = obj.ToString();
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -222,7 +272,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                              station = string.Join(",", _wareaModel.StationConfig.Stations.Where(p => p.IsEnable).Select(n => n.Name))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    };
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, "Workarea.json"), _wareaModel);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, Path.GetFileName(_wareaModel.savepath) + ".json"), _wareaModel);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                  
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    var curWorkarea = JsonParser.DeepCopy<WorkareaModel>(_wareaModel);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    if (!string.IsNullOrEmpty(apmStationFile))
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |