Esempio n. 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="filterData"></param>
 internal Filter( MantisConnectWebservice.FilterData filterData )
 {
     this.id = Convert.ToInt32( filterData.id );
     this.owner = new User( filterData.owner );
     this.projectId = Convert.ToInt32( filterData.project_id );
     this.isPublic = filterData.is_public;
     this.name = filterData.name;
     this.filterString = filterData.filter_string;
 }
Esempio n. 2
0
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            Settings settings = Settings.Default;
            MantisData data = MantisService.Data;
            Session session = MantisService.MantisSession;

            // Validating
            if (ProjectComboBox.SelectedItem == null ||
                CategoryComboBox.SelectedItem == null ||
                PriorityComboBox.SelectedItem == null ||
                EtaComboBox.SelectedItem == null ||
                SeverityComboBox.SelectedItem == null ||
                ReproducibilityComboBox.SelectedItem == null ||
                String.IsNullOrEmpty(SummaryTextBox.Text) ||
                String.IsNullOrEmpty(DescriptionTextBox.Text))
            {
                MessageBox.Show("You must fill every required fields.", App.Current.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            // Get issue properties
            int? issueId = null;
            string summary = SummaryTextBox.Text;
            string project = (string)ProjectComboBox.SelectedItem;
            string severity = (string)SeverityComboBox.SelectedItem;
            string priority = (string)PriorityComboBox.SelectedItem;
            string reproducibility = (string)ReproducibilityComboBox.SelectedItem;
            string eta = (string)EtaComboBox.SelectedItem;
            string category = (string)CategoryComboBox.SelectedItem;
            string productVersion = (string)ProductVersionComboBox.SelectedItem;
            string targetVersion = (string)TargetVersionComboBox.SelectedItem;
            string description = DescriptionTextBox.Text;
            string comment = CommentTextBox.Text;
            string assignedToString = (string)AssignedToComboBox.SelectedItem;
            User assignedTo;
            if (String.IsNullOrEmpty(assignedToString))
                assignedTo = new User { Id = 0, Name = "", Email = "", RealName = "" };
            else
                assignedTo = data.Users[project].Single(w => w.Name == (string)AssignedToComboBox.SelectedItem);
            Controls.Attachment[] attachments = Attachments.Items.OfType<Controls.Attachment>().ToArray();

            // Set last properties
            settings.LastProject = project;
            settings.LastCategory = category;
            settings.LastProductVersion = productVersion;
            settings.LastTargetVersion = targetVersion;
            settings.LastSeverity = severity;
            settings.LastReproducibility = reproducibility;
            settings.Save();

            // Clear form fields
            SummaryTextBox.Text = "";
            DescriptionTextBox.Text = "";
            CommentTextBox.Text = "";
            Attachments.ClearWithAnimation();

            BackgroundWorkerService.EnqueueTask("Submitting issue", (param) =>
            {
                Issue issue = new Issue();

                issue.Summary = summary;
                issue.Project = new ObjectRef(project);
                issue.Priority = new ObjectRef(priority);
                issue.Severity = new ObjectRef(severity);
                issue.Reproducibility = new ObjectRef(reproducibility);
                issue.Eta = new ObjectRef(eta);
                issue.Category = new ObjectRef(category);
                issue.ProductVersion = productVersion;
                issue.TargetVersion = targetVersion;
                issue.Description = description;
                issue.AssignedTo = assignedTo;
                issue.ReportedBy = new User { Name = session.Username, };

                issueId = session.Request.IssueAdd(issue);
            });
            BackgroundWorkerService.EnqueueTask("Submitting issue note", (param) =>
            {
                if (!String.IsNullOrEmpty(comment) && issueId.HasValue)
                {
                    IssueNote issueNote = new IssueNote();
                    issueNote.Author = new User { Name = session.Username, };
                    issueNote.Text = comment;

                    session.Request.IssueNoteAdd(issueId.Value, issueNote);
                }
            });
            foreach (Controls.Attachment attachment in attachments)
            {
                BackgroundWorkerService.EnqueueTask("Submitting " + attachment.FileName, attachment, (param) =>
                {
                    Controls.Attachment currentAttachment = (Controls.Attachment)param;
                    if (issueId.HasValue)
                    {
                        session.Request.IssueAddFile(issueId.Value, currentAttachment.FileName, "application/octet-stream", currentAttachment.Data);
                    }
                });
            }
        }