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 btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cbPackageName.SelectedIndex == -1 || cbPackageName.SelectedIndex == 0)
                    MessageBox.Show("Package name is mandatory.");
                else
                {
                    if (!Directory.Exists(ConfigurationManager.AppSettings["XmlDestination"] + "/" + cbPackageName.SelectedValue.ToString()))  // if it doesn't exist, create
                        Directory.CreateDirectory(ConfigurationManager.AppSettings["XmlDestination"] + "/" + cbPackageName.SelectedValue.ToString());

                    File.WriteAllText(XmlFile, XmlUtilities.GetFormatedXml(fullXml));

                    PermanentStoreFiles();

                    DropExistingItems();

                    CAHarvestUtilities harvest = new CAHarvestUtilities(UserName, Password, Broker);
                    ProjectInformation projectInfo = new ProjectInformation();
                    projectInfo.Backport = ((cbBackport.SelectedIndex != 0 && cbBackport.SelectedIndex != -1) ? cbBackport.SelectedValue.ToString() : "");
                    projectInfo.PackageName = cbPackageName.SelectedValue.ToString();
                    projectInfo.ProdDate = (string.IsNullOrEmpty(txbReleaseDate.Text) ? null : (DateTime?)Convert.ToDateTime(txbReleaseDate.Text));
                    projectInfo.DevCompleteDate = (string.IsNullOrEmpty(txbDevComplete.Text) ? null : (DateTime?)Convert.ToDateTime(txbDevComplete.Text)); ;

                    harvest.SaveProjectComments(cbPackageName.SelectedValue.ToString(), Repository, projectInfo);

                    MessageBox.Show("Data successfully committed.");

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error creating the XML: " + ex.Message);
            }
        }
        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.");
                }
            }
        }