public ActionResult Edit(string ids) { var id = int.Parse(ids); R_User_ActionInfo act = R_User_ActionInfoService.LoadEntities(u => u.ID == id).FirstOrDefault(); var result = new { model = act }; JsonResult str = Json(result, JsonRequestBehavior.AllowGet); return(Json(result, JsonRequestBehavior.AllowGet)); }
//去除特殊权限 public ActionResult RemoveUserAction(int UserInfoID, int ActionInfoID) { //R_User_ActionInfoService.Delete() var item = R_User_ActionInfoService.LoadEntities(r => r.UserInfoID == UserInfoID && r.ActionInfoID == ActionInfoID) .FirstOrDefault(); if (item != null) { item.DelFlag = (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Deleted; R_User_ActionInfoService.SaveChanges(); } return(Content("ok")); }
//#region 设置角色 //public ActionResult GetRoleInfo(Guid SUser) //{ // var delNormal = (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Normal; // UserInfo userInfo = UserInfoService.LoadEntities(u => u.ID == SUser && u.DelFlag == delNormal).FirstOrDefault(); // if (userInfo != null) // { // var allRoleInfo = RoleInfoService.LoadEntities(u => u.DelFlag == delNormal).ToList(); // var data = new // { // Rows = (from r in allRoleInfo // select // new { r.ID, r.Name, r.SubTime, r.SubBy, selected = userInfo.RoleInfo.Contains(r) }).ToList() // }; // return Json(data, JsonRequestBehavior.AllowGet); // } // else // { // return Content("选择的用户不存在!"); // } //} //[HttpPost] //public ActionResult SetUserRoleSave(string UserId, string RolesId) //{ // short delNormal = (short)Model.Enum.DelFlagEnum.Normal; // string[] idStrs = null; // //用户选择的角色 // List<RoleInfo> userRoleSelList = new List<RoleInfo>(); // Guid idUser = Guid.Parse(UserId); // if (RolesId != "") // { // idStrs = RolesId.Split(','); // } // UserInfo userInfo = UserInfoService.LoadEntities(u => u.ID == idUser && u.DelFlag == delNormal).FirstOrDefault(); // if (userInfo == null) // { // return Content("系统运行出错!"); // } // /**************************************************************/ // userInfo.RoleInfo.Clear(); // if (idStrs != null) // { // foreach (var idStr in idStrs) // { // Guid roleId = Guid.Parse(idStr); // RoleInfo roleInfo = RoleInfoService.LoadEntities(u => u.ID == roleId && u.DelFlag == delNormal).FirstOrDefault(); // userInfo.RoleInfo.Add(roleInfo); // } // } // if (UserInfoService.Savechanges() > 0) // { // return Content("ok"); // } // else // { // return Content("系统运行出错!"); // } /**************************************************************/ //给用户添加用户选择的角色 //if (idStrs != null) //{ // //添加已选 // foreach (var idStr in idStrs) // { // Guid roleId = Guid.Parse(idStr); // RoleInfo roleInfo = RoleInfoService.LoadEntities(u => u.ID == roleId && u.DelFlag == delNormal).FirstOrDefault(); // userRoleSelList.Add(roleInfo); // //只添加原来没有的角色 // if (!userInfo.RoleInfo.Contains(roleInfo)) // { // userInfo.RoleInfo.Add(roleInfo); // } // } // //已选权限 // var userRoleDelList = userInfo.RoleInfo.Except(userRoleSelList).ToList(); // foreach (var roleEx in userRoleDelList) // { // userInfo.RoleInfo.Remove(roleEx); // } //} //else //{ // userInfo.RoleInfo.Clear(); //} //if (UserInfoService.Savechanges() > 0) //{ // return Content("ok"); //} //else //{ // return Content("ok"); //} //} //#endregion #region 设置用户的特殊权限 public ActionResult SetAction(int id) { short delNormal = (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Normal; ViewData.Model = UserInfoService.LoadEntities(u => u.ID == id).FirstOrDefault(); ViewBag.ExistUserActions = R_User_ActionInfoService.LoadEntities(r => r.DelFlag == delNormal && r.UserInfoID == id).ToList(); //后台往前天传递 所有的权限 ViewBag.AllActionInfos = ActionInfoService.LoadEntities(a => a.DelFlag == delNormal).ToList(); return(View()); }
public ActionResult GetUserAction(int SUser) { //拿到前台发送来的是当前页面和页的大小 short delNormal = (short)Model.Enum.DelFlagEnum.Normal; var userActionList = R_User_ActionInfoService.LoadEntities(u => u.UserInfoID == SUser && u.DelFlag == delNormal).ToList(); var data = new { Rows = (from u in userActionList select new{ ID = u.ID, Action = u.ActionInfo.Name, u.IsPass }).ToList() }; return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(R_User_ActionInfo act) { if (act.UserInfoID == 0) { return(Content("请选择用户")); } if (act.ActionInfoID == 0) { return(Content("请选择权限")); } //查找已有权限 var userAction = R_User_ActionInfoService.LoadEntities(u => u.UserInfoID == act.UserInfoID && u.ActionInfoID == act.ActionInfoID).FirstOrDefault(); if (userAction != null) { if (userAction.DelFlag == (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Deleted) { userAction.DelFlag = (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Normal; if (R_User_ActionInfoService.Update(userAction)) { R_User_ActionInfoService.SaveChanges(); return(Content("ok")); } } else { return(Content("该用户权限已经存在,不允许重复添加!")); } } //查找用户编码 var user = UserInfoService.LoadEntities(u => u.ID == act.UserInfoID).FirstOrDefault(); //查找权限编码 var action = ActionInfoService.LoadEntities(u => u.ID == act.ActionInfoID).FirstOrDefault(); //#region 生成编码 act.Code = user.Code + "-" + action.Code; act.Name = user.Name + "-" + action.Name; act.DelFlag = (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Normal; R_User_ActionInfoService.Add(act); if (R_User_ActionInfoService.SaveChanges() > 0) { return(Content("ok")); } return(Content("添加失败了")); }
//添加特殊权限 public ActionResult SetUserActionPasss(R_User_ActionInfo userAction) { var item = R_User_ActionInfoService.LoadEntities(r => r.UserInfoID == userAction.UserInfoID && r.ActionInfoID == userAction.ActionInfoID) .FirstOrDefault(); if (item == null)//如果没有那么直接添加 { R_User_ActionInfoService.Add(userAction); R_User_ActionInfoService.SaveChanges(); } else//如果有那么直接修改 { item.IsPass = userAction.IsPass; item.DelFlag = (short)SS.Platform.OA.Model.Enum.DelFlagEnum.Normal; R_User_ActionInfoService.SaveChanges(); } return(Content("ok")); }