Reading and Writing General Resource Properties
In Microsoft Project, each resource is defined by a set of general properties that uniquely identify it and determine its availability within a project. These attributes include the resource’s name, identifiers (ID/UID), and time availability (start and finish dates). With Aspose.Tasks for .NET, developers can easily read and modify these general properties directly from Microsoft Project files (MPP/XML). This enables programmatic control over resource management without relying on Microsoft Project, making it useful for custom reporting, data synchronization, or project automation tools.
General Resource Properties
The Resource class provides several important properties:
- Name – gets or sets the resource’s name (
string). - Id – gets or sets the resource’s ID (
int). - Uid – gets or sets the resource’s unique ID (
int). - Start – gets or sets the resource’s start date (
DateTime). - Finish – gets or sets the resource’s finish date (
DateTime).
These properties ensure that each resource is properly identified and scheduled within a project plan.
Working with General Resource Properties
To view a resource’s general properties in Microsoft Project manually:
- From the View menu, select More Views, then choose Resource Sheet.
- From the Insert menu, select Column.
- Add the columns such as Start, Finish, ID, and Unique ID.
This provides visibility into the core attributes of project resources.
Setting General Resource Properties using Aspose.Tasks
The following code example demonstrates how to set general resource properties programmatically. This snippet creates or updates a resource by assigning values to its Name, Id, Uid, Start, and Finish properties. Such automation helps streamline resource initialization or synchronization across multiple project files.
1// Add resources
2Resource resource = project.Resources.Add("Rsc");
3
4// Set resource properties, Resource properties are represented by static class Rsc
5resource.Set(Rsc.StandardRate, 15);
6resource.Set(Rsc.OvertimeRate, 20);FAQ
Q: What is the difference between Id and Uid?
Idis the visible identifier of a resource within a project file, whileUidis a globally unique identifier that remains consistent across operations and versions.
Q: Can I set custom start and finish dates for resources?
- Yes. By assigning values to the
StartandFinishproperties, you can control the availability period of a resource.
Q: Which formats support reading and writing resource properties?
- Aspose.Tasks supports both MPP and XML Microsoft Project file formats.
Q: Can I bulk update resource properties?
- Yes. You can iterate through the resource collection and update properties for multiple resources programmatically.
Conclusion
Managing general resource properties is fundamental for organizing and scheduling resources in project plans. With Aspose.Tasks for .NET, developers can easily read, update, and control resource identifiers, names, and availability dates directly from Microsoft Project files. This provides flexibility for automation, integration, and custom project management solutions without requiring Microsoft Project itself.