Exemple #1
0
        private void UpdateAllNodesPath(RadTreeNode rtn)
        {
            Guid id = new Guid(rtn.Value);

            if (id != Guid.Empty)
            {
                Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(id, rtn.GetFullPath(" > "));
            }
            foreach (RadTreeNode childNode in rtn.Nodes)
            {
                UpdateAllNodesPath(childNode);
            }
        }
Exemple #2
0
        protected void Tree_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            List.Visible = false;
            if (e.MenuItem.Value.StartsWith("CREATE", StringComparison.OrdinalIgnoreCase))
            {
                string[] menuItemValues = e.MenuItem.Value.Split('_');
                bool     maxRestricted  = false;
                if (new Guid(e.Node.Value) != Guid.Empty)
                {
                    EntityNodeType ent = Entity.NodeTypes[menuItemValues[1]];
                    if (ent != null && ent.MaxRestrict > 0)
                    {
                        maxRestricted = IsRestricted(e.Node, menuItemValues[1], ent.MaxRestrict, this.Entity.HierarchyMaxDepth);
                    }
                }

                if (!maxRestricted)
                {
                    Guid        entityId = Bll.Providers.EntityNodeProvider.InsertEntityNode(UserContext.Current.OrganizationId, this.SelectedInstanceId, "new", new Guid(menuItemValues[1]), this.EntityId, new Guid(e.Node.Value), this.Entity.HierarchyStartLevel);
                    RadTreeNode rtn      = new RadTreeNode();
                    rtn.Text          = "new";
                    rtn.Value         = entityId.ToString("N");
                    rtn.Category      = menuItemValues[1];
                    rtn.ContextMenuID = "Menu" + menuItemValues[1];
                    e.Node.Nodes.Add(rtn);
                    e.Node.Expanded = true;
                    Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(entityId, rtn.GetFullPath(" > "));
                    StartNodeInEditMode(rtn.Value);
                }
                else
                {
                    RestrictErrorLabel.Text    = Resources.EntityControl_RestrictErrorLabel_Text;
                    RestrictErrorLabel.Visible = true;
                }
            }
            else if (e.MenuItem.Value.ToUpperInvariant() == "DELETE")
            {
                EntityNodeProvider.DeleteEntityNode(new Guid(e.Node.Value));
                Tree.FindNodeByValue(e.Node.Value).Remove();
            }
            else if (e.MenuItem.Value.ToUpperInvariant() == "CLONE")
            {
                Guid sourceId = new Guid(e.Node.Value);
                ClientDataSet.EntityNodeRow source = EntityNodeProvider.GetEntityNode(sourceId);

                if (source.IsParentEntityNodeIdNull())
                {
                    source.ParentEntityNodeId = Guid.Empty;
                }

                RadTreeNode rtn = new RadTreeNode();
                rtn.Text          = e.Node.Text + "_Copy" + (e.Node.ParentNode.Nodes.Count + 1).ToString(CultureInfo.InvariantCulture);
                rtn.Value         = EntityNodeProvider.InsertEntityNode(UserContext.Current.OrganizationId, this.SelectedInstanceId, rtn.Text, source.EntityNodeTypeId, source.EntityId, source.ParentEntityNodeId, this.Entity.HierarchyStartLevel).ToString();
                rtn.Category      = e.Node.Category;
                rtn.ContextMenuID = e.Node.ContextMenuID;
                e.Node.ParentNode.Nodes.Add(rtn);
                Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(new Guid(rtn.Value), rtn.GetFullPath(" > "));
                CloneNode(e.Node, rtn);
            }

            else if (e.MenuItem.Value == Resources.EntityControl_AddNodeType || e.MenuItem.Value == Resources.EntityControl_EditNodeType)
            {
                List.DataBind();
                List.Visible = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(e.MenuItem.Value))
                {
                    Response.Redirect(string.Format(CultureInfo.InvariantCulture, e.MenuItem.Value, e.Node.Value));
                }
            }
        }
Exemple #3
0
        protected void Tree_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (e.SourceDragNode == null || e.DestDragNode == null)
            {
                return;
            }
            bool IsMerge = e.SourceDragNode.Level == e.DestDragNode.Level;

            if (e.SourceDragNode.Level - 1 != e.DestDragNode.Level && !IsMerge)
            {
                return;
            }
            if (e.SourceDragNode.Level < 1)
            {
                return;
            }

            object obj      = Support.ConvertStringToType(e.SourceDragNode.Value, typeof(Guid));
            Guid   sourceId = ((obj == null) ? Guid.Empty : (Guid)obj);

            obj = Support.ConvertStringToType(e.DestDragNode.Value, typeof(Guid));
            Guid        destId     = ((obj == null) ? Guid.Empty : (Guid)obj);
            RadTreeNode destNode   = Tree.FindNodeByValue(e.DestDragNode.Value);
            RadTreeNode sourceNode = Tree.FindNodeByValue(e.SourceDragNode.Value);

            if (IsMerge)
            {
                foreach (RadTreeNode rtn in sourceNode.Nodes)
                {
                    EntityNodeProvider.ChangeParentEntityNode(new Guid(rtn.Value), destId);
                }
                EntityNodeProvider.MergeEntityNode(sourceId, destId);
                RefreshTree();
                destNode = Tree.FindNodeByValue(destId.ToString());
                UpdateAllNodesPath(destNode);
            }
            else
            {
                bool isCopy = false;
                if (!String.IsNullOrEmpty(Request.Params["CtrlKeyField"]))
                {
                    isCopy = Convert.ToBoolean(Request.Params["CtrlKeyField"], CultureInfo.InvariantCulture);
                }

                if (isCopy)
                {
                    EntityNodeProvider.CopyEntityNode(UserContext.Current.OrganizationId, this.SelectedInstanceId, sourceId, destId, this.Entity.HierarchyStartLevel);
                    RadTreeNode rtn = new RadTreeNode();
                    rtn.Text          = sourceNode.Text;
                    rtn.Value         = sourceNode.Value;
                    rtn.Category      = sourceNode.Category;
                    rtn.ContextMenuID = sourceNode.ContextMenuID;
                    destNode.Nodes.Add(rtn);
                    Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(new Guid(rtn.Value), rtn.GetFullPath(" > "));
                }
                else
                {
                    EntityNodeProvider.ChangeParentEntityNode(sourceId, destId);
                    destNode.Nodes.Add(sourceNode);
                    Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(new Guid(sourceNode.Value), sourceNode.GetFullPath(" > "));
                }
            }
        }
Exemple #4
0
        private void CloneNode(RadTreeNode radTreeNode, RadTreeNode targetNode)
        {
            foreach (RadTreeNode sourceNode in radTreeNode.Nodes)
            {
                Guid sourceId = new Guid(sourceNode.Value);
                ClientDataSet.EntityNodeRow source = EntityNodeProvider.GetEntityNode(sourceId);

                RadTreeNode rtn = new RadTreeNode();
                rtn.Text          = sourceNode.Text;
                rtn.Value         = EntityNodeProvider.InsertEntityNode(UserContext.Current.OrganizationId, this.SelectedInstanceId, source.Name, source.EntityNodeTypeId, source.EntityId, new Guid(targetNode.Value), this.Entity.HierarchyStartLevel).ToString();
                rtn.Category      = sourceNode.Category;
                rtn.ContextMenuID = sourceNode.ContextMenuID;
                targetNode.Nodes.Add(rtn);
                Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(new Guid(rtn.Value), rtn.GetFullPath(" > "));

                if (sourceNode.Nodes.Count > 0)
                {
                    CloneNode(sourceNode, rtn);
                }
            }
        }
        private String GetNodeUrl(RadTreeNode node)
        {
            String result = null;
            if (node != null)
                result = node.GetFullPath("/").Replace(RootNodeValue,"").Replace("//","/");

            if (String.IsNullOrEmpty(result))
                result = CmsSiteMap.RootPath;

            return result;
        }