public JsonResult SetResetPassword(int?us_idx) { try { if (us_idx == null) { throw new Exception(Resources.Resource.res0219);//잘못된 호출입니다. } UserModel chkUser = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel { us_idx = us_idx }); Mapper.Instance().Update("User.udtUser", new UserModel { us_idx = us_idx, login_pw = AESEncrypt.AESEncrypt256(CommonUtil.DefaultPassword(), chkUser.login_id.Trim()) }); return(Json(1)); } catch (Exception ex) { Mapper.Instance().RollBackTransaction(); logger.Error(string.Format("ERROR : 시스템 설정 저장"), ex); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
public JsonResult SetChangePassword(string nowPassword, string changePassword, string changeChkPassword) { try { UserModel chkUser = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel { us_idx = Convert.ToInt32(Session["USER_IDX"]) }); if (chkUser.login_pw != AESEncrypt.AESEncrypt256(nowPassword, Session["LOGIN_ID"].ToString())) { throw new Exception(Resources.Resource.res0318);//입력하신 비밀번호가 일치하지않습니다 } if (changePassword == "" || changeChkPassword == "") { throw new Exception(Resources.Resource.res0299);//변경될 비밀번호가 잘못되었습니다. } if (changePassword != changeChkPassword) { throw new Exception(Resources.Resource.res0317);//입력된 두개의 비밀번호가 다릅니다. } // 만약 제약조건 있을경우 여기서 해결한다. Mapper.Instance().Update("User.udtUser", new UserModel { us_idx = Convert.ToInt32(Session["USER_IDX"]), login_pw = AESEncrypt.AESEncrypt256(changePassword, Session["LOGIN_ID"].ToString()) }); return(Json(1)); } catch (Exception ex) { logger.Error(string.Format("ERROR : 시스템 설정 저장"), ex); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
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() })); } }
public ActionResult TryLogin(UserModel loginInfo) { LoginHistoryModel loginHis = new LoginHistoryModel(); try { /* * N 잘못된 ID * P 잘못된 PW * O OPT 발행 * X 잘못된 OPT 입력 * S 정상 로그인 */ string tryID = loginInfo.login_id.Trim(); string tryPW = AESEncrypt.AESEncrypt256(loginInfo.login_pw, tryID); loginHis.try_id = tryID; loginHis.try_pw = tryPW; loginHis.try_ip = CommonUtil.GetRemoteIP(this.Request); loginHis.session_id = Session.SessionID; if (tryID == "") { loginHis.login_st = "N"; throw new Exception("아이디가 입력되지 않았습니다."); } if (loginInfo.login_pw.Trim() == "") { loginHis.login_st = "P"; throw new Exception("비밀번호가 입력되지 않았습니다."); } UserModel user = Mapper.Instance().QueryForObject <UserModel>("User.selUser", loginInfo); if (user == null || user.us_idx == null) { loginHis.login_st = "N"; throw new Exception("잘못된 접속 정보입니다."); } if (user.login_pw != tryPW) { loginHis.login_st = "P"; throw new Exception("잘못된 접속 정보입니다."); } loginHis.login_us = user.us_idx; if (user.use_fl != "Y") { loginHis.login_st = "A"; throw new Exception("잘못된 접속 정보입니다."); } loginHis.login_st = "S"; Session["USER_IDX"] = user.us_idx; Session["LOGIN_ID"] = user.login_id; Session["USER_NM"] = user.us_nm; Session["USER_POS"] = user.us_pos; Session["USER_POS_NM"] = user.us_pos_nm; Session["USER_GROUP_IDX"] = user.us_group; Session["USER_GROUP_NM"] = user.us_group_nm; Session["USER_ROLE"] = user.us_role; Session["USER_ROLE_NM"] = user.us_role_nm; Session["SESSION_ID"] = Session.SessionID; Session["LANG_CD"] = loginInfo.langCd; var userAuth = Mapper.Instance().QueryForList <AuthModel>("Auth.selAuthInfo", new AuthModel { target_type = "U", target_idx = user.us_idx }); var deptAuth = Mapper.Instance().QueryForList <AuthModel>("Auth.selAuthInfo", new AuthModel { target_type = "D", target_idx = user.us_group }); var roleAuth = Mapper.Instance().QueryForList <AuthModel>("Auth.selAuthInfo", new AuthModel { target_type = "R", target_idx = (int)user.us_role }); Hashtable authList = new Hashtable(); authList.Add("USER", userAuth); authList.Add("DEPT", deptAuth); authList.Add("ROLE", roleAuth); Session["AUTH"] = authList; return(Json(new { result = "Redirect", url = Url.Action("index", "Main") })); } catch (Exception ex) { logger.Error(string.Format("LOGIN ERROR -", loginHis.login_st), ex); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } finally { loginHis.SetLoginHistory(); } }
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() })); } }
public JsonResult SetBoardContents() { try { FormCollection collection = new FormCollection(Request.Unvalidated.Form); BbsContentsModel bbsContents = new BbsContentsModel(); bbsContents.bbs_idx = collection["bbs_idx"] == null ? null : (int?)Convert.ToInt32(collection["bbs_idx"].Split(',')[1]); bbsContents.bbs_title = collection["bbs_title"] == null ? "" : collection["bbs_title"].Trim() == "" ? "" : collection["bbs_title"].Split(',')[1]; bbsContents.bbs_content = collection["bbs_content"] == null ? "" : collection["bbs_content"].Trim() == "" ? "" : collection["bbs_content"].Split(',')[1]; bool isNew = bbsContents.bbs_idx == null ? true : false; if (isNew)//신규작성 { Mapper.Instance().BeginTransaction(); bbsContents.create_us = Convert.ToInt32(Session["USER_IDX"]); bbsContents.bbs_category = collection["bbs_category"] == null ? "" : collection["bbs_category"].Trim() == "" ? "" : collection["bbs_category"].Split(',')[1]; int bbs_idx = (int)Mapper.Instance().Insert("Bbs.insBbsContent", bbsContents); foreach (string f in Request.Files) { //xhr에 있. HttpPostedFileBase file = Request.Files[f]; //파일명으로 찾아서 serlec BbsFileModel BbsFIleList = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel() { bbs_idx = bbs_idx, file_org_nm = file.FileName }); string fileOrgName = file.FileName; string fileExtension = Path.GetExtension(file.FileName); //확장자 string fileName = Path.GetFileNameWithoutExtension(file.FileName); //without확장자 string fileConvNm = AESEncrypt.AESEncrypt256(fileName, bbs_idx.ToString()); string valutPath = System.Configuration.ConfigurationManager.AppSettings["BbsFilePath"].ToString(); int?BbsFIleIdx = (int)Mapper.Instance().Insert("Bbs.insBbsFile", new BbsFileModel { bbs_idx = bbs_idx, file_org_nm = file.FileName, file_conv_nm = fileConvNm + fileExtension }); CommonUtil.FileSave(valutPath + "\\" + bbs_idx, file, fileConvNm + fileExtension);//\은 두개써야함 인식못함. } Mapper.Instance().CommitTransaction(); return(Json(bbsContents)); } else//수정 { Mapper.Instance().BeginTransaction(); bbsContents.bbs_category = collection["bbs_category"] == null ? "" : collection["bbs_category"].Trim() == "" ? "" : collection["bbs_category"].Split(',')[1]; Mapper.Instance().Update("Bbs.udtBbsContent", new BbsContentsModel { bbs_idx = bbsContents.bbs_idx, bbs_category = bbsContents.bbs_category, bbs_title = bbsContents.bbs_title, bbs_content = bbsContents.bbs_content }); var bbsPrevFileList = Mapper.Instance().QueryForList <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel { bbs_idx = bbsContents.bbs_idx }); int prevFileCount = bbsPrevFileList.Count(); foreach (string f in Request.Files) { HttpPostedFileBase file = Request.Files[f]; // 기존에 등록되있으면서 삭제되지 않을 파일 if (file.ContentLength == 0) { continue; } // Insert BbsFileModel BbsFIleList = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel() { bbs_idx = bbsContents.bbs_idx, file_org_nm = file.FileName }); string fileOrgName = file.FileName; string fileExtension = Path.GetExtension(file.FileName); //확장자 string fileName = Path.GetFileNameWithoutExtension(file.FileName); //without확장자 string fileConvNm = AESEncrypt.AESEncrypt256(fileName, bbsContents.bbs_idx.ToString()); string valutPath = System.Configuration.ConfigurationManager.AppSettings["BbsFilePath"].ToString(); int?BbsFIleIdx = (int)Mapper.Instance().Insert("Bbs.insBbsFile", new BbsFileModel { bbs_idx = bbsContents.bbs_idx, file_org_nm = file.FileName, file_conv_nm = fileConvNm + fileExtension }); CommonUtil.FileSave(valutPath + "\\" + bbsContents.bbs_idx, file, fileConvNm + fileExtension);//\은 두개써야함 인식못함. } for (int iCnt = 0; iCnt < prevFileCount; iCnt++) { bool isExist = false; foreach (string f in Request.Files) { if (bbsPrevFileList[iCnt].file_org_nm == Request.Files[f].FileName) { isExist = true; break; } } if (!isExist) { //DELETE //bbsPrevFileList[iCnt]; BbsFileModel BbsDelFIleList = Mapper.Instance().QueryForObject <BbsFileModel>("Bbs.selBbsFile", new BbsFileModel() { bbs_idx = bbsContents.bbs_idx, file_org_nm = bbsPrevFileList[iCnt].file_org_nm }); var fileIDX = BbsDelFIleList.bbs_file_idx; var bbsIDX = BbsDelFIleList.bbs_idx; setFileDelete(fileIDX); } } Mapper.Instance().CommitTransaction(); return(Json(bbsContents.bbs_idx)); } }//try catch (Exception ex) { Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }
// GET: Interface public JsonResult IF_EO_INFO(InterfaceEoInfo itfEo) { List <interfaceResult> itfResult = new List <interfaceResult>(); try { if (itfEo == null) { throw new Exception(Resources.Resource.res0289);//EO 정보가 없는 데이터 입니다. } #region -- 입력된 데이터를 우선 temp table 에 저장한다. 검증을 위해. try { string argsJson = new JavaScriptSerializer().Serialize(itfEo); int jSonIdx = (int)Mapper.Instance().Insert("ITF.insTempJson", new TempItfJson { itf_json = argsJson }); itfEo.json_idx = jSonIdx; logger.Info(string.Format("ITF : IF_EO_INFO\r\nID:{0}\r\n{1}", jSonIdx, argsJson)); //itfEo.temp_idx = temp_idx; //Mapper.Instance().Insert("ITF.insTempEo", itfEo.temp_idx); //foreach (interfacePartInfo partInfo in itfEo.partList) //{ // partInfo.temp_idx = temp_idx; // Mapper.Instance().Insert("ITF.insTempPart", partInfo); // if (partInfo.fileList == null) // { // continue; // } // foreach (ItfFileInfo fileInfo in partInfo.fileList) // { // fileInfo.temp_idx = temp_idx; // Mapper.Instance().Insert("ITF.insTempFile", fileInfo); // } //} } catch (Exception ex) { logger.Error(string.Format("ITF : IF_EO_INFO"), ex); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } #endregion Mapper.Instance().BeginTransaction(); ItfEoInfo chkEo = Mapper.Instance().QueryForObject <ItfEoInfo>("ITF.selItfEoInfo", new ItfEoInfo { eo_no = itfEo.eo_no }); if (chkEo != null) { throw new Exception(Resources.Resource.res0316);//인터페이스가 완료된 EO 데이터입니다. } int eoIdx = (int)Mapper.Instance().Insert("ITF.insItfEoInfo", itfEo); logger.Info(string.Format("ITF : IF_EO_INFO\r\nEO 저장 : {0}", eoIdx)); if (itfEo.partList == null) { throw new Exception(Resources.Resource.res0300);//부품정보가 없는 EO입니다. } foreach (interfacePartInfo partInfo in itfEo.partList) { ItfPartMaster partMaster = partInfo.GetPartMaster(); partMaster.eo_idx = eoIdx; int partIdx = (int)Mapper.Instance().Insert("ITF.insItfPartMaster", partMaster); logger.Info(string.Format("ITF : IF_EO_INFO\r\nPART 저장 : {0} - {1}", partIdx, partMaster.part_no)); partInfo.part_idx = partIdx; var childPartList = from pl in itfEo.partList where pl.parent_part_no == partInfo.part_no && pl.parent_part_rev_no == partInfo.part_rev_no select pl; foreach (interfacePartInfo childPart in childPartList) { childPart.parent_part_idx = partIdx; } int FileCnt = 0; if (partInfo.fileList == null) { logger.Info(string.Format("ITF : IF_EO_INFO\r\nPART FILE 없음 : {0} - {1} -----------------------------", partIdx, partMaster.part_no)); continue; } logger.Info(string.Format("ITF : IF_EO_INFO\r\nPART FILE 갯수 : {0} - {1} {2}개 -----------------------------", partIdx, partMaster.part_no, partInfo.fileList.Count)); foreach (ItfFileInfo fileInfo in partInfo.fileList) { var getFile = Mapper.Instance().QueryForObject <ItfFileInfo>("ITF.selItfFIleInfo", new ItfFileInfo() { file_org_nm = fileInfo.file_org_nm, part_no = partInfo.part_no, part_rev_no = partInfo.part_rev_no }); if (getFile != null) { continue; } string valutPath = System.Configuration.ConfigurationManager.AppSettings["EoFilePath"].ToString(); CommonUtil.FolderCreate(valutPath + "\\" + partInfo.part_no); string fileName = fileInfo.file_org_nm; string fileExtension = Path.GetExtension(fileName); string fileConvName = string.Empty;; fileConvName = AESEncrypt.AESEncrypt256(string.Format("{0}_{1}_{2}", eoIdx, partIdx, ++FileCnt), partInfo.part_no); fileInfo.file_conv_nm = fileConvName + fileExtension; // 파일 경로 작업 끝 int file_idx = (int)Mapper.Instance().Insert("ITF.insItfFileInfo", fileInfo); logger.Info(string.Format("ITF : IF_EO_INFO\r\nPART FILE 저장 : {0} - {1} {2} - {3}", partIdx, partMaster.part_no, file_idx, fileName)); interfaceResult resFileInfo = new interfaceResult(); resFileInfo.file_idx = file_idx; resFileInfo.partNo = partInfo.part_no; resFileInfo.partRevNo = partInfo.part_rev_no; resFileInfo.plmFIleName = fileInfo.file_org_nm; resFileInfo.plmFIleRevNo = fileInfo.file_rev_no; resFileInfo.ftpFilePath = partInfo.part_no; resFileInfo.ftpFileConvName = fileInfo.file_conv_nm; resFileInfo.plmFileOid = fileInfo.file_oid; resFileInfo.file_format = fileInfo.file_format; itfResult.Add(resFileInfo); } logger.Info(string.Format("ITF : IF_EO_INFO\r\nPART FILE 저장 완료 : {0} - {1} {2}개 -----------------------------", partIdx, partMaster.part_no, FileCnt)); } foreach (interfacePartInfo partInfo in itfEo.partList) { ItfBomInfo bomInfo = partInfo.GetBomInfo(); logger.Info(string.Format("ITF : IF_EO_INFO\r\nPART BOM 저장 완료 : [대상]{0} - {1} [부모]{2} - {3} -----------------------------", partInfo.part_no, partInfo.part_rev_no, partInfo.parent_part_no, partInfo.parent_part_rev_no)); Mapper.Instance().Insert("ITF.insItfBom", bomInfo); } Mapper.Instance().CommitTransaction(); //string retJson = new JavaScriptSerializer().Serialize(itfResult); return(Json(itfResult)); } catch (Exception ex) { logger.Error(string.Format("ITF : IF_EO_INFO"), ex); Mapper.Instance().RollBackTransaction(); return(Json(new ResultJsonModel { isError = true, resultMessage = ex.Message, resultDescription = ex.ToString() })); } }