public bool DeleteUserController(DeleteUserDomain userDm) { UserBIZ userBIZ = new UserBIZ(); userBIZ.DeleteUser(userDm.UserAccount); return(true); }
/// <summary> /// Check blank password and password is matching with given password. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public ErrorItem CheckPassword(NZString username, NZString password) { if (password.IsNull) { ErrorItem item = new ErrorItem(password.Owner, Messages.eValidate.VLM9004.ToString()); return(item); } // ถ้าต้องการเช็คการเข้ารหัส ให้ปรับเป็น true. bool bUseHashPassword = true; //== Check password same with stored on database. UserBIZ userBiz = new UserBIZ(); string hashPassword = string.Empty; if (bUseHashPassword) { hashPassword = userBiz.HashUserPassword(username.StrongValue, password.StrongValue, true); } else { hashPassword = password.StrongValue; } UserDTO userDTO = userBiz.LoadUser(username); if (hashPassword != userDTO.PASS.StrongValue) { ErrorItem item = new ErrorItem(password.Owner, Messages.eValidate.VLM9007.ToString()); return(item); } return(null); }
public bool UpdateUserController(CreateUserDomain userDm) { UserBIZ userBIZ = new UserBIZ(); UserDTO userDTO = new UserDTO(); userDTO.APPLY_DATE.Value = DateTime.Now; userDTO.CRT_BY = CommonLib.Common.CurrentUserInfomation.Username; userDTO.CRT_DATE.Value = DateTime.Now; userDTO.CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.UserCD; userDTO.DATE_FORMAT = userDm.DefaultDateFormat; userDTO.FLG_ACTIVE = userDm.IsActive; userDTO.FLG_RESIGN = userDm.IsResign; userDTO.GROUP_CD = userDm.GroupUser; userDTO.LANG_CD = userDm.DefaultLang; userDTO.LOWER_USER_ACCOUNT = userDm.UserAccount.ToLower(); userDTO.MENU_SET_CD = userDm.MenuSet; if (!userDm.PassWord.IsNull) { userDTO.PASS.Value = userBIZ.HashUserPassword(userDm.UserAccount.StrongValue, userDm.PassWord.StrongValue, true);//userDm.PassWord; userDTO.PASS.Owner = userDm.PassWord.Owner; } userDTO.UPPER_USER_ACCOUNT = userDm.UserAccount.ToUpper(); userDTO.UPD_BY = CommonLib.Common.CurrentUserInfomation.Username; userDTO.UPD_DATE.Value = DateTime.Now; userDTO.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.UserCD; userDTO.USER_ACCOUNT = userDm.UserAccount; userDTO.FULL_NAME = userDm.UserName; userBIZ.UpdateUser(userDTO); return(true); }
/// <summary> /// 查询记录 /// </summary> private void BtnSearch_Click(object sender) { ObservableCollection <User> source = new UserBIZ().SelectAll(); var pagedSource = new QueryableCollectionView(source); View.DGSelect.ItemsSource = pagedSource; View.searchDataPager.Source = pagedSource; View.DGSelect.SelectedItems.Remove(View.DGSelect.SelectedItem);//取消首行选中 }
public DataTable LoadPermissionTable(string strUserName) { DataTable dtPermission = null; UserBIZ userBiz = new UserBIZ(); dtPermission = userBiz.LoadPermissionTable(strUserName); return(dtPermission); }
/// <summary> /// Save modified user profile. /// </summary> /// <param name="model"></param> /// <exception cref="BusinessException"><c>BusinessException</c>.</exception> /// <exception cref="Exception"><c>Exception</c>.</exception> public void SaveUserProfile(UserProfileUIDM model) { UserBIZ bizUser = new UserBIZ(); bizUser.UpdateUserProfile(CommonLib.Common.CurrentUserInfomation.UserCD, model.Username, model.CurrentPassword, model.Password, model.ConfirmPassword, new NZInt(null, model.DefaultDateFormat.Value), new NZInt(null, model.DefaultLang.Value)); }
public FrmADM010_UserMaintenance() { InitializeComponent(); m_bizUser = new UserBIZ(AppEnvironment.Database); ControlUtil.VisibleControl(false, m_toolBarExport, m_toolBarImport, m_toolBarPrint); ControlUtil.VisibleControl(false, m_toolBarPrint); ControlUtil.VisibleControl(true, m_toolBarExport); ControlUtil.EnabledControl(false, this.Controls); }
/// <summary> /// check for password can use for create new user /// </summary> /// <param name="password"></param> /// <returns></returns> public ErrorItem CheckPassword(NZString password) { if (password.IsNull) { ErrorItem item = new ErrorItem(password.Owner, Messages.eValidate.VLM9004.ToString()); return(item); } UserBIZ userBiz = new UserBIZ(); return(null); }
private void RefreshUserSpread() { UserBIZ biz = new UserBIZ(); fpUser.DataSource = DTOUtility.ConvertListToDataTable(biz.LoadAllUserNotInGroup(m_GroupCD)); UserMaintenanceUIDM umd = new UserMaintenanceUIDM(); shtUser.Columns[(int)eColUser.SEL].Locked = false; shtUser.Columns[(int)eColUser.USER_ACCOUNT].Locked = true; shtUser.Columns[(int)eColUser.FULL_NAME].Locked = true; }
/// <summary> /// 注销登录 /// </summary> /// <returns></returns> public bool Logout() { ServiceAuthentication auth = new ServiceAuthentication(this.currentContext); ServiceIdentity user = auth.GetIdentity(); if (user != null) { UserBIZ biz = new UserBIZ(); biz.SaveLogoutLog(user.Id); return(auth.SignOut(user)); } return(false); }
public void RemoveUserFromGroup(CreateGroupDomain groupDm, string userCD) { UserBIZ userBIZ = new UserBIZ(); UserDTO userDTO = new UserDTO(); userDTO.GROUP_CD = groupDm.GroupCD; userDTO.UPD_BY = CommonLib.Common.CurrentUserInfomation.Username; userDTO.UPD_DATE.Value = DateTime.Now; userDTO.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.UserCD; userDTO.USER_ACCOUNT.Value = userCD; userBIZ.RemoveUserFromGroup(userDTO); }
//Url: //UserService/Login/string:LoginName;string:LoginPwd public UserLoginInfoModel Login() { string message; UserBIZ biz = new UserBIZ(); UserModel user = biz.Login(this.User.LoginName, EncryptPwd(this.User.LoginPwd), out message); UserLoginInfoModel model = new UserLoginInfoModel(); model.User = user; model.LoginResult = user != null; model.LoginResultMessage = message; return(model); }
public bool AddUserToGroupController(CreateUserDomain userDm) { UserBIZ userBIZ = new UserBIZ(); UserDTO userDTO = new UserDTO(); userDTO.GROUP_CD = userDm.GroupUser; userDTO.UPD_BY = CommonLib.Common.CurrentUserInfomation.Username; userDTO.UPD_DATE.Value = DateTime.Now; userDTO.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.UserCD; userDTO.USER_ACCOUNT = userDm.UserAccount; userBIZ.AddUserToGroup(userDTO); return(true); }
public CreateUserDomain LoadData(CreateUserDomain userDm) { UserBIZ userBIZ = new UserBIZ(); UserDTO userDTO = userBIZ.LoadUser(userDm.UserAccount); userDm.DefaultLang.Value = userDTO.LANG_CD.Value; userDm.GroupUser.Value = userDTO.GROUP_CD.Value; userDm.PassWord.Value = userDTO.PASS.Value; userDm.UserName.Value = userDTO.FULL_NAME.Value; userDm.DefaultDateFormat.Value = userDTO.DATE_FORMAT.Value; userDm.UserAccount.Value = userDTO.USER_ACCOUNT.Value; userDm.MenuSet.Value = userDTO.MENU_SET_CD.Value; userDm.IsActive.Value = userDTO.FLG_ACTIVE.Value; userDm.IsResign.Value = userDTO.FLG_RESIGN.Value; return(userDm); }
private void RefreshUserSpread() { UserBIZ biz = new UserBIZ(); fpUser.DataSource = DTOUtility.ConvertListToDataTable(biz.LoadAllUser()); UserMaintenanceUIDM umd = new UserMaintenanceUIDM(); //dmcUserMaintenance.LoadData(umd); int rows = shtUser.Rows.Count; for (int i = 0; i < rows; i++) { shtUser.Rows[i].Locked = true; } }
public ErrorItem CheckExistUserAccount(NZString userAccount) { UserBIZ userBiz = new UserBIZ(); if (userAccount.IsNull) { ErrorItem item = new ErrorItem(userAccount.Owner, Messages.eValidate.VLM9002.ToString()); return(item); } if (userBiz.isExistUserAccount(userAccount)) { ErrorItem item = new ErrorItem(userAccount.Owner, Messages.eValidate.VLM9001.ToString()); return(item); } return(null); }
public Map <string, object> LoadUserProfile(NZString userCD) { UserProfileUIDM model = new UserProfileUIDM(); UserBIZ bizUser = new UserBIZ(); UserDTO dtoUser = bizUser.LoadUser(userCD); model.UserAccount.Value = dtoUser.USER_ACCOUNT.Value; model.Username.Value = dtoUser.FULL_NAME.Value; model.DefaultDateFormat.Value = dtoUser.DATE_FORMAT.Value; model.DefaultLang.Value = dtoUser.LANG_CD.Value; Map <string, object> mapData = new Map <string, object>(); mapData.Put(C_VAL_MODEL, model); return(mapData); }
/// <summary> /// <para>Check blank username and found username on database.</para> /// </summary> /// <param name="username"></param> /// <returns></returns> public ErrorItem CheckUsername(NZString username) { if (username.IsNull) { ErrorItem item = new ErrorItem(username.Owner, Messages.eValidate.VLM9002.ToString()); return(item); } UserBIZ userBiz = new UserBIZ(); UserDTO userDTO = userBiz.LoadUser(username); //== Check found specified username. if (userDTO == null) { ErrorItem item = new ErrorItem(username.Owner, Messages.eValidate.VLM9007.ToString()); return(item); } return(null); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> /// <exception cref="BusinessException"><c>BusinessException</c>.</exception> /// <exception cref="ValidateException"><c>ValidateException</c>.</exception> public bool ValidateLogin(NZString username, NZString password) { ValidateException validateException = new ValidateException(); ErrorItem errorItem = null; errorItem = CheckUsername(username); if (errorItem != null) { validateException.AddError(errorItem); throw validateException; } errorItem = CheckPassword(username, password); if (errorItem != null) { validateException.AddError(errorItem); throw validateException; } validateException.ThrowIfHasError(); UserBIZ userBiz = new UserBIZ(); UserDTO userDTO = userBiz.LoadUser(username); if (userDTO.FLG_ACTIVE.StrongValue != 1) { errorItem = new ErrorItem(null, "ERR00001", "Account doesn't activate."); throw new BusinessException(errorItem); } if (userDTO.FLG_RESIGN.StrongValue == 1) { errorItem = new ErrorItem(null, "ERR00002", "Account has resigned."); throw new BusinessException(errorItem); } return(true); }
/// <summary> /// /// </summary> /// <param name="userCD"></param> /// <param name="oldPassword"></param> /// <param name="newPassword"></param> /// <param name="confirmNewPassword"></param> /// <returns></returns> /// <exception cref="BusinessException"><c>BusinessException</c>.</exception> public void BizCheckChangePassword(NZString userCD, NZString oldPassword, NZString newPassword, NZString confirmNewPassword) { // UserDAO dao = new UserDAO(CommonLib.Common.CurrentDatabase); UserBIZ biz = new UserBIZ(); // check old password. if (!newPassword.IsNull && !confirmNewPassword.IsNull) { UserDTO dtoUser = biz.LoadUser(userCD); string encPassword = biz.HashUserPassword(userCD.StrongValue, oldPassword.StrongValue, true); if (!Equals(encPassword, dtoUser.PASS.StrongValue)) { ErrorItem error = new ErrorItem(confirmNewPassword.Owner, Messages.eValidate.VLM9010.ToString()); throw new BusinessException(error); } if (!Equals(newPassword.Value, confirmNewPassword.Value)) { ErrorItem error = new ErrorItem(confirmNewPassword.Owner, Messages.eValidate.VLM9009.ToString()); throw new BusinessException(error); } } }
/// <summary> /// Login operation /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns>Return true if login complete. Otherwise return false.</returns> public bool Login(NZString username, NZString password) { ConfigurationController prc = new ConfigurationController(); UserValidator userValidator = new UserValidator(); ErrorItem errorItem = null; //== Load last database configuration. Map <string, string> mapConfig = prc.LoadConfiguration(); DatabaseCredential credential = new DatabaseCredential(); credential.Provider = (DatabaseProvider)Enum.Parse(typeof(DatabaseProvider), mapConfig[ConfigurationController.S_KEY_PROVIDER_NAME].Value); credential.ServerName = mapConfig[ConfigurationController.S_KEY_SERVER_NAME].Value; credential.DatabaseName = mapConfig[ConfigurationController.S_KEY_DATABASE_NAME].Value; credential.Username = mapConfig[ConfigurationController.S_KEY_USERNAME].Value; credential.Password = mapConfig[ConfigurationController.S_KEY_PASSWORD].Value; credential.ConnectionTimeout = mapConfig[ConfigurationController.S_KEY_CONNECTION_TIMEOUT].Value; int iCommandTimeout = 0; if (Int32.TryParse(mapConfig[ConfigurationController.S_KEY_COMMAND_TIMEOUT].Value, out iCommandTimeout)) { Database.m_iDefaultCommandTimeout = iCommandTimeout; } else { Database.m_iDefaultCommandTimeout = 30; } //== Test database connection ans register current database. errorItem = DatabaseManager.TestConnection(credential); if (errorItem == null) { // Initialize DAO Factory. SystemMaintenance.DAO.DAOFactory.SetProvider(credential.Provider); // Register current database. Common.RegisterCurrentDatabase(DatabaseManager.CreateDatabase(credential)); // Register message loader. ApplicationContextManager.RegisterMessageLoader(new DBMessageLoader(Common.CurrentDatabase)); } else { MessageBox.Show(errorItem.Message.MessageDescription, null, MessageBoxButtons.OK, MessageBoxIcon.Error); // Release current database. Common.UnregisterUserInformation(); return(false); } userValidator.ValidateLogin(username, password); // Singin user information session. UserBIZ userBiz = new UserBIZ(); UserDTO userDTO = userBiz.LoadUser(username); userBiz.RegisterMachine(username); UserInfo userInfo = new UserInfo(); userInfo.DateFormat = (eDateFormat)userDTO.DATE_FORMAT.StrongValue; userInfo.LanguageCD.Value = userDTO.LANG_CD.Value; userInfo.LastLogin.Value = DateTime.Now; userInfo.UserCD.Value = userDTO.USER_ACCOUNT.Value; userInfo.Username.Value = userDTO.FULL_NAME.Value; userInfo.Machine.Value = Environment.MachineName; userInfo.GroupCode.Value = userDTO.GROUP_CD.Value; Common.RegisterUserInformation(userInfo); // Store last user login. IniFile ini = new IniFile(System.IO.Path.Combine(Application.StartupPath, Common.CONFIG_FILENAME)); ini.Write(S_SECTION, S_USER, username.StrongValue); ini.Dispose(); return(true); }