Пример #1
0
        /// <summary>
        /// 绑定树
        /// </summary>
        /// <param name="authorityProvider">模块及权限服务对象</param>
        /// <param name="mpid">父模块ID</param>
        /// <param name="authority">查询方式:U-用户;R-角色</param>
        /// <param name="id">查询方式的ID</param>
        /// <param name="nodes">本级节点集合</param>
        private void BindTree(iiAuthority authorityProvider, string mpid, string authority, string id, TreeNodeCollection nodes)
        {
            //本级模块
            DataTable modules = authorityProvider.GetModuleList(mpid, authority, id);

            if (modules == null || modules.Rows.Count == 0)
            {
                return; //递归结束
            }
            else
            {
                foreach (DataRow module in modules.Rows)
                {
                    #region 创建模块项

                    string grant = module["Grant"].ToString().Trim(); //获得授权的方式:U-用户;R-角色;(null)-无
                    string mid   = module["ID"].ToString().Trim();

                    TreeNode node = new TreeNode();

                    string nodeRemark = string.Empty;
                    if (authority == "U")
                    {
                        switch (grant)
                        {
                        case "U":     //权限来自用户,允许维护
                            node.Checked = true;
                            break;

                        case "R":     //权限继承自角色,禁止维护
                            node.Checked      = false;
                            node.ShowCheckBox = false;
                            nodeRemark        = this.GetGlobalResourceString("Inherited"); //备注
                            break;

                        default:     //无权限,允许维护
                            node.Checked = false;
                            break;
                        }
                    }
                    else
                    {
                        node.Checked = (grant.Length != 0);
                    }

                    node.Value        = mid;
                    node.Text         = module["Name"].ToString() + nodeRemark;
                    node.ToolTip      = module["Remark"].ToString();
                    node.SelectAction = TreeNodeSelectAction.None;
                    nodes.Add(node);

                    #endregion

                    //递归下一级
                    this.BindTree(authorityProvider, mid, authority, id, node.ChildNodes);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Initialize()
        {
            #region 页面内容


            #endregion

            //权限树
            Tree.Nodes.Clear();
            using (iiAuthority authorityProvider = new iiAuthority())
            {
                //根节点的PID为框架名称
                this.BindTree(authorityProvider, iiGlobal.FrameworkName, "U", iiGlobal.CurrentUserID, Tree.Nodes);
            }
        }
Пример #3
0
        /// <summary>
        /// 绑定树
        /// </summary>
        /// <param name="authorityProvider">模块及权限服务对象</param>
        /// <param name="mpid">父模块ID</param>
        /// <param name="authority">查询方式:U-用户;R-角色</param>
        /// <param name="id">查询方式的ID</param>
        /// <param name="nodes">本级节点集合</param>
        private void BindTree(iiAuthority authorityProvider, string mpid, string authority, string id, TreeNodeCollection nodes)
        {
            //本级模块
            DataTable modules = authorityProvider.GetModuleList(mpid, authority, id);

            if (modules == null || modules.Rows.Count == 0)
            {
                return; //递归结束
            }
            else
            {
                foreach (DataRow module in modules.Rows)
                {
                    string grant = module["Grant"].ToString().Trim(); //获得授权的方式:U-用户;R-角色;(null)-无
                    if (grant.Length != 0)                            //不是空白表示有权限
                    {
                        #region 创建模块项

                        string mid = module["ID"].ToString().Trim();
                        string url = module["URL"].ToString();

                        TreeNode node = new TreeNode();
                        node.Value        = mid;
                        node.Text         = module["Name"].ToString();
                        node.ToolTip      = module["Remark"].ToString();
                        node.SelectAction = TreeNodeSelectAction.SelectExpand;
                        if (url.Length > 0)
                        {
                            node.NavigateUrl = string.Format("{0}/{1}",
                                                             iiGlobal.VirtualPath,
                                                             url
                                                             );
                        }
                        else
                        {
                            node.NavigateUrl = "javascript:void(null);";
                        }
                        nodes.Add(node);

                        #endregion

                        //递归下一级
                        this.BindTree(authorityProvider, mid, authority, id, node.ChildNodes);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OKButton_Click(object sender, EventArgs e)
        {
            List <string> checkedMIDs = new List <string>();

            #region  中的模块ID

            //菜单节点
            foreach (TreeNode checkedNode in Tree.CheckedNodes)
            {
                //仅处理叶节点(父节点自然在其路径上)
                if (checkedNode.ChildNodes.Count <= 0)
                {
                    string[] checkedNodeMIDs = checkedNode.ValuePath.Split(new char[] { Tree.PathSeparator }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string checkedNodeMID in checkedNodeMIDs)
                    {
                        if (!checkedMIDs.Contains(checkedNodeMID))
                        {
                            checkedMIDs.Add(checkedNodeMID);
                        }
                    }
                }
            }

            #endregion

            using (iiAuthority authorityProvider = new iiAuthority())
            {
                try
                {
                    authorityProvider.Update(
                        this.CurrentAuthority,
                        this.CurrentID,
                        string.Join(iiGlobal.Separator.ToString(), checkedMIDs.ToArray())
                        );
                }
                catch (Exception error)
                {
                    this.ShowErrorMessage(this.GetGlobalResourceString("UpdateErrorMessage") + error.Message);
                    return;
                }
            }
            //回调
            this.DialogCallback("'CloseRefresh'", "window");
        }
Пример #5
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Initialize()
        {
            #region 页面内容

            //标题
            PageTitle.Text = string.Format("{0} - {1}",
                                           this.GetGlobalResourceString("AuthorityDetailTitle"),
                                           this.CurrentID
                                           );

            #endregion

            //权限树
            Tree.Nodes.Clear();
            using (iiAuthority authorityProvider = new iiAuthority())
            {
                //根节点的PID为框架名称
                this.BindTree(authorityProvider, iiGlobal.FrameworkName, this.CurrentAuthority, this.CurrentID, Tree.Nodes);
            }
        }