예제 #1
0
        /// <summary>
        /// Reloads the list of projects for the selected domain
        /// </summary>
        private void ReloadProjects()
        {
            //Now we need to populate the list of projects
            string domainName = (string)this.cboDomain.SelectedValue;

            HP.QUalityCenter.List projectsOleList = TdConnection.get_VisibleProjects(domainName);
            ArrayList             projectsList    = new ArrayList();

            //Convert into a standard bindable list source (OLEList index starts at 1)
            for (int i = 1; i <= projectsOleList.Count; i++)
            {
                projectsList.Add(projectsOleList[i]);
            }
            this.cboProject.DataSource = projectsList;

            //Enable the login button if we have at least one project
            if (projectsList.Count >= 1)
            {
                this.btnLogin.Enabled = true;
            }
        }
예제 #2
0
        /// <summary>
        /// Authenticates the user from the providing server/login/password information
        /// </summary>
        /// <param name="sender">The sending object</param>
        /// <param name="e">The event arguments</param>
        private void btnAuthenticate_Click(object sender, System.EventArgs e)
        {
            //Disable the login and next button
            this.btnLogin.Enabled = false;
            this.btnNext.Enabled  = false;

            //Make sure that a login was entered
            if (this.txtLogin.Text.Trim() == "")
            {
                MessageBox.Show("You need to enter a QualityCenter login", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //Make sure that a server was entered
            if (this.txtServer.Text.Trim() == "")
            {
                MessageBox.Show("You need to enter a QualityCenter server name", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                //Instantiate the connection to QualityCenter
                TdConnection = new HP.QUalityCenter.TDConnection();

                try
                {
                    try
                    {
                        //The OTA API
                        TdConnection.InitConnectionEx(this.txtServer.Text);
                        TdConnection.Login(this.txtLogin.Text, this.txtPassword.Text);

                        //The Site Admin API
                        try
                        {
                            SaConnection = new SAapi();
                            SaConnection.Login(this.txtServer.Text, this.txtLogin.Text, this.txtPassword.Text);
                        }
                        catch (Exception)
                        {
                            //Unable to use the SiteAdmin API, so just leave NULL and don't use
                            SaConnection = null;
                        }
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("Error Logging in to QualityCenter: " + exception.Message, "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //Check to see if logged in and change the UI as appropriate
                    if (TdConnection.LoggedIn)
                    {
                        MessageBox.Show("You have logged into Quality Center Successfully", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("That login/password combination was not valid for the instance of QualityCenter", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    //Now we need to populate the list of domains
                    HP.QUalityCenter.List domainsOleList = TdConnection.VisibleDomains;
                    ArrayList             domainsList    = new ArrayList();
                    //Convert into a standard bindable list source (OLEList index starts at 1)
                    for (int i = 1; i <= domainsOleList.Count; i++)
                    {
                        domainsList.Add(domainsOleList[i]);
                    }
                    this.cboDomain.DataSource = domainsList;

                    //Make sure we have at least one domain
                    if (domainsList.Count >= 1)
                    {
                        //Reload the projects list
                        ReloadProjects();
                    }
                }
                catch (COMException exception)
                {
                    MessageBox.Show("Unable to access the HP QC API. Please make sure you that you have downloaded and installed the HP client components for HP QC (" + exception.Message + ")", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                catch (FileNotFoundException exception)
                {
                    MessageBox.Show("Unable to access the HP QC API. Please make sure you that you have downloaded and installed the HP client components for HP QC (" + exception.Message + ")", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
            catch (COMException exception)
            {
                MessageBox.Show("Unable to access the HP QC API. Please make sure you that you have downloaded and installed the HP client components for HP QC (" + exception.Message + ")", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            catch (FileNotFoundException exception)
            {
                MessageBox.Show("Unable to access the HP QC API. Please make sure you that you have downloaded and installed the HP client components for HP QC (" + exception.Message + ")", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }