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.

@sa.hajizadeh

Can you please try using following modified sample code using latest Aspose.Tasks for .NET 21.1 on your end and share the feedback does it resolve the things on your end.

new License().SetLicense("My_License.lic");
var project = new Project("TestProject.mpp");
var collector = new ChildTasksCollector();
TaskUtils.Apply(project.RootTask, collector, 0);
var 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();
var startDate = new DateTime(2021, 1, 14, 8, 0, 0);
task.Set(Tsk.Duration, project.GetDuration(7, TimeUnitType.Day));
task.Set(Tsk.Start, startDate);
task.Set(Tsk.ActualStart, startDate);
task.Set(Tsk.ActualDuration, project.GetDuration(5, 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));

The issues you have found earlier (filed as TASKSNET-4632) have been fixed in this update.