Beispiel #1
0
        /// <summary>
        /// 根据cat_ctrl,cat_id获得新闻列表
        /// </summary>
        /// <returns></returns>
        public static List <NewsInfo> News_SelectPaged(string cat_ctrl, string cat_id, string page, string pagesize)
        {
            page     = (int.Parse(page) < 1) ? "1" : page;
            pagesize = (int.Parse(pagesize) > 30) ? "30" : pagesize;

            NewsCateInfo   cate     = CacheMarker.GetNewsCatesBycat_id(cat_id);
            NewsSearchInfo search   = new NewsSearchInfo();
            int            rowcount = 0;

            using (var access = new DataAccess_QzNews(Constants.QZNewSite_News_Db_Key))
            {
                search.n_state = 1;

                if (cate != null && cate.cat_inheritAll && !cate.cat_isLast)
                {
                    search.cat_inheritPath = cate.cat_path;
                }
                else
                {
                    search.n_cat_id = cate.cat_id;
                }

                string whereString = search.ToWhereString();

                // 图集
                if ("photo" == cat_ctrl)
                {
                    whereString += " and n_type='images'";
                }

                return(access.News_SelectPaged(GetNewsTable(cate.cat_tableIndex), "*", whereString, search.DefOrder, int.Parse(page), int.Parse(pagesize), out rowcount));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 加载个人评论(个人中心:我的跟帖)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public Stream LoadUserContent(string userId, string page, string pagesize)
        {
            // 得到上下文
            WebOperationContext woc = WebOperationContext.Current;

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

            // 根据条件获得评论
            List <CommentInfo> cmtLst = DataAccess_News.Comments_SelectPaged(userId, page, pagesize);

            // 在评论里加上作者、发表时间、以及文章标题
            List <CommentInfoApp> cmtLst2 = new List <CommentInfoApp>();

            if (cmtLst != null)
            {
                for (int i = 0; i < cmtLst.Count; i++)
                {
                    var item    = cmtLst[i];
                    var infoApp = new CommentInfoApp();
                    infoApp.cmt_content      = item.cmt_content;
                    infoApp.cmt_id           = item.cmt_id;
                    infoApp.cmt_sourceId     = item.cmt_sourceId;
                    infoApp.cmt_sourceType   = item.cmt_sourceType;
                    infoApp.cmt_uid          = item.cmt_uid;
                    infoApp.cmt_sourceCateId = item.cmt_sourceCateId;

                    int catId = 0;
                    if (!int.TryParse(item.cmt_sourceCateId, out catId))
                    {
                        continue;
                    }

                    var cate = CacheMarker.GetNewsCatesBycat_id(catId.ToString());
                    if (cate == null)
                    {
                        continue;
                    }
                    NewsInfo news = CacheMarker.News_Selectbyn_gid(item.cmt_sourceId, "News_" + cate.cat_tableIndex.ToString());
                    if (news != null)
                    {
                        infoApp.n_authors = news.n_authors;
                        infoApp.n_date    = news.n_date;
                        infoApp.n_title   = news.n_title;
                    }

                    cmtLst2.Add(infoApp);
                }
            }
            var jsonSerialiser = new JavaScriptSerializer();

            json = "{\"list\":" + jsonSerialiser.Serialize(cmtLst2) + "}";
            return(new MemoryStream(Encoding.UTF8.GetBytes(json)));
        }
Beispiel #3
0
        /// <summary>
        /// 获得某条新闻的详细内容
        /// </summary>
        /// <param name="rData"></param>
        /// <returns></returns>
        public Stream NewsContent_Selectbync_n_gid(NewsContentInfo_RD rData)
        {
            WebOperationContext context = WebOperationContext.Current;

            context.OutgoingResponse.ContentType = "application/json;charset=utf-8";
            string json = "";
            // 获取某条新闻的详细内容
            List <NewsContentInfo> list = DataAccess_News.GetNewsContent(rData.n_gid);

            if (list.Count == 0)
            {
                json = string.Format("{{\"contents\":{0},\"shareUrl\":\"{1}\",\"imgs\":{2}}}", string.Empty,
                                     string.Empty, string.Empty);
            }
            else
            {
                string       shareUrl = ""; // 分享文章的地址
                NewsCateInfo cateInfo = null;
                string       n_gid    = "";
                // 获取文章分类的相关字段信息,并拼接得到文章分享地址
                if (list != null && list.Count > 0)
                {
                    // 分类ID
                    string cat_id = rData.vl_cateId.ToSafety();
                    // 根据分类ID获取分类信息
                    cateInfo = CacheMarker.GetNewsCatesBycat_id(cat_id);

                    string cat_ctrl = (cateInfo != null) ? cateInfo.cat_ctrl : "";
                    n_gid    = list[0].nc_n_gid;
                    shareUrl = "http://qiye.qianzhan.com/show/detail/" + rData.n_gid + ".html";
                    //ServiceHandler.GetDetailURL(cat_ctrl, cat_id, n_gid, 1, false);
                }

                // 存放图片数据
                List <ImgsInfo> imgs = new List <ImgsInfo>();
                // 自定义文章内容
                list = CustomContent(list, n_gid, "News_" + cateInfo.cat_tableIndex, out imgs, rData.vl_screenSize);

                // 插入浏览记录
                int logIndex = VisitLog_Insert(rData, shareUrl);
                if (logIndex == -1)
                {
                    return(null);
                }

                var jsonSerialiser = new JavaScriptSerializer();
                json = string.Format("{{\"contents\":{0},\"shareUrl\":\"{1}\",\"imgs\":{2}}}", jsonSerialiser.Serialize(list), shareUrl, jsonSerialiser.Serialize(imgs));
            }

            return(new MemoryStream(Encoding.UTF8.GetBytes(json)));
        }