| | |
| | | using System.Security.Cryptography; |
| | | |
| | | namespace HStation.Service |
| | | namespace HStation.Service |
| | | { |
| | | /// <summary> |
| | | /// |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 型号ID 获取 |
| | | /// </summary> |
| | | public List<Model.PumpPartMain> GetByMainID(long ID) |
| | | { |
| | | var idlist = PumpMainAndPartMap.GetByPumpMainID(ID); |
| | | return GetByIds(idlist); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public List<Model.PumpPartMain> GetByIds(List<long> Ids) |
| | |
| | | } |
| | | var all = GetAll(); |
| | | return Ids.Select(x => all.Find(y => y.ID == x)).ToList().Where(x => x != null).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取最大排序码 |
| | | /// </summary> |
| | | public int GetMaxSortCode() |
| | | { |
| | | var all = GetAll(); |
| | | if (all == null || all.Count < 1) |
| | | { |
| | | return 0; |
| | | } |
| | | return all.Max(x => x.SortCode); |
| | | } |
| | | |
| | | #endregion Query |
| | |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 插入一条数据 |
| | | /// </summary> |
| | | public long InsertEX(Model.PumpPartMain part, List<Model.PumpPropContent> pumpPropContents, Model.PumpMainAndPartMap partmap) |
| | | { |
| | | if (part == null || pumpPropContents == null || partmap == null) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var partentity = Model2Entity(part); |
| | | var propcontentsentity = PumpPropContent.Model2Entities(pumpPropContents); |
| | | var partmapentity = PumpMainAndPartMap.Model2Entity(partmap); |
| | | var id = dal.InsertsEx(partentity, propcontentsentity, partmapentity); |
| | | if (id > 0) |
| | | { |
| | | UpdateCache(id); |
| | | PumpPropContent.UpdateCacheByPartID(id); |
| | | PumpMainAndPartMap.UpdateCacheByPartID(id); |
| | | } |
| | | return id; |
| | | } |
| | | |
| | | #endregion Insert |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public bool UpdateEX(Model.PumpPartMain pumppart, List<Model.PumpPropContent> pumpPropContents) |
| | | { |
| | | if (pumppart == null || pumpPropContents.Count < 0) |
| | | { |
| | | return false; |
| | | } |
| | | var pumppartentity = Model2Entity(pumppart); |
| | | var pumpPropContentsentity = PumpPropContent.Model2Entities(pumpPropContents); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var bol = dal.UpdateEx(pumppartentity, pumpPropContentsentity); |
| | | if (bol) |
| | | { |
| | | UpdateCache(pumppart.ID); |
| | | PumpPropContent.UpdateCache(pumpPropContentsentity.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新排序码 |
| | | /// </summary> |
| | | public bool UpdateSortCode(long ID, int SortCode) |
| | |
| | | if (bol) |
| | | { |
| | | UpdateCache(sorters.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新 Paras |
| | | /// </summary> |
| | | public bool UpdateParas(long ID, Dictionary<string, string> Paras) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var bol = dal.UpdateParas(ID, ParasHelper.ToString(Paras)); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新 Flags |
| | | /// </summary> |
| | | public bool UpdateFlags(long ID, List<string> Flags) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var bol = dal.UpdateFlags(ID, FlagsHelper.ToString(Flags)); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新 TagName |
| | | /// </summary> |
| | | public bool UpdateTagName(long ID, string TagName) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var bol = dal.UpdateTagName(ID, TagName); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | } |