/// <summary> /// ALL processing happens here, since we are not using ASP.NET controls or events. /// Page_Load will: /// * check the Cache for a catalog to use /// * if not, check the filesystem for a serialized cache /// * and if STILL not, Server.Transfer to the Spider to build a new cache /// * check the QueryString for search arguments (and if so, do a search) /// * otherwise just show the HTML of this page - a blank search form /// </summary> public void Page_Load() { // prevent Searcharoo from indexing itself (ie. it's own results page) if ((Request.UserAgent != null) && (Request.UserAgent.ToLower().IndexOf("searcharoo") > 0)) { Response.Clear(); Response.End(); return; } bool getCatalog = false; try { // see if there is a catalog object in the cache _Catalog = (Catalog)Application["Searcharoo_Catalog"]; // if so, get the _WordCount _WordCount = _Catalog.Length; _Cache = (Searcharoo.Common.Cache)Application["Searcharoo_Cache"]; } catch (Exception ex) { // otherwise, we'll need to build the catalog log.Warn("Catalog object unavailable : building a new one!"); _Catalog = null; // in case _Cache = null; } ucSearchPanelHeader.WordCount = _WordCount; //ucSearchPanelFooter.WordCount = _WordCount; if (_Catalog == null) { getCatalog = true; } else if (_Catalog.Length == 0) { getCatalog = true; } if (getCatalog) { // Create the thread object, passing in the Alpha.Beta method // via a ThreadStart delegate. This does not start the thread. SearchCatalogInit sci = new SearchCatalogInit(); Thread t = new Thread(() => sci.GetCatalog(this)); t.Start(); if ((string)Application["CatalogLoad"] == "") { // Still no Catalog, so we have to start building a new one if (_Catalog == null) { _Catalog = (Catalog)Application["Searcharoo_Catalog"]; _Cache = (Searcharoo.Common.Cache)Application["Searcharoo_Cache"]; } } } if (this.SearchQuery == "") { ucSearchPanelHeader.IsSearchResultsPage = false; } else { //refactored into class - catalog can be build via a console application as well as the SearchSpider.aspx page Searcharoo.Engine.Search se = new Searcharoo.Engine.Search(); SortedList output = this.GetSearchResults(se); // se.GetResults(this.SearchQuery, _Catalog); _NumberOfMatches = output.Count.ToString(); if (output.Count > 0) { _PagedResults.DataSource = output.GetValueList(); _PagedResults.AllowPaging = true; _PagedResults.PageSize = MaxResultsPerPage; //;Preferences.ResultsPerPage; //10; _PagedResults.CurrentPageIndex = Request.QueryString["page"] == null ? 0 : Convert.ToInt32(Request.QueryString["page"]) - 1; _Matches = se.SearchQueryMatchHtml; _DisplayTime = se.DisplayTime; _Geocoded = se.GeocodedMatches; SearchResults.DataSource = _PagedResults; SearchResults.DataBind(); } else { lblNoSearchResults.Visible = true; } // Set the display info in the top & bottom user controls ucSearchPanelHeader.Word = this.SearchQuery; ucSearchPanelHeader.IsSearchResultsPage = true; } }
/// <summary> /// Available to override in the Kml page which filters out non-geocoded results /// </summary> protected virtual SortedList GetSearchResults(Searcharoo.Engine.Search se) { return(se.GetResults(this.SearchQuery, _Catalog)); }
protected void Button1_Click(object sender, EventArgs e) { us = (User)Session["user"]; string lat = (string)Session["lat"]; string lon = (string)Session["long"]; we.Word_search1 = TextBox1.Text; we.latid = lat; we.@long = lon; we.Searcher_id = us.ID; we.date_s = DateTime.Now; data.Word_searches.InsertOnSubmit(we); data.SubmitChanges(); // string ko= Cache.Get("OurSearch.aspx").ToString(); foreach (char ss in TextBox1.Text) { if ((ss >= 0x600 && ss <= 0x6ff) || (ss >= 0x750 && ss <= 0x77f) || (ss >= 0xfb50 && ss <= 0xfc3f) || (ss >= 0xfe70 && ss <= 0xfefc)) { Searcharoo.Engine.Search.flag = 1; break; } else { Searcharoo.Engine.Search.flag = 0; break; } } _Catalog = Catalog.Load(); Searcharoo.Engine.Search se = new Searcharoo.Engine.Search(); SortedList output = se.GetResults(TextBox1.Text, _Catalog); _NumberOfMatches = output.Count.ToString(); _DisplayTime = se.DisplayTime; if (output.Count > 0) { Repeater1.DataSource = null; Repeater1.DataBind(); lblNoSearchResults.Visible = false; _PagedResults.DataSource = output.GetValueList(); _PagedResults.AllowPaging = true; _PagedResults.PageSize = Preferences.ResultsPerPage; //10; _PagedResults.CurrentPageIndex = Request.QueryString["page"] == null ? 0 : Convert.ToInt32(Request.QueryString["page"]) - 1; _Matches = se.SearchQueryMatchHtml; _DisplayTime = se.DisplayTime; string displaydate = datee; Repeater1.DataSource = _PagedResults; Repeater1.DataBind(); Repeater1.Visible = true; } else { Repeater1.DataSource = null; Repeater1.DataBind(); lblNoSearchResults.Visible = true; } //// Set the display info in the top & bottom user controls // ucSearchPanelHeader.Word = ucSearchPanelFooter.Word = this.SearchQuery; // ucSearchPanelFooter.Visible = true; // ucSearchPanelFooter.IsFooter = true; // ucSearchPanelHeader.IsSearchResultsPage = true; Session["lat"] = HiddenField1.Value.ToString(); Session["long"] = HiddenField2.Value.ToString(); Session["user"] = us; }