Esempio n. 1
0
 private string DisplayError(BeginSessionResponse response)
 {
     if (response.InvalidApiKey)
     {
         return("The API key for this program is not valid");
     }
     else if (response.LoginRequired)
     {
         return("This account is protected by a username and password. Please login instead.");
     }
     else if (response.RateLimited)
     {
         return("Actions are being performed too quickly. Please slow down.");
     }
     else if (response.WrongUsernameOrPassword)
     {
         return("Wrong username or password");
     }
     else if (response.ErrorMessage != null)
     {
         return("Error: " + response.ErrorMessage);
     }
     else
     {
         return("An error occurred");
     }
 }
 private void ErrorProcessingBeginSession(BeginSessionResponse error)
 {
     if (error.InvalidApiKey)
     {
         MessageBox.Show("Invalid API Key!");
     }
 }
Esempio n. 3
0
        private string ErrorProcessing(BeginSessionResponse result)
        {
            string loginError = "Успешно";

            if (result.RateLimited)
            {
                Thread.Sleep(3000);
                LoginGo();
            }
            if (result.LoginRequired || result.WrongUsernameOrPassword)
            {
                loginError = "Неверный логин или пароль";
            }
            return(loginError);
        }
Esempio n. 4
0
        private async void LoginGo()
        {
            BeginSessionResponse result = null;

            try
            {
                result = await DiceWebAPI.BeginSessionAsync(Settings.Default.ApiSettings, _loginModel.Login,
                                                            _loginModel.Password, int.Parse(_loginModel.GoogleCode == ""?"0": _loginModel.GoogleCode));
            }
            catch (Exception ex)
            {
            }

            if (result != null)
            {
                OnLogin?.Invoke(this, new ResultLoginModel {
                    Session = result.Session, ErrorResult = ErrorProcessing(result)
                });
            }
        }
        private async void GetNewAccount()
        {
            BeginSessionResponse sessionResult = null;

            try
            {
                sessionResult = await DiceWebAPI.BeginSessionAsync(Settings.Default.ApiSettings);
            }
            catch (Exception ex)
            {
            }

            if (sessionResult.Success)
            {
                CreateUserResponse newAccResult = null;
                try
                {
                    newAccResult = await DiceWebAPI.CreateUserAsync(sessionResult.Session, _newAccountModel.Login, _newAccountModel.PasswordOne);
                }
                catch (Exception ex)
                {
                }

                if (newAccResult.Success)
                {
                    MessageBox.Show("New account created!");
                    OnLogin?.Invoke(this, _newAccountModel.Login);
                }
                else
                {
                    ErrorProcessingCreateUser(newAccResult);
                }
            }
            else
            {
                ErrorProcessingBeginSession(sessionResult);
            }
        }