Defining Weekdays for Exceptions

Contents
[ Hide Show ]

When setting up calendar exceptions with Aspose.Tasks for .NET, it is possible to define working days as exceptions.

Defining Calendar Workdays

The Exceptions collection exposed by the Calendar class can be used to define the weekdays for an exception.

To see a list of exceptions in Microsoft Project:

  1. Open a file.
  2. From the Tools menu, select Change Working Time to open the Change Working Time dialogue.

The following example defines the dates 24-Dec-2009 through 31-Dec-2009 as exceptions.

 1// Create a project instance
 2Project project = new Project();
 3
 4// Define Calendar
 5Calendar cal = project.Calendars.Add("Calendar1");
 6
 7// Define week days exception for a holiday
 8CalendarException except = new CalendarException();
 9except.EnteredByOccurrences = false;
10except.FromDate = new DateTime(2009, 12, 24, 0, 0, 0);
11except.ToDate = new DateTime(2009, 12, 31, 23, 59, 0);
12except.Type = CalendarExceptionType.Daily;
13except.DayWorking = false;
14cal.Exceptions.Add(except);
15
16project.Save("Project_DefineWeekDayException_out.xml", SaveFileFormat.XML);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.