public void SaveToEbook(Models.IncidentReport report, string path) { string document = @"\\844dc2\Conners\"; if (report.isApproximate) { document += path + @"\Incident Report " + report.incidentDate.ToString("yyyy-MM") + ".pdf"; } else { document += path + @"\Incident Report " + report.incidentDate.ToString("yyyy-MM-dd") + ".pdf"; } try { Reports.ResidentialReport reportDocument = this.ResidentialReport(report.incidentId); reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, document); reportDocument.Close(); reportDocument.Dispose(); } catch (Exception ex) { string errorMessage = ex.Message; if (ex.InnerException != null) { errorMessage += ex.InnerException.Message; } throw new Exception(document + Environment.NewLine + errorMessage); } }
public FileStreamResult Residential(long id) { try { Reports.ResidentialReport report = this.ResidentialReport(id); Stream reportStream = report.ExportToStream(ExportFormatType.PortableDocFormat); report.Close(); report.Dispose(); return(new FileStreamResult(reportStream, "application/pdf")); } catch (Exception ex) { string errorMessage = ex.Message; if (ex.InnerException != null) { errorMessage += "; " + ex.InnerException.Message; } errorMessage += Environment.NewLine; throw new Exception(errorMessage); } }