| | |
| | | { |
| | | var all = AssetsPipeSeriesCacheHelper.GetSet(() => |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var entity_list = dal.GetAll(); |
| | | var model_list = Entity2Models(entity_list); |
| | | if (model_list == null) |
| | |
| | | //通过 ID 更新缓存 |
| | | private static void UpdateCache(long ID) |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var entity_ds = dal.GetByID(ID); |
| | | var model_ds = Entity2Model(entity_ds); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var entity_list = dal.GetByIds(Ids); |
| | | var model_list = Entity2Models(entity_list); |
| | | var all = GetCache(); |
| | |
| | | |
| | | #endregion Cache |
| | | |
| | | |
| | | |
| | | #region Query |
| | | |
| | | /// <summary> |
| | |
| | | public List<Model.AssetsPipeSeries> GetAll() |
| | | { |
| | | var all = GetCache(); |
| | | return all.OrderBy(x => x.SortCode).ToList(); |
| | | return all.OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return default; |
| | | } |
| | | var all = GetAll(); |
| | | return all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.SortCode).ToList(); |
| | | return all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取子级及自身 |
| | | /// </summary> |
| | | public List<Model.AssetsPipeSeries> GetChildAndSelfByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | var list = all.Where(x => x.ID == ID || x.ParentIds.Contains(ID)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | return list; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取子级 |
| | | /// </summary> |
| | | public List<Model.AssetsPipeSeries> GetChildrenByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | var list = all.Where(x => x.ParentIds.Contains(ID)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | return list; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取父级 |
| | | /// </summary> |
| | | public List<Model.AssetsPipeSeries> GetParentByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | var model = all.Find(x => x.ID == ID); |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | return all.Where(x => model.ParentIds.Contains(x.ID)).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取父级及自身 |
| | | /// </summary> |
| | | public List<Model.AssetsPipeSeries> GetParentAndSelfByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | var model = all.Find(x => x.ID == ID); |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | return all.Where(x => model.ParentIds.Contains(x.ID) || x.ID == ID).OrderBy(x => x.ParentIds.Count).ThenBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ParentID 获取 |
| | | /// </summary> |
| | | public List<Model.AssetsPipeSeries> GetByParentID(long ParentID) |
| | | { |
| | | var all = GetAll(); |
| | | return all.Where(x => x.ParentIds.LastOrDefault() == ParentID).OrderBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 是否包含子项 |
| | | /// </summary> |
| | | public bool HasChildren(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | return all.Exists(x => x.ParentIds.Contains(ID)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取最大排序码 |
| | | /// </summary> |
| | | public int GetMaxSortCode() |
| | | public int GetMaxSortCode(long ParentID) |
| | | { |
| | | var all = GetAll(); |
| | | if (all == null || all.Count < 1) |
| | | List<Model.AssetsPipeSeries> list = null; |
| | | if (ParentID < 1) |
| | | { |
| | | list = GetAll(); |
| | | list = list?.Where(x => x.ParentIds.Count < 1).ToList(); |
| | | } |
| | | else |
| | | { |
| | | list = GetByParentID(ParentID); |
| | | } |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return 0; |
| | | } |
| | | return all.Max(x => x.SortCode); |
| | | return list.Max(x => x.SortCode); |
| | | } |
| | | |
| | | #endregion Query |
| | | |
| | | |
| | | |
| | | #region Insert |
| | | |
| | |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var entity = Model2Entity(model); |
| | | var id = dal.Insert(entity); |
| | | if (id > 0) |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var entity_list = Model2Entities(list); |
| | | var ids = dal.InsertsR(entity_list); |
| | | if (ids != null && ids.Count > 0) |
| | |
| | | } |
| | | |
| | | #endregion Insert |
| | | |
| | | |
| | | |
| | | #region Update |
| | | |
| | |
| | | return false; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.Update(entity); |
| | | if (bol) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | var entity_list = Model2Entities(list); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.Updates(entity_list); |
| | | if (bol) |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateSortCode(ID, SortCode); |
| | | if (bol) |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | | { |
| | | UpdateCache(sorters.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新树排序码 |
| | | /// </summary> |
| | | public bool UpdateTreeSortCode(long ID, List<long> ParentIds, int SortCode) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateTreeSortCode(ID, TreeParentIdsHelper.ToString(ParentIds), SortCode); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新树排序 |
| | | /// </summary> |
| | | public bool UpdateTreeSorter(List<Yw.Model.TreeSorter> sorters) |
| | | { |
| | | if (sorters == null || sorters.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | if (sorters.Exists(x => x.ID < 1)) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateTreeSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | | { |
| | | UpdateCache(sorters.Select(x => x.ID).ToList()); |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateParas(ID, ParasHelper.ToString(Paras)); |
| | | if (bol) |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateFlags(ID, FlagsHelper.ToString(Flags)); |
| | | if (bol) |
| | | { |
| | |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.UpdateTagName(ID, TagName); |
| | | if (bol) |
| | | { |
| | |
| | | } |
| | | |
| | | #endregion Update |
| | | |
| | | |
| | | |
| | | #region Exist |
| | | |
| | |
| | | |
| | | #endregion Exist |
| | | |
| | | |
| | | |
| | | #region Delete |
| | | |
| | | /// <summary> |
| | |
| | | public bool DeleteByID(long ID, out string Msg) |
| | | { |
| | | Msg = string.Empty; |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IPipeLineSeries>(); |
| | | if (HasChildren(ID)) |
| | | { |
| | | Msg = "存在子级,请删除后重试!"; |
| | | return false; |
| | | } |
| | | var serviceMain = new AssetsPipeMain(); |
| | | if (serviceMain.IsExistBySeriesID(ID)) |
| | | { |
| | | Msg = "存在型号信息,请删除后重试!"; |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsPipeSeries>(); |
| | | var bol = dal.DeleteByID(ID); |
| | | if (bol) |
| | | { |