public ActionResult BindRole(string id) { if (string.IsNullOrEmpty(id) || TypeHelper.TypeToInt32(id, -1) < 0) { return(RedirectToAction("List")); } var dataList = DawnAuthRoleBLL.ISelect(); var roleList = DawnAuthUserRoleBLL.ISelect(string.Format("user_id='{0}'", int.Parse(id))); ViewBag.UserId = id; ViewBag.UserBindRole = roleList; return(View(dataList)); }
public string Authorityed(FormCollection form) { var stateInfo = GeneralHandler.StateSuccess; string roleCode = form["hidRoleCode"]; string moduleCode = form["moduleCode"]; string authString = form["authString"]; var roleInfo = DawnAuthRoleBLL.ISelect(string.Format("role_code='{0}'", roleCode)).First(); if (string.IsNullOrEmpty(roleInfo.RoleAuthority) || string.IsNullOrWhiteSpace(roleInfo.RoleAuthority) || !roleInfo.RoleAuthority.Contains(moduleCode)) { authString = "|" + authString; authString = moduleCode + authString; authString += ";"; if (!string.IsNullOrWhiteSpace(roleInfo.RoleAuthority)) { authString = roleInfo.RoleAuthority + authString; } } else { string[] authArray = GetModuleFunction(roleInfo.RoleAuthority); for (int i = 0; i < authArray.Length; i++) { if (string.IsNullOrWhiteSpace(authArray[i])) { continue; } if (authArray[i].Contains(moduleCode)) { authArray[i] = "|" + authString; authArray[i] = moduleCode + authArray[i]; break; } } authString = null; for (int i = 0; i < authArray.Length; i++) { if (string.IsNullOrWhiteSpace(authArray[i])) { continue; } authString += authArray[i]; authString += ";"; } } DawnAuthRoleBLL.Update(roleCode, authString); return(stateInfo); }
public string Function(FormCollection form) { int moduleId = TypeHelper.TypeToInt32(form["moduleId"], 0); string roleCode = form["roleCode"] as string; string moduleCode = form["moduleCode"] as string; var stateInfo = GeneralHandler.StateFailing; if (moduleId > 0 && !string.IsNullOrEmpty(roleCode) && !string.IsNullOrEmpty(moduleCode)) { StringBuilder sb = new StringBuilder(); int indexVal = 0; var roleInfo = DawnAuthRoleBLL.ISelect(string.Format("role_code='{0}'", roleCode)).First(); int[] funArray = null; if (!string.IsNullOrEmpty(roleInfo.RoleAuthority) && !string.IsNullOrWhiteSpace(roleInfo.RoleAuthority)) { funArray = GetFunction(moduleCode, roleInfo.RoleAuthority); } var funList = DawnAuthFunctionBLL.ISelect(string.Format("mdl_id='{0}' and (fun_ident < 1)", moduleId), "fun_mark"); if (funList == null || funList.Count < 1) { sb.Append("<li class=\"field-item bi\">"); sb.Append(GeneralHandler.FNoneInfo); sb.Append("</li>"); } else { foreach (var item in funList) { indexVal++; sb.Append("<li class=\"field-item bi\">"); sb.AppendFormat("<label>{0}</label>", item.FunName); int flag = 0; if (funArray != null && funArray.Length > 0) { int indexValue = item.FunMark - 1; if (indexValue < funArray.Length) { if (funArray[indexValue] == 1) { flag = 1; } } } if (flag == 1) { sb.AppendFormat("<input class=\"switch-on\" type=\"button\" id=\"btn{0}\" onclick=\"dataSave({0},'{1}','del');\" />", indexVal, moduleCode); sb.AppendFormat("<input type=\"hidden\" id=\"hidAuth{0}\" value=\"1\" />", indexVal); } else { sb.AppendFormat("<input class=\"switch-off\" type=\"button\" id=\"btn{0}\" onclick=\"dataSave({0},'{1}','add');\" />", indexVal, moduleCode); sb.AppendFormat("<input type=\"hidden\" id=\"hidAuth{0}\" value=\"0\" />", indexVal); } sb.Append("</li>"); } } sb.AppendFormat("<input type=\"hidden\" id=\"hidAuthCount\" value=\"{0}\" />", funList.Count); stateInfo = sb.ToString(); } return(stateInfo); }