Example #1
0
        private void GetData()
        {
            int count;

            m_PostList   = PostBOV5.Instance.GetPosts(My, PostForm, PageNumber, out count);
            m_TotalCount = count;

            PostBOV5.Instance.ProcessKeyword(m_PostList, ProcessKeywordMode.FillOriginalText);

            List <int> threadIDs = new List <int>();

            foreach (PostV5 post in m_PostList)
            {
                if (threadIDs.Contains(post.ThreadID) == false)
                {
                    threadIDs.Add(post.ThreadID);
                }
            }

            m_ThreadList = PostBOV5.Instance.GetThreads(threadIDs);

            PostBOV5.Instance.ProcessKeyword(m_ThreadList, ProcessKeywordMode.FillOriginalText);

            SetPager("list", null, PageNumber, PostForm.PageSize, count);
        }
Example #2
0
        public override DenouncingCollection GetDenouncingWithReply(DenouncingFilter filter, int pageNumber)
        {
            using (SqlSession db = new SqlSession())
            {
                DenouncingCollection denouncings = null;

                using (SqlQuery query = db.CreateQuery())
                {
                    query.Pager.PageNumber  = pageNumber;
                    query.Pager.PageSize    = filter.PageSize;
                    query.Pager.TableName   = "bx_Denouncings";
                    query.Pager.SortField   = "DenouncingID";
                    query.Pager.IsDesc      = filter.IsDesc;
                    query.Pager.SelectCount = true;

                    filter.Type = DenouncingType.Reply;

                    GetSearchDenouncingsCondition(query, filter);

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        denouncings = new DenouncingCollection(reader);

                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                denouncings.TotalRecords = reader.Get <int>(0);
                            }
                        }
                    }
                }

                FillDenouncingContents(denouncings, db);

                if (denouncings.Count > 0)
                {
                    int[] targetIDs = GetTargetIDs(denouncings);

                    PostCollectionV5 posts = PostBOV5.Instance.GetPosts(targetIDs);

                    for (int i = 0; i < denouncings.Count; i++)
                    {
                        for (int j = 0; j < posts.Count; j++)
                        {
                            if (denouncings[i].TargetID == posts[j].ThreadID)
                            {
                                denouncings[i].TargetReply = posts[j];
                                break;
                            }
                        }
                    }
                }
                return(denouncings);
            }
        }
Example #3
0
        public override bool BeforeExecute(int operatorUserID, string param, ref long offset, ref int totalCount, out string title)
        {
            StringList paramData = StringList.Parse(param);

            PostFilter filter = PostFilter.Parse(paramData[0]);

            AuthUser operatorUser = UserBO.Instance.GetAuthUser(operatorUserID);

            int tempTotalCount;
            PostCollectionV5 posts = PostBOV5.Instance.GetPosts(operatorUser, filter, 1, out tempTotalCount);

            if (posts == null || posts.Count == 0)
            {
                title = "没有数据可以审核";
                return(false);
            }

            totalCount = tempTotalCount;

            title = "将审核 " + totalCount + " 个回复";

            return(true);
        }
Example #4
0
        private void SetThreadContent(BasicThread thread, QuestionThread question, PostCollectionV5 posts, bool getBestPost, int pageNumber, bool getExtendedInfo)
        {
            bool removeContent = false;
            bool removeBestPost = false;

            if (thread is QuestionThread)
                question = (QuestionThread)thread;

            foreach (PostV5 post in posts)
            {
                //if (post.PostType == PostType.ThreadContent)
                //    thread.ThreadContent = post;
                //bool isBestPost = false;
                if (question != null)
                {
                    if (question.BestPostID == post.PostID)
                    {
                        question.BestPost = post;
                        //isBestPost = true;
                        removeBestPost = true;
                    }
                }

                if (post.PostID == thread.ContentID)
                {
                    thread.ThreadContent = post;
                    removeContent = true;
                }
            }

            if (getExtendedInfo)
            {
                if (removeBestPost)
                    posts.Remove(question.BestPost);
                if (removeContent && pageNumber > 1)
                    posts.Remove(thread.ThreadContent);
            }

            if (question != null && question.BestPostID != 0 && question.BestPost == null && getBestPost)
            {
                //这种情况 可能发生在  最佳答案被删除的情况下   所以把BestPostID更新为0
                question.BestPostID = 0;
            }
        }
Example #5
0
        public override double GetFinishPercent(Mission mission, int userID, int cycleTimes, DateTime beginDate, StringTable values, out bool isFail)
        {
            isFail = false;

            System.Collections.Generic.List <int> forumIDs = new System.Collections.Generic.List <int>();
            if (!string.IsNullOrEmpty(values[forumIDsName]))
            {
                int[] tempforumIDs = StringUtil.Split <int>(values[forumIDsName]);

                StringBuilder forumNames = new StringBuilder();
                foreach (int forumID in tempforumIDs)
                {
                    Forum forum = ForumBO.Instance.GetForum(forumID);
                    if (forum != null)
                    {
                        forumIDs.Add(forumID);
                    }
                }
            }

            DateTime endDate = DateTime.MaxValue;

            if (false == string.IsNullOrEmpty(values[timeOutName]))
            {
                int hour = int.Parse(values[timeOutName]);
                if (hour > 0)
                {
                    endDate = beginDate.AddHours(hour);
                }
                else if (cycleTimes == 0)
                {
                    beginDate = DateTime.MinValue;
                }
            }
            else if (cycleTimes == 0)
            {
                beginDate = DateTime.MinValue;
            }
            else if (cycleTimes > 0)
            {
                endDate = beginDate.AddSeconds(cycleTimes);
            }

            int postCount = int.Parse(values[topicCountName]);

            if (values[actionName] == "0")//发主题
            {
                int total;

                ThreadCollectionV5 threads = PostBOV5.Instance.GetMyThreads(userID, true, 1, int.MaxValue, out total);

                int finishCount = 0;
                foreach (BasicThread thread in threads)
                {
                    if (thread.ThreadStatus != ThreadStatus.Recycled && thread.ThreadStatus != ThreadStatus.UnApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(thread.ForumID))
                        {
                            if (thread.CreateDate >= beginDate && thread.CreateDate <= endDate)
                            {
                                finishCount++;
                            }
                        }
                    }

                    if (finishCount >= postCount)
                    {
                        return(1);
                    }
                }

                if (endDate <= DateTimeUtil.Now)
                {
                    isFail = true;
                }

                return((double)finishCount / (double)postCount);
            }
            else if (values[actionName] == "1")//发回复
            {
                PostCollectionV5 posts = PostBOV5.Instance.GetUserPosts(userID, beginDate, endDate);

                int targetUserID = 0;
                int.TryParse(values[replyUserName], out targetUserID);

                ThreadCollectionV5 threads = null;

                if (targetUserID > 0)
                {
                    System.Collections.Generic.List <int> threadIDs = new System.Collections.Generic.List <int>();
                    foreach (PostV5 post in posts)
                    {
                        if (post.IsApproved && !threadIDs.Contains(post.ThreadID))
                        {
                            threadIDs.Add(post.ThreadID);
                        }
                    }
                    if (threadIDs.Count > 0)
                    {
                        threads = PostBOV5.Instance.GetThreads(threadIDs);
                    }
                }

                int targetThreadID = 0;
                int.TryParse(values[replyTopicName], out targetThreadID);

                int finishCount = 0;

                foreach (PostV5 post in posts)
                {
                    if (post.IsApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(post.ForumID))
                        {
                            if (targetThreadID == 0 || post.ThreadID == targetThreadID)//回复指定主题
                            {
                                if (targetUserID == 0)
                                {
                                    finishCount++;
                                }
                                else
                                {
                                    foreach (BasicThread thread in threads)
                                    {
                                        if (thread.ThreadID == post.ThreadID && thread.PostUserID == targetUserID)//回复指定用户
                                        {
                                            finishCount++;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (finishCount >= postCount)
                    {
                        return(1);
                    }
                }


                if (endDate <= DateTimeUtil.Now)
                {
                    isFail = true;
                }

                return((double)finishCount / (double)postCount);
            }
            else //发主题或者回复
            {
                int total;

                ThreadCollectionV5 threads = PostBOV5.Instance.GetMyThreads(userID, true, 1, int.MaxValue, out total);

                int finishCount = 0;
                foreach (BasicThread thread in threads)
                {
                    if (thread.ThreadStatus != ThreadStatus.Recycled && thread.ThreadStatus != ThreadStatus.UnApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(thread.ForumID))
                        {
                            if (thread.CreateDate >= beginDate && thread.CreateDate <= endDate)
                            {
                                finishCount++;
                            }
                        }
                    }

                    if (finishCount >= postCount)
                    {
                        return(1);
                    }
                }

                PostCollectionV5 posts = PostBOV5.Instance.GetUserPosts(userID, beginDate, endDate);

                foreach (PostV5 post in posts)
                {
                    if (post.IsApproved)
                    {
                        if (forumIDs.Count == 0 || forumIDs.Contains(post.ForumID))
                        {
                            finishCount++;
                        }
                    }

                    if (finishCount >= postCount)
                    {
                        return(1);
                    }
                }


                if (endDate <= DateTimeUtil.Now)
                {
                    isFail = true;
                }

                return((double)finishCount / (double)postCount);
            }
        }
Example #6
0
        protected bool GetPosts(ThreadType threadType, out int? totalCount, out BasicThread thread, out PostCollectionV5 posts)
        {
            totalCount = null;
            thread = null;
            posts = null;
            ThreadType realThreadType = threadType;
            if (string.Compare(Type, SystemForum.RecycleBin.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                //totalCount = base.TotalPosts;
                return true;
            }
            else if (string.Compare(Type, SystemForum.UnapproveThreads.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                //m_Thread.ThreadContent = m_PostList[0];
                totalCount = posts.TotalRecords;
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                return true;
            }
            else if (string.Compare(Type, MyThreadType.MyUnapprovedThread.ToString(), true) == 0)
            //|| string.Compare(Type, MyThreadType.MyUnapprovedPostThread.ToString(), true) == 0)
            {
                int count;
                PostBOV5.Instance.GetUnapprovedPostThread(ThreadID, MyUserID, PageNumber, PageSize, out thread, out posts, out count);


                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }
                if (posts.Count > 0)
                    thread.ThreadContent = posts[0];
                else
                    ShowError("您要查看的主题不存在或者已被删除");


                totalCount = count;
                return true;
            }
            else if (IsGetPost)
            {
                if (threadType != ThreadType.Normal)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal)), "type=getpost&postid=" + PostID);
                }

                thread = PostBOV5.Instance.GetThread(ThreadID);
                PostV5 post = PostBOV5.Instance.GetPost(PostID, true);
                if (post == null)
                {
                    ShowError("您要查看的帖子不存在或者已被删除");
                }

                posts = new PostCollectionV5();
                posts.Add(post);

                totalCount = 1;

                return true;
            }
            else
                return false;
        }
Example #7
0
        /// <summary>
        /// 返回null时表示不存在 searchID
        /// </summary>
        /// <param name="searchID"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageNumber"></param>
        /// <param name="totalCount"></param>
        /// <param name="keyword"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public override void SearchTopics(Guid searchID, int pageSize, int pageNumber, SearchType searchType, int maxResult, List<int> canVisitForumIDs, List<int> allForumIDs, out int totalCount, out string keyword, out SearchMode mode, out ThreadCollectionV5 threads, out PostCollectionV5 posts)
        {
            threads = null;
            posts = null;
            totalCount = 0;
            keyword = null;
            mode = SearchMode.Subject;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = @"
SELECT * FROM bx_SearchPostResults WITH (NOLOCK) WHERE [ID]=@ID;
UPDATE bx_SearchPostResults SET UpdateDate = GETDATE() WHERE [ID]=@ID; 
";
                query.CommandType = CommandType.Text;
                query.CreateParameter<Guid>("@ID", searchID, SqlDbType.UniqueIdentifier);

                bool isDesc = true;
                List<int> threadIDs = new List<int>();
                List<int> postIDs = new List<int>();

                List<int> forumIDs = new List<int>();
                int targetUserID = 0;
                bool isBefore = false;
                DateTime? PostDate = null;


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        mode = (SearchMode)reader.Get<byte>("SearchMode");
                        keyword = reader.Get<string>("Keyword");
                        threadIDs = StringUtil.Split2<int>(reader.Get<string>("ThreadIDs"));
                        postIDs = StringUtil.Split2<int>(reader.Get<string>("PostIDs"));
                        isDesc = reader.Get<bool>("IsDesc");

                        forumIDs = StringUtil.Split2<int>(reader.Get<string>("ForumIDs"));
                        targetUserID = reader.Get<int>("TargetUserID");
                        isBefore = reader.Get<bool>("IsBefore");
                        PostDate = reader.GetNullable<DateTime>("PostDate");
                    }
                }
                if (keyword == null)
                    return;
                string[] keywords = keyword.Split(' ');

                List<string> resultKeywords = new List<string>();
                foreach (string word in keywords)
                {
                    string tempWord = DaoUtil.GetSafeString(word).Trim();
                    if (tempWord == string.Empty)
                        continue;

                    resultKeywords.Add(tempWord);
                }

                threads = new ThreadCollectionV5();
                posts = new PostCollectionV5();


                if (mode == SearchMode.Subject || mode == SearchMode.UserThread)
                {
                    if (threadIDs.Count == 0)
                    {
                        return;
                    }


                    totalCount = threadIDs.Count;


                    int start = pageSize * (pageNumber - 1);
                    int end = start + pageSize;

                    if (end > totalCount)
                        end = totalCount;

                    if (start >= end)
                        return;

                    threadIDs.Sort();

                    if (isDesc)
                        threadIDs.Reverse();

                    List<int> inThreadIDs = new List<int>();
                    for (int i = start; i < end; i++)
                    {
                        inThreadIDs.Add(threadIDs[i]);
                    }


                    query.CommandText = @"
DECLARE @ThreadIDTable table(ID int identity(1,1), TID int);
DECLARE @Rows int;

INSERT INTO @ThreadIDTable(TID)
    SELECT ThreadID FROM bx_Threads WITH(NOLOCK) WHERE ThreadID IN(@ThreadIDs) AND ThreadStatus<4 ORDER BY ThreadID;

SELECT @Rows = @@RowCount;

IF @Rows = @Count BEGIN --说明上次搜索结果中没有被删除的情况
    SELECT 1;
    SELECT * FROM bx_Threads WITH(NOLOCK) WHERE ThreadStatus<4 AND ThreadID in(@InThreadIDs) ORDER BY ThreadID " + (isDesc ? "DESC" : "ASC") + @";
END 
ELSE BEGIN
    SELECT 0;
    SELECT TID FROM @ThreadIDTable;
END
";
                    query.CreateParameter<int>("@Count", totalCount, SqlDbType.Int);
                    query.CreateInParameter<int>("@InThreadIDs", inThreadIDs);
                    query.CreateInParameter<int>("@ThreadIDs", threadIDs);

                    List<int> resultThreadIDs = new List<int>();
                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        bool isResult = false;
                        while (reader.Read())
                        {
                            isResult = reader.Get<int>(0) == 1;
                        }
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                if (isResult)
                                    threads.Add(new BasicThread(reader));
                                else
                                    resultThreadIDs.Add(reader.GetInt32(0));
                            }
                        }

                        if (isResult)
                            return;
                    }
                    #region
                    if (threadIDs.Count > resultThreadIDs.Count)
                    {
                        int minID, maxID;
                        if (isDesc == false)
                        {
                            minID = threadIDs[0];
                            maxID = threadIDs[threadIDs.Count - 1];
                        }
                        else
                        {
                            maxID = threadIDs[0];
                            minID = threadIDs[threadIDs.Count - 1];
                        }

                        query.CommandType = CommandType.Text;
                        query.Parameters.Clear();


                        string tempKeyword;

                        string sql = GetSearchTopicsSql(query, false, forumIDs, canVisitForumIDs, allForumIDs, resultKeywords, targetUserID, mode, searchType, PostDate, isBefore, isDesc, maxResult - resultThreadIDs.Count, minID, maxID, out tempKeyword);

                        if (sql == null)
                        {
                            threads = new ThreadCollectionV5();
                            posts = new PostCollectionV5();
                            return;
                        }

                        query.CommandText = sql;

                        using (XSqlDataReader reader = query.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (isDesc)
                                    resultThreadIDs.Add(reader.GetInt32(0));
                            }
                        }

                        query.Parameters.Clear();
                        query.CommandText = @"
UPDATE bx_SearchPostResults SET ThreadIDs = @NewThreadIDs WHERE [ID]=@ID;
";
                        query.CommandType = CommandType.Text;

                        query.CreateParameter<string>("@NewThreadIDs", StringUtil.Join(resultThreadIDs), SqlDbType.Text);
                        query.CreateParameter<Guid>("@ID", searchID, SqlDbType.UniqueIdentifier);

                        query.ExecuteNonQuery();
                    }
                    #endregion

                    totalCount = resultThreadIDs.Count;


                    start = pageSize * (pageNumber - 1);
                    end = start + pageSize;

                    if (end > totalCount)
                        end = totalCount;

                    if (start >= end)
                        return;

                    if (isDesc)
                        resultThreadIDs.Reverse();

                    inThreadIDs = new List<int>();
                    for (int i = start; i < end; i++)
                    {
                        inThreadIDs.Add(resultThreadIDs[i]);
                    }

                    query.Parameters.Clear();
                    query.CommandType = CommandType.Text;
                    query.CommandText = @"
SELECT * FROM bx_Threads WITH(NOLOCK) WHERE ThreadStatus<4 AND ThreadID in(@ThreadIDs) ORDER BY ThreadID " + (isDesc ? "DESC" : "ASC") + @";
";
                    query.CreateInParameter<int>("@ThreadIDs", inThreadIDs);
                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            threads.Add(new BasicThread(reader));
                        }
                    }
                }
                else
                {
                    if (postIDs.Count == 0)
                    {
                        return;
                    }

                    totalCount = postIDs.Count;


                    int start = pageSize * (pageNumber - 1);
                    int end = start + pageSize;

                    if (end > totalCount)
                        end = totalCount;

                    if (start >= end)
                        return;

                    postIDs.Sort();

                    if (isDesc)
                        postIDs.Reverse();

                    List<int> inPostIDs = new List<int>();
                    for (int i = start; i < end; i++)
                    {
                        inPostIDs.Add(postIDs[i]);
                    }

                    query.CommandText = @"
DECLARE @PostIDTable table(ID int identity(1,1), TID int);
DECLARE @Rows int;

INSERT INTO @PostIDTable(TID)
    SELECT PostID FROM bx_Posts WITH(NOLOCK) WHERE PostID IN(@PostIDs) AND SortOrder<4000000000000000 ORDER BY PostID;

SELECT @Rows = @@RowCount;

IF @Rows = @Count BEGIN --说明上次搜索结果中没有被删除的情况
    SELECT 1;
    SELECT * FROM bx_Posts WITH(NOLOCK) WHERE SortOrder<4000000000000000 AND PostID in(@InPostIDs) ORDER BY PostID " + (isDesc ? "DESC" : "ASC") + @";
END 
ELSE BEGIN
    SELECT 0;
    SELECT TID FROM @PostIDTable;
END
";
                    query.CreateParameter<int>("@Count", totalCount, SqlDbType.Int);
                    query.CreateInParameter<int>("@InPostIDs", inPostIDs);
                    query.CreateInParameter<int>("@PostIDs", postIDs);

                    List<int> resultPostIDs = new List<int>();
                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        bool isResult = false;

                        while (reader.Read())
                        {
                            isResult = reader.Get<int>(0) == 1;
                        }
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                if (isResult)
                                    posts.Add(new PostV5(reader));
                                else
                                    resultPostIDs.Add(reader.GetInt32(0));
                            }
                        }

                        if (isResult)
                            return;
                    }

                    if (postIDs.Count > resultPostIDs.Count)
                    {
                        int minID, maxID;
                        if (isDesc == false)
                        {
                            minID = postIDs[0];
                            maxID = postIDs[postIDs.Count - 1];
                        }
                        else
                        {
                            maxID = postIDs[0];
                            minID = postIDs[postIDs.Count - 1];
                        }

                        query.CommandType = CommandType.Text;
                        query.Parameters.Clear();

                        string tempKeyword;
                        string sql = GetSearchTopicsSql(query, false, forumIDs, canVisitForumIDs, allForumIDs, resultKeywords, targetUserID, mode, searchType, PostDate, isBefore, isDesc, maxResult - resultPostIDs.Count, minID, maxID, out tempKeyword);
                        if (sql == null)
                        {
                            threads = new ThreadCollectionV5();
                            posts = new PostCollectionV5();
                            return;
                        }

                        query.CommandText = sql;

                        using (XSqlDataReader reader = query.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (isDesc)
                                    resultPostIDs.Add(reader.GetInt32(0));
                            }
                        }

                        query.Parameters.Clear();
                        query.CommandText = @"
UPDATE bx_SearchPostResults SET PostIDs = @NewPostIDs WHERE [ID]=@ID;
";
                        query.CommandType = CommandType.Text;

                        query.CreateParameter<string>("@NewPostIDs", StringUtil.Join(resultPostIDs), SqlDbType.Text);
                        query.CreateParameter<Guid>("@ID", searchID, SqlDbType.UniqueIdentifier);

                        query.ExecuteNonQuery();
                    }

                    totalCount = resultPostIDs.Count;


                    start = pageSize * (pageNumber - 1);
                    end = start + pageSize;

                    if (end > totalCount)
                        end = totalCount;

                    if (start >= end)
                        return;

                    if (isDesc)
                        resultPostIDs.Reverse();

                    inPostIDs = new List<int>();
                    for (int i = start; i < end; i++)
                    {
                        inPostIDs.Add(resultPostIDs[i]);
                    }

                    query.Parameters.Clear();
                    query.CommandType = CommandType.Text;
                    query.CommandText = @"
SELECT * FROM bx_Posts WITH(NOLOCK) WHERE SortOrder<4000000000000000 AND PostID in(@PostIDs) ORDER BY PostID " + (isDesc ? "DESC" : "ASC") + @";
";
                    query.CreateInParameter<int>("@PostIDs", inPostIDs);

                    using (XSqlDataReader reader = query.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            posts.Add(new PostV5(reader));
                        }
                    }
                }
            }
        }
Example #8
0
        private PostCollectionV5 GetPosts(XSqlDataReader reader, bool isFirstRead)
        {
            PostCollectionV5 posts = new PostCollectionV5();

            List<int> replyIDs = new List<int>();

            if (isFirstRead)
            {
                while (reader.Read())
                {
                    PostV5 post = new PostV5(reader);
                    post.Attachments = new AttachmentCollection();
                    post.PostMarks = new PostMarkCollection();
                    posts.Add(post);
                    replyIDs.Add(post.PostID);
                }
            }
            else
            {
                if (reader.NextResult())
                {
                    while (reader.Read())
                    {
                        PostV5 post = new PostV5(reader);
                        post.Attachments = new AttachmentCollection();
                        post.PostMarks = new PostMarkCollection();
                        posts.Add(post);
                        replyIDs.Add(post.PostID);
                    }
                }
            }
            //读取下一个结果集
            if (reader.NextResult())
            {
                while (reader.Read()) //附件列表
                {
                    Attachment attachment = new Attachment(reader);
                    int replyIndex = replyIDs.IndexOf(attachment.PostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].Attachments.Add(attachment);
                    }
                }
            }
            //历史附件
            if (reader.NextResult())
            {
                while (reader.Read()) //附件列表
                {
                    Attachment attachment = new Attachment(reader);
                    attachment.AttachType = AttachType.History;
                    int hpostID = reader.Get<int>("HPostID");
                    int replyIndex = replyIDs.IndexOf(hpostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].Attachments.Add(attachment);
                    }
                }
            }
            if (reader.NextResult())//评分列表
            {
                while (reader.Read())
                {
                    PostMark postMark = new PostMark(reader);
                    int replyIndex = replyIDs.IndexOf(postMark.PostID);
                    if (replyIndex != -1)
                    {
                        posts[replyIndex].PostMarks.Add(postMark);
                    }
                }
            }
            if (reader.NextResult())
            {
                string s = null;
                while (reader.Read())
                {
                    s = reader.Get<string>(0);
                }

#if !Publish
                if (reader.SqlQuery.TempInfo != null)
                    reader.SqlQuery.TempInfo += "-----" + s;
                else
                    reader.SqlQuery.TempInfo = s;
#endif
            }

            return posts;
        }
Example #9
0
 public abstract void SearchTopics(Guid searchID, int pageSize, int pageNumber, SearchType searchType, int maxResult, List <int> canVisitForumIDs, List <int> allForumIDs, out int totalCount, out string keyword, out SearchMode mode, out ThreadCollectionV5 threads, out PostCollectionV5 posts);
Example #10
0
 public abstract bool GetThread(int threadID, bool normalOnly, int totalCount, bool getThread, bool getReplies, int postUserID, int pageIndex, int pageSize, out BasicThread thread, out PostCollectionV5 replies, out int repliesCountForUser);
Example #11
0
 public abstract void GetThreadWithReplies(int threadID, int totalCount, bool getThread, int pageNumber, int pageSize, out BasicThread thread, out PostCollectionV5 replies);
Example #12
0
 public abstract void GetPosts(int threadID, int totalReplies, int getOldCount, int getNewCount, ref BasicThread thread, out PostV5 threadContent, out PostCollectionV5 topPosts);
Example #13
0
 public abstract void GetUserPosts(int threadID, int userID, int pageNumber, int pageSize, bool getExtendedInfo, bool getThread, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType, out int totalCount);
Example #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="threadID"></param>
 /// <param name="pageNumber"></param>
 /// <param name="pageSize"></param>
 /// <param name="totalCount">回复总数 加 主题内容</param>
 /// <param name="getExtendedInfo"></param>
 /// <returns></returns>
 public abstract void GetPosts(int threadID, bool onlyNormal, int pageNumber, int pageSize, int?totalCount, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType);
Example #15
0
        public override void GetUserPosts(int threadID, int userID, int pageNumber, int pageSize, bool getExtendedInfo, bool getThread, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType, out int totalCount)
        {
            totalCount = 0;
            posts = new PostCollectionV5();
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetThreadUserPosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadType", (int)threadType, SqlDbType.TinyInt);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);

                SetTopMarkCountParam(query);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    bool isFirstRead = true;
                    if (checkThreadType)
                    {
                        isFirstRead = false;
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    if (getThread)
                    {
                        if (isFirstRead)
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader,null);
                            }
                        }
                        else
                        {
                            if (reader.NextResult())
                            {
                                while (reader.Read())
                                {
                                    thread = GetThread(reader,null);
                                }
                            }
                        }

                        isFirstRead = false;
                    }

                    if (isFirstRead)
                    {
                        while (reader.Read())
                            totalCount = reader.Get<int>(0);
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                                totalCount = reader.Get<int>(0);
                        }
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        /*
        #region 存储过程 bx_GetCachedPosts
        [StoredProcedure(Name = "bx_GetCachedPosts", Script = @"
CREATE PROCEDURE {name}
     @ThreadID            int
    ,@GetOldCount         int
    ,@GetNewCount         int 
    ,@TotalCount          int
    ,@BestPostID          int
    ,@TopMarkCount        int    
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE @SQLString nvarchar(4000),@SQLString2 nvarchar(4000);
	SET @SQLString='';
    SET @SQLString2 = '';

    DECLARE @Condition nvarchar(4000);
    SET @Condition = '[ThreadID]=' + CAST(@ThreadID as varchar(16))+' AND [SortOrder]<4000000000000000 ';

    IF @BestPostID <> 0 BEGIN
        SET @TotalCount = @TotalCount - 1;
        SET @Condition = '[PostID]<>' + CAST(@BestPostID as varchar(16)) + ' AND ' + @Condition;
    END 

    DECLARE @ExcuteSqlString2 char(1);
    IF @GetOldCount + @GetNewCount >= @TotalCount BEGIN
        SET @SQLString = 'SELECT TOP '+ CAST((@GetOldCount + @GetNewCount) as varchar(16)) +' " + PostColumns + @" FROM [bx_Posts] WITH(NOLOCK) WHERE ' + @Condition + ' ORDER BY PostID DESC ';
        SET @SQLString2 = @SQLString;
        SET @ExcuteSqlString2 = '0';
    END
    ELSE BEGIN
        SET @ExcuteSqlString2 = '1';
        SET @SQLString = '
                            SELECT * FROM 
                            (SELECT TOP '+ CAST(@GetOldCount as varchar(16)) +' " + PostColumns + @" FROM [bx_Posts] WITH(NOLOCK) WHERE ' + @Condition + ' ORDER BY PostID ASC) AS T1
                         ';

        SET @SQLString2 = '
                            SELECT * FROM 
                            (SELECT TOP '+ CAST(@GetNewCount as varchar(16)) +' " + PostColumns + @" FROM [bx_Posts] WITH(NOLOCK) WHERE ' + @Condition + ' ORDER BY PostID DESC) AS T2
                          ';
    END
        
        DECLARE @PostFieldsString nvarchar(4000);
        " + PostFields2 + @"
     
END
"
            )]
        #endregion

        */
        public override void GetPosts(int threadID, int totalReplies, int getOldCount, int getNewCount, ref BasicThread thread, out PostV5 threadContent, out PostCollectionV5 topPosts)
        {
            threadContent = null;
            topPosts = null;

            using (SqlQuery query = new SqlQuery())
            {
                int bestPostID = 0;
                if (SetBestPost(query, thread))
                {
                    QuestionThread question = (QuestionThread)thread;
                    bestPostID = question.BestPostID;
                }

                query.CommandText = "bx_GetCachedPosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<int>("@TotalCount", totalReplies + 1, SqlDbType.Int);//要获取主题内容  所以回复总数加1
                query.CreateParameter<int>("@GetOldCount", getOldCount + 1, SqlDbType.Int);//要获取主题内容  所以加1
                query.CreateParameter<int>("@GetNewCount", getNewCount, SqlDbType.Int);

                SetTopMarkCountParam(query);
                query.CreateParameter<int>("@BestPostID", bestPostID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    topPosts = GetPosts(reader, true);
                    if (topPosts.Count > 0)
                    {
                        threadContent = topPosts[0];
                        topPosts.RemoveAt(0);
                    }
                }
            }
        }
Example #17
0
 public abstract void GetPolemizeWithReplies(int threadID, PostType?postType, int pageNumber, int pageSize, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType, out int totalCount);
Example #18
0
        public override void GetThreadWithReplies(int threadID, int totalCount, bool getThread, int pageNumber, int pageSize, out BasicThread thread, out PostCollectionV5 replies)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.IsDesc = true;
                query.Pager.ResultFields = "*";
                query.Pager.SortField = "[SortOrder]";
                query.Pager.PrimaryKey = "[PostID]";
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = pageSize;
                query.Pager.TotalRecords = totalCount;
                query.Pager.SelectCount = true;
                query.Pager.TableName = "[bx_Posts]";

                query.Pager.Condition = " ThreadID=@ThreadID AND [ThreadStatus]<4 ";

                if (getThread)
                {
                    query.Pager.AfterExecute = string.Concat(@"
SELECT ", ThreadFields, @"
          FROM [bx_Threads] WITH (NOLOCK)
         WHERE [ThreadID] = @ThreadID AND [ThreadStatus]<4;
");
                }

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);

                thread = null;
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    replies = new PostCollectionV5(reader);
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            thread = new BasicThread(reader);
                        }
                    }
                }
            }
        }
Example #19
0
 public abstract void GetUnapprovedPostThread(int threadID, int?userID, int pageNumber, int pageSize, out BasicThread thread, out PostCollectionV5 posts, out int totalCount);
Example #20
0
 public override bool GetThread(int threadID, bool normalOnly, int totalCount, bool getThread, bool getReplies, int postUserID, int pageIndex, int pageSize, out BasicThread thread, out PostCollectionV5 replies, out int repliesCountForUser)
 {
     throw new NotImplementedException();
 }
Example #21
0
        public override PostCollectionV5 GetPosts(int pageNumber, PostFilter filter, Guid[] excludeRoleIDs, ref int totalCount)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.IsDesc = filter.IsDesc;

                query.Pager.SortField = "PostID";

                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.TotalRecords = totalCount;
                query.Pager.SelectCount = true;
                query.Pager.TableName = "[bx_Posts]";

                query.Pager.Condition = BuilderSearchPostCondition(filter, excludeRoleIDs, query, false);

                PostCollectionV5 posts;
                using (XSqlDataReader reader = query.ExecuteReader())
                {

                    posts = new PostCollectionV5(reader);

                    if (reader.NextResult())
                    {
                        if (reader.Read())
                            totalCount = reader.Get<int>(0);
                    }
                    return posts;
                }
            }
        }
Example #22
0
        protected bool GetPosts(ThreadType threadType, out int?totalCount, out BasicThread thread, out PostCollectionV5 posts)
        {
            totalCount = null;
            thread     = null;
            posts      = null;
            ThreadType realThreadType = threadType;

            if (string.Compare(Type, SystemForum.RecycleBin.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                //totalCount = base.TotalPosts;
                return(true);
            }
            else if (string.Compare(Type, SystemForum.UnapproveThreads.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                //m_Thread.ThreadContent = m_PostList[0];
                totalCount = posts.TotalRecords;
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                return(true);
            }
            else if (string.Compare(Type, MyThreadType.MyUnapprovedThread.ToString(), true) == 0)
            //|| string.Compare(Type, MyThreadType.MyUnapprovedPostThread.ToString(), true) == 0)
            {
                int count;
                PostBOV5.Instance.GetUnapprovedPostThread(ThreadID, MyUserID, PageNumber, PageSize, out thread, out posts, out count);


                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }
                if (posts.Count > 0)
                {
                    thread.ThreadContent = posts[0];
                }
                else
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }


                totalCount = count;
                return(true);
            }
            else if (IsGetPost)
            {
                if (threadType != ThreadType.Normal)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal)), "type=getpost&postid=" + PostID);
                }

                thread = PostBOV5.Instance.GetThread(ThreadID);
                PostV5 post = PostBOV5.Instance.GetPost(PostID, true);
                if (post == null)
                {
                    ShowError("您要查看的帖子不存在或者已被删除");
                }

                posts = new PostCollectionV5();
                posts.Add(post);

                totalCount = 1;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #23
0
        public override void GetUnapprovedPostThread(int threadID, int? userID, int pageNumber, int pageSize, out BasicThread thread, out PostCollectionV5 posts, out int totalCount)
        {
            totalCount = 0;
            thread = null;

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_GetUnapprovedPostThread";
                query.CommandType = CommandType.StoredProcedure;
                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<int?>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                SetTopMarkCountParam(query);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        thread = GetThread(reader, null);
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }
                    }

                    posts = GetPosts(reader, false);
                }
            }
        }
Example #24
0
        protected override void GetThread()
        {
            if (IsOnlyLookOneUser)
            {
                Response.Redirect(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, 1, LookUserID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal), ForumListPage));
            }


            if (IsUnapprovePosts)
            {
                BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal)), "type=" + Type);
            }

            if (string.IsNullOrEmpty(Type))
            {
                ThreadType realThreadType;

                PostBOV5.Instance.GetQuestionWithReplies(ThreadID, PageNumber, PageSize, true, UpdateView, out m_QuestionThread, out m_PostList, out realThreadType);

                //如果不是 问题帖 则跳到相应的页面
                if (realThreadType != ThreadType.Question)
                {
                    Response.Redirect(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)));
                }
            }
            else
            {
                BasicThread thread;
                GetPosts(ThreadType.Question, out m_TotalPosts, out thread, out m_PostList);

                m_QuestionThread = (QuestionThread)thread;

            }

            PostCollectionV5 tempPosts;
            if (m_QuestionThread!=null && m_QuestionThread.BestPost != null)
            {
                tempPosts = new PostCollectionV5(m_PostList);
                tempPosts.Add(m_QuestionThread.BestPost);
            }
            else
                tempPosts = m_PostList;

            PostBOV5.Instance.ProcessKeyword(tempPosts, ProcessKeywordMode.TryUpdateKeyword);

            //if (_Request.IsSpider == false)
            //{
                //List<int> userIDs = new List<int>();
                //foreach (PostV5 post in tempPosts)
                //{
                //    userIDs.Add(post.UserID);
                //}
                //UserBO.Instance.GetUsers(userIDs, GetUserOption.WithAll);
            UserBO.Instance.GetUsers(tempPosts.GetUserIds(), GetUserOption.WithAll);
            //}
        }
Example #25
0
        public override void GetPolemizeWithReplies(int threadID, PostType? postType, int pageNumber, int pageSize, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType, out int totalCount)
        {
            totalCount = 0;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetPolemizeWithReplies";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                SetTopMarkCountParam(query);

                int? postTypeValue = null;
                if (postType != null)
                    postTypeValue = (int)postType.Value;

                query.CreateParameter<int?>("@PostType", postTypeValue, SqlDbType.TinyInt);

                if (thread != null && postType == null)
                    totalCount = thread.TotalReplies + 1;

                query.CreateParameter<int?>("@TotalCount", totalCount, SqlDbType.Int);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);

                if (thread != null && thread.ThreadContent != null)
                    getThreadContent = false;

                query.CreateParameter<bool>("@GetThreadContent", getThreadContent, SqlDbType.Bit);
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    if (checkThreadType)
                    {
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    bool hasReadThreadContent = false;

                    #region Read hasReadThreadContent value
                    if (checkThreadType == false)
                    {
                        while (reader.Read())
                        {
                            hasReadThreadContent = reader.Get<int>(0) == 1;
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                hasReadThreadContent = reader.Get<int>(0) == 1;
                            }
                        }
                    }
                    #endregion

                    PostCollectionV5 tempPosts = new PostCollectionV5();

                    #region 读取 主题内容 设置tempPosts
                    if (hasReadThreadContent)
                    {
                        if (getExtendedInfo)
                        {
                            tempPosts = GetPosts(reader, false);
                        }
                        else
                        {
                            if (reader.NextResult())
                            {
                                tempPosts = new PostCollectionV5(reader);
                            }
                        }
                    }
                    #endregion

                    if (getThread)
                    {
                        #region Read thread
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader, null);
                            }
                        }
                        #endregion
                    }

                    if (thread != null && tempPosts.Count > 0)
                    {
                        thread.ThreadContent = tempPosts[0];
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }
                }
            }
        }
Example #26
0
        public override void GetPosts(int threadID, bool onlyNormal, int pageNumber, int pageSize, int? totalCount, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetPagePosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                query.CreateParameter<int?>("@TotalCount", totalCount, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadType", (int)threadType, SqlDbType.TinyInt);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);
                query.CreateParameter<bool>("@OnlyNormal", onlyNormal, SqlDbType.Bit);

                SetTopMarkCountParam(query);


                if (getThreadContent)
                {
                    if (thread != null && thread.ThreadContent != null)// && thread is BasicThread)
                    {
                        getThreadContent = false;
                    }
                }

                bool getBestPost = false;

                QuestionThread question = null;
                if (getThreadContent)
                {
                    if (thread != null && thread is QuestionThread)
                    {
                        question = (QuestionThread)thread;
                        getBestPost = question.BestPost == null;
                    }
                    else if (thread == null && getThread)
                    {
                        getBestPost = true;
                    }
                }

                if (pageNumber == 1)
                    getThreadContent = false;

                query.CreateParameter<bool>("@GetBestPost", getBestPost, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThreadContent", getThreadContent, SqlDbType.Bit);


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    if (checkThreadType)
                    {
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    bool hasReadThreadContentOrBestPost = false;

                    #region Read hasReadThreadContentOrBestPost value
                    if (checkThreadType == false)
                    {
                        while (reader.Read())
                        {
                            hasReadThreadContentOrBestPost = reader.Get<int>(0) == 1;
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                hasReadThreadContentOrBestPost = reader.Get<int>(0) == 1;
                            }
                        }
                    }
                    #endregion

                    PostCollectionV5 tempPosts = new PostCollectionV5();

                    #region 读取 主题内容 最佳答案 设置tempPosts  仅当 getExtendedInfo = false 时有
                    if (hasReadThreadContentOrBestPost)
                    {
                        //if (getExtendedInfo)
                        //{
                        //    tempPosts = GetPosts(reader, false);
                        //}
                        //else
                        //{
                            if (reader.NextResult())
                            {
                                tempPosts = new PostCollectionV5(reader);
                            }

                            if (reader.NextResult())
                            {
                                if (reader.Read())
                                {
                                    int id = reader.Get<int>("PostID");
                                    if (id != 0)
                                    {
                                        PostV5 post = new PostV5(reader);
                                        tempPosts.Add(post);
                                    }
                                }
                            }
                        //}
                    }
                    #endregion

                    if (getThread)
                    {
                        #region Read thread
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader,null);
                            }
                        }
                        #endregion
                    }

                    int total = 0;
                    if (onlyNormal == false)
                    {
                        if (reader.NextResult() && reader.Read())
                        {
                            total = reader.Get<int>(0);
                        }
                    }

                    if (thread != null && tempPosts.Count > 0)
                    {
                        SetThreadContent(thread, question, tempPosts, getBestPost, pageNumber, false);
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);

                        if (thread != null && (getBestPost || getThreadContent))
                        {
                            SetThreadContent(thread, question, posts, getBestPost, pageNumber, true);
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }

                    if (reader.NextResult())
                    {
                        string s = null;
                        while (reader.Read())
                        {
                            s = reader.Get<string>(0);
                        }

#if !Publish
                        if (reader.SqlQuery.TempInfo != null)
                            reader.SqlQuery.TempInfo += "-----" + s;
                        else
                            reader.SqlQuery.TempInfo = s;
#endif
                    }

                    if (pageNumber == 1 && thread != null && posts.Count > 0)
                        thread.ThreadContent = posts[0];
                        

                    posts.TotalRecords = total;
                }
            }
        }
        private void GetData()
        {
            int count;
            m_PostList = PostBOV5.Instance.GetPosts(My, PostForm, PageNumber, out count);
            m_TotalCount = count;

            PostBOV5.Instance.ProcessKeyword(m_PostList, ProcessKeywordMode.FillOriginalText);

            List<int> threadIDs = new List<int>();
            foreach (PostV5 post in m_PostList)
            {
                if (threadIDs.Contains(post.ThreadID) == false)
                    threadIDs.Add(post.ThreadID);
            }

            m_ThreadList = PostBOV5.Instance.GetThreads(threadIDs);

            PostBOV5.Instance.ProcessKeyword(m_ThreadList, ProcessKeywordMode.FillOriginalText);

            SetPager("list", null, PageNumber, PostForm.PageSize, count);
        }