MPXJ:通过 API 获取计划工作
我想使用 MPXJ 从 MS Project 中提取一段时间内的计划工作。 有谁知道如何通过API获取这些数据? 我找不到任何合适的方法来做到这一点。
(具体场景:我想画一个图表,y轴为计划工作,x轴为日期)
I want to extract the planned work over the time from MS Project using MPXJ.
Does anyone know how to get these figures via API?
I cannot find any appropriate method for doing this.
(Concrete scenario: I want to draw a chart with the planned work on the y-axis and the date on the x-axis)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Jon 上面给出的答案在当时是正确的,但从 MPXJ 4.2 版本开始,用于处理时间分段工作(和成本)的 api 已经发生了很大变化。这是您现在要做的:
这部分是相同的:
这已更改(请注意获取计划工作的不同返回类型和方法,以及 TimephasedUtility 类上的新方法):
您还必须知道的一件事是计划工作工作数据仅包含尚未完成的工作的值(即,当时尚未记录任何实际值)。例如,如果您的任务持续 4 天,并且您已完成 50% 的工时,则您将具有前两天按时间分段的实际工时值,而仅具有后两天按时间分段的计划工时值。它们不会重叠或重复。
因此,如果您尝试显示整个分配时间段的计划工时值(就像您在 MS Project 的任务分配情况视图中看到的那样),您还需要检索按时间分段的实际工时值并使用它们就好像它们也是有计划的工作一样。
The answer Jon gave above was correct at the time, but as of version 4.2 of MPXJ, the api for dealing with timephased work (and cost) has been changed considerably. Here's what you would do now:
This part's the same:
This has changed (notice the different return type and method for getting the planned work, and the new method on the TimephasedUtility class):
One thing you also have to know is that the planned work data only contains values for work that has not been completed yet (ie, no actual values have been recorded for that time). For example, if your assignment lasts for 4 days, and you've completed 50% of the work, then you will have timephased ACTUAL work values for the first two days, and timephased PLANNED work values only for the last two days. They do not overlap or duplicate.
So if you are trying to show planned work values for the whole time period of the assignment (like what you'd see in the Task Usage views in MS Project), you'd need to also retrieve the timephased actual work values and use them as if they were planned work too.
您的起点是分配对象上的以下方法:
顾名思义,这些方法将为您提供计划的工作或完整的工作,表示为在一段时间内执行的工作。
这里的“问题”是,这些数据以紧凑的格式表示(反映了 MS Project 内部存储的方式),这不太适合显示工作的逐周期细分。
为了获得您想要的东西,有两个实用程序类将帮助您将这种紧凑的表示形式转换为工作值列表。例如,您可以为他们提供开始日期、期间类型(日、周、月等)和多个期间,并要求在这些期间内分解工作。
第一步是创建 TimescaleUtility 类的实例,并让它为您生成一系列日期。您为其指定开始日期、所需的时间刻度单位以及所需的周期数。
dateList 变量现在包含您要分割工作的日期范围列表。这种分割是使用 TimephasedUtility 类执行的:
就是这样,datList 中的每个条目现在都包含一个条目,显示该期间的工作量。
希望这是有道理的!
乔恩
your starting point is the following methods on the assignment object:
As their names suggest, these will get you either the planned work or the complete work, expressed as work carried out over periods of time.
The "gotcha" here is that this data is represented in a compact format (reflecting how it's stored by MS Project internally), and this does not lend itself well to showing a period-by-period breakdown of work.
To get what you want, there are two utility classes which will help you to convert this compact representation into a list of work values. For example, you can give them a start date a period type (day, week, month and so on) and a number of periods, and ask for the work to be broken down over these periods.
First step is to create an instance of the TimescaleUtility class, and get it to generate a range of dates for you. You give it the start date, the timescale units you require, and the numnber of periods you want.
The dateList variable now contains the list of date ranges you are going to split the work over. This split is carried out using the TimephasedUtility class:
That's it, your durationList now contains one entry for each entry in the datList showing the amount of work for that period.
Hope that makes sense!
Jon