예제 #1
0
        /// <summary>Starts the thread.</summary>
        public void StartProcess()
        {
            try
            {
                //Connect to the server, get
                Settings.SpiraClient.SoapServiceClient client = Settings.ClientFactory.CreateClient_Spira(new Uri(this._serverURL + "/" + ClientFactory.SPIRA_API));

                //Log in..
                if (client.Connection_Authenticate2(this._userName, this._userPass, Common.APP_NAME))
                {
                    //Okay, try to get the list of project.
                    List <RemoteProject> projs = client.Project_Retrieve();

                    //Got projects? Return 'em!
                    if (this.ProgressFinished != null)
                    {
                        this.ProgressFinished(this, new SpiraFinishArgs(projs));
                    }
                }
                else
                {
                    if (this.ProgressFinished != null)
                    {
                        this.ProgressFinished(this, new SpiraFinishArgs(new Exception("Could not log in with username and password!")));
                    }
                }
            }
            catch (Exception ex)
            {
                if (this.ProgressFinished != null)
                {
                    this.ProgressFinished(this, new SpiraFinishArgs(new Exception("Could not connect to the server. Check your settings and try again.", ex)));
                }
            }
        }
예제 #2
0
        /// <summary>Creates and returns a WSDL client for the given application system. Will try to connect and log on and select project if applicable. If any fails, an exception will be thrown.</summary>
        /// <param name="applicationSystem">The application system definition.</param>
        /// <returns>A client, as a dynamic type.</returns>
        private dynamic CreateApplicationClient(ApplicationSystem applicationSystem, AccountDetails emailSystem)
        {
            const string METHOD = CLASS + "CreateApplicationClient()";

            _eventLog.EntryLog(METHOD);

            //Create our application server.
            dynamic clientApp;

            if (applicationSystem.ServerType == ApplicationSystem.ApplServerTypeEnum.Spira)
            {
                //Create the client.
                clientApp = ClientFactory.CreateClient_Spira(new Uri(applicationSystem.ServerAPIUrl));

                //Connect.
                _eventLog.WriteTrace(METHOD, "Logging into Spira Client.");
                Settings.SpiraClient.SoapServiceClient spiraClient = (Settings.SpiraClient.SoapServiceClient)clientApp;
                if (spiraClient.Connection_Authenticate2(applicationSystem.UserID, applicationSystem.UserPassword, Common.APP_NAME))
                {
                    _eventLog.WriteTrace(METHOD, "Selecting project in Spira Client.");
                    if (emailSystem.ProductOrProjectId.HasValue && spiraClient.Connection_ConnectToProject(emailSystem.ProductOrProjectId.Value))
                    {
                        //We're successful.
                    }
                    else
                    {
                        throw new Exception("Could not log into project #" + emailSystem.ProductOrProjectId.Value.ToSafeString());
                    }
                }
                else
                {
                    throw new Exception("Could not log into server.");
                }
            }
            else
            {
                //Create the client.
                clientApp = ClientFactory.CreateClient_Krono(new Uri(applicationSystem.ServerAPIUrl));

                //Connect.
                _eventLog.WriteTrace(METHOD, "Logging into Krono Client.");
                Settings.KronoClient.SoapServiceClient kronoClient = (Settings.KronoClient.SoapServiceClient)clientApp;
                if (kronoClient.Connection_Authenticate(applicationSystem.UserID, applicationSystem.UserPassword, Common.APP_NAME, true))
                {
                }
                else
                {
                    throw new Exception("Could not log into server.");
                }
            }
            return(clientApp);
        }
        /// <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);
            }
        }