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); }
public static List <CodeReviewComment> CountComments(int workItemid, IConfigurationRoot configuration) { Uri uri = new Uri(configuration["TfsApiUriTFS"]); 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); List <CodeReviewComment> comments = new List <CodeReviewComment>(); foreach (DiscussionThread thread in output) { if (thread.ItemPath != "") { CodeReviewComment comment = new CodeReviewComment(); comment.Author = thread.RootComment.Author.DisplayName; comment.AuthorUniqueName = thread.RootComment.Author.UniqueName; comment.Comment = thread.RootComment.Content; comment.PublishDate = thread.RootComment.PublishedDate.ToString("G"); comment.ItemName = thread.ItemPath; comments.Add(comment); } } return(comments); }
public static IList <CodeReviewComment> RetrieveComments(IDiscussionManager discussionManager, int codeReviewRequestId, string reviewedBy) { List <CodeReviewComment> comments = new List <CodeReviewComment>(); var result = discussionManager.BeginQueryByCodeReviewRequest(codeReviewRequestId, QueryStoreOptions.ServerAndLocal, null, null); var output = discussionManager.EndQueryByCodeReviewRequest(result); foreach (DiscussionThread thread in output) { if (thread.RootComment != null && thread.RootComment.PublishedDate > DateTime.MinValue && reviewedBy.Contains(thread.RootComment.Author.DisplayName) ) { CodeReviewComment comment = new CodeReviewComment(); comment.Author = thread.RootComment.Author.DisplayName; comment.CommentType = thread.RootComment.CommentType.ToString(); comment.Comment = thread.RootComment.Content; comment.PublishDate = thread.RootComment.PublishedDate.ToShortDateString(); comment.ItemName = thread.ItemPath; comments.Add(comment); } } return(comments); }
public List <CodeReviewComment> CountComments(string workItemid) { Uri uri = new Uri("http://tfs.cdbdx.biz:8080/tfs/DefaultCollection/"); TeamFoundationDiscussionService service = new TeamFoundationDiscussionService(); service.Initialize(new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(uri)); IDiscussionManager discussionManager = service.CreateDiscussionManager(); IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(int.Parse(workItemid), QueryStoreOptions.ServerAndLocal, new AsyncCallback(CallCompletedCallback), null); result.AsyncWaitHandle.WaitOne(); var output = discussionManager.EndQueryByCodeReviewRequest(result); List <CodeReviewComment> comments = new List <CodeReviewComment>(); foreach (DiscussionThread thread in output) { if (thread.ItemPath != "") { CodeReviewComment comment = new CodeReviewComment(); comment.Author = thread.RootComment.Author.DisplayName; comment.AuthorUniqueName = thread.RootComment.Author.UniqueName; comment.ReplyComments = new List <CodeReviewComment>(); foreach (Comment childCom in thread.RootComment.GetChildComments()) { CodeReviewComment tmp = new CodeReviewComment(); tmp.Author = childCom.Author.DisplayName; tmp.AuthorUniqueName = childCom.Author.UniqueName; tmp.Comment = childCom.Content; tmp.PublishDate = childCom.PublishedDate.ToString("MMMM dd, yyyy hh:mm:ss"); //tmp.PublishDate = String.Format("{0:d/M/yyyy HH:mm:ss}", childCom.PublishedDate); comment.ReplyComments.Add(tmp); } comment.Comment = thread.RootComment.Content; comment.PublishDate = thread.RootComment.PublishedDate.ToString("MMMM dd, yyyy hh:mm:ss"); //comment.PublishDate = String.Format("{0:d/M/yyyy HH:mm:ss}", thread.RootComment.PublishedDate); comment.ItemName = thread.ItemPath; comments.Add(comment); } } return(comments); }
public static List <CodeReviewComment> CountComments(int workItemid, IDiscussionManager discussionManager) { IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(workItemid, QueryStoreOptions.ServerAndLocal, new AsyncCallback(CallCompletedCallback), null); var output = discussionManager.EndQueryByCodeReviewRequest(result); List <CodeReviewComment> comments = new List <CodeReviewComment>(); foreach (DiscussionThread thread in output) { if (thread.ItemPath != "") { CodeReviewComment comment = new CodeReviewComment(); comment.Author = thread.RootComment.Author.DisplayName; comment.AuthorUniqueName = thread.RootComment.Author.UniqueName; comment.Comment = thread.RootComment.Content; comment.PublishDate = thread.RootComment.PublishedDate.ToShortDateString(); comment.ItemName = thread.ItemPath; comments.Add(comment); } } return(comments); }