/// <summary> /// Initiates logging in with the current <see cref="IProvider"/> registered in the <see cref="ProviderManager"/>. /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task LoginAsync() { if (UserDetails != null) { return; } var provider = ProviderManager.Instance.GlobalProvider; if (provider != null) { try { await provider.LoginAsync(); if (provider.State == ProviderState.SignedIn) { // TODO: include user details? LoginCompleted?.Invoke(this, new EventArgs()); LoadData(); } else { LoginFailed?.Invoke(this, new LoginFailedEventArgs(new TimeoutException("Login did not complete."))); } } catch (Exception e) { LoginFailed?.Invoke(this, new LoginFailedEventArgs(e)); } } }
/// <summary> /// Initiates logging in with the current <see cref="IProvider"/> registered in the <see cref="ProviderManager"/>. /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task LoginAsync() { if (UserDetails != null) { return; } var provider = ProviderManager.Instance.GlobalProvider; if (provider != null) { await provider.LoginAsync(); if (provider.State == ProviderState.SignedIn) { // TODO: include user details? LoginCompleted?.Invoke(this, new EventArgs()); } else { LoginFailed?.Invoke(this, new EventArgs()); } LoadData(); } }
public void Login(string username, string pwd) { ServiceLogin.ServiceLoginClient client = new ServiceLogin.ServiceLoginClient(); client.LoginCompleted += (sender, e) => { ServicesEventArgs <bool> arg = new ServicesEventArgs <bool>(); if (e.Error == null) { arg.Result = e.Result; arg.Succesed = true; } else { arg.Succesed = false; arg.Error = e.Error; #if DEBUG arg.Succesed = true; arg.Result = true; #endif //写错误日志 //..... } if (LoginCompleted != null) { LoginCompleted.Invoke(this, arg); } }; client.LoginAsync(username, pwd); }
private void LoginFinished(IAsyncResult ar) { AsyncResult result = (AsyncResult)ar; LoginDelegate login = (LoginDelegate)result.AsyncDelegate; string error = login.EndInvoke(ar); LoginCompleted?.Invoke(error); }
private void LoginWithTokenFinished(IAsyncResult ar) { var result = (AsyncResult)ar; var login = (Func <TokenKey, string>)result.AsyncDelegate; string error = login.EndInvoke(ar); LoginCompleted?.Invoke(error); }
/// <summary> /// 登录成功 /// </summary> public static void OnLoginCompleted(bool e = false) { if (LoginCompleted != null) { LoginCompleted.Invoke(e); } else { throw new Exception("未实现方法CommonMethodCallBackHandlers.LoginCompleted"); } }
public void LoginWithTokenAsync(TokenKey user) { string error; ConnectedServer = user.Server; if (tokens.ContainsKey(user)) { CurrentUser = user; error = null; } else { error = "Invalid Password"; } LoginCompleted?.Invoke(error); }
/// <summary> /// 用户登陆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { if (this.txtUserId.Text.Trim().Length == 0 || this.txtPwd.Text.Trim().Length <= 0) { MessageBox.Show("请输入账号Id和密码", "登陆提示"); this.txtUserId.Focus(); return; } if (!DataValidate.IsInteger(this.txtUserId.Text.Trim())) { MessageBox.Show("用户名格式错误,必须为正整数", "登陆提示"); this.txtUserId.Focus(); return; } User objUser = new User() { UserId = Convert.ToInt32(this.txtUserId.Text.Trim()), UserPwd = this.txtPwd.Text.Trim() }; //提交数据库验证 try { objUser = this.objUserService.AdminLogin(objUser); if (objUser != null) { //触发登陆成功事件 LoginCompleted?.Invoke(objUser); this.Close(); } else { MessageBox.Show("登陆失败,用户名或密码错误", "登陆提示"); this.txtUserId.Focus(); return; } } catch (Exception ex) { MessageBox.Show("登陆账号数据库验证出错:" + ex.Message, "登陆错误"); return; } }
public void LoginAsync(string username, string password, bool saveToken) { string error; CheckServer(); if ((username == Utils.SavedUser.Item1 && password == Utils.SavedUser.Item2) || (username == Utils.OtherUser.Item1 && password == Utils.OtherUser.Item2)) { error = null; CurrentUser = new TokenKey(username, "localserver"); if (saveToken) { tokens[new TokenKey(username, password)] = username; } } else { error = "Invalid password"; } LoginCompleted?.Invoke(error); }
private void RaiseLoginCompletedEvent() { LoginCompleted?.Invoke(this, EventArgs.Empty); }
void RaiseLoginCompleted(bool success, Exception e = null) { var eArgs = new OperationResultEventArgs(success, e); LoginCompleted?.Invoke(this, eArgs); }
void RaiseLoginCompleted(OperationResultEventArgs e) { LoginCompleted?.Invoke(this, e); }
protected virtual void OnLoginCompleted(LoginEventArgs e) { LoginCompleted?.Invoke(this, e); }
public virtual void OnLoginCompleted(object sender, LoginControlEventArgs e) => LoginCompleted?.Invoke(sender, e);
public void NavigateAfterAuthenticationCompleted(Boolean isPINSet) { LoginCompleted?.Invoke(this, new LoginEventArgs { Mode = loginMode, IsNewPINSet = isPINSet }); }
public void RaiseLoginCompleted() { LoginCompleted?.Invoke(this, EventArgs.Empty); }