问题描述
我需要创建两个方法如下:
I need to create two methods as follows:
- 检索所有的变更在TFS
- 提取超过规定变更新的所有变更。
我做了一些谷歌搜索,发现了几个环节,并设法拿出一些代码。我似乎无法制定出方法来调用来获得变更项目的完整列表。我拙劣的东西在一起,得到这个,但想知道是否有人能帮助我:
I've done some google searching and found a few links and managed to come up with some code. I can't seem to work out the method to call to get the complete list of changeset items. I've botched something together to get this but was wondering if someone can help me:
TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://mydomain.com:8080/tfs"));
VersionControlServer versionControl = projectCollection.GetService<VersionControlServer>();
int latestId = versionControl.GetLatestChangesetId();
List<Changeset> changesetList = new List<Changeset>();
for (int i = 1; i < latestId; i++)
{
try
{
Changeset cs = versionControl.GetChangeset(i);
if (cs != null)
{
changesetList.Add(cs);
}
}
catch (ResourceAccessException)
{
}
}
获取一些标识的变更集抛出一个ResourceAccessException例外,这就是为什么处理程序已被添加。
Getting the changeset for some Id's throws a 'ResourceAccessException' exception which is why the handler has been added.
任何想法如何做到这一点,在正确的方式?
Any ideas on how to do this in the "proper" way?
我在使用Visual Studio 2010与2010年TFS应用程序被写在C#作为.NET 4.0的应用程序。
I'm using Visual Studio 2010 with TFS 2010. Application is being written in C# as a .Net 4.0 app.
TIA
推荐答案
试试这个:
// Replace with your setup
var tfsServer = @"http://tfsserver:8080/tfs/SW";
var serverPath = @"$/PCSW/ProjectX/Main";
// Connect to server
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsServer));
tfs.Connect(ConnectOptions.None);
var vcs = tfs.GetService<VersionControlServer>();
// Create versionspec's. Example start with changeset 529
VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C529", null);
// If you want all changesets use this versionFrom:
// VersionSpec versionFrom = null;
VersionSpec versionTo = VersionSpec.Latest;
// Get Changesets
var changesets = vcs.QueryHistory(
serverPath,
VersionSpec.Latest,
0,
RecursionType.Full,
null,
versionFrom,
versionTo,
Int32.MaxValue,
true,
false
).Cast<Changeset>();
这篇关于TFS 2010:变更ID的获取列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!