Пример #1
0
            internal Task <T> DownloadAttachmentsAsync <T>(ExportAttachmentsJob job, string methodName, CancellationToken cancellationToken, Func <HttpResponseMessage, Task <T> > func, bool disposeResponse)
            {
                var request = new HttpRequestMessage(HttpMethod.Get, job.File.EntityUri);

                request.Headers.Authorization = AuthenticationHeaderValue.Parse(job.File.AuthorizationHeader);
                return(SendFullUriAsync(request, methodName, job.JobId, cancellationToken, func, disposeResponse: disposeResponse));
            }
Пример #2
0
        /// <inheritdoc/>
        public Task RefreshExportJobAsync(ExportAttachmentsJob job, CancellationToken cancellationToken = default)
        {
            Preconditions.NotNull(job, nameof(job));
            Preconditions.NotNullOrEmpty(job.JobId, nameof(job.JobId));

            if (job.Client == null)
            {
                job.Initialize(Client);
            }
            return(GetPopulateAsync(job.JobId, null, nameof(RefreshExportJobAsync), job.JobId, job, true, cancellationToken));
        }
Пример #3
0
        private Task <T> DownloadAttachmentsInternalAsync <T>(ExportAttachmentsJob job, string methodName, CancellationToken cancellationToken, Func <HttpResponseMessage, Task <T> > func, bool disposeResponse)
        {
            Preconditions.NotNull(job, nameof(job));
            Preconditions.NotNullOrEmpty(job.JobId, nameof(job.JobId));

            if (string.IsNullOrEmpty(job.File.EntityUri))
            {
                if (job.Error != null)
                {
                    throw new InvalidOperationException($"Cannot download export job as there was the following error message: {job.Error.Summary}");
                }
                else
                {
                    throw new InvalidOperationException($"Status of retrieved job must be Success but is currently {job.Status}. Please try refreshing the job to see if it's ready to be downloaded.");
                }
            }

            return(AttachmentJobApi.DownloadAttachmentsAsync(job, methodName, cancellationToken, func, disposeResponse));
        }
Пример #4
0
 /// <inheritdoc/>
 public Task <Stream> DownloadAttachmentsStreamAsync(ExportAttachmentsJob job, CancellationToken cancellationToken = default) => DownloadAttachmentsInternalAsync(job, nameof(DownloadAttachmentsStreamAsync), cancellationToken, ReadAsStreamFunc, disposeResponse: false);
Пример #5
0
 /// <inheritdoc/>
 public Task <byte[]> DownloadAttachmentsAsync(ExportAttachmentsJob job, CancellationToken cancellationToken = default) => DownloadAttachmentsInternalAsync(job, nameof(DownloadAttachmentsAsync), cancellationToken, ReadAsByteArrayFunc, disposeResponse: true);