/// <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));
                }
            }
        }
Beispiel #2
0
        /// <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();
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        private void LoginFinished(IAsyncResult ar)
        {
            AsyncResult   result = (AsyncResult)ar;
            LoginDelegate login  = (LoginDelegate)result.AsyncDelegate;
            string        error  = login.EndInvoke(ar);

            LoginCompleted?.Invoke(error);
        }
Beispiel #5
0
        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");
     }
 }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        /// <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;
            }
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
 private void RaiseLoginCompletedEvent()
 {
     LoginCompleted?.Invoke(this, EventArgs.Empty);
 }
Beispiel #11
0
        void RaiseLoginCompleted(bool success, Exception e = null)
        {
            var eArgs = new OperationResultEventArgs(success, e);

            LoginCompleted?.Invoke(this, eArgs);
        }
Beispiel #12
0
 void RaiseLoginCompleted(OperationResultEventArgs e)
 {
     LoginCompleted?.Invoke(this, e);
 }
Beispiel #13
0
 protected virtual void OnLoginCompleted(LoginEventArgs e)
 {
     LoginCompleted?.Invoke(this, e);
 }
Beispiel #14
0
 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
     });
 }
Beispiel #16
0
 public void RaiseLoginCompleted()
 {
     LoginCompleted?.Invoke(this, EventArgs.Empty);
 }