コード例 #1
0
 public override void OnPreRender()
 {
     // Get search results that will be rendered and the total number of search results
     _forumSearchInfoCollection = ForumDB.GetForumSearchResults(_searchTerms, ForumID, ForumUtils.GetPostsPerPage(), _searchPage);
     if (_forumSearchInfoCollection.Count > 0)
         _postsCount = ((ForumSearchInfo)_forumSearchInfoCollection[0]).RecordCount;
 }
コード例 #2
0
 public override void OnPreRender()
 {
     // Get search results that will be rendered and the total number of search results
     _forumSearchInfoCollection = ForumDB.GetForumSearchResults(_searchTerms, ForumID, ForumUtils.GetPostsPerPage(), _searchPage);
     if (_forumSearchInfoCollection.Count > 0)
     {
         _postsCount = ((ForumSearchInfo)_forumSearchInfoCollection[0]).RecordCount;
     }
 }
コード例 #3
0
        public static ForumSearchInfoCollection GetForumSearchResults(string searchTerms, int forumID, int pageSize, int pageIndex)
        {
            // Construct WHERE clause for search
            string whereClause = " AND (";

            string[] termsAnd = null;
            termsAnd     = searchTerms.Split(' ');
            whereClause += "Body LIKE '%" + string.Join("%' AND Body LIKE '%", termsAnd) + "%'";
            whereClause += ") ";

            // Limit to just one forum if required
            whereClause += " AND WS_Threads.ForumID = " + forumID.ToString() + " ";

            // Execute stored procedure
            SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["RiversideInternetForumsConnectionString"]);
            SqlCommand    cmd  = new SqlCommand("WS_GetForumSearchResults", conn);

            // Populate parameters
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@WhereClause", SqlDbType.NVarChar, 500);
            cmd.Parameters.Add("@PageSize", SqlDbType.Int, 4);
            cmd.Parameters.Add("@PageIndex", SqlDbType.Int, 4);
            cmd.Parameters[0].Value = whereClause;
            cmd.Parameters[1].Value = pageSize;
            cmd.Parameters[2].Value = pageIndex;

            conn.Open();

            ForumSearchInfoCollection forumSearchInfoCollection = new ForumSearchInfoCollection();

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                ForumSearchInfo forumSearchInfo = PopulateForumSearchInfo(dr);
                forumSearchInfoCollection.Add(forumSearchInfo);
            }

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

            return(forumSearchInfoCollection);
        }
コード例 #4
0
        public static ForumSearchInfoCollection GetForumSearchResults(string searchTerms, int forumID, int pageSize, int pageIndex)
        {
            // Construct WHERE clause for search
            string whereClause = " AND (";
            string[] termsAnd = null;
            termsAnd = searchTerms.Split(' ');
            whereClause += "Body LIKE '%" + string.Join("%' AND Body LIKE '%", termsAnd) + "%'";
            whereClause += ") ";

            // Limit to just one forum if required
            whereClause += " AND WS_Threads.ForumID = " + forumID.ToString() + " ";

            // Execute stored procedure
            SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["RiversideInternetForumsConnectionString"]);
            SqlCommand cmd = new SqlCommand("WS_GetForumSearchResults", conn);

            // Populate parameters
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@WhereClause", SqlDbType.NVarChar, 500);
            cmd.Parameters.Add("@PageSize", SqlDbType.Int, 4);
            cmd.Parameters.Add("@PageIndex", SqlDbType.Int, 4);
            cmd.Parameters[0].Value = whereClause;
            cmd.Parameters[1].Value = pageSize;
            cmd.Parameters[2].Value = pageIndex;

            conn.Open();

            ForumSearchInfoCollection forumSearchInfoCollection = new ForumSearchInfoCollection();

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                ForumSearchInfo forumSearchInfo = PopulateForumSearchInfo(dr);
                forumSearchInfoCollection.Add(forumSearchInfo);
            }

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

            return forumSearchInfoCollection;
        }