Esempio n. 1
0
        private ActionResult PrepareFileResult(IReport report, string ext, bool download,
                                               byte[] renderedBytes, ReportRegistry.Report reportInfo)
        {
            string fileDownloadName;
            var    customFileName = report as ICustomFileName;

            if (customFileName != null)
            {
                fileDownloadName = customFileName.GetFileName();
            }
            else
            {
                fileDownloadName = (reportInfo.Title ?? reportInfo.Key) + "_" +
                                   DateTime.Now.ToString("yyyyMMdd_HHss");
            }

            fileDownloadName += "." + ext;

            if (download)
            {
                return(new FileContentResult(renderedBytes, "application/octet-stream")
                {
                    FileDownloadName = fileDownloadName
                });
            }

            Response.Headers["Content-Disposition"] = "inline;filename=" + System.Net.WebUtility.UrlEncode(fileDownloadName);
            return(File(renderedBytes, UploadHelper.GetMimeType(fileDownloadName)));
        }
        private ActionResult PrepareFileResult(IReport report, string ext, bool download,
                                               byte[] renderedBytes, ReportRegistry.Report reportInfo)
        {
            string fileDownloadName;
            var    customFileName = report as ICustomFileName;

            if (customFileName != null)
            {
                fileDownloadName = customFileName.GetFileName();
            }
            else
            {
                fileDownloadName = (reportInfo.Title ?? reportInfo.Key) + "_" +
                                   DateTime.Now.ToString("yyyyMMdd_HHss");
            }

            fileDownloadName += "." + ext;

            if (download)
            {
                return(new FileContentResult(renderedBytes, "application/octet-stream")
                {
                    FileDownloadName = fileDownloadName
                });
            }

            var cd = new ContentDisposition
            {
                Inline   = true,
                FileName = fileDownloadName
            };

            Response.AddHeader("Content-Disposition", cd.ToString());
            return(File(renderedBytes, UploadHelper.GetMimeType(fileDownloadName)));
        }