通过 API 创建新工作项时,无法在 TFS 中获取分配给字段的有效用户列表 [英] Cannot get a list of valid users in TFS for AssignedTo field while creating new Workitems via API
本文介绍了通过 API 创建新工作项时,无法在 TFS 中获取分配给字段的有效用户列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过 TFS API 创建新的工作项,这是我在下面使用的方法来获取可以分配工作项的有效用户列表.不知何故,它在 validUserSids 行上给了我一个空引用异常.有人知道这里出了什么问题吗?
Hi I am trying to create new workitems via the TFS API and this is the method I have used below to get a list of valid users who can be assigned workitems. Somehow, it gives me a null reference exception on validUserSids line. Anyone know what's wrong here?
private string[] TFSUsers(string server)
{
// Get a Reference to Team Foundation Server.
TeamFoundationServer tfs = tfsdata.GetTFS(server);
// Get a reference to Group Security Service.
IGroupSecurityService gss = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService));
// Resolve to SIDs
Identity validUserSids = gss.ReadIdentity(SearchFactor.AccountName, "TFS Valid Users", QueryMembership.Expanded);
// Resolve to actual users
Identity[] validUsers = gss.ReadIdentities(SearchFactor.Sid, validUserSids.Members, QueryMembership.None);
List<string> Users = new List<string>();
foreach (Identity user in validUsers)
{
Users.Add(user.DisplayName);
}
return Users.ToArray();
}
推荐答案
以下是获取 TFS 中用户列表的方法:
Here's how you would get the list of users in TFS:
var tfs = TeamFoundationServerFactory.GetServer("http://vstspioneer:8080/tfs/VSTSDF");
var workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
var allowedValues = workItemStore.FieldDefinitions[CoreField.AssignedTo].AllowedValues;
foreach (String value in allowedValues)
{
Console.WriteLine(value);
}
这篇关于通过 API 创建新工作项时,无法在 TFS 中获取分配给字段的有效用户列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文