Issue in reading data in custom fields

I’m using Aspose.Tasks to import the .mpp file data into SQL DB. For some files, it imports data correctly, but for some others, it converts the data to null when importing to DB. This only happens on custom fields. Can you please help me with this issue? I’ve attached the sample file below. For example, custom fields Text30 on NWA WBS ID column and Text18 on MPM Element Type column return null data when importing into SQL DB.

When digging in further, I found that some of the custom fields don’t belong to the ExtendedAttribute arraylist from the Task. For example, custom field Text30 has Alias “NWA WBS ID”, but it doesn’t return in the custom field arraylist below


So I wonder if there is other Class besides ExtendedAttribute in the task to return the custom field collection?

Sorry, I didn’t realize the post didn’t take image format, so I’m pasting the code here again

StringBuilder sbCustom = new StringBuilder();
sbCustom.Append("|Flag1|Flag2|Flag3|Flag4|Flag5|Flag6|Flag7|Flag8|Flag9|Flag10");
sbCustom.Append("|Flag11|Flag12|Flag13|Flag14|Flag15|Flag16|Flag17|Flag18|Flag19|Flag20");
sbCustom.Append("|Number1|Number2|Number3|Number4|Number5|Number6|Number7|Number8|Number9|Number10");
sbCustom.Append("|Number11|Number12|Number13|Number14|Number15|Number16|Number17|Number18|Number19|Number20");
sbCustom.Append("|Text1|Text2|Text3|Text4|Text5|Text6|Text7|Text8|Text9|Text10");
sbCustom.Append("|Text11|Text12|Text13|Text14|Text15|Text16|Text17|Text18|Text19|Text20");
sbCustom.Append("|Text21|Text22|Text23|Text24|Text25|Text26|Text27|Text28|Text29|Text30|");

        ArrayList alCustom = new ArrayList(t.ExtendedAttribute);
        foreach (ExtendedAttribute ea in alCustom) //alCustom.Count returns only 9 while the file has 30 custom fields.
        {
            sbCustom.Replace(ea.AttributeDefinition.FieldName + "|", ea.Value + "|");
             
          
        }

Hi Thien,


Thank you for using Aspose.Tasks.

We can define custom fields which become part of ExtendedAttributes collection of project or tasks wherever required. Now project and each task may contain different combination of these attributes and, hence, count of extended attributes against project and each task is different. For example in the current sample file, following are the number of extended attributes available:
  • Project 68
  • Task1 9
  • Task2 12
  • Task3 13
  • Task4 25
First three tasks do not contain the attributes “NWA WBS ID” and “MPM Element Type”. whereas 4th task contains these extended attributes. These tasks are in a hierarchy such that Task1 has child Task2, which in turn has child Task3, and finally Task3 has child Task4. The above mentioned attribute values can be obtained by recursively parsing this tree. Attached image shows this hierarchy.

Following is the sample code which recursively parses this tree and finally displays the required attributes.

static void Main(string[] args)
{
//create a prject reader instance
ProjectReader projectReader = new ProjectReader();
//call read method of project reader object to get project object
FileStream projectStream = new FileStream("E-1Task.mpp", FileMode.Open);
Project prj = projectReader.Read(projectStream);
projectStream.Close();

//Display project Extended Attributes count

Console.WriteLine("Project total extended properties = " + prj.ExtendedAttributes.Count);
//Access root task of the project
ArrayList alTasks = prj.RootTask.Children;

//Display extended properties
DisplayChildren(alTasks);
}
static void DisplayChildren(ArrayList children)
{
//Parse each children in the task
foreach (Task tsk in children)
{
Console.WriteLine("--------------------------------------");
//Display task name
Console.WriteLine("Task Name = " + tsk.Name);
//Get array list of current task Extended Attributes
ArrayList eas = tsk.ExtendedAttribute;
if (eas != null)
{
//Display current task total attributes count
Console.WriteLine("Total Attributes =" + eas.Count);
//Flag to track if required attribute is found
bool bIsAttribFound = false;
foreach (ExtendedAttribute ea in eas)
{
//Check the required attributes presence
if (ea.FieldId == "188744016" || ea.FieldId == "188744004")
{
Console.WriteLine(ea.AttributeDefinition.Alias.Trim() + " (" + ea.FieldId + ") = " + ea.Value);
bIsAttribFound = true;
}
}
if (!bIsAttribFound)
Console.WriteLine(" does not contain NWA WBS ID & MPM Element Type");
}
//Parse Recursively
if (tsk.Children != null)
{
DisplayChildren(tsk.Children);
}
}
}
Following is output of the above sample code:


Project total extended properties = 68
--------------------------------------
Task Name = EA-18G LOT 34 PRODUCTION
Total Attributes =9
does not contain NWA WBS ID & MPM Element Type
--------------------------------------
Task Name = Program Office (LOE)
Total Attributes =12
does not contain NWA WBS ID & MPM Element Type
--------------------------------------
Task Name = Gate Reviews
Total Attributes =13
does not contain NWA WBS ID & MPM Element Type
--------------------------------------
Task Name = Gate 11 Review (Program Close-out)
Total Attributes =25
NWA WBS ID (188744016) = 601192909AF02P
MPM Element Type (188744004) = P

Please test above code and comment.

Hi Thien,

I can also read the correct values from your sample file. You can use the following simple code to read custom fields:

ProjectReader reader = new ProjectReader();
Project project = reader.Read("E - 1 Task.mpp");
ChildTasksCollector collector = new ChildTasksCollector();
TaskUtils.Apply(project.RootTask, collector, 0);
foreach (Task task in collector.Tasks)
{
    Console.WriteLine(task.Name + " : " + task.Wbs);
    foreach (ExtendedAttribute extendedAttribute in task.ExtendedAttribute)
    {
        Console.WriteLine(extendedAttribute.AttributeDefinition.FieldName + " :" + extendedAttribute.Value);
    }
    Console.WriteLine("-----------------------------------------------");
}

Best Regards,

Yeah, I agree I can read the ExtendedAttribute values of the first file I sent, but for this file, the extended attribute value can’t be read. For example, Text30 (Alias : NWA/WBS ID) has value 601221776CB01, and Text27 (Alias: IPDS) has value “2-01.01,2-02,2-03.01,2-03.02,2-03.03,2-03.05,2-03.10” on the child task Fourth, but the output came out empty or null. I’ve attached the second file below. Could you please check it out?

Hi Thien,


Thank you for using Aspose.Tasks.

I can observe and reproduce the issue, as you have mentioned, with both the coding methods mentioned above. I have forwarded these details to the development team for further investigation. We will let you know here once we have an update from our development team about this issue.

The issue has been logged in our Issue Tracking System as: TASKS-33193.

Thanks for your support. I’m looking forward to hearing from you soon.

I know that you have been working on the issue, but can you let me know when the fix is ready? We’ve been waiting on this fix to get to UAT.

Hi,


Thank you for using Aspose.Tasks and being patient.

I have checked the status of this issue from our Issue Tracking System and found that we will be able to include the fix for this issue in the upcoming product release of Aspose.Tasks, which is due by the beginning of next month.

You will be notified here once the issue is cross checked for resolution and included in the upcoming Release. We appreciate your patience in this regard.

The issues you have found earlier (filed as TASKS-33193) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issue seems not to be fixed yet in this new update. One thing I noticed that it might be working in MS Project 2010, but not in 2007. The custom fields Text30 still don’t import data correctly, it should have 601221776CB01 value for task 5, but it imports empty value. Can you please check it out with this file in MS Projec 2007? We really need this to be fixed before August 20th since our deployment has been delayed due to Aspose.Task import issue.

Hi,

Thank you for the feedback.

I tested your earlier file with the latest version of Aspose.Tasks v4.5.0 and found that the value of custom filed Text30 is retrieved properly. Please refer to the following code for your reference. I have also attached screenshot of the displayed values here.

static void Main(string[] args)
{
    Aspose.Tasks.License license = new Aspose.Tasks.License();
    license.SetLicense("Aspose.Total.Product.Family.lic");
    string file = "VACM Thien.mpp"; // Attached project
    ProjectReader reader = new ProjectReader();
    Project project = reader.Read(file);
    Task task4 = project.GetTaskById(5);
    ExtendedAttribute attr = ArrayUtils.Find(task4.ExtendedAttribute, new FilterByAlias("IPDS")) as ExtendedAttribute;
    Console.WriteLine(attr.Value);
    attr = ArrayUtils.Find(task4.ExtendedAttribute, new FilterByAlias("NWA/WBS ID")) as ExtendedAttribute;
    Console.WriteLine(attr.Value);
    Console.WriteLine("Press any key to continue...");
    Console.ReadKey();
}
private class FilterByAlias : ICondition
{
    private string alias;
    public FilterByAlias(string alias)
    {
        this.alias = alias.ToUpper(CultureInfo.InvariantCulture).Trim();
    }
    public bool Check(object el)
    {
        ExtendedAttribute attr = el as ExtendedAttribute;
        if (attr == null || attr.AttributeDefinition == null || attr.AttributeDefinition.Alias == null)
            return false;
        return (attr.AttributeDefinition.Alias.ToUpper(CultureInfo.InvariantCulture).Trim() == alias);
    }
}

I also tried to check the last file that you have attached in the posting, but I can not find task 5 in this file to retrieve the Custom field value from it. Can you please verify if you have provided us the correct file?

Hi,


Thank you for the feedback.

I can observe the issue as you have mentioned using Aspose.Tasks v 4.5.0. I have reopened this issue so that our development team can investigate it further with the latest input file that you have provided. We will update you here once we have any information from our development team in this regard. We are sorry for the inconvenience you have faced.

Thank you for your support. I just wonder if you could have this issue fixed by August 20th? Our deployment has been delayed for more than a month due to this issue.

Thanks again. Looking forward to hearing from you soon.

Thien

Hi Thien,


We are extremely sorry for the inconvenience you have faced.

I have just checked the status of this issue from our issue tracking system and found that our development team has already started looking into its resolution. Hopefully, we will be able to provide you a hot fix by the end of this week.

Once again, please accept our apologies for the inconvenience.

Hi Thien,


Thank you for being patient for the resolution of this issue.

We have fixed this issue for all versions of MSP files. Please download and try the latest fix Aspose.Tasks v 4.5.1 and let us know your feedback.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.