コード例 #1
0
 public virtual IActionResult ExportReportProcuringAgency(ReportProcuringAgencySearchModel searchModel)
 {
     if (!string.IsNullOrEmpty(searchModel.StringProcuringAgencyId))
     {
         var listProcuringAgency = searchModel.StringProcuringAgencyId.Split(',').ToList();
         searchModel.SelectedProcuringAgencyIds = listProcuringAgency.Select(c => (int)c.ToNumber()).ToList();
     }
     try
     {
         var report = _reportService.GetReportProcuringAgency(
             SelectedProcuringAgencyIds: searchModel.SelectedProcuringAgencyIds.ToList(),
             datetimeFrom: searchModel.datetimeFrom,
             datetimeTo: searchModel.datetimeTo);
         byte[] bytes;
         using (var stream = new MemoryStream())
         {
             _exportManager.ExportContractProcuringAgency(report, stream, Convert.ToDateTime(searchModel.datetimeFrom), Convert.ToDateTime(searchModel.datetimeTo));
             bytes = stream.ToArray();
         }
         return(File(bytes, MimeTypes.TextXlsx, "BaoCaoLichSuHDvaCDT.xlsx"));
     }
     catch (Exception exc)
     {
         ErrorNotification(exc);
         return(RedirectToAction("List"));
     }
 }