public string doQuery(webArgs wargs) { if (wargs.sessId == null || wargs.searchString == null || wargs.searchString == "") return NO_RESULTS; log.Debug("WebBackEnd: Got Search String: " + wargs.searchString); Query query = new Query(); query.AddText (wargs.searchString); if (wargs.searchSource != null && wargs.searchSource != "") { query.AddSource(wargs.searchSource); query.AddDomain(QueryDomain.System); } else query.AddDomain (wargs.globalSearch ? QueryDomain.Global:QueryDomain.System); QueryResult qres = new QueryResult (); //Note: QueryDriver.DoQuery() local invocation is used. //The root tile is used only for adding hits and generating html. BT.SimpleRootTile root = new BT.SimpleRootTile (); root.Query = query; //root.SetSource (searchSource); Do not SetSource on root! ResultPair rp = new ResultPair(root); bufferRenderContext bctx = new bufferRenderContext(rp); Resp resp = new Resp(rp, bctx, wargs.isLocalReq); AttachQueryResult (qres, resp); //Add sessionId-Resp mapping if (sessionResp.Contains(wargs.sessId)) sessionResp[wargs.sessId] = resp; else sessionResp.Add(wargs.sessId, resp); log.Info("WebBackEnd: Starting Query for string \"{0}\"", wargs.searchString); QueryDriver.DoQueryLocal (query, qres); //Wait only till we have enough results to display while ((result.Contains(qres)) && (root.HitCollection.NumResults < 10)) Thread.Sleep(100); if (root.HitCollection.IsEmpty) return NO_RESULTS; lock (root) { root.Render(bctx); return (getResultsLabel(root) + (wargs.isLocalReq ? bctx.buffer:bctx.bufferForExternalQuery)); } }
protected void Search_Click(object o, EventArgs e) { //if (IsPostBack && Session.IsNewSession) if (Session["InitialReqUrl"] == null) { Output.Text = enableSessionMsg; Back.Visible = Forward.Visible = GlobalSearchCheckBox.Visible = false; return; } if (SearchBox.Text.Trim() == "") { Output.Text = HeaderMsg + NO_RESULTS; Back.Visible = Forward.Visible = false; Session["SearchString"] = SearchBox.Text; Session["ResultsOnDisplay"] = Output.Text; Session["GlobalCheckBox"] = GlobalSearchCheckBox.Checked; return; } string searchSrc = sourceList.SelectedItem.Value; if (searchSrc.Equals("Anywhere")) searchSrc = null; remoteChannel.Register(); WebBackEnd remoteObj = (WebBackEnd) Session["RemObj"]; if (remoteObj == null) { remoteObj = new WebBackEnd(); } if ( (remoteObj == null) || !(remoteObj.allowGlobalAccess || isLocalReq())) { Output.Text = localReqOnlyMsg; Back.Visible = Forward.Visible = GlobalSearchCheckBox.Visible = false; sourceList.Enabled = SearchBox.Enabled = Search.Enabled = false; return; } if (!isLocalReq() && (((string)TitleLabel.Text).IndexOf("host") < 0)) TitleLabel.Text += " from host: " + remoteObj.HostName; //Show check-box only if we have one or more NetworkedBeagle nodes configured: bool showGlobalCheckBox = (remoteObj.NetworkBeagleActive) && (searchSrc == null); //Setup arguments for WebBackEnd:doQuery() webArgs wargs = new webArgs(); wargs.sessId = Session.SessionID; wargs.searchString = SearchBox.Text; wargs.searchSource = searchSrc; wargs.isLocalReq = isLocalReq(); wargs.globalSearch = showGlobalCheckBox?GlobalSearchCheckBox.Checked:false; string response = ""; try { response = remoteObj.doQuery(wargs); } catch (Exception ex) { response = "Exception in WebBackEnd:doQuery method\n"; Console.WriteLine("WebFrontEnd: Caught Exception in WebBackEnd:doQuery()\n" + ex.Message); } if (response.StartsWith(NO_RESULTS)) { Output.Text = HeaderMsg + response; Back.Visible = Forward.Visible = false; } else { Output.Text = HeaderMsg + convertUrls(response); Back.Enabled = remoteObj.canBack(Session.SessionID); Forward.Enabled = remoteObj.canForward(Session.SessionID); } GlobalSearchCheckBox.Visible = showGlobalCheckBox; Session["GlobalCheckBox"] = GlobalSearchCheckBox.Checked; Session["RemObj"] = remoteObj; Session["ResultsOnDisplay"] = Output.Text; Session["SearchString"] = SearchBox.Text; Session["Source"] = searchSrc; }
public string doQuery(webArgs wargs) { if (wargs.sessId == null || wargs.searchString == null || wargs.searchString == "") { return(NO_RESULTS); } log.Debug("WebBackEnd: Got Search String: " + wargs.searchString); Query query = new Query(); query.AddText(wargs.searchString); if (wargs.searchSource != null && wargs.searchSource != "") { query.AddSource(wargs.searchSource); query.AddDomain(QueryDomain.System); } else { query.AddDomain(wargs.globalSearch ? QueryDomain.Global:QueryDomain.System); } QueryResult qres = new QueryResult(); //Note: QueryDriver.DoQuery() local invocation is used. //The root tile is used only for adding hits and generating html. BT.SimpleRootTile root = new BT.SimpleRootTile(); root.Query = query; //root.SetSource (searchSource); Do not SetSource on root! ResultPair rp = new ResultPair(root); bufferRenderContext bctx = new bufferRenderContext(rp); Resp resp = new Resp(rp, bctx, wargs.isLocalReq); AttachQueryResult(qres, resp); //Add sessionId-Resp mapping if (sessionResp.Contains(wargs.sessId)) { sessionResp[wargs.sessId] = resp; } else { sessionResp.Add(wargs.sessId, resp); } log.Info("WebBackEnd: Starting Query for string \"{0}\"", wargs.searchString); QueryDriver.DoQueryLocal(query, qres); //Wait only till we have enough results to display while ((result.Contains(qres)) && (root.HitCollection.NumResults < 10)) { Thread.Sleep(100); } if (root.HitCollection.IsEmpty) { return(NO_RESULTS); } lock (root) { root.Render(bctx); return(getResultsLabel(root) + (wargs.isLocalReq ? bctx.buffer:bctx.bufferForExternalQuery)); } }