Working with Task's Actual Properties

The actual properties are used to find out how much time or money has been sent on a task to date.

Working with Actual Properties

The static class Tsk exposes a number of properties for determining a task’s actual properties:

The ChildTasksCollector class collects all the child tasks from a given RootTask when used by TaskUtils.

Actual Properties in Microsoft Project

To access these properties in Microsoft Project:

  1. On the View menu, select More Views and then Task Entry.
  2. On the Insert menu, select Column and add the desired columns to the Task Entry form.

Getting Actual Properties with Aspose.Tasks

A tasks’ actual properties can be obtained by traversing the tasks in a project. The code sample given below writes the actual properties for all tasks found in a project to a console window.

 1// The path to the documents directory.
 2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3    
 4// Create Project instance
 5System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"ActualTaskProperties.mpp");
 6    
 7// Create a ChildTasksCollector instance
 8System::SharedPtr<ChildTasksCollector> collector = System::MakeObject<ChildTasksCollector>();
 9    
10// Collect all the tasks from RootTask using TaskUtils
11TaskUtils::Apply(project->get_RootTask(), collector, 0);
12    
13// Parse through all the collected tasks
14    
15{
16    auto task_enumerator = (collector->get_Tasks())->GetEnumerator();
17    decltype(task_enumerator->get_Current()) task;
18    while (task_enumerator->MoveNext() && (task = task_enumerator->get_Current(), true))
19    {
20        System::Console::WriteLine(System::String(u"Task Name : ") + task->Get(Tsk::Name()));
21        System::Console::WriteLine(System::String(u"Actual Start: ") + task->Get<System::DateTime>(Tsk::ActualStart()).ToLongDateString());
22        System::Console::WriteLine(System::String(u"Actual Finish: ") + task->Get<System::DateTime>(Tsk::ActualFinish()).ToLongDateString());
23        System::Console::WriteLine(System::String(u"Actual Duration: ") + System::Convert::ToString(task->Get<Duration>(Tsk::ActualDuration()).get_TimeSpan().get_Hours()));
24        System::Console::WriteLine(System::String(u"Actual Cost: ") + System::Convert::ToString(task->Get<System::Decimal>(Tsk::ActualCost())));
25        System::Console::WriteLine(u"---------------------------------------------");
26    }
27}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.