コード例 #1
0
        public static NodeAddStatus Add(NodeInfo node, out int newNodeID)
        {
            newNodeID = 0;
            NodeAddStatus result;

            if (Node.GetMainNodeCount() >= Ver.GetVer().NodeLimit&& node.IsShowOnMenu)
            {
                result = NodeAddStatus.ToMoreNode;
            }
            else
            {
                node.Creator    = Account.GetLoginAccount().AccountName;
                node.ChildCount = 0;
                int num = Node.ExistsNode(node.ParentID, node.NodeName, node.UrlRewriteName, "Add", 0);
                if (num > 0)
                {
                    result = (NodeAddStatus)num;
                }
                else
                {
                    if (node.ParentID > 0)
                    {
                        NodeInfo cacheNodeById = Node.GetCacheNodeById(node.ParentID);
                        if (cacheNodeById == null)
                        {
                            result = NodeAddStatus.ParentNodeNotExists;
                            return(result);
                        }
                        node.ParentPath = cacheNodeById.ParentPath + "," + cacheNodeById.AutoID.ToString();
                        node.RootID     = cacheNodeById.RootID;
                        node.Depth      = cacheNodeById.Depth + 1;
                        node.Sort       = BizBase.dbo.GetValue <int>(" SELECT max(Sort) FROM cms_Node WHERE ParentID=" + node.RootID) + 1;
                    }
                    else
                    {
                        node.ParentPath = "0";
                        node.Depth      = 1;
                        node.Sort       = BizBase.dbo.GetValue <int>(" SELECT max(Sort) FROM cms_Node WHERE ParentID=0") + 1;
                    }
                    node.Setting = XmlSerializerUtils.Serialize <NodeSetting>(node.NodeSetting);
                    newNodeID    = BizBase.dbo.InsertModel <NodeInfo>(node);
                    if (newNodeID > 0)
                    {
                        node.AutoID = newNodeID;
                        BizBase.dbo.ExecSQL(string.Concat(new object[]
                        {
                            " UPDATE cms_Node SET ChildList = '",
                            newNodeID,
                            "' WHERE AutoID=",
                            newNodeID
                        }));
                        if (node.ParentID > 0)
                        {
                            BizBase.dbo.ExecSQL(" UPDATE CMS_Node SET ChildCount = ChildCount + 1 WHERE AutoID =" + node.ParentID);
                            Node.UpdateNowParents(node, "Add");
                        }
                        else
                        {
                            BizBase.dbo.ExecSQL(string.Concat(new object[]
                            {
                                " UPDATE cms_Node SET RootID = ",
                                newNodeID,
                                " WHERE AutoID=",
                                newNodeID
                            }));
                        }
                        CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                        result = NodeAddStatus.Success;
                    }
                    else
                    {
                        CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                        result = NodeAddStatus.Error;
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        public static NodeUpdateStatus Update(NodeInfo node)
        {
            NodeInfo dataById = Node.GetDataById(node.AutoID);

            node.Setting = XmlSerializerUtils.Serialize <NodeSetting>(node.NodeSetting);
            int num = Node.ExistsNode(node.ParentID, node.NodeName, node.UrlRewriteName, "Modify", dataById.AutoID);
            NodeUpdateStatus result;

            if (num > 0)
            {
                result = (NodeUpdateStatus)num;
            }
            else if (!dataById.IsShowOnMenu && node.IsShowOnMenu && Node.GetMainNodeCount() >= Ver.GetVer().NodeLimit)
            {
                result = NodeUpdateStatus.ToMoreNode;
            }
            else if (BizBase.dbo.UpdateModel <NodeInfo>(node))
            {
                CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                result = NodeUpdateStatus.Success;
            }
            else
            {
                CacheUtils.Del("JsonLeeCMS_CacheForGetCMSNode");
                result = NodeUpdateStatus.Error;
            }
            return(result);
        }