예제 #1
0
        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 permissionKey = context.Request["key"];

            string type   = context.Request["type"];
            string cateID = context.Request["cateID"];

            sbWhere.AppendFormat(" 1=1 ");
            if (!string.IsNullOrWhiteSpace(type))
            {
                sbWhere.AppendFormat(" AND PermissionType={0}", type);
            }
            if (!string.IsNullOrWhiteSpace(cateID) && cateID != "0")
            {
                sbWhere.AppendFormat(" AND PermissionCateId ={0}", cateID);
            }
            if (!string.IsNullOrWhiteSpace(permissionKey))
            {
                sbWhere.AppendFormat(" AND PermissionKey like '%{0}%'", permissionKey);
            }
            if (!string.IsNullOrWhiteSpace(keyWord))
            {
                sbWhere.AppendFormat(" AND PermissionName like '%{0}%' Or Url like '%{0}%'", keyWord);
            }

            List <PermissionInfo> list = bllPer.GetLit <PermissionInfo>(pageSize, pageIndex, sbWhere.ToString(), "PermissionName");
            int totalCount             = bllPer.GetCount <PermissionInfo>(sbWhere.ToString());

            if (list.Count > 0)
            {
                BLLArticleCategory bllArticleCategory = new BLLArticleCategory();
                List <ZentCloud.BLLJIMP.Model.ArticleCategory> cateList = new BLLJIMP.BLLArticleCategory().GetList <ZentCloud.BLLJIMP.Model.ArticleCategory>(string.Format("WebsiteOwner='{0}' And CategoryType='{1}' Order by Sort", "Common", "Permission"));
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].PermissionCateId == 0)
                    {
                        continue;
                    }
                    ZentCloud.BLLJIMP.Model.ArticleCategory nowType = cateList.FirstOrDefault(p => p.AutoID == list[i].PermissionCateId);
                    if (nowType != null)
                    {
                        list[i].PermissionCate = nowType.CategoryName;
                    }
                }
            }
            return(Common.JSONHelper.ObjectToJson(
                       new
            {
                total = totalCount,
                rows = list
            }));
        }