Regarding MPP Import

Hi Team,


After using the new dll it shows that Extended Attribute is obsolete and gives warning.

Is there a simple way to read the MPP and add the values to the collection.

I am using the below code :_


Project projectWrite = new Project(fileStream);
ChildTasksCollector collector = new ChildTasksCollector();

//Collects all the tasks from RootTask using TaskUtils
TaskUtils.Apply(projectWrite.RootTask, collector, 0);

List<Accenture.CIO.TransIT.BusinessEntities.Task> tskObjList = new List<Accenture.CIO.TransIT.BusinessEntities.Task>();

foreach (Aspose.Tasks.Task tsk in collector.Tasks)
{
bool isText = false;
Accenture.CIO.TransIT.BusinessEntities.Task tskObj = new Accenture.CIO.TransIT.BusinessEntities.Task();
if (tsk.Get(Tsk.Id) > 0)
{
foreach (ExtendedAttribute att in tsk.ExtendedAttributes)
{
if (att.AttributeDefinition.FieldName == StringConstants.TextFieldOne) //Text field one is Action Flag
{
tskObj.ActionFlag = att.Value;
if (tskObj.ActionFlag == StringConstants.InsertAction) //It will extract the workStream Id for the newly inserted task.
{
if (tsk.ParentTask.ParentTask.ParentTask.Get(Tsk.Id) == 0) //If category is null.
{
if (tsk.ParentTask.ExtendedAttributes.Count > 0)
{
tskObj.WorkStreamId = Convert.ToInt32(tsk.ParentTask.ExtendedAttributes[0].Value); //If Category is not null.
}
}
else if (tsk.ParentTask.ParentTask.ParentTask.ParentTask.Get(Tsk.Id) == 0)
{
if (tsk.ParentTask.ExtendedAttributes.Count > 0)
{
tskObj.WorkStreamId = Convert.ToInt32(tsk.ParentTask.ExtendedAttributes[0].Value);
}
}
}
isText = true;
}

if (isText)
{
//Adding Comments to the TASK Object.
if (att.AttributeDefinition.FieldName == StringConstants.TextFieldTwo) //-- Comments
{
tskObj.Comments = att.Value;
}

//Adding Level to the TASK Object.
if (att.AttributeDefinition.FieldName == StringConstants.TextFieldThree) //-- Level Column
{
tskObj.TaskLevel = att.Value;
}
//Adding Deliverable to the TASK Object.
if (att.AttributeDefinition.FieldName == StringConstants.TextFieldFour) //–Owner Category/Deliverable
{
tskObj.OwnerCategory = att.Value;
}
//Adding Task Nbr to the TASK Object.
if (att.AttributeDefinition.FieldName == StringConstants.NumberFieldOne) // Hidden Field Task Number which will be 0 for Insert.
{
tskObj.Id = Convert.ToInt32(att.Value);
}
//Adding WorkStreamId (Number2) & Action Flag (Flag1) to the TASK Object.

if (att.AttributeDefinition.FieldName == StringConstants.NumberFieldTwo
|| att.AttributeDefinition.FieldName == StringConstants.TextFieldOne)
{
// if (att.AttributeDefinition.FieldName == StringConstants.NumberFieldTwo)
// {
if (tskObj.WorkStreamId == null) //Checking if the WorkStream is not null specially for the newly Inserted Task which has null workstreamId and is set above.
{
tskObj.WorkStreamId = Convert.ToInt32(att.Value);
}

//Adding MilestoneInd
tskObj.MilestoneInd = tsk.Get(Tsk.IsMilestone).Value == true ? StringConstants.ActiveInd : StringConstants.NoIndicator;
//Adding Percent Complete
tskObj.CompletionPct = tsk.Get(Tsk.PercentComplete);
//Adding Task Description to the TASK Object.
tskObj.TaskDesc = tsk.Get(Tsk.Name);
//Adding Duration Number to the TASK Object (Removing Day & filtering only the no. part).
var DurationNbr = Regex.Split(tsk.Get(Tsk.Duration).ToString(), @"\D+");
tskObj.DurationNbr = Convert.ToInt16(DurationNbr[0]);
//Adding Planned Start Date to the TASK Object.
tskObj.PlannedStartDt = tsk.Get(Tsk.Start);
//Adding Planned End Date to the TASK Object.
tskObj.PlannedEndDt = tsk.Get(Tsk.Finish);
//Adding Predecessor to the TASK Object.
if (tsk.Predecessors.Count > 0)
foreach (var predecessor in tsk.Predecessors)
{
// tskObj.PredecessorNbr = tskObj.PredecessorNbr + predecessor.Get(Tsk.Id).ToString() + “,”;
string predMPPNo = predecessor.Get(Tsk.Id).ToString();
string tskNumber = (GetTaskNumber(Convert.ToInt32(predMPPNo), projectWrite)).ToString();
if (tskNumber != null)
{
tskObj.PredecessorNbr = tskObj.PredecessorNbr + tskNumber + “,”;
}
}
//Adding Resource Name to the TASK Object.
foreach (Aspose.Tasks.ResourceAssignment ass in tsk.Assignments)
{
var a = ass.Get(Asn.Resource).Get(Rsc.Name);
if(!string.IsNullOrEmpty(ass.Get(Asn.Resource).Get(Rsc.Name)))
tskObj.OwnerNm = ass.Get(Asn.Resource).Get(Rsc.Name);
}
//Adding Action Flag to the TASK Object.
if (att.AttributeDefinition.FieldName == StringConstants.FlagFieldOne)
{
tskObj.CriticalPathInd = att.Value;

}
//Adding Category Description to the TASK Object.
if (tsk.ParentTask.ParentTask.ParentTask.Get(Tsk.Id) == 0)
{
tskObj.CategoryDesc = null;

}
else if (tsk.ParentTask.ParentTask.ParentTask.ParentTask.Get(Tsk.Id) == 0)
{
tskObj.CategoryDesc = tsk.ParentTask.Get(Tsk.Name);

}

isText = false;
}
}
}
if (tskObj != null && tskObj.ActionFlag
!= null)
tskObjList.Add(tskObj);
}

Thanks
Abhishek Prasad

Hi Abhishek,

Thank you for writing to Aspose support team.

The hotfix version provided to you earlier includes new API methods to create task extended attributes. Therefore, the warning message is included to use the new static methods instead of setting extended attribute properties. However, for reading the extended attribute properties, you may safely ignore the warning which is also mentioned as part of the warning message.

We also reviewed your code for reading the MPP file and that is the recommended approach for reading tasks and related properties. Please let us know if you have any further query in this regard.