We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Updating a task as completed modifies every other task's start and end dates

Hi,

I am using the following code snippet for marking a task as completed.

ChildTasksCollector collector = new ChildTasksCollector(); // Create a ChildTasksCollector instance
TaskUtils.Apply(proj.RootTask, collector, 1); // Collect all the tasks from RootTask using TaskUtils

Aspose.Tasks.Task task = collector.Tasks.FirstOrDefault(t => t.Id.Equals(taskId));
if (task != null) // Detail XML
{
task.Finish = newDate;
task.PercentComplete = 100;

}


Here whenever the “Finish” is updated project automatically updates all the task’s start and end dates irrespective of the dependency.

we also tried updating the task by updating “ActualFinish” and "ActualStart " properties as shown below:

task.ActualStart = task.Start;
task.ActualDuration =
(newDate - task.Start);
task.ActualFinish =newDate ;
task.ActualWork = task.Work;
task.ActualCost =
task.Cost;
task.PercentComplete = 100;

but there is no change in the output.

What we actually need is, whenever a particular task is completed the start date and end date needs to be updated based on the dependency.

Please do help us on this issue and kindly get back to me in case you need any more clarifications.

Thanking you,
Srinivas NV


Hi Srinivas,


Thank you for writing to Aspose support team.

Aspose.Tasks library is revamped and new version is released Aspose.Tasks for .NET 8.0.0. I have tried the scenario by using new library and am afraid to share that I could not observe the issue. Could you please give it a try and let us know the feedback? If issue is not resolved, please send us the sample project file for testing it here.

static void TestUpdatePercentage()
{
Project proj = new Project(@“597545.xml”);
ChildTasksCollector collector = new ChildTasksCollector(); // Create a ChildTasksCollector instance
TaskUtils.Apply(proj.RootTask, collector, 1); // Collect all the tasks from RootTask using TaskUtils
//Aspose.Tasks.Task task = collector.Tasks.FirstOrDefault(t => t.Id.Equals(taskId));
Aspose.Tasks.Task task = collector.Tasks.FirstOrDefault(t => t.Get(Tsk.Id).Equals(1));
if (task != null) // Detail XML
{
DateTime dt = new DateTime(2015, 1, 8, 5, 0, 0);
task.Set(Tsk.Finish, dt);
task.Set(Tsk.ActualStart, task.Get(Tsk.Start));
task.Set(Tsk.ActualFinish, task.Get(Tsk.Finish));
}
proj.Save(@“597545Output.xml”, Aspose.Tasks.Saving.SaveFileFormat.XML);
}

Hi Kashif Iqbal,

When I tried with the new “Aspose.Tasks for .NET 8.0.0” dll, I am not getting the .Set() [task.Set(Tsk.Finish, dt)] method in the Task.


I downloaded the dll from this link.

Also i have attached the XML generated before and after updating task (we updated the task named “New Task 1”)

We are using .Net Framework 4.5, but I didnot get Aspose.tasks.dll for this framework in the above link.

Hi Srinivas,


I have downloaded the library again from the link you have mentioned and found it working fine. A project is created using the latest DLL and is executed with your sample XML file “BeforeUpdate.XML” to test the scenario. I am afraid that no issue is observed and only the specified task “New Task 1” is updated by the code. The Set functions are also available without any issue.

Here the complete project is attached where the said DLL (4.0) is used whereas Project target framework is 4.5. You may please give it a try and let us know the feedback.

P.S. MSP 2010 raises exception while opening the “AfterUpdate.xml” sent by you however output file created by the attached project opens fine.