Exemple #1
0
        public static void ChangeParentEntityNodeType(Guid entityId, Guid sourceId, Guid destinationId)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            EntityNodeType source = EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes[sourceId.ToString("N")];
            EntityNodeType dest   = EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes[destinationId.ToString("N")];

            int indexDest = EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes.IndexOf(dest);

            EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes.Remove(source);
            EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes.Insert(indexDest, source);

            using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                int order = 1;
                foreach (EntityNodeType ent in EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes)
                {
                    ClientDataSet.EntityNodeTypeRow row = GetEntityNodeType(ent.Id, organizationId);
                    row.OrderNumber = order;

                    adapter.Update(row);

                    order++;
                }
            }
        }
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));
                }
            }
        }