我们正在研究TFS数据库(TFS_Warehouse,TFS_FabrikamFibreCollection)以创建一些与TFS活动相关的报告。我们需要根据团队名称生成报告。 TFS维持 以下项目层次结构: ProjectCollection 项目 队
我们可以在TFS_Warehouse数据库中映射ProjectCollections和Projects,它们位于DimTeamProject中。 但是ee无法在TFS_Warehouse / TFS_FabrikamFibreCollection数据库中映射团队名称。 如果您对DB表格的团队名称映射有任何疑问,请告诉我。
答案 0 :(得分:2)
这是我为您的问题找到的最接近的解决方案:
SELECT map.[TeamId]
,map.[ProjectId]
,proj.[ProjectNodeName] AS [Team Project Name]
,ado.[SamAccountName] AS [Team Name]
FROM [Tfs_FabrikamFibreCollection].[dbo].[tbl_TempTeamProjectMapping] map
JOIN [Tfs_Warehouse].[dbo].[DimTeamProject] proj ON map.[ProjectId] = proj.[ProjectNodeGUID]
JOIN [Tfs_FabrikamFibreCollection].[dbo].[ADObjects] ado ON map.[TeamId] = ado.[TeamFoundationId]
出于某种原因,[tbl_TempTeamProjectMapping]
表包含默认安全组(读者,贡献者,项目管理员等),但这些可以很容易地从结果中过滤掉。
答案 1 :(得分:0)
答案 2 :(得分:0)
我建议远离SQL并使用TFS API。以下PowerShell调用TFS客户端命名空间并带回集合和项目。
#region Get-TfsSummary
function Get-TfsSummary{
param(
[parameter(Position=0,HelpMessage=' Full server name. e.g. tfsServer.domain.net',Mandatory)]
[string]
$serverFQDN, # eg 'tfsServer.domain.net'
[parameter(Position=1,HelpMessage=' port used to access the TFS server e.g. 8080')]
[string]
$serverPort, # eg '8080'
[parameter(Position=2,HelpMessage=' The root virtual directory for TFS. Default is tfs e.g. tfs ')]
[string]
$tfsRootNode # eg 'tfs'
)
Add-Type -AssemblyName "Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
$tfsUri = 'http://' + $serverFQDN + ':' + $serverPort +'/' + $tfsRootNode + '/'
$tfsConfigurationServer = [Microsoft.TeamFoundation.Client.TfsConfigurationServerFactory]::GetConfigurationServer($tfsUri)
$tpcService = $tfsConfigurationServer.GetService("Microsoft.TeamFoundation.Framework.Client.ITeamProjectCollectionService")
$sortedCollections = $tpcService.GetCollections() | Sort-Object -Property Name
$numberOfProjects = 0
$numberOfStoppedCollections = 0
$numberOfStartedProjects = 0
$numberOfStoppedProjects = 0
$isStopped = ''
foreach($collection in $sortedCollections) {
$collectionUri = $tfsUri + "/" + $collection.Name
$tfsTeamProject = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($collectionUri)
try {
$cssService = $tfsTeamProject.GetService("Microsoft.TeamFoundation.Server.ICommonStructureService4")
}catch{}
$sortedProjects = $cssService.ListProjects() | Sort-Object -Property Name
if($collection.State -eq 'Stopped'){
$isStopped = ' but is stopped'
$numberOfStoppedCollections++
$numberOfStoppedProjects += $sortedProjects.Count
}
Write-Host "`n" $collection.Name "(" $collection.Id ")- contains" $sortedProjects.Count "project(s)$isStopped"
$isStopped = ''
foreach($project in $sortedProjects)
{
$numberOfProjects++
Write-Host (" - " + $project.Name + " (" + $project.Uri + ")")
}
}
$numberOfStartedProjects = $numberOfProjects - $numberOfStoppedProjects
Write-Host
Write-Host "Number of stopped collections " $numberOfStoppedCollections
Write-Host "Total number of project collections " $sortedCollections.Count
Write-Host "Online projects " $numberOfStartedProjects
Write-Host "Total number of projects " $numberOfProjects
}
#endregion Get-TfsSummary