public static void CreateReport(string orderUniqueNumber, string reportformat, string templatecode , string reporttype, AgencyReportRequest agencyReportRequest) { var restClient = (ReportsRestClient)GetRestClient("ReportsRestClient"); var format = (ReportFormat)Enum.Parse(typeof(ReportFormat), reportformat, true); Report report = null; if (reporttype == "ininvoice") { report = restClient.CreateInInvoice(orderUniqueNumber, templatecode, format); } if (reporttype == "outinvoice") { report = restClient.CreateOutInvoice(orderUniqueNumber, templatecode, format); } if (reporttype == "agentreport") { report = restClient.CreateAgentReport(agencyReportRequest, templatecode, format); } string uniquenumber = orderUniqueNumber ?? agencyReportRequest.OrganizationCode; string filename = reporttype + "_" + uniquenumber + "_" + DateTime.Now.ToString("MMdd_HHmmss") + "." + reportformat; var filePath = Path.Combine(Path.GetTempPath(), filename); File.WriteAllBytes(filePath, report.Content); Process.Start(new ProcessStartInfo { FileName = filePath, UseShellExecute = true }); }
private void btnSave_Click(object sender, EventArgs e) { var agencyReportRequest = new AgencyReportRequest(); agencyReportRequest.ServiceType = "flights"; agencyReportRequest.OrganizationCode = _orgcode; agencyReportRequest.BeginDate = calFrom.DateTime; agencyReportRequest.EndDate = calTo.DateTime; splashScreenManager1.ShowWaitForm(); try { DataProcessor.CreateReport(null, cbFormat.EditValue.ToString(), null, "agentreport", agencyReportRequest); } finally { splashScreenManager1.CloseWaitForm(); } this.DialogResult = DialogResult.OK; }
public void CreateFlightsAgency() { ReportsRestClient restClient = CreateRestClient(); var agencyReportRequest = new AgencyReportRequest(); agencyReportRequest.ServiceType = "flights"; agencyReportRequest.OrganizationCode = "sputnik"; agencyReportRequest.BeginDate = DateTime.Parse("2012.01.01"); agencyReportRequest.EndDate = DateTime.Now; Report report = restClient.CreateAgentReport(agencyReportRequest, null /*Стандартный шаблон отчета*/, ReportFormat.Pdf /*формат файла*/); //Сохраняем присланные байты в файл string filePath = Path.Combine(Path.GetTempPath(), report.Name /*Это имя вполне подойдет для названия файла*/); File.WriteAllBytes(filePath, report.Content); //Запускаем файл в связанном приложении Process.Start(new ProcessStartInfo { FileName = filePath, UseShellExecute = true }); }