General Calendar Properties

Contents
[ Hide Show ]

General Calendar Properties

Microsoft Project uses calendars and other information to calculate project end dates. Aspose.Tasks for C++ API supports calendar functionality. This article illustrates the calendar properties that can be set and shows how they are applied in code.

The Calendar exposes a number of properties used to define the base calendar in Microsoft Outlook:

The code example given below demonstrates how to get the general calendar properties.

 1// Load an existing project
 2System::String dataDir = Examples::CPP::RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 3System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project_GeneralCalendarProperties.xml");
 4    
 5    
 6{
 7    auto cal_enumerator = (project->get_Calendars())->GetEnumerator();
 8    decltype(cal_enumerator->get_Current()) cal;
 9    while (cal_enumerator->MoveNext() && (cal = cal_enumerator->get_Current(), true))
10    {
11        if (cal->get_Name() != nullptr)
12        {
13            System::Console::WriteLine(System::String(u"UID : ") + System::Convert::ToString(cal->get_Uid()) + u" Name: " + cal->get_Name());
14            
15            // Show if it is has a base calendar
16            System::Console::Write(u"Base Calendar : ");
17            if (cal->get_IsBaseCalendar())
18            {
19                System::Console::WriteLine(u"Self");
20            }
21            else
22            {
23                System::Console::WriteLine(cal->get_BaseCalendar()->get_Name());
24            }
25            
26            // Get Time in hours on each working day
27            
28            {
29                auto wd_enumerator = (cal->get_WeekDays())->GetEnumerator();
30                decltype(wd_enumerator->get_Current()) wd;
31                while (wd_enumerator->MoveNext() && (wd = wd_enumerator->get_Current(), true))
32                {
33                    System::TimeSpan ts = wd->GetWorkingTime();
34                    System::Console::WriteLine(System::String(u"Day Type: ") + System::ObjectExt::ToString(wd->get_DayType()) + u" Hours: " + System::ObjectExt::ToString(ts));
35                }
36            }
37        }
38    }
39}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.