我需要用TFS API做几件事。其中,我必须阅读每个项目的sprint在WPF UI中显示的资源规划信息。
沿着本指南标记,我现在有了以下方法:
private TfsTeamService _teamService;
private ICommonStructureService4 _structureService;
TeamSettingsConfigurationService _teamSettingsConfigurationService;
public void GetUserIterationAssignments(IList<ProjectInfo> projects)
{
foreach (ProjectInfo project in projects)
{
Console.WriteLine(project.Name);
TeamFoundationTeam team = _teamService.QueryTeams(project.Uri).First();
IList<Guid> teamGuids = new List<Guid>() { team.Identity.TeamFoundationId };
TeamConfiguration config = _teamSettingsConfigurationService.GetTeamConfigurations(teamGuids).FirstOrDefault();
if (config != null)
{
foreach (string nodePath in config.TeamSettings.IterationPaths)
{
var projectNameIndex = nodePath.IndexOf("\\", 2);
var fullPath = nodePath.Insert(projectNameIndex, "\\Iteration");
var nodeInfo = _structureService.GetNodeFromPath(fullPath);
if (nodeInfo.StartDate != null &&
nodeInfo.FinishDate != null)
{
foreach (TeamFoundationIdentity member in team.GetMembers(_collection, MembershipQuery.Direct))
{
Console.WriteLine("{0} is in assigned to {1} from {2}",
member.DisplayName,
nodeInfo.Name,
nodeInfo.StartDate,
nodeInfo.FinishDate);
}
}
}
}
}
}我需要打印到控制台(当然,就本例而言)是容量视图中显示的大部分信息:

更确切地说,我需要
对怎么做有什么想法吗?
发布于 2014-01-24 12:56:00
这些值只能从Server对象模型中获得(目前还没有等效的客户端对象模型)。接口和对象都是Internal,所以即使在服务器上也不能访问这些值。
internal TeamCapacity GetTeamIterationCapacity(Guid teamId, Guid iterationId);声明类型:Microsoft.TeamFoundation.Server.WebAccess.WorkItemTracking.Common.DataAccess.TeamConfigurationComponent大会:Microsoft.TeamFoundation.Server.WebAccess.WorkItemTracking.Common, Version=12.0.0.0
目前,获取数据的唯一方法是通过json服务(/tfs/{ProjectCollection}/{Team Project}/_api/_teamcapacity/updateteamcapacity/{Team}/{Iteration/Path}?__v=4),团队容量页面使用或直接从James提到的表中的ProjectCollection数据库获取数据。
看起来,json服务使用的是请求验证,这使得很难从任何外部系统使用。
要求免责声明: TFS的服务器数据库不是为了扩展性,不支持对它们的任何直接查询,而且模型可以在没有通知的情况下更改,甚至在service之间也是如此。不支持直接查询TFS数据库。通过官方API以外的任何其他方法更改TFS数据库中的值,基本上会使您的TFS服务器处于不受支持的状态,并可能在稍后升级到更新版本时引起重大问题。
发布于 2014-01-31 16:52:10
这不是一种受支持的方法,如果升级到较新版本的TFS,将来可能会中断,但是如果您只想读取中的数据,则可以直接转到TFS服务器的数据库。
您需要的特定值在其中(假设您使用的是DefaultCollection)
[Tfs_DefaultCollection].[dbo].[tbl_TeamConfigurationCapacity][Tfs_DefaultCollection].[dbo].[tbl_TeamConfigurationCapacityDaysOffRange]它们通过GUID引用迭代和用户。
[Tfs_Warehouse].[dbo].[DimIteration]中可以找到迭代GUID[Tfs_Configuration].[dbo].[tbl_Identity]中搜索用户名/SSID来找到用户GUID下面是一个快速示例,它以小时为单位询问我在一月迭代中的容量:
select Capacity from [Tfs_DefaultCollection].[dbo].[tbl_TeamConfigurationCapacity] as _cap
inner join [Tfs_Configuration].[dbo].[tbl_Identity] as _user
on _user.[Id] = _cap.[TeamMemberId]
inner join [Tfs_Warehouse].[dbo].[DimIteration] as _iter
on _iter.[IterationGUID] = _cap.[IterationId]
where _iter.[IterationPath]='\Code\Current\401-Jan'
and _user.[DisplayName]='Williams, Jason'您可以使用类似的方法从tbl_TeamConfigurationCapacityDaysOffRange读取每个假日的开始/结束日期范围。然而,这有点复杂,因为有团队休息日和个人休息日。
下面是我用来实现这一目标的查询。(虽然在为所有用户工作了6个月之后,我们的一个用户突然从查询中消失了,但我发现,由于没有明显的原因,我现在需要在IdentityMap表中查找他的ID。反向工程的乐趣来自无文件来源:-(
select [StartTime],[EndTime] from [Tfs_DefaultCollection].[dbo].[tbl_TeamConfigurationCapacityDaysOffRange] as _cap1
inner join [Tfs_Warehouse].[dbo].[DimIteration] as _iter1
on _iter1.[IterationGUID] = _cap1.[IterationId]
where _iter1.[IterationPath]='\Code\Current\401-Jan'
and _cap1.[TeamMemberId]='00000000-0000-0000-0000-000000000000'
union
select [StartTime],[EndTime] from [Tfs_DefaultCollection].[dbo].[tbl_TeamConfigurationCapacityDaysOffRange] as _cap2
inner join [Tfs_DefaultCollection].[dbo].[tbl_IdentityMap] as _map
on _map.[localId] = _cap2.[TeamMemberId]
inner join [Tfs_Configuration].[dbo].[tbl_Identity] as _user2
on _user2.[Id] = _map.[masterId]
inner join [Tfs_Warehouse].[dbo].[DimIteration] as _iter2
on _iter2.[IterationGUID] = _cap2.[IterationId]
where _iter2.[IterationPath]='\Code\Current\401-Jan'
and (_user2.[DisplayName]='Williams, Jason')您只需要为提到迭代路径和要查询的用户名的两个位置替换适当的值。
发布于 2014-07-01 13:11:14
还有另一种无法支持的可能性。在积压/容量/{迭代路径}网站上看看。数据后面包含JSON格式的容量信息(团队容量-数据)。
https://onedrive.live.com/redir?resid=88F0C013A4398D9B%21129
https://stackoverflow.com/questions/13990421
复制相似问题