Retrieving Task's Budget Work and Cost Values

Microsoft Project 2007 and 2010 provide budget cost and budget work as task fields. Aspose.Tasks for .NET provides these properties as BudgetWork and BudgetCost.

Reading budget work and cost value

Before Aspose.Tasks for .NET 5.0.0, budget work and cost could be calculated by accessing an activity’s resource assignments and summing up the budget cost and work values. From Aspose.Task for .NET 5.0.0, it can be obtained directly as described in the following code.

The following lines of code retrieve a task’s budget work and cost information.

 1Project project = new Project("New Project.mpp");
 2
 3// Display budget work and budget cost for project summary task
 4Task projSummary = project.RootTask;
 5Console.WriteLine("projSummary.BudgetWork = " + projSummary.Get(Tsk.BudgetWork).ToString());
 6Console.WriteLine("projSummary.BudgetCost = " + projSummary.Get(Tsk.BudgetCost).ToString());
 7
 8// Display resource budget work
 9Resource resource = project.Resources.GetByUid(6);
10Console.WriteLine("Resource BudgetWork = " + resource.Get(Rsc.BudgetWork).ToString());
11
12// Display resource budget cost
13resource = project.Resources.GetByUid(7);
14Console.WriteLine("Resource BudgetCost = " + resource.Get(Rsc.BudgetCost).ToString());
15
16// Display assignment budget work and budget cost
17foreach (ResourceAssignment assignment in projSummary.Assignments)
18{
19    if (assignment.Get(Asn.Resource).Get(Rsc.Type) == ResourceType.Work)
20        Console.WriteLine("Assignment BudgetWork = " + assignment.Get(Asn.BudgetWork).ToString());
21    else
22        Console.WriteLine("Assignment BudgetCost = " + assignment.Get(Asn.BudgetCost).ToString());
23}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.