Ejemplo n.º 1
0
        private void SelectOperationForOne()
        {
            GetResource();
            TreeNode _node = tvRole.SelectedNode;

            if (_node == null || _node.Tag == null)
            {
                return;
            }

            IDictionary <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > _permissions = null;

            try
            {
                PrivilegeService _proxy = Common.Util.CreateProxy();

                using (_proxy as IDisposable)
                {
                    _permissions = _proxy.GetPermission(nTabControl1.SelectedTab.Name, (_node.Tag as Role));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "提示");
                return;
            }

            InitCheckBox(_resTreeListMap[nTabControl1.SelectedTab.Name].Items);

            if (_permissions == null || _permissions.Count == 0)
            {
                return;
            }

            foreach (Priv res in _permissions.Keys)
            {
                SetCheckBox(_resTreeListMap[nTabControl1.SelectedTab.Name].Items, res);
            }
        }
Ejemplo n.º 2
0
        private void GetDeleteRes(List <Priv> res)
        {
            //当前Role查找数据库中的权限
            IDictionary <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > _permissionsParent = null;
            List <Priv>      InitResList = new List <Priv>();
            PrivilegeService _proxy      = Common.Util.CreateProxy();

            using (_proxy as IDisposable)
            {
                _permissionsParent = _proxy.GetPermission(nTabControl1.SelectedTab.Name, (tvRole.SelectedNode.Tag as Role));

                foreach (KeyValuePair <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > pair in _permissionsParent)
                {
                    InitResList.Add(pair.Key);
                }
            }

            //查找出初始Res和选择后的Res差别,找到DelResList
            foreach (Priv initRes in InitResList)
            {
                bool judge = true;
                foreach (Priv checkItem in res)
                {
                    if (initRes.Id == checkItem.Id)
                    {
                        judge = false;
                        continue;
                    }
                }

                if (judge)
                {
                    deleteResList.Add(initRes);
                }
            }
        }
Ejemplo n.º 3
0
        private void GetResource()
        {
            _resTreeListMap[nTabControl1.SelectedTab.Name].Items.Clear();
            string           _resTypeId = this.nTabControl1.SelectedTab.Name;
            IList <Priv>     _resources = null;
            PrivilegeService _proxy     = Common.Util.CreateProxy();

            try
            {
                using (_proxy as IDisposable)
                {
                    _resources = _proxy.GetResource(_resTypeId);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "提示");
                return;
            }
            TreeListViewItem _root = new TreeListViewItem(nTabControl1.SelectedTab.Text + "包含的资源", 9);

            Neusoft.Privilege.BizLogic.Model.Resource _res = new Neusoft.Privilege.BizLogic.Model.Resource();
            _res.Id   = "root";
            _res.Name = nTabControl1.SelectedTab.Text;
            _res.Type = nTabControl1.SelectedTab.Name;
            _root.Tag = _res;
            _resTreeListMap[nTabControl1.SelectedTab.Name].Items.Add(_root);

            //判断单一节点情况,并且要分级授权
            IDictionary <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > _permissionsParent = null;
            IList <Priv> resources = new List <Priv>();

            if (IsJudgeOperationForOne(_resTypeId))
            {
                if (tvRole.SelectedNode != null && tvRole.SelectedNode.Tag != null)
                {
                    if ((tvRole.SelectedNode.Tag as Role).Id == "roleadmin" || (tvRole.SelectedNode.Tag as Role).ParentId == "roleadmin")
                    {
                        addResource(_root, _resources);
                    }
                    else
                    {
                        try
                        {
                            using (_proxy as IDisposable)
                            {
                                _permissionsParent = _proxy.GetPermission(nTabControl1.SelectedTab.Name, (tvRole.SelectedNode.Parent.Tag as Role));
                            }

                            foreach (KeyValuePair <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > pair in _permissionsParent)
                            {
                                resources.Add(pair.Key);
                            }

                            addResource(_root, resources);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, "提示");
                            return;
                        }
                    }
                }
            }
            else
            {
                addResource(_root, _resources);
            }

            _root.ExpandAll();
        }
Ejemplo n.º 4
0
        private void SelectOperation()
        {
            ClearSelectedOptions();

            TreeNode _node = tvRole.SelectedNode;

            if (_node == null || _node.Tag == null)
            {
                return;
            }

            NeuTreeListView _list = _resTreeListMap[nTabControl1.SelectedTab.Name];

            if (_list == null || _list.SelectedItems.Count == 0)
            {
                return;
            }
            TreeListViewItem _item = _list.SelectedItems[0];

            if ((_item.Tag as Priv).Id == "root")
            {
                return;
            }

            IDictionary <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > _permissions = null;

            try
            {
                PrivilegeService _proxy = Common.Util.CreateProxy();

                using (_proxy as IDisposable)
                {
                    _permissions = _proxy.GetPermission(nTabControl1.SelectedTab.Name, (_item.Tag as Priv).Id, (_node.Tag as Role));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "提示");
                return;
            }

            if (_permissions == null || _permissions.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair <Priv, IList <Neusoft.Privilege.BizLogic.Model.Operation> > _pair in _permissions)
            {
                foreach (Neusoft.Privilege.BizLogic.Model.Operation _opera in _pair.Value)
                {
                    Control _c = _resGroupBoxMap[nTabControl1.SelectedTab.Name].Controls[_opera.Id];

                    if (_c != null && _c.GetType() == typeof(NeuCheckBox))
                    {
                        (_c as NeuCheckBox).Checked = true;
                    }
                    else if (_c != null && _c.GetType() == typeof(NeuRadioButton))
                    {
                        (_c as NeuRadioButton).Checked = true;
                    }
                }
                break;
            }
        }