Defining Weekdays for Exceptions

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 custom exception dates, including specific weekdays that should be treated differently from the base calendar schedule.

To view and modify such exceptions in Microsoft Project:

  1. Open the project file.
  2. From the Tools menu, choose Change Working Time to open the “Change Working Time” dialog box.
  3. Review the list of exceptions or add new ones using date ranges and weekday definitions.

Example: Define Weekday Exceptions

The following example demonstrates how to define a calendar exception for a date range from December 24 to December 31, 2009, specifying certain weekdays as working days within that exception range.

 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);

{{}}

Conclusion

Defining weekdays for calendar exceptions allows for greater flexibility in managing non-standard working schedules, such as partial holidays, shift work, or temporary calendar changes in a project. This feature supports real-world scheduling scenarios where standard working calendars need adjustments for specific periods.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.