private Stream GetStreamFromAppropiateConnector(string path = "")
        {
            Stream result = null;

            if (_connector != null)
            {
                result = _connector.GetData(path);
            }
            if (_v1Connector != null)
            {
                _v1Connector.UseMetaApi();
                result = _v1Connector.GetData(path);
            }

            return(result);
        }
        public Stream GetReadStream(string key)
        {
            Stream result = null;

            if (!string.IsNullOrEmpty(key))
            {
                if (_connector != null)
                {
                    result = _connector.GetData(key.Substring(key.LastIndexOf('/') + 1));
                }
                else if (_v1Connector != null)
                {
                    result = _v1Connector.GetData(key.Substring(key.LastIndexOf('/') + 1));
                }
            }

            return(result);
        }
示例#3
0
        public QueryResult Retrieve(Query query)
        {
            var doc = new XmlDocument();

            try
            {
                Stream stream;
                if (_connector != null)
                {
                    stream = _connector.GetData(new QueryURLBuilder(query).ToString());
                }
                else
                {
                    if (query.IsHistorical)
                    {
                        _v1Connector.UseHistoryApi();
                    }
                    else
                    {
                        _v1Connector.UseDataApi();
                    }
                    stream = _v1Connector.GetData(new QueryURLBuilder(query, true).ToString());
                }
                doc.Load(stream);
                stream.Dispose();
            }
            catch (WebException ex)
            {
                //if we get a 404, return an empty query result otherwise throw the exception
                if ((ex.Response is HttpWebResponse && ((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound) || ex.Status.ToString() == "404")
                {
                    return(GetEmptyQueryResult(query));
                }

                throw;
            }

            return(ParseQueryResult(doc.DocumentElement, query));
        }