General Resource Assignment Properties
Contents
[
Hide
Show
]An assignment is a resource that has been assigned to a specific task. Each resource has general properties, typically a unique ID, a start and a finish time. This article explains how to set and get these properties with Aspose.Tasks.
Working with General Assignment Properties
The ResourceAssignment class exposes a number of properties used to set and get general assignment properties:
- Uid sets and gets an assignment’s unique ID (integer).
- Start sets and gets an assignment’s start date (DateTime).
- Finish sets and gets an assignment’s end date (DateTime).
To see an assignment’s general properties in Microsoft Project:
- From the View menu, select Task Usage.
- From the Insert menu, select Column.
- Add the Start. Finish and Unique ID columns.
Setting General Resource Assignment Properties using Aspose.Tasks
The following example shows how to set these properties from scratch.
1// Create empty project
2Project project = new Project();
3
4// Add new task and resource
5Task task = project.RootTask.Children.Add("Task");
6Resource resource = project.Resources.Add("Rsc");
7resource.Set(Rsc.StandardRate, 10);
8resource.Set(Rsc.OvertimeRate, 15);
9
10// Assign the resource desired task
11ResourceAssignment assignment = project.ResourceAssignments.Add(task, resource);
Getting General Resource Assignment Properties using Aspose.Tasks
The resource assignment properties can be accessed by traversing the project’s ResourceAssignments property.
1Project project = new Project("New Project.mpp");
2
3// Print general resource assignment properties
4foreach (ResourceAssignment ra in project.ResourceAssignments)
5{
6 Console.WriteLine(ra.Get(Asn.Uid));
7 Console.WriteLine(ra.Get(Asn.Start).ToShortDateString());
8 Console.WriteLine(ra.Get(Asn.Finish).ToShortDateString());
9}