public FileResult ExportOrder(OrderSearch orderSearch) { ExportReportService _export = new ExportReportService(); DownLoadFile downloadFile = _export.GenerateOrderReport(orderSearch); //string path = ConfigurationManager.AppSettings["directoryPath"]; string path = App.Config.ReportDirectoryPath; //string downloadFile = string.Format(path, file); ////Stream fs = File.OpenRead(@"c:\testdocument.docx"); //FileStream stream = new FileStream(downloadFile, FileMode.Open, FileAccess.Read); //byte[] buffer = new byte[2048]; //byte[] bufferByte; //using (MemoryStream ms = new MemoryStream()) //{ // int read; // while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) // { // ms.Write(buffer, 0, read); // } // bufferByte = ms.ToArray(); //}; //stream.Close(); //_export.DeleteFile(downloadFile); return(File(downloadFile.bufferByte, "application/vnd.ms-excel", downloadFile.FileName)); }
/// <summary> /// Exports report in .xlsx file /// </summary> /// <param name="reportSearch">reportSearch contains which report to export and it filters values</param> /// <remark>This method export Announcement analysis report,Finance report,Cancel avail report,Date change report</remark>> /// <returns>FileResult which help to download report in browser</returns> public ActionResult Reports1(ReportSearch reportSearch) { string path = string.Empty; string downloadFile = string.Empty; DownLoadFile downLoadFile = null; IExportReportService exportService = new ExportReportService(); if (reportSearch.ReportTitleID.Equals(1)) { int recordCount = exportService.GetAnnouncementAnalysisReportRecordCount(reportSearch); if (recordCount > App.Config.MaxAnnouncementAnalysisDownloadRecordLimit) { TempData["ErrorMsg"] = string.Format("There are {0} records that you are trying to download. Record count should not exceed {1} records.", recordCount, App.Config.MaxAnnouncementAnalysisDownloadRecordLimit); return(RedirectToAction("Reports", "Report", new { @reportSearch = reportSearch })); } downLoadFile = exportService.GenerateAnnouncementAnalysisReport(reportSearch); } else if (reportSearch.ReportTitleID.Equals(2)) { downLoadFile = exportService.GenerateCancelAvailsReport(reportSearch); } else if (reportSearch.ReportTitleID.Equals(3)) { downLoadFile = exportService.GenerateFinanceReport(reportSearch); } else if (reportSearch.ReportTitleID.Equals(4)) { downLoadFile = exportService.GenerateAnnouncementChangeReport(reportSearch); } return(File(downLoadFile.bufferByte, "application/vnd.ms-excel", downLoadFile.FileName)); }
public FileResult Reports1(ReportSearch reportSearch) { string path = string.Empty; string downloadFile = string.Empty; DownLoadFile downLoadFile = null; ExportReportService exportService = new ExportReportService(); if (reportSearch.ReportTitleID.Equals(1)) { downLoadFile = exportService.GenerateAnnouncementAnalysisReport(reportSearch); } else if (reportSearch.ReportTitleID.Equals(2)) { downLoadFile = exportService.GenerateCancelAvailsReport(reportSearch); } else if (reportSearch.ReportTitleID.Equals(3)) { downLoadFile = exportService.GenerateFinanceReport(reportSearch); } else if (reportSearch.ReportTitleID.Equals(4)) { downLoadFile = exportService.GenerateAnnouncementChangeReport(reportSearch); } //file = TempData["fileName"].ToString(); //path = ConfigurationManager.AppSettings["directoryPath"]; //path = App.Config.ReportDirectoryPath; //string fullPath = string.Format(path, file); return(File(downLoadFile.bufferByte, "application/vnd.ms-excel", downLoadFile.FileName)); //TempData["fileName"] = file; //return RedirectToAction("Reports"); }
public FileResult ExportTitle(TitleSearch titleSearch) { ExportReportService _export = new ExportReportService(); DownLoadFile downloadFile = _export.GenerateTitleReport(titleSearch); //string path = ConfigurationManager.AppSettings["directoryPath"]; //string path = App.Config.ReportDirectoryPath; //string downloadFile = string.Format(path, file); return(File(downloadFile.bufferByte, "application/vnd.ms-excel", downloadFile.FileName)); }
public ActionResult Reports(ReportSearch reportSearch) { ReportsModel reportModel = new ReportsModel(); ExportReportService _report = new ExportReportService(); //reportModel.Name = Session["Name"].ToString(); var searchValues = _report.GetSearchValues(); reportModel.ReportSearch.ContentDistributors = searchValues.ContentDistributors; reportModel.ReportSearch.ContentProviders = searchValues.ContentProviders; reportModel.ReportSearch.LocalEdits = searchValues.LocalEdits; reportModel.ReportSearch.AnnouncementProcessedDate = searchValues.AnnouncementProcessedDate; return(View(reportModel)); }
public ActionResult ExportTitle(TitleSearch titleSearch) { //Titles(TitleSearch titleSearch, int? pageNumber) IExportReportService _export = new ExportReportService(); int recordCount = _export.GetTitleReportRecordCount(titleSearch); if (recordCount > App.Config.MaxTitleReportDownloadRecordLimit) { titleSearch.Territory = string.IsNullOrEmpty(titleSearch.TerritoryConcat) ? titleSearch.Territory : titleSearch.TerritoryConcat.Split('|'); titleSearch.Language = string.IsNullOrEmpty(titleSearch.LanguageConcate) ? titleSearch.Language : titleSearch.LanguageConcate.Split('|'); titleSearch.Region = string.IsNullOrEmpty(titleSearch.RegionConcat) ? titleSearch.Region : titleSearch.RegionConcat.Split('|'); TempData["ErrorMsg"] = string.Format("There are {0} records that you are trying to download. Record count should not exceed {1} records.", recordCount, App.Config.MaxTitleReportDownloadRecordLimit); return(RedirectToAction("Titles", "Title", new { @titleSearch = titleSearch })); //return RedirectToAction("Index"); } DownLoadFile downloadFile = _export.GenerateTitleReport(titleSearch); return(File(downloadFile.bufferByte, "application/vnd.ms-excel", downloadFile.FileName)); }