Assignment in Windows Forms proj (ProjIO)

29 Apr 20215 minutes to read

Assignment class is used to bind resources to tasks. It can also be used to retrieve the details of the task and resource that are bound together.

Properties, Methods, and Events Tables for Task

Constructors

Assignment Constructor

Name Description
Assignment.Assignment() Initializes a new instance of Assignment class.

Properties

Assignment Properties

Property Description
UID Gets or sets the unique identifier of the assignment.
TaskUID Gets or sets the unique identifier of the task.
ResourceUID Gets or sets the unique identifier of the resource.
PercentWorkComplete Gets or sets the amount of work completed on the assignment.
ActualCost Gets or sets the actual cost incurred on the assignment.
ActualFinish Gets or sets the actual finish date of the assignment.
ActualOvertimeCost Gets or sets the actual overtime cost incurred on the assignment.
ActualOvertimeWork Gets or sets the actual amount of overtime work incurred on the assignment.
ActualStart Gets or sets the actual start date of the assignment.
ActualWork Gets or sets the actual amount of work incurred on the assignment.
ACWP Gets or sets the actual cost of work performed on the assignment to-date.
Confirmed Whether the Resource has accepted all of his or her assignments.
Cost Gets or sets the projected or scheduled cost of the assignment.
CostRateTable Gets or sets the cost rate table used for the assignment.
CostVariance Gets or sets the difference between the cost and baseline cost for a resource.
CV Gets or sets the earned value cost variance.
Delay Gets or sets the amount that the assignment is delayed.
Finish Gets or sets the scheduled finish date of the assignment.
FinishVariance Gets or sets the variance of the assignment finish date from the baseline finish date.
Hyperlink Gets or sets the title of the hyperlink associated with the assignment.
HyperlinkAddress Gets or sets the hyperlink associated with the assignment.
HyperlinkSubAddress Gets or sets the document bookmark of the hyperlink associated with the assignment.
WorkVariance Gets or sets the variance of assignment work from the baseline work as minutes x 1000.
HasFixedRateUnits Whether the Units are Fixed Rate.
FixedMaterial Whether the consumption of the assigned material resource occurs in a single, fixed amount.
LevelingDelay Gets or sets the delay caused by leveling.
LevelingDelayFormat Gets or sets the format for expressing the duration of the delay.
LinkedFields Whether the Project is linked to another OLE object.
MileStone Whether the assignment is a milestone.
Notes Gets or sets the text notes associated with the assignment.
Overallocated Whether the assignment is over allocated.
OvertimeCost Gets or sets the sum of the actual and remaining overtime cost of the assignment.
OvertimeWork Gets or sets the scheduled overtime work scheduled for the assignment.
PeakUnits Gets or sets the largest number of units that a resource is assigned for a task.
RateScale Gets or sets the time unit for the usage rate of the material resource assignment.
RegularWork Gets or sets the amount of non-overtime work scheduled for the assignment.
RemainingCost Gets or sets the remaining projected cost of completing the assignment.
RemainingOvertimeCost Gets or sets the remaining projected overtime cost of completing the assignment.
RemainingOvertimeWork Gets or sets the remaining overtime work scheduled to complete the assignment.
RemainingWork Gets or sets the remaining work scheduled to complete the assignment.
ResponsePending Whether a response has been received for a TeamAssign message.
Start Gets or sets the scheduled start date of the assignment.
Stop Gets or sets the date that the assignment was stopped.
Resume Gets or sets the date that the assignment resumed.
StartVariance Gets or sets the variance of the assignment start date from the baseline start date.
Summary Whether the task is a summary task.
SV Gets or sets the earned value schedule variance, through the project status date.
Units Gets or sets the number of units for the assignment.
UpdateNeeded Whether the resource assigned to a task needs to be updated as to the status of the task.
VAC Gets or sets the difference between baseline cost and total cost.
Work Gets or sets the amount of scheduled work for the assignment.
WorkContour Gets or sets the work contour of the assignment.
BCWS Gets or sets the budgeted cost of work on the assignment.
BCWP Gets or sets the budgeted cost of work performed on the assignment to-date.
BookingType Gets or sets the booking type of the assignment.
ActualWorkProtected Gets or sets the duration through which actual work is protected.
ActualOvertimeWorkProtected Gets or sets the duration through which actual overtime work is protected.
CreationDate Gets or sets the date the assignment was created.
AssnOwner Gets or sets the name of the assignment owner.
AssnOwnerGuid Gets or sets the GUID of the assignment owner
BudgetCost Gets or sets the budgeted amount for cost resources on this assignment.
BudgetWork Gets or sets the budgeted work amount for work or material resources on this assignment.
ExtendedAttribute Gets or sets the value of an extended attribute.
Baseline Gets or sets the collection of baseline values associated with the assignment.
F404000 – F4040C8 Gets or sets Project 2010 assignment enterprise custom field elements.
TimePhasedData Gets or sets the time phased data associated with the assignment.

Methods

Assignment Methods

Method Description
Equals Returns a value indicating whether this instance is equal to a specified object
GetHashCode Serves as a hash function for Assignment type
GetType Gets the type of the current instance
ToString Returns a string that represents the current object

Adding Assignments to a Project

Assignments are used to bind the task and resources. Project class exposes Assignments collection that represents the list of all the Assignment objects in a project. This property can be used to add assignment.

The code below shows adding assignments to a project:

  • C#
  • // Creating an instance of the Project
    
    Project project = new Project();
    
    
    
    // Creating a task
    
    Task task = new Task();
    
    task.Name = "Task1";
    
    
    
    // Adding the task to project
    
    project.RootTask.Children.Add(task);
    
    
    
    // Calculating Task ID
    
    project.CalculateTaskIDs();
    
    
    
    // Creating a resource
    
    Resource resource = new Resource();
    
    resource.Name = "Resource1";
    
    
    
    // Adding resource to project
    
    project.Resources.Add(resource)
    
    
    
    // Calculating Resource ID
    
    project.CalculateResourceIDs()
    
    
    
    // Creating an instance of Assignment
    
    Assignment assignment = new Assignment();
    
    assignment.UID = 1;
    
    
    
    // Assigning resource to task
    
    assignment.Task = task;
    
    assignment.Resource = resource;
    
    
    
    // Adding resource to project
    
    project.Resources.Add(resource);
  • VBNET
  • ' Creating an instance of Project
    
    Dim project As Project = New Project()
    
    
    
    ' Creating an instance of Task
    
    Dim task As Task = New Task()
    
    task.Name = "Task1"
    
    
    
    ' Adding the task to project
    
    project.RootTask.Children.Add(task)
    
    
    
    ' Calculating Task ID
    
    project.CalculateTaskIDs()
    
    
    
    ' Creating an instance of Resource
    
    Dim resource As Resource = New Resource()
    
    resource.Name = "Resource1"
    
    
    
    ' Adding resource to project
    
    project.Resources.Add(resource)
    
    
    
    ' Calculating Resource ID
    
    project.CalculateResourceIDs()
    
    
    
    ' Creating an instance of Assignment
    
    Dim assignment As Assignment = New Assignment()
    
    assignment.UID = 1
    
    
    
    ' Assigning tasks and resource to assignment
    
    assignment.Task = task
    
    assignment.Resource = resource
    
    
    
    ' Adding an assignment to a project
    
    project.Assignments.Add(assignment)

    The project created using the above code will look as shown in the following Microsoft Project screenshot.

    Assignment_img1