From ca1ccd0dd9f2d6936368f07d14a2b29b309fd151 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期三, 04 十二月 2024 15:59:25 +0800 Subject: [PATCH] 增加单独匹配界面 --- Service/HStation.Service.Assets.Core/05-service/14-Bluntead/03-BluneteadCoefficient/AssetsBluntheadCoefficient.cs | 277 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 150 insertions(+), 127 deletions(-) diff --git a/Service/HStation.Service.Assets.Core/05-service/14-Bluntead/03-BluneteadCoefficient/AssetsBluntheadCoefficient.cs b/Service/HStation.Service.Assets.Core/05-service/14-Bluntead/03-BluneteadCoefficient/AssetsBluntheadCoefficient.cs index 6532185..221dde1 100644 --- a/Service/HStation.Service.Assets.Core/05-service/14-Bluntead/03-BluneteadCoefficient/AssetsBluntheadCoefficient.cs +++ b/Service/HStation.Service.Assets.Core/05-service/14-Bluntead/03-BluneteadCoefficient/AssetsBluntheadCoefficient.cs @@ -3,73 +3,73 @@ namespace HStation.Service { /// <summary> - /// - ///</summary> - public partial class AssetsBluntheadCoefficient + /// + ///</summary> + public partial class AssetsBluntheadCoefficient { #region Cache //鑾峰彇缂撳瓨 private static List<Model.AssetsBluntheadCoefficient> GetCache() { - var all = AssetsBluntheadCoefficientCacheHelper.GetSet(() => - { - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var entity_list = dal.GetAll(); - var model_list = Entity2Models(entity_list); - if (model_list == null) - { - model_list = new List<Model.AssetsBluntheadCoefficient>(); - } - return model_list; - }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime); - return all; + var all = AssetsBluntheadCoefficientCacheHelper.GetSet(() => + { + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var entity_list = dal.GetAll(); + var model_list = Entity2Models(entity_list); + if (model_list == null) + { + model_list = new List<Model.AssetsBluntheadCoefficient>(); + } + return model_list; + }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime); + return all; } //閫氳繃 ID 鏇存柊缂撳瓨 private static void UpdateCache(long ID) { - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var entity_ds = dal.GetByID(ID); - var model_ds = Entity2Model(entity_ds); - var all = GetCache(); - var model = all.Find(x => x.ID == ID); - if (model == null) - { - all.Add(model_ds); - } - else - { - model.Reset(model_ds); - } - AssetsBluntheadCoefficientCacheHelper.Trigger(); + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var entity_ds = dal.GetByID(ID); + var model_ds = Entity2Model(entity_ds); + var all = GetCache(); + var model = all.Find(x => x.ID == ID); + if (model == null) + { + all.Add(model_ds); + } + else + { + model.Reset(model_ds); + } + AssetsBluntheadCoefficientCacheHelper.Trigger(); } //閫氳繃 Ids 鏇存柊缂撳瓨 private static void UpdateCache(List<long> Ids) { - if (Ids == null || Ids.Count < 1) - { - return; - } - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var entity_list = dal.GetByIds(Ids); - var model_list = Entity2Models(entity_list); - var all = GetCache(); - all.RemoveAll(x => Ids.Contains(x.ID)); - if (model_list != null && model_list.Count > 0) - { - all.AddRange(model_list); - } - AssetsBluntheadCoefficientCacheHelper.Trigger(); + if (Ids == null || Ids.Count < 1) + { + return; + } + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var entity_list = dal.GetByIds(Ids); + var model_list = Entity2Models(entity_list); + var all = GetCache(); + all.RemoveAll(x => Ids.Contains(x.ID)); + if (model_list != null && model_list.Count > 0) + { + all.AddRange(model_list); + } + AssetsBluntheadCoefficientCacheHelper.Trigger(); } //绉婚櫎缂撳瓨 private static void RemoveCache(long ID) { - var all = GetCache(); - all.RemoveAll(x => x.ID == ID); - AssetsBluntheadCoefficientCacheHelper.Trigger(); + var all = GetCache(); + all.RemoveAll(x => x.ID == ID); + AssetsBluntheadCoefficientCacheHelper.Trigger(); } /// <summary> @@ -77,10 +77,20 @@ /// </summary> public static void PublishCache(string key) { - AssetsBluntheadCoefficientCacheHelper.Publish(key); + AssetsBluntheadCoefficientCacheHelper.Publish(key); } - #endregion + //绉婚櫎鎵�鏈夌紦瀛� + private static void RemoveAllCache() + { + var all = GetCache(); + all.Clear(); + AssetsBluntheadCoefficientCacheHelper.Trigger(); + } + + #endregion Cache + + #region Query @@ -89,8 +99,8 @@ /// </summary> public List<Model.AssetsBluntheadCoefficient> GetAll() { - var all = GetCache(); - return all.ToList(); + var all = GetCache(); + return all.ToList(); } /// <summary> @@ -98,8 +108,8 @@ /// </summary> public Model.AssetsBluntheadCoefficient GetByID(long ID) { - var all = GetAll(); - return all.Find(x => x.ID == ID); + var all = GetAll(); + return all.Find(x => x.ID == ID); } /// <summary> @@ -107,15 +117,17 @@ /// </summary> public List<Model.AssetsBluntheadCoefficient> GetByIds(List<long> Ids) { - if (Ids == null || Ids.Count < 1) - { - return default; - } - var all = GetAll(); - return all.Where(x => Ids.Contains(x.ID)).ToList(); + if (Ids == null || Ids.Count < 1) + { + return default; + } + var all = GetAll(); + return all.Where(x => Ids.Contains(x.ID)).ToList(); } - #endregion + #endregion Query + + #region Insert @@ -124,18 +136,18 @@ /// </summary> public long Insert(Model.AssetsBluntheadCoefficient model) { - if (model == null) - { - return default; - } - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var entity = Model2Entity(model); - var id = dal.Insert(entity); - if (id > 0) - { - UpdateCache(id); - } - return id; + if (model == null) + { + return default; + } + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var entity = Model2Entity(model); + var id = dal.Insert(entity); + if (id > 0) + { + UpdateCache(id); + } + return id; } /// <summary> @@ -143,22 +155,22 @@ /// </summary> public bool Inserts(List<Model.AssetsBluntheadCoefficient> list) { - if (list == null || list.Count < 1) - { - return false; + if (list == null || list.Count < 1) + { + return false; } - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var entity_list = Model2Entities(list); - var ids = dal.InsertsR(entity_list); - if (ids != null && ids.Count > 0) - { - UpdateCache(ids); - return true; - } - return false; + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var entity_list = Model2Entities(list); + var ids = dal.InsertsR(entity_list); + if (ids != null && ids.Count > 0) + { + UpdateCache(ids); + return true; + } + return false; } - - #endregion + + #endregion Insert #region Update @@ -167,18 +179,18 @@ /// </summary> public bool Update(Model.AssetsBluntheadCoefficient model) { - if (model == null) - { - return false; - } - var entity = Model2Entity(model); - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var bol = dal.Update(entity); - if (bol) - { - UpdateCache(model.ID); - } - return bol; + if (model == null) + { + return false; + } + var entity = Model2Entity(model); + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var bol = dal.Update(entity); + if (bol) + { + UpdateCache(model.ID); + } + return bol; } /// <summary> @@ -186,26 +198,25 @@ /// </summary> public bool Updates(List<Model.AssetsBluntheadCoefficient> list) { - if (list == null || list.Count < 1) - { - return false; - } - if (list.Exists(x => x.ID < 1)) - { - return false; - } - var entity_list = Model2Entities(list); - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var bol = dal.Updates(entity_list); - if (bol) - { - UpdateCache(list.Select(x => x.ID).ToList()); - } - return bol; + if (list == null || list.Count < 1) + { + return false; + } + if (list.Exists(x => x.ID < 1)) + { + return false; + } + var entity_list = Model2Entities(list); + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var bol = dal.Updates(entity_list); + if (bol) + { + UpdateCache(list.Select(x => x.ID).ToList()); + } + return bol; } - - #endregion + #endregion Update #region Delete @@ -214,18 +225,30 @@ /// </summary> public bool DeleteByID(long ID, out string Msg) { - Msg = string.Empty; - var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); - var bol = dal.DeleteByID(ID); - if (bol) - { - RemoveCache(ID); - } - return bol; + Msg = string.Empty; + var dal = DALCreateHelper.CreateDAL<DAL.IAssetsBluntheadCoefficient>(); + var bol = dal.DeleteByID(ID); + if (bol) + { + RemoveCache(ID); + } + return bol; } - - #endregion - - + + /// <summary> + /// 鍒犻櫎鍏ㄩ儴 + /// </summary> + public bool DeleteAll() + { + var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsBluntheadCoefficient>(); + var bol = dal.DeleteAll(); + if (bol) + { + RemoveAllCache(); + } + return bol; + } + + #endregion Delete } } \ No newline at end of file -- Gitblit v1.9.3