Resource and Calendars

The Resource class exposes the Calendar property which is used to set or get the calendar for a resource. This property accepts and returns an Aspose.Tasks.Calendar object.

Working with Resource Calendars

To define a calendar for a resource in Microsoft Project:

  1. In the Resource Sheet, double-click the desired resource.
  2. Click the Change Working Time button.

Setting Resource Calendar using Aspose.Tasks

The following code creates a standard calendar and resource and then assigns the calendar to the resource.

1Project project = new Project();
2Resource res = project.Resources.Add("Resource1");
3
4// Add standard calendar and assign to resource
5Calendar cal = project.Calendars.Add("Resource1");
6res.Set(Rsc.Calendar, cal);

Getting Resource Calendar using Aspose.Tasks

The code below shows how to get resource calendars by traversing a project’s resources.

 1Project project = new Project("New Project.mpp");
 2
 3// Display base calendar name for all resources
 4foreach (Resource res in project.Resources)
 5{
 6    if (res.Get(Rsc.Name) != null)
 7    {
 8        Console.WriteLine(res.Get(Rsc.Calendar).BaseCalendar.Name);
 9    }
10}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.