Beispiel #1
0
        private async void ButtonLogout_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBoxResult.No == MessageBox.Show("Are you sure you want to log out?", "", MessageBoxButton.YesNo))
                {
                    return;
                }

                _idSettings.AuthCookie = null;
                _idSettings.Write();

                if (_expressClient == null)
                {
                    return; // should not happen, but to be save
                }
                await _expressClient.Logout();

                ShowMessage("You are logged out", Visual.Severities.Info);
                RefreshLoginDependentControls(false, false);
            }
            catch (Exception)
            {
                ShowMessage("Error during log out", Visual.Severities.Error);
            }
        }
Beispiel #2
0
        /// <summary>
        /// login and then automatically run the order
        /// </summary>
        private async void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            LoginSuccessful           = false;
            LoginRemembered           = false;
            VersionOk                 = false;
            LabelErrorMessage.Content = "";
            var origCursor = Cursor;

            try
            {
                Cursor = Cursors.Wait;
                try
                {
                    var loggedIn = await _expressClient.Login(TextLogin.Text, Pw.Password, CheckRemember.IsChecked == true);

                    if (!loggedIn)
                    {
                        LabelErrorMessage.Content = "Login failed.";
                        return;
                    }

                    if (CheckRemember.IsChecked == true)
                    {
                        _idSettings.AuthCookie = _expressClient.AuthCookie;
                        _idSettings.UserLogin  = TextLogin.Text;
                        LoginRemembered        = true;
                    }
                    else
                    {
                        _idSettings.AuthCookie = null;
                    }

                    _idSettings.Write(); // also if null auth cookie

                    LoginSuccessful = true;

                    VersionOk = await _expressClient.CheckIfCurrentVersion();

                    if (!VersionOk)
                    {
                        RowUpdateMessage.MaxHeight = 100;
                        ButtonLogin.IsEnabled      = false;
                        return;
                    }

                    this.Close();
                }
                catch (Exception exception)
                {
                    LabelErrorMessage.Content = exception.Message;
                    return;
                }
            }
            finally
            {
                Cursor = origCursor;
            }
        }