예제 #1
0
        public ActionResult RoleFuncsTree(int?roleid)
        {
            var funcsall = DaoFunction.FindList();
            List <SYS_ROLEFUNCTION> exists = null;

            if (roleid != null)
            {
                exists = DaoRolefunction.FindList("", "ROLE_ID", roleid).ToList();
            }
            return(Json(GenRoleFuncsTree(funcsall, exists, null), JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Delete(string id)
        {
            try
            {
                var arrid = id.Split(',');
                foreach (var _id in arrid)
                {
                    dao.DeleteObject(dao.GetEntity("ROLE_ID", int.Parse(_id)));
                    DaoRolefunction.Delete("ROLE_ID", int.Parse(_id));
                    DaoUserole.Delete("ROLE_ID", int.Parse(_id));
                }

                return(RedirectToAction("/"));
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog("删除角色出错", ex);
                return(Redirect("/Home/Error"));
            }
        }
예제 #3
0
        public ActionResult GetRoleFuncsTree(int roleid, int?check, int?disabled, string searchNam)
        {
            var rolefunclist = DaoRolefunction.FindList("", "role_id", roleid);
            var funcsall     = DaoFunction.FindList();
            var tree         = new ZtreeNode
            {
                id        = "",
                name      = "顶级权限",
                @checked  = check == null,
                open      = true,
                isParent  = true,
                nocheck   = true,
                highlight = (string.IsNullOrEmpty(searchNam) ? false : "顶级权限".IndexOf(searchNam) > -1),
                children  = GenRoleFuncsTree(funcsall, rolefunclist, null, null
                                             , disabled, searchNam)
            };

            if (!string.IsNullOrEmpty(searchNam))
            {
                GenFuncsTreeHighlight(tree);
            }
            GenFuncsTreeHighlight2(tree, rolefunclist);
            return(Json(tree, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult RoleFuncSubmit(FormCollection formCollection)
        {
            int roleid   = Convert.ToInt32(formCollection["roleid"]);
            var allfuncs = DaoFunction.FindList();
            var exists   = DaoRolefunction.FindList("", "ROLE_ID", roleid);

            DaoRolefunction.DeleteObject(exists.ToList());
            var rolefuncs = formCollection["hidRoleFunc"];

            var addroleauths = new List <SYS_ROLEFUNCTION>();

            if (allfuncs != null && !string.IsNullOrEmpty(rolefuncs))
            {
                rolefuncs = "," + rolefuncs + ",";
                foreach (var func in allfuncs)
                {
                    if (rolefuncs.IndexOf("," + func.FUNCTION_ID + ",") > -1)
                    {
                        addroleauths.Add(new SYS_ROLEFUNCTION
                        {
                            ROLE_ID      = roleid,
                            FUNCTION_ID  = func.FUNCTION_ID,
                            CREATE_DTIME = DateTime.Now,
                            CREATE_ID    = UserState.UserID
                        });
                    }
                    if (rolefuncs.IndexOf("," + func.FUNCTION_ID + "_1,") > -1)
                    {
                        addroleauths.Add(new SYS_ROLEFUNCTION
                        {
                            ROLE_ID      = roleid,
                            FUNCTION_ID  = func.FUNCTION_ID,
                            FUNCTION_TYP = 1,
                            CREATE_DTIME = DateTime.Now,
                            CREATE_ID    = UserState.UserID
                        });
                    }
                    if (rolefuncs.IndexOf("," + func.FUNCTION_ID + "_2,") > -1)
                    {
                        addroleauths.Add(new SYS_ROLEFUNCTION
                        {
                            ROLE_ID      = roleid,
                            FUNCTION_ID  = func.FUNCTION_ID,
                            FUNCTION_TYP = 2,
                            CREATE_DTIME = DateTime.Now,
                            CREATE_ID    = UserState.UserID
                        });
                    }
                    if (rolefuncs.IndexOf("," + func.FUNCTION_ID + "_3,") > -1)
                    {
                        addroleauths.Add(new SYS_ROLEFUNCTION
                        {
                            ROLE_ID      = roleid,
                            FUNCTION_ID  = func.FUNCTION_ID,
                            FUNCTION_TYP = 3,
                            CREATE_DTIME = DateTime.Now,
                            CREATE_ID    = UserState.UserID
                        });
                    }
                    if (rolefuncs.IndexOf("," + func.FUNCTION_ID + "_4,") > -1)
                    {
                        addroleauths.Add(new SYS_ROLEFUNCTION
                        {
                            ROLE_ID      = roleid,
                            FUNCTION_ID  = func.FUNCTION_ID,
                            FUNCTION_TYP = 4,
                            CREATE_DTIME = DateTime.Now,
                            CREATE_ID    = UserState.UserID
                        });
                    }
                }
            }
            if (addroleauths.Count > 0)
            {
                DaoRolefunction.AddObject(addroleauths);
            }

            return(JsonResult(true, "提交成功"));
        }