/// <summary> /// The print appointment confirmations. /// </summary> /// <param name="confirmationDate"> /// The confirmation date. /// </param> /// <param name="officeNum"> /// The office number. /// </param> /// <param name="userId"> /// The user id. /// </param> /// <returns> /// The the result /// </returns> public ActionResult PrintAppointmentConfirmations(string confirmationDate, string officeNum, int userId) { var date = DateTime.Parse(confirmationDate); var confirmationSummaries = this.appointmentManager.GetAppointmentConfirmations(date, officeNum, userId); foreach (var confirmation in confirmationSummaries) { switch (confirmation.ConfirmationStatus) { case "Confirmed": { confirmation.ConfirmationStatus = "<span style='font-weight:bold'>Confirmed</span>" + "</br>" + "Left Message" + "</br>" + "None" + "</br>" + "Not Available"; break; } case "Left Message": { confirmation.ConfirmationStatus = "Confirmed" + "</br>" + "<span style='font-weight:bold'>Left Message</span>" + "</br>" + "None" + "</br>" + "Not Available"; break; } case "Not Available": { confirmation.ConfirmationStatus = "Confirmed" + "</br>" + "Left Message" + "</br>" + "None" + "</br>" + "<span style='font-weight:bold'>Not Available</span>"; break; } case "None": { confirmation.ConfirmationStatus = "Confirmed" + "</br>" + "Left Message" + "</br>" + "<span style='font-weight:bold'>None</span>" + "</br>" + "Not Available"; break; } default: { confirmation.ConfirmationStatus = "Confirmed" + "</br>" + "Left Message" + "</br>" + "<span style='font-weight:bold'>None</span>" + "</br>" + "Not Available"; break; } } } var confirmationsReport = ReportFactory.CreateReportWithManualDispose <AppointmentConfirmationsReport>(); // This will be disposed after the report is streamed. var companyId = OfficeHelper.GetCompanyId(officeNum); confirmationsReport.SetDataSource(confirmationSummaries); confirmationsReport.SetParameterValue("Date", confirmationDate); var util = new ReportUtilities(); var outStream = (MemoryStream)util.AddLogo(confirmationsReport, confirmationsReport.Section1, 0, companyId, officeNum); if (outStream != null) { this.Response.Clear(); this.Response.ClearHeaders(); this.Response.ContentType = "application/pdf"; this.Response.BinaryWrite(outStream.ToArray()); this.Response.End(); } ReportFactory.CloseAndDispose(confirmationsReport); // report has been streamed, it is safe to dispose it return(null); }