private static List <CodeReviewComment> GetCodeReviewComments(int workItemId) { List <CodeReviewComment> comments = new List <CodeReviewComment>(); Uri uri = new Uri(URL_TO_TFS_COLLECTION); TeamFoundationDiscussionService service = new TeamFoundationDiscussionService(); service.Initialize(new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(uri)); IDiscussionManager discussionManager = service.CreateDiscussionManager(); IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(workItemId, QueryStoreOptions.ServerAndLocal, new AsyncCallback(CallCompletedCallback), null); var output = discussionManager.EndQueryByCodeReviewRequest(result); foreach (DiscussionThread thread in output) { if (thread.RootComment != null) { CodeReviewComment comment = new CodeReviewComment(); comment.Author = thread.RootComment.Author.DisplayName; comment.Comment = thread.RootComment.Content.Replace(",", " COMMA ").Replace(System.Environment.NewLine, " NEWLINE "); comment.PublishDate = thread.RootComment.PublishedDate.ToShortDateString(); comment.ItemName = thread.ItemPath; comments.Add(comment); } } return(comments); }
private static List<CodeReviewComment> GetCodeReviewComments(int workItemId) { List<CodeReviewComment> comments = new List<CodeReviewComment>(); Uri uri = new Uri(URL_TO_TFS_COLLECTION); TeamFoundationDiscussionService service = new TeamFoundationDiscussionService(); service.Initialize(new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(uri)); IDiscussionManager discussionManager = service.CreateDiscussionManager(); IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(workItemId, QueryStoreOptions.ServerAndLocal, new AsyncCallback(CallCompletedCallback), null); var output = discussionManager.EndQueryByCodeReviewRequest(result); foreach (DiscussionThread thread in output) { if (thread.RootComment != null) { CodeReviewComment comment = new CodeReviewComment(); comment.Author = thread.RootComment.Author.DisplayName; comment.Comment = thread.RootComment.Content.Replace(",", " COMMA ").Replace(System.Environment.NewLine, " NEWLINE "); comment.PublishDate = thread.RootComment.PublishedDate.ToShortDateString(); comment.ItemName = thread.ItemPath; comments.Add(comment); } } return comments; }