Giter Site home page Giter Site logo

joniles / mpxj Goto Github PK

View Code? Open in Web Editor NEW
244.0 244.0 101.0 427.67 MB

Primary repository for MPXJ library

Home Page: http://www.mpxj.org/

License: GNU Lesser General Public License v2.1

CSS 0.02% C# 0.37% Ruby 3.34% Shell 0.01% Java 95.90% VBA 0.24% Visual Basic .NET 0.10% Python 0.01% Batchfile 0.03%

mpxj's People

Contributors

amarkssmartpm avatar brandonherzog avatar cjohnspm avatar danieltaylor-nz avatar dependabot[bot] avatar forenpm avatar jlleitschuh avatar joniles avatar lobmeleon avatar markatwood avatar ninthwaveltd avatar rsinha9 avatar sebastianstock avatar ztravis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mpxj's Issues

P6 .xer file cannot be opened by latest MPXJ (7.5.0)

Hello,

Parsing this basic .xer file (found in simple.xer.zip) using MPXJ leads to an exception:

Reading input file started.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
	at net.sf.mpxj.primavera.DatatypeConverter.parseUUID(DatatypeConverter.java:59)
	at net.sf.mpxj.primavera.MapRow.getUUID(MapRow.java:156)
	at net.sf.mpxj.primavera.PrimaveraReader.processFields(PrimaveraReader.java:1438)
	at net.sf.mpxj.primavera.PrimaveraReader.processTasks(PrimaveraReader.java:656)
	at net.sf.mpxj.primavera.PrimaveraXERFileReader.processTasks(PrimaveraXERFileReader.java:497)
	at net.sf.mpxj.primavera.PrimaveraXERFileReader.read(PrimaveraXERFileReader.java:130)
	at net.sf.mpxj.reader.UniversalProjectReader.readProjectFile(UniversalProjectReader.java:340)
	at net.sf.mpxj.reader.UniversalProjectReader.read(UniversalProjectReader.java:234)
	at net.sf.mpxj.reader.UniversalProjectReader.read(UniversalProjectReader.java:139)
	at net.sf.mpxj.reader.UniversalProjectReader.read(UniversalProjectReader.java:120)
	at net.sf.mpxj.sample.MpxjConvert.readFile(MpxjConvert.java:106)
	at net.sf.mpxj.sample.MpxjConvert.process(MpxjConvert.java:84)
	at net.sf.mpxj.sample.MpxjConvert.main(MpxjConvert.java:57)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
	... 13 more

The file only contains one task.

ProjectFile.getDefaultCalendar().getWorkWeeks() not work?

I am using MPXJ 7.8.1 to read MS Project file(.mpp). I created a new calendar via copy "24 Hours" as following:
Screen Shot 2019-05-15 at 12 04 57 PM

When I use ProjectFile.getDefaultCalendar().getWorkWeeks() to get the workweeks, it returns nothing.

    ...
    UniversalProjectReader reader = new UniversalProjectReader()
    ProjectFile projectFile = reader.read(stream)
    ProjectProperties projectProperties = projectFile.getProjectProperties()
    def calendar = projectFile.getDefaultCalendar()
    calendar.getName() + ': ' + calendar.getWorkWeeks()
    
    Output: My Calendar: []

Dates of tasks are incorrect

Hello,
We've discovered a really strange bug where the dates are being imported incorrectly from a Microsoft Project file. Initially, we thought it might a problem with the frontend library, but I can confirm that the dates are being read incorrectly on import.

I've attached some screenshots of the dates in Microsoft Project, and the dates reported in our software after import. I'll be happy to send the file to an email if you need it.

Cheers!

dates_in_project_file
dates_reported

task.setFieldByAlias not working

I am able to manage standard fields without problem.
I'm trying to manage custom fields in MPP file.

MPPReader reader = new MPPReader();
reader.setPreserveNoteFormatting(true);
ProjectFile projectFile = reader.read("C:/test.mpp");

TaskContainer tc = projectFile.getTasks();
System.out.println("Number of tasks: " + tc.size());

Iterator<Task> it = tc.iterator();
for (int i = 0; it.hasNext(); i++) {
	Task task = it.next();

	System.out.println("GTMDATE: " + task.getFinish().toGMTString());
	task.setFinish( new Date() );
	System.out.println("GTMDATE: " + task.getFinish().toGMTString());

	String alias = "Custom Fieldname";
	task.setFieldByAlias(alias, "ABCD" );
	System.out.printf("%s : %s\n", alias, task.getFieldByAlias(alias));

	task.setFieldByAlias(alias, 1234 );
	System.out.printf("%s : %s\n", alias, task.getFieldByAlias(alias));
}

The output is always

Number of tasks: 1894
...
GTMDATE: 8 Jun 2018 10:00:00 GMT
GTMDATE: 19 Nov 2018 13:12:28 GMT
Custom Fieldname : null
Custom Fieldname : null

Is this supposed to work?

MS Word document resulted from RTFEmbeddedObject.getData() byte array cannot be opened

Hello, I'm trying to extract an MS Word file embedded in an RTF file by using RTFEmbeddedObject.getEmbeddedObjects(String file). The method returns a list with four instances, which is expected. When I check the resulting data array with Apache Tika, it returns the application/x-tika-msoffice mime type, which seems correct.

However, when I try to open the resulting file, it doesn't show the expected result on MS Word. I will attach both files on this issue.

here's the code that I'm using:

`
List<List> rtfl = RTFEmbeddedObject.getEmbeddedObjects(readLineByLine(file));

    for(List<RTFEmbeddedObject> l : rtfl){

        FileUtils.writeByteArrayToFile(new File
                ("test.doc"),
                l.get(1).getData());

        Tika t = new Tika();

        String s = t.detect(l.get(1).getData());

        System.out.println("Mimetype: " + s);

    }

`

Attachments at:
rtfword.zip

Thanks in advance!

ProjectCalendar getWork() method doesn't work properly with ranged calendar exceptions

The ProjectCalendar() getWork(Date, Date, TimeUnit) method in the C# version of MPXJ appears to be buggy when you have Calendar exceptions with Ranges

For example, if I have a task that's 80 hours that runs from 12/23 - 1/8, but I have calendar holiday exceptions of 12/23 - 12/25 for Christmas and 1/1 for new years day, and I do something simple like:

java.util.Date date1 = new java.util.Date(2019, 12, 23);
java.util.Date date2 = new java.util.Date(2020, 1, 8);
Debug.WriteLine(myProjectCalendar.GetWork(date1, date2, net.sf.mpxj.TimeUnit.DAYS));

It returns 11 days instead of 9 days.

What I believe is happening:

  • Between 12/23 and 1/8, there's 13 days

  • The code sees that there's two exceptions, one starting on 12/25, and one only on 1/1 and says 13 - 2 = 11

  • In reality, I would expect the code to say hey, this exception day starts on 12/25 and continues through 12/27 so that's 3 days, and there's another exception day on 1/1 which is a total of 4 days, 13 total business days - 4 exception days = 9 days of work

Example .mpp file attached where I'm seeing this bug today:
Sample Schedule.zip

Would be great if this could be patched!

My UniqueId is a Long Number, but Task.uniqueId is Integer. Overflow of Int

My uniqueId is create by the gantt plugin. So, when i am trying to create a projectFile Task passing the uniqueId, the value of my uniqueId is changed, cause of int overflow.

long myUniqueId = myTask.getUniqueId(); // 1544482355525 -> long
ProjectFile project = new ProjectFile();
Task task = project.addTask();

task.setUniqueId((int) myUniqueId);

Activity codes on tasks

Hi Jon Iles,

First of all, thank for your great lib. I've got a question, I can't find the activity codes linked to the task with the library. Are they available? Or are you planning on exposing them as well?

They contain really critical info for my project.

With kind regards!

XER Writing Support

Hi,

Is there any reason why writing to XERs is not supported? Is there a license issue or something? It would be really useful!

Happy to contribute to this if required.

Best,
Samir.

Is ProjectCalendar.getDate(startDate, duration, returnNextWorkStart) working correctly?

I was wondering if the function ProjectCalendar.getDate(Date startDate, Duration duration, boolean returnNextWorkStart) is working correctly. The description states:

It takes account of working hours in each day, non working and calendar exceptions.

I would have thought that the function would not allocate hours for days with DayType.NON_WORKING, it however does allocate hours on non working days in the tests I performed.

Outline code lookup tables do not show up

I'm trying to read the outline codes - while the outline codes are being read fine, the lookup tables are Not. I've tested this on several MPP files, and have ensured that there are lookup tables present for the outline codes.

My application is .Net, and I'm using MPXJ via IKVM.

Code is below. The outline code names show up, but the lookup table size is 0 everytime.
I've also attached a screenshot from a MPP file - for instance, the custom fields '00:Phase' through '04: Wrong Phase' all show up in the console, but the lookup table size is 0.

Much appreciated!
mpp_lookuptable

private void outlinecodereader(ProjectFile project)
{
    foreach (CustomField outlinecode in project.CustomFields)
    {
        Console.WriteLine("Outline Code Name = " + outlinecode.Alias + "; count = " + outlinecode.LookupTable.size);
    }
}

MSP June 4th 2019 .mpp file format breaking changes

Saving a project with the versions of MSP that contain the June 4th fixes compared to the same release lines of MSP that precede it appear to have enough changes to the task data and meta data records to be causing some significant data corruption.

Reference:
https://support.microsoft.com/en-us/help/4464589/june-4-2019-update-for-project-2016-kb4464589

Although this was an update from a few weeks ago, I believe some of the 'monthly' distribution and update channels from Microsoft are just beginning to push this out to desktops as of the last few days.

  • We are still to do testing to see the full scope of this, we know it affects Tasks strongly, it doesn't appear to affect Calendar data, but more detailed looks into record/data types like Resources, Dependencies, and Assignments are TBD.
  • Some of the corruption findings of reading the .mpp file and writing it back out as .xml included:
    • All or most tasks that were active (1) were coming out as inactive (0) in the xml file.
    • Many summary tasks were having their summary element set to 0 in the xml file.
    • Some tasks appeared to get duplicated (same 'ID' or 'MSP row number' but different 'UID' values). This also has a knock-on effect in skewing the OutlineLevel numbers to accommodate the dupes.
    • We found some custom fields (e.g. "Text3") could be misaligned to completely different tasks (usually the weird dupes); very bad news for us as these are used to hold unique references to external systems for updates, but it wasn't always the case so a bit hit and miss.
    • The misaligned reading of the task records seemed to cause a large number of the 'Enterprise Flag' fields to be spontaneously added to the xml file that don't exist at all in the same .mpp. These fields only ever exported with the flag field set to 1 and not 0, and which fields they were would vary from task to task, it wasn't all that consistent (could be between 0 to 7 flag fields per task).

These new-version MSP (June+) .mpp files can still be opened perfectly fine by the prior versions (e.g. March release of MSP) and without these issues present, but I guess that's part of the nature of how it reads the OLEDoc format that's different to the expectations that the MPP reader class has.

I plan to get and upload copies of the side-by-side .mpp files from March (good) and June (bad) releases of MSP if that helps, along with their converted-to-xml counterparts.

Cannot read custom fields sometimes

Sometimes custom fields (mostly populated with lookup tables) are missing when we are reading them from mpp files. (Maybe this was a related issue, but we still have something like this: #38 )

Finally we have some mpps (mpps.zip) to share which contain the following issue:
The 11. task (unique id: 14) in the original mpp (QualityReportTestGIVE) has a value in TaskField Text8.
I deleted the value and saved it as QualityReportTestGIVE_2.
Reading the first version there is no problem (all values are fine). However, reading the second one, Text8 is missing from other tasks as well (unique id: 16 and 15), not just from the one that I modified.
Other interesting fact: when I open the second version in MSP 2013 and save it again (as QualityReportTestGIVE_3) without any modification, then reading the third version, Text8 is OK in other tasks and missing only from the earlier modified task which would be the expected behavior with the second version as well.

Currently used MPXJ version in Java: 7.6.3 (but we had the same experience with earlier versions)

Could it be fixed somehow?
Please let me know if you need further information.

Activity ID in primavera is not getting exported

The Activity ID is not being set to the Task object of mpxj when reading from primavera using the PrimaveraXERFileReader class.
The default ACTIVITY IDs in primavera are set as A0001, A0002 etc. When you export a project as P6 XML, you will see that this id of the Activity is set in the id tag.
But when you are reading the Primavera XER file using the mpxj PrimaveraXERFileReader, the Task object's id is set as a sequence (1,2,3 etc). What is the way to get the Activity ID of the project seen in P6? Am using the Task class's getID() API to get this id.

Primavera Exception Dates: Off by 1 day?

I noticed recently a change was made to account for P6 exception dates being days from 12/30/1899 instead of 1900.

I thought this should fix the issue I'm seeing, but it didn't.

I'm using the 7.0.2 NUGET .NET package, and I have to add 1 day to the exceptions after import to make them match what is found in the P6 client.

foreach (ProjectCalendarException exception in calendar.CalendarExceptions.ToIEnumerable())
                {
                    if (!exception.Working)
                    {
                        for (var dt = exception.FromDate.ToDateTime(); dt <= exception.ToDate.ToDateTime(); dt = dt.AddDays(1))
                            dates.Add(dt.Date.AddDays(1));
                    }
                }

I've tried using the ToDateTime function provided by MPXJ as well as another one I found that does a simple conversion using Year, Month, etc into new DateTime. Both produce the same results.

When I inspect the Calendar object, the Exception shows, for instance, as 2009/12/31 (-6:00), when it should be 2010/1/1.

missing tasks when parsing mpp14

After I deleted a task and its children in project 2010 or 2013, mpjx will get wrong result.
Distinguish deleted tasks with (flags & 0x02) != 0, seems not right for mpp14.

MSPDI reader and writer will omit OutlineCode and LookupTable information

Using Mpxj 7.6.2 (.net), if I read a .mpp file containing a simple lookup table, Mpxj can view it and extend it in memory with additional lookup values.

Reading an MSP 2016 generated .xml file with the same lookup table, results in saying that the ProjectFile has no lookup table or custom field information values, when opening the same .xml again into MSP 2016 still shows them correctly.

Writing either of these read ProjectFile instances to .xml with MSPDIWriter has the following observations:

  • OutlineCodes project level element does not exist at all.
  • ExtendedAttributes is incomplete and has a FieldID element reference that points nowhere.
  • Ltuid and related elements are missing

SaveVersion is 14

Simplified read/write program:

using System;
using System.IO;
using net.sf.mpxj;
using net.sf.mpxj.mspdi;
using net.sf.mpxj.reader;

namespace mspdi {

    class Program {
        static void Main(string[] args) {
            FileInfo file = null;
            if (args.Length == 1)
                file = new FileInfo(args[0]);

            if (file != null && file.Exists)
                ConvertUsingMpxj(file.FullName);
            else
                ShowUsage();
        }

        private static void ConvertUsingMpxj(string filename) {

            if (string.IsNullOrEmpty(filename)) {
                ShowUsage();
                return;
            }

            // If .mpp then lookup table exists, if .xml it does not (even though MSP 2016 shows it when opening the same .xml file)
            var reader = new UniversalProjectReader();
            var project = reader.read(filename);

            Console.WriteLine($"Has lookup table: {project.CustomFields.GetCustomField(TaskField.TEXT1)?.LookupTable}");

            // Neither .mpp or .xml as source when written out using MSPDIWriter is having the custom field and lookups in the generated .xml
            var writer = new MSPDIWriter {SaveVersion = SaveVersion.Project2016};
            writer.write(project, filename + "-converted.xml");

            Console.WriteLine("Finished");
        }

        private static void ShowUsage() => Console.WriteLine("Usage: mspdi [filename]");
    }

}

Console output showing detection of lookup table w/MPP reader

D:\Projects\mpxj\mspdi\bin\Debug>mspdi c:\temp\Project2.mpp
Has lookup table: [[CustomFieldValueItem uniqueID=1 guid=0191cf35-78c6-e811-afd5-001fbc126620 parentId=0 value=Yes, [CustomFieldValueItem uniqueID=2 guid=0291cf35-78c6-e811-afd5-001fbc126620 parentId=0 value=No]
Finished

Console output of identical project saved as .xml in MSP (and persists when re-opening in MSP):

D:\Projects\mpxj\mspdi\bin\Debug>mspdi c:\temp\Project2.xml
Has lookup table: []
Finished

Excerpt of resulting .xml file generated by MSPDIWriter:

    <ExtendedAttributes>
        <ExtendedAttribute>
            <FieldID>188743731</FieldID>
            <FieldName>Text1</FieldName>
        </ExtendedAttribute>
    </ExtendedAttributes>

Files used and generated:
project2-before-and-after.zip

Same TaskField is mapped to different FIELD_ARRAY-indices in MPPTaskField14.java

Hi Jon,

I'm unsure if this could be a problem or not, at least it looks like this could be a problem.
The following TaskField's are defined twice:

  • TaskField.SCHEDULED_START
  • TaskField.SCHEDULED_FINISH
  • TaskField.SCHEDULED_DURATION

the first time:

FIELD_ARRAY[29] = TaskField.SCHEDULED_DURATION;
FIELD_ARRAY[36] = TaskField.SCHEDULED_FINISH;
FIELD_ARRAY[35] = TaskField.SCHEDULED_START;

the second time:

FIELD_ARRAY[1338] = TaskField.SCHEDULED_START;
FIELD_ARRAY[1339] = TaskField.SCHEDULED_FINISH;
FIELD_ARRAY[1340] = TaskField.SCHEDULED_DURATION;

Primavera WBS not read or exported correctly when there is no activity under it

I am trying to use MPXJ (Version 7.7.1) to read Primavera project from XER and XML. I found that if a WBS has no activity under it, it is going to be treated as a task. The summary flag will be set to false. Also if I try to dump the file using PrimaveraPMFileWriter, the WBS is going to be dumped as Activity.

I've created a sample schedule to demonstrate this issue. The schedule is created with P6 Professional 18.8 as follows:
screen shot 2018-12-11 at 1 24 57 pm
This is the schedule dumped as XML:
TEST1.xml.zip
And this is the same schedule being read and dumped from MPXJ using PrimaveraPMFileWriter:
TEST1.export.xml.zip

I think the cause of this issue is MPXJ only marks tasks with child tasks under it as summary task.

task.setSummary(task.getChildTasks().size() != 0);

Similar issue is also found with XER file, as it is sharing PrimaveraReader with XML file.

Could you please look into this issue or provide a work around so that I can distinguish an empty WBS from a task? Thanks.

Exception working with AstaFileReader class

Hey,

I need help with this issue, when I am trying to read one file with .PP extension in C# doing this:

AstaFileReader reader = new AstaFileReader();
ProjectFile projectFile = reader.read(inputFile);

This error appear

"Can not convert the type 'java.util.PropertyResourceBundle' to 'sun.util.resources.OpenListResourceBundle'."

Maybe I am doing something wrong, could I get help please?

Add multiple front-end tasks to a task, but when project is opened, the front-end task is not displayed

Add multiple front-end tasks to a task, but when project is opened, the front-end task is not displayed, and it is successful if only one front-end task is added.

if (CollectionUtils.isNotEmpty(list)) {
          for (PredecessorVO predecessorVO : list) {
                 net.sf.mpxj.Task target = getMpxTaskByUniqueId(mpxTasks, predecessorVO.getTargetTask());

                 Duration lag = Duration.getInstance(predecessorVO.getLag().getDuration(),
                                predecessorVO.getLag().getUnits());
                 mpxTask.addPredecessor(target, predecessorVO.getType(), lag);
          }
}

Processing UDFs from XER: Performance

Hey Jon,

I finally got around to forking and building this awesome project (jar and .NET).

The reason I did it was to debug some performance issues I am having. Basically I have a huge client XER (350mb) that is taking ~2 hrs to process.

I discovered that the UDF processing is taking about 95% of that time, due to there being ~3 mil UDF rows. Commenting out the loop in PrimaveraReader.getContainerUDF() takes that 2 hrs down to 4.5 min. That method is called in two places and it's exponential based on the number of UDF rows.

I can keep my fork and leave it commented, since I don't need UDFs at this time, but thought you might like to know. I'm not too familiar with Java, but some type of Dictionary with O(1) lookup (Map<int, List> maybe?) might be a good candidate for storing the UDF rows by ID?

Thanks!

Wrong timephased data when importing from mpp

It's copied from: https://sourceforge.net/p/mpxj/bugs/322/
(This is a major Bug for us.)

ResourceAssignment::getTimephasedActualWork() returns incorrect values when read from mpp (Project 2013). From xml it is fine. Tested with mpxj version 7.1.0. (getTimephasedWork() seems also wrong)

For example see attached mpp, task: "FixUnit50".

Use case: In the mpp we had tasks with different completion and types. Then I added an exception to the standard calendar. TypesWithException.zip

More example with attached mpp. In task "ExceptionMerges" assignment with "Merge4" getTimephasedWork() has returning incorrect values. Tested with mpxj 7.0.2 & 7.2.1.
ScheduleAdv.zip

MSPDIWriter.writeProjectProperties() isn't writing comments field

I am setting the project header comments using ProjectProperties.setComments() method. But, when I write the ProjectFile into xml using MSPDIWriter.write() method, it's not writing the comments field as it's not being taken care of in MSPDIWriter.writeProjectProperties(). Can we fix that?

Missing Extended Attributes (MPP to XML)

The XML generated from MPP (using last version of MS Project) cames with empty section directly inside the Project tag.

If we look the XML generated by MS Project for the same gantt, it has 80 lines between and tags, corresponding to the extended attribute which we configured in MS Project, plus 10 blocks with the following form (Duration1 to Duration10):

<ExtendedAttribute>
    <FieldID>188743783</FieldID>
    <FieldName>Duration1</FieldName>
    <Guid>000039B7-8BBE-4CEB-82C4-FA8C0B400067</Guid>
    <SecondaryPID>255868968</SecondaryPID>
    <SecondaryGuid>000039B7-8BBE-4CEB-82C4-FA8C0F404028</SecondaryGuid>
</ExtendedAttribute>

which we didn't configure.

Also, the XML from MPXJ has no tag inside , while it do comes in the XML generated with MS Project.

There's no problem when we try with any MPP generated with older versions of MS Project.

This same issue was created on SF.net (https://sourceforge.net/p/mpxj/bugs/337/), but seems to be more activity on GitHub

We're using the 7.9.3 version.

Issue with subprojects for .mpp files (using MS Project 2010)

Hey there,

Just found what I believe to be a new issue - we use MS Project 2010 files where I work, and I'd like to use your library, but I seem to have an issue with subprojects

To better explain -- from time to time, we will have one "macro" schedule that has many sub "micro" project schedules embedded into it

But in .NET / C#, when I use Task.SubProject.FullPath, sometimes it misses subprojects that are definitely linked (I have 1 macro schedule with 11 micro schedules attached as subprojects), and other times it's grabbing subprojects that aren't actually subprojects at all but successor or predecessor references to other .mpp files (just because their a successor or predecessor doesn't mandate them being a subproject)

Ultimately the field I'm trying to get at is "Subproject File" which is a native field in MS Project 2010, not even a custom field, and it doesn't appear that I can get this information today (screenshot of native field attached today)
subprojectFile

After further reviewing this issue - while the predecessor/successor issue still appears to be an issue, the other reason I wasn't seeing some actual subprojects was because they were added as "read only" inserted projects per the "Indicators" column, screenshot below --

secondPicture

I'm able to see everything without the red ! point, but all the red ! is indicating is that they were added as read only, so I would think I should still be able to get the "Subproject File" name

Variations as to how MSP saves custom field lookup values

MPXJ versions:

7.6.x - 7.9.2 inclusive

MSP versions:

Seems to be at least any 2016-2019 standard or pro

  • (specifically I'm using Project for Office 365, 16.0.11328.20362 - 32-bit right now but we have customers and testers on other versions and haven't found one that isn't affected yet).

Problem summary:

When importing an .xml into MSP and saving it as .mpp, if there were lookup values on columns (e.g. Text1) for rows that had not been visibly shown on a view prior to saving it and reading it with MPXJ, it seems it stores the lookup data in a different place within the .mpp file and causes MPXJ to read garbage characters from something else instead.

Test code for demonstration:

package com.regoconsulting.mpxj;

import net.sf.mpxj.MPXJException;
import net.sf.mpxj.ProjectFile;
import net.sf.mpxj.Task;
import net.sf.mpxj.reader.UniversalProjectReader;

import java.io.IOException;

public class Main {

    public static void main(String[] args) throws MPXJException, IOException {
        if (args.length > 0)
            ReadTaskLookupValues(args[0].startsWith("com.rego") ? args[1] : args[0]);
    }

    private static void ReadTaskLookupValues(String filename) throws MPXJException, IOException {
        UniversalProjectReader reader = new UniversalProjectReader();
        ProjectFile project = reader.read(filename);

        for (Task task : project.getTasks()) {
            System.out.println(task.getName() + ": " + task.getText(1));
        }
    }
    
}

Setup and steps to reproduce:

  1. Create new project in MSP, add 1 task
  2. Go to Custom Fields, select Lookup for Text1 (task) and enter a few dummy values like so:
    image
  3. Add the Text1 column to your gantt view, pick a value for your Text1 column of your task, then hide the column from the view again so it is not showing.
  4. Save the file as an .xml file in MSP.
  5. Import the .xml as a new project in MSP, do not show the Text1 column or contents at any time.
  6. Save the project as an .mpp (e.g. TaskLookupValuesFault.mpp)
  7. Save the project again as an .xml (e.g. TaskLookupValuesFixed.xml)
  8. Save the project again as an .mpp (e.g. TaskLookupValuesFixed.mpp)
  9. Repeat steps 7 and 8 again; for some reason you may have to save it a couple of times when using this version of the workaround.
  10. Try to open both .mpp files (fixed and fault) with MPXJ and output the value of the Text1 field for the tasks

Example outputs:

D:\mpxj-test>java -classpath out\production\mpxj;lib/* com.regoconsulting.mpxj.Main c:\temp\TaskLookupValuesFault.mpp
Project1: null
Task1: ???????????

D:\mpxj-test>java -classpath out\production\mpxj;lib/* com.regoconsulting.mpxj.Main c:\temp\TaskLookupValuesFixed.mpp
Project1: null
Task1: Just

Due to the non-ascii / non-printable chars it just shows ???? but in a non-ascii (e.g. Unicode) aware display it shows this instead, in case it "helps" with identification of where the funky data was being pulled from:
image

Expected results:

Both projects to have had the same output (e.g. "Just" for Task1).

Workarounds:

Aside from saving-as xml/mpp a couple of times, which seems to force MSP to "read" the lookups data in a way that influences how it then stores the view/lookup/task data back into the MPP later on, it's also possible to workaround by ensuring that Text1 is added to the view inside MSP and showing for every row that has a value before saving it.

I guess in both ways, we're forcing MSP to have to acknowledge and read the data in a way that alters how it then saves it again, otherwise the place or ordering in the file for where it stores that data will be elsewhere and MPXJ picks up something else.

Sample project files:

Here's the examples I used for the code and results above; I created this project and task manually in the MSP UI - there's nothing special about their generation. I include the original .xml used to import as a new project, and then the subsequent saves of that file to get the bad and good .mpp's to demonstrate with.

TaskLookupValuesDemo.zip

Elapsed Days to Days Duration Conversion Incorrect

The conversion from elapsed days to days is incorrect, first the minutes are calculated based on a 24 hour clock and then the conversion back is done based on minutes per day which is hardcoded to assume that there are 8 hour days.

Example:
If you have 1ed it is first converted to 1440 minutes and then when it's converted back with the 8 hour day it's converted to 3d.

license id in maven/pom.xml is incorrect

The project LICENSE file is LGPL-2.1 and the license headers on the *.java source files are LGPL-2.1. However, the maven/pom.xml incorrectly identifies those licenses as LGPL-3.0

project date/time format is not imported

Not sure if I'm doing correct, but looks currently mpxj doesn't support to import the project date/time format via MPPReader.read API? Looks projectProperties.getDateFormat() always returns 20, while projectProperties.getTimeFormat() always returns 0.

Any plan when we're gonna support to import the project date/time format?

Asta PP not importing all task predecessors

The LINK table can contain references to TASK, MILESTONE and TASK_COMPLETED_SECTION tables in the START_TASK and END_TASK fields. The TASK_COMPLETED_SECTION references are currently ignored, resulting in missing predecessor relationships for completed tasks.

MPP8Reader read task notes issue

Your work is very great!
I found a small issue in the source code: line 462 in the file "mpxj/src/main/java/net/sf/mpxj/mpp/MPP8Reader.java", the code is "taskExtData = new ExtendedData(taskVarData, getOffset(data, 312));"; here the parameter "312" seems incorrect, after testing it, i think this parameter should be 362, do you agree?

WBS not read correctly during import of Microsoft Office Project 2003 file

During the import of a Microsoft Office Project 2003 file, the WBS of tasks are read correctly until the yellow part, after that they all WBS are null, I am using mpxj-for-csharp 5.1.9 to import the mpp file:

image

I can't share the project file I have, due to confidentiality, I can of course try to replicate it in a different project file. I hope the image above gives you enough information. If not, let me know how I can help you further pinpoint the issue.

PrimaveraP6 Attribute

Hi im syafik
How to find this PrimaveraP6 Attribute from .xer file
1.Performance % complete
2.Schedule Performance Index
3.Cost performance index
4.Planned value cost
5.Earned value cost
thank you

Issue reading custom fields populated using a lookup

Hi,

I use the java version and this is reproducible using 7.2.0 and 7.2.1

I have a use case where I need my users to populate a field using a lookup (Reporting Flag), when I try to parse and read the content of the file, I am not able to read the values for the custom column (I get null).

I am able to read 'simple' custom columns where the value is a string (Overall Rag)

Below is a small code snippet to reproduce the issue, please find a screen shot of the file in the attachment. Reporting Flag has a lookup of values (Flag1, Flag2, Flag3 ...).

I am not able to attach the mpp to github, but let me know if you want me to send it by email.

project

import net.sf.mpxj.CustomField;
import net.sf.mpxj.ProjectFile;
import net.sf.mpxj.Task;
import net.sf.mpxj.mpp.MPPReader;
import net.sf.mpxj.reader.ProjectReader;

import java.nio.file.Path;
import java.nio.file.Paths;

public class CustomFieldsMain {

	public static void main(String[] args) throws Exception {
		Path path = Paths.get("path to the file", "Project-1.mpp");

		ProjectReader reader = new MPPReader();
		final ProjectFile projectFile = reader.read(path.toFile());

		// print custom fields values for task# 1
		final Task task = projectFile.getTasks().getByUniqueID(1);
		System.out.println(task.getName());

		for (CustomField customField : projectFile.getCustomFields()) {
			System.out.printf("%s : %s\n", customField.getAlias(), task.getFieldByAlias(customField.getAlias()));
		}
	}

}

MPXJ C# - Resource assignment count

Hi,
I have a XER file that I imported to my trial version of Primavera P6. Here is an screen shot of one of the activity's assigned resources:
image
As you see I have 14 resources in Primavera but when I watch it in Visual Studio I have 13 resources:
image
Well I guess it has problem with duplicate assignment of same resource(I marked in the first screen shot).

Am I right? Is there any way to get all 14 resources on C# side?

Expose Relation ID and Proj ID

I love your library!

I am wondering if you might be open to exposing some of the IDs when reading XER files.
The two I'm currently interested in are the Relation ID (integer) and the Project ID (integer).

I believe that would be adding "task_pred_id" to processPredecessors() and exposing "proj_id" in project properties.

It would be useful for tying back to the data source for BI.

Thank you for the work you put into this great library. I would be happy to fork and contribute if I knew how the java -> C# build was done.

Issue after publishing

I am able to read values from MPP, but and publish it in my local machine, but while publishing in a different laptop got error "System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified."

Did I miss something to add while packaging.

any help will be highly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.