Need explanation for varying behavior when updating Task Dates

I’m working on a solution to synchronize dates between the MS Project Plan that we do our scheduling in and our internal database. I’ve been able to read the dates out of the project plan and thus, update our internal database without issues. When attempting to update dates in the other direction (update the MSP plan based on dates from the database), I’m getting mixed results. I decided to start from the basics and created a very simple project plan and I’m also getting results there that I can’t say I understand. I’m looking for the general rules for updating dates in our project plans using .Tasks for .NET. I’m running with the latest version of .Tasks and am working with MSP 2007 files.


For my sync project, I will need to accomplish the following:
a) For tasks that have started (known by our database only), update the Actual Start Date and set the % Work Complete to a value between 1 and 99% (to help our scheduler with resource management) --> expectation is that upon save, the Actual Start date change forced a change to the Start and Finish Dates (for a fixed duration task), which is the behavior I’ve experienced when I do this same thing direct in MSP
b) For tasks that have completed (known by our database only), update the Actual Finish Date and set the % Work Complete to 100% --> expectation is that upon save, the Actual Finish date change forced a change to the Finish Date field and duration (if applicable)

As I’m experiencing results that don’t match expectations, I decided to break it down to the very basics. I decided to create a very simple project plan file, which I’ve attached called “TestSyncProject”. It has a single fixed duration task with a Start Date of 4/22/15 and a duration of 2 days. When I attempt to simply change the Start Date to 4/20/15, it increases the duration to 4 days, leaving the original Finish Date alone. If I change the Start Date to 4/27 (after the original), it correctly moves the Finish Date to 4/28 and leaves the duration at 2 days. I’ve included the two output files that show the results of these changes.

In addition to this behavior, when I attempted to instead write to the Actual Start (to clarify, the Start date was NOT touched in this example), trying to test the expected result outlined in point (a) above to 4/17/15, using the same test file, the saved file did not have anything in the Actual Start column. The Start Date did change to 4/17, but again, the fixed duration of 2 days was not adhered to, but instead resulted in a new duration of 5 days, with the original Finish Date of 4/23 left in tact.

Thus, I’m struggling to understand the behavior of the .Tasks tool as it does not seem to match directly with what I experience when I make the same changes directly in MSP. I’m not sure if I manually need to make additional changes to other parameters that I haven’t been touching in code. I appreciate any feedback to help explain this.

Below is the simple code I’ve been executing (changes made during testing were to the newDate value and which line was commented out between setting either the Tsk.Start or Tsk.ActualStart):

Aspose.Tasks.Project proj = new Aspose.Tasks.Project(dir + “TestSyncProject.mpp”);
ChildTasksCollector collector = new ChildTasksCollector();
TaskUtils.Apply(proj.RootTask, collector, 0);
DateTime newDate = new DateTime(2015, 4, 17);

foreach (Task tsk in collector.Tasks)
{
if (tsk.Get(Tsk.Name) == “Test 1”)
{
Duration tskDuration = tsk.Get(Tsk.Duration);
// tsk.Set(Tsk.Start, newDate);
tsk.Set(Tsk.ActualStart, newDate);
}
}

proj.Save(dir + “SavedByTask.mpp”, SaveFileFormat.MPP);

Hi Michael,

Thank you for your inquiry.

I would like to address your concerns one by one and share my findings here with you. The tests have been carried out using the latest version of Aspose.Tasks for .NET 8.2.0 and the following code sample (which simply sets the Start and Actual Start of the task). I have also attached the output of the following code for your kind reference. Please feel free to write us back for further discussion if your have any concerns about the difference in results I have shared below.

1. When I attempt to simply change the Start Date to 4/20/15, it increases the duration to 4 days, leaving the original Finish Date alone.

Findings: I was not able to observe the issue. In the attached screenshot, you can see that the start date is changed to 20/4/2015 and duration remains at 2 days. The same can be found in the saved file StartChagnedTo_20150420.mpp that is attached here for your reference.

2. If I change the Start Date to 4/27 (after the original), it correctly moves the Finish Date to 4/28 and leaves the duration at 2 days.

Findings: The results are same at my end as well. Resultant file, named StartChagnedTo_20150427.mpp is attached here for your reference.

3. In addition to this behavior, when I attempted to instead write to the Actual Start (to clarify, the Start date was NOT touched in this example), trying to test the expected result outlined in point (a) above to 4/17/15, using the same test file, the saved file did not have anything in the Actual Start column. The Start Date did change to 4/17, but again, the fixed duration of 2 days was not adhered to, but instead resulted in a new duration of 5 days, with the original Finish Date of 4/23 left in tact.

Findings: I was able to observe the issue where the summary task Actual Start field contains NA in this case and have logged this as TASKS-33983 in our bug tracking system for further investigation by our product team. However, I would also like to share that the start date is changed to 4/17/2015, Finish Date is set to 4/20/2015 and duration remains 2 days as expected. Resultant file, named ActualStartChagnedTo_20150417.mpp is attached here for your reference.

Code:

static void Check622326()
{
    Project project = new Project("622326\\TestSyncProject.mpp");
    Task task = project.RootTask.Children.GetById(1);
    Console.WriteLine("************ Task Original Information ************");
    PrintTask(task);
    Console.WriteLine("************ Changing Task Start Date *************");
    task.Set(Tsk.Start, new DateTime(2015, 4, 20));
    PrintTask(task);
    project.Save("622326\\StartChagnedTo_20150420.mpp", SaveFileFormat.MPP);
    Console.WriteLine("************ Changing Task Start Date *************");
    task.Set(Tsk.Start, new DateTime(2015, 4, 27));
    PrintTask(task);
    project.Save("622326\\StartChagnedTo_20150427.mpp", SaveFileFormat.MPP);
    Console.WriteLine("\n************ Changing Task Actual Start Date ************");
    task.Set(Tsk.ActualStart, new DateTime(2015, 4, 17, 8, 0, 0));
    PrintTask(task);
    Console.WriteLine("\n************ Summary Task Information ************");
    PrintTask(project.RootTask.Children.GetById(0));
    project.Save("622326\\ActualStartChagnedTo_20150417.mpp", SaveFileFormat.MPP);
}

static void PrintTask(Task task)
{
    Console.WriteLine(task.Get(Tsk.Name));
    Console.WriteLine("Start: " + task.Get(Tsk.Start));
    Console.WriteLine("Finish: " + task.Get(Tsk.Finish));
    Console.WriteLine("Duration: " + task.Get(Tsk.Duration));
    Console.WriteLine("Actual Start: " + task.Get(Tsk.ActualStart));
    Console.WriteLine("Actual Finish: " + task.Get(Tsk.ActualFinish));
    Console.WriteLine("Percent Complete: " + task.Get(Tsk.PercentComplete));
}

PS: The part of code for changing task’s Start date was commented when testing the Actual Start date issue.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.