internal void setSolution(string solName)
        {
            try
            {
                //We have the solution name, load up the projects associated, and remove them from the available.
                this._solName = solName;
                if (!string.IsNullOrEmpty(this._solName))
                {
                    this._solName = this._solName.Replace(' ', '_');

                    this.lstSelectProjects.Items.Clear();
                    string strProjs = this._Settings.GetValue(this._solName, "Projects");
                    if (!string.IsNullOrEmpty(strProjs))
                    {
                        foreach (string strProj in strProjs.Split(Connect.SpiraProject.CHAR_RECORD))
                        {
                            Connect.SpiraProject Project = Connect.SpiraProject.GenerateFromString(strProj);
                            this.lstSelectProjects.Items.Add(Project);
                        }
                        //remove dupliates.
                        this.removeDuplicates();
                    }
                    this.lstSelectProjects.IsEnabled = true;
                }
                this.setRTFCaption();
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfAssignProject::setSolution", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }
        /// <summary>Loads the specified incident into the form, handling all client creation and UI updates. Entry point for loading new item.</summary>
        /// <param name="inProject">SpiraProject associated with this artifact.</param>
        /// <param name="itemKey">Item key for this artifact. ex: "IN:1234"</param>
        /// <returns>False.</returns>
        internal bool loadItem(Connect.SpiraProject inProject, string itemKey)
        {
            try
            {
                this.lblItemTag.Content = itemKey;

                //Hide the form, show the "I'm loading.." bar.
                this.panelForm.Visibility         = Visibility.Collapsed;
                this.panelLoading.Visibility      = Visibility.Visible;
                this.panelLoadingError.Visibility = Visibility.Collapsed;
                this.msgLoadingErrorMsg.Text      = "";
                //Verify we have an item and project to load.
                if (inProject != null)
                {
                    this._Project = inProject;
                }
                this._itemCode = itemKey;

                //Call the real load function.
                this.loadItem_Incident();
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfDetailsIncident::loadItem", ex, System.Diagnostics.EventLogEntryType.Error);
            }
            return(false);
        }
Example #3
0
        /// <summary>Loads the specified task into the display form.</summary>
        /// <param name="TaskTag">Item tag, like "TK:1234".</param>
        /// <param name="Project">SpiraProject for details on this project.</param>
        internal void LoadRequirement(Inflectra.SpiraTest.IDEIntegration.VisualStudio.Connect.SpiraProject Project, string TaskTag)
        {
            try
            {
                //Set display
                this.panelForm.Visibility         = Visibility.Collapsed;
                this.panelLoading.Visibility      = Visibility.Visible;
                this.panelLoadingError.Visibility = Visibility.Collapsed;

                //Set vaiables.
                this._ItemTag           = TaskTag;
                this.lblItemTag.Content = this._ItemTag;
                this._Project           = Project;

                //Call loading function.
                this.LoadItem_Requirement();
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfDetailsRequirement::LoadRequirement", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }
        internal void setSettings(Connect.SettingsClass.XMLFileReader Settings)
        {
            try
            {
                this._Settings = Settings;

                //We have the file, load up all avaiable projects already defined.
                this._Projects = new List <Connect.SpiraProject>();
                string strProjs = this._Settings.GetValue("General", "Projects");
                if (!string.IsNullOrEmpty(strProjs))
                {
                    foreach (string strProj in strProjs.Split(Connect.SpiraProject.CHAR_RECORD))
                    {
                        Connect.SpiraProject Project = Connect.SpiraProject.GenerateFromString(strProj);
                        this._Projects.Add(Project);
                        this.lstAvailProjects.Items.Add(Project);
                    }
                }
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfAssignProject::setSettings", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }
        /// <summary>Hit when the user wants to add/edit a serverproject.</summary>
        /// <param name="sender">btnNew / btnEdit</param>
        /// <param name="e">Event Args</param>
        void btnNewEdit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button button = (Button)sender;

                //Create the form.
                wpfNewSpiraProject frmAddProject = new wpfNewSpiraProject();

                if (button.Name == "btnEdit")
                {
                    //Get the item selected.
                    Connect.SpiraProject proj = (Connect.SpiraProject) this.lstAvailProjects.SelectedItem;
                    frmAddProject.txbServer.Text       = proj.ServerURL.AbsoluteUri;
                    frmAddProject.txbUserID.Text       = proj.UserName;
                    frmAddProject.txbUserPass.Password = proj.UserPass;
                    int projnum = frmAddProject.cmbProjectList.Items.Add(proj);
                    frmAddProject.cmbProjectList.SelectedIndex = projnum;
                }

                if (frmAddProject.ShowDialog().Value)
                {
                    if (frmAddProject.cmbProjectList.SelectedItem != null)
                    {
                        Connect.SpiraProject selProject = (Connect.SpiraProject)frmAddProject.cmbProjectList.SelectedItem;

                        //Add it to the available list if there's no existing ones.
                        bool AddToSelected = false;
                        for (int i = 0; i < this.lstAvailProjects.Items.Count;)
                        {
                            if (((Connect.SpiraProject) this.lstAvailProjects.Items[i]).IsEqualTo(selProject))
                            {
                                this.lstAvailProjects.Items.RemoveAt(i);
                            }
                            else
                            {
                                i++;
                            }
                        }
                        for (int i = 0; i < this.lstSelectProjects.Items.Count;)
                        {
                            if (((Connect.SpiraProject) this.lstSelectProjects.Items[i]).IsEqualTo(selProject))
                            {
                                this.lstSelectProjects.Items.RemoveAt(i);
                                AddToSelected = true;
                            }
                            else
                            {
                                i++;
                            }
                        }

                        if (AddToSelected)
                        {
                            this.lstSelectProjects.Items.Add(selProject);
                        }
                        else
                        {
                            this.lstAvailProjects.Items.Add(selProject);
                        }
                    }
                    this.hasChanged = true;
                }
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfAssignProject::btnNewEdit_Click", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }
        /// <summary>Called when the client finished a piece of work.</summary>
        /// <param name="sender">The client.</param>
        /// <param name="e">EventArgs</param>
        void client_ActionCompleted(object sender, EventArgs e)
        {
            try
            {
                if (e.GetType() == typeof(Connection_Authenticate2CompletedEventArgs))
                {
                    Connection_Authenticate2CompletedEventArgs evt = (Connection_Authenticate2CompletedEventArgs)e;
                    if (evt.Error == null)
                    {
                        this.txtStatus.Text = "Getting user information...";
                        this._client.User_RetrieveByUserNameAsync(this.txbUserID.Text);
                    }
                    else
                    {
                        this.btnConnect_Click(null, null);
                        //Just act like they canceled the service, then set error flag.
                        this.barProg.Foreground = System.Windows.Media.Brushes.Red;
                        this.barProg.Value      = 1;
                        this.txtStatus.Text     = "Could not connect!";
                        this.txtStatus.ToolTip  = evt.Error.Message;
                    }
                }
                else if (e.GetType() == typeof(User_RetrieveByUserNameCompletedEventArgs))
                {
                    User_RetrieveByUserNameCompletedEventArgs evt = (User_RetrieveByUserNameCompletedEventArgs)e;
                    if (evt.Error == null)
                    {
                        this.txtStatus.Text  = "Getting Projects...";
                        this.txbUserNum.Text = evt.Result.UserId.ToString();
                        this._client.Project_RetrieveAsync();
                    }
                    else
                    {
                        this.btnConnect_Click(null, null);
                        //Just act like they canceled the service, then set error flag.
                        this.barProg.Foreground = System.Windows.Media.Brushes.Red;
                        this.barProg.Value      = 1;
                        this.txtStatus.Text     = "Could not get user info.";
                        this.txtStatus.ToolTip  = evt.Error.Message;
                    }
                }
                else if (e.GetType() == typeof(Spira_ImportExport.Project_RetrieveCompletedEventArgs))
                {
                    Project_RetrieveCompletedEventArgs evt = (Project_RetrieveCompletedEventArgs)e;
                    if (evt.Error == null)
                    {
                        this.cmbProjectList.Items.Clear();
                        //Load projects here.
                        if (evt.Result.Length > 0)
                        {
                            foreach (RemoteProject RemoteProj in evt.Result)
                            {
                                Connect.SpiraProject Project = new Connect.SpiraProject();
                                Project.ProjectID = RemoteProj.ProjectId.Value;
                                Project.ServerURL = new Uri(this.txbServer.Text);
                                Project.UserName  = this.txbUserID.Text;
                                Project.UserPass  = this.txbUserPass.Password;
                                Project.UserID    = int.Parse(this.txbUserNum.Text);

                                this.cmbProjectList.Items.Add(Project);
                            }
                            this.cmbProjectList.SelectedIndex = 0;
                            this.grdAvailProjs.IsEnabled      = true;
                            this.grdEntry.IsEnabled           = true;
                            this.barProg.IsIndeterminate      = false;
                            this.barProg.Value      = 0;
                            this.btnConnect.Content = "_Get Projects";
                            this.btnConnect.Tag     = false;
                            this.txtStatus.Text     = "";
                            this.txtStatus.ToolTip  = null;
                        }
                        else
                        {
                            int num = this.cmbProjectList.Items.Add("-- No Projects Available --");
                            this.cmbProjectList.SelectedIndex = num;
                            //Reset form.
                            this.grdEntry.IsEnabled      = true;
                            this.barProg.IsIndeterminate = false;
                            this.btnConnect.Content      = "_Get Projects";
                            this.btnConnect.Tag          = false;
                        }
                    }
                    else
                    {
                        this.btnConnect_Click(null, null);
                        //Just act like they canceled the service, then set error flag.
                        this.barProg.Foreground = System.Windows.Media.Brushes.Red;
                        this.barProg.Value      = 1;
                        this.txtStatus.Text     = "Could not get projects.";
                        this.txtStatus.ToolTip  = evt.Error.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfNewSpiraProject::client_ActionCompleted", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }