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:

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.

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

FAQ

Q: What’s the difference between task work timephased data and cost timephased data?

Q: Can I also write timephased data with Aspose.Tasks?

Q: Does timephased data affect scheduling directly?

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.