private string Query(HttpContext context) { StringBuilder sbWhere = new StringBuilder(); int pageIndex = Convert.ToInt32(context.Request["page"]); int pageSize = Convert.ToInt32(context.Request["rows"]); string keyWord = context.Request["searchReq"]; string group_type = context.Request["group_type"]; string thisSite = context.Request["this_site"]; sbWhere.AppendFormat(" 1=1 "); if (!string.IsNullOrWhiteSpace(keyWord)) { sbWhere.AppendFormat(" AND GroupName like '%{0}%' ", keyWord); } if (!string.IsNullOrWhiteSpace(group_type)) { if (group_type == "0") { sbWhere.AppendFormat(" AND (GroupType ={0} OR GroupType Is Null) ", group_type); } else { sbWhere.AppendFormat(" AND GroupType ={0} ", group_type); } } if (thisSite == "1") { sbWhere.AppendFormat(" AND (WebsiteOwner Is Null Or WebsiteOwner='common')"); } else if (thisSite == "2") { sbWhere.AppendFormat(" AND WebsiteOwner ='{0}' ", bllPer.WebsiteOwner); } List <PermissionGroupInfo> List = bllPer.GetLit <PermissionGroupInfo>(pageSize, pageIndex, sbWhere.ToString()) .OrderByDescending(p => p.GroupType).ToList(); List <PermissionGroupInfo> dataList = new List <PermissionGroupInfo>(); foreach (var item in List.Where(p => p.GroupType == 1)) { item.has_column = bllPms.ExistsRelation(item.GroupID.ToString().ToString(), 3); item.PmsIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 0); item.MenuIdsStr = bllMenu.GetMenuStrByRelationID(item.GroupID.ToString(), 0); item.PmsColumnIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 3); dataList.Add(item); } foreach (var item in List.Where(p => p.GroupType == 2)) { item.has_column = bllPms.ExistsRelation(item.GroupID.ToString().ToString(), 3); item.PmsIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 0); item.MenuIdsStr = bllMenu.GetMenuStrByRelationID(item.GroupID.ToString(), 0); item.PmsColumnIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 3); dataList.Add(item); } foreach (var item in List.Where(p => p.GroupType == 0)) { item.has_column = bllPms.ExistsRelation(item.GroupID.ToString().ToString(), 3); item.PmsIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 0); item.MenuIdsStr = bllMenu.GetMenuStrByRelationID(item.GroupID.ToString(), 0); item.PmsColumnIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 3); dataList.Add(item); } foreach (var item in List.Where(p => p.GroupType == 3)) { item.has_column = bllPms.ExistsRelation(item.GroupID.ToString().ToString(), 3); item.PmsIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 0); item.MenuIdsStr = bllMenu.GetMenuStrByRelationID(item.GroupID.ToString(), 0); item.PmsColumnIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 3); dataList.Add(item); } foreach (var item in List.Where(p => p.GroupType == 4)) { item.has_column = bllPms.ExistsRelation(item.GroupID.ToString().ToString(), 3); item.PmsIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 0); item.MenuIdsStr = bllMenu.GetMenuStrByRelationID(item.GroupID.ToString(), 0); item.PmsColumnIdsStr = bllPms.GetPmsStrByRelationID(item.GroupID.ToString(), 3); dataList.Add(item); } int totalCount = bllPer.GetCount <PermissionGroupInfo>(sbWhere.ToString()); return(Common.JSONHelper.ObjectToJson( new { total = totalCount, rows = dataList })); }