简体   繁体   中英

How to filter TFS contributors to a specific project?

Currently I can get all of the TFS contributors using workItemStore.FieldDefinitions[CoreField.AssignedTo].AllowedValues , but the thing is that I want to search for the allowed members of a specific project(I already have the project info extracted from TFS), as the results are in the hundreds instead of just 5-6.

Any suggestions are welcome.

You can use the following code to get valid user for a specific team project:

List<string> displayNames = new List<string>();
        TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://tfsservername:8080/tfs/collectionname"));
        tfs.EnsureAuthenticated();
        WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

        WorkItemTypeCollection workItemTypes = workItemStore.Projects["Agile"].WorkItemTypes;

        WorkItemType wiType = workItemTypes["task"];

        var allowedValues = wiType.FieldDefinitions[CoreField.AssignedTo].AllowedValues;

        foreach (String value in allowedValues)
        {
            displayNames.Add(value);
        }

However, for your data-binding requirement, could you please offer more information? By the way, what kind of project you're working with? A winform project?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM