public void CheckInvalidLogin(string username, string password)
 {
     UsernameField.SendKeys(username);
     PasswordField.SendKeys(password);
     FailedBtnSignIn.Click(false);
     ErrorLoginMessage.WaitForElementVisibleAndEnabled();
 }
        private async Task HandleLogin()
        {
            HttpMessage resp = await LoginHelper.Login(
                tbx_username.Text, tbx_password.Password, tbx_valicode.Text, guids.TempGuid);

            switch (resp.statusCode)
            {
            case HttpStatusCode.OK:
                this.loginData = resp.data as LoginData;
                this.userData  = JsonHelper.Deserialize <UserData>(loginData.userData);
                LoginSuccess   = true;
                //var names = await StringValues.getValidNames();
                //if (names.Contains(userData.Name))
                //{
                //    MessageBox.Show(userData.Name + ",欢迎你!", "欢迎");
                //}
                //else
                //{
                //    MessageBox.Show(userData.Name + ",请联系不朽购买软件使用权限" +
                //        Environment.NewLine + "QQ:623408596", "警告");
                //    Environment.Exit(0);
                //}
                urpSettings.username = tbx_username.Text;
                if (urpSettings.savepwd)
                {
                    urpSettings.password = tbx_password.Password;
                }
                else
                {
                    urpSettings.password = "";
                }
                FileHelper.WriteSettings(urpSettings);
                MainWindow mainWindow = new MainWindow(loginData, userData);
                mainWindow.Show();
                this.Close();
                break;

            case HttpStatusCode.BadRequest:
                ErrorLoginMessage err = resp.data as ErrorLoginMessage;
                if (err.error_description == "验证码错误!")
                {
                    tbx_valicode.Text = "";
                }
                MessageBox.Show(err.error_description, "错误");
                await RefreshGuids();

                break;

            default:
                MessageBox.Show(resp.data.ToString(), "异常错误!");
                break;
            }
        }
Example #3
0
        private async Task HandleLogin()
        {
            HttpMessage resp = await LoginHelper.Login(
                tbx_username.Text, tbx_password.Password, tbx_valicode.Text, guids.TempGuid);

            switch (resp.statusCode)
            {
            case HttpStatusCode.OK:
                this.loginData       = resp.data as LoginData;
                this.userData        = JsonHelper.Deserialize <UserData>(loginData.userData);
                LoginSuccess         = true;
                urpSettings.username = tbx_username.Text;
                if (urpSettings.savepwd)
                {
                    urpSettings.password = tbx_password.Password;
                }
                else
                {
                    urpSettings.password = "";
                }
                FileHelper.WriteSettings(urpSettings);
                MainWindow mainWindow = new MainWindow(loginData, userData);
                mainWindow.Show();
                this.Close();
                break;

            case HttpStatusCode.BadRequest:
                ErrorLoginMessage err = resp.data as ErrorLoginMessage;
                if (err.error_description == "验证码错误!")
                {
                    tbx_valicode.Text = "";
                }
                MessageBox.Show(err.error_description, "错误");
                await RefreshGuids();

                break;

            default:
                MessageBox.Show(resp.data.ToString(), "异常错误!");
                break;
            }
        }