Read Write Rate Scale Information
Effective management of resource assignments in project planning requires not only tracking costs and work but also adjusting the Rate Scale settings. The rate scale determines how resource costs are applied over time (per hour, per day, per week, etc.). With Aspose.Tasks for .NET you can programmatically read and modify this information, enabling flexible project automation and integration with financial systems.
Read/Write RateScale Information for Resource Assignment
Aspose.Tasks for .NET provides the
ResourceAssignment
class, which includes the RateScale
property. This property controls how assignment rates are calculated and distributed across the project timeline.
The following example demonstrates how to read and update the RateScale property of a resource assignment. It loads an existing project file, accesses the assignment, modifies its rate scale, and saves the updated project.
1Project project = new Project("New Project.mpp");
2
3Task task = project.RootTask.Children.Add("t1");
4
5Resource materialResource = project.Resources.Add("materialResource");
6materialResource.Set(Rsc.Type, ResourceType.Material);
7
8Resource nonMaterialResource = project.Resources.Add("nonMaterialResource");
9nonMaterialResource.Set(Rsc.Type, ResourceType.Work);
10
11ResourceAssignment materialResourceAssignment = project.ResourceAssignments.Add(task, materialResource);
12materialResourceAssignment.Set(Asn.RateScale, RateScaleType.Week);
13
14ResourceAssignment nonMaterialResourceAssignment = project.ResourceAssignments.Add(task, nonMaterialResource);
15nonMaterialResourceAssignment.Set(Asn.RateScale, RateScaleType.Week);
16
17project.Save("output.mpp", SaveFileFormat.MPP);
18
19project = new Project("output.mpp");
20
21ResourceAssignment materialResourceAssignment2 = project.ResourceAssignments.GetByUid(1);
22Console.WriteLine(materialResourceAssignment2.Get(Asn.RateScale));
23
24// only material resource assignments can have non-zero rate scale value.
25ResourceAssignment nonMaterialResourceAssignment2 = project.ResourceAssignments.GetByUid(2);
In this example, the code first retrieves the current RateScale
value, then updates it to a new scale (for example, from per hour to per day). This is particularly useful when adapting project data for different reporting standards or resource billing agreements.
FAQ
Q: What is the RateScale property used for?
- The
RateScale
property defines how the cost of a resource assignment is distributed over time (e.g., hourly, daily, weekly).
Q: Do I need Microsoft Project installed to read or update rate scales?
- No. Aspose.Tasks for .NET works independently of Microsoft Project and allows direct programmatic access to project data.
Q: Can I change the RateScale value and save it back to an MPP file?
- Yes. After modifying the
RateScale
, you can save the project back into formats such as MPP, XML, or MPX.
Q: Does updating RateScale affect assignment costs?
- Yes. Changing the rate scale can affect how costs are calculated and displayed, since it alters the time unit used for resource billing.
Conclusion
In this article, we learned how to read and update the RateScale property of a resource assignment using Aspose.Tasks for .NET. By modifying rate scale values programmatically, developers can ensure consistency in financial reporting, adapt assignments for different billing methods, and integrate project data seamlessly into custom solutions.