Beispiel #1
0
 private void mRemove_Click(object sender, EventArgs e)
 {
     if (_CurrentCategory.IsCategory == false)
     {
         //Obtengo el padre
         _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault <CategoryTree>();
         _ParentFwkCategory.RemoveRule(_CurrentCategory.Name);
         _CategoryTreeList.RemoveItem(_CurrentCategory.Id);//No es necesario ya que se ejecurara luego --> PopulateAsync
         try
         {
             FwkMembership.CreateRuleInCategory(_ParentFwkCategory.FwkCategory, frmAdmin.Provider.Name);
             MessageViewInfo.Show("Rule was successfully removed from category");
             PopulateAsync();
         }
         catch (Exception ex)
         { throw ex; }
     }
     else
     {
         DialogResult r = MessageBox.Show("Will have to delete the category and recursively all its subcategories", "Rules mannager", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (r == DialogResult.Yes)
         {
             try
             {
                 FwkMembership.RemoveCategory(_CurrentCategory.FwkCategory.CategoryId, frmAdmin.Provider.Name);
                 MessageViewInfo.Show("Category was successfully removed ");
                 PopulateAsync();
             }
             catch (Exception ex)
             { throw ex; }
         }
     }
 }
Beispiel #2
0
        private void treeList1_DragDrop(object sender, DragEventArgs e)
        {
            FwkAuthorizationRule rule = null;
            CategoryTree wCategoryTree_ToMove = null;
            TreeListHitInfo wHitInfo = treeList1.CalcHitInfo(treeList1.PointToClient(new Point(e.X, e.Y)));
            if (wHitInfo.Node == null)
                return;

            rule = e.Data.GetData(typeof(FwkAuthorizationRule)) as FwkAuthorizationRule;

            if (rule == null)
            {
                wCategoryTree_ToMove = e.Data.GetData(typeof(CategoryTree)) as CategoryTree;
            }
            //List<FwkAuthorizationRule> wRuleList = e.Data.GetData(typeof(List<FwkAuthorizationRule>)) as List<FwkAuthorizationRule>;
            //FwkAuthorizationRule rule = e.Data.GetData(typeof(FwkAuthorizationRule)) as FwkAuthorizationRule;
            #region Move rule
            if (rule != null)
            {

                _CurrentCategory = (CategoryTree)treeList1.GetDataRecordByNode(wHitInfo.Node);
                lblCurrentCategory.Text = _CurrentCategory.Name;
                if (_CurrentCategory.IsCategory == false)
                {
                    //Obtengo el padre
                    _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault<CategoryTree>();
                    _CurrentCategory = _ParentFwkCategory;
                }

                #region Add Rules to Category

                if (!_CurrentCategory.AnyRule(rule.Name))
                {

                    _CurrentCategory.AddRule(rule);
                    FwkMembership.CreateRuleInCategory(_CurrentCategory.FwkCategory, frmAdmin.Provider.Name);
                }

                #endregion

                PopulateAsync();
            }

            #endregion


            if (wCategoryTree_ToMove != null)
            {
                if (wCategoryTree_ToMove.Id == _CurrentCategory.Id)
                {
                    Cursor = Cursors.Default;
                    return;
                }

                #region Mueve una categoria
                if (wCategoryTree_ToMove.IsCategory)
                {
                    if (_CurrentCategory.IsCategory == false)
                    {
                        //Obtengo el padre de la categoria destino 
                        _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault<CategoryTree>();
                        _CurrentCategory = _ParentFwkCategory;
                    }
                    if (wCategoryTree_ToMove.ParentId == _CurrentCategory.Id)
                    {
                        Cursor = Cursors.Default;
                        return;
                    }

                    FwkMembership.UpdateParentCategory(
                        wCategoryTree_ToMove.FwkCategory.CategoryId,
                        wCategoryTree_ToMove.FwkCategory.ParentId.Value,
                        _CurrentCategory.FwkCategory.CategoryId,
                        frmAdmin.Provider.Name);
                }
                #endregion

                #region Mueve una regla a otra categoria
                if (wCategoryTree_ToMove.IsCategory == false)
                {
                    if (_CurrentCategory.IsCategory == false)
                    {
                        //Obtengo el padre de la categoria destino 
                        _CurrentCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault<CategoryTree>();

                    }
                    if (wCategoryTree_ToMove.ParentId == _CurrentCategory.Id)
                    {
                        Cursor = Cursors.Default;
                        return;
                    }

                    if (!_CurrentCategory.AnyRule(wCategoryTree_ToMove.Name))
                    {

                        _CurrentCategory.AddRule(wCategoryTree_ToMove.FwkAuthorizationRule);
                        FwkMembership.CreateRuleInCategory(_CurrentCategory.FwkCategory, frmAdmin.Provider.Name);

                        //Obtengo el padre de la regla a mover para eliminarle la regla
                        _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(wCategoryTree_ToMove.ParentId)).FirstOrDefault<CategoryTree>();
                        _ParentFwkCategory.RemoveRule(wCategoryTree_ToMove.Name);
                        FwkMembership.CreateRuleInCategory(_ParentFwkCategory.FwkCategory, frmAdmin.Provider.Name);

                    }


                }
                #endregion

                PopulateAsync();
            }
            Cursor = Cursors.Default;
        }
Beispiel #3
0
        private void mRemove_Click(object sender, EventArgs e)
        {
            if (_CurrentCategory.IsCategory == false)
            {
                //Obtengo el padre
                _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault<CategoryTree>();
                _ParentFwkCategory.RemoveRule(_CurrentCategory.Name);
                _CategoryTreeList.RemoveItem(_CurrentCategory.Id);//No es necesario ya que se ejecurara luego --> PopulateAsync
                try
                {
                    FwkMembership.CreateRuleInCategory(_ParentFwkCategory.FwkCategory, frmAdmin.Provider.Name);
                    MessageViewInfo.Show("Rule was successfully removed from category");
                    PopulateAsync();
                }
                catch (Exception ex)
                { throw ex; }
            }
            else
            {
                DialogResult r = MessageBox.Show("Will have to delete the category and recursively all its subcategories", "Rules mannager", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {
                    try
                    {
                        FwkMembership.RemoveCategory(_CurrentCategory.FwkCategory.CategoryId, frmAdmin.Provider.Name);
                        MessageViewInfo.Show("Category was successfully removed ");
                        PopulateAsync();
                    }
                    catch (Exception ex)
                    { throw ex; }
                }

            }
        }
Beispiel #4
0
        private void treeList1_DragDrop(object sender, DragEventArgs e)
        {
            FwkAuthorizationRule rule = null;
            CategoryTree         wCategoryTree_ToMove = null;
            TreeListHitInfo      wHitInfo             = treeList1.CalcHitInfo(treeList1.PointToClient(new Point(e.X, e.Y)));

            if (wHitInfo.Node == null)
            {
                return;
            }

            rule = e.Data.GetData(typeof(FwkAuthorizationRule)) as FwkAuthorizationRule;

            if (rule == null)
            {
                wCategoryTree_ToMove = e.Data.GetData(typeof(CategoryTree)) as CategoryTree;
            }
            //List<FwkAuthorizationRule> wRuleList = e.Data.GetData(typeof(List<FwkAuthorizationRule>)) as List<FwkAuthorizationRule>;
            //FwkAuthorizationRule rule = e.Data.GetData(typeof(FwkAuthorizationRule)) as FwkAuthorizationRule;
            #region Move rule
            if (rule != null)
            {
                _CurrentCategory        = (CategoryTree)treeList1.GetDataRecordByNode(wHitInfo.Node);
                lblCurrentCategory.Text = _CurrentCategory.Name;
                if (_CurrentCategory.IsCategory == false)
                {
                    //Obtengo el padre
                    _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault <CategoryTree>();
                    _CurrentCategory   = _ParentFwkCategory;
                }

                #region Add Rules to Category

                if (!_CurrentCategory.AnyRule(rule.Name))
                {
                    _CurrentCategory.AddRule(rule);
                    FwkMembership.CreateRuleInCategory(_CurrentCategory.FwkCategory, frmAdmin.Provider.Name);
                }

                #endregion

                PopulateAsync();
            }

            #endregion


            if (wCategoryTree_ToMove != null)
            {
                if (wCategoryTree_ToMove.Id == _CurrentCategory.Id)
                {
                    Cursor = Cursors.Default;
                    return;
                }

                #region Mueve una categoria
                if (wCategoryTree_ToMove.IsCategory)
                {
                    if (_CurrentCategory.IsCategory == false)
                    {
                        //Obtengo el padre de la categoria destino
                        _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault <CategoryTree>();
                        _CurrentCategory   = _ParentFwkCategory;
                    }
                    if (wCategoryTree_ToMove.ParentId == _CurrentCategory.Id)
                    {
                        Cursor = Cursors.Default;
                        return;
                    }

                    FwkMembership.UpdateParentCategory(
                        wCategoryTree_ToMove.FwkCategory.CategoryId,
                        wCategoryTree_ToMove.FwkCategory.ParentId.Value,
                        _CurrentCategory.FwkCategory.CategoryId,
                        frmAdmin.Provider.Name);
                }
                #endregion

                #region Mueve una regla a otra categoria
                if (wCategoryTree_ToMove.IsCategory == false)
                {
                    if (_CurrentCategory.IsCategory == false)
                    {
                        //Obtengo el padre de la categoria destino
                        _CurrentCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault <CategoryTree>();
                    }
                    if (wCategoryTree_ToMove.ParentId == _CurrentCategory.Id)
                    {
                        Cursor = Cursors.Default;
                        return;
                    }

                    if (!_CurrentCategory.AnyRule(wCategoryTree_ToMove.Name))
                    {
                        _CurrentCategory.AddRule(wCategoryTree_ToMove.FwkAuthorizationRule);
                        FwkMembership.CreateRuleInCategory(_CurrentCategory.FwkCategory, frmAdmin.Provider.Name);

                        //Obtengo el padre de la regla a mover para eliminarle la regla
                        _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(wCategoryTree_ToMove.ParentId)).FirstOrDefault <CategoryTree>();
                        _ParentFwkCategory.RemoveRule(wCategoryTree_ToMove.Name);
                        FwkMembership.CreateRuleInCategory(_ParentFwkCategory.FwkCategory, frmAdmin.Provider.Name);
                    }
                }
                #endregion

                PopulateAsync();
            }
            Cursor = Cursors.Default;
        }