| | |
| | | /// <summary> |
| | | /// 图表关联 |
| | | ///</summary> |
| | | public partial class PhartDiagramRelation |
| | | public partial class PhartDiagramRelation |
| | | { |
| | | #region Cache |
| | | |
| | | //获取缓存 |
| | | private static List<Model.PhartDiagramRelation> GetCache() |
| | | { |
| | | var all = PhartDiagramRelationCacheHelper.GetSet(() => |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | var entity_list = dal.GetAll(); |
| | | var model_list = Entity2Models(entity_list); |
| | | if (model_list == null) |
| | | { |
| | | model_list = new List<Model.PhartDiagramRelation>(); |
| | | } |
| | | return model_list; |
| | | }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime); |
| | | return all; |
| | | var all = PhartDiagramRelationCacheHelper.GetSet(() => |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | var entity_list = dal.GetAll(); |
| | | var model_list = Entity2Models(entity_list); |
| | | if (model_list == null) |
| | | { |
| | | model_list = new List<Model.PhartDiagramRelation>(); |
| | | } |
| | | 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.IPhartDiagramRelation>(); |
| | | 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); |
| | | } |
| | | PhartDiagramRelationCacheHelper.Trigger(); |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | 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); |
| | | } |
| | | PhartDiagramRelationCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //通过 Ids 更新缓存 |
| | | private static void UpdateCache(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | 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); |
| | | } |
| | | PhartDiagramRelationCacheHelper.Trigger(); |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | 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); |
| | | } |
| | | PhartDiagramRelationCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //移除缓存 |
| | |
| | | /// </summary> |
| | | public static void PublishCache(string key) |
| | | { |
| | | PhartDiagramRelationCacheHelper.Publish(key); |
| | | PhartDiagramRelationCacheHelper.Publish(key); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | /// </summary> |
| | | public List<Model.PhartDiagramRelation> GetAll() |
| | | { |
| | | var all = GetCache(); |
| | | return all.OrderBy(x => x.SortCode).ToList(); |
| | | var all = GetCache(); |
| | | return all.OrderBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public Model.PhartDiagramRelation GetByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | return all.Find(x => x.ID == ID); |
| | | var all = GetAll(); |
| | | return all.Find(x => x.ID == ID); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public List<Model.PhartDiagramRelation> GetByIds(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var all = GetAll(); |
| | | return all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.SortCode).ToList(); |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var all = GetAll(); |
| | | return all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public List<Tuple<Model.PhartDiagramRelation, Yw.Model.PhartDiagram, List<Yw.Model.PhartGraph>>> GetTupleByObjectTypeAndObjectID |
| | | (string ObjectType, long ObjectID, eDiagramType? DiagramType = null, List<eGraphType> GraphTypeList = null) |
| | | { |
| | | var allRelationList = GetByObjectTypeAndObjectID(ObjectType,ObjectID); |
| | | var allRelationList = GetByObjectTypeAndObjectID(ObjectType, ObjectID); |
| | | if (allRelationList == null || allRelationList.Count < 1) |
| | | { |
| | | return default; |
| | |
| | | /// </summary> |
| | | public long Insert(Model.PhartDiagramRelation model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | 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.IPhartDiagramRelation>(); |
| | | var entity = Model2Entity(model); |
| | | var id = dal.Insert(entity); |
| | | if (id > 0) |
| | | { |
| | | UpdateCache(id); |
| | | } |
| | | return id; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool Inserts(List<Model.PhartDiagramRelation> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return false; |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | 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.IPhartDiagramRelation>(); |
| | | 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 |
| | | |
| | | #region Update |
| | | |
| | |
| | | /// </summary> |
| | | public bool Update(Model.PhartDiagramRelation model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return false; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | 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.IPhartDiagramRelation>(); |
| | | var bol = dal.Update(entity); |
| | | if (bol) |
| | | { |
| | | UpdateCache(model.ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新拓展 |
| | |
| | | /// </summary> |
| | | public bool Updates(List<Model.PhartDiagramRelation> 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.IPhartDiagramRelation>(); |
| | | 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.IPhartDiagramRelation>(); |
| | | var bol = dal.Updates(entity_list); |
| | | if (bol) |
| | | { |
| | | UpdateCache(list.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新排序码 |
| | | /// </summary> |
| | | public bool UpdateSortCode(long ID, int SortCode) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | var bol = dal.UpdateSortCode(ID, SortCode); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | var bol = dal.UpdateSortCode(ID, SortCode); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool UpdateSorter(List<Yw.Model.Sorter> sorters) |
| | | { |
| | | if (sorters == null || sorters.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | if (sorters.Exists(x => x.ID < 1)) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | var bol = dal.UpdateSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | | { |
| | | UpdateCache(sorters.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | if (sorters == null || sorters.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | if (sorters.Exists(x => x.ID < 1)) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<DAL.IPhartDiagramRelation>(); |
| | | var bol = dal.UpdateSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | | { |
| | | UpdateCache(sorters.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新 OtherName |