private async void LoginOrSearch()
        {
            try
            {
                var loggedIn = await QuandlConfig.ApiKeyValid();

                Dispatcher.Invoke(() =>
                {
                    if (loggedIn)
                    {
                        foreach (UIElement child in currentStepGrid.Children)
                        {
                            child.Visibility = Visibility.Visible;
                        }

                        ChangeToCurrentStep();
                    }
                    else
                    {
                        var loginXaml = new Uri("../Settings/Login.xaml", UriKind.Relative);
                        stepFrame.NavigationUIVisibility = NavigationUIVisibility.Hidden;
                        stepFrame.Source = loginXaml;
                        currentStepGrid.Children[0].Visibility = Visibility.Collapsed;
                        currentStepGrid.Children[2].Visibility = Visibility.Collapsed;
                    }
                    Focus();
                });
            }
            catch (Exception exp)
            {
                MainLogic.Instance.UpdateStatusBar(exp);
                Logger.log(exp);
            }
        }
예제 #2
0
 private async void ValideKey()
 {
     try
     {
         await QuandlConfig.ApiKeyValid();
     }
     catch (Exception exp)
     {
         Globals.ThisAddIn.UpdateStatusBar(exp);
         Logger.log(exp);
     }
 }
예제 #3
0
        private async void loginButton_click(object sender, RoutedEventArgs e)
        {
            loginForm.IsEnabled   = false;
            errorLabel.Visibility = Visibility.Hidden;

            try
            {
                // save this to config
                if (!string.IsNullOrWhiteSpace(apiKey.Text))
                {
                    var key = apiKey.Text.Trim();
                    if (await QuandlConfig.ApiKeyValid(key))
                    {
                        QuandlConfig.ApiKey = key;
                        MainLogic.Instance.TaskPaneUpdater.Hide <WizardGuideControlHost>();
                    }
                    else
                    {
                        DisplayErrorMessage(Properties.Resources.SettingsInValidApiKey);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(email.Text) && !string.IsNullOrWhiteSpace(password.Password))
                {
                    QuandlConfig.AuthenticateWithCredentials(new Web(), email.Text.Trim(), password.Password.Trim());
                    MainLogic.Instance.TaskPaneUpdater.Hide <WizardGuideControlHost>();
                }
                else
                {
                    DisplayErrorMessage(Properties.Resources.SettingsIncorrectUsernameOrPassword);
                }
            }
            catch (QuandlErrorBase exp)
            {
                if (exp.StatusCode == HttpStatusCode.BadRequest)
                {
                    DisplayErrorMessage(Properties.Resources.SettingsIncorrectCredentials);
                }
                else
                {
                    DisplayErrorMessage(Properties.Resources.SettingsSomethingWrongTryLater);
                }
            }
            catch (Exception exp)
            {
                DisplayErrorMessage(Properties.Resources.SettingsIncorrectUsernameOrPassword);
                MainLogic.Instance.UpdateStatusBar(exp);
                // For debug purposes only. This should not make it to production.

                Logger.log(exp);
            }
        }
예제 #4
0
 async Task ValidateApiKey(string apiKey)
 {
     if (await QuandlConfig.ApiKeyValid(apiKey))
     {
         Dispatcher.Invoke(() => {
             SaveSettings(apiKey);
             Close();
         });
     }
     else
     {
         DisplayErrorMessage(Properties.Resources.InvalidApiKeyEntered);
     }
 }
        public WizardGuide()
        {
            InitializeComponent();

            // Wait for the UI thread to become idle before rendering. Not this can have disastrous performance implications if used incorrectly.
            Dispatcher.Invoke(new System.Action(() => { }), DispatcherPriority.ContextIdle, null);

            // async check that the user is logged in our not
            Loaded += async delegate
            {
                PrepareFormEvents();
                try
                {
                    var validKey = await QuandlConfig.ApiKeyValid();

                    LoginOrSearch();
                }
                catch (Exception exp)
                {
                    MainLogic.Instance.UpdateStatusBar(exp);
                    Logger.log(exp);
                }
            };
        }