Пример #1
0
        private async Task doLogout()
        {
            try
            {
                IAccountManagerResult isValid = await magocloudClient.AccountManager.IsValid(userData);

                if (isValid.Success)
                {
                    IAccountManagerResult result = await magocloudClient.AccountManager.Logout(userData);

                    if (result.Success)
                    {
                        tbxMessages.Text = "User successfully logged out";
                    }
                    else
                    {
                        tbxMessages.Text = "Logout failed";
                    }
                }
                else
                {
                    tbxMessages.Text = "Login no more valid, logout failed";
                }
            }
            catch (Exception exception)
            {
                tbxMessages.Text = $"Error during logout {exception.Message}";
            }

            userData = null;
        }
Пример #2
0
        private async void btnConnect_Click(object sender, EventArgs e)
        {
            if (userData != null)
            {
                MessageBox.Show("already connected");
                return;
            }

            if (tbxAccountName.Text == string.Empty || tbxRootURL.Text == string.Empty || tbxSubscription.Text == string.Empty)
            {
                MessageBox.Show("missing connection data");
                return;
            }
            try
            {
                magocloudClient = new MagoAPIClient(tbxRootURL.Text, new ProducerInfo("MyProdKey", "MyAppId"));

                IAccountManagerResult result = await magocloudClient.AccountManager?.Login(tbxAccountName.Text, tbxPassword.Text, tbxSubscription.Text);

                if (!result.Success || result.UserData == null || !result.UserData.IsLogged)
                {
                    tbxMessages.Text = "Invalid login\r\n" + result.ReturnValue;
                    return;
                }

                userData         = result.UserData;
                tbxMessages.Text = "Connected succesfully!";
            }
            catch (Exception ex)
            {
                tbxMessages.Text = ex.Message;
            }
        }