public ActionResult createErPdf(string ExcelGridName, string ERReportName, string SortBy = "", string SortOrder = "") { var emailService = new CommonService(); var createErPdf = "failed"; string fileGuid = ""; try { byte[] fileContents = null; SearchCorporateER ERsearchcriteria = Session["ERsearchcriteria"] as SearchCorporateER; var epaService = new EPAssignment(); fileContents = epaService.EPAssignmentRDLC(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 })); }
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; SearchCorporateER ERsearchcriteria = Session["ERsearchcriteria"] as SearchCorporateER; var epaService = new EPAssignment(); fileContents = epaService.EPAssignmentRDLC(ERsearchcriteria, (int)WebConstants.ReportFormat.PDF, SortBy, SortOrder); email.AttachmentLocation[0] = emailService.SavePDF(ExcelGridName, fileContents); email.FileContents = fileContents; email.ReportName = ERReportName; //int actionTypeId = 52; 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)); }