Free Support Forum - aspose.com

Deleting a Tasks breaks Project Recalculation

Hello,
While testing I noticed a potential bug. I was able to successfully import an existing Project file using Aspose with no issues. However, I noticed that if you delete a task from the Project file, and save, all of the previous data gets removed (Actual Start, Actual Finish, and Duration) and the Project Recalculation no longer works.
How can I fix this issue? Is there a way to delete a task from the Project file and not have my previous data removed? I have attached screenshots of the Project files, and below is the logic used to retrieve and edit an existing Project file.

Thank you

static void Main(string[] args)
{

        License lic = new License();
        lic.SetLicense("Aspose.Tasks.lic");
     

        // The path to the documents directory.
        string dataDir = "C:/Users//Desktop/";

        // Read project xml into file stream
        using (Stream filesStream = new FileStream(dataDir + "ProjectBeforeSave.mpp", FileMode.Open))
        {
            // Create project using file stream
            Project project = new Project(filesStream);

            ChildTasksCollector childTasks = new ChildTasksCollector();
            TaskUtils.Apply(project.RootTask, childTasks, 0);
            Console.WriteLine("Number of tasks: " + childTasks.Tasks.Count);

            foreach(var task in childTasks.Tasks)
            {
                Console.WriteLine( "Task Name " + task.Get(Tsk.Name) + " Start " + task.Get(Tsk.Start) + " Finish " + task.Get(Tsk.Finish)  + " Actual Start " + task.Get(Tsk.ActualStart) + " Actual Finish " + task.Get(Tsk.ActualFinish));
                Console.WriteLine(" ");
                // Console.WriteLine("Finish " + task.Get(Tsk.Finish));
            }

            //Delete Task from Project file
            var taskToDelete = childTasks.Tasks.Find(x => x.Get(Tsk.Uid) == 8);
            Console.WriteLine("Task to Delete" + taskToDelete.Get(Tsk.Name));

            taskToDelete.Delete();

            //Modify an exiting tasks.
            var taskToModify = childTasks.Tasks.Find(x => x.Get(Tsk.Uid) == 7);
            taskToModify.Set(Tsk.ActualFinish, DateTime.Now);
            project.Recalculate();

            //Save the Project file
             project.Save(dataDir + " ProjectAfterSave.mpp", SaveFileFormat.MPP);

             //The existing Actual Start and Finish dates were removed. 
          

        }

AfterSaveProjectScreenshot.PNG (10.8 KB)
BeforeSaveProjectFileScreenshot.PNG (11.5 KB)
ProjectBeforeSave.zip (56.0 KB)

@tarvonn,

I have worked with sample code shared and have observed the issue specified. A ticket with ID TASKSNET-4207 has been created to further investigate and resolve the issue. We will share the feedback with you as soon as the issue will be fixed.

Hello,

Do you know when TASKSNET-4207 will be completed?

Thanks

@tarvonn,

The concerned issue has been marked as resolved in upcoming Aspose.Tasks for .NET 20.8. We request for your patience and will share the good news with you as soon as the issue will be fixed.

Thanks for the update.

@tarvonn,

You are welcome. We will apprise you with product release as soon as it will be shared online.