public ActionResult Edit(int id, int?pid) { try { TempData["FUNCALL"] = DaoFunction.FindList(); var user = DaoFunction.GetEntity("FUNCTION_ID", id); if (null != pid) { if (pid != 0) { TempData["PARFUN"] = DaoFunction.GetEntity("FUNCTION_ID", pid); } else { ViewBag.pid = pid; } } return(View(user)); } catch (Exception e) { LogHelper.ErrorLog("修改权限出错", e); return(Json(new { result = false, desc = "系统错误,请重试" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(SYS_FUNCTION function) { try { if (string.IsNullOrEmpty(function.FUNCTION_NAM)) { ModelState.AddModelError("FUNCTION_NAM", "权限名称不能为空!"); } if (string.IsNullOrEmpty(function.FUNCTION_COD)) { ModelState.AddModelError("FUNCTION_COD", "权限编码不能为空!"); } else if (DaoFunction.GetEntity("FUNCTION_COD", function.FUNCTION_COD) != null) { ModelState.AddModelError("FUNCTION_COD", "权限编码已经存在!"); } if (!ModelState.IsValid) { ModelState.AddModelError("", "数据验证失败!"); return(JsonResult(false, "数据验证失败!")); } function.CREATE_ID = UserState.UserID; function.CREATE_DTIME = DateTime.Now; DaoFunction.AddObject(function); //RefleshFuncCache(); return(JsonResult(true, "新增成功", "AUTH", "/", false)); } catch (Exception ex) { LogHelper.ErrorLog("系统错误!", ex); return(JsonResult(false, "系统错误!")); } }
//[UserAuth("AUTH_FUNC_VIW")] public ActionResult GetFuncsTree(int?id, int?check, int?disabled, string searchNam) { var funcsall = DaoFunction.FindList(); var tree = new ZtreeNode { id = "", name = "顶级权限", @checked = check == null, open = true, isParent = true, nocheck = true, highlight = (!string.IsNullOrEmpty(searchNam) && "顶级权限".IndexOf(searchNam) > -1), children = GenFuncsTree(funcsall, null, check, disabled, searchNam) }; var treelist = new List <ZtreeNode> { tree }; if (null != id || Request.Form["lv"] == "0") { if (id == 0) { id = null; } treelist = GenFuncsTree(funcsall, id, check, disabled, searchNam); } if (!string.IsNullOrEmpty(searchNam)) { GenFuncsTreeHighlight(tree); } return(Json(treelist, JsonRequestBehavior.AllowGet)); }
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)); }
public ActionResult Details(int id) { var funcall = DaoFunction.FindList(); var model = DaoFunction.GetEntity("FUNCTION_ID", id); if (null != model) { model.Par_FuncList = funcall.Where(obj => obj.FUNCTION_ID == model.PAR_FUNCTION_ID).ToList(); } return(View(model)); }
public ActionResult Edit(SYS_FUNCTION function, int id, int?pid) { TempData["FUNCALL"] = DaoFunction.FindList(); var exituser = DaoFunction.GetEntity("FUNCTION_ID", id); var old = DaoFunction.GetEntity("FUNCTION_ID", function.FUNCTION_ID); try { if (string.IsNullOrEmpty(function.FUNCTION_NAM)) { ModelState.AddModelError("FUNCTION_NAM", "权限名称不能为空!"); } if (string.IsNullOrEmpty(function.FUNCTION_COD)) { ModelState.AddModelError("FUNCTION_COD", "权限编码不能为空!"); } else { var exist = DaoFunction.GetEntity("FUNCTION_COD", function.FUNCTION_COD); if (null != exist && exist.FUNCTION_ID != function.FUNCTION_ID) { ModelState.AddModelError("FUNCTION_COD", "权限编码已经存在!"); } } if (!ModelState.IsValid) { ModelState.AddModelError("", "修改失败"); return(JsonResult(false, "修改失败", "AUTH")); } function.MODIFY_ID = UserState.UserID; function.MODIFY_DTIME = DateTime.Now; var rst = dao.UpdateObject(function, "FUNCTION_ID"); if (rst > 0) { //RefleshFuncCache(); return(JsonResult(true, "修改成功", "AUTH", "/", false)); } else { ModelState.AddModelError("ModelState", "修改失败。"); return(JsonResult(false, "修改失败", "AUTH")); } } catch (Exception ex) { LogHelper.ErrorLog("修改失败", ex); ModelState.AddModelError("", "修改失败。"); return(Redirect("/Home/Error")); } }
internal ICollection <SYS_FUNCTION> GetFuncCache() { try { string key = "FUNCTIONCONTROLLLER_CACHEKEY_FUNCLIST"; return(new MemoryCacheProvider().Get(key, () => DaoFunction.FindList())); } catch (Exception ex) { LogHelper.ErrorLog("GetFuncCache", ex); return(null); } }
public ActionResult Edit(int id) { try { TempData["MENUALL"] = DaoMenu.FindList(); TempData["FUNCALL"] = DaoFunction.FindList(); var role = DaoMenu.GetEntity("MENU_ID", id); return(View(role)); } catch (Exception ex) { LogHelper.ErrorLog("修改菜单出错", ex); return(Json(new { result = false, desc = "系统错误,请重试" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(int?pid) { TempData["FUNCALL"] = DaoFunction.FindList(); if (null != pid) { if (pid != 0) { TempData["PARFUN"] = DaoFunction.GetEntity("FUNCTION_ID", pid); } else { ViewBag.pid = pid; } } return(View()); }
public ActionResult Details(int id) { try { var menuall = DaoMenu.FindList(); var menu = DaoMenu.GetEntity("MENU_ID", id); if (null != menu) { menu.Par_MenuList = menuall.Where(obj => obj.MENU_ID == menu.PAR_MENU_ID).ToList(); menu.Func = DaoFunction.GetEntity("FUNCTION_ID", menu.FUNCTION_ID); } return(View(menu)); } catch (Exception ex) { LogHelper.ErrorLog("查看菜单出错", ex); return(Json(new { Result = false, Text = "系统出错!" + ex.Message }, JsonRequestBehavior.AllowGet)); } }
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)); }
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, "提交成功")); }
public ActionResult Create() { TempData["FUNCALL"] = DaoFunction.FindList(); TempData["MENUALL"] = DaoMenu.FindList(); return(View()); }