Beispiel #1
0
 public IHttpActionResult DownloadInternalRequisitionFormReport([FromUri] OrderAdminSearchCriteria searchCriteria)
 {
     try
     {
         var    path = System.Web.Hosting.HostingEnvironment.MapPath(_appSettings.InternalRequisitionFormTemplate);
         byte[] content;
         using (FileStream file = File.Open(path, FileMode.Open))
         {
             content = _orderReportService.GetInternalRequisitionFormReport(
                 _workContext.User,
                 file,
                 searchCriteria);
         }
         var stream = new MemoryStream(content);
         var result = new FileActionResult(stream,
                                           $"InternalRequisitionForm_{searchCriteria.OrderStatus}_{DateTime.Now.ToString("dd-MM-yyyy")}.xlsx");
         return(result);
     }
     catch (StaffingPurchaseException ex)
     {
         return(new StaffPurchaseExceptionActionResult(ex.Message));
     }
     catch (Exception ex)
     {
         _logger.Error("Failed to download Internal Requisition Form Report", ex);
         return(new StaffPurchaseExceptionActionResult(_resourceManager.GetString("OrderReport.FailedToReport")));
     }
 }