Reading Resource Timephased Data

Aspose.Tasks for C++ API 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 following code example demonstrates reading the Timephased data of a Resource.

 1// Create project instance
 2System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"ResourceTimephasedData.mpp");
 3    
 4// Get the Resource by its ID
 5System::SharedPtr<Resource> resource = project1->get_Resources()->GetByUid(1);
 6    
 7// Print Timephased data of ResourceWork
 8System::Console::WriteLine(u"Timephased data of ResourceWork");
 9    
10{
11    auto td_enumerator = (resource->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate())))->GetEnumerator();
12    decltype(td_enumerator->get_Current()) td;
13    while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
14    {
15        System::Console::Write(System::String(u"Start: ") + td->get_Start().ToShortDateString());
16        System::Console::Write(System::String(u" Work: ") + td->get_Value() + System::Environment::get_NewLine());
17    }
18}
19    
20// Print Timephased data of ResourceCost
21System::Console::WriteLine(u"Timephased data of ResourceCost");
22    
23{
24    auto td_enumerator = (resource->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()), Aspose::Tasks::TimephasedDataType::ResourceCost))->GetEnumerator();
25    decltype(td_enumerator->get_Current()) td;
26    while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
27    {
28        System::Console::Write(System::String(u"Start: ") + td->get_Start().ToShortDateString());
29        System::Console::Write(System::String(u" Cost: ") + td->get_Value() + System::Environment::get_NewLine());
30    }
31}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.