コード例 #1
0
        private List<NewsModel> GetSearchResult(out int MatchCount, out int PageCount)
        {
            SearchInfo InputInfo = new SearchInfo()
            {
                ConfigElement = Config.Searches["news"],
                PageIndex = PageIndex,
                PageSize = PageSize,
                QueryString = SearchWord
            };

            Searcher s = new NewsSearcher(InputInfo);
            List<ISearchEntity> RawResult = s.GetSearchResult(out MatchCount);

            //在这里排序

            List<NewsModel> SearchResult = new List<NewsModel>();
            int PageLowerBound = (InputInfo.PageIndex - 1) * PageSize;
            int PageUpperBound = PageLowerBound + PageSize;
            PageCount = (int)(MatchCount / PageSize) + 1;

            for (int i = 0; i < RawResult.Count; i++)
            {
                if (i > PageLowerBound && i <= PageUpperBound)
                {
                    SearchResult.Add((NewsModel)RawResult[i]);
                }
            }

            return SearchResult;
        }
コード例 #2
0
        private List<ProductModel> GetSearchResult(out int MatchCount, out int PageCount)
        {
            SearchInfo InputInfo = new SearchInfo()
            {
                ConfigElement = Config.Searches["product"],
                PageIndex = PageIndex,
                PageSize = PageSize,
                QueryString = SearchWord,
                Category = SearchCategory,
                sortType = GetSortType()
            };

            Searcher s = new ProductSearcher(InputInfo);
            List<ISearchEntity> RawResult = s.GetSearchResult(out MatchCount);

            Logger.Info(String.Format("{0}\t{1}\t{2}\t{3}\t{4}", SearchWord, SearchCategory, SortValue, PageIndex, MatchCount));

            //在这里排序
            if (IsOrderDesc()) RawResult.Reverse();

            List<ProductModel> SearchResult = new List<ProductModel>();
            int PageLowerBound = (InputInfo.PageIndex - 1) * PageSize;
            int PageUpperBound = PageLowerBound + PageSize;
            PageCount = (int)(MatchCount / PageSize) + 1;

            for (int i = 0; i < RawResult.Count; i++)
            {
                if (i >= PageLowerBound && i <= PageUpperBound)
                {
                    SearchResult.Add((ProductModel)RawResult[i]);
                }
            }

            return SearchResult;
        }