/// <summary> /// The search bind data. /// </summary> /// <param name="newSearch"> /// The new search. /// </param> private void SearchBindData(bool newSearch) { #if (!DEBUG) try { #endif if (newSearch && !this.IsValidSearchRequest()) { return; } if (newSearch || this.Get <IYafSession>().SearchData == null) { var sw = (SearchWhatFlags)Enum.Parse(typeof(SearchWhatFlags), this.listSearchWhat.SelectedValue); var sfw = (SearchWhatFlags)Enum.Parse(typeof(SearchWhatFlags), this.listSearchFromWho.SelectedValue); int forumId = int.Parse(this.listForum.SelectedValue); var searchResults = LegacyDb.GetSearchResult( this.SearchWhatCleaned, this.SearchWhoCleaned, sfw, sw, forumId, this.PageContext.PageUserID, this.PageContext.PageBoardID, this.Get <YafBoardSettings>().ReturnSearchMax, this.Get <YafBoardSettings>().UseFullTextSearch, this.Get <YafBoardSettings>().EnableDisplayName); if (newSearch) { // setup highlighting this.SetupHighlightWords(sw); } this.Get <IYafSession>().SearchData = searchResults; this.Pager.CurrentPageIndex = 0; this.Pager.PageSize = int.Parse(this.listResInPage.SelectedValue); this.Pager.Count = searchResults.AsEnumerable().Count(); bool areResults = this.Pager.Count > 0; this.SearchRes.Visible = areResults; this.NoResults.Visible = !areResults; } this.UpdateHistory.AddEntry("{0}|{1}".FormatWith(this.Pager.CurrentPageIndex, this.Pager.PageSize)); var pagedData = this.Get <IYafSession>().SearchData.AsEnumerable().ToList().GetPaged(this.Pager); // only load required messages this.Get <YafDbBroker>().LoadMessageText(pagedData); this.SearchRes.DataSource = pagedData; this.SearchRes.DataBind(); #if (!DEBUG) } catch (Exception x) { this.Logger.Log(this.PageContext.PageUserID, this, x); this.PageContext.AddLoadMessage( this.PageContext.IsAdmin ? "{0}".FormatWith(x) : "An error occurred while searching."); } #endif }