async public Task DeleteNoteAsync(int noteId) { try { await DiscussionOperator.DeleteNoteAsync(MergeRequestDescriptor, noteId); } catch (OperatorException) { throw new DiscussionEditorException(); } }
async public Task ResolveDiscussionAsync(bool resolved) { try { await DiscussionOperator.ResolveDiscussionAsync(MergeRequestDescriptor, DiscussionId, resolved); } catch (OperatorException) { throw new DiscussionEditorException(); } }
async public Task ReplyAsync(string body) { try { await DiscussionOperator.ReplyAsync(MergeRequestDescriptor, DiscussionId, body); } catch (OperatorException) { throw new DiscussionEditorException(); } }
async public Task ModifyNoteBodyAsync(int noteId, string body) { try { await DiscussionOperator.ModifyNoteBodyAsync(MergeRequestDescriptor, DiscussionId, noteId, body); } catch (OperatorException) { throw new DiscussionEditorException(); } }
async public Task CreateNoteAsync(CreateNewNoteParameters parameters) { try { await DiscussionOperator.CreateNoteAsync(MergeRequestDescriptor, parameters); } catch (OperatorException) { throw new DiscussionCreatorException(false); } }
async public Task <Discussion> GetDiscussion() { try { return(await DiscussionOperator.GetDiscussionAsync(MergeRequestDescriptor, DiscussionId)); } catch (OperatorException) { throw new DiscussionEditorException(); } }
async public Task <List <Discussion> > GetDiscussionsAsync(MergeRequestDescriptor mrd) { try { return(await DiscussionOperator.GetDiscussionsAsync(mrd)); } catch (OperatorException) { throw new DiscussionManagerException(); } }
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); } }
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); }
// 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)); }
internal DiscussionEditor(MergeRequestDescriptor mrd, string discussionId, DiscussionOperator discussionOperator) { DiscussionOperator = discussionOperator; MergeRequestDescriptor = mrd; DiscussionId = discussionId; }
internal DiscussionCreator(MergeRequestDescriptor mrd, DiscussionOperator discussionOperator) { DiscussionOperator = discussionOperator; MergeRequestDescriptor = mrd; }
public DiscussionManager(UserDefinedSettings settings) { DiscussionOperator = new DiscussionOperator(settings); }