General Resource Assignment Properties

An assignment is a resource that has been assigned to a specific task. Each resource has general properties, typically a unique ID, a start and a finish time. This article explains how to set and get these properties with Aspose.Tasks.

Working with General Assignment Properties

The ResourceAssignment class exposes a number of properties used to set and get general assignment properties:

To see an assignment’s general properties in Microsoft Project:

  1. From the View menu, select Task Usage.
  2. From the Insert menu, select Column.
  3. Add the Start. Finish and Unique ID columns.

Setting General Resource Assignment Properties using Aspose.Tasks

The following code example demonstrates how to set these properties from scratch.

 1// Create empty project
 2System::SharedPtr<Project> project1 = System::MakeObject<Project>();
 4// Add new task and resource
 5System::SharedPtr<Task> task1 = project1->get_RootTask()->get_Children()->Add(u"Task");
 6System::SharedPtr<Resource> rsc1 = project1->get_Resources()->Add(u"Rsc");
 7rsc1->Set<System::Decimal>(Rsc::StandardRate(), static_cast<System::Decimal>(10));
 8rsc1->Set<System::Decimal>(Rsc::OvertimeRate(), static_cast<System::Decimal>(15));
10// Assign the resource desired task
11System::SharedPtr<ResourceAssignment> assn = project1->get_ResourceAssignments()->Add(task1, rsc1);

Getting General Resource Assignment Properties using Aspose.Tasks

The resource assignment properties can be accessed by traversing the project’s ResourceAssignments property.

 1// Create project instance
 2System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"GetGeneralResourceAssignmentProperties.mpp");
 4// Print general resource assignment properties
 7    auto ra_enumerator = (project1->get_ResourceAssignments())->GetEnumerator();
 8    decltype(ra_enumerator->get_Current()) ra;
 9    while (ra_enumerator->MoveNext() && (ra = ra_enumerator->get_Current(), true))
10    {
11        System::Console::WriteLine(ra->Get<int32_t>(Asn::Uid()));
12        System::Console::WriteLine(ra->Get<System::DateTime>(Asn::Start()).ToShortDateString());
13        System::Console::WriteLine(ra->Get<System::DateTime>(Asn::Finish()).ToShortDateString());
14    }
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.