/// <summary> /// 记录当前操作权限名称 add by zfj 2015-6-5 /// </summary> /// <param name="refresh">是否强制更新缓存</param> protected void SaveCurrentOperate(bool refresh = false) { try { string url = Request.Url.LocalPath.ToLower(); //跳过ashx if (url.IndexOf(".ashx") < 0) { //无缓存数据 或者 强制刷新 if (CacheHelper.GetCache("OpList") == null || refresh) { var list = new Sys_Operating_BLL().GetList(" optionlevel=2 "); //记录二级菜单 list.Add(new Sys_Operating { Url = "/login.aspx", Name = "用户登录" }); CacheHelper.SetCache("OpList", list); } //记录当前操作权限名称 var listCache = CacheHelper.GetCache("OpList") as List <Sys_Operating>; if (listCache.Where(p => p.Url.ToLower().Contains(url)).Count() > 0) { _CurrentOperatName = listCache.Where(p => p.Url.ToLower().Contains(url)).ToList()[0].Name; RequestSession.GetSessionUser().CurrentOperate = _CurrentOperatName; } } } catch (Exception ex) { } }
/// <summary> /// 绑定tree列表 /// add by fzz /// 16-03-02 /// </summary> /// <param name="context"></param> public void getZTree(HttpContext context) { string id = context.Request["id"] ?? ""; if (string.IsNullOrEmpty(id)) { return; } Sys_Operating_BLL bll = new Sys_Operating_BLL(); List <Sys_RoleOperating> roleList = new Sys_Role_BLL().GetListOperate(id); string[] allIDs = roleList.Select(p => p.OperatingId.ToString()).ToArray();//该角色授权过的所有权限 List <Sys_Operating> oList = bll.GetList(""); StringBuilder sstr = new StringBuilder(); if (oList != null && oList.Count > 0) { foreach (var item in oList) { sstr.Append("{ \"id\": \"" + item.ID + "\", \"pId\": \"" + item.ParentId + "\", \"name\": \"" + item.Name + "\"" + (item.ParentId == null ? ",\"open\":true" : "") + (allIDs.Contains(item.ID + "") ? ",\"checked\": true}," : "},")); } } //context.Response.Write(JsonConvert.SerializeObject(oList)); context.Response.Write("[" + sstr.ToString().TrimEnd(',') + "]"); }
/// <summary> /// 绑定权限信息 /// 创建人:yxy /// 创建时间:2015-06-02 /// </summary> /// <param name="ID"></param> public void BindInfo(string ID) { if (ID != "") { Sys_Operating_BLL OperatBll = new Sys_Operating_BLL(); Sys_VW_Operating operatM = OperatBll.SelectVWModel(" ID='" + ID + "'"); if (operatM != null) { HidID.Value = ID; name.Value = operatM.Name; parentid.Value = operatM.ParentId.ToString(); code.Value = operatM.Code; level.Value = operatM.OptionLevel.ToString(); url.Value = operatM.Url; order.Value = operatM.SortOrder.ToString(); if (operatM.IsPublicOperating.Value) { isPublic.Value = "1"; isPublic2.Value = "1"; } else { isPublic.Value = "0"; isPublic2.Value = "0"; } description.Value = operatM.Description; CreateDate.Value = operatM.CreateDate.ToString(); } } }
/// <summary> /// 添加菜单 /// 创建人:yxy /// 时间:2015-06-2 /// </summary> public void OperatingAdd(HttpContext context) { PD.BLL.Sys_Operating_BLL bll = new Sys_Operating_BLL(); Sys_Operating model = new Sys_Operating(); model.ID = Guid.NewGuid(); model.Name = context.Request["name"]; if (context.Request["parentid"] == "" || context.Request["parentid"] == null) { model.ParentId = null; } else { model.ParentId = new Guid(context.Request["parentid"]); } model.Code = context.Request["code"]; if (context.Request["level"] == "") { model.OptionLevel = null; } else { model.OptionLevel = Convert.ToInt32(context.Request["level"]); } model.Url = context.Request["url"]; if (context.Request["order"] == "") { model.SortOrder = null; } else { model.SortOrder = Convert.ToInt32(context.Request["order"]); } if (context.Request["isPublic2"] == "" || context.Request["isPublic2"] == null) { model.IsPublicOperating = null; } else if (context.Request["isPublic2"] == "1") { model.IsPublicOperating = true; } else if (context.Request["isPublic2"] == "0") { model.IsPublicOperating = false; } model.Description = context.Request["description"]; //model.CreateDate = DateTime.Now; if (bll.Insert(model)) { context.Response.Write("1"); } else { context.Response.Write("0"); } }
/// <summary> /// 获取菜单列表 /// 创建人:yxy /// 时间:2015-06-02 /// </summary> /// <param name="context"></param> public void OperatingList(HttpContext context) { Sys_Operating_BLL bll = new Sys_Operating_BLL(); string pageIndex = context.Request["pageIndex"] ?? ""; string pageSize = context.Request["pageSize"] ?? ""; string name = StringHelper.SqlSpecialConvert(context.Request["sname"] ?? "", StringConverTypeEnum.Like); int pageCount = 1; StringBuilder sb = new StringBuilder(); List <Sys_VW_Operating> list = bll.GetListByPage(Convert.ToInt32(pageIndex), Convert.ToInt32(pageSize), name, ref pageCount); if (list.Count > 0) { sb.Append("<tr><th>权限名称</th><th>父级权限</th><th>编号</th><th>操作级别</th><th>链接地址</th><th>权限描述</th><th>权限排序</th><th>是否公共操作</th><th>创建日期</th><th>基本操作</th></tr>"); foreach (var item in list) { string isPublic = ""; if (item.IsPublicOperating.Value) { isPublic = "公开"; } else { isPublic = "不公开"; } sb.Append("<tr>"); //sb.Append("<td><input type='checkbox' value='" + item.ID + "' name='MySelect'/></td>"); sb.Append("<td>" + item.Name + "</td>"); sb.Append("<td>" + item.ParentName + "</td>"); sb.Append("<td>" + item.Code + "</td>"); sb.Append("<td>" + item.OptionLevel + "</td>"); sb.Append("<td>" + item.Url + "</td>"); sb.Append("<td>" + item.Description + "</td>"); sb.Append("<td>" + item.SortOrder + "</td>"); sb.Append("<td>" + isPublic + "</td>"); sb.Append("<td>" + DateTimeHelper.ToString(item.CreateDate.Value, PD.Common.DateTimeHelper.DateFormat.SHORTDATE) + "</td>"); sb.Append("<td>"); sb.Append("<a href='OperatingAdd.aspx?action=edit&ID=" + item.ID + "'>编辑</a>"); //sb.Append("<a href=''>删除</a>"); sb.Append("</td>"); sb.Append("</tr>"); } context.Response.Write("{\"count\":\"" + pageCount + "\",\"data\":\"" + sb.ToString().Replace("\r", "").Replace("\n", "").Replace("\t", "") + "\"}"); } else { context.Response.Write("{\"count\":\"0\",\"data\":\"\"}"); } }
/// <summary> /// 导出Excel列表 /// 时间:2015-08-16 /// 创建人:wsy /// </summary> /// <param name="context"></param> public void ExportExcel(HttpContext context) { string type = context.Request["type"]; string name = StringHelper.SqlSpecialConvert(context.Request["sname"] ?? "", StringConverTypeEnum.Like); List <Sys_VW_Operating> oplist; Sys_Operating_BLL bll = new Sys_Operating_BLL(); string pageIndex = context.Request["pageIndex"] ?? ""; string pageSize = context.Request["pageSize"] ?? ""; pageIndex = type == "all" ? "1" : pageIndex; int pageCount = 1; oplist = bll.GetListByPage(Convert.ToInt32(pageIndex), Convert.ToInt32(pageSize), name, ref pageCount);//权限列表 Excel.ExportExcelByMyXls <Sys_VW_Operating>(oplist, "Name,ParentName,Code,OptionLevel,Url,Description,SortOrder,IsPublicName,ToDateShort", "权限名称,父级权限,编号,操作级别,链接地址,权限描述,权限排序,是否公共操作,创建日期", "OperatingList.xls", "权限列表导出"); LogHelper.InserLog((int)EnumClass.OperateType.导出操作, PageBase.CurrentOperatName, "导出了权限列表"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = Context.Request["id"] ?? ""; //string name=Context.Request["name"]??""; if (string.IsNullOrEmpty(id)) { return; } this.id.Value = id; // this.name.Value = name; int totalCount = 0; Sys_Operating_BLL bll = new Sys_Operating_BLL(); List <Sys_RoleOperating> roleList = new Sys_Role_BLL().GetListOperate(id); string[] allIDs = roleList.Select(p => p.OperatingId.ToString()).ToArray(); //该角色授权过的所有权限 List <Sys_Operating> operList = bll.GetList("", false); //父级 totalCount += operList.Count; foreach (var key in operList) { //查询子级 List <Sys_Operating> childList = bll.GetList(key.ID.ToString(), true); totalCount += childList.Count; } StringBuilder html = new StringBuilder(); foreach (var key in operList) { //查询子级 List <Sys_Operating> childList = bll.GetList(key.ID.ToString(), true); html.Append("<div class='user_jur_h1'><span><input type='checkbox' newname='MySelect' count='" + childList.Count + "' value='" + key.ID + "' id='" + key.ID + "' onclick='CheckBoxP(this," + totalCount + ")' " + (allIDs.Contains(key.ID.ToString()) ? "checked=checked" : "") + "/><em>" + key.Name + "</em></span></div>"); if (childList.Count > 0) { html.Append("<div class='user_jur_h2'>"); foreach (var item in childList) { html.Append(" <span><input type='checkbox' name='" + item.ParentId + "' count='" + childList.Count + "' id='" + item.ID + "' value='" + item.ID + "' onclick='CheckBoxC(this," + totalCount + ")' newname='MySelect' " + (allIDs.Contains(item.ID.ToString()) ? "checked=checked" : "") + " /><em>" + item.Name + "</em></span>"); } html.Append("</div>"); } } html.Append(" <div class='user_jur_h3'><span><input type='checkbox' id='selectAll' " + (Regex.Matches(html.ToString(), @"checked").Count / 2 == totalCount ? "checked=checked" : "") + " onclick='selectAlls()'/><em>全选</em></span></div>"); this.operates.InnerHtml = html.ToString(); } }
/// <summary> /// 绑定操作模块 /// 创建人:wsy /// 时间:2015-06-02 /// </summary> /// <param name="context"></param> private void SelectOperate(HttpContext context) { Sys_Operating_BLL opbll = new Sys_Operating_BLL(); List <Sys_Operating> operating = opbll.GetList(" OptionLevel=2 and Name!='用户日志'");//只查询二级页面 operating = operating.OrderBy(p => p.Name).ToList(); StringBuilder oper = new StringBuilder(); oper.Append("<option value=\"\">全部</option>"); if (operating.Count > 0) { for (int i = 0; i < operating.Count; i++) { if (Convert.ToBoolean(operating[i].IsPublicOperating)) { oper.Append("<option value=\"" + operating[i].ID + "\">" + operating[i].Name + "</option>"); } } } context.Response.Write(oper); }
public void GetOpidByUrl(HttpContext context) { string opUrl = context.Request["opUrl"] ?? ""; if (string.IsNullOrEmpty(opUrl)) { context.Response.Write("0"); } else { Sys_Operating_BLL bll = new Sys_Operating_BLL(); Sys_Operating op = bll.SelectModel(" url like '%" + opUrl + "%' "); if (op != null) { context.Response.Write(op.ID); } else { context.Response.Write("0"); } } }