Beispiel #1
0
        public static List<Post> GetPostList(PostpramsInfo pi, out List<Attachment> attachList, bool isModer)
        {
            //var postList = BBX.Data.Posts.GetPostList(postpramsInfo);
            var uid = 0;
            if (!pi.Condition.IsNullOrWhiteSpace()) uid = pi.Condition.Substring(pi.Condition.IndexOf("=") + 1).ToInt();
            var postList = Post.GetPostList(pi.Tid, uid, pi.Invisible, pi.Pageindex, pi.Pagesize)
                .ToList();
            attachList = new List<Attachment>();
            if (postList.Count == 0) return postList;
            // 设置楼层
            var start = (pi.Pageindex - 1) * pi.Pagesize;
            foreach (var item in postList)
            {
                item.Id = ++start;
            }

            int inPostAdCount = Advertisement.GetInPostAdCount("", pi.Fid);
            //ForumInfo forumInfo = Forums.GetForumInfo(postList[0].Fid);
            var forumInfo = XForum.FindByID(postList[0].Fid);
            foreach (var item in postList)
            {
                item.SmileyOff = !forumInfo.AllowSmilies ? 1 : item.SmileyOff;
                item.BBCodeOff = !forumInfo.AllowBbCode ? 1 : item.BBCodeOff;
                Posts.LoadExtraPostInfo(item, inPostAdCount);
            }
            string pidListWithAttach = Posts.GetPidListWithAttach(postList);
            attachList = Attachments.GetAttachmentList(pi, pidListWithAttach);
            Posts.ParsePostListExtraInfo(pi, attachList, isModer, postList);
            return postList;
        }
Beispiel #2
0
        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);
        }