Как работать с кодами набросок в проектах
Пользовательские наброски кодов - это теги, которые вы определяете для задач или ресурсов, которые предоставляют структуру проекта, которая отличается от кодов WBS или номеров. Aspose.Tasks для C ++ позволяет вам получить эти схемы кодов и их свойства, такие как псевдоним, Alllevelsrequired, Enterprise, EnterpriseOutlineCodealias, FieldId, FieldName, Phoneticeticias, Guid, Masks и ценности.
Чтение кодов набросок
Класс проекта разоблачает OutlineCodes, который представляет собой коллекцию предметов OutlineCodedEfinition. OutlineCodedEfinition предоставляет все детали, как показано в следующем примере кода.
Следующие строки кода получают информацию о коде проекта.
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"OutlineCodes.mpp");
2
3
4{
5 auto ocd_enumerator = (project->get_OutlineCodes())->GetEnumerator();
6 decltype(ocd_enumerator->get_Current()) ocd;
7 while (ocd_enumerator->MoveNext() && (ocd = ocd_enumerator->get_Current(), true))
8 {
9 System::Console::WriteLine(System::String(u"Alias = ") + ocd->get_Alias());
10 if (ocd->get_AllLevelsRequired())
11 {
12 System::Console::WriteLine(u"It contains property: must have all levels");
13 }
14 else
15 {
16 System::Console::WriteLine(u"It does not contain property: must have all levels");
17 }
18 if (ocd->get_Enterprise())
19 {
20 System::Console::WriteLine(u"It is an enterprise custom outline code.");
21 }
22 else
23 {
24 System::Console::WriteLine(u"It is not an enterprise custom outline code.");
25 }
26
27 System::Console::WriteLine(System::String(u"Reference to another custom field for which this outline code definition is an alias is = ") + ocd->get_EnterpriseOutlineCodeAlias());
28 System::Console::WriteLine(System::String(u"Field Id = ") + ocd->get_FieldId());
29 System::Console::WriteLine(System::String(u"Field Name = ") + ocd->get_FieldName());
30 System::Console::WriteLine(System::String(u"Phonetic Alias = ") + ocd->get_PhoneticAlias());
31 System::Console::WriteLine(System::String(u"Guid = ") + ocd->get_Guid());
32
33 // Display outline code masks
34
35 {
36 auto outlineMask_enumerator = (ocd->get_Masks())->GetEnumerator();
37 decltype(outlineMask_enumerator->get_Current()) outlineMask;
38 while (outlineMask_enumerator->MoveNext() && (outlineMask = outlineMask_enumerator->get_Current(), true))
39 {
40 System::Console::WriteLine(System::String(u"Level of a mask = ") + outlineMask->get_Level());
41 System::Console::WriteLine(System::String(u"Mask = ") + System::ObjectExt::ToString(outlineMask));
42 }
43 }
44
45 // Display out line code values
46
47 {
48 auto outlineMask1_enumerator = (ocd->get_Values())->GetEnumerator();
49 decltype(outlineMask1_enumerator->get_Current()) outlineMask1;
50 while (outlineMask1_enumerator->MoveNext() && (outlineMask1 = outlineMask1_enumerator->get_Current(), true))
51 {
52 System::Console::WriteLine(System::String(u"Description of outline value = ") + outlineMask1->get_Description());
53 System::Console::WriteLine(System::String(u"Value Id = ") + outlineMask1->get_ValueId());
54 System::Console::WriteLine(System::String(u"Value = ") + outlineMask1->get_Value());
55 System::Console::WriteLine(System::String(u"Type = ") + System::ObjectExt::ToString(outlineMask1->get_Type()));
56 }
57 }
58 }
59}
Check Outline Code Id Uniqueness
While working with OutlineCode, Aspose.Tasks shall check the uniqueness of the Outline Code Id and duplicate Ids will be replaced with unique values.
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"OutlineValues2010.mpp");
2
3System::SharedPtr<OutlineCodeDefinition> textOutline = System::MakeObject<OutlineCodeDefinition>();
4textOutline->set_FieldId(System::Convert::ToString((int)Aspose::Tasks::ExtendedAttributeTask::OutlineCode7));
5textOutline->set_Alias(u"My Outline Code");
6
7project->get_OutlineCodes()->Add(textOutline);
8
9System::SharedPtr<OutlineMask> mask = System::MakeObject<OutlineMask>();
10mask->set_Type(Aspose::Tasks::MaskType::Characters);
11textOutline->get_Masks()->Add(mask);
12
13System::SharedPtr<OutlineValue> textValue = System::MakeObject<OutlineValue>();
14textValue->set_Value(u"Text value 1");
15textValue->set_ValueId(1);
16textValue->set_Type(Aspose::Tasks::OutlineValueType::Text);
17textValue->set_Description(u"Text value descr 1");
18textOutline->get_Values()->Add(textValue);
19
20project->Save(dataDir + u"MultipleOutlineValues.mpp", Aspose::Tasks::Saving::SaveFileFormat::MPP);