public DTO.ResponseMessage <bool> ChangePassword(DTO.User user, string newPassword) { DTO.ResponseMessage <bool> res = new DTO.ResponseMessage <bool>(); try { string _oldPassword = Utils.EncryptSHA256.Encrypt(user.USER_PASS); string _newPassword = Utils.EncryptSHA256.Encrypt(newPassword); AG_IAS_USERS ent = base.ctx.AG_IAS_USERS.FirstOrDefault(s => s.USER_ID == user.USER_ID); if (ent == null) { res.ErrorMsg = "ไม่พบข้อมูลผู้ใช้งาน"; LoggerFactory.CreateLog().LogError(String.Format("ไม่พบข้อมูลผู้ใช้งาน AG_IAS_USERS->USER_ID :{0}", user.USER_ID)); return(res); } if (ent.USER_PASS != _oldPassword) { res.ErrorMsg = "รหัสผ่านเดิมไม่ถูกต้อง"; return(res); } if (ent.USER_PASS == _newPassword) { res.ErrorMsg = "รหัสผ่านใหม่ต้องไม่ซ้ำรหัสผ่านเดิม"; return(res); } ent.USER_PASS = _newPassword; ent.LASTPASSWORD_CHANGDATE = DateTime.Now; ent.UPDATED_BY = user.USER_ID; ent.UPDATED_DATE = DateTime.Now; int Reset_pass_time = (ent.RESET_TIMES != null) ? Convert.ToInt16(ent.RESET_TIMES) : 0; if (Reset_pass_time == 0) { ent.RESET_TIMES = 1; } else { ent.RESET_TIMES = Reset_pass_time + 1; } base.ctx.SaveChanges(); } catch (Exception ex) { res.ErrorMsg = "พบข้อผิดพลาดในการเปลี่ยนรหัสผ่าน"; LoggerFactory.CreateLog().Fatal(String.Format("AccountService_ChangePassword USER_ID :{0}", user.USER_ID), ex); } return(res); }
public String LinkRecipt(IAS.DAL.Interfaces.IIASPersonEntities ctx) { AG_IAS_USERS user = ctx.AG_IAS_USERS.FirstOrDefault(a => a.USER_ID == CREATE_BY); if (user != null) { String urlroot = ConfigurationManager.AppSettings["WebPublicUrl"].ToString(); String requestdata = CryptoBase64.Encryption(String.Format("{0}||{1}", user.USER_NAME, FilePath)); return(String.Format("{0}UserControl/ViewFile.aspx?PostReceipt={1}", urlroot, requestdata)); } else { return("ไม่พบข้อมูลของเจ้าของใบสั่งจ่าย กรุณาติดต่อผู้ดูแลระบบ"); } }
public void InsertOIC(RemoteFileInfoAddOic request) { // var res = new DTO.ResponseMessage<bool>(); try { var ctx = new IASPersonEntities(); string memberType = ""; if (request.oicTypeCode == "1") { memberType = DTO.RegistrationType.OICAgent.GetEnumValue().ToString(); } if (request.oicTypeCode == "2") { memberType = DTO.RegistrationType.OICFinace.GetEnumValue().ToString(); } if (request.oicTypeCode == "0") { memberType = DTO.RegistrationType.OIC.GetEnumValue().ToString(); } var entExist = ctx.AG_IAS_USERS .Where(w => w.USER_NAME == request.oicUserName) .FirstOrDefault(); if (entExist != null) { // res.ErrorMsg = Resources.errorPersonService_012 + oicUserName + Resources.errorPersonService_013; // return res; } var per = new AG_IAS_PERSONAL_T(); using (MemoryStream ms = new MemoryStream()) { request.FileByteStream.CopyTo(ms); per.IMG_SIGN = ms.ToArray(); } per.ID = OracleDB.GetGenAutoId(); per.EMPLOYEE_NO = request.oicEmpNo; per.PRE_NAME_CODE = request.preNameCode; per.NAMES = request.firstName; per.LASTNAME = request.lastName; per.MEMBER_TYPE = memberType; per.SEX = request.sex; ctx.AG_IAS_PERSONAL_T.AddObject(per); var user = new AG_IAS_USERS(); user.USER_ID = per.ID; user.USER_NAME = request.oicUserName; user.MEMBER_TYPE = memberType; if (request.oicTypeCode == "1") { user.USER_TYPE = user.USER_RIGHT = DTO.RegistrationType.OICAgent.GetEnumValue().ToString(); } if (request.oicTypeCode == "2") { user.USER_TYPE = user.USER_RIGHT = DTO.RegistrationType.OICFinace.GetEnumValue().ToString(); } if (request.oicTypeCode == "0") { user.USER_TYPE = user.USER_RIGHT = DTO.RegistrationType.OIC.GetEnumValue().ToString(); } user.OIC_TYPE = request.oicTypeCode; user.OIC_EMP_NO = request.oicEmpNo; user.CREATED_BY = user.UPDATED_BY = "AGDOI"; user.CREATED_DATE = user.UPDATED_DATE = DateTime.Now; user.IS_ACTIVE = "A"; user.IS_APPROVE = "Y"; ctx.AG_IAS_USERS.AddObject(user); ctx.SaveChanges(); //res.ResultMessage = true; } catch (Exception ex) { //res.ErrorMsg = "กรุณาติดต่อผู้ดูแลระบบ"; LoggerFactory.CreateLog().Fatal("PersonService_InsertOIC", ex); } // return res; }
public DTO.ResponseMessage <bool> ChangePasswordByAdmin(DTO.User user, DTO.UserProfile userProfile) { DTO.ResponseMessage <bool> res = new DTO.ResponseMessage <bool>(); try { AG_IAS_USERS ent = base.ctx.AG_IAS_USERS.FirstOrDefault(s => s.USER_ID == user.USER_ID); if (ent == null) { res.ErrorMsg = "ไม่พบข้อมูลผู้ใช้งาน"; LoggerFactory.CreateLog().LogError(String.Format("ไม่พบข้อมูลผู้ใช้งาน AG_IAS_USERS->USER_ID :{0}", user.USER_ID)); return(res); } if (String.IsNullOrEmpty(user.USER_PASS)) { res.ErrorMsg = "กรุณากรอกรหัสผ่าน"; return(res); } string _newPassword = Utils.EncryptSHA256.Encrypt(user.USER_PASS); ent.USER_PASS = _newPassword; ent.LASTPASSWORD_CHANGDATE = DateTime.Now; ent.UPDATED_BY = userProfile.Id; ent.UPDATED_DATE = DateTime.Now; int Reset_pass_time = (ent.RESET_TIMES != null) ? Convert.ToInt16(ent.RESET_TIMES) : 0; if (Reset_pass_time == 0) { ent.RESET_TIMES = 1; } else { ent.RESET_TIMES = Reset_pass_time + 1; } #region sent mail var person = base.ctx.AG_IAS_PERSONAL_T.FirstOrDefault(s => s.ID == ent.USER_ID); if (!String.IsNullOrEmpty(person.EMAIL)) { string fromMail = ConfigurationManager.AppSettings["EmailOut"].ToString(); string toMail = person.EMAIL; string Subject = "แจ้งเปลี่ยนรหัสผ่าน"; StringBuilder Body = new StringBuilder(); Body.Append("เนื่องด้วยบัญชีใช้งานของคุณ " + person.NAMES + " " + person.LASTNAME + " ได้ทำการเปลี่ยนรหัสผ่านโดย Admin ใน "); Body.Append(" ระบบช่องทางการบริการตัวแทน/นายหน้าประกันภัยแบบเบ็ดเสร็จ "); Body.Append("<br/>"); Body.Append(" User: "******"<br/>"); Body.Append(" Password: "******" <br/><br/>"); EmailSender.Sending(Body, toMail, Subject).Sent(); } #endregion sent mail base.ctx.SaveChanges(); } catch (Exception ex) { res.ErrorMsg = "พบข้อผิดพลาดในการเปลี่ยนรหัสผ่าน"; LoggerFactory.CreateLog().Fatal(string.Format("AccountService_ChangePasswordByAdmin USER_ID:{0}", user.USER_ID), ex); } return(res); }
public DTO.ResponseMessage <bool> EditMemberTypeAndActive(DTO.AccountDetail ent, DTO.UserProfile userProfile) { DTO.ResponseMessage <Boolean> res = new DTO.ResponseMessage <bool>(); try { string loginfo = string.Empty; var Person = base.ctx.AG_IAS_PERSONAL_T.FirstOrDefault(x => x.ID == ent.ID); var User = base.ctx.AG_IAS_USERS.FirstOrDefault(s => s.USER_ID == ent.ID); if (Person == null || User == null) { res.ErrorMsg = "ไม่พบข้อมูลผู้ใช้งาน"; LoggerFactory.CreateLog().LogError(String.Format("ไม่พบข้อมูลผู้ใช้งาน USER_ID :{0} ในตาราง AG_IAS_PERSONAL_T หรือ AG_IAS_USERS", ent.ID)); return(res); } #region Check from TYPE to TYPE string err = "ไม่สามารถย้ายประเภทผู้ใช้งาน"; switch (Person.MEMBER_TYPE) { case "1": if (ent.MEMBER_TYPE != "1") { res.ErrorMsg = err; return(res); } break; case "2": case "3": case "7": if (ent.MEMBER_TYPE != "2" && ent.MEMBER_TYPE != "3" && ent.MEMBER_TYPE != "7") { res.ErrorMsg = err; return(res); } break; case "4": case "5": case "6": if (ent.MEMBER_TYPE != "5" && ent.MEMBER_TYPE != "6" && ent.MEMBER_TYPE != "4") { res.ErrorMsg = err; return(res); } break; } #endregion Check from TYPE to TYPE /** * ย้าย MEMBER_TYPE จาก (02-บริษัท, 03-สมาคม) ไปเป็น (07-เจ้าหน้าที่สนามสอบ) * ให้ตรวจสอบ (02-บริษัท, 03-สมาคม) ว่ามีการสมัครสอบหรือไม่? * หากมีการสมัครสอบจะไม่สามารถย้ายไปเป็น (07-เจ้าหน้าที่สนามสอบ) */ if ((Person.MEMBER_TYPE == "2" || Person.MEMBER_TYPE == "3") && ent.MEMBER_TYPE == "7") { OracleDB ora = new OracleDB(); string sql = "select count(*) haveCount from AG_APPLICANT_T where ID_CARD_NO = '" + Person.ID_CARD_NO + "' and " + " EXAM_PLACE_CODE in (select EXAM_PLACE_CODE from AG_EXAM_PLACE_R) "; DataTable dt = ora.GetDataTable(sql); if (dt.Rows[0]["haveCount"].ToInt() > 0) { res.ErrorMsg = "ไม่สามารถย้ายประเภทผู้ใช้งาน"; return(res); } } /* * 2-บริษัท, 3-สมาคม, 5-คปภ.การเงิน, 6-คปภ.ตัวแทน, 7-เจ้าหน้าที่สนามสอบ */ if (ent.MEMBER_TYPE == "2" || ent.MEMBER_TYPE == "3" || ent.MEMBER_TYPE == "7") { if (ent.COMP_CODE == Person.COMP_CODE && Person.MEMBER_TYPE == ent.MEMBER_TYPE) { res.ErrorMsg = "ไม่มีการเปลี่ยนแปลงข้อมูล"; return(res); } var Regis = base.ctx.AG_IAS_REGISTRATION_T.FirstOrDefault(s => s.ID == ent.ID); if (Regis == null) { res.ErrorMsg = "ไม่พบข้อมูลผู้ใช้งาน"; return(res); } // ย้ายได้เฉพาะ status = 2-อนุมัติ(สมัคร), 5-อนุมัติ(แก้ไข) if (Person.STATUS != "2" && Person.STATUS != "5" && Person.STATUS != null) { var Status = base.ctx.AG_IAS_STATUS.FirstOrDefault(s => s.STATUS_CODE == Person.STATUS); res.ErrorMsg = "ไม่สามารถย้ายประเภทผู้ใช้งาน เนื่องจากสถานะ " + Status.STATUS_NAME; return(res); } string ID = OracleDB.GetGenAutoId(); #region AG_IAS_PERSONAL_T AG_IAS_PERSONAL_T newPerson = new AG_IAS_PERSONAL_T { ID = ID, //new Data MEMBER_TYPE = ent.MEMBER_TYPE, //new Data ID_CARD_NO = Person.ID_CARD_NO, EMPLOYEE_NO = Person.EMPLOYEE_NO, PRE_NAME_CODE = Person.PRE_NAME_CODE, NAMES = Person.NAMES, LASTNAME = Person.LASTNAME, NATIONALITY = Person.NATIONALITY, BIRTH_DATE = Person.BIRTH_DATE, SEX = Person.SEX, EDUCATION_CODE = Person.EDUCATION_CODE, ADDRESS_1 = Person.ADDRESS_1, ADDRESS_2 = Person.ADDRESS_2, AREA_CODE = Person.AREA_CODE, PROVINCE_CODE = Person.PROVINCE_CODE, ZIP_CODE = Person.ZIP_CODE, TELEPHONE = Person.TELEPHONE, LOCAL_ADDRESS1 = Person.LOCAL_ADDRESS1, LOCAL_ADDRESS2 = Person.LOCAL_ADDRESS2, LOCAL_AREA_CODE = Person.LOCAL_AREA_CODE, LOCAL_PROVINCE_CODE = Person.LOCAL_PROVINCE_CODE, LOCAL_ZIPCODE = Person.LOCAL_ZIPCODE, LOCAL_TELEPHONE = Person.LOCAL_TELEPHONE, EMAIL = Person.EMAIL, STATUS = Person.STATUS, TUMBON_CODE = Person.TUMBON_CODE, LOCAL_TUMBON_CODE = Person.LOCAL_TUMBON_CODE, COMP_CODE = ent.COMP_CODE, //new Data CREATED_BY = userProfile.Id, //new Data CREATED_DATE = DateTime.Now, //new Data UPDATED_BY = userProfile.Id, //new Data UPDATED_DATE = DateTime.Now, //new Data APPROVE_RESULT = Person.APPROVE_RESULT, APPROVED_BY = Person.APPROVED_BY, AGENT_TYPE = Person.AGENT_TYPE, SIGNATUER_IMG = Person.SIGNATUER_IMG, IMG_SIGN = Person.IMG_SIGN }; #endregion #region AG_IAS_USERS AG_IAS_USERS newUser = new AG_IAS_USERS { USER_ID = ID, //new Data USER_NAME = User.USER_NAME, USER_PASS = User.USER_PASS, USER_TYPE = ent.MEMBER_TYPE, //new Data IS_ACTIVE = User.IS_ACTIVE, USER_RIGHT = ent.MEMBER_TYPE, //new Data USER_TERM_ACCEPTED = User.USER_TERM_ACCEPTED, CREATED_BY = userProfile.Id, //new Data CREATED_DATE = DateTime.Now, //new Data UPDATED_BY = userProfile.Id, //new Data UPDATED_DATE = DateTime.Now, //new Data RESET_TIMES = User.RESET_TIMES, OIC_TYPE = User.OIC_TYPE, MEMBER_TYPE = ent.MEMBER_TYPE, //new Data OIC_EMP_NO = User.OIC_EMP_NO, IS_APPROVE = User.IS_APPROVE, APPROVED_BY = User.APPROVED_BY, STATUS = User.STATUS, APP_CLOSED = User.APP_CLOSED, LASTPASSWORD_CHANGDATE = User.LASTPASSWORD_CHANGDATE, OTH_USER_TYPE = ent.OTH_USER_TYPE //new Data }; #endregion #region AG_IAS_REGISTRATION_T AG_IAS_REGISTRATION_T newRegis = new AG_IAS_REGISTRATION_T { ID = ID, MEMBER_TYPE = ent.MEMBER_TYPE, ID_CARD_NO = Regis.ID_CARD_NO, EMPLOYEE_NO = Regis.EMPLOYEE_NO, PRE_NAME_CODE = Regis.PRE_NAME_CODE, NAMES = Regis.NAMES, LASTNAME = Regis.LASTNAME, NATIONALITY = Regis.NATIONALITY, BIRTH_DATE = Regis.BIRTH_DATE, SEX = Regis.SEX, EDUCATION_CODE = Regis.EDUCATION_CODE, ADDRESS_1 = Regis.ADDRESS_1, ADDRESS_2 = Regis.ADDRESS_2, AREA_CODE = Regis.AREA_CODE, PROVINCE_CODE = Regis.PROVINCE_CODE, ZIP_CODE = Regis.ZIP_CODE, TELEPHONE = Regis.TELEPHONE, LOCAL_ADDRESS1 = Regis.LOCAL_ADDRESS1, LOCAL_ADDRESS2 = Regis.LOCAL_ADDRESS2, LOCAL_AREA_CODE = Regis.LOCAL_AREA_CODE, LOCAL_PROVINCE_CODE = Regis.LOCAL_PROVINCE_CODE, LOCAL_ZIPCODE = Regis.LOCAL_ZIPCODE, LOCAL_TELEPHONE = Regis.LOCAL_TELEPHONE, EMAIL = Regis.EMAIL, STATUS = Regis.STATUS, TUMBON_CODE = Regis.TUMBON_CODE, LOCAL_TUMBON_CODE = Regis.LOCAL_TUMBON_CODE, COMP_CODE = ent.COMP_CODE, CREATED_BY = userProfile.Id, CREATED_DATE = DateTime.Now, UPDATED_BY = userProfile.Id, UPDATED_DATE = DateTime.Now, NOT_APPROVE_DATE = Regis.NOT_APPROVE_DATE, LINK_REDIRECT = Regis.LINK_REDIRECT, REG_PASS = Regis.REG_PASS, APPROVE_RESULT = Regis.APPROVE_RESULT, APPROVED_BY = Regis.APPROVED_BY, AGENT_TYPE = Regis.AGENT_TYPE, IMPORT_STATUS = Regis.IMPORT_STATUS }; #endregion base.ctx.AG_IAS_PERSONAL_T.AddObject(newPerson); base.ctx.AG_IAS_USERS.AddObject(newUser); base.ctx.AG_IAS_REGISTRATION_T.AddObject(newRegis); Person.STATUS = "7"; Regis.STATUS = "7"; User.IS_ACTIVE = "C"; User.UPDATED_BY = userProfile.Id; User.UPDATED_DATE = DateTime.Now; User.OTH_USER_TYPE = ent.OTH_USER_TYPE; loginfo = string.Format("{0} {1} เปลี่ยนประเภทผู้ใช้งานจาก USER_ID:{2} เป็น USER_ID:{3}", Person.NAMES, Person.LASTNAME, ent.ID, ID); } else if (ent.MEMBER_TYPE == "5" || ent.MEMBER_TYPE == "6" || ent.MEMBER_TYPE == "4") { if (ent.MEMBER_TYPE == Person.MEMBER_TYPE) { res.ErrorMsg = "ไม่มีการเปลี่ยนแปลงข้อมูล"; return(res); } loginfo = string.Format("[OIC] USER_ID:{0} {1} {2} เปลี่ยนประเภทผู้ใช้งานจาก MEMBER_TYPE:{3} เป็น MEMBER_TYPE:{4}", ent.ID, Person.NAMES, Person.LASTNAME, Person.MEMBER_TYPE, ent.MEMBER_TYPE); Person.MEMBER_TYPE = ent.MEMBER_TYPE; Person.UPDATED_BY = userProfile.Id; Person.UPDATED_DATE = DateTime.Now; User.USER_TYPE = ent.MEMBER_TYPE; User.MEMBER_TYPE = ent.MEMBER_TYPE; User.UPDATED_BY = userProfile.Id; User.UPDATED_DATE = DateTime.Now; User.OTH_USER_TYPE = ent.OTH_USER_TYPE; } else { res.ErrorMsg = "ไม่มีการเปลี่ยนแปลงข้อมูล"; return(res); } base.ctx.SaveChanges(); LoggerFactory.CreateLog().LogInfo(loginfo); } catch (Exception ex) { res.ErrorMsg = "พบข้อผิดพลาดในการเปลี่ยนประเภทผู้ใช้งาน"; LoggerFactory.CreateLog().Fatal(string.Format("AccountService_EditMemberTypeAndActive USER_ID: {0}", ent.ID), ex); } return(res); }