⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.cs

📁 微软的.NET论坛的源代码(COOL!!!)
💻 CS
字号:
using System;
using AspNetForums.Components;
using System.Web;

namespace AspNetForums {
    /// <summary>
    /// This class contains the method used to perform searches.  The Search Web control uses
    /// this class to perform its searching.
    /// </summary>
    public class Search {

        /// <summary>
        /// This method returns the result of a search.  It returns the exact number of records as determined
        /// by the RecsPerPage input parameter.
        /// </summary>
        /// <param name="ToSearch">Specifies what, specifically, to search.  Users can opt to search
        /// for posts (PostsSearch) or search for post authors (PostsBySearch).</param>
        /// <param name="SearchWhat">Instructs how to interpret the search query.  Values can be: SearchAllWords,
        /// SearchAnyWord, or SearchExactPhrase.</param>
        /// <param name="ForumToSearch">Indicates the ID of the Forum to search.  To search all forums,
        /// specify a value of -1 here.</param>
        /// <param name="SearchTerms">Specifies the user's typed-in search query.</param>
        /// <param name="Page">Indicates what page of the search results to display.</param>
        /// <param name="RecsPerPage">Determines how many records per page to display.</param>
        /// <returns>A PostCollection containing RecsPerPage Posts (perhaps less).</returns>
        /// <remarks>Page is indexed starting at 1.  That is, to get the first page of search results
        /// pass a value of 1 as the Page parameter.</remarks>
        public static PostCollection PerformSearch(ToSearchEnum ToSearch, SearchWhatEnum SearchWhat,
            int ForumToSearch, String SearchTerms, int Page, int RecsPerPage) {
            // Create Instance of the IWebForumsDataProviderBase
            IWebForumsDataProviderBase dp = DataProvider.Instance();

            // ensure that Page > 0 and RecsPerPage > 0
            if (RecsPerPage <= 0) RecsPerPage = 10;
            if (Page <= 0) Page = 1;

            return dp.GetSearchResults(ToSearch, SearchWhat, ForumToSearch, SearchTerms, Page, RecsPerPage, HttpContext.Current.User.Identity.Name);
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -