예제 #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
            }));
        }
예제 #2
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        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
            }));
        }