Working with Resources and Calendars

In Microsoft Project, resources such as people, equipment, or materials can be assigned calendars that define their availability. By working with resource calendars, you can accurately model real-world constraints, manage working and non-working time, and improve scheduling accuracy. This guide explains how to create and assign resource calendars programmatically using Aspose.Tasks for .NET, as well as how to retrieve existing calendars from a project file.

Working with Resource Calendars

To define a calendar for a resource in Microsoft Project manually:

  1. In the Resource Sheet, double-click the desired resource.
  2. Click the Change Working Time button and adjust the working hours or exceptions.

With Aspose.Tasks, you can automate this process directly in C# without requiring Microsoft Project to be installed.

Setting Resource Calendar using Aspose.Tasks

The following example demonstrates how to create a standard calendar, define a resource, and then assign the calendar to that resource. This ensures that the resource availability strictly follows the specified calendar.

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 next example shows how to traverse all project resources and retrieve their assigned calendars. This is useful for analyzing existing schedules or verifying that resources are configured correctly.

 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}

FAQ

Q: Do I need Microsoft Project installed to work with resource calendars?

Q: Can I define custom working hours for a resource calendar?

Q: Is it possible to assign different calendars to different resources?

Conclusion

Resource calendars are essential for accurate project planning and resource allocation. With Aspose.Tasks for .NET, developers can create, assign, and retrieve calendars programmatically, ensuring flexible and precise scheduling without relying on Microsoft Project. This allows for automation, integration, and scalability in enterprise project management solutions.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.