Timephased Data Generation for Different Work Contours
Contents
[
Hide
Show
]Timephased Data Generation for Different Work Contours
Aspose.Tasks for C++ API provides the facility to generate timephased data for different work contours of an assigned resource. The generated data is obtained using TimeScaleData which takes the project start and finish dates as input parameters.
The following piece of code assigns different types of work contours to an assigned resource and displays its timephased data.
1// Create project instance
2System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"ResourceAssignmentTimephasedData.mpp");
3
4// Get the first task of the Project
5System::SharedPtr<Task> task = project1->get_RootTask()->get_Children()->GetById(1);
6
7// Get the First Resource Assignment of the Project
8System::SharedPtr<ResourceAssignment> firstRA = project1->get_ResourceAssignments()->ToList()->idx_get(0);
9
10// Flat contour is default contour
11System::Console::WriteLine(u"Flat contour");
12
13auto tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
14
15{
16 auto td_enumerator = (tdList)->GetEnumerator();
17 decltype(td_enumerator->get_Current()) td;
18 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
19 {
20 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
21 }
22}
23
24// Change contour
25firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::Turtle);
26System::Console::WriteLine(u"Turtle contour");
27tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
28
29{
30 auto td_enumerator = (tdList)->GetEnumerator();
31 decltype(td_enumerator->get_Current()) td;
32 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
33 {
34 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
35 }
36}
37
38// Change contour
39firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::BackLoaded);
40System::Console::WriteLine(u"BackLoaded contour");
41tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
42
43{
44 auto td_enumerator = (tdList)->GetEnumerator();
45 decltype(td_enumerator->get_Current()) td;
46 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
47 {
48 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
49 }
50}
51
52// Change contour
53firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::FrontLoaded);
54System::Console::WriteLine(u"FrontLoaded contour");
55tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
56
57{
58 auto td_enumerator = (tdList)->GetEnumerator();
59 decltype(td_enumerator->get_Current()) td;
60 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
61 {
62 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
63 }
64}
65
66// Change contour
67firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::Bell);
68System::Console::WriteLine(u"Bell contour");
69tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
70
71{
72 auto td_enumerator = (tdList)->GetEnumerator();
73 decltype(td_enumerator->get_Current()) td;
74 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
75 {
76 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
77 }
78}
79
80// Change contour
81firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::EarlyPeak);
82System::Console::WriteLine(u"EarlyPeak contour");
83tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
84
85{
86 auto td_enumerator = (tdList)->GetEnumerator();
87 decltype(td_enumerator->get_Current()) td;
88 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
89 {
90 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
91 }
92}
93
94// Change contour
95firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::LatePeak);
96System::Console::WriteLine(u"LatePeak contour");
97tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
98
99{
100 auto td_enumerator = (tdList)->GetEnumerator();
101 decltype(td_enumerator->get_Current()) td;
102 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
103 {
104 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
105 }
106}
107
108// Change contour
109firstRA->Set<WorkContourType>(Asn::WorkContour(), Aspose::Tasks::WorkContourType::DoublePeak);
110System::Console::WriteLine(u"DoublePeak contour");
111tdList = task->GetTimephasedData(project1->Get<System::DateTime>(Prj::StartDate()), project1->Get<System::DateTime>(Prj::FinishDate()));
112
113{
114 auto td_enumerator = (tdList)->GetEnumerator();
115 decltype(td_enumerator->get_Current()) td;
116 while (td_enumerator->MoveNext() && (td = td_enumerator->get_Current(), true))
117 {
118 System::Console::WriteLine(td->get_Start().ToShortDateString() + u" " + td->get_Value());
119 }
120}