Overtimes in Tasks

Microsoft Project lets users assign overtime to tasks. Aspose.Tasks for C++ API supports this functionality through two properties in the Task class.

Overtime

The [Tsk] ( https://reference.aspose.com/tasks/cpp/class/aspose.tasks.tsk) exposes several properties for working with overtime:

Microsoft Project view of task overtime

To see a task’s overtime work and cost properties:

  1. In the Task Entry form, select the Insert menu and then Column.
  2. Add the overtime columns.

Getting task overtimes in Aspose.Tasks

The following code example demonstrates how to get the overtime cost and work associated with a task.

 1// Read project from file stream
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<System::IO::FileStream> fs = System::MakeObject<System::IO::FileStream>(dataDir + u"TaskOvertimes.mpp", System::IO::FileMode::Open);
 4System::SharedPtr<Project> project1 = System::MakeObject<Project>(fs);
 5fs->Close();
 6    
 7// Read overtime and percentage completion for tasks
 8    
 9{
10    auto tsk1_enumerator = (project1->get_RootTask()->get_Children())->GetEnumerator();
11    decltype(tsk1_enumerator->get_Current()) tsk1;
12    while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
13    {
14        System::Console::WriteLine(tsk1->Get<System::Decimal>(Tsk::OvertimeCost()));
15        System::Console::WriteLine(System::ObjectExt::ToString(tsk1->Get<Duration>(Tsk::OvertimeWork())));
16        System::Console::WriteLine(tsk1->Get<int32_t>(Tsk::PercentComplete()));
17        System::Console::WriteLine(System::Convert::ToString(tsk1->Get<int32_t>(Tsk::PercentWorkComplete())));
18        System::Console::WriteLine(System::Convert::ToString(tsk1->Get<int32_t>(Tsk::PhysicalPercentComplete())));
19        
20        // Set percent complete
21        tsk1->Set<int32_t>(Tsk::PercentComplete(), 100);
22    }
23}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.