我正在使用 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);**