We are pleased to announce the release of Aspose.Tasks for .NET 18.6. This release introduces a new feature of writing extended attributes information to resource assignments similar to tasks and resources. It also improves the overall API functionality by fixing issues reported with the previous version of the API. For a detailed note on what is new and fixed, please visit the release notes section of API documentation.

Adding Extended Attributes to Resource Assignments

Aspose.Tasks API already had the capability to add extended attributes to tasks and resources in a project. This month’s release introduces the capability to add extended attributes information to resource assignments as well. Extended Attributes can be added to resource assignments as plain as well as lookup values. The ollowing examples show adding these two type of extended attributes to the project.

Adding Extended Attribute

Project project = new Project(dataDir + "Blank2010.mpp");

// Add new task and resource
Task task1 = project.RootTask.Children.Add("Task");
Resource rsc1 = project.Resources.Add("Rsc");

// Assign the resource desired task
ResourceAssignment assn = project.ResourceAssignments.Add(task1, rsc1);

var assignment = project.ResourceAssignments.First();

// Custom attributes which is visible in "Resource Usage" view can be created with ExtendedAttributeDefinition.CreateResourceDefinition method.
{
    ExtendedAttributeDefinition resCostAttr = ExtendedAttributeDefinition.CreateResourceDefinition(
        CustomFieldType.Cost,
        ExtendedAttributeResource.Cost5,
        "My cost");

    project.ExtendedAttributes.Add(resCostAttr);

    var value = resCostAttr.CreateExtendedAttribute();
    value.Value = "1500";

    assignment.ExtendedAttributes.Add(value);
}

// Custom attributes which is visible in "Task Usage" view can be created with ExtendedAttributeDefinition.CreateTaskDefinition method
{
    ExtendedAttributeDefinition resCostAttr2 = ExtendedAttributeDefinition.CreateTaskDefinition(
        CustomFieldType.Cost,
        ExtendedAttributeTask.Cost5,
        "My cost for task");

    project.ExtendedAttributes.Add(resCostAttr2);

    var value = resCostAttr2.CreateExtendedAttribute();
    value.Value = "2300";

    assignment.ExtendedAttributes.Add(value);
}

project.Save(dataDir + "AddExtendedAttributesToResourceAssignment_out.mpp", SaveFileFormat.MPP); 

Adding Extended Attribute as Lookup Value

Project project = new Project(dataDir + "Blank2010.mpp");

var assignment = project.ResourceAssignments.First();

{
    ExtendedAttributeDefinition resCostAttr = ExtendedAttributeDefinition.CreateLookupResourceDefinition(
        CustomFieldType.Cost,
        ExtendedAttributeResource.Cost5,
        "My lookup cost");

    var value1 = new Value { NumberValue = 1500, Description = "Val 1", Id = 1, Val = "1500" };

    resCostAttr.AddLookupValue(value1);

    resCostAttr.AddLookupValue(new Value
    {
        NumberValue = 2500,
        Description = "Val 2",
        Id = 2
    });

    project.ExtendedAttributes.Add(resCostAttr);

    var value = resCostAttr.CreateExtendedAttribute(value1);
    value.Value = "1500";
    project.Save(dataDir + "AddExtendedAttributesToRAWithLookUp_out.mpp", SaveFileFormat.MPP); 

API Resources

You may visit the following API resources for getting started and working with the API.