Esempio n. 1
0
 async public Task <List <Discussion> > GetDiscussionsAsync(MergeRequestDescriptor mrd)
 {
     try
     {
         return(await DiscussionOperator.GetDiscussionsAsync(mrd));
     }
     catch (OperatorException)
     {
         throw new DiscussionManagerException();
     }
 }
Esempio n. 2
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));
        }