问题
If I have the name and the owner of the Shelveset, I can find it successfully using the following code:
foreach (Shelveset shelveset in
versionControlServer.QueryShelvesets(workItem.
Fields["Associated Context"].Value.ToString(), "NW\\LFreeman"))
where workItem
is an instance of a CodeReviewRequest
workItem
.
I can get the name of the CodeReviewRequest
from workItem.Fields["Associated Context"]
If I set the owner to null
as such, it returns an empty list. It has been reported to me that this method will only work when the owner is specified as a string.
I am trying to figure out how to get the owner.
Using workItem.Fields["Associated Context Owner"].Value.ToString()
, I am able to get the GUID of the owner.
The challenge is now how to convert the GUID to the expected owner which would be "NW\LFreeman".
When I print out the workItems.Fields["Associated Context Owner"].Value.ToString()
, here's what I see:
c3741a78-1a44-4bf6-95b0-f360cd387f3e
Is it possible to retrieve "NW\LFreeman" from this GUID? If so, what method call will enable me to do this mapping?
Edit:
Here is the code that worked for me based on the answer and link given:
Guid ownerId = new Guid(codeReviewRequestWorkItem.Fields["Associated Context Owner"].Value.ToString());
Guid[] teamFoundationIds = new Guid[1];
teamFoundationIds[0] = ownerId;
TeamFoundationIdentity[] users = ims.ReadIdentities((Guid[])teamFoundationIds, MembershipQuery.None);
Shelveset[] shelves = vcs.QueryShelvesets(codeReviewRequestWorkItem.Fields["Associated Context"].Value.ToString(), users[0].UniqueName.ToString());
回答1:
IIdentityManagementService.ReadIdentities is what you are looking for.
来源:https://stackoverflow.com/questions/43083438/how-to-find-a-shelveset-using-information-provided-by-a-codereviewrequest