コード例 #1
0
        public ActionResult PdfViewer(int?link_file_idx, string is_itf)
        {
            string fileOrgName  = string.Empty;
            string fileConvName = string.Empty;
            string filePath     = string.Empty;

            if (is_itf == "N")
            {
                DistTempFileModel fileInfo = Mapper.Instance().QueryForObject <DistTempFileModel>("DIST.selDistTempFile", new DistTempFileModel {
                    temp_file_idx = link_file_idx
                });

                if (fileInfo == null)
                {
                    throw new Exception(Resources.Resource.res0320);//잘못된 파일을 호출하셨습니다.
                }

                fileOrgName  = fileInfo.file_org_nm;
                fileConvName = fileInfo.file_conv_nm;

                filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + fileInfo.dist_idx;

                LogCtrl.SetLog(fileInfo, eActionType.FileView, this.HttpContext, fileInfo.file_org_nm);
            }
            else
            {
                ItfFileInfo fileInfo = Mapper.Instance().QueryForObject <ItfFileInfo>("ITF.selItfFIleInfo", new ItfFileInfo {
                    file_idx = link_file_idx
                });

                if (fileInfo == null)
                {
                    throw new Exception(Resources.Resource.res0320);//잘못된 파일을 호출하셨습니다.
                }

                fileOrgName  = fileInfo.file_org_nm;
                fileConvName = fileInfo.file_conv_nm;

                filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + fileInfo.part_no;

                LogCtrl.SetLog(fileInfo, eActionType.FileView, this.HttpContext, fileInfo.file_org_nm);
            }

            if (!CommonUtil.IsFile(filePath, fileConvName))
            {
                ViewBag.Massage = @Resources.Resource.res0366; // 파일이 없습니다.
                return(View());
            }

            PdfWatermark watermark     = new PdfWatermark();
            string       watermarkFile = watermark.SetWaterMarkPdf(filePath, fileConvName, Convert.ToInt32(Session["USER_IDX"]), CommonUtil.GetRemoteIP(this.Request));

            string fPath = System.Configuration.ConfigurationManager.AppSettings["ViewTempFileUrl"].ToString() + "/" + Path.GetFileName(watermarkFile);

            ViewBag.Massage  = null;
            ViewBag.FileName = fPath;
            return(View());
            //return View("PdfFileViewer" + (System.Web.HttpUtility.UrlEncode(fPath, System.Text.Encoding.GetEncoding("utf-8"))).Replace("+", "%20"));
        }
コード例 #2
0
        /// <summary>
        /// 일반 사용자가 내부 파일 받을 때 쓰는 함수
        /// </summary>
        /// <param name="link_file_idx"></param>
        /// <param name="is_itf"></param>
        /// <returns></returns>
        public ActionResult FileDownload(int?link_file_idx, string is_itf)
        {
            System.IO.Stream fStream      = null;
            string           fileOrgName  = string.Empty;
            string           fileConvName = string.Empty;
            string           filePath     = string.Empty;

            if (is_itf == "N")
            {
                DistTempFileModel fileInfo = Mapper.Instance().QueryForObject <DistTempFileModel>("DIST.selDistTempFile", new DistTempFileModel {
                    temp_file_idx = link_file_idx
                });

                if (fileInfo == null)
                {
                    throw new Exception(Resources.Resource.res0320);//잘못된 파일을 호출하셨습니다.
                }

                fileOrgName  = fileInfo.file_org_nm;
                fileConvName = fileInfo.file_conv_nm;

                filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + fileInfo.dist_idx;

                LogCtrl.SetLog(fileInfo, eActionType.FileDown, this.HttpContext, fileInfo.file_org_nm);
            }
            else
            {
                ItfFileInfo fileInfo = Mapper.Instance().QueryForObject <ItfFileInfo>("ITF.selItfFIleInfo", new ItfFileInfo {
                    file_idx = link_file_idx
                });

                if (fileInfo == null)
                {
                    throw new Exception(Resources.Resource.res0320);//잘못된 파일을 호출하셨습니다.
                }

                fileOrgName  = fileInfo.file_org_nm;
                fileConvName = fileInfo.file_conv_nm;

                filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + fileInfo.part_no;

                LogCtrl.SetLog(fileInfo, eActionType.FileDown, this.HttpContext, fileInfo.file_org_nm);
            }

            if (!CommonUtil.IsFile(filePath, fileConvName))
            {
                ViewBag.Massage = Resources.Resource.res0366; // 파일이 없습니다.
                return(View());
            }

            if (fileConvName.ToLower().Contains(".pdf"))
            {
                PdfWatermark watermark     = new PdfWatermark();
                string       watermarkFile = watermark.SetWaterMarkPdf(filePath, fileConvName, Convert.ToInt32(Session["USER_IDX"]), CommonUtil.GetRemoteIP(this.Request));
                fStream = CommonUtil.FileStream(watermarkFile);
            }
            else
            {
                fStream = CommonUtil.FileStream(filePath, fileConvName);
            }

            if (Request.Browser.Browser == "IE" || Request.Browser.Browser == "InternetExplorer")
            {
                return(File(fStream, MediaTypeNames.Application.Octet, HttpUtility.UrlEncode(fileOrgName, System.Text.Encoding.UTF8)));
            }
            else
            {
                return(File(fStream, MediaTypeNames.Application.Octet, fileOrgName));
            }
        }