public BackgroundQuery(IRowSourceWrapper rowSource, TaskScheduler backgroundTaskScheduler, IQueryRequest queryRequest) { RowSource = rowSource; BackgroundTaskScheduler = backgroundTaskScheduler; QueryRequest = queryRequest; _rootCancellationToken = QueryRequest.CancellationToken; }
public string ExtractQuery(IQueryRequest request) { var otherDataSets = new List<string>(); var query = SearchDataSet( request.Source , request.ReportPath , request.ReportName , request.DataSetName , ref otherDataSets); if (string.IsNullOrEmpty(query)) { var reference = SearchSharedDataSet( request.Source , request.ReportPath , request.ReportName , request.DataSetName , ref otherDataSets); if (!string.IsNullOrEmpty(reference)) query = ReadQueryFromSharedDataSet(request.Source, reference); } if (!string.IsNullOrEmpty(query)) return query; if (otherDataSets.Count() == 0) throw new ArgumentException(string.Format("No report found on path '{0}' with name '{1}'", request.ReportPath, request.ReportName)); else if (otherDataSets.Count() == 1) throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The dataset for this report is {3}", request.ReportPath, request.ReportName, request.DataSetName, otherDataSets[0])); else throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The datasets for this report are {3}", request.ReportPath, request.ReportName, request.DataSetName, String.Join(", ", otherDataSets.ToArray()))); }
private async Task<SelectedSnapshot> taskLoadAsync(IQueryRequest N1QLQueryRequest) { Task<IQueryResult<SnapshotEntry>> queryTask = _CBBucket.QueryAsync<SnapshotEntry>(N1QLQueryRequest); IQueryResult<SnapshotEntry> result = await queryTask; if (result.Rows.Count == 0) throw new Exception("No Snapshots Found"); return ToSelectedSnapshot(result.Rows[0]); }
private Exception BuildDataSetNotFoundException(IQueryRequest request, XmlDocument docXml, string xpath, XmlNamespaceManager nsmgr) { var nodes = docXml.SelectNodes(xpath, nsmgr); var dataSetFound = new List<String>(); foreach (XmlNode node in nodes) dataSetFound.Add(node.Attributes["Name"].Value); if (dataSetFound.Count() > 1) throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The datasets for this report are {3}", request.ReportPath, request.ReportName, request.DataSetName, String.Join(", ", dataSetFound.ToArray()))); else throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The dataset for this report is named '{3}'", request.ReportPath, request.ReportName, request.DataSetName, dataSetFound[0])); }
public string ExtractQuery(IQueryRequest request) { var fullPath = string.Format("{0}{1}", request.ReportPath, request.ReportName); if (!File.Exists(fullPath)) throw new ArgumentException(string.Format("No report found on path '{0}' with name '{1}'", request.ReportPath, request.ReportName)); var docXml = new XmlDocument(); docXml.Load(fullPath); var xpath = string.Format("//rd:Report/rd:DataSets/rd:DataSet[@Name=\"{0}\"]/rd:Query/rd:CommandText", request.DataSetName); var nsmgr = new XmlNamespaceManager(docXml.NameTable); nsmgr.AddNamespace("rd", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"); var node = docXml.SelectSingleNode(xpath, nsmgr); if (node != null) return node.InnerText; else throw BuildDataSetNotFoundException(request, docXml, "//rd:Report/rd:DataSets/rd:DataSet", nsmgr); }
public QueryTimer(IQueryRequest queryRequest, ITimingStore store, bool enableQueryTiming) { Store = store; if (!store.Enabled || !enableQueryTiming) return; if (queryRequest == null) { throw new ArgumentException(QueryMustBeProvided); } if (string.IsNullOrEmpty(queryRequest.GetOriginalStatement())) { throw new ArgumentException(QueryStatementMustBeProvided); } _statement = queryRequest.GetOriginalStatement(); _enableQueryTiming = enableQueryTiming; ClusterElapsedTime = NotRecorded; _stopwatch = Stopwatch.StartNew(); }
public string ExtractQuery(IQueryRequest request) { using (var conn = new SqlConnection()) { //create connection and define sql query conn.ConnectionString = request.Source; var cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = ReadQueryFromContent(); //create the three parameters for the sql query var paramReportPath = new SqlParameter("ReportPath",System.Data.SqlDbType.NVarChar, 425); paramReportPath.Value=request.ReportPath; cmd.Parameters.Add(paramReportPath); var paramReportName = new SqlParameter("ReportName",System.Data.SqlDbType.NVarChar, 425); paramReportName.Value=request.ReportName; cmd.Parameters.Add(paramReportName); //var paramDataSetName = new SqlParameter("DataSetName", System.Data.SqlDbType.NVarChar, 128); //paramDataSetName.Value = request.DataSetName; //cmd.Parameters.Add(paramDataSetName); //execute the command conn.Open(); var dr = cmd.ExecuteReader(); if (!dr.HasRows) throw new ArgumentException(string.Format("No report found on path '{0}' with name '{1}'", request.ReportPath, request.ReportName)); var dataSetFound = new List<String>(); while (dr.Read()) if (dr.GetString(2) == request.DataSetName) return dr.GetString(5); //CommandText else dataSetFound.Add(dr.GetString(2)); if (dataSetFound.Count()>1) throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The datasets for this report are {3}", request.ReportPath, request.ReportName, request.DataSetName, String.Join(", ", dataSetFound.ToArray()))); else throw new ArgumentException(string.Format("The requested dataset ('{2}') wasn't found for the report on path '{0}' with name '{1}'. The dataset for this report is {3}", request.ReportPath, request.ReportName, request.DataSetName, dataSetFound[0])); } }
public string ExtractQuery(IQueryRequest request) { var fullPath = string.Format("{0}{1}", request.ReportPath, request.ReportName); if (!File.Exists(fullPath)) throw new ArgumentException(string.Format("No report found on path '{0}' with name '{1}'", request.ReportPath, request.ReportName)); //Load the xml var docXml = new XmlDocument(); docXml.Load(fullPath); var root = docXml.FirstChild; if (root.NodeType == XmlNodeType.XmlDeclaration) root = root.NextSibling; //Check that the data set exist var xpath = string.Format("//rd:Report/rd:DataSets/rd:DataSet[@Name=\"{0}\"]", request.DataSetName); //var xpath = "//Report"; var nsmgr = new XmlNamespaceManager(docXml.NameTable); nsmgr.AddNamespace("rd", root.GetNamespaceOfPrefix(string.Empty)); var node = docXml.SelectSingleNode(xpath, nsmgr); if (node == null) throw BuildDataSetNotFoundException(request, docXml, "//rd:Report/rd:DataSets/rd:DataSet", nsmgr); //Search in the xml the DataSet and especially the CommandText within this dataset xpath = string.Format("//rd:Report/rd:DataSets/rd:DataSet[@Name=\"{0}\"]/rd:Query/rd:CommandText", request.DataSetName); node = docXml.SelectSingleNode(xpath, nsmgr); if (node != null) return node.InnerText; // Weve fond the query //If not found then we'll check if it's not a shared dataset xpath = string.Format("//rd:Report/rd:DataSets/rd:DataSet[@Name=\"{0}\"]/rd:SharedDataSet/rd:SharedDataSetReference", request.DataSetName); node = docXml.SelectSingleNode(xpath, nsmgr); if (node == null) throw new ArgumentException(string.Format("The data set named '{0}' has been found but no command text or shared dataset reference has been found", request.DataSetName)); var sharedDataSetName = node.InnerText + ".rsd"; return ExtractQueryFromSharedDataSet(string.Format("{0}{1}", request.ReportPath, sharedDataSetName)); }
public abstract void StartQuery(IQueryRequest queryRequest);
public ForegroundQuery(IRowSourceWrapper rowSource, IQueryRequest queryRequest) { RowSource = rowSource; QueryRequest = queryRequest; }
public string ExecuteQuery(IQueryRequest query, Formatting format) { return JsonConvert.SerializeObject(ExecuteQuery(query), format); }
public IQueryResult<dynamic> ExecuteQuery(IQueryRequest query) { return ClusterHelper .GetBucket(CouchbaseConfigHelper.Instance.Bucket) .Query<dynamic>(query); }
public override void StartQuery(IQueryRequest queryRequest) { new ForegroundQuery(this, queryRequest).Start(); }