| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class PumpPartMain |
| | | public partial class AssetsPumpPartMain |
| | | { |
| | | #region Cache |
| | | |
| | | //获取缓存 |
| | | private static List<Model.PumpPartMain> GetCache() |
| | | private static List<Model.AssetsPumpPartMain> GetCache() |
| | | { |
| | | var all = PumpPartMainCacheHelper.GetSet(() => |
| | | var all = AssetsPumpPartMainCacheHelper.GetSet(() => |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var entity_list = dal.GetAll(); |
| | | var model_list = Entity2Models(entity_list); |
| | | if (model_list == null) |
| | | { |
| | | model_list = new List<Model.PumpPartMain>(); |
| | | model_list = new List<Model.AssetsPumpPartMain>(); |
| | | } |
| | | return model_list; |
| | | }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime); |
| | |
| | | //通过 ID 更新缓存 |
| | | private static void UpdateCache(long ID) |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var entity_ds = dal.GetByID(ID); |
| | | var model_ds = Entity2Model(entity_ds); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | model.Reset(model_ds); |
| | | } |
| | | PumpSeriesCacheHelper.Trigger(); |
| | | AssetsPumpSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //通过 Ids 更新缓存 |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var entity_list = dal.GetByIds(Ids); |
| | | var model_list = Entity2Models(entity_list); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | all.AddRange(model_list); |
| | | } |
| | | PumpSeriesCacheHelper.Trigger(); |
| | | AssetsPumpSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //移除缓存 |
| | |
| | | { |
| | | var all = GetCache(); |
| | | all.RemoveAll(x => x.ID == ID); |
| | | PumpSeriesCacheHelper.Trigger(); |
| | | AssetsPumpSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public static void PublishCache(string key) |
| | | { |
| | | PumpSeriesCacheHelper.Publish(key); |
| | | AssetsPumpSeriesCacheHelper.Publish(key); |
| | | } |
| | | |
| | | #endregion Cache |
| | |
| | | /// <summary> |
| | | /// 获取所有 |
| | | /// </summary> |
| | | public List<Model.PumpPartMain> GetAll() |
| | | public List<Model.AssetsPumpPartMain> GetAll() |
| | | { |
| | | var all = GetCache(); |
| | | return all; |
| | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public Model.PumpPartMain GetByID(long ID) |
| | | public Model.AssetsPumpPartMain GetByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | return all.Find(x => x.ID == ID); |
| | |
| | | /// <summary> |
| | | /// 通过 型号ID 获取 |
| | | /// </summary> |
| | | public List<Model.PumpPartMain> GetByMainID(long ID) |
| | | public List<Model.AssetsPumpPartMain> GetByMainID(long ID) |
| | | { |
| | | var idlist = PumpMainAndPartMap.GetByPumpMainID(ID); |
| | | var idlist = AssetsPumpMainAndPartMap.GetByPumpMainID(ID); |
| | | return GetByIds(idlist); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public List<Model.PumpPartMain> GetByIds(List<long> Ids) |
| | | public List<Model.AssetsPumpPartMain> GetByIds(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 插入一条数据 |
| | | /// </summary> |
| | | public long Insert(Model.PumpPartMain model) |
| | | public long Insert(Model.AssetsPumpPartMain model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var entity = Model2Entity(model); |
| | | var id = dal.Insert(entity); |
| | | if (id > 0) |
| | |
| | | /// <summary> |
| | | /// 插入多条 |
| | | /// </summary> |
| | | public bool Inserts(List<Model.PumpPartMain> list) |
| | | public bool Inserts(List<Model.AssetsPumpPartMain> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var entity_list = Model2Entities(list); |
| | | var ids = dal.InsertsR(entity_list); |
| | | if (ids != null && ids.Count > 0) |
| | |
| | | /// <summary> |
| | | /// 插入一条数据 |
| | | /// </summary> |
| | | public long InsertEX(Model.PumpPartMain part, List<Model.PumpPropContent> pumpPropContents, Model.PumpMainAndPartMap partmap) |
| | | public long InsertEX(Model.AssetsPumpPartMain part, List<Model.AssetsPumpPropContent> AssetsPumpPropContents, Model.AssetsPumpMainAndPartMap partmap) |
| | | { |
| | | if (part == null || pumpPropContents == null || partmap == null) |
| | | if (part == null || AssetsPumpPropContents == null || partmap == null) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var partentity = Model2Entity(part); |
| | | var propcontentsentity = PumpPropContent.Model2Entities(pumpPropContents); |
| | | var partmapentity = PumpMainAndPartMap.Model2Entity(partmap); |
| | | var propcontentsentity = AssetsPumpPropContent.Model2Entities(AssetsPumpPropContents); |
| | | var partmapentity = AssetsPumpMainAndPartMap.Model2Entity(partmap); |
| | | var id = dal.InsertsEx(partentity, propcontentsentity, partmapentity); |
| | | if (id > 0) |
| | | { |
| | | UpdateCache(id); |
| | | PumpPropContent.UpdateCacheByPartID(id); |
| | | PumpMainAndPartMap.UpdateCacheByPartID(id); |
| | | AssetsPumpPropContent.UpdateCacheByPartID(id); |
| | | AssetsPumpMainAndPartMap.UpdateCacheByPartID(id); |
| | | } |
| | | return id; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public bool Update(Model.PumpPartMain model) |
| | | public bool Update(Model.AssetsPumpPartMain model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return false; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var bol = dal.Update(entity); |
| | | if (bol) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 批量更新 |
| | | /// </summary> |
| | | public bool Updates(List<Model.PumpPartMain> list) |
| | | public bool Updates(List<Model.AssetsPumpPartMain> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | var entity_list = Model2Entities(list); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var bol = dal.Updates(entity_list); |
| | | if (bol) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public bool UpdateEX(Model.PumpPartMain pumppart, List<Model.PumpPropContent> pumpPropContents) |
| | | public bool UpdateEX(Model.AssetsPumpPartMain pumppart, List<Model.AssetsPumpPropContent> AssetsPumpPropContents) |
| | | { |
| | | if (pumppart == null || pumpPropContents.Count < 0) |
| | | if (pumppart == null || AssetsPumpPropContents.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); |
| | | var AssetsPumpPropContentsentity = AssetsPumpPropContent.Model2Entities(AssetsPumpPropContents); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var bol = dal.UpdateEx(pumppartentity, AssetsPumpPropContentsentity); |
| | | if (bol) |
| | | { |
| | | UpdateCache(pumppart.ID); |
| | | PumpPropContent.UpdateCache(pumpPropContentsentity.Select(x => x.ID).ToList()); |
| | | AssetsPumpPropContent.UpdateCache(AssetsPumpPropContentsentity.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var bol = dal.UpdateSortCode(ID, SortCode); |
| | | if (bol) |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var bol = dal.UpdateSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | | { |
| | |
| | | public bool DeleteByID(long ID, out string Msg) |
| | | { |
| | | Msg = string.Empty; |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var bol = dal.DeleteByID(ID); |
| | | if (bol) |
| | | { |
| | |
| | | //通过 ID 删除产品表及属性表 |
| | | public bool DeleteExByID(long ID) |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPumpPartMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPumpPartMain>(); |
| | | var partmain = dal.GetByID(ID); |
| | | var propmodellist = PumpPropContent.GetProplistByPartID(ID); |
| | | var propentitylist = PumpPropContent.Model2Entities(propmodellist); |
| | | var propmodellist = AssetsPumpPropContent.GetProplistByPartID(ID); |
| | | var propentitylist = AssetsPumpPropContent.Model2Entities(propmodellist); |
| | | var bol = dal.DeleteEx(partmain, propentitylist); |
| | | if (bol) |
| | | { |
| | | RemoveCache(ID); |
| | | PumpPropContent.RemoveCacheByIDs(propmodellist.Select(x => x.ID).ToList()); |
| | | AssetsPumpPropContent.RemoveCacheByIDs(propmodellist.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |