Working with Calendar Properties
Contents
[
Hide
Show
]Working with General Calendar Properties
Microsoft Project uses calendars and other information to calculate project end dates. Aspose.Tasks for .NET 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:
- BaseCalendar – the base calendar. This property supports the Calendar object for reading and writing the base calendar for the current calendar instance and is only applicable is the current calendar instance is not already a base calendar.
- Name – the calendar’s name. Get or set the property with a string.
- Uid – the calendar’s unique ID. Integer.
The code that follows gets the general calendar properties.
1// Load an existing project
2Project project = new Project("Project_GeneralCalendarProperties.xml");
3
4foreach (Calendar cal in project.Calendars)
5{
6 if (cal.Name != null)
7 {
8 Console.WriteLine("UID : " + cal.Uid.ToString() + " Name: " + cal.Name);
9
10 // Show if it is has a base calendar
11 Console.Write("Base Calendar : ");
12 if (cal.IsBaseCalendar)
13 Console.WriteLine("Self");
14 else
15 Console.WriteLine(cal.BaseCalendar.Name);
16
17 // Get Time in hours on each working day
18 foreach (WeekDay wd in cal.WeekDays)
19 {
20 TimeSpan ts = wd.GetWorkingTime();
21 Console.WriteLine("Day Type: " + wd.DayType.ToString() + " Hours: " + ts.ToString());
22 }
23 }
24}