Read Task Timephased Data
In Microsoft Project, timephased data is displayed in the right-hand section of the Task Usage and Resource Usage views. It represents how work or cost is distributed over time.
With Aspose.Tasks for .NET, developers can programmatically read and process task timephased data from MPP or XML files.
Understanding Timephased Data
Timephased data provides detailed breakdowns of task values (e.g., work or cost) over specific time intervals. Aspose.Tasks enables this functionality through the Task class:
- GetTimephasedData
Purpose: Retrieves time-distributed values (work or cost) for a task.
Parameters:
- Start date of the interval
- Finish date of the interval
- (Optional) Type of timephased data (e.g., TaskCost)
This allows developers to extract detailed project analytics programmatically.
Working with Timephased Data
Aspose.Tasks for .NET supports reading a task’s time-phased data from Microsoft Project (MPP) files. The time-phased data is retrieved using the Task object’s GetTimephasedData method.
- To retrieve the task work’s time-phased data, the GetTimephasedData method takes the project’s start and finish dates as input parameters.
- To retrieve the task cost’s time-phased data, it takes an additional input parameter that specifies the type of time phase data as TaskCost.
Example: Reading Task Timephased Data in Aspose.Tasks
The following C# example demonstrates how to read timephased work and cost values for tasks:
1Project project = new Project("New Project.mpp");
2
3// Set project properties
4project.Set(Prj.StartDate, new DateTime(2013, 10, 30, 9, 0, 0));
5project.Set(Prj.NewTasksAreManual, false);
6
7// Add task and resources
8Task task = project.RootTask.Children.Add("Task");
9Resource resource = project.Resources.Add("Rsc");
10
11// Set resource rates and task duration
12resource.Set(Rsc.StandardRate, 10);
13resource.Set(Rsc.OvertimeRate, 15);
14task.Set(Tsk.Duration, project.GetDuration(6));
15
16// Create resource assignment
17ResourceAssignment assignment = project.ResourceAssignments.Add(task, resource);
18assignment.Set(Asn.Stop, DateTime.MinValue);
19assignment.Set(Asn.Resume, DateTime.MinValue);
20
21// Set Backloaded contour, it increases task duration from 6 to 10 days
22assignment.Set(Asn.WorkContour, WorkContourType.BackLoaded);
23
24project.SetBaseline(BaselineType.Baseline);
25task.Set(Tsk.PercentComplete, 50);
26
27// Read timephased data
28List<TimephasedData> td = assignment.GetTimephasedData(assignment.Get(Asn.Start), assignment.Get(Asn.Finish), TimephasedDataType.AssignmentRemainingWork).ToList();
29Console.WriteLine(td.Count);
30foreach(TimephasedData timePhasedValue in td)
31{
32 Console.WriteLine(timePhasedValue.Value);
33}
Key Notes
- Timephased data provides a granular view of project progress and costs.
- Developers can use it to create custom reports, charts, or integrate with analytics systems.
- The method works consistently with MPP and XML formats.
FAQ
Q: What’s the difference between task work timephased data and cost timephased data?
- Work timephased data shows distribution of hours/effort, while Cost timephased data shows financial allocation over time.
Q: Can I also write timephased data with Aspose.Tasks?
- Yes. Aspose.Tasks allows both reading and writing task timephased data.
Q: Does timephased data affect scheduling directly?
- No. It mainly affects reporting and resource/cost tracking but does not change task dependencies.