Beispiel #1
0
        /// <summary>
        /// Processes a SPARQL Query asynchronously passing the results to the relevant handler and invoking the callback when the query completes
        /// </summary>
        /// <param name="rdfHandler">RDF Handler</param>
        /// <param name="resultsHandler">Results Handler</param>
        /// <param name="query">SPARQL Query</param>
        /// <param name="callback">Callback</param>
        /// <param name="state">State to pass to the callback</param>
        public void ProcessQuery(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, SparqlQuery query, QueryCallback callback, Object state)
        {
            ProcessQueryAsync d = new ProcessQueryAsync(this.ProcessQuery);

            d.BeginInvoke(rdfHandler, resultsHandler, query, r =>
            {
                d.EndInvoke(r);
                callback(rdfHandler, resultsHandler, state);
            }, state);
        }
        /// <summary>
        /// Processes a SPARQL Query asynchronously invoking the relevant callback when the query completes
        /// </summary>
        /// <param name="query">SPARQL QUery</param>
        /// <param name="rdfCallback">Callback for queries that return a Graph</param>
        /// <param name="resultsCallback">Callback for queries that return a Result Set</param>
        /// <param name="state">State to pass to the callback</param>
        /// <remarks>
        /// In the event of a success the appropriate callback will be invoked, if there is an error both callbacks will be invoked and passed an instance of <see cref="AsyncError"/> which contains details of the error and the original state information passed in.
        /// </remarks>
        public void ProcessQuery(SparqlQuery query, GraphCallback rdfCallback, SparqlResultsCallback resultsCallback, Object state)
        {
            Graph             g    = new Graph();
            SparqlResultSet   rset = new SparqlResultSet();
            ProcessQueryAsync d    = new ProcessQueryAsync(this.ProcessQuery);

            d.BeginInvoke(new GraphHandler(g), new ResultSetHandler(rset), query, r =>
            {
                try
                {
                    d.EndInvoke(r);
                    if (rset.ResultsType != SparqlResultsType.Unknown)
                    {
                        resultsCallback(rset, state);
                    }
                    else
                    {
                        rdfCallback(g, state);
                    }
                }
                catch (RdfQueryException queryEx)
                {
                    if (rdfCallback != null)
                    {
                        rdfCallback(null, new AsyncError(queryEx, state));
                    }
                    if (resultsCallback != null)
                    {
                        resultsCallback(null, new AsyncError(queryEx, state));
                    }
                }
                catch (Exception ex)
                {
                    RdfQueryException queryEx = new RdfQueryException("Unexpected error while making an asynchronous query, see inner exception for details", ex);
                    if (rdfCallback != null)
                    {
                        rdfCallback(null, new AsyncError(queryEx, state));
                    }
                    if (resultsCallback != null)
                    {
                        resultsCallback(null, new AsyncError(queryEx, state));
                    }
                }
            }, state);
        }
Beispiel #3
0
        /// <summary>
        /// Processes a SPARQL Query asynchronously invoking the relevant callback when the query completes
        /// </summary>
        /// <param name="query">SPARQL QUery</param>
        /// <param name="rdfCallback">Callback for queries that return a Graph</param>
        /// <param name="resultsCallback">Callback for queries that return a Result Set</param>
        /// <param name="state">State to pass to the callback</param>
        public void ProcessQuery(SparqlQuery query, GraphCallback rdfCallback, SparqlResultsCallback resultsCallback, Object state)
        {
            Graph             g    = new Graph();
            SparqlResultSet   rset = new SparqlResultSet();
            ProcessQueryAsync d    = new ProcessQueryAsync(this.ProcessQuery);

            d.BeginInvoke(new GraphHandler(g), new ResultSetHandler(rset), query, r =>
            {
                d.EndInvoke(r);
                if (rset.ResultsType != SparqlResultsType.Unknown)
                {
                    resultsCallback(rset, state);
                }
                else
                {
                    rdfCallback(g, state);
                }
            }, state);
        }
        /// <summary>
        /// Processes a SPARQL Query asynchronously passing the results to the relevant handler and invoking the callback when the query completes
        /// </summary>
        /// <param name="rdfHandler">RDF Handler</param>
        /// <param name="resultsHandler">Results Handler</param>
        /// <param name="query">SPARQL Query</param>
        /// <param name="callback">Callback</param>
        /// <param name="state">State to pass to the callback</param>
        /// <remarks>
        /// In the event of a success the callback will be invoked, if there is an error the callback will be invoked and passed an instance of <see cref="AsyncError"/> which contains details of the error and the original state information passed in.
        /// </remarks>
        public void ProcessQuery(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, SparqlQuery query, QueryCallback callback, Object state)
        {
            ProcessQueryAsync d = new ProcessQueryAsync(this.ProcessQuery);

            d.BeginInvoke(rdfHandler, resultsHandler, query, r =>
            {
                try
                {
                    d.EndInvoke(r);
                    callback(rdfHandler, resultsHandler, state);
                }
                catch (RdfQueryException queryEx)
                {
                    callback(rdfHandler, resultsHandler, new AsyncError(queryEx, state));
                }
                catch (Exception ex)
                {
                    callback(rdfHandler, resultsHandler, new AsyncError(new RdfQueryException("Unexpected error making an asynchronous query", ex), state));
                }
            }, state);
        }
Beispiel #5
0
 /// <summary>
 /// Processes a SPARQL Query asynchronously passing the results to the relevant handler and invoking the callback when the query completes
 /// </summary>
 /// <param name="rdfHandler">RDF Handler</param>
 /// <param name="resultsHandler">Results Handler</param>
 /// <param name="query">SPARQL Query</param>
 /// <param name="callback">Callback</param>
 /// <param name="state">State to pass to the callback</param>
 public void ProcessQuery(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, SparqlQuery query, QueryCallback callback, Object state)
 {
     ProcessQueryAsync d = new ProcessQueryAsync(this.ProcessQuery);
     d.BeginInvoke(rdfHandler, resultsHandler, query, r =>
     {
         d.EndInvoke(r);
         callback(rdfHandler, resultsHandler, state);
     }, state);
 }
Beispiel #6
0
 /// <summary>
 /// Processes a SPARQL Query asynchronously invoking the relevant callback when the query completes
 /// </summary>
 /// <param name="query">SPARQL QUery</param>
 /// <param name="rdfCallback">Callback for queries that return a Graph</param>
 /// <param name="resultsCallback">Callback for queries that return a Result Set</param>
 /// <param name="state">State to pass to the callback</param>
 public void ProcessQuery(SparqlQuery query, GraphCallback rdfCallback, SparqlResultsCallback resultsCallback, Object state)
 {
     Graph g = new Graph();
     SparqlResultSet rset = new SparqlResultSet();
     ProcessQueryAsync d = new ProcessQueryAsync(this.ProcessQuery);
     d.BeginInvoke(new GraphHandler(g), new ResultSetHandler(rset), query, r =>
         {
             d.EndInvoke(r);
             if (rset.ResultsType != SparqlResultsType.Unknown)
             {
                 resultsCallback(rset, state);
             }
             else
             {
                 rdfCallback(g, state);
             }
         }, state);
 }