Esempio n. 1
0
        private void InitMenuTree(int loginId)
        {
            List <string> treenodes = new List <string>();

            IList <EtNet_Models.Menu> menus = MenuManager.getMenuAll();
            //IList<EtNet_Models.Menu> menus = MenuManager.getMenuAllbyID(loginId);
            StringBuilder sbMenu = new StringBuilder();

            string[] menuArr = null;
            IList <LoginUserLimit> lulList = LoginUserLimitManager.getAllNodeById(loginId);

            if (lulList.Count > 0)
            {
                foreach (LoginUserLimit lul in lulList)
                {
                    sbMenu.Append(lul.Nodeid.Nodeid);
                    sbMenu.Append(",");
                }

                menuArr = sbMenu.ToString().TrimEnd(',').Split(',');
            }

            foreach (EtNet_Models.Menu menu in menus)
            {
                string node = string.Format("{{ 'id':'{0}', 'pId':'{1}', 'name':'{2}', 'open':'false','checked':'{3}'}}",
                                            menu.Nodeid, menu.Parentnodeid, menu.Name, menuArr == null ? false : (menuArr.Contains(menu.Nodeid.ToString())));
                treenodes.Add(node);
            }

            NodesMenu = string.Join(",", treenodes.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// 检测是否有权限查看数据
        /// </summary>
        /// <returns></returns>
        private int LoginLimitIsEmpty()
        {
            string    userId = Request.QueryString["uid"];
            LoginInfo login  = LoginInfoManager.getLoginInfoByLoginID(userId);

            return(LoginUserLimitManager.GetLimitCount(login.Id));
        }
Esempio n. 3
0
        /// <summary>
        /// 同步角色下的用户权限
        /// </summary>
        /// <param name="menus">要同步的菜单权限</param>
        private void SetPersmissionByRole(List <MyTreeNode> menus)
        {
            int roleID = Convert.ToInt32(Request.QueryString["id"]);

            //角色下的用户ID,已“,”分隔
            string users = LoginDataLimitManager.GetUsersByRole(roleID);

            if (users != string.Empty)
            {
                string[] usersArr = users.Split(',');
                //删除用户权限
                for (int i = 0; i < usersArr.Length; i++)
                {
                    LoginUserLimitManager.DeleteLoginLimitByUser(int.Parse(usersArr[i]));
                }

                LoginUserLimit userLimit = new LoginUserLimit();
                //添加用户权限
                for (int i = 0; i < usersArr.Length; i++)
                {
                    for (int j = 0; j < menus.Count(); j++)
                    {
                        LoginUserLimitManager.InsertUserLimt(usersArr[i], menus[j].Id.ToString());
                    }
                }
            }
        }
Esempio n. 4
0
        private void DisplayUserLimitMenu()
        {
            //得到父节点Id
            int nodeid = int.Parse(hidParentMenu.Value);
            //得到当前角色Id
            int id = int.Parse(hidId.Value);

            ArrayList arrUserChildMenu = new ArrayList();
            //根据角色Id和父节点Id得到RoleRight表中已经存在的子菜单信息\
            IList <EtNet_Models.LoginUserLimit> UserChildLimit = LoginUserLimitManager.GetUserLimitByIdAndParentNodeId(id, nodeid);

            foreach (LoginUserLimit userLimit in UserChildLimit)
            {
                arrUserChildMenu.Add(userLimit.Nodeid.Nodeid.ToString());
            }
            //根据父节点Id得到对应的所有子节点信息
            IList <EtNet_Models.Menu> menus = MenuManager.getMenuByParentId(nodeid);

            //将子节点循环追加到CheckBoxList控件中
            foreach (EtNet_Models.Menu menu in menus)
            {
                ListItem list = new ListItem();
                list.Value = menu.Nodeid.ToString();
                list.Text  = menu.Name.ToString();
                if (arrUserChildMenu.Contains(list.Value))
                {
                    list.Selected = true;
                }
                chklstChildMenu.Items.Add(list);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 设置保存
        /// </summary>
        private void SaveLimit()
        {
            //获取ID
            int id = int.Parse(Request.QueryString["id"].ToString());
            IList <LoginUserLimit> currentUserLimit = LoginUserLimitManager.getAllNodeById(id);
            ArrayList arrUserNodes = new ArrayList();

            foreach (LoginUserLimit userLimit in currentUserLimit)
            {
                arrUserNodes.Add(userLimit.Nodeid.Nodeid.ToString());
            }


            foreach (Control ct in this.phUserDistribute.Controls)
            {
                CheckBox        chk = (CheckBox)ct.FindControl("chkParentMenu");
                HtmlInputHidden hih = (HtmlInputHidden)ct.FindControl("hidParentMenu");

                if (chk.Checked)
                {
                    if (!arrUserNodes.Contains(hih.Value))
                    {
                        LoginUserLimitManager.InsertUserLimt(id.ToString(), hih.Value);
                    }
                }
                else
                {
                    if (arrUserNodes.Contains(hih.Value))
                    {
                        LoginUserLimitManager.DeleteUserLimit(id.ToString(), hih.Value);
                    }
                }


                CheckBoxList chklist = (CheckBoxList)ct.FindControl("chklstChildMenu");
                foreach (ListItem listItem in chklist.Items)
                {
                    if (listItem.Selected)
                    {
                        if (!arrUserNodes.Contains(listItem.Value))
                        {
                            LoginUserLimitManager.InsertUserLimt(id.ToString(), listItem.Value);
                        }
                    }
                    else
                    {
                        if (arrUserNodes.Contains(listItem.Value))
                        {
                            LoginUserLimitManager.DeleteUserLimit(id.ToString(), listItem.Value);
                        }
                    }
                }
            }
            Response.Write("<script>alert('权限下次登录时生效!!');self.document.location.href='LoginSet.aspx'</script>");
        }
Esempio n. 6
0
        private void DeleteUserPremission(int userId)
        {
            LoginDataLimit ldlModel = new LoginDataLimit();

            ldlModel.DataIds = "";
            ldlModel.LoginId = userId;
            //删除用户数据权限
            LoginDataLimitManager.Setlimit(ldlModel);
            //删除用户角色权限
            LoginUserLimitManager.DeleteLoginLimitByUser(userId);
        }
Esempio n. 7
0
        /// <summary>
        /// 初始化权限
        /// </summary>
        /// <param name="id"></param>
        private void DisplayUserLimit(int id)
        {
            IList <LoginUserLimit> currentUserParentNodes = LoginUserLimitManager.getParentNodesById(id);
            ArrayList arrUserParentNodes = new ArrayList();

            foreach (LoginUserLimit userLimit in currentUserParentNodes)
            {
                arrUserParentNodes.Add(userLimit.Nodeid.Nodeid.ToString());
            }

            IList <EtNet_Models.Menu> menus = EtNet_BLL.MenuManager.getAllParentNode();

            foreach (EtNet_Models.Menu menu in menus)
            {
                string nodeid = menu.Nodeid.ToString();

                string nodename = menu.Name.ToString();

                UserLimit userLimit = (UserLimit)LoadControl(@"UserLimit.ascx");

                HtmlInputHidden hidParentNode = (HtmlInputHidden)userLimit.FindControl("hidParentMenu");

                hidParentNode.Value = nodeid;

                HtmlInputHidden hidUser = (HtmlInputHidden)userLimit.FindControl("hidId");

                hidUser.Value = id.ToString();

                CheckBox chkParentMenu = (CheckBox)userLimit.FindControl("chkParentMenu");


                chkParentMenu.Text = nodename;

                if (arrUserParentNodes.Contains(nodeid))
                {
                    chkParentMenu.Checked = true;
                }

                this.phUserDistribute.Controls.Add(userLimit);
            }
        }
Esempio n. 8
0
        protected void BtnSave_Click(object sender, ImageClickEventArgs e)
        {
            List <MyTreeNode> dataList   = HidData.Value == string.Empty ? null : ReadNode(HidData.Value);
            List <MyTreeNode> menuList   = HidMenu.Value == string.Empty ? null : ReadNode(HidMenu.Value);
            List <MyTreeNode> noMenuList = HidNoMenu.Value == string.Empty ? null : ReadNode(HidNoMenu.Value);

            object loginId = Request.QueryString["id"];
            int    id      = 0;

            if (loginId == null || !int.TryParse(loginId.ToString(), out id) || Convert.ToInt32(loginId) <= 0)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('参数错误')</script>");
                return;
            }
            LoginDataLimit ldl = new LoginDataLimit();

            if (dataList == null)
            {
                ldl.DataIds = string.Empty;
            }
            else
            {
                StringBuilder dataIds = new StringBuilder();
                foreach (MyTreeNode node in dataList)
                {
                    if (!node.IsParent)
                    {
                        dataIds.Append(node.Id);
                        dataIds.Append(",");
                    }
                }

                ldl.DataIds = dataIds.ToString().TrimEnd(',');
            }
            ldl.LoginId = Convert.ToInt32(loginId);
            ldl.RoleId  = int.Parse(DdlRoleList.SelectedValue);

            if (LoginDataLimitManager.Setlimit(ldl))
            {
                InitDataTree(Convert.ToInt32(loginId));
            }

            IList <LoginUserLimit> lulList = LoginUserLimitManager.getAllNodeById(Convert.ToInt32(loginId));

            ArrayList arrNodes = new ArrayList();

            foreach (LoginUserLimit userLimit in lulList)
            {
                arrNodes.Add(userLimit.Nodeid.Nodeid.ToString());
            }

            foreach (MyTreeNode mtn in menuList)
            {
                if (!arrNodes.Contains(mtn.Id.ToString()))
                {
                    LoginUserLimitManager.InsertUserLimt(loginId.ToString(), mtn.Id.ToString());
                }
            }

            foreach (MyTreeNode mtn in noMenuList)
            {
                if (arrNodes.Contains(mtn.Id.ToString()))
                {
                    LoginUserLimitManager.DeleteUserLimit(loginId.ToString(), mtn.Id.ToString());
                }
            }

            InitMenuTree(Convert.ToInt32(loginId));


            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('保存成功');self.location.href='../SysSet/LoginSet.aspx'</script>");
        }
Esempio n. 9
0
        private int LoginLimitIsEmpty()
        {
            LoginInfo login = LoginInfoManager.getLoginInfoByLoginID(this.txtLoginId.Text.ToString());

            return(LoginUserLimitManager.GetLimitCount(login.Id));
        }
Esempio n. 10
0
        /// <summary>
        /// 判断是否存在权限
        /// </summary>
        /// <returns></returns>
        private int LoginLimitIsEmpty(string Id)
        {
            LoginInfo login = LoginInfoManager.getLoginInfoById(Convert.ToInt32(Id));

            return(LoginUserLimitManager.GetLimitCount(login.Id));
        }