using Yw.Vmo;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
/// 监测值辅助类
|
/// </summary>
|
public class SimulationMonitorValueHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public SimulationMonitorValueHelper(SimulationVisualListHelper visualListHelper, SimulationMonitorHelper monitorHelper)
|
{
|
_visualListHelper = visualListHelper;
|
_monitorHelper = monitorHelper;
|
}
|
|
private SimulationVisualListHelper _visualListHelper = null;//可见列表辅助类
|
private SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
|
private List<HydroMonitorValueViewModel> _allMonitorValueList = null;//所有监测值列表
|
|
/// <summary>
|
/// 获取
|
/// </summary>
|
public async Task<List<HydroMonitorValueViewModel>> Get()
|
{
|
if (_allMonitorValueList == null)
|
{
|
_allMonitorValueList = new List<HydroMonitorValueViewModel>();
|
var allVisualDict = _visualListHelper.GetVisualDict();
|
if (allVisualDict != null && allVisualDict.Count > 0)
|
{
|
var allMonitorList = await _monitorHelper.Get();
|
if (allMonitorList != null && allMonitorList.Count > 0)
|
{
|
foreach (var monitor in allMonitorList)
|
{
|
if (allVisualDict.ContainsKey(monitor.Relation))
|
{
|
var visual = allVisualDict[monitor.Relation];
|
var vm = new HydroMonitorValueViewModel(monitor, visual);
|
_allMonitorValueList.Add(vm);
|
}
|
}
|
}
|
}
|
}
|
return _allMonitorValueList;
|
}
|
|
/// <summary>
|
/// 更新
|
/// </summary>
|
public async void Update(string code, List<HydroMonitorVmo> monitorList)
|
{
|
var visual = _visualListHelper.GetVisual(code);
|
if (visual == null)
|
{
|
return;
|
}
|
|
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);
|
}
|
});
|
}
|
|
|
}
|
}
|