public void DownloadReportTest() { var manager = new ReportingManager(); var login = manager.Login(); Assert.IsNotNull(login); Assert.AreNotEqual("", login.Access_token); var parms = new Dictionary <string, string> { { "complianceApplicationId", "3d770eb7-d7b8-48e4-a155-41f482e86cc7" }, { "orgName", "cGMP+Cell+Processing+Facility+Diabetes+Research+Institute+University+of+Miami+Miller+School+of+Medicine+ORG" } }; using (var stream = manager.DownloadPdf(login.Access_token, "Inspection Summary", parms)) { Assert.IsNotNull(stream); var trueVaultManager = new TrueVaultManager(); var apiKey = ConfigurationManager.AppSettings["DocumentLibraryApiKey"]; var result = trueVaultManager.Upload(apiKey, "9c0d8021-0660-4e03-9fb0-00b47e0c76dd", "InspectionSummary_2016_12_22.pdf", stream); Assert.IsNotNull(result); Assert.AreNotEqual("", result.Result); Console.WriteLine(result.Blob_id); //stream.Position = 0; //File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "\\test.pdf", stream.ToArray()); } }
public Document CopyReport(string reportName, string vaultId, Guid appId, string organizationName, int cycleNumber = 0, bool factOnly = true, string fileName = "", string fullFileName = "") { var manager = new ReportingManager(); var documentFacade = this.container.GetInstance <DocumentFacade>(); var login = manager.Login(); var parms = new Dictionary <string, string>(); switch (reportName) { case Constants.Reports.AccreditationReport: parms = new Dictionary <string, string> { { "complianceApplicationId", appId.ToString() }, { "orgName", organizationName.Replace(" ", "+") } }; if (string.IsNullOrEmpty(fullFileName)) { fullFileName = $"Accreditation Rpt - {organizationName.Replace(" ", "")}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Year}.pdf"; } if (string.IsNullOrEmpty(fileName)) { fileName = $"Accreditation Rpt - {DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Year} - .pdf"; } break; case Constants.Reports.InspectionSummary: parms = new Dictionary <string, string> { { "complianceApplicationId", appId.ToString() }, { "orgName", organizationName.Replace(" ", "+") } }; fullFileName = $"InspectionSummary_{organizationName.Replace(" ", "")}_{DateTime.Now.Year}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.pdf"; fileName = $"InspectionSummary_{DateTime.Now.Year}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.pdf"; break; case Constants.Reports.SingleApplication: parms = new Dictionary <string, string> { { "applicationUniqueId", appId.ToString() } }; fullFileName = $"AnnualApplication_{organizationName.Replace(" ", "")}_{DateTime.Now.Year}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.pdf"; fileName = $"AnnualApplication_{DateTime.Now.Year}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.pdf"; break; case Constants.Reports.OutcomesData: parms = new Dictionary <string, string> { { "complianceApplicationId", appId.ToString() }, { "orgName", organizationName.Replace(" ", "+") } }; if (string.IsNullOrWhiteSpace(fullFileName)) { fullFileName = $"Outcomes/Data Rpt - {organizationName.Replace(" ", "")}_{DateTime.Now.Year}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.pdf"; } if (string.IsNullOrWhiteSpace(fileName)) { fileName = $"Outcomes/Data Rpt - {organizationName.Replace(" ", "")}_{DateTime.Now.Year}_{DateTime.Now.Month}_{DateTime.Now.Day}_{DateTime.Now.Hour}_{DateTime.Now.Minute}_{DateTime.Now.Second}.pdf"; } break; } using (var stream = manager.DownloadPdf(login.Access_token, reportName, parms)) { var trueVaultManager = new TrueVaultManager(); var apiKey = ConfigurationManager.AppSettings["DocumentLibraryApiKey"]; var result = trueVaultManager.Upload(apiKey, vaultId, fullFileName, stream); if (result.Result != TrueVaultManager.Success) { throw new Exception("Error saving to True Vault"); } return(documentFacade.AddToLibrary(appId, organizationName, fileName, null, factOnly, "System", result.Blob_id, true, false)); } }