| | |
| | | using Yw.Vmo; |
| | | using Yw.Hydro; |
| | | using static Yw.WinFrmUI.Q3d.EpanetEnum; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public SimulationMonitorValueHelper(SimulationVisualListHelper visualListHelper, SimulationMonitorHelper monitorHelper) |
| | | public SimulationMonitorValueHelper |
| | | ( |
| | | SimulationVisualListHelper visualListHelper, |
| | | SimulationMonitorHelper monitorHelper |
| | | ) |
| | | { |
| | | _visualListHelper = visualListHelper; |
| | | _monitorHelper = monitorHelper; |
| | | } |
| | | |
| | | private SimulationVisualListHelper _visualListHelper = null;//可见列表辅助类 |
| | | private SimulationMonitorHelper _monitorHelper = null;//监测点辅助类 |
| | | private List<HydroMonitorValueViewModel> _allMonitorValueList = null;//所有监测值列表 |
| | | private readonly SimulationVisualListHelper _visualListHelper = null;//可见列表辅助类 |
| | | private readonly SimulationMonitorHelper _monitorHelper = null;//监测点辅助类 |
| | | private List<HydroMonitorValueViewModel> _allList = null;//所有监测值列表 |
| | | |
| | | /// <summary> |
| | | /// 获取 |
| | | /// 获取所有 |
| | | /// </summary> |
| | | public async Task<List<HydroMonitorValueViewModel>> Get() |
| | | public async Task<List<HydroMonitorValueViewModel>> GetAll() |
| | | { |
| | | if (_allMonitorValueList == null) |
| | | if (_allList == null) |
| | | { |
| | | _allMonitorValueList = new List<HydroMonitorValueViewModel>(); |
| | | _allList = new List<HydroMonitorValueViewModel>(); |
| | | var allVisualDict = _visualListHelper.GetVisualDict(); |
| | | if (allVisualDict != null && allVisualDict.Count > 0) |
| | | { |
| | | var allMonitorList = await _monitorHelper.Get(); |
| | | var allMonitorList = await _monitorHelper.GetAll(); |
| | | if (allMonitorList != null && allMonitorList.Count > 0) |
| | | { |
| | | foreach (var monitor in allMonitorList) |
| | | { |
| | | if (allVisualDict.ContainsKey(monitor.Relation)) |
| | | if (allVisualDict.ContainsKey(monitor.Parter)) |
| | | { |
| | | var visual = allVisualDict[monitor.Relation]; |
| | | var vm = new HydroMonitorValueViewModel(monitor, visual); |
| | | _allMonitorValueList.Add(vm); |
| | | var visual = allVisualDict[monitor.Parter]; |
| | | var vm = new HydroMonitorValueViewModel(monitor, visual, null); |
| | | _allList.Add(vm); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return _allMonitorValueList; |
| | | return _allList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新 |
| | | /// </summary> |
| | | public async void Update(string code, List<HydroMonitorVmo> monitorList) |
| | | public async Task Update(string code, List<HydroMonitorValueViewModel> valueList) |
| | | { |
| | | var visual = _visualListHelper.GetVisual(code); |
| | | if (visual == null) |
| | | var all = await GetAll(); |
| | | all.RemoveAll(x => x.Vmo.Parter == code); |
| | | if (valueList != null && valueList.Count > 0) |
| | | { |
| | | return; |
| | | all.AddRange(valueList); |
| | | } |
| | | } |
| | | |
| | | var allMonitorValueList = await Get(); |
| | | var monitorValueList = allMonitorValueList.Where(x => x.Vmo.Relation == code).ToList(); |
| | | monitorValueList?.ForEach(x => |
| | | { |
| | | var result = monitorList?.Exists(t => t.Relation == x.Vmo.Relation && t.PropName == x.Vmo.PropName); |
| | | if (!(result.HasValue && result.Value)) |
| | | { |
| | | allMonitorValueList.Remove(x); |
| | | } |
| | | }); |
| | | monitorList?.ForEach(x => |
| | | { |
| | | var result = monitorValueList?.Exists(t => t.Vmo.Relation == x.Relation && t.Vmo.PropName == x.PropName); |
| | | if (!(result.HasValue && result.Value)) |
| | | { |
| | | var vm = new HydroMonitorValueViewModel(x, visual); |
| | | allMonitorValueList.Add(vm); |
| | | } |
| | | }); |
| | | /// <summary> |
| | | /// 重置 |
| | | /// </summary> |
| | | public async void Reset(string monitorInfo) |
| | | { |
| | | var allMonitorValueList = await GetAll(); |
| | | allMonitorValueList.UpdateMonitorValue(monitorInfo); |
| | | } |
| | | |
| | | |