Example #1
0
 async public Task DeleteNoteAsync(int noteId)
 {
     try
     {
         await DiscussionOperator.DeleteNoteAsync(MergeRequestDescriptor, noteId);
     }
     catch (OperatorException)
     {
         throw new DiscussionEditorException();
     }
 }
Example #2
0
 async public Task ResolveDiscussionAsync(bool resolved)
 {
     try
     {
         await DiscussionOperator.ResolveDiscussionAsync(MergeRequestDescriptor, DiscussionId, resolved);
     }
     catch (OperatorException)
     {
         throw new DiscussionEditorException();
     }
 }
Example #3
0
 async public Task ReplyAsync(string body)
 {
     try
     {
         await DiscussionOperator.ReplyAsync(MergeRequestDescriptor, DiscussionId, body);
     }
     catch (OperatorException)
     {
         throw new DiscussionEditorException();
     }
 }
Example #4
0
 async public Task ModifyNoteBodyAsync(int noteId, string body)
 {
     try
     {
         await DiscussionOperator.ModifyNoteBodyAsync(MergeRequestDescriptor, DiscussionId, noteId, body);
     }
     catch (OperatorException)
     {
         throw new DiscussionEditorException();
     }
 }
Example #5
0
 async public Task CreateNoteAsync(CreateNewNoteParameters parameters)
 {
     try
     {
         await DiscussionOperator.CreateNoteAsync(MergeRequestDescriptor, parameters);
     }
     catch (OperatorException)
     {
         throw new DiscussionCreatorException(false);
     }
 }
Example #6
0
 async public Task <Discussion> GetDiscussion()
 {
     try
     {
         return(await DiscussionOperator.GetDiscussionAsync(MergeRequestDescriptor, DiscussionId));
     }
     catch (OperatorException)
     {
         throw new DiscussionEditorException();
     }
 }
Example #7
0
 async public Task <List <Discussion> > GetDiscussionsAsync(MergeRequestDescriptor mrd)
 {
     try
     {
         return(await DiscussionOperator.GetDiscussionsAsync(mrd));
     }
     catch (OperatorException)
     {
         throw new DiscussionManagerException();
     }
 }
Example #8
0
        async public Task CreateDiscussionAsync(NewDiscussionParameters parameters)
        {
            try
            {
                await DiscussionOperator.CreateDiscussionAsync(MergeRequestDescriptor, parameters);
            }
            catch (OperatorException ex)
            {
                bool handled = await handleGitlabError(parameters, ex);

                throw new DiscussionCreatorException(handled);
            }
        }
Example #9
0
        async private Task <bool> createMergeRequestWithoutPosition(NewDiscussionParameters parameters)
        {
            Debug.Assert(parameters.Position.HasValue);

            Trace.TraceInformation("Reporting a discussion without Position (fallback)");

            parameters.Body     = getFallbackInfo(parameters.Position.Value) + "<br>" + parameters.Body;
            parameters.Position = null;

            try
            {
                await DiscussionOperator.CreateDiscussionAsync(MergeRequestDescriptor, parameters);
            }
            catch (OperatorException ex)
            {
                ExceptionHandlers.Handle(ex, "Cannot create a discussion (again)");
                return(false);
            }
            return(true);
        }
Example #10
0
        // Instead of searching for a latest discussion note with some heuristically prepared parameters,
        // let's clean up all similar notes, including a recently added one
        async private Task cleanupBadNotes(NewDiscussionParameters parameters)
        {
            Debug.Assert(parameters.Position.HasValue);

            Trace.TraceInformation("Looking up for a note with bad position...");

            int deletedCount = 0;

            List <Discussion> discussions = await DiscussionOperator.GetDiscussionsAsync(MergeRequestDescriptor);

            if (discussions == null)
            {
                Trace.TraceWarning(String.Format("No discussions found"));
                return;
            }

            foreach (Discussion discussion in discussions)
            {
                foreach (DiscussionNote note in discussion.Notes)
                {
                    if (arePositionsEqual(note.Position, parameters.Position.Value))
                    {
                        Trace.TraceInformation(
                            "Deleting discussion note." +
                            " Id: {0}, Author.Username: {1}, Created_At: {2} (LocalTime), Body:\n{3}",
                            note.Id.ToString(), note.Author.Username, note.Created_At.ToLocalTime(), note.Body);

                        await DiscussionOperator.DeleteNoteAsync(MergeRequestDescriptor, note.Id);

                        ++deletedCount;
                    }
                }
            }

            Trace.TraceInformation(String.Format("Deleted {0} notes", deletedCount));
        }
Example #11
0
 internal DiscussionEditor(MergeRequestDescriptor mrd, string discussionId, DiscussionOperator discussionOperator)
 {
     DiscussionOperator     = discussionOperator;
     MergeRequestDescriptor = mrd;
     DiscussionId           = discussionId;
 }
Example #12
0
 internal DiscussionCreator(MergeRequestDescriptor mrd, DiscussionOperator discussionOperator)
 {
     DiscussionOperator     = discussionOperator;
     MergeRequestDescriptor = mrd;
 }
Example #13
0
 public DiscussionManager(UserDefinedSettings settings)
 {
     DiscussionOperator = new DiscussionOperator(settings);
 }