Esempio n. 1
0
        /// <summary>Creates the WCF endpoints</summary>
        /// <param name="fullUri">The URI</param>
        /// <returns>The client class</returns>
        /// <remarks>We need to do this in code because the app.config file is not available in VSTO</remarks>
        public static SpiraSoapService.SoapServiceClient CreateClient_Spira5(Uri baseUri)
        {
            Uri fullUri = new Uri(baseUri.ToString() + Common.SERVICE_SPIRA_5);

            BasicHttpBinding httpBinding = SpiraClientFactory.createBinding(fullUri.Scheme);

            //Create the new client with endpoint and HTTP Binding
            EndpointAddress endpointAddress = new EndpointAddress(fullUri.AbsoluteUri);

            SpiraSoapService.SoapServiceClient spiraSoapService = new SpiraSoapService.SoapServiceClient(httpBinding, endpointAddress);

            //Modify the operation behaviors to allow unlimited objects in the graph
            foreach (var operation in spiraSoapService.Endpoint.Contract.Operations)
            {
                var behavior = operation.Behaviors.Find <DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
                if (behavior != null)
                {
                    behavior.MaxItemsInObjectGraph = 2147483647;
                }
            }
            return(spiraSoapService);
        }
        /// <summary>Tests the importer's password.</summary>
        /// <param name="sender">Button</param>
        /// <param name="e">RoutedEventArgs</param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //Hide the controls..
            this.divTesting.Cursor     = Cursors.Wait;
            this.divTesting.Visibility = System.Windows.Visibility.Visible;
            this.txtTesting.Text       = "Testing.";
            this.txtTesting.Foreground = Brushes.Black;
            this.spnSpinner.Visibility = System.Windows.Visibility.Visible;
            this.divTesting.MouseDown -= divTesting_MouseDown;



            SoapServiceClient client = SpiraClientFactory.CreateClient_Spira5(this.serverUrl);

            client.Connection_Authenticate2Completed    += client_Connection_Authenticate2Completed;
            client.Project_RetrieveCompleted            += client_Project_RetrieveCompleted;
            client.Connection_ConnectToProjectCompleted += client_Connection_ConnectToProjectCompleted;
            client.User_CreateCompleted += client_User_CreateCompleted;
            client.User_DeleteCompleted += client_User_DeleteCompleted;

            //Now connect..
            client.Connection_Authenticate2Async(this.serverUser, this.serverPass, Common.APP_NAME, client);
        }
Esempio n. 3
0
        /// <summary>Hit when the user clicks the 'next' button.</summary>
        /// <param name="sender">btnNext</param>
        /// <param name="e">RoutedEventArgs</param>
        private void onNextClick(object sender, RoutedEventArgs e)
        {
            const string METHOD = CLASS_NAME + "onNextClick()";

            //Depending on which page is displayed..
            switch (this._pageNo)
            {
            case 1:
            {
                try
                {
                    //Set the controls on the form..
                    this.grdForm.IsEnabled = false;
                    this.Cursor            = Cursors.Wait;
                    this.btnNext.IsEnabled = false;

                    //Try to connect to the server.
                    SoapServiceClient client = SpiraClientFactory.CreateClient_Spira5(new Uri(this._page1.SelectedServerURL, UriKind.Absolute));
                    client.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(client_Connection_Authenticate2Completed);
                    client.Connection_Authenticate2Async(Common.USER_NAME, this._page1.txtAdminPassword.Password, "ProjectExport");
                    Logger.LogTrace(METHOD, "Screen #1: Validating user input.");
                }
                catch (Exception ex)
                {
                    string msg = ((ex.InnerException != null) ? ex.InnerException.Message : ex.Message);
                    MessageBox.Show("There was an error connecting to the server:" + Environment.NewLine + msg, "Server Unavailable", MessageBoxButton.OK, MessageBoxImage.Error);

                    this.grdForm.IsEnabled = true;
                    this.Cursor            = Cursors.Arrow;
                    this.btnNext.IsEnabled = true;
                }
            }
            break;

            case 2:
            {
                //No checking needed, we move on..
                //Advance the page.
                this.btnNext.IsEnabled = true;
                this._pageNo           = 3;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page3);
                this._page3.setServerLogin(new Uri(this._page1.SelectedServerURL), Common.USER_NAME, this._page1.SelectedPassword);
                Logger.LogTrace(METHOD, "Screen #2: Moved to screen #3.");
            }
            break;

            case 3:
            {
                //No checking needed, we move on..
                //Advance the page.
                this.btnNext.IsEnabled = false;
                this._pageNo           = 4;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page4);
                Logger.LogTrace(METHOD, "Screen #3: Moved to screen #4.");
            }
            break;

            case 4:
            {
                //No checking needed, we move on..
                //Advance the page.
                this.btnNext.IsEnabled = false;
                this._pageNo           = 5;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page5);
                this._page5.setInformation(System.IO.Path.GetFileName(this._page4.SelectedFile), this._page2.SelectedProjectName, this._page3.SelectedUserPass);
                Logger.LogTrace(METHOD, "Screen #3: Moved to screen #4.");
            }
            break;

            case 5:
            {
                //The confirmed they want to continue. Start exporting.
                this._pageNo = 6;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page6);
                Logger.LogTrace(METHOD, "Screen #5: Moved to screen #6.");

                this._page6.setConnectionInfo(
                    this._page2.SelectedProjectName,
                    this._page1.SelectedPassword,
                    this._page4.SelectedFile,
                    new Uri(this._page1.SelectedServerURL),
                    this._page3.SelectedUserPass);

                //Disable Back button.
                this.btnBack.IsEnabled   = false;
                this.btnCancel.IsEnabled = false;
                this.btnNext.IsEnabled   = false;
            }
            break;

            case 6:
            {
                //Close the window.
                this.Close();
            }
            break;
            }
        }
Esempio n. 4
0
        /// <summary>Hit when the user clicks the 'next' button.</summary>
        /// <param name="sender">btnNext</param>
        /// <param name="e">RoutedEventArgs</param>
        private void onNextClick(object sender, RoutedEventArgs e)
        {
            const string METHOD = CLASS_NAME + "onNextClick()";

            //Depending on which page is displayed..
            switch (this._pageNo)
            {
            case 1:
            {
                try
                {
                    //Set the controls on the form..
                    this.grdForm.IsEnabled = false;
                    this.Cursor            = Cursors.Wait;
                    this.btnNext.IsEnabled = false;

                    //Try to connect to the server.
                    SoapServiceClient client1 = SpiraClientFactory.CreateClient_Spira5(new Uri(this._page1.SelectedServerURL, UriKind.Absolute));
                    client1.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(client1_Connection_Authenticate2Completed);
                    client1.Connection_Authenticate2Async("administrator", this._page1.txtAdminPassword.Text, "ProjectExport");
                    Logger.LogTrace(METHOD, "Screen #1: Validating user input.");
                }
                catch (Exception ex)
                {
                    string msg = ((ex.InnerException != null) ? ex.InnerException.Message : ex.Message);
                    MessageBox.Show("There was an error connecting to the server:" + Environment.NewLine + msg, "Server Unavailable", MessageBoxButton.OK, MessageBoxImage.Error);

                    this.grdForm.IsEnabled = true;
                    this.Cursor            = Cursors.Arrow;
                    this.btnNext.IsEnabled = true;
                }
            }
            break;

            case 2:
            {
                //No checking needed, we move on..
                //Advance the page.
                this.btnNext.IsEnabled = false;
                this._pageNo           = 3;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page3);
                Logger.LogTrace(METHOD, "Screen #2: Moved to screen #3.");
            }
            break;

            case 3:
            {
                try
                {
                    //Set the controls on the form..
                    this.grdForm.IsEnabled = false;
                    this.Cursor            = Cursors.Wait;
                    this.btnNext.IsEnabled = false;

                    //Check that the server is not the same as the input..
                    Uri  server1      = new Uri(this._page1.SelectedServerURL);
                    Uri  server2      = new Uri(this._page3.SelectedServerURL);
                    bool server1Local = (server1.Host.ToLowerInvariant().Trim() == "localhost" || server1.Host.ToLowerInvariant().Trim() == "127.0.0.1");
                    bool server2Local = (server2.Host.ToLowerInvariant().Trim() == "localhost" || server2.Host.ToLowerInvariant().Trim() == "127.0.0.1");
                    if (!server1.Equals(server2) && (!server1Local || !server2Local))
                    {
                        //Try to connect to the server.
                        SoapServiceClient client2 = SpiraClientFactory.CreateClient_Spira5(new Uri(this._page3.SelectedServerURL, UriKind.Absolute));
                        client2.Connection_Authenticate2Completed += new EventHandler <Connection_Authenticate2CompletedEventArgs>(client2_Connection_Authenticate2Completed);
                        client2.Connection_Authenticate2Async(Common.USER_NAME, this._page3.txtAdminPassword.Text, Common.APP_NAME);
                        Logger.LogTrace(METHOD, "Screen #3: Validating user input.");
                    }
                    else
                    {
                        MessageBox.Show("Both your import and export servers are the same. If importing and exporting to the same server, we recommend you use the Project copy feature in Administration.", "Same Host", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                        //Rest form.
                        this.grdForm.IsEnabled = true;
                        this.Cursor            = Cursors.Arrow;
                        this.btnNext.IsEnabled = true;
                    }
                }
                catch (Exception ex)
                {
                    string msg = ((ex.InnerException != null) ? ex.InnerException.Message : ex.Message);
                    MessageBox.Show("There was an error connecting to the server:" + Environment.NewLine + msg, "Server Unavailable", MessageBoxButton.OK, MessageBoxImage.Error);

                    this.grdForm.IsEnabled = true;
                    this.Cursor            = Cursors.Arrow;
                    this.btnNext.IsEnabled = true;
                }
            }
            break;

            case 4:
            {
                //No checking needed, we move on..
                //Advance the page.
                this.btnNext.IsEnabled = true;
                this._pageNo           = 5;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page5);
                this._page5.setServerLogin(new Uri(this._page3.SelectedServerURL), Common.USER_NAME, this._page3.SelectedPassword);
                Logger.LogTrace(METHOD, "Screen #4: Moved to screen #5.");
            }
            break;

            case 5:
            {
                //Entered in project name, show summary screen.
                this._pageNo = 6;
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page6);
                Logger.LogTrace(METHOD, "Screen #5: Moved to screen #6.");

                //Generate the URLs, so we can parse them..
                Uri server1 = new Uri(this._page1.SelectedServerURL);
                Uri server2 = new Uri(this._page3.SelectedServerURL);
                this._page6.setInformation(
                    this._page1.SelectedServerURL,
                    this._page2.SelectedProject.Name + " [PR:" + this._page2.SelectedProject.ProjectId.Value.ToString() + "]",
                    this._page3.SelectedServerURL,
                    this._page4.SelectedProjectName);

                //Set controls.
                this.btnBack.IsEnabled   = true;
                this.btnCancel.IsEnabled = true;
                this.btnNext.IsEnabled   = true;
            }
            break;

            case 6:
            {
                //The confirmed they want to continue. Start exporting.
                this.grdContent.Children.Clear();
                this.grdContent.Children.Add(this._page7);
                Logger.LogTrace(METHOD, "Screen #6: Moved to screen #7.");
                this._pageNo = 7;

                //Start export.
                this._page7.setConnectionInfo(this._page2.SelectedProject, this._page1.SelectedPassword, new Uri(this._page1.SelectedServerURL));

                //Disable Back button.
                this.btnBack.IsEnabled   = false;
                this.btnCancel.IsEnabled = false;
                this.btnNext.IsEnabled   = false;
            }
            break;

            case 7:
            {
                //Only close if the Export threw an error.
                if (this._page7.isError)
                {
                    this.Close();
                }
            }
            break;

            case 8:
            {
                //Close the window.
                this.Close();
            }
            break;
            }
        }