private QueryResults ExecuteWithResults(ParsedQuery query, int siteId, bool textResults) { QueryResults results = null; Site site = GetSite(siteId); ValidateQuery(query, site); results = QueryRunner.GetResults(query, site, CurrentUser); results = TranslateResults(query, textResults, results); return(results); }
private ActionResult GetCsv(string sitename, int revisionId, TargetSites targetSites) { Query query = QueryUtil.GetQueryForRevision(revisionId); if (query == null) { return(PageNotFound()); } var results = QueryRunner.GetResults( new ParsedQuery(query.QueryBody, Request.Params, executionPlan: false, targetSites: targetSites), null, CurrentUser ); return(new CsvResult(results.ResultSets)); }
public ActionResult ShowSingleSiteCsv(string sitename, int revisionId, string slug) { Query query = QueryUtil.GetQueryForRevision(revisionId); if (query == null) { return(PageNotFound()); } Site site; if (!TryGetSite(sitename, out site)) { return(site == null ? (ActionResult)PageNotFound() : RedirectPermanent(string.Format("/{0}/csv/{1}{2}{3}", site.TinyName.ToLower(), revisionId, slug.HasValue() ? "/" + slug : "", Request.Url.Query ))); } var parsedQuery = new ParsedQuery(query.QueryBody, Request.Params); if (!parsedQuery.IsExecutionReady) { return(PageBadRequest()); } CachedResult cachedResults = QueryUtil.GetCachedResults( parsedQuery, Site.Id ); List <ResultSet> resultSets; if (cachedResults != null) { resultSets = JsonConvert.DeserializeObject <List <ResultSet> >(cachedResults.Results, QueryResults.GetSettings()); } else { resultSets = QueryRunner.GetResults( parsedQuery, site, CurrentUser ).ResultSets; } return(new CsvResult(resultSets)); }
public ActionResult ShowSingleSiteCsv(string sitename, int revisionId) { Query query = QueryUtil.GetQueryForRevision(revisionId); if (query == null) { return(PageNotFound()); } var site = GetSite(sitename); if (sitename == null) { return(PageNotFound()); } var parsedQuery = new ParsedQuery(query.QueryBody, Request.Params); if (!parsedQuery.IsExecutionReady) { return(PageBadRequest()); } CachedResult cachedResults = QueryUtil.GetCachedResults( parsedQuery, Site.Id ); List <ResultSet> resultSets; if (cachedResults != null) { resultSets = JsonConvert.DeserializeObject <List <ResultSet> >(cachedResults.Results); } else { resultSets = QueryRunner.GetResults( parsedQuery, site, CurrentUser ).ResultSets; } return(new CsvResult(resultSets)); }
public void TestPostLinkShouldNotCrash() { QueryRunner.GetResults(new ParsedQuery("select top 10 Id as [Post Link] from Posts", null), Current.DB.Sites.First(), new User()); }