当前位置: 首页>>代码示例>>C#>>正文


C# TreeProvider.MoveNodeUp方法代码示例

本文整理汇总了C#中TreeProvider.MoveNodeUp方法的典型用法代码示例。如果您正苦于以下问题:C# TreeProvider.MoveNodeUp方法的具体用法?C# TreeProvider.MoveNodeUp怎么用?C# TreeProvider.MoveNodeUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeProvider的用法示例。


在下文中一共展示了TreeProvider.MoveNodeUp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MoveDocumentUp

    /// <summary>
    /// Moves a document up in the content tree. Called when the "Move document up" button is pressed.
    /// Expects the "CreateDocumentStructure" method to be run first.
    /// </summary>
    private bool MoveDocumentUp()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Select a node
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/Document-2", "en-us");

        if (node != null)
        {
            // Move the node up
            tree.MoveNodeUp(node.NodeID);

            return true;
        }

        return false;
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:22,代码来源:Default.aspx.cs

示例2: RaisePostBackEvent

    public void RaisePostBackEvent(string eventArgument)
    {
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Current Node ID
        int nodeId = ValidationHelper.GetInteger(Param1, 0);

        TreeProvider tree = new TreeProvider(currentUser);
        EventLogProvider log = new EventLogProvider();

        string documentName = string.Empty;
        string action = Action.ToLower();
        string siteName = CMSContext.CurrentSiteName;

        // Process the request
        switch (action)
        {
            case "refresh":
                treeContent.NodeID = nodeId;
                AddScript("currentNodeId = " + nodeId + ";\n");

                break;

            case "moveup":
            case "movedown":
            case "movetop":
            case "movebottom":
                // Move the document up (document order)
                try
                {
                    if (nodeId == 0)
                    {
                        AddAlert(GetString("ContentRequest.ErrorMissingSource"));
                        return;
                    }

                    // Get document to move
                    TreeNode node = tree.SelectSingleNode(nodeId);

                    // Check the permissions for document
                    if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)
                    {
                        switch (action)
                        {
                            case "moveup":
                                node = tree.MoveNodeUp(nodeId);
                                break;

                            case "movedown":
                                node = tree.MoveNodeDown(nodeId);
                                break;

                            case "movetop":
                                node = tree.SelectSingleNode(nodeId);
                                tree.SetNodeOrder(nodeId, DocumentOrderEnum.First);
                                break;

                            case "movebottom":
                                node = tree.SelectSingleNode(nodeId);
                                tree.SetNodeOrder(nodeId, DocumentOrderEnum.Last);
                                break;
                        }

                        if (node != null)
                        {
                            // Log the synchronization tasks for the entire tree level
                            if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges"))
                            {
                                // Log the synchronization tasks for the entire tree level
                                DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, node.NodeAliasPath, tree);
                            }

                            // Select the document in the tree
                            documentName = node.DocumentName;

                            treeContent.ExpandNodeID = node.NodeParentID;
                            treeContent.NodeID = node.NodeID;
                            AddScript("currentNodeId = " + node.NodeID + ";\n");
                        }
                        else
                        {
                            AddAlert(GetString("ContentRequest.MoveFailed"));
                        }
                    }
                    else
                    {
                        // Select the document in the tree
                        treeContent.NodeID = nodeId;

                        AddAlert(GetString("ContentRequest.MoveDenied"));
                    }
                }
                catch (Exception ex)
                {
                    log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.GetUserHostAddress(), EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri());
                    AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message);
                }
                break;

            case "setculture":
//.........这里部分代码省略.........
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:101,代码来源:Tree.aspx.cs

示例3: RaisePostBackEvent

    public void RaisePostBackEvent(string eventArgument)
    {
        var currentUser = MembershipContext.AuthenticatedUser;

        // Current Node ID
        int nodeId = ValidationHelper.GetInteger(Param1, 0);

        TreeProvider tree = new TreeProvider(currentUser);

        string documentName = string.Empty;
        string action = Action.ToLowerCSafe();
        string siteName = SiteContext.CurrentSiteName;

        // Process the request
        switch (action)
        {
            case "refresh":
                treeElem.SelectedNodeID = nodeId;
                AddScript("currentNodeId = " + nodeId + ";");
                break;

            case "moveup":
            case "movedown":
            case "movetop":
            case "movebottom":
                // Move the document up (document order)
                try
                {
                    if (nodeId == 0)
                    {
                        AddAlert(GetString("ContentRequest.ErrorMissingSource"));
                        return;
                    }

                    // Get document to move
                    TreeNode node = tree.SelectSingleNode(nodeId);

                    // Check whether node exists
                    if (node == null)
                    {
                        ShowError(GetString("ContentRequest.ErrorMissingSource"));
                        return;
                    }

                    // Check the permissions for document
                    if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)
                    {
                        // Root of products tree can not be moved
                        if (!IsProductTree || (node.NodeAliasPath.CompareToCSafe(StartingAliasPath, true) != 0))
                        {
                            switch (action)
                            {
                                case "moveup":
                                    tree.MoveNodeUp(node);
                                    break;

                                case "movedown":
                                    tree.MoveNodeDown(node);
                                    break;

                                case "movetop":
                                    tree.SetNodeOrder(node, DocumentOrderEnum.First);
                                    break;

                                case "movebottom":
                                    tree.SetNodeOrder(node, DocumentOrderEnum.Last);
                                    break;
                            }

                            // Log the synchronization tasks for the entire tree level
                            DocumentSynchronizationHelper.LogDocumentChangeOrder(siteName, node.NodeAliasPath, tree);

                            // Select the document in the tree
                            documentName = node.GetDocumentName();

                            treeElem.ExpandNodeID = node.NodeParentID;
                            treeElem.SelectedNodeID = node.NodeID;
                            AddScript("currentNodeId = " + node.NodeID + ";");
                        }
                    }
                    else
                    {
                        // Select the document in the tree
                        treeElem.SelectedNodeID = nodeId;

                        AddAlert(GetString("ContentRequest.MoveDenied"));
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogEvent(EventType.ERROR, "Content", "MOVE", EventLogProvider.GetExceptionLogMessage(ex), RequestContext.RawURL, currentUser.UserID, currentUser.UserName, nodeId, documentName, RequestContext.UserHostAddress, SiteContext.CurrentSite.SiteID);
                    AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message);
                }
                break;

            case "setculture":
                // Set the preferred culture code
                try
                {
                    // Set the culture code
//.........这里部分代码省略.........
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:101,代码来源:CMSDeskTree.ascx.cs

示例4: RaisePostBackEvent

    public void RaisePostBackEvent(string eventArgument)
    {
        if (eventArgument == "move")
        {
            // Keep current user object
            CurrentUserInfo cu = CMSContext.CurrentUser;

            // Parse input value
            string[] values = hdnMoveId.Value.Split(';');

            // Create tree provider
            TreeProvider tree = new TreeProvider(cu);

            // Get tree node object
            int nodeId = ValidationHelper.GetInteger(values[1], 0);
            TreeNode node = tree.SelectSingleNode(nodeId);

            // Check whether node exists
            if (node == null)
            {
                ShowError(GetString("ContentRequest.ErrorMissingSource"));
                return;
            }

            try
            {
                // Check permissions
                if (cu.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)
                {
                    // Switch by action
                    switch (values[0])
                    {
                        case "up":
                            node = tree.MoveNodeUp(nodeId);
                            break;

                        case "down":
                            node = tree.MoveNodeDown(nodeId);
                            break;

                        case "top":
                            node = tree.SelectSingleNode(nodeId);
                            tree.SetNodeOrder(nodeId, DocumentOrderEnum.First);
                            break;

                        case "bottom":
                            node = tree.SelectSingleNode(nodeId);
                            tree.SetNodeOrder(nodeId, DocumentOrderEnum.Last);
                            break;
                    }

                    if (node != null)
                    {
                        if (!RequiresDialog)
                        {
                            ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAfterMove", ScriptHelper.GetScript("parent.RefreshTree(" + node.NodeParentID + ", " + node.NodeParentID + ");"));
                        }

                        // Log the synchronization tasks for the entire tree level
                        if (SettingsKeyProvider.GetBoolValue(node.NodeSiteName + ".CMSStagingLogChanges"))
                        {
                            // Log the synchronization tasks for the entire tree level
                            DocumentSynchronizationHelper.LogDocumentChangeOrder(node.NodeSiteName, node.NodeAliasPath, tree);
                        }
                    }
                    else
                    {
                        ShowError(GetString("ContentRequest.MoveFailed"));
                    }
                }
                else
                {
                    ShowError(GetString("ContentRequest.MoveDenied"));
                }
            }
            catch (Exception ex)
            {
                EventLogProvider log = new EventLogProvider();
                log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", cu.UserID, cu.UserName, nodeId, node.DocumentName, HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri());

                ShowError(GetString("ContentRequest.MoveFailed") + " : " + ex.Message);
            }
        }
        else if (eventArgument == "refresh")
        {
            // Register the refresh script after the 'move' action is performed
            Hashtable parameters = WindowHelper.GetItem(Identifier) as Hashtable;
            if ((parameters != null) && (parameters.Count > 0))
            {
                int refreshNodeId = ValidationHelper.GetInteger(parameters["refreshnodeid"], 0);
                string refreshScript = "parent.RefreshTree(" + refreshNodeId + ", " + refreshNodeId + ")";
                ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAfterMove", refreshScript, true);
            }
            else
            {
                // If node id not found refresh whole content tree
                ScriptHelper.RegisterStartupScript(this, typeof(string), "refreshAllAfterMove", "parent.RefreshTree(" + NodeID + ", " + NodeID + ")", true);
            }
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:100,代码来源:DocumentList.ascx.cs

示例5: RaisePostBackEvent

    public void RaisePostBackEvent(string eventArgument)
    {
        CurrentUserInfo currentUser = CMSContext.CurrentUser;

        // Current Node ID
        int nodeId = ValidationHelper.GetInteger(Param1, 0);

        TreeProvider tree = new TreeProvider(currentUser);
        EventLogProvider log = new EventLogProvider();

        string documentName = "";
        string action = Action.ToLower();

        // Process the request
        switch (action)
        {
            case "moveup":
            case "movedown":
                // Move the document up (document order)
                try
                {
                    if (nodeId == 0)
                    {
                        AddAlert(GetString("ContentRequest.ErrorMissingSource"));
                        return;
                    }

                    // Get document to move
                    TreeNode node = tree.SelectSingleNode(nodeId);

                    // Check the permissions for document
                    if (currentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)
                    {
                        switch (action)
                        {
                            case "moveup":
                                node = tree.MoveNodeUp(nodeId);
                                break;

                            case "movedown":
                                node = tree.MoveNodeDown(nodeId);
                                break;
                        }

                        string siteName = CMSContext.CurrentSiteName;
                        if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSStagingLogChanges"))
                        {
                            // Load all nodes under parent node
                            if (node != null)
                            {
                                string parentPath = TreePathUtils.GetParentPath(node.NodeAliasPath);

                                DataSet ds = tree.SelectNodes(siteName, parentPath.TrimEnd('/') + "/%", TreeProvider.ALL_CULTURES, true, null, null, null, 1);

                                // Check if data source is not empty
                                if (!DataHelper.DataSourceIsEmpty(ds))
                                {
                                    // Go through all nodes
                                    foreach (DataRow dr in ds.Tables[0].Rows)
                                    {
                                        // Update child nodes
                                        int logNodeId = ValidationHelper.GetInteger(dr["NodeID"], 0);
                                        string culture = ValidationHelper.GetString(dr["DocumentCulture"], "");
                                        string className = ValidationHelper.GetString(dr["ClassName"], "");

                                        TreeNode tn = tree.SelectSingleNode(logNodeId, culture, className);
                                        DocumentSynchronizationHelper.LogDocumentChange(tn, TaskTypeEnum.UpdateDocument, tree);
                                    }
                                }
                            }
                        }

                        // Move the node
                        if (node != null)
                        {
                            documentName = node.DocumentName;

                            treeContent.ExpandNodeID = node.NodeParentID;
                            treeContent.NodeID = node.NodeID;
                        }
                        else
                        {
                            AddAlert(GetString("ContentRequest.MoveFailed"));
                        }
                    }
                    else
                    {
                        AddAlert(GetString("ContentRequest.MoveDenied"));
                    }
                }
                catch (Exception ex)
                {
                    log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "MOVE", currentUser.UserID, currentUser.UserName, nodeId, documentName, HTTPHelper.GetUserHostAddress(), EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri());
                    AddAlert(GetString("ContentRequest.MoveFailed") + " : " + ex.Message);
                }
                break;

            case "delete":
                // Delete the document
                try
//.........这里部分代码省略.........
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:101,代码来源:tree.aspx.cs


注:本文中的TreeProvider.MoveNodeUp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。