/// <summary>
        /// Query the store using a SPARQL query
        /// </summary>
        /// <param name="storeName">Store to query</param>
        /// <param name="queryExpression">SPARQL query string</param>
        /// <param name="ifNotModifiedSince">OPTIONAL: If the store has not been modified since the time specified by this parameter,
        /// the query is not executed and a <see cref="BrightstarStoreNotModifiedException"/> is raised instead.</param>
        /// <param name="resultsFormat">OPTIONAL: The format to use for the SPARQL results. Defaults to <see cref="SparqlResultsFormat.Xml"/>.</param>
        /// <returns>A stream containing SPARQL query results in the requested format</returns>
        public Stream ExecuteQuery(string storeName, string queryExpression, DateTime?ifNotModifiedSince = null, SparqlResultsFormat resultsFormat = null)
        {
            if (storeName == null)
            {
                throw new ArgumentNullException("storeName");
            }
            if (queryExpression == null)
            {
                throw new ArgumentNullException("queryExpression");
            }
            if (resultsFormat == null)
            {
                resultsFormat = SparqlResultsFormat.Xml;
            }

            try
            {
                var pStream = new MemoryStream();
#if SILVERLIGHT
                var t = new Thread(ExecuteQuery);
                t.Start(new QueryParams(storeName, queryExpression, ifNotModifiedSince, resultsFormat, pStream));
                t.Join();
#else
                var t = new Task(() => _serverCore.Query(storeName, queryExpression, ifNotModifiedSince, resultsFormat, pStream));
                t.Start();
                t.Wait();
                if (t.IsFaulted && t.Exception != null)
                {
                    throw t.Exception;
                }
#endif

                pStream.Seek(0, SeekOrigin.Begin);
                return(pStream);
            }
            catch (BrightstarStoreNotModifiedException ex)
            {
                throw new BrightstarClientException("Store not modified", new ExceptionDetail(ex));
            }
            catch (Exception ex)
            {
                Logging.LogError(BrightstarEventId.ServerCoreException, "Error Executing Query {0} {1}", storeName, queryExpression);
                throw new BrightstarClientException("Error querying store " + storeName + " with expression " + queryExpression + ". " + ex.Message, ex);
            }
        }
        public override SparqlResult ExecuteSparql(string sparqlExpression)
        {
            var resultStream = new MemoryStream();

            _serverCore.Query(_storeName, sparqlExpression, DataSetGraphUris, null, SparqlResultsFormat.Xml,
                              RdfFormat.RdfXml, resultStream);
            resultStream.Seek(0, SeekOrigin.Begin);
            return(new SparqlResult(resultStream));
        }
示例#3
0
        public override SparqlResult ExecuteSparql(SparqlQueryContext sparqlQueryContext)
        {
            var resultStream = new MemoryStream();

            _serverCore.Query(_storeName, sparqlQueryContext.SparqlQuery, DataSetGraphUris, null, SparqlResultsFormat.Xml,
                              RdfFormat.RdfXml, resultStream);
            resultStream.Seek(0, SeekOrigin.Begin);
            return(new SparqlResult(resultStream, sparqlQueryContext));
        }
        public override SparqlResult ExecuteSparql(string sparqlExpression)
        {
            var xml = _serverCore.Query(_storeName, sparqlExpression, SparqlResultsFormat.Xml);

            return(new SparqlResult(xml));
        }
示例#5
0
 public string ProcessQuery(string storeId, string query)
 {
     return(_serverCore.Query(storeId, query, SparqlResultsFormat.Xml));
 }