/// <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));
        }
Exemplo n.º 2
0
        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");
        }