Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Issue"/> class.
        /// </summary>
        /// <param name="issueData">
        /// Issue data from Webservice proxy.
        /// </param>
        internal Issue(MantisConnectWebservice.IssueData issueData)
        {
            this.Id                    = Convert.ToInt32(issueData.id);
            this.Project               = new ObjectRef(issueData.project);
            this.Category              = new ObjectRef(issueData.category);
            this.Summary               = issueData.summary;
            this.Description           = StringUtils.WebserviceMultilineToNative(issueData.description);
            this.StepsToReproduce      = issueData.steps_to_reproduce == null ? String.Empty : StringUtils.WebserviceMultilineToNative(issueData.steps_to_reproduce);
            this.AdditionalInformation = issueData.additional_information == null ? String.Empty : StringUtils.WebserviceMultilineToNative(issueData.additional_information);
            this.AssignedTo            = issueData.handler == null ? null : new User(issueData.handler);
            this.ReportedBy            = new User(issueData.reporter);
            this.ProductVersion        = issueData.version == null ? String.Empty : issueData.version;
            this.ProductBuild          = issueData.build == null ? String.Empty : issueData.build;
            this.Os                    = issueData.os == null ? String.Empty : issueData.os;
            this.OsBuild               = issueData.os_build == null ? String.Empty : issueData.os_build;
            this.Platform              = issueData.platform == null ? String.Empty : issueData.platform;
            this.FixedInVersion        = issueData.fixed_in_version == null ? String.Empty : issueData.fixed_in_version;
            this.SponsorshipTotal      = Convert.ToInt32(issueData.sponsorship_total);
            this.Reproducibility       = new ObjectRef(issueData.reproducibility);
            this.Resolution            = new ObjectRef(issueData.resolution);
            this.Eta                   = new ObjectRef(issueData.eta);
            this.Status                = new ObjectRef(issueData.status);
            this.Priority              = new ObjectRef(issueData.priority);
            this.Severity              = new ObjectRef(issueData.severity);
            this.Projection            = new ObjectRef(issueData.projection);
            this.ViewState             = new ObjectRef(issueData.view_state);

            this.Notes         = IssueNote.ConvertArray(issueData.notes);
            this.Attachments   = Attachment.ConvertArray(issueData.attachments);
            this.Relationships = IssueRelationship.ConvertArray(issueData.relationships);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a note to the specified issue.
        /// </summary>
        /// <param name="issueId">
        /// Issue id to add note to.
        /// </param>
        /// <param name="note">
        /// The note to add
        /// </param>
        /// <remarks>
        /// The user must have write access to the issue and the issue must
        /// not be readonly.
        /// </remarks>
        /// <returns>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// Note is null
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The issue id is 0 or negative. Or note is empty or blank.
        /// </exception>
        public int IssueNoteAdd(int issueId, IssueNote note)
        {
            ValidateIssueId(issueId);
            ValidateIssueNote(note);

            return(Convert.ToInt32(this.mc.mc_issue_note_add(
                                       this.session.Username,
                                       this.session.Password,
                                       issueId.ToString(CultureInfo.InvariantCulture),
                                       note.ToWebservice())));
        }
Esempio n. 3
0
        /// <summary>
        /// A static method that converts an array of issue notes from webservice proxy format to an
        /// array of <see cref="IssueNote"/>
        /// </summary>
        /// <param name="issueNotesData">
        /// An array of issue notes in webservice proxy format.
        /// </param>
        /// <returns>
        /// An array of <see cref="IssueNote"/>.
        /// </returns>
        internal static IssueNote[] ConvertArray(MantisConnectWebservice.IssueNoteData[] issueNotesData)
        {
            if (issueNotesData == null)
            {
                return(new IssueNote[0]);
            }

            IssueNote[] notes = new IssueNote[issueNotesData.Length];

            for (int i = 0; i < issueNotesData.Length; ++i)
            {
                notes[i] = new IssueNote(issueNotesData[i]);
            }

            return(notes);
        }
Esempio n. 4
0
        /// <summary>
        /// Validates an issue note and raises an exception if it is not valid.
        /// </summary>
        /// <param name="note">
        /// The note to be validated
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The issue note is null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The note is invalid.
        /// </exception>
        private static void ValidateIssueNote(IssueNote note)
        {
            if (note == null)
            {
                throw new ArgumentNullException("note");
            }

            if (note.Text == null)
            {
                throw new ArgumentNullException("note.Text");
            }

            if (note.Text.Trim().Length == 0)
            {
                throw new ArgumentOutOfRangeException("note");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Convert this instance to the type supported by the webservice proxy.
        /// </summary>
        /// <returns>
        /// A copy of this instance in the webservice proxy type.
        /// </returns>
        internal MantisConnectWebservice.IssueData ToWebservice()
        {
            MantisConnectWebservice.IssueData issueData = new MantisConnectWebservice.IssueData();

            issueData.id                     = this.Id.ToString();
            issueData.category               = this.Category.Name;
            issueData.summary                = this.Summary;
            issueData.description            = StringUtils.NativeMultilineToWebservice(this.Description);
            issueData.additional_information = StringUtils.NativeMultilineToWebservice(this.AdditionalInformation);
            issueData.steps_to_reproduce     = StringUtils.NativeMultilineToWebservice(this.StepsToReproduce);
            issueData.build                  = this.ProductBuild;
            issueData.version                = this.ProductVersion;
            issueData.os                     = this.Os;
            issueData.os_build               = this.OsBuild;
            issueData.platform               = this.Platform;
            issueData.sponsorship_total      = this.SponsorshipTotal.ToString();
            issueData.fixed_in_version       = this.FixedInVersion;
            issueData.view_state             = this.ViewState.ToWebservice();
            issueData.projection             = this.Projection.ToWebservice();
            issueData.eta                    = this.Eta.ToWebservice();
            issueData.priority               = this.Priority.ToWebservice();
            issueData.severity               = this.Severity.ToWebservice();
            issueData.project                = this.Project.ToWebservice();
            issueData.reproducibility        = this.Reproducibility.ToWebservice();
            issueData.resolution             = this.Resolution.ToWebservice();
            issueData.status                 = this.Status.ToWebservice();
            issueData.reporter               = this.ReportedBy.ToWebservice();
            issueData.handler                = this.AssignedTo == null ? null : this.AssignedTo.ToWebservice();
            issueData.date_submitted         = this.dateSubmitted;
            issueData.last_updated           = this.lastUpdated;

            issueData.notes = IssueNote.ConvertArrayToWebservice(this.Notes);

            // TODO: Attachments
            // TODO: Relationships

            return(issueData);
        }