public override async Task<BerkeleyError> WriteAsync(BerkeleyDb db, Byte[] key, Byte[] value, BerkeleyDbWriteMode writeMode)
        {
            String requestUri = "api/database/write/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
            var data = new BerkeleyDtoPut(key, value);
            var content = new ObjectContent<BerkeleyDtoPut>(data, _formatter, (String)null);
            HttpResponseMessage response = await _httpClient.PostAsync(requestUri, content).ConfigureAwait(false);
            if (!response.IsSuccessStatusCode)
                return new BerkeleyError(response.StatusCode);

            BerkeleyDbError error = await SerializeHelper.GetErrorAsync(_serializer, response.Content).ConfigureAwait(false);
            return new BerkeleyError(error);
        }
예제 #2
0
        public override async Task <BerkeleyError> WriteMultipleAsync(BerkeleyDb db, BerkeleyDtoPut data, BerkeleyDbWriteMode writeMode)
        {
            String        requestUri;
            ObjectContent content;

            if (data.Key == null)
            {
                requestUri = "api/database/writemultiplekey/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
                content    = new ObjectContent <Byte[]>(data.Value, _formatter, (String)null);
            }
            else
            {
                requestUri = "api/database/write/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
                content    = new ObjectContent <BerkeleyDtoPut>(data, _formatter, (String)null);
            }

            HttpResponseMessage response = await _httpClient.PostAsync(requestUri, content);

            if (!response.IsSuccessStatusCode)
            {
                return(new BerkeleyError(response.StatusCode));
            }

            BerkeleyDbError error = await SerializeHelper.GetErrorAsync(_serializer, response.Content).ConfigureAwait(false);

            return(new BerkeleyError(error));
        }
        public override async Task<BerkeleyError> WriteDuplicateAsync(BerkeleyDb db, BerkeleyDtoPut data, int bufferSize, BerkeleyDbWriteMode writeMode)
        {
            String requestUri;
            BerkeleyDtoPut dataPost;
            if (data.Key.Length <= bufferSize && data.Value.Length <= bufferSize)
            {
                requestUri = "api/database/writemultipleduplicate/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
                dataPost = new BerkeleyDtoPut(data.Key, data.Value);
            }
            else
            {
                requestUri = "api/database/write/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
                dataPost = data;
            }

            ObjectContent content = new ObjectContent<BerkeleyDtoPut>(dataPost, _formatter, (String)null);
            HttpResponseMessage response = await _httpClient.PostAsync(requestUri, content).ConfigureAwait(false);
            if (!response.IsSuccessStatusCode)
                return new BerkeleyError(response.StatusCode);

            BerkeleyDbError error = await SerializeHelper.GetErrorAsync(_serializer, response.Content).ConfigureAwait(false);
            return new BerkeleyError(error);
        }
예제 #4
0
        public override async Task <BerkeleyError> WriteDuplicateAsync(BerkeleyDb db, BerkeleyDtoPut data, int bufferSize, BerkeleyDbWriteMode writeMode)
        {
            String         requestUri;
            BerkeleyDtoPut dataPost;

            if (data.Key.Length <= bufferSize && data.Value.Length <= bufferSize)
            {
                requestUri = "api/database/writemultipleduplicate/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
                dataPost   = new BerkeleyDtoPut(data.Key, data.Value);
            }
            else
            {
                requestUri = "api/database/write/?handle=" + db.Handle.ToString() + "&writemode=" + writeMode.ToStringEx();
                dataPost   = data;
            }

            ObjectContent       content  = new ObjectContent <BerkeleyDtoPut>(dataPost, _formatter, (String)null);
            HttpResponseMessage response = await _httpClient.PostAsync(requestUri, content).ConfigureAwait(false);

            if (!response.IsSuccessStatusCode)
            {
                return(new BerkeleyError(response.StatusCode));
            }

            BerkeleyDbError error = await SerializeHelper.GetErrorAsync(_serializer, response.Content).ConfigureAwait(false);

            return(new BerkeleyError(error));
        }