public override void OnPreRender()
        {
            // Determine whether we are in flat view or tree view mode.  This setting is
            // stored in a cookie, but should probably be moved in to the user's profile
            // which is stored in the database.
            if (!_viewDropDownSelected)
                _forumView = ForumUtils.GetForumView(Page);
            ListItem listItem = _viewDropDownList.Items.FindByValue(_forumView.ToString());
            if (listItem != null)
                listItem.Selected = true;

            // _threadID identifies the thread we are currently viewing.  _postID identifies
            // the post within the thread that is currently being shown. (i.e. in tree view,
            // only one post can be viewed at a time).  _threadID can be obtained from the value
            // of _postID.  We will also determine what page we are looking at.
            _threadID = ForumDB.GetThreadFromPost(_postID);
            _threadPage = ForumDB.GetSortOrderFromPost(_postID, _forumView)/ForumUtils.GetPostsPerPage();

            // If looking at the first post in a thread, then increment the thread view count
            if (_threadID == _postID)
                ForumDB.IncrementThreadViews(_threadID);

            // Get page of posts that will be rendered
            _forumPostCollection = ForumDB.GetThread(_threadID, _threadPage, ForumUtils.GetPostsPerPage(), _forumView);

            // Register javascript for dynamically showing threads in tree view
            if (_forumView == ForumUtils.ForumView.TreeViewDynamic)
                RegisterJavascript();
        }
Пример #2
0
        public override void OnPreRender()
        {
            // Determine whether we are in flat view or tree view mode.  This setting is
            // stored in a cookie, but should probably be moved in to the user's profile
            // which is stored in the database.
            if (!_viewDropDownSelected)
            {
                _forumView = ForumUtils.GetForumView(Page);
            }
            ListItem listItem = _viewDropDownList.Items.FindByValue(_forumView.ToString());

            if (listItem != null)
            {
                listItem.Selected = true;
            }

            // _threadID identifies the thread we are currently viewing.  _postID identifies
            // the post within the thread that is currently being shown. (i.e. in tree view,
            // only one post can be viewed at a time).  _threadID can be obtained from the value
            // of _postID.  We will also determine what page we are looking at.
            _threadID   = ForumDB.GetThreadFromPost(_postID);
            _threadPage = ForumDB.GetSortOrderFromPost(_postID, _forumView) / ForumUtils.GetPostsPerPage();

            // If looking at the first post in a thread, then increment the thread view count
            if (_threadID == _postID)
            {
                ForumDB.IncrementThreadViews(_threadID);
            }

            // Get page of posts that will be rendered
            _forumPostCollection = ForumDB.GetThread(_threadID, _threadPage, ForumUtils.GetPostsPerPage(), _forumView);

            // Register javascript for dynamically showing threads in tree view
            if (_forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                RegisterJavascript();
            }
        }
Пример #3
0
        public static ForumPostCollection GetThread(int threadID, int threadPage, int postsPerPage, ForumUtils.ForumView forumView)
        {
            SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["RiversideInternetForumsConnectionString"]);
            SqlCommand    cmd  = new SqlCommand("WS_GetThread", conn);

            bool flatView = (forumView == ForumUtils.ForumView.FlatView);

            // Populate parameters
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ThreadID", SqlDbType.Int, 4);
            cmd.Parameters.Add("@ThreadPage", SqlDbType.Int, 4);
            cmd.Parameters.Add("@PostsPerPage", SqlDbType.Int, 4);
            cmd.Parameters.Add("@FlatView", SqlDbType.Bit, 1);
            cmd.Parameters[0].Value = threadID;
            cmd.Parameters[1].Value = threadPage;
            cmd.Parameters[2].Value = postsPerPage;
            cmd.Parameters[3].Value = flatView;

            conn.Open();

            ForumPostCollection forumPostCollection = new ForumPostCollection();

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                ForumPost forumPost = PopulateForumPost(dr);
                forumPost.PostID = Convert.ToInt32(dr["PostID"]);
                forumPostCollection.Add(forumPost);
            }

            dr.Close();
            conn.Close();

            return(forumPostCollection);
        }
Пример #4
0
        public static ForumPostCollection GetThread(int threadID, int threadPage, int postsPerPage, ForumUtils.ForumView forumView)
        {
            SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["RiversideInternetForumsConnectionString"]);
            SqlCommand cmd = new SqlCommand("WS_GetThread", conn);

            bool flatView = (forumView == ForumUtils.ForumView.FlatView);

            // Populate parameters
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ThreadID", SqlDbType.Int, 4);
            cmd.Parameters.Add("@ThreadPage", SqlDbType.Int, 4);
            cmd.Parameters.Add("@PostsPerPage", SqlDbType.Int, 4);
            cmd.Parameters.Add("@FlatView", SqlDbType.Bit, 1);
            cmd.Parameters[0].Value = threadID;
            cmd.Parameters[1].Value = threadPage;
            cmd.Parameters[2].Value = postsPerPage;
            cmd.Parameters[3].Value = flatView;

            conn.Open();

            ForumPostCollection forumPostCollection = new ForumPostCollection();

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                ForumPost forumPost = PopulateForumPost(dr);
                forumPost.PostID = Convert.ToInt32(dr["PostID"]);
                forumPostCollection.Add(forumPost);
            }

            dr.Close();
            conn.Close();

            return forumPostCollection;
        }