private void simpleButton1_Click(object sender, EventArgs e) { if (ValidNewPass()) { string _oldPass = this.te_oldPass.EditValue.ToString(); string _newPass = this.te_newPass.EditValue.ToString(); IAuthorize _authService = LoginConfig.GetAuthorizeInterface(); if (_authService.ChangePassWord(SessionClass.CurrentSinoUser.LoginName, _oldPass, _newPass, "")) { XtraMessageBox.Show("修改口令成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } else { XtraMessageBox.Show("修改口令失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } }
/// <summary> /// 验证旧口令的正确性 /// </summary> /// <param name="_oldPass"></param> private bool ValidOldPass(string _oldPass) { IAuthorize _authService = LoginConfig.GetAuthorizeInterface(); return(_authService.CheckPassword(SessionClass.CurrentSinoUser.LoginName, _oldPass, "")); }
public void Login() { try { string ls_name = textUser.EditValue.ToString().Trim(); string ls_pass = textPass.EditValue.ToString(); string ls_type = this.CE_AuthorType.EditValue.ToString(); #region 取数据接口 IAuthorize _authService = LoginConfig.GetAuthorizeInterface(); if (_authService == null) { throw new Exception("未找到服务器端登录服务!"); } #endregion SinoUser _su = _authService.LoginSys(ConfigFile.SystemID, ls_name, ls_pass, ls_type); if (_su != null) { SessionClass.CurrentLogonName = ls_name; SessionClass.CurrentLogonPass = ls_pass; SessionClass.CurrentSinoUser = _su; SessionClass.CurrentTicket = new SinoSZTicketInfo(_su.LoginName, _su.IPAddress, _su.EncryptedTicket); SessionClass.ServerConfigData = _authService.GetServerConfig(); DataRow[] _drs = _UserDs.User.Select(string.Format("Username='******'", ls_name)); if (_drs.Length == 0) { DataRow row = _UserDs.User.NewRow(); row["Username"] = ls_name; _UserDs.User.Rows.Add(row); _UserDs.WriteXml(_schemaFile, XmlWriteMode.IgnoreSchema); } _su.DwID = _su.CurrentPost.PostDwID; loginTimes = 0; System.ComponentModel.ISynchronizeInvoke synchronizer = this; MethodInvoker invoker = new MethodInvoker(LoginSuccess); synchronizer.Invoke(invoker, null); } else { XtraMessageBox.Show("用户名/口令不正确或过期!", "系统提示"); System.ComponentModel.ISynchronizeInvoke synchronizer = this; MethodInvoker invoker = new MethodInvoker(ResetForm); synchronizer.Invoke(invoker, null); } loginTimes++; if (loginTimes > 2) { System.ComponentModel.ISynchronizeInvoke synchronizer = this; MethodInvoker invoker = new MethodInvoker(CancelApplicaton); synchronizer.Invoke(invoker, null); } } catch (Exception e) { ShowMessageDelegate showProgress = new ShowMessageDelegate(ShowMessage); string _msg = string.Format("发生错误:{0}", e.Message); this.Invoke(showProgress, new object[] { _msg }); } }