⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nodes.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 3 页
字号:
            RemoveCacheAllNodeInfo();
        }

        public static void RemoveCacheAllNodeInfo()
        {
            SiteCache.RemoveByPattern(@"CK_Content_NodeInfo_NodeId_\S*");
        }

        public static void RemoveCacheByNodeId(int nodeId)
        {
            SiteCache.Remove("CK_Content_NodeInfo_NodeId_" + nodeId.ToString());
        }

        public static int ResetChildNodes(int nodeId)
        {
            NodeInfo cacheNodeById = GetCacheNodeById(nodeId);
            if (cacheNodeById.IsNull || (cacheNodeById.ParentId != 0))
            {
                return 1;
            }
            IList<NodeInfo> nodesListInArrChildId = GetNodesListInArrChildId(cacheNodeById.ArrChildId);
            nodesListInArrChildId.Remove(cacheNodeById);
            int num = 0;
            int count = 0;
            count = nodesListInArrChildId.Count;
            foreach (NodeInfo info2 in nodesListInArrChildId)
            {
                if (num == 0)
                {
                    info2.PrevId = 0;
                }
                else
                {
                    info2.PrevId = nodesListInArrChildId[num - 1].NodeId;
                }
                if (num == (count - 1))
                {
                    info2.NextId = 0;
                }
                else
                {
                    info2.NextId = nodesListInArrChildId[num + 1].NodeId;
                }
                info2.NodeDir = info2.ParentDir.Replace("/", "") + info2.NodeDir;
                info2.RootId = cacheNodeById.RootId;
                num++;
                info2.OrderId = num;
                info2.ParentId = cacheNodeById.NodeId;
                info2.Child = 0;
                info2.ArrChildId = info2.NodeId.ToString();
                info2.ParentPath = "0," + cacheNodeById.NodeId.ToString();
                info2.Depth = cacheNodeById.Depth + 1;
                info2.ParentDir = cacheNodeById.ParentDir + cacheNodeById.NodeDir + info2.NodeDir;
                Update(info2);
            }
            cacheNodeById.Child = count;
            Update(cacheNodeById);
            return 0;
        }

        public static void ResetNodes()
        {
            int num = 0;
            int count = 0;
            IList<NodeInfo> nodesList = GetNodesList();
            count = nodesList.Count;
            foreach (NodeInfo info in nodesList)
            {
                if (num == 0)
                {
                    info.PrevId = 0;
                }
                else
                {
                    info.PrevId = nodesList[num - 1].NodeId;
                }
                if (num == (count - 1))
                {
                    info.NextId = 0;
                }
                else
                {
                    info.NextId = nodesList[num + 1].NodeId;
                }
                info.RootId = num + 1;
                info.OrderId = 0;
                info.ParentId = 0;
                info.Child = 0;
                info.ArrChildId = info.NodeId.ToString();
                info.ParentPath = "0";
                info.Depth = 0;
                info.ParentDir = "/";
                num++;
                Update(info);
            }
            RemoveCacheAllNodeInfo();
        }

        public static string ResolveUploadDir(NodeInfo nodeInfo, string uploadFilePathRule)
        {
            uploadFilePathRule = uploadFilePathRule.Replace("{$NodeDir}", nodeInfo.NodeDir);
            uploadFilePathRule = uploadFilePathRule.Replace("{$ParentDir}", nodeInfo.ParentDir);
            uploadFilePathRule = uploadFilePathRule.Replace("{$NodeIdentifier}", nodeInfo.NodeIdentifier);
            if (nodeInfo.ParentDir.Contains(","))
            {
                string[] strArray = nodeInfo.ParentDir.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                uploadFilePathRule = uploadFilePathRule.Replace("{$RootDir}", GetCacheNodeById(DataConverter.CLng(strArray[1])).NodeDir);
                return uploadFilePathRule;
            }
            uploadFilePathRule = uploadFilePathRule.Replace("{$RootDir}", nodeInfo.NodeDir);
            return uploadFilePathRule;
        }

        public static string ShowNodeNavigation(int nodeId)
        {
            return ShowNodeNavigation(nodeId, 0, "");
        }

        public static string ShowNodeNavigation(int nodeId, string navigation)
        {
            return ShowNodeNavigation(nodeId, 0, navigation);
        }

        private static string ShowNodeNavigation(int nodeId, int type, string navigation)
        {
            if (string.IsNullOrEmpty(navigation))
            {
                navigation = "ContentManage.aspx";
            }
            NodeInfo cacheNodeById = GetCacheNodeById(nodeId);
            if (cacheNodeById.IsNull)
            {
                return string.Empty;
            }
            IList<NodeInfo> nodesListInParentPath = GetNodesListInParentPath(cacheNodeById.ParentPath);
            StringBuilder builder = new StringBuilder();
            if (nodesListInParentPath.Count <= 0)
            {
                builder.Append("根节点");
            }
            else
            {
                foreach (NodeInfo info2 in nodesListInParentPath)
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(" >> ");
                    }
                    if (type == 0)
                    {
                        builder.Append(string.Concat(new object[] { "<a href='", navigation, "?NodeID=", info2.NodeId, "&NodeName=", DataSecurity.UrlEncode(info2.NodeName), "'>" }));
                        builder.Append(info2.NodeName);
                        builder.Append("</a>");
                        continue;
                    }
                    builder.Append(info2.NodeName);
                }
            }
            if ((type == 0) || (type == 2))
            {
                if (builder.Length > 0)
                {
                    builder.Append(" >> ");
                }
                builder.Append(cacheNodeById.NodeName);
            }
            return builder.ToString();
        }

        public static string ShowNodesAndRootNavigation(int nodeId)
        {
            return ShowNodeNavigation(nodeId, 2, "");
        }

        public static string ShowParentNodesNavigation(int nodeId)
        {
            return ShowNodeNavigation(nodeId, 1, "");
        }

        private static void UpateNodeStructure(int parentId, int depth, string parentPath, string parentDir)
        {
            if (string.IsNullOrEmpty(parentPath))
            {
                parentPath = parentId.ToString();
            }
            else
            {
                parentPath = parentPath + "," + parentId.ToString();
            }
            IList<NodeInfo> nodesListByParentId = GetNodesListByParentId(parentId);
            NodeInfo cacheNodeById = GetCacheNodeById(parentId);
            cacheNodeById.Child = nodesListByParentId.Count;
            cacheNodeById.OrderId = orderId;
            cacheNodeById.ArrChildId = parentId.ToString();
            Update(cacheNodeById);
            int num = 0;
            foreach (NodeInfo info2 in nodesListByParentId)
            {
                orderId++;
                info2.OrderId = orderId;
                info2.Depth = depth;
                info2.ParentPath = parentPath;
                if (info2.NodeType == NodeType.Container)
                {
                    info2.ParentDir = parentDir;
                }
                if (num == 0)
                {
                    info2.PrevId = 0;
                }
                else
                {
                    info2.PrevId = nodesListByParentId[num - 1].NodeId;
                }
                if (num == (nodesListByParentId.Count - 1))
                {
                    info2.NextId = 0;
                }
                else
                {
                    info2.NextId = nodesListByParentId[num + 1].NodeId;
                }
                info2.ArrChildId = info2.NodeId.ToString();
                Update(info2);
                UpateNodeStructure(info2.NodeId, info2.Depth + 1, info2.ParentPath, VirtualPathUtility.AppendTrailingSlash(info2.ParentDir) + info2.NodeDir + "/");
                num++;
            }
            UpdateArrChildStructure(nodesListByParentId);
        }

        public static int Update(NodeInfo nodeInfo)
        {
            NodeInfo cacheNodeById = GetCacheNodeById(nodeInfo.NodeId);
            if ((nodeInfo.NodeName != cacheNodeById.NodeName) && ExistsNodeName(nodeInfo.ParentId, nodeInfo.NodeName))
            {
                return 2;
            }
            if ((nodeInfo.NodeIdentifier != cacheNodeById.NodeIdentifier) && ExistsNodeIdentifier(nodeInfo.ParentId, nodeInfo.NodeIdentifier))
            {
                return 3;
            }
            if (dal.Update(nodeInfo))
            {
                RemoveCacheByNodeId(nodeInfo.NodeId);
                return 1;
            }
            return 0;
        }

        public static int Update(NodeInfo nodeInfo, IList<NodesModelTemplateRelationShipInfo> infoList)
        {
            int num = Update(nodeInfo);
            if (num == 1)
            {
                ModelManager.UpdateNodesModelTemplateRelationShip(nodeInfo.NodeId, infoList);
            }
            return num;
        }

        public static bool UpdateArrChildId(int nodeId, string arrChildId)
        {
            RemoveCacheAllNodeInfo();
            return dal.UpdateArrChildId(nodeId, arrChildId);
        }

        private static void UpdateArrChildStructure(IList<NodeInfo> nodeList)
        {
            foreach (NodeInfo info in nodeList)
            {
                foreach (NodeInfo info2 in GetNodesListInArrChildId(info.ParentPath))
                {
                    info2.ArrChildId = info2.ArrChildId + "," + info.NodeId.ToString();
                    UpdateArrChildId(info2.NodeId, info2.ArrChildId);
                }
            }
        }

        public static bool UpdateChild(int parentId)
        {
            RemoveCacheAllNodeInfo();
            return dal.UpdateChild(parentId);
        }

        public static bool UpdateChild(int nodeId, int child)
        {
            RemoveCacheAllNodeInfo();
            return dal.UpdateChild(nodeId, child);
        }

        public static bool UpdateChildPurview(int nodeId, int purviewType)
        {
            bool flag = true;
            NodeInfo cacheNodeById = GetCacheNodeById(nodeId);
            if (!DataValidator.IsValidId(cacheNodeById.ArrChildId))
            {
                return false;
            }
            if ((purviewType == 1) || (purviewType == 2))
            {
                flag = dal.UpdateChildPurview(cacheNodeById.ArrChildId, purviewType);
            }
            RemoveCacheAllNodeInfo();
            return flag;
        }

        private static bool UpdateNextId(int nodeId, int nextId)
        {
            RemoveCacheByNodeId(nodeId);
            return dal.UpdateNextId(nodeId, nextId);
        }

        public static bool UpdateNodePurviewType(int nodeId)
        {
            bool flag = true;
            NodeInfo cacheNodeById = GetCacheNodeById(nodeId);
            int maxPurviewTypeInParentPath = GetMaxPurviewTypeInParentPath(cacheNodeById.NodeId);
            if (cacheNodeById.PurviewType < maxPurviewTypeInParentPath)
            {
                flag = dal.UpdateNodePurviewType(cacheNodeById.NodeId, maxPurviewTypeInParentPath);
            }
            RemoveCacheAllNodeInfo();
            return flag;
        }

        public static bool UpdateOrderId(int nodeId, int orderId)
        {
            RemoveCacheByNodeId(nodeId);
            return dal.UpdateOrderId(nodeId, orderId);
        }

        public static bool UpdateOrderId(int rootId, int orderId, int addNum)
        {
            RemoveCacheAllNodeInfo();
            return dal.UpdateOrderId(rootId, orderId, addNum);
        }

        private static bool UpdateRootId(string nodeId, int rootId)
        {
            return dal.UpdateRootId(nodeId, rootId);
        }

        public static string UploadPathParse(NodeInfo nodeInfo, string fileName)
        {
            string uploadFilePathRule = SiteConfig.SiteOption.UploadFilePathRule;
            return ((ResolveUploadDir(nodeInfo, uploadFilePathRule).Replace("{$FileType}", Path.GetExtension(fileName).ToLower().Replace(".", "")).Replace("{$Year}", DateTime.Now.Year.ToString()).Replace("{$Month}", DateTime.Now.Month.ToString()) + "/").Replace("{$Day}", DateTime.Now.Day.ToString()) + "/").Replace("//", "/");
        }

        public static string WriteMessageByErrorNum(int errorNum)
        {
            switch (errorNum)
            {
                case 0:
                    return "";

                case 1:
                    return "找不到指定的节点或者已经被删除!";

                case 2:
                    return "要移动节点和目标节点相同,无需移动!";

                case 3:
                    return "目标节点与当前父节点相同,无需移动!";

                case 4:
                    return "不能指定外部节点为所属节点!";

                case 5:
                    return "不能指定该节点的下属节点作为所属节点!";

                case 6:
                    return "目标节点的子节点中已经存在与此节点名称相同的节点,不能移动!";

                case 7:
                    return "目标节点的子节点中是否已经存在与此节点目录相同的节点,不能移动!";
            }
            return "节点移动失败!";
        }

        public static string WriteNodesUniteMessage(int errorType)
        {
            switch (errorType)
            {
                case 0:
                    return "";

                case 1:
                    return "未指定要合并的节点!";

                case 2:
                    return "未指定目标节点!";

                case 3:
                    return "要合并的节点与目标节点相同,请不要在相同节点内进行操作!";

                case 4:
                    return "目标节点不存在,可能已经被删除!";

                case 5:
                    return "目标节点中含有子节点,不能合并!";

                case 6:
                    return "目标节点是专题、单个页面或外部节点!";

                case 7:
                    return "找不到指定的节点,可能已经被删除!";

                case 8:
                    return "不能将一个节点合并到其下属子节点中!";
            }
            return "节点合并失败!";
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -