public void LoadProjects() { CAHarvestUtilities harvest = new CAHarvestUtilities(UserName, Password, Broker); dsProjects = harvest.GetRepoList("DefaultPackageInputFile", Repository); this.Dispatcher.Invoke((Action)(() => { cbPackageName.ItemsSource = dsProjects; cbPackageName.SelectedIndex = 0; cbBackport.ItemsSource = dsProjects; cbBackport.SelectedIndex = 0; dgDependencies.ItemsSource = dsDependencies; HarvestId.ItemsSource = dsProjects; })); }
private void StartRepoTry_MethodAsync() { string user = ""; string password = ""; string broker = ""; this.Dispatcher.Invoke((Action)(() => { btnValidate.IsEnabled = false; btnValidate.Content = "Validating..."; user = txbUser.Text; password = txbPassword.Password; broker = txbBroker.Text; btnChangeUser.IsEnabled = false; //btnValidate.Background = Brushes.Green; })); try { if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(broker)) { CAHarvestUtilities harvest = new CAHarvestUtilities(user, password, broker); repoList = harvest.GetRepoList("DefaultRepoInputFile"); this.Dispatcher.Invoke((Action)(() => { cbProjectList.ItemsSource = repoList; //cbProjectList.SelectedIndex = 0; if (repoList.Contains(ConfigurationManager.AppSettings["DefaultProject"])) cbProjectList.SelectedValue = ConfigurationManager.AppSettings["DefaultProject"]; else cbProjectList.SelectedIndex = 0; btnOk.IsEnabled = true; cbProjectList.IsEnabled = true; txbUser.IsEnabled = false; txbPassword.IsEnabled = false; txbBroker.IsEnabled = false; btnValidate.IsEnabled = false; btnChangeUser.IsEnabled = true; //btnValidate.IsEnabled = true; btnValidate.Content = "Load Projects"; })); } else { this.Dispatcher.Invoke((Action)(() => { btnValidate.IsEnabled = true; btnValidate.Content = "Load Projects"; btnChangeUser.IsEnabled = true; })); MessageBox.Show("User / Password / Broker must be entered."); } } catch (Exception ex) { this.Dispatcher.Invoke((Action)(() => { btnChangeUser.IsEnabled = true; btnValidate.IsEnabled = true; btnValidate.Content = "Load Projects"; btnOk.IsEnabled = false; cbProjectList.IsEnabled = false; txbUser.IsEnabled = true; txbPassword.IsEnabled = true; txbBroker.IsEnabled = true; })); if (ex.Message == "Harvest Login Error.") { MessageBox.Show("There was an error logging into Harvest, please check your credentials try again."); } else if (ex.Message == "Harvest Undefined Error.") { MessageBox.Show("There was an error connecting to the broker, please check the name try again."); } } }