Task Budget Work and Cost Values
Contents
[
Hide
Show
]Reading budget work and cost value
Microsoft Project 2007 and 2010 provide budget cost and budget work as task fields. Aspose.Tasks for C++ API provides these properties as Task.BudgetWork and Task.BudgetCost for retrieving budget work and cost for the task.
The following code examples demonstrates how to retrieve a task’s budget work and cost information.
1// Create project instance
2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"BudgetWorkAndCost.mpp");
4
5// Display budget work and budget cost for project summary task
6System::SharedPtr<Task> projSummary = project1->get_RootTask();
7System::Console::WriteLine(System::String(u"projSummary.BudgetWork = ") + System::ObjectExt::ToString(projSummary->Get<Duration>(Tsk::BudgetWork())));
8System::Console::WriteLine(System::String(u"projSummary.BudgetCost = ") + System::Convert::ToString(projSummary->Get<System::Decimal>(Tsk::BudgetCost())));
9
10// Display resource budget work
11System::SharedPtr<Resource> rsc = project1->get_Resources()->GetByUid(6);
12System::Console::WriteLine(System::String(u"Resource BudgetWork = ") + System::ObjectExt::ToString(rsc->Get<Duration>(Rsc::BudgetWork())));
13
14// Display resource budget cost
15rsc = project1->get_Resources()->GetByUid(7);
16System::Console::WriteLine(System::String(u"Resource BudgetCost = ") + System::Convert::ToString(rsc->Get<System::Decimal>(Rsc::BudgetCost())));
17
18// Display assignment budget work and budget cost
19
20{
21 auto assn_enumerator = (projSummary->get_Assignments())->GetEnumerator();
22 decltype(assn_enumerator->get_Current()) assn;
23 while (assn_enumerator->MoveNext() && (assn = assn_enumerator->get_Current(), true))
24 {
25
26 // C# preprocessor directive: #if !__cplusplus
27
28
29 // C# preprocessor directive: #endif
30
31 auto resource = assn->Get(Asn::Resource());
32
33 if (static_cast<ResourceType>(resource->Get(Rsc::Type())) == Aspose::Tasks::ResourceType::Work)
34 {
35 System::Console::WriteLine(System::String(u"Assignment BudgetWork = ") + System::ObjectExt::ToString(assn->Get<Duration>(Asn::BudgetWork())));
36 }
37 else
38 {
39 System::Console::WriteLine(System::String(u"Assignment BudgetCost = ") + System::Convert::ToString(assn->Get<System::Decimal>(Asn::BudgetCost())));
40 }
41 }
42}