private async Task StoreRenderedReport(
            IExecuteReportRequest request,
            IExecuteReportResponse response,
            byte[]                 bytes)
        {
            Log.Verbose("Uploading rendered report to storage.");

            var extension = GetFileExtension(request);

            using (var stream = new MemoryStream(bytes, writable: false))
                response.Uri = await _storage.PutAsync(stream, extension);
        }
        private async Task <byte[]> ExecuteReport(
            IExecuteReportRequest request,
            IExecuteReportResponse response)
        {
            Log.Verbose("Creating report execution service client.");
            var credential = request.GetNetworkCredential();

            using (var client = _services.CreateExecutionClient(credential))
            {
                Log.Verbose("Invoking LoadReport2.");
                var loaded = await client.LoadReport2Async(
                    new LoadReport2Request { Report = request.Path }
                    );

                var executionHeader = loaded.ExecutionHeader;

                Log.Verbose("Invoking SetExecutionParameters2.");
                await client.SetExecutionParameters2Async(
                    new SetExecutionParameters2Request
                {
                    ExecutionHeader   = executionHeader,
                    Parameters        = GetParameterValues(request),
                    ParameterLanguage = GetParameterLanguage(request),
                }
                    );

                Log.Verbose("Invoking Render2.");
                var rendered = await client.Render2Async(new Render2Request
                {
                    ExecutionHeader = executionHeader,
                    Format          = GetFormat(request),
                    PaginationMode  = PageCountMode.Actual
                });

                response.ContentType       = rendered.MimeType;
                response.FileNameExtension = rendered.Extension;
                response.Length            = rendered.Result.Length;
                response.Messages          = TranslateWarnings(rendered.Warnings);

                return(rendered.Result);
            }
        }