copy from Service/HStation.Service.Assets.Core/05-service/08-FourLink/01-FourlinkMain/FourLinkManage.cs
copy to Service/HStation.Service.Assets.Core/05-service/04-FourLink/03-AssetsFourCoefficient/AssetsFourlinkCoefficient.cs
Îļþ´Ó Service/HStation.Service.Assets.Core/05-service/08-FourLink/01-FourlinkMain/FourLinkManage.cs ¸´ÖÆ |
| | |
| | | using HStation.Assets; |
| | | |
| | | namespace HStation.Service |
| | | namespace HStation.Service |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class AssetsFourlinkMain |
| | | public partial class AssetsFourlinkCoefficient |
| | | { |
| | | #region Cache |
| | | |
| | | //è·åç¼å |
| | | private static List<Model.AssetsFourlinkMain> GetCache() |
| | | private static List<Model.AssetsFourlinkCoefficient> GetCache() |
| | | { |
| | | var all = AssetsFourlinkMainCacheHelper.GetSet(() => |
| | | var all = AssetsFourlinkCoefficientCacheHelper.GetSet(() => |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var entity_list = dal.GetAll(); |
| | | var model_list = Entity2Models(entity_list); |
| | | if (model_list == null) |
| | | { |
| | | model_list = new List<Model.AssetsFourlinkMain>(); |
| | | model_list = new List<Model.AssetsFourlinkCoefficient>(); |
| | | } |
| | | return model_list; |
| | | }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime); |
| | |
| | | //éè¿ ID æ´æ°ç¼å |
| | | private static void UpdateCache(long ID) |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var entity_ds = dal.GetByID(ID); |
| | | var model_ds = Entity2Model(entity_ds); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | model.Reset(model_ds); |
| | | } |
| | | AssetsPumpSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //éè¿ Ids æ´æ°ç¼å |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var entity_list = dal.GetByIds(Ids); |
| | | var model_list = Entity2Models(entity_list); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | all.AddRange(model_list); |
| | | } |
| | | AssetsPumpSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //ç§»é¤ç¼å |
| | |
| | | { |
| | | var all = GetCache(); |
| | | all.RemoveAll(x => x.ID == ID); |
| | | AssetsPumpSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //ç§»é¤ææç¼å |
| | | private static void RemoveAllCache() |
| | | { |
| | | var all = GetCache(); |
| | | all.Clear(); |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public static void PublishCache(string key) |
| | | { |
| | | AssetsPumpSeriesCacheHelper.Publish(key); |
| | | AssetsFourlinkSeriesCacheHelper.Publish(key); |
| | | } |
| | | |
| | | #endregion Cache |
| | |
| | | /// <summary> |
| | | /// è·åææ |
| | | /// </summary> |
| | | public List<Model.AssetsFourlinkMain> GetAll() |
| | | public List<Model.AssetsFourlinkCoefficient> GetAll() |
| | | { |
| | | var all = GetCache(); |
| | | return all; |
| | |
| | | /// <summary> |
| | | /// éè¿ ID è·å |
| | | /// </summary> |
| | | public Model.AssetsFourlinkMain GetByID(long ID) |
| | | public Model.AssetsFourlinkCoefficient GetByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | return all.Find(x => x.ID == ID); |
| | |
| | | /// <summary> |
| | | /// éè¿ ID è·å |
| | | /// </summary> |
| | | public List<Model.AssetsFourlinkMain> GetByIds(List<long> Ids) |
| | | public List<Model.AssetsFourlinkCoefficient> GetByIds(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | |
| | | return all.Where(x => Ids.Contains(x.ID)).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éè¿ ç³»åID è·å |
| | | /// </summary> |
| | | public List<Model.AssetsFourlinkMain> GetBySeriesID(long id) |
| | | { |
| | | if (id < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var all = GetAll(); |
| | | return all.Where(x => x.SeriesID == id).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 |
| | | |
| | | #region Insert |
| | |
| | | /// <summary> |
| | | /// æå
¥ä¸æ¡æ°æ® |
| | | /// </summary> |
| | | public long Insert(Model.AssetsFourlinkMain model) |
| | | public long Insert(Model.AssetsFourlinkCoefficient model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var entity = Model2Entity(model); |
| | | var id = dal.Insert(entity); |
| | | if (id > 0) |
| | |
| | | /// <summary> |
| | | /// æå
¥å¤æ¡ |
| | | /// </summary> |
| | | public bool Inserts(List<Model.AssetsFourlinkMain> list) |
| | | public bool Inserts(List<Model.AssetsFourlinkCoefficient> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var entity_list = Model2Entities(list); |
| | | var ids = dal.InsertsR(entity_list); |
| | | if (ids != null && ids.Count > 0) |
| | |
| | | /// <summary> |
| | | /// æ´æ°ä¸æ¡ |
| | | /// </summary> |
| | | public bool Update(Model.AssetsFourlinkMain model) |
| | | public bool Update(Model.AssetsFourlinkCoefficient model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return false; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var bol = dal.Update(entity); |
| | | if (bol) |
| | | { |
| | | UpdateCache(model.ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°é»è®¤å¼ç¶æ |
| | | /// </summary> |
| | | public bool UpdateDefaultStatus(long ID, bool Status) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var model = GetByID(ID); |
| | | model.IsDefault = Status; |
| | | var entity = Model2Entity(model); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var bol = dal.Update(entity); |
| | | if (bol) |
| | | { |
| | |
| | | /// <summary> |
| | | /// æ¹éæ´æ° |
| | | /// </summary> |
| | | public bool Updates(List<Model.AssetsFourlinkMain> list) |
| | | public bool Updates(List<Model.AssetsFourlinkCoefficient> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | var entity_list = Model2Entities(list); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var bol = dal.Updates(entity_list); |
| | | if (bol) |
| | | { |
| | |
| | | public bool DeleteByID(long ID, out string Msg) |
| | | { |
| | | Msg = string.Empty; |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkMain>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var bol = dal.DeleteByID(ID); |
| | | if (bol) |
| | | { |
| | |
| | | return bol; |
| | | } |
| | | |
| | | public bool DeleteAll() |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var bol = dal.DeleteAll(); |
| | | if (bol) |
| | | { |
| | | RemoveAllCache(); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | #endregion Delete |
| | | } |
| | | } |