using Yw.Hydro;
|
using Yw.Model;
|
using Yw.Service;
|
|
namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 构件属性辅助类
|
/// </summary>
|
public class HydroPropStatusHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public HydroPropStatusHelper
|
(
|
Yw.Model.HydroModelInfo hydroInfo,
|
List<Yw.Model.HydroParterPropStatusInfo> allPropStatusDbList
|
)
|
{
|
_hydroInfo = hydroInfo;
|
_dict = _hydroInfo.ToPropStatusInfoDict(allPropStatusDbList);
|
}
|
|
private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
|
private Dictionary<string, List<Yw.Model.HydroParterPropStatusInfo>> _dict = null;//字典
|
|
/// <summary>
|
/// 获取属性状态信息
|
/// </summary>
|
public HydroParterPropStatusInfo GetPropStatusInfo(string code, string propNameInfo)
|
{
|
if (string.IsNullOrEmpty(code))
|
{
|
return default;
|
}
|
if (string.IsNullOrEmpty(propNameInfo))
|
{
|
return default;
|
}
|
if (_dict == null)
|
{
|
_dict = new Dictionary<string, List<Model.HydroParterPropStatusInfo>>();
|
}
|
if (!_dict.ContainsKey(code))
|
{
|
_dict.Add(code, new List<Model.HydroParterPropStatusInfo>());
|
}
|
if (_dict[code] == null)
|
{
|
_dict[code] = new List<Model.HydroParterPropStatusInfo>();
|
}
|
var list = _dict[code];
|
var propStatusInfo = list.Find(x => x.PropName == propNameInfo);
|
return propStatusInfo;
|
|
}
|
|
/// <summary>
|
/// 获取属性状态Db列表
|
/// </summary>
|
public List<Yw.Model.HydroParterPropStatusInfo> GetPropStatusDbList()
|
{
|
return _hydroInfo.ToPropStatusDbList(_dict);
|
}
|
|
/// <summary>
|
/// 更新属性状态
|
/// </summary>
|
public void UpdatePropStatus(Yw.Model.HydroParterInfo parter, string propNameInfo, ePropStatus propStatus, string statusInfo)
|
{
|
UpdatePropStatus(parter?.Code, propNameInfo, propStatus, statusInfo);
|
}
|
|
/// <summary>
|
/// 更新属性状态
|
/// </summary>
|
public void UpdatePropStatus(string code, string propNameInfo, ePropStatus propStatus, string statusInfo)
|
{
|
if (string.IsNullOrEmpty(code))
|
{
|
return;
|
}
|
if (string.IsNullOrEmpty(propNameInfo))
|
{
|
return;
|
}
|
if (_dict == null)
|
{
|
_dict = new Dictionary<string, List<Model.HydroParterPropStatusInfo>>();
|
}
|
if (!_dict.ContainsKey(code))
|
{
|
_dict.Add(code, new List<Model.HydroParterPropStatusInfo>());
|
}
|
if (_dict[code] == null)
|
{
|
_dict[code] = new List<Model.HydroParterPropStatusInfo>();
|
}
|
var list = _dict[code];
|
var propStatusInfo = list.Find(x => x.PropName == propNameInfo);
|
if (propStatusInfo == null)
|
{
|
propStatusInfo.Parter = code;
|
propStatusInfo.PropName = propNameInfo;
|
}
|
propStatusInfo.PropStatus = propStatus;
|
propStatusInfo.StatusInfo = statusInfo;
|
}
|
|
|
|
|
}
|
}
|