コード例 #1
0
        public async Task <HttpResponseMessage> GenerateHeatChart(HttpRequestMessage request, int heatChartID)
        {
            string filePath = string.Empty;
            string fileName = string.Empty;

            try
            {
                var heatChartHeader = _heatChartHeaderRepository.GetSingleByHeatChartHeaderID(heatChartID);

                var heatChartHeaderVM = DomainToViewModelCustomMapper.MapHeatChartHeader(heatChartHeader);

                fileName = string.Format("{0}_{1}", heatChartHeader.HeatChartNumber.Replace("/", "_"), "HeatChart.pdf");

                var resultStream = PDFGenerateHelper.GeneratePDF(fileName, heatChartHeaderVM, string.Empty, ConfigurationReader.IsSaveToDirectory);

                S3UploadObject.WriteAnObject(resultStream, fileName, ConfigurationReader.AWSHeatChartFolderName);
            }
            catch (Exception ex)
            {
                LogError(ex);
            }

            return(CreateHttpResponse(request, () =>
            {
                return S3UploadObject.DownloadAnObject(fileName, ConfigurationReader.AWSHeatChartFolderName);
            }));
        }
コード例 #2
0
        public async Task <HttpResponseMessage> GenerateHeatChartRDLC(HttpRequestMessage request, int heatChartID)
        {
            string filePath = string.Empty;
            string fileName = string.Empty;

            try
            {
                var heatChartHeader = _heatChartHeaderRepository.GetSingleByHeatChartHeaderID(heatChartID);

                var heatChartHeaders = new List <HeatChartHeader>();
                heatChartHeaders.Add(heatChartHeader);

                var heatChartHeaderVMs = DomainToViewModelCustomMapper.MapHeatChartHeaders(heatChartHeaders);

                var heatChartHeaderDatasetVMs = AutoMapper.Map <IEnumerable <HeatChartHeaderVM>, IEnumerable <HeatChartHeaderDatasetVM> >(heatChartHeaderVMs);

                var heatChartDetailsDatasetVMs =
                    AutoMapper.Map <IEnumerable <HeatChartDetailsVM>, IEnumerable <HeatChartDetailsDatasetVM> >(heatChartHeaderVMs.FirstOrDefault().HeatChartDetails);

                fileName = string.Format("{0}_{1}", heatChartHeader.HeatChartNumber.Replace("/", "_"), "HeatChart.pdf");

                var resultStream = await ReportGenerator.GeneratePDF(heatChartHeaderDatasetVMs.ToList(), heatChartDetailsDatasetVMs.ToList(), fileName);

                S3UploadObject.WriteAnObject(resultStream, fileName, ConfigurationReader.AWSHeatChartFolderName);
            }
            catch (Exception ex)
            {
                LogError(ex);
            }

            return(CreateHttpResponse(request, () =>
            {
                return S3UploadObject.DownloadAnObject(fileName, ConfigurationReader.AWSHeatChartFolderName);
            }));
        }
コード例 #3
0
 public async Task <HttpResponseMessage> Download(string fileName)
 {
     try
     {
         if (!string.IsNullOrEmpty(fileName))
         {
             return(S3UploadObject.DownloadAnObject(fileName, ConfigurationReader.AWSMaterialRegisterFolderName));
         }
         return(this.Request.CreateResponse(HttpStatusCode.NotFound, "File not found."));
     }
     catch (Exception ex)
     {
         LogError(ex);
         return(this.Request.CreateResponse(HttpStatusCode.InternalServerError, ex));
     }
 }