/// <summary>Hit when the user wants to test their connection to the server.</summary>
        /// <param name="sender">btnTest</param>
        /// <param name="e">RoutedEventArgs</param>
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            //Check that form is entered as necessary. Create background data class.
            this.lblTestResult.Content = null;
            if (this.checkForm())
            {
                //Create our background values class.
                bool isSpira   = (this.rdoSpira.IsChecked.HasValue && this.rdoSpira.IsChecked.Value);
                Uri  serverUri = new Uri(this.cmbHttps.Text + this.txtServerURL.Text.Trim() + "/" + ((isSpira) ? ClientFactory.SPIRA_API : ClientFactory.KRONO_API));
                btnTest_DoWorkArgs workArgs = new btnTest_DoWorkArgs(isSpira, serverUri, this.txtUserName.Text.Trim(), this.txtUserPass.Password);

                //Create background worker.
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork                    += this.btnTest_TestConnection;
                worker.ProgressChanged           += this.btnTest_ProgressChanged;
                worker.WorkerReportsProgress      = true;
                worker.WorkerSupportsCancellation = false;

                //Disable form..
                this.IsEnabled           = false;
                this.isBackgroundRunning = true;

                //Start thread.
                worker.RunWorkerAsync(workArgs);
            }
        }
        /// <summary>Hit when we're going to connect to the server.</summary>
        /// <param name="sender">BackgroundWorker</param>
        /// <param name="e">DoWorkEventArgs</param>
        private void btnTest_TestConnection(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker  = sender as BackgroundWorker;
            bool             success = false;

            if (e.Argument is btnTest_DoWorkArgs)
            {
                //Get our arguments.
                btnTest_DoWorkArgs workerArgs = (btnTest_DoWorkArgs)e.Argument;

                //Start the process..!
                worker.ReportProgress(0, "Connecting to server...");
                if (workerArgs.isSpira)
                {
                    try
                    {
                        //Create client.
                        Settings.SpiraClient.SoapServiceClient spiraClient = Settings.ClientFactory.CreateClient_Spira(workerArgs.serverUrl);

                        //Now try to sign in.
                        worker.ReportProgress(50, "Logging in...");
                        success = spiraClient.Connection_Authenticate2(workerArgs.loginId, workerArgs.loginPass, "EmailIntegration");
                    }
                    catch (Exception ex)
                    {
                        worker.ReportProgress(100, ex);
                        return;
                    }
                }
                else
                {
                    try
                    {
                        //reate client.
                        Settings.KronoClient.SoapServiceClient kronoClient = Settings.ClientFactory.CreateClient_Krono(workerArgs.serverUrl);

                        //Now try to sign in.
                        worker.ReportProgress(50, "Logging in...");
                        success = kronoClient.Connection_Authenticate(workerArgs.loginId, workerArgs.loginPass, "EmailIntegration", false);
                    }
                    catch (Exception ex)
                    {
                        worker.ReportProgress(100, ex);
                        return;
                    }
                }

                //Send result back to main thread.
                worker.ReportProgress(100, success);
            }
        }