No baseline in existing mpp file

Hi,
We are trying to upgrade our aspose.tasks from version 19.3 to 22.3. Using version 19.3, we are able to successfully export the .mpp file multiple times. However, using version 22.3 22.3, we are only able to export the .mpp once. Our logic checks to see if the .mpp file exists when exporting and if so, it will use that file instead of generating new. In version 22.3, the aspose.tasks.taskbaselinecollection count is always zero when retrieving from the existing .mpp file. In version 19.3, the count is always 1. The exact same code works successfully version 19.3 but doesn’t work in 22.3 I am new to this exporting process using aspose so hopefully my explanation makes sense. Can you verify if this is a bug in your software or has something changed in regards to retrieving the baselinecollection?

Just to add some extra information to this post: When we are in update mode, we are using the following statement to retrieve the task.

_myTask = _myMSProject.RootTask.Children.GetByUid(_uid);

The baseline collection count is always 0 in version 22.3 but it evaulates to 1 in 19.3. The program later fails because we are trying to get a list of the baselines using _mytask.Baselines.tolist() but there are none available in 22.3.

Thanks

@liesa.collier,

could you attach a sample .mpp file so we can reproduce the issue on our side?

823_971___CHKMAJOR.zip (44.8 KB)

I have attached sample.

@liesa.collier,
Thank you for the sample file.
The baselines which you can observe in 19.3 are “redundant” (don’t contain any non-zero values) and were instantiated due to a bug. Now it’s fixed.

@liesa.collier,

regarding the following issue you’ve mentioned:

Using version 19.3, we are able to successfully export the .mpp file multiple times. However, using version 22.3 22.3, we are only able to export the .mpp once.

Could you attach a code example?

Hi,
So, if I am understanding you correctly. We were using a ‘bug’ feature which has since been corrected?
Our problem is when we use an existing .mpp file in version 22.3, the baseline collection is never populated for the tasks. When we try to update, we try to generate a list of baseline collections but there is none? We were using the statement
TaskBaseline baseline = _myTask.Baselines.ToList()

That is the only problem we are having and why we can’t execute the code the second time. This worked perfectly fine in 19.3. How do we get access to the baseline for an existing .mpp file?

Thanks

It makes sense, because in attached file tasks doesn’t have non-empty baseline properties:
Screenshot_1.png

So task.Baselines collection is not filled with “empty” baselines objects to reduce memory consumption in this case.

If Baseline property was set for any task in mpp file, the resulting collection for the task is populated with TaskBaseline object.

To list all baselines saved in .mpp file you can use the following snippet:

    var project = new Project("823_971___CHKMAJOR.mpp");

    Console.WriteLine("Baselines present:");
    foreach (var baselineType in Enum.GetValues(typeof(BaselineType)))
    {
        var saveTime = project.GetBaselineSaveTime((BaselineType)baselineType);

        if (saveTime != DateTime.MinValue)
        {
            Console.WriteLine("{0}, last saved on {1}", baselineType, saveTime);
        }
    }

If you want to update task’s baseline properties, you could instantiate and add TaskBaseline object to task’s Baselines collection:

if (task.Baselines.Count == 0)
{
    var baseline = new TaskBaseline(task);
    baseline.BaselineNumber = BaselineType.Baseline;
    baseline.Start = DateTime.Now.AddDays(-2);
    baseline.Finish = DateTime.Now.AddDays(-1);
    task.Baselines.Add(baseline);
}