ResourceAssignment

ResourceAssignment class

Represents a resource assignment in a project.

public class ResourceAssignment : IEquatable<ResourceAssignment>

Properties

Name Description
Baselines { get; } Gets AssignmentBaselineCollection object. The collection of baseline values associated with an assignment.
ExtendedAttributes { get; set; } Gets or sets an instance of the ExtendedAttributeCollection class for this object.
Guid { get; set; } Gets or sets unique identifier for this assignment.
ParentProject { get; } Gets parent project for this assignment.
Resource { get; set; }
Task { get; set; }
TimephasedData { get; set; } Gets or sets the instance of TimephasedDataCollection class containing elements of TimephasedData class.

Methods

Name Description
Delete() Deletes resource assignment from project assignments collection.
override Equals(object) Returns a value indicating whether this instance is equal to a specified object.
Equals(ResourceAssignment) Returns a value indicating whether this instance is equal to a specified instance of the ResourceAssignment class.
Get<T>(Key<T, AsnKey>) Returns the value to which the property is mapped in this container.
override GetHashCode() Returns a hash code value for the instance of the ResourceAssignment class.
GetTimephasedData(DateTime, DateTime) Returns TimephasedDataCollection object with the instances of TimephasedData class within given start and end dates of AssignmentWork.
GetTimephasedData(DateTime, DateTime, TimephasedDataType) Returns the instance TimephasedDataCollection class containing instances of TimephasedData class within given start and end dates of specified TimephasedDataType.
MakeTPs(DateTime, TimeSpan, Calendar, List<TimephasedData>, bool, int) Generates a list of time phased data.
Set<T>(Key<T, AsnKey>, T) Maps the specified property to the specified value in this container.
SplitTask(DateTime, DateTime, Calendar) Splits task into two parts.
TimephasedDataFromTaskDuration(Calendar) Generates list of time phased data based on the task duration and the scheduled start date.
override ToString() Returns short string representation of the instance of the ResourceAssignment class. The exact details of the representation are unspecified and subject to change.

Examples

Shows how to create an assignment and get/set common assignment properties.

var project = new Project(DataDir + "BudgetWorkAndCost.mpp");

var task = project.RootTask.Children.Add("Task");
task.Set(Tsk.Start, new DateTime(2020, 4, 2, 8, 0, 0));
task.Set(Tsk.Duration, project.GetDuration(1));
task.Set(Tsk.Finish, new DateTime(2020, 4, 2, 17, 0, 0));
var resource = project.Resources.Add("Resource");
var resourceAssignment = project.ResourceAssignments.Add(task, resource);
resourceAssignment.Set(Asn.Start, new DateTime(2020, 4, 2, 8, 0, 0));
resourceAssignment.Set(Asn.Work, project.GetWork(1));
resourceAssignment.Set(Asn.Finish, new DateTime(2020, 4, 2, 17, 0, 0));

Console.WriteLine(resourceAssignment.Get(Asn.Start));
Console.WriteLine(resourceAssignment.Get(Asn.Work));
Console.WriteLine(resourceAssignment.Get(Asn.Finish));

See Also