General Resource Assignment Properties
A resource assignment represents a resource linked to a specific task. Each assignment has basic general properties such as a unique identifier, start date, and finish date. Aspose.Tasks for .NET allows developers to programmatically set and retrieve these properties, providing more control over project management automation.
Working with General Assignment Properties
The ResourceAssignment class exposes several key properties:
- Uid – sets or gets an assignment’s unique ID (integer).
- Start – sets or gets the assignment’s start date (DateTime).
- Finish – sets or gets the assignment’s finish date (DateTime).
To view assignment properties in Microsoft Project manually:
- 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
In the following example, we create a resource assignment from scratch and set its unique ID, start date, and finish date. This is useful when initializing new assignments programmatically.
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 next example demonstrates how to read general assignment properties by iterating through the ResourceAssignments collection in a project. This approach is typically used when analyzing or reporting existing project data.
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}FAQ
Q: Do I need Microsoft Project installed to read or edit general assignment properties?
- No. Aspose.Tasks for .NET provides full access to these properties without requiring Microsoft Project.
Q: Can I set both start and finish dates programmatically?
- Yes. The
StartandFinishproperties can be set directly to define custom assignment timelines.
Q: Will changes to UID, Start, or Finish be preserved in Microsoft Project after saving?
- Yes. Any modifications you make with Aspose.Tasks will appear correctly when the project file is opened in Microsoft Project.
Conclusion
General resource assignment properties such as UID, Start, and Finish are fundamental for project scheduling. With Aspose.Tasks for .NET, you can easily set or retrieve these values programmatically, making it simple to automate project workflows, validate assignments, or generate reports—all without depending on Microsoft Project.