Estimated and Milestone Tasks

In Microsoft Project, milestones are used to monitor a project’s progress. Milestones are crucial points in the project. Typically, a milestone’s a task with no duration but any task can be marked as a milestone. Aspose.Tasks for C++ API helps you manage milestones.

Working with Milestones

The Tsk class exposes the IsEstimated and IsMilestone properties to manage estimated and milestone tasks:

Viewing Estimated and Milestone Tasks in Microsoft Project

To see whether a task is estimates of marked as a milestone in Microsoft Project one can double-click a task in the Task Entry form:

marking an estimated task as a milestone in Microsoft Project

Finding out Whether a Task is Estimated or a Milestone

The following code example demonstrates how to find out whether a task is estimated or a milestone using Aspose.Tasks.

 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"EstimatedMilestoneTasks.mpp", System::IO::FileMode::Open);
 4System::SharedPtr<Project> prj = System::MakeObject<Project>(fs);
 5fs->Close();
 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(prj->get_RootTask(), collector, 0);
12    
13// Parse through all the collected tasks
14    
15{
16    auto tsk1_enumerator = (collector->get_Tasks())->GetEnumerator();
17    decltype(tsk1_enumerator->get_Current()) tsk1;
18    while (tsk1_enumerator->MoveNext() && (tsk1 = tsk1_enumerator->get_Current(), true))
19    {
20        System::String strEst = tsk1->Get<NullableBool>(Tsk::IsEstimated()).get_Value() ? System::String(u"Estimated") : System::String(u"Non-Estimated");
21        System::String strMileStone = tsk1->Get<NullableBool>(Tsk::IsMilestone()).get_Value() ? System::String(u"Milestone") : System::String(u"Non-Milestone");
22        System::Console::WriteLine(tsk1->Get(Tsk::Name()) + u" : " + strEst);
23        System::Console::WriteLine(tsk1->Get(Tsk::Name()) + u" : " + strMileStone);
24    }
25}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.