Bar*_*ğlu 4 .net tfs annotations visual-studio tfs2010
我正在尝试编写一个将使用TFS API的小应用程序.
我将有一个方法,这个方法有三个参数,如项目名称,文件名和行号.然后它给了我写这部分代码的人的名字.
public string GetProgrammer(string projectname, string file, int linenumber)
{
//implementation
return programmerName;
}
Run Code Online (Sandbox Code Playgroud)
我已经搜索了一些TFS API,但我无法找到解决此问题的确切信息.TFS API是否提供此信息?
提前致谢,
优秀的问题.但是,没有直接的方法可以用来做到这一点.相反,你需要做以下事情,
public string GetProgrammer(string projectname, string file, int linenumber)
{
// 1. Connect To TFS get the project name that you have passed
var tfs = TfsTeamProjectCollectionFactory
.GetTeamProjectCollection(new Uri("TfsUrl"));
var vsStore = tfs.GetService<VersionControlServer>();
var myProject = vsStore.TryGetTeamProject(projectName);
// 2. Use the versionControlServer Service and get a history
// i.e. all changesets that fall under the parent 'filename'
// with recursion.none
var histories = service.GetBranchHistory(
new ItemSpec[] { new ItemSpec (filePath, RecursionType.None) },
VersionSpec.Latest);
// 3. Loop through each changeset and build your code block adding
// the name of the user who owns the changeset in a List.
foreach (BranchHistoryTreeItem history in histories[0])
{
var change = service.GetChangeset(
history.Relative.BranchToItem.ChangesetId,
true,
true);
if (change.WorkItems.ToList().Count == 0)
{
// Create your file compiling the changes from each check-in
// and lets say store in stream
}
}
// 4. Now pass the line number, in what ever code block it falls
// you should get the details of the user, changeset and other details
// to return.
// Query the stream build in the last step for the line number
return programmerName;
}
Run Code Online (Sandbox Code Playgroud)
一些突出的问题, - 几次,在文件开发中,几个用户修改了同一行或相同的代码块.你打算如何处理?
查看这些可能有助于您开始连接到TFS的博客文章,使用versionControlServer获取文件的变更集并循环更改集.http://geekswithblogs.net/TarunArora/category/12804.aspx
HTH干杯,塔伦
| 归档时间: |
|
| 查看次数: |
982 次 |
| 最近记录: |