예제 #1
0
파일: Posts.cs 프로젝트: xiongeee/BBX
        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;
        }
예제 #2
0
파일: Debates.cs 프로젝트: xiongeee/BBX
        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);
        }
예제 #3
0
파일: Posts.cs 프로젝트: xiongeee/BBX
        public static EntityList<Post> GetPagedLastPost(PostpramsInfo ppi)
        {
            var list = Post.GetPagedLastPost(ppi);
            var random = new Random((int)DateTime.Now.Ticks);
            int inPostAdCount = Advertisement.GetInPostAdCount("", ppi.Fid);
            foreach (var pi in list)
            {
                ppi.Smileyoff = pi.SmileyOff;
                ppi.BBCode = pi.BBCodeOff < 1;
                ppi.Parseurloff = pi.ParseUrlOff;
                ppi.Allowhtml = pi.HtmlOn;
                ppi.Pid = pi.ID;

                var msg = pi.Message;
                ppi.Sdetail = msg;
                if (ppi.Price > 0 && pi.Layer == 0)
                {
                    var ue = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
                    msg = string.Format("<div class=\"paystyle\">此帖为交易帖,要付 {0} <span class=\"bold\">{1}</span>{2} 才可查看</div>", ue.Name, ppi.Price, ue.Unit);
                }
                else
                {
                    if (!ppi.Ubbmode)
                        msg = UBB.UBBToHTML(ppi);
                    else
                        msg = Utils.HtmlEncode(msg);
                }
                pi.Adindex = random.Next(0, inPostAdCount);
                if (ppi.Jammer == 1) msg = ForumUtils.AddJammer(msg);
                pi.Html = msg;

                if (!pi["showemail"].ToBoolean())
                {
                    pi["email"] = "";
                }
            }
            return list;
        }