Free Support Forum - aspose.com

Setting Actual Duration is not change actual finish date of the task

Hi,

I opened a mpp file using aspose.tasks dll
Then I set the Actual Start Date, Actual Duration and Remaining Duration of a Task in opened project.
I expect that the Actual Finish date to change according to the entered data.
but it did not. After running the Recalculate() method of the project, The task duration returns to the original value before the change.
Can anyone help me on this, please?

@sa.hajizadeh

Can you please share the working sample code along with source file and generated output so that I may investigate the issue further on my end to help you out.

Thanks for your response,
here is the code sample:

    public static void TestMethod()
    {
        new License().SetLicense("My_License.lic");
        Stream stream = new FileStream("MPP_File_Path", FileMode.Open);
        Project Project = new Project(stream);
        stream.Dispose();
        Project.CalculationMode = CalculationMode.Automatic;

        ChildTasksCollector collector = new ChildTasksCollector();
        TaskUtils.Apply(Project.RootTask, collector, 0);
        Task task = collector.Tasks.Find(x => x.Get(Tsk.WBS) == "A.1.1");

        string startDate = (new DateTime(1970, 1, 1)).AddMilliseconds(1610569800000).ToLocalTime().Date.AddMilliseconds(3600000 * 8).ToString();
        task.Set(Tsk.ActualStart, DateTime.Parse(startDate));
        task.Set(Tsk.ActualDuration, Project.GetDuration(5, TimeUnitType.Day));
        task.Set(Tsk.RemainingDuration, Project.GetDuration(2, TimeUnitType.Day));
        Project.Recalculate();
        Console.WriteLine(task.Get(Tsk.Duration));
        Console.WriteLine(task.Get(Tsk.ActualDuration));
        Console.WriteLine(task.Get(Tsk.RemainingDuration));
        Console.WriteLine(task.Get(Tsk.ActualFinish));
        Console.WriteLine(task.Get(Tsk.PercentComplete));
    }

And, this is the mpp file
TestProject.zip (26.6 KB)

@sa.hajizadeh

This seems to be a probable issue in API and I have created an issue with ID TASKSNET-4632 in our issue tracking system to further investigate this on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.