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,
- Project 68
- Task1 9
- Task2 12
- Task3 13
- Task4 25
static void Main(string[] args){//create a prject reader instanceProjectReader projectReader = new ProjectReader();//call read method of project reader object to get project objectFileStream 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 projectArrayList alTasks = prj.RootTask.Children;//Display extended propertiesDisplayChildren(alTasks);}
static void DisplayChildren(ArrayList children){//Parse each children in the taskforeach (Task tsk in children){Console.WriteLine("--------------------------------------");//Display task nameConsole.WriteLine("Task Name = " + tsk.Name);//Get array list of current task Extended AttributesArrayList eas = tsk.ExtendedAttribute;if (eas != null){//Display current task total attributes countConsole.WriteLine("Total Attributes =" + eas.Count);//Flag to track if required attribute is foundbool bIsAttribFound = false;foreach (ExtendedAttribute ea in eas){//Check the required attributes presenceif (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 Recursivelyif (tsk.Children != null){DisplayChildren(tsk.Children);}}}
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) = PPlease 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,
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,
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 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,
Hi Thien,
The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.