Defining Weekdays for Exceptions

Contents
[ Hide Show ]

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

Defining 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 code example defines the dates 24-Dec-2009 through 31-Dec-2009 as exceptions.

 1System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
 2    
 3// Create a project instance
 4System::SharedPtr<Project> prj = System::MakeObject<Project>();
 5    
 6// Define Calendar
 7System::SharedPtr<Aspose::Tasks::Calendar> cal = prj->get_Calendars()->Add(u"Calendar1");
 8    
 9// Define week days exception for a holiday
10System::SharedPtr<CalendarException> except = System::MakeObject<CalendarException>();
11except->set_EnteredByOccurrences(false);
12except->set_FromDate(System::DateTime(2009, 12, 24, 0, 0, 0));
13except->set_ToDate(System::DateTime(2009, 12, 31, 23, 59, 0));
14except->set_Type(Aspose::Tasks::CalendarExceptionType::Daily);
15except->set_DayWorking(false);
16cal->get_Exceptions()->Add(except);
17    
18// Save the Project
19prj->Save(dataDir + u"Project_DefineWeekDayException_out.xml", Aspose::Tasks::Saving::SaveFileFormat::XML);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.