public ActionResult SendERPDFEmail(string ExcelGridName, Email email, string ERReportName, string SortBy = "", string SortOrder = "") { var emailService = new CommonService(); bool emailSuccess = true; var emailMessage = WebConstants.Excel_Email_Success; try { byte[] fileContents = null; SearchER ERsearchcriteria = Session["ERsearchcriteria"] as SearchER; // Session.Remove("ERsearchcriteria"); if (ERReportName == "TracersByTJCStandard") { var tjcStandardService = new TracersByTJCStandard(); fileContents = tjcStandardService.TracerByTJCStandardRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); } else if (ERReportName == "ERTracerByQuestion") { var ERTracerByQuestion = new ERTracerByQuestion(); fileContents = ERTracerByQuestion.ERTracerByQuestionRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); } else { var tcsService = new TracersComplianceSummary(); fileContents = tcsService.TracersComplianceSummaryRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); } email.AttachmentLocation[0] = emailService.SavePDF(ExcelGridName, fileContents); email.FileContents = fileContents; emailSuccess = emailService.SendExcelEmailAttachemnt(email, true); if (emailSuccess) { emailMessage = WebConstants.Excel_Email_Success; } else { emailMessage = WebConstants.Email_Failed; } } catch (Exception) { emailMessage = WebConstants.Excel_Email_Failed; } finally { Session.Remove("ERsearchcriteria"); } return(Json(emailMessage)); }
public ActionResult createErPdf(string ExcelGridName, string ERReportName, string SortBy = "", string SortOrder = "") { var emailService = new CommonService(); var createErPdf = "failed"; string fileGuid = ""; try { byte[] fileContents = null; SearchER ERsearchcriteria = Session["ERsearchcriteria"] as SearchER; Session.Remove("ERsearchcriteria"); if (ERReportName == "TracersByTJCStandard") { var tjcStandardService = new TracersByTJCStandard(); fileContents = tjcStandardService.TracerByTJCStandardRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); } else if (ERReportName == "ERTracerByQuestion") { var ERTracerByQuestion = new ERTracerByQuestion(); fileContents = ERTracerByQuestion.ERTracerByQuestionRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); } else { var tcsService = new TracersComplianceSummary(); fileContents = tcsService.TracersComplianceSummaryRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); } if (fileContents != null) { createErPdf = "success"; } else { createErPdf = "failed"; } fileGuid = emailService.SavePDF(ExcelGridName, fileContents); } catch (Exception) { createErPdf = "failed"; } finally { Session.Remove("ERsearchcriteria"); } return(Json(new { exportCreated = createErPdf, fileGuid = fileGuid })); }