Saving Updated Resource Assignment to MPP

Contents
[ Hide Show ]

Aspose.Tasks for C++ API supports updating resource assignment data and writing it back to an MPP file.

Updating Resource Assignments

To read, assign and save the updated file:

  1. Read an MPP file. The one used in this example contains one task and one resource without any assignments.
  2. Assign the resource to the task.
  3. Add the assigned resource to the project.
  4. Finally, save the project to the MPP file.

The following code example demonstrates how to perform these tasks.

 1// Create project instance and access first task and resource
 2System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"UpdateResourceAssignment.mpp");
 3System::SharedPtr<Task> task = project1->get_RootTask()->get_Children()->GetById(1);
 4System::SharedPtr<Resource> rsc = project1->get_Resources()->GetById(1);
 5        
 6// Create resource assignment
 7System::SharedPtr<ResourceAssignment> assn = project1->get_ResourceAssignments()->Add(task, rsc);
 8assn->Set<System::String>(Asn::Notes(), u"Newly added assignment");
 9        
10// Save project as MPP
11project1->Save(dataDir + u"UpdateResourceAssignment_out.mpp", Aspose::Tasks::Saving::SaveFileFormat::MPP);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.