Beispiel #1
0
        async private Task onAddCommentAsync()
        {
            string caption = String.Format("Add comment to merge request \"{0}\"",
                                           _workflow.State.MergeRequest.Title);

            using (NewDiscussionItemForm form = new NewDiscussionItemForm(caption))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (form.Body.Length == 0)
                    {
                        MessageBox.Show("Comment body cannot be empty", "Warning",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    DiscussionCreator creator =
                        _discussionManager.GetDiscussionCreator(_workflow.State.MergeRequestDescriptor);

                    labelWorkflowStatus.Text = "Adding a comment...";
                    await creator.CreateNoteAsync(new CreateNewNoteParameters { Body = form.Body });

                    labelWorkflowStatus.Text = "Comment added";
                }
            }
        }
Beispiel #2
0
        private static void submitDiscussion(Snapshot snapshot, DiffToolInfo diffToolInfo, DiffPosition position,
                                             string body, bool includeContext)
        {
            if (body.Length == 0)
            {
                MessageBox.Show("Discussion text cannot be empty", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            NewDiscussionParameters parameters = new NewDiscussionParameters
            {
                Body     = body,
                Position = includeContext ? createPositionParameters(position) : new Nullable <PositionParameters>()
            };

            MergeRequestDescriptor mergeRequestDescriptor = new MergeRequestDescriptor
            {
                HostName    = snapshot.Host,
                ProjectName = snapshot.Project,
                IId         = snapshot.MergeRequestIId
            };

            UserDefinedSettings settings = new UserDefinedSettings(false);
            DiscussionManager   manager  = new DiscussionManager(settings);
            DiscussionCreator   creator  = manager.GetDiscussionCreator(mergeRequestDescriptor);

            try
            {
                creator.CreateDiscussionAsync(parameters).Wait();
            }
            catch (DiscussionCreatorException ex)
            {
                Trace.TraceInformation(
                    "Additional information about exception:\n" +
                    "Position: {0}\n" +
                    "Include context: {1}\n" +
                    "Snapshot refs: {2}\n" +
                    "DiffToolInfo: {3}\n" +
                    "Body:\n{4}",
                    position.ToString(),
                    includeContext.ToString(),
                    snapshot.Refs.ToString(),
                    diffToolInfo.ToString(),
                    body);

                if (!ex.Handled)
                {
                    throw;
                }
            }
        }