private static List<ShowtopicPagePostInfo> GetDebatePostList(PostpramsInfo postpramsInfo, out List<ShowtopicPageAttachmentInfo> attachList, bool isModer, int debateOpinion, PostOrderType postOrderType) { List<ShowtopicPagePostInfo> postList = new List<ShowtopicPagePostInfo>(); attachList = new List<ShowtopicPageAttachmentInfo>(); StringBuilder attachmentpidlist = new StringBuilder(); StringBuilder pidList = new StringBuilder(); postList = Data.Debates.GetDebatePostList(postpramsInfo, debateOpinion, postOrderType); //当因冗余字段不准导致未取得分页信息时,修正冗余字段,并取最后一页 if (postList.Count == 0 && postpramsInfo.Pageindex > 1) { int postcount = Data.Debates.GetRealDebatePostCount(postpramsInfo.Tid, debateOpinion); postpramsInfo.Pageindex = postcount % postpramsInfo.Pagesize == 0 ? postcount / postpramsInfo.Pagesize : postcount / postpramsInfo.Pagesize + 1; postList = Data.Debates.GetDebatePostList(postpramsInfo, debateOpinion, postOrderType); } StringBuilder attachPidList = new StringBuilder(); foreach (ShowtopicPagePostInfo post in postList) { pidList.AppendFormat("{0},", post.Pid); if (post.Attachment > 0) attachPidList.AppendFormat("{0},", post.Pid); } attachList = Attachments.GetAttachmentList(postpramsInfo, attachPidList.ToString().TrimEnd(',')); Dictionary<int, int> postdiggs = GetPostDiggs(pidList.ToString().Trim(',')); foreach (ShowtopicPagePostInfo post in postList) { if (postdiggs.ContainsKey(post.Pid)) post.Diggs = postdiggs[post.Pid]; } Posts.ParsePostListExtraInfo(postpramsInfo, attachList, isModer, postList); return postList; }
/// <summary> /// 返回辩论帖子列表 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <param name="debateOpinion">辩论正反观点</param> /// <param name="postOrderType">排序类型</param> /// <returns></returns> public static List <ShowtopicPagePostInfo> GetDebatePostList(PostpramsInfo postpramsInfo, int debateOpinion, PostOrderType postOrderType) { IDataReader reader = DatabaseProvider.GetInstance().GetDebatePostList(postpramsInfo, debateOpinion, postpramsInfo.Pagesize, postpramsInfo.Pageindex, PostTables.GetPostTableId(postpramsInfo.Tid), postOrderType); return(Posts.LoadPostList(postpramsInfo, reader)); }
private static List <ShowtopicPagePostInfo> GetDebatePostList(PostpramsInfo postpramsInfo, out List <ShowtopicPageAttachmentInfo> attachmentlist, bool ismoder, int debateOpinion, PostOrderType postOrderType) { List <ShowtopicPagePostInfo> postcoll = new List <ShowtopicPagePostInfo>(); attachmentlist = new List <ShowtopicPageAttachmentInfo>(); StringBuilder attachmentpidlist = new StringBuilder(); StringBuilder pidlist = new StringBuilder(); IDataReader reader = DatabaseProvider.GetInstance().GetDebatePostList(postpramsInfo.Tid, debateOpinion, postpramsInfo.Pagesize, postpramsInfo.Pageindex, Posts.GetPostTableName(postpramsInfo.Tid), postOrderType); postcoll = Posts.ParsePostList(postpramsInfo, attachmentlist, ismoder, postcoll, reader, attachmentpidlist); //当因冗余字段不准导致未取得分页信息时,修正冗余字段,并取最后一页 if (postcoll.Count == 0 && postpramsInfo.Pageindex > 1) { int postcount = DatabaseProvider.GetInstance().ReviseDebateTopicDiggs(postpramsInfo.Tid, debateOpinion); postpramsInfo.Pageindex = postcount % postpramsInfo.Pagesize == 0 ? postcount / postpramsInfo.Pagesize : postcount / postpramsInfo.Pagesize + 1; reader = DatabaseProvider.GetInstance().GetDebatePostList(postpramsInfo.Tid, debateOpinion, postpramsInfo.Pagesize, postpramsInfo.Pageindex, Posts.GetPostTableName(postpramsInfo.Tid), postOrderType); postcoll = Posts.ParsePostList(postpramsInfo, attachmentlist, ismoder, postcoll, reader, attachmentpidlist); } foreach (ShowtopicPagePostInfo post in postcoll) { pidlist.AppendFormat("{0},", post.Pid); } Dictionary <int, int> postdiggs = GetPostDiggs(pidlist.ToString().Trim(',')); foreach (ShowtopicPagePostInfo post in postcoll) { if (postdiggs.ContainsKey(post.Pid)) { post.Diggs = postdiggs[post.Pid]; } } return(postcoll); }
private static List <Post> GetDebatePostList(PostpramsInfo pi, out List <Attachment> attachList, bool isModer, int debateOpinion, PostOrderType postOrderType) { var sb = new StringBuilder(); //var list = BBX.Data.Debates.GetDebatePostList(pi, debateOpinion, postOrderType); var list = Post.SearchDebate(pi.Tid, debateOpinion, (pi.Pageindex - 1) * pi.Pagesize, pi.Pagesize); if (list.Count == 0 && pi.Pageindex > 1) { //var count = BBX.Data.Debates.GetRealDebatePostCount(pi.Tid, debateOpinion); var count = Post.SearchDebateCount(pi.Tid, debateOpinion); pi.Pageindex = ((count % pi.Pagesize == 0) ? (count / pi.Pagesize) : (count / pi.Pagesize + 1)); //list = BBX.Data.Debates.GetDebatePostList(pi, debateOpinion, postOrderType); list = Post.SearchDebate(pi.Tid, debateOpinion, (pi.Pageindex - 1) * pi.Pagesize, pi.Pagesize); } var list2 = list.ToList(); // 设置楼层 var start = (pi.Pageindex - 1) * pi.Pagesize; var db = Debate.FindByTid(pi.Tid); foreach (var item in list2) { item.Id = ++start; if (db != null) { db.CastTo(item); } } var sb2 = new StringBuilder(); int inPostAdCount = Advertisement.GetInPostAdCount("", pi.Fid); foreach (var item in list2) { Posts.LoadExtraPostInfo(item, inPostAdCount); sb.AppendFormat("{0},", item.ID); if (item.Attachment > 0) { sb2.AppendFormat("{0},", item.ID); } } attachList = Attachments.GetAttachmentList(pi, sb2.ToString().TrimEnd(',')); var postDiggs = Debates.GetPostDiggs(sb.ToString().Trim(',')); foreach (var item in list2) { if (postDiggs.ContainsKey(item.ID)) { item.Diggs = postDiggs[item.ID]; } } Posts.ParsePostListExtraInfo(pi, attachList, isModer, list2); return(list2); }