Example #1
0
        public void SaveTree()
        {
            EntityNodeProvider.DeleteAllEntityNodesRelatedEntityNodes(UserContext.Current.OrganizationId, EntityNodeId, EntityId);
            RelationType rt;

            foreach (RadTreeNode rtn in this.CheckedNodes)
            {
                if (rtn.Category == "1")
                {
                    rt = RelationType.CheckedAndAllChildren;
                }
                else if (rtn.Category == "2")
                {
                    rt = RelationType.Blocked;
                }
                else
                {
                    rt = RelationType.Checked;
                }

                EntityNodeProvider.InsertEntityNodesRelatedEntityNodes(EntityNodeId, new Guid(rtn.Value), EntityId, rt, UserContext.Current.OrganizationId);
            }
            if (OnSaved != null)
            {
                OnSaved(this, new EventArgs());
            }
        }
Example #2
0
        public static string GetEntityNodePath(Guid entityNodeId)
        {
            string result = string.Empty;

            ClientDataSet.EntityNodeRow row = EntityNodeProvider.GetEntityNode(entityNodeId);
            if (row != null)
            {
                result = row.FullPath;
            }

            return(result);
        }
Example #3
0
        public EntityNodeTypeCollection GetCustomNodeTypes(Guid organizationId, Guid?instanceId)
        {
            EntityNodeTypeCollection customNodeTypes = new EntityNodeTypeCollection();

            foreach (ClientDataSet.EntityNodeTypeRow entRow in EntityNodeProvider.GetCustomEntityNodeTypesByEntityId(organizationId, instanceId, this.Id).Rows)
            {
                EntityNodeType ent = new EntityNodeType();
                ent.Id          = entRow.EntityNodeTypeId;
                ent.OrderNumber = entRow.OrderNumber;
                ent.Name        = entRow.Name;
                customNodeTypes.Add(ent);
            }
            customNodeTypes.Sort();
            return(customNodeTypes);
        }
Example #4
0
        protected void Tree_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(e.Text))
            {
                object obj = Support.ConvertStringToType(e.Node.Value, typeof(Guid));
                e.Node.Text = e.Text;
                EntityNodeProvider.UpdateEntityName(((obj == null) ? Guid.Empty : (Guid)obj), e.Text);
                Bll.Providers.EntityNodeProvider.UpdateEntityNodePath(((obj == null) ? Guid.Empty : (Guid)obj), e.Node.GetFullPath(" > "));
            }
        }
Example #5
0
        private void RefreshTree(bool saveExpandedState)
        {
            Guid?instanceId = null;

            if (Entity.HierarchyStartLevel == EntityLevel.Instance)
            {
                instanceId = this.SelectedInstanceId;
            }

            Tree.DataSource = EntityNodeProvider.GetEntityNodesTree(UserContext.Current.OrganizationId, instanceId, this.Entity.Id, this.Entity.Name);
            Tree.Rebind(saveExpandedState);

            if (Tree.Nodes.Count > 0)
            {
                Tree.Nodes[0].Expanded = true;
            }

            Tree.ContextMenus.Clear();
            Tree.ContextMenus.AddRange(this.ContextMenus.Values);
        }
Example #6
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);
                }
            }
        }
Example #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        // gets a rule engine
        RulesEngine rulesEngine = RuleEngineProvider.RulesEngines["DataCollectorAssignment"];
        // gets a ticket entity and fill his fields
        Entity ent = EntityNodeProvider.GetEntityNodeType(new Guid("00000000-0000-0000-0000-000000000003"));

        ent.Fields["Square"].Value = 40000;
        ent.Fields["Status"].Value = 3;
        //ent.Fields["Address"].Value = 3;
        //EntityNodeProvider.GetEntityNode(
        Entity orgStruct = EntityFieldProvider.Entities["4cda22f3-4f01-4768-8608-938dc6a06825"];

        if (orgStruct != null)
        {
            ent.Fields["Address"].Value = orgStruct;
        }
        // add entity as input parameter
        rulesEngine.AddInputEntity(ent);
        // gets a output RuleId
        Label1.Text = rulesEngine.Execute().ToString();
    }
Example #8
0
        protected void DropDownListEntityFields_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.EntityTypeId == Guid.Empty)
            {
                return;
            }
            EntityFieldCollection fields = EntityNodeProvider.GetEntityFields(this.EntityTypeId);

            if (fields == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(m_FieldName))
            {
                DropDownListEntityFields.SelectedValue = m_FieldName;
            }
            EntityField field = fields[DropDownListEntityFields.SelectedValue];

            if (field == null)
            {
                return;
            }
            LabelFieldType.Text          = field.DataType.Name;
            LabelFieldsTypeFullName.Text = field.DataType.FullName;
            DropDownListTerm.Items.Clear();
            DropDownListTerm.Items.Add(new ListItem("=="));
            DropDownListTerm.Items.Add(new ListItem("!="));

            ControlValue    FieldTypeConrol = ControlValue.TextBox;
            List <ListItem> lists           = new List <ListItem>();

            lists.Add(new ListItem(">"));
            lists.Add(new ListItem(">="));
            lists.Add(new ListItem("<"));
            lists.Add(new ListItem("<="));

            if (field.ListValues.Count > 0)
            {
                LabelFieldType.Text            = Resources.RuleParametersControl_LookupText;
                FieldTypeConrol                = ControlValue.ComboBox;
                ComboBoxEntityValue.DataSource = field.ListValuesOld;
                ComboBoxEntityValue.DataBind();
                if (m_EntityValue != null)
                {
                    ComboBoxEntityValue.SelectedValue = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
            }
            else if (field.DataType == typeof(short))
            {
                FieldTypeConrol = ControlValue.TextBox;
                DropDownListTerm.Items.AddRange(lists.ToArray());
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                TextBoxEntityValue.ValidationType = CustomValidationDataType.Integer;
                TextBoxEntityValue.MaximumValue   = (field.MaxValue != null) ? ((short)field.MaxValue).ToString(CultureInfo.CurrentCulture) : short.MaxValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.MinimumValue   = (field.MinValue != null) ? ((short)field.MinValue).ToString(CultureInfo.CurrentCulture) : short.MinValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.Text           = (field.DefaultValue != null) ? Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture) : "0";
            }
            else if (field.DataType == typeof(int))
            {
                FieldTypeConrol = ControlValue.TextBox;
                DropDownListTerm.Items.AddRange(lists.ToArray());
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                TextBoxEntityValue.ValidationType = CustomValidationDataType.Integer;
                TextBoxEntityValue.MaximumValue   = (field.MaxValue != null) ? ((int)field.MaxValue).ToString(CultureInfo.CurrentCulture) : int.MaxValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.MinimumValue   = (field.MinValue != null) ? ((int)field.MinValue).ToString(CultureInfo.CurrentCulture) : int.MinValue.ToString(CultureInfo.CurrentCulture);
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    TextBoxEntityValue.Text = (field.DefaultValue != null) ? Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture) : "0";
                }
            }
            else if (field.DataType == typeof(long))
            {
                FieldTypeConrol = ControlValue.TextBox;
                DropDownListTerm.Items.AddRange(lists.ToArray());
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                TextBoxEntityValue.ValidationType = CustomValidationDataType.Integer;
                TextBoxEntityValue.MaximumValue   = (field.MaxValue != null) ? ((long)field.MaxValue).ToString(CultureInfo.CurrentCulture) : long.MaxValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.MinimumValue   = (field.MinValue != null) ? ((long)field.MinValue).ToString(CultureInfo.CurrentCulture) : long.MinValue.ToString(CultureInfo.CurrentCulture);
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    TextBoxEntityValue.Text = (field.DefaultValue != null) ? Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture) : "0";
                }
            }
            else if (field.DataType == typeof(decimal))
            {
                FieldTypeConrol = ControlValue.TextBox;
                DropDownListTerm.Items.AddRange(lists.ToArray());
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                TextBoxEntityValue.ValidationType = CustomValidationDataType.Double;
                TextBoxEntityValue.MaximumValue   = (field.MaxValue != null) ? ((decimal)field.MaxValue).ToString(CultureInfo.CurrentCulture) : decimal.MaxValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.MinimumValue   = (field.MinValue != null) ? ((decimal)field.MinValue).ToString(CultureInfo.CurrentCulture) : decimal.MinValue.ToString(CultureInfo.CurrentCulture);
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    TextBoxEntityValue.Text = (field.DefaultValue != null) ? Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture) : decimal.Zero.ToString(CultureInfo.CurrentCulture);
                }
            }
            else if (field.DataType == typeof(double))
            {
                FieldTypeConrol = ControlValue.TextBox;
                DropDownListTerm.Items.AddRange(lists.ToArray());
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                TextBoxEntityValue.ValidationType = CustomValidationDataType.Double;
                TextBoxEntityValue.MaximumValue   = (field.MaxValue != null) ? ((double)field.MaxValue).ToString(CultureInfo.CurrentCulture) : double.MaxValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.MinimumValue   = (field.MinValue != null) ? ((double)field.MinValue).ToString(CultureInfo.CurrentCulture) : double.MinValue.ToString(CultureInfo.CurrentCulture);
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    TextBoxEntityValue.Text = (field.DefaultValue != null) ? Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture) : decimal.Zero.ToString(CultureInfo.CurrentCulture);
                }
            }
            else if (field.DataType == typeof(float))
            {
                FieldTypeConrol = ControlValue.TextBox;
                DropDownListTerm.Items.AddRange(lists.ToArray());
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                TextBoxEntityValue.ValidationType = CustomValidationDataType.Double;
                TextBoxEntityValue.MaximumValue   = (field.MaxValue != null) ? ((float)field.MaxValue).ToString(CultureInfo.CurrentCulture) : float.MaxValue.ToString(CultureInfo.CurrentCulture);
                TextBoxEntityValue.MinimumValue   = (field.MinValue != null) ? ((float)field.MinValue).ToString(CultureInfo.CurrentCulture) : float.MinValue.ToString(CultureInfo.CurrentCulture);
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    TextBoxEntityValue.Text = (field.DefaultValue != null) ? Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture) : decimal.Zero.ToString(CultureInfo.CurrentCulture);
                }
            }
            else if (field.DataType == typeof(DateTime))
            {
                DropDownListTerm.Items.AddRange(lists.ToArray());
                FieldTypeConrol            = ControlValue.DatePicker;
                DatePickerEntityValue.Type = DatePickerType.DateTimePicker;

                if (field.MaxValue != null)
                {
                    DatePickerEntityValue.MaxDate = (DateTime)field.MaxValue;
                }
                if (field.MinValue != null)
                {
                    DatePickerEntityValue.MinDate = (DateTime)field.MinValue;
                }
                if (m_EntityValue != null)
                {
                    DatePickerEntityValue.SelectedDate = Convert.ToDateTime(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else if (field.DefaultValue != null)
                {
                    DatePickerEntityValue.SelectedDate = (DateTime)field.DefaultValue;
                }
            }
            else if (field.DataType == typeof(bool))
            {
                FieldTypeConrol = ControlValue.CheckBox;
                if (m_EntityValue != null)
                {
                    CheckBoxEntityValue.Checked = Convert.ToBoolean(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else
                {
                    CheckBoxEntityValue.Checked = (field.DefaultValue != null) ? Convert.ToBoolean(field.DefaultValue, CultureInfo.CurrentCulture) : false;
                }
            }
            else if (field.DataType == typeof(Guid))
            {
                FieldTypeConrol = ControlValue.TextBox;
                TextBoxEntityValue.MaxLength            = 25;
                TextBoxEntityValue.ValidationType       = CustomValidationDataType.RegularExpression;
                TextBoxEntityValue.ValidationExpression = @"[({]?(0x)?[0-9a-fA-F]{8}([-,]?(0x)?[0-9a-fA-F]{4}){2}((-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12})|(,\{0x[0-9a-fA-F]{2}(,0x[0-9a-fA-F]{2}){7}\}))[)}]?";
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else if (field.DefaultValue != null)
                {
                    TextBoxEntityValue.Text = ((Guid)field.DefaultValue).ToString();
                }
            }
            else if (field.DataType == typeof(Entity))
            {
                FieldTypeConrol = ControlValue.TreeView;
                EntityTreeViewValue.EntityId = field.Id;
                if (m_EntityValue != null)
                {
                    EntityTreeViewValue.EntityNodeId = (Guid)m_EntityValue;
                }
                EntityTreeViewValue.DataBind();
            }
            else
            {
                TextBoxEntityValue.ValidationType = CustomValidationDataType.String;
                if (field.MaxLength > 0)
                {
                    TextBoxEntityValue.MaxLength = 0;
                }
                if (m_EntityValue != null)
                {
                    TextBoxEntityValue.Text = Convert.ToString(m_EntityValue, CultureInfo.CurrentCulture);
                }
                else if (field.DefaultValue != null)
                {
                    TextBoxEntityValue.Text = HttpUtility.HtmlEncode(Convert.ToString(field.DefaultValue, CultureInfo.CurrentCulture));
                }
            }
            if (!string.IsNullOrEmpty(m_Term))
            {
                DropDownListTerm.SelectedValue = m_Term;
            }
            switch (FieldTypeConrol)
            {
            case ControlValue.TextBox:
                TextBoxEntityValue.Visible    = true;
                ComboBoxEntityValue.Visible   = false;
                DatePickerEntityValue.Visible = false;
                CheckBoxEntityValue.Visible   = false;
                EntityTreeViewValue.Visible   = false;
                break;

            case ControlValue.CheckBox:
                TextBoxEntityValue.Visible    = false;
                ComboBoxEntityValue.Visible   = false;
                DatePickerEntityValue.Visible = false;
                CheckBoxEntityValue.Visible   = true;
                EntityTreeViewValue.Visible   = false;
                break;

            case ControlValue.ComboBox:
                TextBoxEntityValue.Visible    = false;
                ComboBoxEntityValue.Visible   = true;
                DatePickerEntityValue.Visible = false;
                CheckBoxEntityValue.Visible   = false;
                EntityTreeViewValue.Visible   = false;
                break;

            case ControlValue.DatePicker:
                TextBoxEntityValue.Visible    = false;
                ComboBoxEntityValue.Visible   = false;
                DatePickerEntityValue.Visible = true;
                CheckBoxEntityValue.Visible   = false;
                EntityTreeViewValue.Visible   = false;
                break;

            case ControlValue.TreeView:
                TextBoxEntityValue.Visible    = false;
                ComboBoxEntityValue.Visible   = false;
                DatePickerEntityValue.Visible = false;
                CheckBoxEntityValue.Visible   = false;
                EntityTreeViewValue.Visible   = true;
                break;
            }
        }
Example #9
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));
                }
            }
        }
Example #10
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(" > "));
                }
            }
        }
Example #11
0
        public void LoadTree()
        {
            if (EntityId != Guid.Empty && UserContext.Current != null)
            {
                Entity entity     = EntityFieldProvider.Entities[EntityId.ToString()];
                Guid?  instanceId = new Guid?();
                if (entity.HierarchyStartLevel == EntityLevel.Instance)
                {
                    instanceId = new Guid?(UserContext.Current.InstanceId);
                }
                ClientDataSet.EntityNodeDataTable dt = new ClientDataSet.EntityNodeDataTable();
                if (UserContext.Current != null)
                {
                    this.OnClientNodeClicked = "onClientNodeClicked";
                    //                    this.ContextMenus.AddRange(CustomContextMenus.Values);
                    base.DataFieldID       = dt.EntityNodeIdColumn.ColumnName;
                    base.DataFieldParentID = dt.ParentEntityNodeIdColumn.ColumnName;
                    base.DataTextField     = dt.NameColumn.ColumnName;
                    base.DataValueField    = dt.EntityNodeIdColumn.ColumnName;
                    this.DataSource        = EntityNodeProvider.GetEntityNodesTree(UserContext.Current.OrganizationId, instanceId, EntityId, entity.Name);
                    this.DataBind();
                    if (this.Nodes.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(CustomRootNodeText))
                        {
                            this.Nodes[0].Text = CustomRootNodeText;
                        }

                        if ((AllowRootNodeSelection.HasValue && !AllowRootNodeSelection.Value) || (!AllowRootNodeSelection.HasValue && !Entity.EnableRootNodeSelection))
                        {
                            this.Nodes[0].Checkable = false;
                            this.Nodes[0].Category  = "3";
                        }
                        this.Nodes[0].Expanded = true;
                    }
                }
            }

            ClientDataSet.EntityNodesRelatedEntityNodesDataTable t = EntityNodeProvider.GetAllEntityNodesRelatedEntityNodes(UserContext.Current.OrganizationId, EntityNodeId, EntityId);
            RadTreeNode rtn;

            foreach (ClientDataSet.EntityNodesRelatedEntityNodesRow row in t.Rows)
            {
                rtn = this.FindNodeByValue(row.RelatedEntityNodeId.ToString());
                if (rtn == null)
                {
                    row.Delete();
                    continue;
                }
                if (rtn.Category != "3")
                {
                    if (row.RelationType == (int)RelationType.Checked)
                    {
                        rtn.Checked = true;
                    }
                    else if (row.RelationType == (int)RelationType.CheckedAndAllChildren)
                    {
                        rtn.Checked  = true;
                        rtn.Category = "1";
                    }
                    else if (row.RelationType == (int)RelationType.Blocked)
                    {
                        rtn.Checked  = true;
                        rtn.Category = "2";
                    }
                }
            }

            SetStateNode(this.Nodes[0]);
            ProcessNodes(this.Nodes[0]);

            if (OnLoaded != null)
            {
                OnLoaded(this, new EventArgs());
            }
        }