Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pg_uid">"Corp_Page_News"</param>
        /// <param name="blk_name">"Focus"</param>
        /// <param name="topn">"5"</param>
        /// <returns></returns>
        public Stream CMSItems_SelectPaged(string pg_uid, string blk_name, string topn)
        {
            // 得到上下文
            WebOperationContext woc = WebOperationContext.Current;

            // 设置响应格式,消除了返回为string的有反斜杠情况
            woc.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            string json = "";

            CMSBlocksInfo block = CacheMarker.GetCMSBlocksInfo(pg_uid, blk_name);

            if (block == null)
            {
                return(null);
            }
            // 获得发布过的前topn条数据
            List <CMSItemsInfo> cmsItems = new List <CMSItemsInfo>();

            cmsItems = DataAccess_News.CMSItems_SelectTopN2(block.blk_id, int.Parse(topn), "" /*" and n_publish = 1"*/);

            var jsonSerialiser = new JavaScriptSerializer();

            json = string.Format("{{\"AppTop\":{0}}}", jsonSerialiser.Serialize(cmsItems));

            return(new MemoryStream(Encoding.UTF8.GetBytes(json)));
        }
Exemple #2
0
        public static Response Process_Index_Pics()
        {
            var pics_mb = CacheMarker.GetCMSBlocksInfo("App_Header_Pic", "Focus").ToMaybe()     // get info of the block with a path of 'App_Header_Pic.Focus'. Refer to behind website for more details
                          .Select(block => DataAccess_News.CMSItems_SelectTopN2(block.blk_id, 5, "").ToMaybe())
                          .Select(items => items.Select(item => new Index_Pic()
            {
                href = item.n_linkUrl, img_src = item.n_imageUrl, title = item.n_title
            }).ToList().ToMaybe());

            var body     = pics_mb.HasValue ? pics_mb.Value.ToJson() : new List <Index_Pic>().ToJson();
            var response = Util.Normal_Resp_Create(body, EncryptType.PT);

            return(response);
        }