Exemplo n.º 1
0
        public async Task <IActionResult> SearchSitemapItems([FromBody] SitemapItemSearchCriteria request)
        {
            if (request == null)
            {
                return(BadRequest("request is null"));
            }

            var searchSitemapItemResponse = await _sitemapItemService.SearchAsync(request);

            return(Ok(searchSitemapItemResponse));
        }
Exemplo n.º 2
0
        public async Task DoExportAsync(Stream outStream, Action <ExportImportProgressInfo> progressCallback, ICancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var progressInfo = new ExportImportProgressInfo {
                Description = "loading data..."
            };

            progressCallback(progressInfo);

            using (var sw = new StreamWriter(outStream))
                using (var writer = new JsonTextWriter(sw))
                {
                    await writer.WriteStartObjectAsync();

                    progressInfo.Description = "Site maps exporting...";
                    progressCallback(progressInfo);

                    await writer.WritePropertyNameAsync("Sitemaps");

                    await writer.SerializeJsonArrayWithPagingAsync(_jsonSerializer, _batchSize, (skip, take) => _sitemapService.SearchAsync(new SitemapSearchCriteria {
                        Skip = skip, Take = take
                    }), (processedCount, totalCount) =>
                    {
                        progressInfo.Description = $"{ processedCount } of { totalCount } site maps have been exported";
                        progressCallback(progressInfo);
                    }, cancellationToken);

                    progressInfo.Description = "Site map items exporting...";
                    progressCallback(progressInfo);

                    await writer.WritePropertyNameAsync("SitemapItems");

                    await writer.SerializeJsonArrayWithPagingAsync(_jsonSerializer, _batchSize, (skip, take) => _sitemapItemService.SearchAsync(new SitemapItemSearchCriteria {
                        Skip = skip, Take = take
                    }), (processedCount, totalCount) =>
                    {
                        progressInfo.Description = $"{ processedCount } of { totalCount } site maps items have been exported";
                        progressCallback(progressInfo);
                    }, cancellationToken);

                    await writer.WriteEndObjectAsync();

                    await writer.FlushAsync();
                }
        }