Ejemplo n.º 1
0
        // added for v1.6.0
        /// <summary>
        /// Handles the Click event of the btnDuplicate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnDuplicate_Click( object sender, EventArgs e )
        {
            try
            {
                if( ActiveNode == null )
                {
                    ShowError( "btnDuplicate_Click:: non starting node found." );
                    return;
                }

                Node node = new Node();
                node.ParentNode = ActiveNode.ParentNode;
                node.Site = ActiveNode.Site;
                node.Title = "Copy of " + ActiveNode.Title;
                node.Template = ActiveNode.Template;
                node.Culture = ActiveNode.Culture;
                node.LinkUrl = ActiveNode.LinkUrl;
                node.MetaDescription = ActiveNode.MetaDescription;
                node.MetaKeywords = ActiveNode.MetaKeywords;
                node.LinkTarget = ActiveNode.LinkTarget;
                node.ShowInNavigation = ActiveNode.ShowInNavigation;

                node.CreateShortDescription();

                foreach( NodePermission np in ActiveNode.NodePermissions )
                {
                    NodePermission npNew = new NodePermission();
                    npNew.Node = node;
                    npNew.Role = np.Role;
                    npNew.ViewAllowed = np.ViewAllowed;
                    npNew.EditAllowed = np.EditAllowed;
                    node.NodePermissions.Add( npNew );
                }

                IList rootNodes = base.CoreRepository.GetRootNodes( node.Site );
                node.CalculateNewPosition( rootNodes );
                ActiveNode.ChildNodes.Add(node);

                base.CoreRepository.SaveObject( node );

                CopySectionsFromNode( ActiveNode, node );

                base.CoreRepository.ClearQueryCache( "Nodes" );
                base.CoreRepository.ClearCollectionCache("Cuyahoga.Core.Domain.Node.ChildNodes");

                Context.Response.Redirect(String.Format( "NodeEdit.aspx?NodeId={0}&message=Node has been duplicated.", node.Id ) );

            }
            catch( Exception ee )
            {
                ShowException( ee );
            }
        }
Ejemplo n.º 2
0
        protected void btnDuplicate_Click(object sender, EventArgs e)
        {
            try
            {
                if (ActiveNode == null)
                {
                    ShowError("btnDuplicate_Click:: non starting node found.");
                    return;
                }

                Node node = new Node();
                node.ParentNode = ActiveNode.ParentNode;
                node.Site = this.ActiveSite;
                node.Title = "Copy of " + ActiveNode.Title;

                //Custom: Check for existing copies and rename accordingly
                if (node.ParentNode.ChildNodes.Count > 0)
                {
                    foreach (Node n in node.ParentNode.ChildNodes)
                    {
                        if (node.Title == n.Title)
                        {
                            node.Title = "Copy of " + n.Title;
                        }
                    }
                }

                node.Template = ActiveNode.Template;
                node.Culture = ActiveNode.Culture;
                node.LinkUrl = ActiveNode.LinkUrl;
                node.MetaDescription = ActiveNode.MetaDescription;
                node.MetaKeywords = ActiveNode.MetaKeywords;
                node.LinkTarget = ActiveNode.LinkTarget;
                node.ShowInNavigation = ActiveNode.ShowInNavigation;

                node.CreateShortDescription();

                foreach (NodePermission np in ActiveNode.NodePermissions)
                {
                    NodePermission npNew = new NodePermission();
                    npNew.Node = node;
                    npNew.Role = np.Role;
                    npNew.ViewAllowed = np.ViewAllowed;
                    npNew.EditAllowed = np.EditAllowed;
                    node.NodePermissions.Add(npNew);
                }

                IList rootNodes = NodeService.GetRootNodes(node.Site).ToList();

                node.CalculateNewPosition(rootNodes);
                ActiveNode.ChildNodes.Add(node);

                NodeService.SaveNode(node);

                CopySectionsFromNode(ActiveNode, node);

                _commonDao.RemoveQueryFromCache("Nodes");
                _commonDao.RemoveCollectionFromCache("Cuyahoga.Core.Domain.Node.ChildNodes");

                Context.Response.Redirect(String.Format("NodeEdit.aspx?NodeId={0}&message=Node has been duplicated.", node.Id));

            }
            catch (Exception ee)
            {
                ShowException(ee);
            }
        }