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); }
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 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); }
private void buttonSearch_Click(object sender, EventArgs e) { Uri uri = new Uri(TfsUri); TeamFoundationDiscussionService service = new TeamFoundationDiscussionService(); service.Initialize(new TfsTeamProjectCollection(uri)); TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri); WorkItemStore store = projectCollection.GetService <WorkItemStore>(); WorkItemLinkInfo[] list = GetCodeReviewRequests(store); IDiscussionManager discussionManager = service.CreateDiscussionManager(); List <ResponseAnalysis> responseList = new List <ResponseAnalysis>(); List <WorkItemLinkInfo> filteredList = list.Where(p => p.SourceId != 0).ToList(); foreach (WorkItemLinkInfo item in filteredList) { ResponseAnalysis response = new ResponseAnalysis(); WorkItem Widemand = store.GetWorkItem(item.SourceId); WorkItem WiResponse = store.GetWorkItem(item.TargetId); string reviewer = WiResponse.Fields["Accepted By"].Value.ToString(); string date = Widemand.Fields["Created Date"].Value.ToString(); response.WorkiTemId = Widemand.Id; response.CommentNumber = CountComments(Widemand.Id, discussionManager, NormalizeName(reviewer)); response.OwnerName = Widemand.CreatedBy; response.CodeReviewStatus = WiResponse.Fields["Closed Status"].Value.ToString(); response.Direction = GetDirection(Widemand.CreatedBy); response.ReviewerName = reviewer; response.Team = GetTeam(Widemand.CreatedBy); //WorkItemType type = item.Links.WorkItem.Type; responseList.Add(response); } int nbConcernedLines = 0; }
static void Main(string[] args) { string projecturi = "https://xxx:8080/tfs/"; int changesetid = xxx; TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(projecturi)); VersionControlServer vcs = ttpc.GetService <VersionControlServer>(); Changeset cset = vcs.GetChangeset(changesetid); TeamFoundationDiscussionService tfds = new TeamFoundationDiscussionService(); tfds.Initialize(ttpc); IDiscussionManager idm = tfds.CreateDiscussionManager(); IAsyncResult iar = idm.BeginQueryByVersion(cset.ArtifactUri, QueryStoreOptions.ServerOnly, new AsyncCallback(Callback), null); var threads = idm.EndQueryByVersion(iar); foreach (DiscussionThread dt in threads) { Console.WriteLine(dt.RootComment.Content); Console.WriteLine(dt.RootComment.Author.DisplayName); Console.ReadLine(); } }
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); }
public DiscussionController(IDiscussionManager discussionManager, IReportManager reportManager) { _discussionManager = discussionManager; _reportManager = reportManager; }