Modifying TimePhased Data and saving into MPP file

MPPFiles.zip (266.9 KB)

HI Sir,

My requirement is to modify the timephased data value for any resource assignment. and finally save the entire project in different MPP file.
Please find the below code:

string licenseFileName = Path.Combine(dataDir, “Aspose.Total.Product.Family.lic”);
License license = new License();
license.SetLicense(licenseFileName);

Project project = new Project(“GM_VCU_1_5_rough_top_down_1201060_Read.mpp”) { CalculationMode = CalculationMode.None };

Task tsk1 = project.SelectAllChildTasks().FirstOrDefault(t => t.Get(Tsk.Name) == “Hours - Project management”);
foreach (ResourceAssignment assignment in tsk1.Assignments)
{
// Read timephased data
List td = assignment.GetTimephasedData(assignment.Get(Asn.Start), assignment.Get(Asn.Finish), TimephasedDataType.AssignmentRemainingWork).ToList();

foreach (TimephasedData timePhasedValue in td)
{
timePhasedValue.Value = “PT8H0M0S”;
}
}

project.Recalculate();
project.Save(“AfterLinking_out.mpp”, Aspose.Tasks.Saving.SaveFileFormat.MPP);

after debugging i found that in project variable value is updating but not reflecting into output MPP file.

@chetanbhola

We need to further investigate the issue on our end. A ticket with ID TASKSNET-10342 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hello @chetanbhola.

In order to modify values of TimephasedData you should modify items in ResourceAssignment.TimephasedData collection directly in the following way:

            Project project = new Project("GM_VCU_1_5_rough_top_down_1201060_Read.mpp") { CalculationMode = CalculationMode.None };

            Task tsk1 = project.SelectAllChildTasks().FirstOrDefault(t => t.Get(Tsk.Name) == "Hours - Project management");
            foreach (ResourceAssignment assignment in tsk1.Assignments)
            {
                foreach (TimephasedData timePhasedValue in assignment.TimephasedData)
                {
                    if (timePhasedValue.Value == "PT0H0MS")
                    {
                        continue;
                    }

                    timePhasedValue.Value = "PT8H0M0S";
                }
            }

            project.Recalculate();
            project.Save("AfterLinking_out.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);

Also please ensure that you use Aspose.Tasks for .NET v. 21.10 because we released fixes for some issues related to TimephasedData handling.

Hi,
i tried but still timephased values are not reflecting into output MPP file.

below steps i followed:

installed Aspose.Tasks for .NET v. 21.10.
update the code suggested by you into the application.

Please find the input and output file here.MPPFiles.zip (248.6 KB)

Hello @chetanbhola.
We examined the attached file and found out that “AfterLinking_out.mpp” is saved by Aspose.Tasks for .NET v 21.6.
Could you check that you use version 21.10 ?