如何使用 CodeReviewRequest 提供的信息查找货架集 [英] How to find a Shelveset using information provided by a CodeReviewRequest

查看:22
本文介绍了如何使用 CodeReviewRequest 提供的信息查找货架集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有货架集的名称和所有者,我可以使用以下代码成功找到它:

 foreach (Shelvessetshelvesset inversionControlServer.QueryShelvesets(workItem.字段["关联上下文"].Value.ToString(), "NW\\LFreeman"))

其中 workItemCodeReviewRequest workItem 的一个实例.

我可以从 workItem.Fields["Associated Context"]

获取 CodeReviewRequest 的名称

如果我将所有者设置为 null,它会返回一个空列表.据我所知,此方法仅在将所有者指定为字符串时才有效.

我正在想办法找到所有者.

使用 workItem.Fields["Associated Context Owner"].Value.ToString(),我能够获得所有者的 GUID.

现在的挑战是如何将 GUID 转换为预期的所有者,即NW\LFreeman".

当我打印出 workItems.Fields["Associated Context Owner"].Value.ToString() 时,我看到的是:

c3741a78-1a44-4bf6-95b0-f360cd387f3e

是否可以从此 GUID 中检索NW\LFreeman"?如果是这样,什么方法调用将使我能够进行此映射?

<小时>

以下是根据给出的答案和链接对我有用的代码:

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);Shelvesset[]shelves = vcs.QueryShelvesets(codeReviewRequestWorkItem.Fields["Associated Context"].Value.ToString(), users[0].UniqueName.ToString());

解决方案

IIdentityManagementService.ReadIdentities 正是您要找的.

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());

解决方案

IIdentityManagementService.ReadIdentities is what you are looking for.

这篇关于如何使用 CodeReviewRequest 提供的信息查找货架集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆