如何确定PSI中的资源工作可用性

时间:2015-08-12 13:10:02

标签: c# ms-project-server-2013 psi

我通过Microsoft.SharePoint.Client上下文使用MS Project Server 2013的PSI界面。

我需要在特定日期获得特定资源的数量或小时数。

例如,Resource1的当前最大单位为100%。我设置了8h的工作日,这意味着Resource1每个工作日都有8h。我将Resource1计划工作2小时设置为今天。因此,今天我需要获得最长的可用时间:8h - 2h = 6h。

//open project context
ProjectContext projContext;
projContext = new ProjectContext(pwaPath);

//load enterprise resource
projContext.Load(projContext.EnterpriseResources);
projContext.ExecuteQuery();

//get first resource
EnterpriseResource resource = projContext.EnterpriseResources[0];

//what should I do next?

如果没有人工计算,是否有任何方法可以获得此估算值?

1 个答案:

答案 0 :(得分:0)

        DateTime dtStart = DateTime.Parse("09.04.2015");
        DateTime dtEnd = DateTime.Parse("12.28.2016");
        var plan = checkoutProj.GetResourcePlan(dtStart, dtEnd, TimeScale.Days);

        projContext.Load(plan.Assignments);
        projContext.ExecuteQuery();

        DateTime dttest = DateTime.Parse("8.28.2016");
        var assgn = plan.Assignments[0].Intervals.GetByStart(dttest);

        projContext.Load(plan.Assignments[0].Intervals);
        projContext.Load(plan.Assignments[1].Intervals);
        projContext.Load(assgn);
        projContext.ExecuteQuery();

assgn.Duration 为您提供特定日期的工作量。