Working with Calendar Properties

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:

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}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.