/// <summary> /// 获取根节点信息,不包含扩展信息 /// </summary> /// <param name="parentPath">父节点路径(0,1,2,3)</param> /// <returns></returns> public NodesEntity GetRootNodeByParentPath(string parentPath) { if (!string.IsNullOrEmpty(parentPath)) { string[] strArray = parentPath.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strArray.Length; i++) { int nodeId = DataConverter.CLng(strArray[i]); if (nodeId > 0) { NodesEntity cacheNodeById = GetCacheNodeById(nodeId); if (cacheNodeById.ParentID == 0) { return(cacheNodeById); } } } } return(new NodesEntity()); }
/// <summary> /// 获取所有的节点列表(包含容器栏目、专题栏目、单页节点和外链),并添加 '所有栏目'为根节点 /// </summary> /// <param name="nodeType">节点类型</param> /// <param name="isShowArchiving">是否显示归档类型的节点</param> /// <param name="isAddAll">是否添加'所有栏目'为根节点</param> /// <returns></returns> public IList <NodesEntity> GetNodeList(NodeType nodeType = NodeType.None, bool isShowArchiving = false, bool isAddAll = false) { Expression <Func <NodesEntity, bool> > predicate = p => true; if (nodeType != NodeType.None) { predicate = predicate.And(p => p.NodeType == (int)nodeType); } if (!isShowArchiving) { predicate = predicate.And(p => p.PurviewType != 3); } SortModelField sortModelField1 = new SortModelField() { SortName = "RootID", IsDESC = false }; SortModelField sortModelField2 = new SortModelField() { SortName = "OrderSort", IsDESC = false }; SortModelField[] orderByExpression = new SortModelField[2]; orderByExpression[0] = sortModelField1; orderByExpression[1] = sortModelField2; IList <NodesEntity> nodesList = LoadListAll(predicate, orderByExpression); if (isAddAll) { NodesEntity item = new NodesEntity(); item.NodeName = "所有栏目"; item.NodeID = -1; item.Depth = 0; item.ParentPath = "0"; item.NextID = 0; item.Child = 0; item.NodeType = (int)(NodeType.Container); item.NodeDir = ""; nodesList.Insert(0, item); } return(nodesList); }