We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting ResourceAssignment Cost

Hi!


How do I set the Cost of a ResourceAssignment (C#)?

Thanks,

Doug

Hi Doug,


Thank you for writing to Aspose support team.

Resource assignment is calculated by using the resource “Standard Rate” multiplied by number of hours worked by the resource. In the following example a 6 days task is assigned to a resource whose standard rate is $10. As total work hours are 8*6=48, therefore total resource assignment cost is $480. Could you please give a try to the following sample code and let us know the feedback?

Project project = new Project();<o:p></o:p>

project.Set(Prj.StartDate, new DateTime(2015, 7, 1, 8, 0, 0));

project.Set(Prj.NewTasksAreManual, false);

Task task = project.RootTask.Children.Add("Task");

Resource rsc = project.Resources.Add("Rsc");

rsc.Set(Rsc.StandardRate, 10);

// 6 days duration

task.Set(Tsk.Duration, project.GetDuration(6));

ResourceAssignment assn = project.ResourceAssignments.Add(task, rsc);

Console.WriteLine("Assignment cost = " + assn.Get(Asn.Cost));

project.Save(path + "Output.xml", SaveFileFormat.XML);

Your explanation “Resource assignment is calculated by using the resource “Standard Rate” multiplied by number of hours worked” kind of answers my question.


We have some complex rules that compute cost based upon hours, hourly rate, (and other factors) and we needed to be able to assign the Cost value.

Can other values such as BCWP or BCWS be assigned?

Thanks,

Doug

What I would like to be able to do is the following:


ResourceAssignment ra = … ;
decimal val = CalculateCost(…);
ra.Set(Asn.Cost, val);

Is this possible? My code compiles okay, but my “sets” appear to be ignored by MS Project.

Hi Doug,


This depends on the project’s calculation mode as follow:

Project Mode = None: You can set any value as per your requirements
Project Mode = Automatic: The value is recalculated even if you set it
Project Mode = Manual: The value is recalculated without rescheduling and without recalculation of other objects

Please try these at your end and share your feedback with us.

Thank you very much! This is exactly what I needed to get these rolling the way I need. Your help has been timely and most beneficial!

Hi Doug,


Thank you for providing feedback and please feel free to write us back if you have any other query related to Aspose.Tasks.