Read Task Timephased Data

Contents
[ Hide Show ]

In Microsoft Project, time-phased data is displayed on the right side of the Task Usage and Resource Usage views. Users can write this data manually and with Aspose.Tasks for .NET, you can write it programmatically, or get it from a project into your application.

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.

The following piece of code shows how to read a task’s timephased data.

 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}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.