public async Task ExecuteReportReturnDetails() { var service = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var reportPath = "/reports/X2R_User_Report"; try { var requestObject = new ReportExecutionRequest { reportUnitUri = reportPath, async = true, outputFormat = "pdf", }; var reportJob = await service.ExecuteReportAsync(requestObject); if (reportJob != null && !string.IsNullOrEmpty(reportJob.requestId)) { if (!service.cancelStatuses.Contains(reportJob.status)) { Task <ExecutionStatus> pollTask = service.PollReport(reportJob.requestId); pollTask.Wait(); } var jobDetails = await service.GetExecutionDetails(reportJob.exports[0].id); Debug.Assert(true); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public static async Task <string> ExecuteRequest(ReportExecutionResultSet executionSet) { var requestId = string.Empty; var execService = new ReportExecutionService(SessionRepository); var reportJob = await execService.ExecuteReportAsync(executionSet.GetDefaultRequestObject()); return(reportJob.requestId); }
public async Task GetExecutedReportContentShouldNotHappenThisWay() { // f7bebd78-965c-4e08-ac27-6ade43f75163/exports/383b0c75-551d-43b0-9736-06af2fa4610d/outputResource var service = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>()); var reportPath = "/reports/X2R_User_Report"; var reportName = "X2R_User_Report.pdf"; var requestObject = new ReportExecutionRequest { reportUnitUri = reportPath, async = false, outputFormat = "pdf", }; try { Task <ReportExecutionResponse> execTask = service.ExecuteReportAsync(requestObject); execTask.Wait(); var execResponse = execTask.Result; if (!string.IsNullOrEmpty(execResponse.requestId) && execResponse.status.Equals("ready", StringComparison.OrdinalIgnoreCase)) { foreach (var export in execResponse.exports) { var downloadPath = System.AppContext.BaseDirectory + reportName + ".pdf"; if (System.IO.File.Exists(downloadPath)) { System.IO.File.Delete(downloadPath); } var rawBytes = await service.GetExecutionOuput(execResponse.requestId, export.id); System.IO.File.WriteAllBytes(downloadPath, rawBytes); } } Debug.Assert(true); } catch (Exception ex) { Assert.Fail(ex.Message); } }