public Resp(ResultPair rp, bufferRenderContext bCtx, bool isLocalReq) { this._rp = rp; this.bufCtx = bCtx; this._localRequest = isLocalReq; this.tileTab = bCtx.table; }
public string doBack(string sessId) { Resp resp = (Resp)sessionResp[sessId]; if (!canBack(sessId) || (resp == null)) { return(NO_RESULTS); } BT.SimpleRootTile root = resp.resultPair.rootTile; if (root != null) { lock (root) { root.HitCollection.PageBack(); bufferRenderContext bctx = resp.bufferContext; bctx.init(); root.Render(bctx); return(getResultsLabel(root) + (resp.isLocalReq ? bctx.buffer:bctx.bufferForExternalQuery)); } } return(NO_RESULTS); }
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)); } }
public void dispatchAction(string sessId, string actionString) { string tile_id = null, action = null; bool actionDone = false; //if (actionString.StartsWith ("dynaction:")) { bufferRenderContext b = ((Resp)sessionResp[sessId]).bufferContext; if (b != null) { actionDone = b.DoAction(actionString); } //} if (actionDone) { return; } if (actionString.StartsWith("action:")) { int pos1 = "action:".Length; int pos2 = actionString.IndexOf("!"); if (pos2 <= 0) { return; } tile_id = actionString.Substring(pos1, pos2 - pos1); action = actionString.Substring(pos2 + 1); log.Debug("WebBackEnd tile_id: {0}, action: {1}", tile_id, action); BT.Tile t = ((Resp)sessionResp[sessId]).GetTile(tile_id); if (t == null) { return; } MethodInfo info = t.GetType().GetMethod(action, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.Any, new Type[] {}, null); if (info == null) { log.Warn("WebBackEnd:dispatchAction couldn't find method called {0}", action); return; } object[] attrs = info.GetCustomAttributes(false); foreach (object attr in attrs) { if (attr is BT.TileActionAttribute) { info.Invoke(t, null); return; } } log.Warn("WebBackEnd:dispatchAction {0} does not have the TileAction attribute", t); } string command = null; string commandArgs = null; if (actionString.StartsWith("http://") || actionString.StartsWith("file://")) { command = "gnome-open"; commandArgs = "'" + actionString + "'"; } else if (actionString.StartsWith("mailto:")) { command = "evolution"; commandArgs = actionString; } if (command != null) { Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = command; if (commandArgs != null) { //if (args != null) p.StartInfo.Arguments = commandArgs; } try { p.Start(); } catch { } } }
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)); } }