Hi
Hi Craig,
Hi Kashif
You are right about those extended attributes but there are many appearing in the collection that are empty in the plan.
For example, OutlineCode10 - it has no values in the plan yet element 129 of the collection contains OutlineCode10
When I analyse other MS Project plan with a blank OutlineCode10 it never appears in the collection - whereas for this plan it does.
I am using ASPOSE tasks to read MS Project plans to import the data in the plans into my database.
HTH
Craig
Hi Craig,
static public void DisplayProjectExtendedAttributes()
{
Project prj = new Project(@“kayak.mpp”);
//Declare ChildTasksCollector class object
ChildTasksCollector collector = new ChildTasksCollector();
//Use TaskUtils to get all children tasks in RootTask
TaskUtils.Apply(prj.RootTask, collector, 0);
foreach (Task tsk in collector.Tasks)
{
Console.WriteLine("Task Id = " + tsk.Id + “, Task=” + tsk.Name);
List TaskEas = tsk.ExtendedAttribute;
foreach (ExtendedAttribute TaskEa in TaskEas)
{
Console.WriteLine(“Ex Field Name = " + TaskEa.AttributeDefinition.FieldName);
Console.WriteLine(“Value = " + TaskEa.Value.ToString());
}
Console.WriteLine(”___________________________________”);
}
}
Hi Kashif
When we read a plan we immediately look at the ExtendedAttributes collection to determine if the plan is using any custom columns. We then make decisions based on that fact. For most plans the ExtendedAttributes collection only contains columns that are actually being used. If no columns are being used it is blank (I have attached a sample plan that has an empty ExtendedAttributes collection).
The weird thing about the kayak.mpp plan is that it is handled differently to other plans where the ExtendedAttributes collection has much fewer elements in it.
Craig
Hi Craig,
static public void CreateExtendedAttributes()
{
//create a project instance
Project prj = new Project(@“Template.mpp”);
List eads = prj.ExtendedAttributes;
if (eads == null)
{
eads = new List();
prj.ExtendedAttributes = eads;
}
// Create extended attribute definition
ExtendedAttributeDefinition ead = new ExtendedAttributeDefinition();
ead.FieldId = ((int)ExtendedAttributeTask.Number1).ToString();
ead.FieldName = “Number1”;
eads.Add(ead);
// Following code is disabled which adds value for attribute “Number1”
// Get zero index task
//Task tsk = (Task)prj.RootTask.Children[0];
//List eas = tsk.ExtendedAttribute;
//if (eas == null)
//{
// eas = new List();
// tsk.ExtendedAttribute = eas;
//}
//ExtendedAttribute ea = new ExtendedAttribute();
//ea.FieldId = ead.FieldId;
//ea.Value = “123”;
//eas.Add(ea);
prj.Save(@“New.mpp”, SaveFileFormat.MPP);
}