Example #1
0
        public JsonResult SetDepartment(DeptModel SearchDept)
        {
            try
            {
                int resultInt = 0;

                if (SearchDept.dept_idx == null)
                {
                    SearchDept.create_us = Convert.ToInt32(Session["USER_IDX"]);
                    resultInt            = (int)Mapper.Instance().Insert("User.insDepartment", SearchDept);
                    SearchDept.dept_idx  = resultInt;
                    LogCtrl.SetLog(SearchDept, eActionType.DataInsert, this.HttpContext, SearchDept.dept_nm);
                }
                else
                {
                    resultInt = Mapper.Instance().Update("User.udtDepartment", SearchDept);
                    LogCtrl.SetLog(SearchDept, eActionType.DataUpdate, this.HttpContext, SearchDept.dept_nm);
                }

                return(Json(resultInt));
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("ERROR : 부서저장"), ex);
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #2
0
        public JsonResult SetCommCode(CommLibraryModel commcode)
        {
            try
            {
                int resultInt = 0;

                if (commcode.idx == null)
                {
                    commcode.create_us = Convert.ToInt32(Session["USER_IDX"]);

                    resultInt    = (int)Mapper.Instance().Insert("Common.insCommCode", commcode);
                    commcode.idx = resultInt;
                    LogCtrl.SetLog(commcode, eActionType.DataInsert, this.HttpContext, commcode.kor_nm);
                }
                else
                {
                    resultInt = Mapper.Instance().Update("Common.udtCommCode", commcode);
                    LogCtrl.SetLog(commcode, eActionType.DataUpdate, this.HttpContext, commcode.kor_nm);
                }

                return(Json(resultInt));
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("ERROR : 공통코드 저장"), ex);
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #3
0
        public ActionResult RecvView(int?dist_idx)
        {
            if (dist_idx == null)
            {
                return(RedirectToAction("ErrorView", "Error", Resources.Resource.res0270 /*잘못된 페이지를 호출하셨습니다*/));
            }

            var distModel = Mapper.Instance().QueryForObject <DistMasterModel>("Recv.selReciverDistInfo", new DistMasterModel {
                dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"])
            });
            var distEoModel = Mapper.Instance().QueryForObject <DistEoModel>("DIST.selDistEo", new DistEoModel {
                dist_idx = dist_idx
            });
            var distRecvFile = Mapper.Instance().QueryForList <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel {
                dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"]), use_fl = "Y"
            });
            var distRecieverInfo = Mapper.Instance().QueryForObject <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel {
                dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"])
            });

            var eoBom = Mapper.Instance().QueryForList <ItfBomInfo>("Part.selPartBom", new ItfBomInfo {
                eo_idx = distModel.eo_idx
            });

            ViewBag.distModel        = distModel;
            ViewBag.distEoModel      = distEoModel;
            ViewBag.distRecvFile     = distRecvFile;
            ViewBag.eoBomList        = eoBom;
            ViewBag.distRecieverInfo = distRecieverInfo;
            LogCtrl.SetLog(distModel, eActionType.RecvView, this.HttpContext, distModel.dist_title);

            return(View());
        }
Example #4
0
        public JsonResult SetVender(VendModel argModel)
        {
            try
            {
                int resultInt = 0;

                if (argModel.vend_idx == null)
                {
                    argModel.create_us = Convert.ToInt32(Session["USER_IDX"]);

                    resultInt         = (int)Mapper.Instance().Insert("User.insVender", argModel);
                    argModel.vend_idx = resultInt;
                    LogCtrl.SetLog(argModel, eActionType.DataInsert, this.HttpContext, argModel.vend_nm);
                }
                else
                {
                    resultInt = Mapper.Instance().Update("User.udtVender", argModel);
                    LogCtrl.SetLog(argModel, eActionType.DataUpdate, this.HttpContext, argModel.vend_nm);
                }

                return(Json(resultInt));
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("ERROR : 협력사 저장"), ex);
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #5
0
        public JsonResult SetDistFinish(DistMasterModel distModel)
        {
            try
            {
                if (distModel.dist_idx == null)
                {
                    throw new Exception(Resources.Resource.res0219);                              /*잘못된 호출입니다*/
                }

                distModel.dist_st = "DF";

                Mapper.Instance().Update("DIST.udtDistMaster", distModel);

                Mapper.Instance().Update("DIST.udtDistReceiverStatus", new DistReceiverModel {
                    dist_idx = distModel.dist_idx, recv_dist_st = "DF"
                });

                DistMasterModel distMaster = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel {
                    dist_idx = distModel.dist_idx
                });

                LogCtrl.SetLog(distModel, eActionType.CompulsionExpire, this.HttpContext, distMaster.dist_title);

                return(Json("1"));
            }
            catch (Exception ex)
            {
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #6
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"));
        }
Example #7
0
        public JsonResult SetDistEoInfo(DistEoModel distEo)
        {
            try
            {
                bool isNew = distEo.dist_idx == null ? true : false;
                Mapper.Instance().BeginTransaction();
                // 신규
                if (isNew)
                {
                    distEo.dist_idx = SetDistMaster(new DistMasterModel()
                    {
                        eo_fl = "Y", dist_st = "CR", create_us = Convert.ToInt32(Session["USER_IDX"])
                    });
                    Mapper.Instance().Insert("DIST.insDistEo", distEo);
                }
                else
                {
                    DistEoModel compareEo = Mapper.Instance().QueryForObject <DistEoModel>("DIST.selDistEo", new DistEoModel()
                    {
                        dist_idx = distEo.dist_idx
                    });

                    // 기존 EO에 속한 파일이 있을 경우 지워버린다.
                    if (compareEo != null)
                    {
                        Mapper.Instance().Delete("DIST.delDistRecvEoFile", new DistRecvFileModel {
                            dist_idx = distEo.dist_idx, eo_idx = compareEo.eo_idx
                        });
                        Mapper.Instance().Update("DIST.udtDistEo", distEo);
                    }
                    else
                    {
                        Mapper.Instance().Insert("DIST.insDistEo", distEo);
                    }

                    SetUdtDistMaster(new DistMasterModel {
                        dist_idx = distEo.dist_idx
                    });
                }

                SetRecieverLinkFile(distEo.dist_idx);

                DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel()
                {
                    dist_idx = distEo.dist_idx
                });

                LogCtrl.SetLog(distEo, eActionType.DistEoSave, this.HttpContext, dist.dist_title);
                Mapper.Instance().CommitTransaction();
                return(Json(distEo.dist_idx));
            }
            catch (Exception ex)
            {
                Mapper.Instance().RollBackTransaction();
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #8
0
        public int SetDistMaster(DistMasterModel distMaster)
        {
            int distIDX = (int)Mapper.Instance().Insert("DIST.insDistMaster", distMaster);

            LogCtrl.SetLog(new DistMasterModel {
                dist_idx = distIDX
            }, eActionType.DistInsert, this.HttpContext, distMaster.dist_title);
            return(distIDX);
        }
Example #9
0
        public ActionResult BbsFileDownload(int?bbs_file_idx) //11
        {
            System.IO.Stream fStream      = null;
            string           fileOrgName  = string.Empty;
            string           fileConvName = string.Empty;
            string           filePath     = string.Empty;


            BbsFileModel bbsfile = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel {
                bbs_file_idx = bbs_file_idx
            });

            if (bbsfile == null)
            {
                throw new Exception(Resources.Resource.res0320);//잘못된 파일을 호출하셨습니다.
            }
            //foreach () { }
            fileOrgName  = bbsfile.file_org_nm;
            fileConvName = bbsfile.file_conv_nm;
            filePath     = System.Configuration.ConfigurationManager.AppSettings["BbsFilePath"].ToString() + "\\" + bbsfile.bbs_idx;


            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);
            }

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

            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));
            }
        }
Example #10
0
        public ActionResult DistPdfViewer(int?dist_file_idx)
        {
            string fileOrgName  = string.Empty;
            string fileConvName = string.Empty;
            string filePath     = string.Empty;


            DistRecvFileModel distFile = Mapper.Instance().QueryForObject <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel {
                dist_file_idx = dist_file_idx, recv_us = Convert.ToInt32(Session["USER_IDX"])
            });

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

            if (distFile.recv_dist_st == "DF")
            {
                throw new Exception(Resources.Resource.res0297);//배포가 만료된 파일입니다.
            }

            fileOrgName  = distFile.file_org_nm;
            fileConvName = distFile.file_conv_nm;

            if (distFile.is_itf == "N")
            {
                filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + distFile.dist_idx;
            }
            else
            {
                filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + distFile.part_no;
            }

            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));

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

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

            ViewBag.Massage  = null;
            ViewBag.FileName = fPath;
            return(View("PdfViewer"));
        }
Example #11
0
        public JsonResult DelDepartment(int deptIdx)
        {
            try
            {
                int resultInt = 0;

                UserModel SearchUser = new UserModel();
                SearchUser.isVender        = "N";
                SearchUser.isLowDepartment = "Y";
                SearchUser.us_group        = deptIdx;
                var userList = Mapper.Instance().QueryForList <UserModel>("User.selUser", SearchUser);

                if (userList.Count() > 0)
                {
                    throw new Exception(Resources.Resource.res0309);//사용자가 있는 부서는 삭제할수 없습니다.
                }

                DeptModel dept = Mapper.Instance().QueryForObject <DeptModel>("User.selDepartment", new DeptModel {
                    dept_idx = deptIdx
                });

                var SonDepartment = Mapper.Instance().QueryForList <Hashtable>("User.selTargetSonDept", deptIdx);

                if (SonDepartment.Count() > 1)
                {
                    throw new Exception(Resources.Resource.res0326);//하위 부서가 존재하여 삭제 할 수 없습니다.
                }

                resultInt = (int)Mapper.Instance().Delete("User.delDepartment", deptIdx);

                if (resultInt < 1)
                {
                    throw new Exception(Resources.Resource.res0310);//삭제되지 않았습니다. 관리자에게 문의해주세요.
                }

                LogCtrl.SetLog(new DeptModel {
                    dept_idx = deptIdx
                }, eActionType.DataDelete, this.HttpContext, dept.dept_nm);
                return(Json(resultInt));
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("ERROR : 부서저장"), ex);
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #12
0
        public ActionResult BoardModify(int?bbs_idx)
        {
            var bbsContentsModel = Mapper.Instance().QueryForObject <BbsContentsModel>("Bbs.selBbsContent", new BbsContentsModel {
                bbs_idx = bbs_idx
            });
            var bbsFileModel = Mapper.Instance().QueryForList <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel {
                bbs_idx = bbs_idx
            });

            ViewBag.bbsContentsModel = bbsContentsModel;
            ViewBag.bbsFileModel     = bbsFileModel;

            LogCtrl.SetLog(bbsContentsModel, eActionType.DataSelect, this.HttpContext);

            return(View());
        }
Example #13
0
        public JsonResult SetDelDistReceiver(List <DistReceiverModel> receiverModel)
        {
            try
            {
                Mapper.Instance().BeginTransaction();
                DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel()
                {
                    dist_idx = receiverModel[0].dist_idx
                });

                SetUdtDistMaster(new DistMasterModel {
                    dist_idx = receiverModel[0].dist_idx
                });
                foreach (DistReceiverModel distRecv in receiverModel)
                {
                    // 1. 수신자에 속한 배포 파일 삭제
                    Mapper.Instance().Delete("DIST.delDistRecvFile", new DistRecvFileModel {
                        dist_idx = distRecv.dist_idx, recv_idx = distRecv.recv_idx
                    });

                    // 2. 수신자 삭제
                    int i = (int)Mapper.Instance().Delete("DIST.delDistReceiver", new DistReceiverModel {
                        dist_idx = distRecv.dist_idx, recv_idx = distRecv.recv_idx
                    });

                    LogCtrl.SetLog(distRecv, eActionType.DistReceiverDelete, this.HttpContext, dist.dist_title);
                    if (i == 0)
                    {
                        throw new Exception(Resources.Resource.res0312);//수신자 삭제가 실패했습니다
                    }
                }

                Mapper.Instance().CommitTransaction();

                return(Json(1));
            }
            catch (Exception ex)
            {
                Mapper.Instance().RollBackTransaction();
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #14
0
        public ActionResult BoardView(int?bbs_idx)
        {//쓰고-view-list로
            //내용
            var bbsContentsModel = Mapper.Instance().QueryForObject <BbsContentsModel>("Bbs.selBbsContent", new BbsContentsModel {
                bbs_idx = bbs_idx
            });
            //현재처럼 idx를 각각 가져오면 단일건을 가져오는 것. bbs_idx로 조회해서 가져와야함.
            //댓글
            //var bbsReplyModel = Mapper.Instance().QueryForList<BbsReplyModel>("Bbs.selBbsReply", new BbsReplyModel { bbs_idx = bbs_idx });
            //파일
            var bbsFileModel = Mapper.Instance().QueryForList <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel {
                bbs_idx = bbs_idx
            });

            ViewBag.bbsContentsModel = bbsContentsModel;
            ViewBag.bbsFileModel     = bbsFileModel;
            //ViewBag.bbsReplyModel = bbsReplyModel;ajax로 보내야함.

            LogCtrl.SetLog(bbsContentsModel, eActionType.DataSelect, this.HttpContext);

            return(View());
        }
Example #15
0
        public ActionResult BoardModify(int?bbs_idx)
        {   //카테고리
            var getBbsCategory = Mapper.Instance().QueryForList <CommLibraryModel>("Common.selCommCode", new CommLibraryModel {
                parent_code = "Category", use_fl = "Y"
            });

            ViewBag.BbsCategory = getBbsCategory;
            //내용
            var bbsContentsModel = Mapper.Instance().QueryForObject <BbsContentsModel>("Bbs.selBbsContent", new BbsContentsModel {
                bbs_idx = bbs_idx
            });
            //파일
            var bbsFileModel = Mapper.Instance().QueryForList <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel {
                bbs_idx = bbs_idx
            });

            ViewBag.bbsContentsModel = bbsContentsModel;
            ViewBag.bbsFileModel     = bbsFileModel;

            LogCtrl.SetLog(bbsContentsModel, eActionType.DataSelect, this.HttpContext);
            return(View());
        }
Example #16
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));
            }
        }
Example #17
0
        public ActionResult DistTempFileUpload(int?dist_idx)
        {
            try
            {
                if (Request.Files == null)
                {
                    throw new Exception(Resources.Resource.res0221);                         /*업로드할 파일이 존재하지 않습니다*/
                }

                try
                {
                    Mapper.Instance().BeginTransaction();

                    if (dist_idx == null)
                    {
                        dist_idx = SetDistMaster(new DistMasterModel()
                        {
                            eo_fl = "Y", dist_st = "CR", create_us = Convert.ToInt32(Session["USER_IDX"])
                        });
                    }

                    foreach (string f in Request.Files)
                    {
                        HttpPostedFileBase file = Request.Files[f];

                        DistTempFileModel distTempFileList = Mapper.Instance().QueryForObject <DistTempFileModel>("DIST.selDistTempFile", new DistTempFileModel()
                        {
                            dist_idx = dist_idx, file_org_nm = file.FileName
                        });

                        if (distTempFileList != null)
                        {
                            throw new Exception(Resources.Resource.res0327);//한 배포 건 안에 동일한 이름의 파일을 업로드 할 수 없습니다
                        }

                        string fileOrgName   = file.FileName;
                        string fileExtension = Path.GetExtension(file.FileName);
                        string fileName      = Path.GetFileNameWithoutExtension(file.FileName);
                        string fileConvNm    = AESEncrypt.AESEncrypt256(fileName, dist_idx.ToString());

                        int?tempFileIdx = (int)Mapper.Instance().Insert("DIST.insDistTempFile", new DistTempFileModel {
                            dist_idx = dist_idx, file_org_nm = file.FileName, file_conv_nm = fileConvNm + fileExtension
                        });

                        string valutPath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString();
                        CommonUtil.FileSave(valutPath + "\\" + dist_idx, file, fileConvNm + fileExtension);

                        LogCtrl.SetLog(new DistTempFileModel {
                            dist_idx = dist_idx, temp_file_idx = tempFileIdx
                        }, eActionType.DistLocalFileSave, this.HttpContext, fileOrgName);
                    }

                    SetRecieverLinkFile(dist_idx);
                    Mapper.Instance().CommitTransaction();
                    return(Json(dist_idx));
                }
                catch (Exception ex)
                {
                    Mapper.Instance().RollBackTransaction();
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #18
0
        public JsonResult StartDist(DistMasterModel distModel, List <DistReceiverModel> recvList)
        {
            try
            {
                Mapper.Instance().BeginTransaction();

                if (recvList == null)
                {
                    throw new Exception(Resources.Resource.res0311);// 선택 된 수신자가 없습니다
                }

                var distFileList = Mapper.Instance().QueryForList <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel {
                    dist_idx = distModel.dist_idx, use_fl = "Y"
                });

                if (distFileList.Count == 0)
                {
                    throw new Exception(Resources.Resource.res0296);//"배포 할 파일이 없습니다."
                }

                TimeSpan TS = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")) - DateTime.Parse(distModel.finish_date);

                int diffDay = TS.Days;

                if (diffDay >= 0)
                {
                    throw new Exception(Resources.Resource.res0294);//만료일은 금일 보다 이후여야 합니다
                }

                //selConfig
                //DIST	EXPIRE_TERM	10
                //DIST DISCARD_TERM    20
                //
                ConfigModel disuseTerm = Mapper.Instance().QueryForObject <ConfigModel>("Common.selConfig", new ConfigModel {
                    comm_section = "DIST", comm_code = "DISCARD_TERM"
                });

                DateTime now = DateTime.Now;

                distModel.dist_st = "DS";
                distModel.dist_dt = now;

                SetUdtDistMaster(distModel);

                foreach (DistReceiverModel recv in recvList)
                {
                    recv.recv_finish_dt = distModel.finish_dt;
                    recv.recv_dist_st   = "DS";

                    Mapper.Instance().Update("DIST.udtDistReceiver", recv);
                }

                DistMasterModel distMaster = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel {
                    dist_idx = distModel.dist_idx
                });
                UserModel distUsr = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel {
                    us_idx = distMaster.create_us
                });
                List <DistReceiverModel> distRecvList = Mapper.Instance().QueryForList <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel {
                    dist_idx = distModel.dist_idx
                }).Cast <DistReceiverModel>().ToList();

                // Transaction 이 걸려 있어 임시로 데이터 대입
                distMaster.dist_dt    = now;
                distMaster.finish_dt  = distModel.finish_dt;
                distMaster.dist_title = distModel.dist_title;
                distMaster.dist_msg   = distModel.dist_msg;

                DistMail smtpMail = new DistMail(Request);

                smtpMail.SetMailInfo(distMaster, distUsr, distRecvList);
                smtpMail.SendMail();

                LogCtrl.SetLog(distModel, eActionType.DistStart, this.HttpContext, distModel.dist_title);
                Mapper.Instance().CommitTransaction();
                return(Json(1));
            }
            catch (Exception ex)
            {
                Mapper.Instance().RollBackTransaction();
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #19
0
        public JsonResult SetVendUserEdit(UserModel user)
        {
            try
            {
                if (user.login_id.Trim() == "")
                {
                    throw new Exception(Resources.Resource.res0157);//로그인 아이디를 입력해주세요
                }

                if (user.us_nm.Trim() == "")
                {
                    throw new Exception(Resources.Resource.res0168);//사용자 이름을 입력해주세요.
                }

                if (user.us_email.Trim() == "")
                {
                    throw new Exception(Resources.Resource.res0169);//사용자 이메일을 입력해주세요
                }

                UserModel chkUser = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel {
                    login_id = user.login_id.Trim()
                });

                if (chkUser != null && chkUser.us_idx != user.us_idx)
                {
                    throw new Exception(Resources.Resource.res0291);//"동일한 로그인 계정이 존재합니다. 로그인 아이디를 확인해주세요."
                }

                UserModel chkUserEmail = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel {
                    us_email = user.us_email.Trim()
                });

                if (chkUserEmail != null && chkUser.us_idx != user.us_idx)
                {
                    throw new Exception(Resources.Resource.res0292);//"동일한 메일 계정이 존재합니다. 메일을 확인해주세요."
                }

                user.us_role = 10;

                int resultInt = 0;

                user.login_id = user.login_id.Trim();

                if (user.us_idx == null)
                {
                    user.create_us = Convert.ToInt32(Session["USER_IDX"]);
                    user.login_pw  = AESEncrypt.AESEncrypt256(CommonUtil.DefaultPassword(), user.login_id.Trim());

                    resultInt   = (int)Mapper.Instance().Insert("User.insUser", user);
                    user.us_idx = resultInt;
                    LogCtrl.SetLog(user, eActionType.DataInsert, this.HttpContext, user.us_nm);
                }
                else
                {
                    resultInt = Mapper.Instance().Update("User.udtUser", user);
                    LogCtrl.SetLog(user, eActionType.DataUpdate, this.HttpContext, user.us_nm);
                }

                return(Json(resultInt));
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("ERROR : 사용자 저장"), ex);
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #20
0
        public JsonResult SetDistReceiver(int?dist_idx, List <DistReceiverModel> receiverModel)
        {
            try
            {
                Mapper.Instance().BeginTransaction();
                DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel()
                {
                    dist_idx = dist_idx
                });

                if (dist_idx == null)
                {
                    dist_idx = SetDistMaster(new DistMasterModel()
                    {
                        eo_fl = "Y", dist_st = "CR", create_us = Convert.ToInt32(Session["USER_IDX"])
                    });
                }
                else
                {
                    SetUdtDistMaster(new DistMasterModel {
                        dist_idx = dist_idx
                    });
                }

                var prevRecvList = Mapper.Instance().QueryForList <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel {
                    dist_idx = dist_idx
                });

                foreach (DistReceiverModel recv in receiverModel)
                {
                    var chkRecv = from rcv in prevRecvList
                                  where rcv.recv_us == recv.recv_us
                                  select rcv;

                    if (chkRecv.Count() > 0)
                    {
                        continue;
                    }
                    else
                    {
                        recv.dist_idx = dist_idx;
                        Mapper.Instance().Insert("DIST.insDistReceiver", recv);

                        LogCtrl.SetLog(recv, eActionType.DistReceiverSave, this.HttpContext, dist.dist_title);
                    }
                }

                SetRecieverLinkFile(dist_idx);

                Mapper.Instance().CommitTransaction();

                return(Json(dist_idx));
            }
            catch (Exception ex)
            {
                Mapper.Instance().RollBackTransaction();
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Example #21
0
        /// <summary>
        /// 수신자가 다운로드 받는 함수
        /// </summary>
        /// <param name="dist_file_idx"></param>
        /// <returns></returns>
        public ActionResult DistFileDownload(int?dist_file_idx)
        {
            System.IO.Stream fStream      = null;
            string           fileOrgName  = string.Empty;
            string           fileConvName = string.Empty;
            string           filePath     = string.Empty;


            DistRecvFileModel distFile = Mapper.Instance().QueryForObject <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel {
                dist_file_idx = dist_file_idx, recv_us = Convert.ToInt32(Session["USER_IDX"])
            });
            DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel {
                dist_idx = distFile.dist_idx
            });

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

            if (dist.dist_st == "CR")
            {
                throw new Exception("배포가 진행되지 않는 파일입니다.");
            }

            if (dist.dist_st == "DF" && distFile.recv_dist_st == "DF")
            {
                throw new Exception(Resources.Resource.res0297);//배포가 만료된 파일입니다.
            }

            fileOrgName  = distFile.file_org_nm;
            fileConvName = distFile.file_conv_nm;

            if (distFile.is_itf == "N")
            {
                filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + distFile.dist_idx;
            }
            else
            {
                filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + distFile.part_no;
            }

            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);
            }

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

            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));
            }
        }
Example #22
0
 public int SetUdtDistMaster(DistMasterModel distMaster)
 {
     LogCtrl.SetLog(distMaster, eActionType.DistSave, this.HttpContext, distMaster.dist_title);
     return((int)Mapper.Instance().Update("DIST.udtDistMaster", distMaster));
 }
Example #23
0
        public ActionResult DistAllFileDownload(int?dist_idx)
        {
            if (dist_idx == null)
            {
                throw new Exception(Resources.Resource.res0598);//잘못된 호출방식입니다.
            }

            DistMasterModel dist = Mapper.Instance().QueryForObject <DistMasterModel>("DIST.selDistMaster", new DistMasterModel {
                dist_idx = dist_idx
            });

            DistReceiverModel recv = Mapper.Instance().QueryForObject <DistReceiverModel>("DIST.selDistReceiver", new DistReceiverModel {
                dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"])
            });

            if (dist.dist_st == "CR")
            {
                throw new Exception(Resources.Resource.res0328);//"해당 배포 파일은 다운로드 할 수 없습니다."
            }

            if (dist.dist_st == "DF" && recv.recv_dist_st == "DF")
            {
                throw new Exception(Resources.Resource.res0297);//배포가 만료된 파일입니다.
            }

            var distFile = Mapper.Instance().QueryForList <DistRecvFileModel>("DIST.selDistRecvFile", new DistRecvFileModel {
                dist_idx = dist_idx, recv_us = Convert.ToInt32(Session["USER_IDX"])
            });

            List <string[]> files = new List <string[]>();

            foreach (DistRecvFileModel recvFile in distFile)
            {
                //System.IO.Stream fStream = null;

                string fileOrgName  = recvFile.file_org_nm;
                string fileConvName = recvFile.file_conv_nm;

                string filePath = string.Empty;

                if (recvFile.is_itf == "N")
                {
                    filePath = System.Configuration.ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "\\" + recvFile.dist_idx;
                }
                else
                {
                    filePath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString() + "\\" + recvFile.part_no;
                }

                string downloadFileFullPath = string.Empty;

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

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

                files.Add(new string[] { downloadFileFullPath, recvFile.file_org_nm });

                LogCtrl.SetLog(recvFile, eActionType.FileDown, this.HttpContext, "전체 다운로드 : " + dist.dist_title);
            }

            using (var memoryStream = new MemoryStream())
            {
                using (ZipArchive ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        if (System.IO.File.Exists(files[i][0].ToString()))
                        {
                            ziparchive.CreateEntryFromFile(files[i][0].ToString(), files[i][1].ToString());
                        }
                    }
                }
                return(File(memoryStream.ToArray(), "application/zip", HttpUtility.UrlEncode(dist.dist_title + ".zip", System.Text.Encoding.UTF8)));
            }
        }