Esempio n. 1
0
        public async Task <SolrQueryResults <T> > ExecuteAsync(ISolrQuery q, ISolrQueryBody body, QueryOptions options,
                                                               CancellationToken cancellationToken = default(CancellationToken))
        {
            var handler        = options?.RequestHandler?.HandlerUrl ?? DefaultHandler;
            var param          = GetAllParameters(q, options);
            var results        = new SolrQueryResults <T>();
            var serializedBody = body?.Serialize() ?? String.Empty;

            XDocument xml;

            if (connection is IStreamSolrConnection cc)
            {
                using (var r = await cc.PostStreamAsStreamAsync(handler,
                                                                body?.MimeType ?? SimpleJsonQueryBody.ApplicationJson,
                                                                new MemoryStream(Encoding.UTF8.GetBytes(serializedBody)), param, cancellationToken))
                {
                    xml = XDocument.Load(r);
                }
            }
            else
            {
                var r = await connection.PostStreamAsync(handler,
                                                         body?.MimeType ?? SimpleJsonQueryBody.ApplicationJson,
                                                         new MemoryStream(Encoding.UTF8.GetBytes(serializedBody)), param);

                xml = XDocument.Parse(r);
            }

            resultParser.Parse(xml, results);
            return(results);
        }
Esempio n. 2
0
        public Task <string> ExecuteAsync(ISolrConnection connection)
        {
            string json  = GetAtomicUpdateJson();
            var    bytes = Encoding.UTF8.GetBytes(json);

            using (var content = new MemoryStream(bytes))
                return(connection.PostStreamAsync("/update", "text/json; charset=utf-8", content, GetParamsAsKvp()));
        }
Esempio n. 3
0
 public virtual Task <string> PostStreamAsync(string relativeUrl, string contentType, Stream content, IEnumerable <KeyValuePair <string, string> > parameters)
 {
     Console.WriteLine("Posting Binary Async");
     return(conn.PostStreamAsync(relativeUrl, contentType, content, parameters));
 }
Esempio n. 4
0
        public Task <string> ExecuteAsync(ISolrConnection connection)
        {
            var queryParameters = ConvertToQueryParameters();

            return(connection.PostStreamAsync("/update/extract", parameters.StreamType, parameters.Content, queryParameters));
        }
Esempio n. 5
0
 public Task <string> PostStreamAsync(string relativeUrl, string contentType, System.IO.Stream content, IEnumerable <KeyValuePair <string, string> > getParameters)
 {
     return(conn.PostStreamAsync(relativeUrl, contentType, content, getParameters));
 }
Esempio n. 6
0
 public async Task <string> PostStreamAsync(string relativeUrl, string contentType, Stream content, IEnumerable <KeyValuePair <string, string> > getParameters)
 {
     // TODO add other args
     Log($"{nameof(relativeUrl)}={relativeUrl}, {nameof(contentType)}={contentType}");
     return(await _connection.PostStreamAsync(relativeUrl, contentType, content, getParameters));
 }