public JsonResult SaveFunctionAcl(string[] userIds, string code, string appCode) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(); if (userIds == null || userIds.Length == 0) { // 没有选中的用户 result.Message = "msgGlobalString.SelectUser"; result.Success = false; return Json(result, JsonRequestBehavior.AllowGet); } for (int i = 0; i < userIds.Length; i++) { // 验证是否有权限 if (!this.UserValidator.ValidateOrgAdmin(userIds[i])) { result.Message = "FunctionAcl.NotEnoughAuthorization"; result.Success = false; return Json(result, JsonRequestBehavior.AllowGet); } OThinker.H3.Acl.FunctionAcl acl = new OThinker.H3.Acl.FunctionAcl( userIds[i], code, true, this.UserValidator.UserID); // 添加 if (!this.Engine.FunctionAclManager.Add(acl)) { //因改为一次可添加多人 暂时去掉已存在节点添加失败的提醒 // 添加失败 //result.Success = false; //result.Extend = this.Engine.Organization.GetName(userIds[i]); //result.Message = "FunctionNode.AddAclFailed"; } else { result.Success = true; } } UpdateModifiedTime(code, appCode); return Json(result, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 保存权限设置 /// </summary> /// <param name="addSelectedIds"></param> /// <param name="delSelectedIds"></param> /// <param name="unitID">绑定权限的组织单元,用户,角色ID</param> /// <returns></returns> public JsonResult SaveAcl(string addSelectedIds, string delSelectedIds, string unitID) { ActionResult result = new ActionResult(true, "msgGlobalString.SaveSucced"); try { string[] addFunIds = addSelectedIds.Split(';'); string[] delFunIds = delSelectedIds.Split(';'); foreach (string id in addFunIds) { if (string.IsNullOrWhiteSpace(id)) { continue; } Acl.FunctionAcl acl = new OThinker.H3.Acl.FunctionAcl(); acl.CreatedBy = this.UserValidator.UserID; acl.CreatedTime = System.DateTime.Now; acl.FunctionCode = id; acl.Run = true; acl.UserID = unitID; this.Engine.FunctionAclManager.Add(acl); } foreach (string id in delFunIds) { if (string.IsNullOrWhiteSpace(id)) { continue; } this.Engine.FunctionAclManager.Delete(id); } } catch (Exception ex) { result.Success = false; result.Message = "保存失败," + ex.Message; } //客户端实现 //AddSelectIds.Value = ";"; //DelSelectIds.Value = ";"; return(Json(result)); }