以下内容适用于 TFS 2013 更新 5
** WARNING ** Getting caught editing the TFS database directly
** will void your Microsoft Support Agreement. **
What follows is not for the uninitiated. ** Proceed at your own risk. **
找到需要设置电子邮件地址的用户。 Identities 表中可能有重复项。我发现SequenceId 最高的是活跃的Identities。
Use Tfs_TFSConfiguration
SELECT i1.AccountName, i1.Id FROM tbl_Identity AS i1
LEFT OUTER JOIN tbl_Identity AS i2
ON (i1.AccountName=i2.AccountName AND i1.SequenceId<i2.SequenceId)
WHERE i2.AccountName IS NULL
AND i1.AccountName in ('<your first user>','<another user>','<and so on>')
这会以 GUID 形式提供您需要更新的帐户的最新Id(s) 列表。这些 GUID 必须重新格式化为 ArtifactId(s),这是一种转换后的二进制格式。这是通过颠倒字节顺序(从低到高)或 GUID 的前三个部分中的每一个来完成的,但保留最后两个部分的顺序。例如:
Returned 'Id' GUID =01020304-0506-0708-090A-0B0C0D0E0F10
Byte Swapped GUID =04030201-0605-0807-090A-0B0C0D0E0F10
Reformatted 'ArtifacId'=0x0403020106050807090A0B0C0D0E0F10
接下来,您必须找到 TFS 用于电子邮件通知的 PropertyId(s)。在 TFS 2013 U5 中,可以通过以下查询找到:
USE Tfs_TFSConfiguration
SELECT Name, PropertyId FROM tbl_PropertyDefinition WHERE Name LIKE '%Address%'
这将为您提供ConfirmedNotificationAddress 和CustomNotificationAddresses 的PropertyId(s);这是 TFS 2013 U5 用于发送通知电子邮件的两个属性字段。
接下来,您必须为 TFS DatabaseCategory 的 Identity 框架找到 InternalKindId
USE Tfs_TFSConfiguration
SELECT Description, InternalKindId FROM tbl_PropertyArtifactKind
WHERE Description='Identity'
现在把它们放在一起,...
如果您的用户的配置记录已经存在,您可以更新设置:
USE Tfs_TFSConfiguration
UPDATE tbl_PropertyValue SET LeadingStringValue='<user's notification email address>'
WHERE ArtifactId=<ArtifactId, reformatted from tbl_Identity query>
AND PropertyId IN ('<first PropertyId from tbl_PropertyDefinition>', '<second id>')
注意:ArtifactId 是一个二进制值,基于半字节交换的数据库 GUID,不会匹配 UPDATE 查询中的引用值。 IE。这部分查询看起来像:
WHERE ArtifactId=0x90D490F6BF7B31491CB894323F38A91F AND
下面我假设PartitionId 是'1';在您继续之前,应通过简要扫描tbl_PropertyValue 表中的记录来验证这一点。
如果您正在加载尚未设置的配置设置:
USE Tfs_TFSConfiguration
INSERT INTO tbl_PropertyValue
(PartitionId, ArtifactId, InternalKindId, Version, PropertyId, LeadingStringValue)
VALUES ('1', <ArtifactId, reformatted from tbl_Identity query>,
'<InternalKindId from tbl_PropertyArtifactKind>',
'0',
'<first PropertyId from tbl_PropertyDefinition>',
'<user's notification email address>'),
('1', <ArtifactId, reformatted from tbl_Identity query>,
'<InternalKindId from tbl_PropertyArtifactKind>',
'0',
'<second PropertyId from tbl_PropertyDefinition>',
'<user's notification email address>')
注意:ArtifactId 必须是一个不带引号的二进制值,从 tbl_Identity 返回的 GUID 转换而来,如上所述。
注意:为每个ArtifactId 创建两条记录,每个PropertyId 一条记录。
** WARNING ** Getting caught editing the TFS database directly
** will void your Microsoft Support Agreement. **
** Proceed at your own risk. **
(这对我有用,......但是,我没有要失效的 Microsoft 支持协议。)