1

我正在使用 CSOM 遍历项目中的 Project Server 2013 资源。我正在检查资源是否是通用的,因为我已经基于它编写了代码逻辑。我有一个 BA 和 PM 通用资源,它们是我使用 Project Server 中的构建团队功能添加的项目的一部分。在资源中心查看这些资源时,这些资源会显示为选中的通用标志。但以编程方式,IsGenericResource标志正在返回False

这是代码片段(**中的相关代码):

public string ProcessGenericResources(ProjectContext pc, PublishedProject publishedproject)
{
    try
    {
            Boolean bStaffingRequestItemUpdated = false; // this will be set to True whenever a staffing list item is update
            string sResourceApproverAttr = ExceptionUtility.ReadKeyFromConfig(sResourceApproverKey);
            string sRet = "";
            DraftProject project;

            if (publishedproject.IsCheckedOut)
               project = publishedproject.Draft.IncludeCustomFields;
            else
               project = publishedproject.CheckOut().IncludeCustomFields;

             pc.Load(project, p => p.Name, p => p.Id);
             DraftProjectResourceCollection ProjectResources = project.ProjectResources;
             pc.Load(ProjectResources, list => list.Include(item => item.Name, item => item.Id, item => item.IsGenericResource));
             pc.ExecuteQuery();
              // For each generic resource, check if an item is already in the Staffing Request list. If not create one
              foreach (DraftProjectResource resource in ProjectResources)
              {
                 List<string> listRMsNotified = new List<string>(); // this is to keep track of RMs already notified
                 pc.Load(resource);
                 pc.ExecuteQuery();
                 **bool bGenericResource = resource.IsGenericResource;
         ExceptionUtility.LogMessage("Resource=> Name:" + resource.Name + " ID:" + resource.Id + " Is Generic Resource?: " + bGenericResource);**
4

1 回答 1

1

我发现了这个问题。显然 ProjectResource 与 EnterpriseResource 不同。对于项目中的每个 ProjectResource,您需要在 ProjectContext.EnterpriseResources 集合中找到匹配项。EnterpriseResources 集合中的记录显示 IsGeneric 属性中的正确值。

于 2014-10-18T20:48:46.903 回答