コード例 #1
0
ファイル: QiClient.cs プロジェクト: GregoryHolt/Qi-Samples
        public async Task <string> GetRangeValues(string streamId, string startIndex, int skip, int count, bool reverse, QiBoundaryType boundaryType)
        {
            string             getClause = string.Format(_getRangeTemplate, startIndex, skip, count, reverse, boundaryType);
            HttpRequestMessage msg       = new HttpRequestMessage
            {
                RequestUri = new Uri(_baseUrl + _streamsBase + @"/" + streamId + getClause),
                Method     = HttpMethod.Get
            };

            string token = AcquireAuthToken();

            msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

            HttpResponseMessage response = await _httpClient.SendAsync(msg);

            if (response.IsSuccessStatusCode)
            {
                string jsonResults = await response.Content.ReadAsStringAsync();

                return(jsonResults);
            }
            else
            {
                throw new QiError(response.StatusCode, "Error getting range values: " + response.ReasonPhrase);
            }
        }
コード例 #2
0
ファイル: QiClient.cs プロジェクト: GregoryHolt/Qi-Samples
        public async Task<string> GetRangeValues(string streamId, string startIndex, int skip, int count, bool reverse, QiBoundaryType boundaryType)
        {
            string getClause = string.Format(_getRangeTemplate, startIndex, skip, count, reverse, boundaryType);
            HttpRequestMessage msg = new HttpRequestMessage
            {
                RequestUri = new Uri(_baseUrl + _streamsBase + @"/" + streamId + getClause),
                Method = HttpMethod.Get
            };

            string token = AcquireAuthToken();
            msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

            HttpResponseMessage response = await _httpClient.SendAsync(msg);
            if (response.IsSuccessStatusCode)
            {
                string jsonResults = await response.Content.ReadAsStringAsync();
                return jsonResults;
            }
            else
            {
                throw new QiError(response.StatusCode, "Error getting range values: " + response.ReasonPhrase);
            }
        }