public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; NameValueCollection rp = context.Request.Form; string msg = string.Empty; try { if (string.IsNullOrEmpty(rp["roleID"])) { msg = "角色不能为空,请选择角色"; } else { List<BaseEntity> list = new List<BaseEntity>(); int count = int.Parse((rp["count"])); //先删除该角色的授权,然后重新创建 int loop = (rp.Count - 2) / 8; Guid roleId= new Guid(rp["roleID"]); for (int i = 0; i < loop; i++) { FuncAccess entity = new FuncAccess(); entity.ID = Guid.NewGuid(); entity.RoleID = roleId; entity.FunctID = rp["acc[" + i + "][ID]"]; bool isbool = false; if (bool.TryParse(rp["acc[" + i + "][FaccIsEnable]"],out isbool)) { entity.IsEnable = isbool; } if (bool.TryParse(rp["acc[" + i + "][IsView]"], out isbool)) { entity.IsView = isbool; } list.Add(entity); } FuncAccessManager manager = new FuncAccessManager( ); manager.Save(roleId, list); context.Response.Write("{\"success\":\"true\" }"); } } catch (Exception ex) { msg = ex.Message; } if (!string.IsNullOrEmpty(msg)) { byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>")); string encode = Convert.ToBase64String(bytes); context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}"); } context.Response.End(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.ContentType = "text/plain"; FuncAccessManager manager = new FuncAccessManager(); HttpRequest rp = context.Request; Guid roleID = new Guid(rp["roleID"]); DataTable dt = manager.GetDataTable(roleID); string result = JsonConvert.Convert2Json(dt); context.Response.Write(result); context.Response.End(); }
protected void Page_PreRender(object sender, EventArgs e) { string path = this.Request.FilePath.ToLower(); if (path.EndsWith("adminIndex.aspx") || path.EndsWith("main.aspx") || path.EndsWith("login.aspx") || path.EndsWith("randomcode.aspx") || path.EndsWith("index.aspx") || path.Contains("edit.aspx")||path.EndsWith("resetpwd.aspx") ) { } else { //权限判断 //先获取当前功能 string funcUrl = path.Substring(path.LastIndexOf("/") + 1); bool hasAcc = new FuncAccessManager().HasAccess(Session["UserID"].ToString(), Session["UserName"].ToString(), funcUrl); if (!hasAcc) { Response.Write("<script>alert('您没有当前功能权限!');</script>"); Response.End(); } } }
private void GenarateNavigator() { string userName = Session["UserName"].ToString(); string userID = Session["UserID"].ToString(); DataTable dt = null; try { dt = new FuncAccessManager().GetAccess(userID, userName); } catch (Exception) { Response.Write("<script>alert('当前用户没有设置任何角色,请联系管理员设置系统角色!');</script>"); Response.End(); } List<FunctionInfo> list = dt.ToList<FunctionInfo>(); IEnumerable<FunctionInfo> root = list.Where(p => !p.ParentID.HasValue); int i = 0; foreach (FunctionInfo item in root) { sb.Append("<ul style='display: block;'>"); string isclose = " close "; if (i > 0) { isclose = "close"; } sb.AppendFormat(@"<li><a navid='site_manage' class='item pack {0}'> <div class='arrow'> </div> <div class='expandable open '> </div> <div class='folder close'> </div> <span>" + item.Name + "</span> </a>", isclose); //查找当前功能组的子功能 int count = list.Count(p => p.ParentID == item.ID); if (count > 0) { sb.Append("<ul class='subblock'>"); IEnumerable<FunctionInfo> childs = list.Where(p => p.ParentID == item.ID); foreach (FunctionInfo child in childs) { sb.AppendFormat(@"<li><a navid='site_config' href='{0}' target='mainframe' class='item'> <div class='arrow'> </div> <div class='expandable'> </div> <div class=''> </div> <span class='subMenu'>{1}</span> </a></li>", child.Url, child.Name); } sb.Append("</ul>"); } sb.Append("</li>"); sb.Append("</ul>"); } if (Session["UserID"].ToString().Open() == StaticClass.RootKey) { sb.Append("<ul style='display: block;'>"); sb.Append(@"<li><a navid='site_config' href='FunctionInfoList.aspx' target='mainframe' class='item'> <div class='arrow'> </div> <div class='expandable'> </div> <div class=''> </div> <span class='subMenu'>功能设置</span> </a></li>"); sb.Append("</ul>"); } Navigator = sb.ToString(); }