Esempio n. 1
0
        /// <summary>
        /// Bulks the async.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="ideasJson">Ideas json.</param>
        public async Task BulkAsync(List <string> ideasJson)
        {
            var request = new BulkRequest();

            request.Include(ideasJson.ToArray());
            var response = await Documents.BulkAsync(request);
        }
Esempio n. 2
0
        /// <summary>
        /// Bulks the async.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="items">Ideas json.</param>
        public TaskResult BulkAsync(List <string> items)
        {
            Logger.Info($"performing bulk imports for broker transaction total: {items.Count}");
            var request = new BulkRequest();

            request.Include(items.ToArray());
            var response = Documents.BulkAsync(request);

            Logger.Info($"operaton reason: {response.Result.StatusCode}");
            return(new TaskResult());
        }
        /// <summary>
        /// Bulks the async.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="imports">Ideas json.</param>
        public async Task <Result> BulkAsync(List <string> imports)
        {
            Logger.Info($"performing bulk imports for broker transaction total: {imports.Count}");
            var request = new BulkRequest();

            request.Include(imports.ToArray());
            var response = await Documents.BulkAsync(request);

            Logger.Info($"operaton reason: {response.Reason}");
            return(new TaskResult {
                IsSuccessful = true
            });
        }
        /// <summary>
        /// Add the specified ideas.
        /// </summary>
        /// <returns>The add.</returns>
        /// <param name="ideas">Ideas.</param>
        public async Task <Result> BulkAsync(List <string> ideasJson)
        {
            var request = new BulkRequest();

            request.Include(ideasJson.ToArray());
            var response = await Documents.BulkAsync(request);

            return(new TaskResult
            {
                IsSuccessful = response.IsSuccess,
                StatusCode = response.StatusCode.ToString(),
                Reason = response.Reason
            });
        }
        /// <summary>
        /// Bulks the insert.
        /// </summary>
        /// <param name="transactions">Transactions.</param>
        public async Task <Result> BulkAsync(List <string> transactions)
        {
            var request = new BulkRequest();

            request.Include(transactions.ToArray());
            var response = await Documents.BulkAsync(request);

            Logger.Info("bulk transaction opeartion completed.");
            var taskResult = new TaskResult {
                IsSuccessful = true
            };

            taskResult.SetData(response);
            return(taskResult);
        }
Esempio n. 6
0
        public async Task ClearAsync(bool compact)
        {
            Log.Message("Clearing out " + this + "...");
            var request  = new QueryViewRequest(SystemViewIdentity.AllDocs);
            var response = await Views.QueryAsync <AllDocsValue>(request);

            if (!response.IsSuccess)
            {
                throw new Exception("Failed to clear local store " + this + ": " + response.Reason);
            }
            var headers = new List <DocumentHeader>();

            for (long i = 0; i < response.RowCount; i++)
            {
                if (!response.Rows[i].Value.Deleted)
                {
                    headers.Add(new DocumentHeader(response.Rows[i].Id, response.Rows[i].Value.Rev));
                }
            }
            if (headers.Count > 0)
            {
                var rs = await Documents.BulkAsync(new BulkRequest().Delete(headers.ToArray()));

                if (!rs.IsSuccess)
                {
                    throw new Exception("Unable to delete all documents in " + this + ": " + rs.Reason);
                }
                if (compact)
                {
                    var rs2 = await Database.CompactAsync();

                    if (!rs2.IsSuccess)
                    {
                        throw new Exception("Unable to compact documents in " + this + ": " + rs2.Reason);
                    }
                }
            }
            if (compact)
            {
                Log.Message(this + " is clear and compacted");
            }
            else
            {
                Log.Message(this + " is clear");
            }
        }