Exemplo n.º 1
0
        public ActionResult SetAccess(string[] selectOperate, int roleId = 0, int userId = 0)
        {
            if (selectOperate == null)
            {
                return(AutoBackResult("失败,选择菜单为空"));
            }
            List <AccessControl> list = new List <AccessControl>();
            int systemId = currentSystemId;

            foreach (string s in selectOperate)
            {
                CRL.Package.RoleAuthorize.AccessControl item = new CRL.Package.RoleAuthorize.AccessControl();
                bool insert = false;
                if (Request["Query_" + s] != null)
                {
                    insert   = true;
                    item.Que = true;
                }

                if (userId == 0)
                {
                    item.Role     = roleId;
                    item.RoleType = RoleType.角色;
                }
                else
                {
                    item.Role     = userId;
                    item.RoleType = RoleType.用户;
                }
                item.MenuCode = s;
                if (insert)
                {
                    item.SystemTypeId = systemId;
                    list.Add(item);
                }
            }

            if (userId == 0)
            {
                AccessControlBusiness.Instance.Delete(b => b.Role == roleId && b.RoleType == RoleType.角色 && b.SystemTypeId == systemId);
            }
            else
            {
                AccessControlBusiness.Instance.Delete(b => b.Role == userId && b.RoleType == RoleType.用户 && b.SystemTypeId == systemId);
            }
            AccessControlBusiness.Instance.BatchInsert(list);
            return(AutoBackResult("设置成功", Request.UrlReferrer.ToString()));
        }
Exemplo n.º 2
0
        public ActionResult SetItemAccess(string menuCode, bool acc, int roleId = 0, int userId = 0)
        {
            int systemId = currentSystemId;

            foreach (string str in menuCode.Split(','))
            {
                string s = str.Trim();
                CRL.Package.RoleAuthorize.AccessControl item = new CRL.Package.RoleAuthorize.AccessControl();
                item.SystemTypeId = systemId;
                if (userId == 0)
                {
                    item.Role     = roleId;
                    item.RoleType = RoleType.角色;
                }
                else
                {
                    item.Role     = userId;
                    item.RoleType = RoleType.用户;
                }
                item.Que      = acc;
                item.MenuCode = s.Trim();

                AccessControl item2;
                if (userId == 0)
                {
                    item2 = AccessControlBusiness.Instance.QueryItem(b => b.Role == roleId && b.RoleType == RoleType.角色 && b.SystemTypeId == systemId && b.MenuCode == s);
                }
                else
                {
                    item2 = AccessControlBusiness.Instance.QueryItem(b => b.Role == userId && b.RoleType == RoleType.用户 && b.SystemTypeId == systemId && b.MenuCode == s);
                }
                if (item2 == null)
                {
                    AccessControlBusiness.Instance.Add(item);
                }
                else
                {
                    ParameCollection c = new ParameCollection();
                    c["Que"] = item.Que;
                    AccessControlBusiness.Instance.Update(b => b.Id == item2.Id, c);
                }
            }
            return(JsonResult(true, ""));
        }
Exemplo n.º 3
0
        public ActionResult SetAccess(string[] selectOperate, int roleId=0, int userId = 0)
        {
            if (selectOperate == null)
            {
                return AutoBackResult("失败,选择菜单为空");
            }
            List<AccessControl> list = new List<AccessControl>();
            int systemId = currentSystemId;
            foreach (string s in selectOperate)
            {
                CRL.Package.RoleAuthorize.AccessControl item = new CRL.Package.RoleAuthorize.AccessControl();
                bool insert = false;
                if(Request["Query_" + s] != null)
                {
                    insert = true;
                    item.Que=true;
                }

                if (userId == 0)
                {
                    item.Role = roleId;
                    item.RoleType = RoleType.角色;
                }
                else
                {
                    item.Role = userId;
                    item.RoleType = RoleType.用户;
                }
                item.MenuCode =s;
                if (insert)
                {
                    item.SystemTypeId = systemId;
                    list.Add(item);
                }
            }

            if (userId == 0)
            {
                AccessControlBusiness.Instance.Delete(b => b.Role == roleId && b.RoleType == RoleType.角色 && b.SystemTypeId == systemId);
            }
            else
            {
                AccessControlBusiness.Instance.Delete(b => b.Role == userId && b.RoleType == RoleType.用户 && b.SystemTypeId == systemId);
            }
            AccessControlBusiness.Instance.BatchInsert(list);
            return AutoBackResult("设置成功",Request.UrlReferrer.ToString());
        }
Exemplo n.º 4
0
        public ActionResult SetItemAccess(string menuCode,bool acc, int roleId = 0, int userId = 0)
        {
            int systemId = currentSystemId;
            foreach (string str in menuCode.Split(','))
            {
                string s = str.Trim();
                CRL.Package.RoleAuthorize.AccessControl item = new CRL.Package.RoleAuthorize.AccessControl();
                item.SystemTypeId = systemId;
                if (userId == 0)
                {
                    item.Role = roleId;
                    item.RoleType = RoleType.角色;
                }
                else
                {
                    item.Role = userId;
                    item.RoleType = RoleType.用户;
                }
                item.Que = acc;
                item.MenuCode = s.Trim();

                AccessControl item2;
                if (userId == 0)
                {
                    item2 = AccessControlBusiness.Instance.QueryItem(b => b.Role == roleId && b.RoleType == RoleType.角色 && b.SystemTypeId == systemId && b.MenuCode == s);
                }
                else
                {
                    item2 = AccessControlBusiness.Instance.QueryItem(b => b.Role == userId && b.RoleType == RoleType.用户 && b.SystemTypeId == systemId && b.MenuCode == s);
                }
                if (item2 == null)
                {
                    AccessControlBusiness.Instance.Add(item);
                }
                else
                {
                    ParameCollection c = new ParameCollection();
                    c["Que"] = item.Que;
                    AccessControlBusiness.Instance.Update(b => b.Id == item2.Id, c);
                }
            }
            return JsonResult(true,"");
        }