Read Timephased Data of a Resource
Contents
[
Hide
Show
]Aspose.Tasks for .NET supports reading a resource’s timephased data from Microsoft Project (MPP) files.
Reading Timephased Resource Data
The Timephased data is retrieved using the Resource object’s TimeScaleData method. For Timephased data of resource work, the
- The TimeScaleData method gets the timephased data for resource work and takes the project’s start and finish dates as input parameters.
- To get the timephased data for resource cost, the TimeScaleData method takes another input parameter - the timephased data type as a ResourceCost.
The following piece of code shows reading the Timephased data of a Resource.
1Project project = new Project("New Project.mpp");
2
3// Get the Resource by its ID
4Resource resource = project.Resources.GetByUid(1);
5
6// Print Timephased data of ResourceWork
7Console.WriteLine("Timephased data of ResourceWork");
8foreach (TimephasedData td in resource.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate)))
9{
10 Console.Write("Start: " + td.Start.ToShortDateString());
11 Console.Write(" Work: " + td.Value + Environment.NewLine);
12}
13
14// Print Timephased data of ResourceCost
15Console.WriteLine("Timephased data of ResourceCost");
16foreach (TimephasedData td in resource.GetTimephasedData(project.Get(Prj.StartDate), project.Get(Prj.FinishDate), TimephasedDataType.ResourceCost))
17{
18 Console.Write("Start: " + td.Start.ToShortDateString());
19 Console.Write(" Cost: " + td.Value + Environment.NewLine);
20}