Example #1
0
        /// <summary>
        /// Converts an array of instances from webservice proxy type to this type.
        /// </summary>
        /// <param name="issuesData">Issues data in webservice proxy type.</param>
        /// <returns>The array converted to this type.</returns>
		internal static Issue[] ConvertArray(MantisConnectWebservice.IssueData[] issuesData)
		{
            if (issuesData == null)
            {
                return null;
            }

			Issue[] issues = new Issue[issuesData.Length];

            for (int i = 0; i < issuesData.Length; ++i)
            {
                issues[i] = new Issue(issuesData[i]);
            }

			return issues;
		}
Example #2
0
        /// <summary>
        /// Event handler for clicking the submit button.
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">not used</param>
        private void submitButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                string attachment = this.attachmentTextBox.Text;

                if (attachment.Length > 0 && !File.Exists(attachment))
                {
                    MessageBox.Show(String.Format("File '{0}' doesn't exist", attachment));
                    return;
                }

                statusBar.Panels[0].Text = "Checking if issue already reported...";

                // Check if issue was previously logged in Mantis.
                int issueId = session.Request.IssueGetIdFromSummary( summaryTextBox.Text );
                if ( issueId > 0 )
                {
                    statusBar.Panels[0].Text = string.Format( "'{0}' already reported in issue {1}", summaryTextBox.Text, issueId );
                    return;
                }

                // Create the issue in memory
                Issue issue = new Issue();

                issue.Project = new ObjectRef(treeView1.SelectedNode.Index);
                issue.Priority = new ObjectRef( priorityComboBox.Text );
                issue.Severity = new ObjectRef( severityComboBox.Text );
                issue.Reproducibility = new ObjectRef( reproducibilityComboBox.Text );
                issue.Category = new ObjectRef( categoryComboBox.Text );
                issue.ProductVersion = versionComboBox.Text;
                issue.Summary = summaryTextBox.Text;
                issue.Description = descriptionTextBox.Text;
                issue.ReportedBy = new User();
                issue.ReportedBy.Name = session.Username;

                statusBar.Panels[0].Text = "Submitting issue...";

                int newIssueId = session.Request.IssueAdd( issue );

                statusBar.Panels[0].Text = String.Format("Submitting attachment to issue {0}...", newIssueId);

                if (attachment.Length > 0)
                {
                    session.Request.IssueAttachmentAdd(newIssueId, attachment, null);
                }

                // Submit the issue and show its id in the status bar
                statusBar.Panels[0].Text = string.Format("Issued added as {0}.", newIssueId);

                ResetForm();
            }
            catch( Exception ex )
            {
                MessageBox.Show( ex.ToString(), "Webservice Error", MessageBoxButtons.OK, MessageBoxIcon.Stop );
                statusBar.Text = string.Empty;
            }
        }
Example #3
0
        /// <summary>
        /// Validate the issue.
        /// </summary>
        /// <param name="issue">The issue, can't be null.</param>
        /// <exception cref="ArgumentNullException">The issue is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        private static void ValidateIssue(Issue issue)
        {
            if (issue == null)
            {
                throw new ArgumentNullException("issue");
            }

            if (issue.Summary == null)
            {
                throw new ArgumentNullException("issue.Summary");
            }

            if (issue.Summary.Trim().Length == 0)
            {
                throw new ArgumentOutOfRangeException("issue.Summary");
            }

            if (issue.Description == null)
            {
                throw new ArgumentNullException("issue.Description");
            }

            if (issue.Description.Trim().Length == 0)
            {
                throw new ArgumentOutOfRangeException("issue.Description");
            }

            if (issue.Notes != null)
            {
                foreach (IssueNote note in issue.Notes)
                {
                    ValidateIssueNote(note);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Add the specified issue to Mantis database.
        /// </summary>
        /// <param name="issue">The issue details.  Issue id is ignored.</param>
        /// <remarks>
        /// TODO: Consider a generic and easy way to time operations.
        /// </remarks>
        /// <returns>The id of the added issue</returns>
        public int IssueAdd(Issue issue)
        {
            ValidateIssue(issue);

            return Convert.ToInt32(this.mc.mc_issue_add(
                this.session.Username,
                this.session.Password,
                issue.ToWebservice()));
        }
Example #5
0
        /// <summary>
        /// Update an issue
        /// </summary>
        /// <param name="issue">The issue to be updated.</param>
        /// <returns>true: updated successfully; otherwise false</returns>
        public bool IssueUpdate(Issue issue)
        {
            ValidateIssue(issue);

            if (issue.Id < 1)
            {
                throw new Exception("Can not update issue. Issue ID does not exist");
            }

            return this.mc.mc_issue_update(
                this.session.Username,
                this.session.Password,
                issue.Id.ToString(),
                issue.ToWebservice());
        }