public void RescheduleProjectFromStartDate()
{
// ExStart:RescheduleProjectFromStartDate
// ExFor: Project.Recalculate
var project = new Project(DataDir + "BZP V01.mpp");
var refDay = new DateTime(2024, 9, 13);
var datelist = new List<DateTime>() { project.Get(Prj.StartDate),refDay,refDay.AddDays(-14),refDay.AddMonths(-12),refDay.AddMonths(12) };
foreach (var date in datelist)
{
Console.WriteLine($"New Start Date {date.ToShortDateString()}");
project.Set(Prj.ScheduleFromStart, true);
project.Set(Prj.StartDate, date);
// Now all tasks dates (Start, Finish, EarlyStart, EarlyFinish, LateStart, LateFinish) are calculated. To get the critical path we need to calculate slacks (can be invoked in separate thread, but only after calculation of all early/late dates)
project.Recalculate();
foreach (var task in project.EnumerateAllChildTasks().Take(1))
{
Console.WriteLine($"{task.Get(Tsk.Id)} {task.Get(Tsk.Name)}");
Console.WriteLine($"Start {task.Get(Tsk.Start)} Finish {task.Get(Tsk.Finish)}");
}
Console.WriteLine($"==========================================================");
}
foreach (var date in datelist)
{
Console.WriteLine($"New Finish Date {date.ToShortDateString()}");
project.Set(Prj.ScheduleFromStart, false);
project.Set(Prj.FinishDate, date);
// Now all tasks dates (Start, Finish, EarlyStart, EarlyFinish, LateStart, LateFinish) are calculated. To get the critical path we need to calculate slacks (can be invoked in separate thread, but only after calculation of all early/late dates)
project.Recalculate();
foreach (var task in project.EnumerateAllChildTasks().Take(1))
{
Console.WriteLine($"{task.Get(Tsk.Id)} {task.Get(Tsk.Name)}");
Console.WriteLine($"Start {task.Get(Tsk.Start)} Finish {task.Get(Tsk.Finish)}");
}
Console.WriteLine($"==========================================================");
}
// ExEnd:RescheduleProjectFromStartDate
}
I used my own reference project BZP V01.zip (59,9 KB) to change the start date of the project using API. Unfortunately, the dates will not be recalculated.
New Start Date 10.05.2019
0 BZP V01
Start 10.05.2019 08:00:00 Finish 16.10.2019 17:00:00
New Start Date 13.09.2024
0 BZP V01
Start 10.05.2019 08:00:00 Finish 16.10.2019 17:00:00
New Start Date 30.08.2024
0 BZP V01
Start 10.05.2019 08:00:00 Finish 16.10.2019 17:00:00
New Start Date 13.09.2023
0 BZP V01
Start 10.05.2019 08:00:00 Finish 16.10.2019 17:00:00
New Start Date 13.09.2025
0 BZP V01
Start 10.05.2019 08:00:00 Finish 16.10.2019 17:00:00
In my example, I also included backward planning and also changed the end dates using API. The dates are calculated correctly here.
New Finish Date 10.05.2019
0 BZP V01
Start 12.07.2018 08:00:00 Finish 09.05.2019 17:00:00
New Finish Date 13.09.2024
0 BZP V01
Start 12.06.2023 08:00:00 Finish 13.09.2024 17:00:00
New Finish Date 30.08.2024
0 BZP V01
Start 29.05.2023 08:00:00 Finish 30.08.2024 17:00:00
New Finish Date 13.09.2023
0 BZP V01
Start 09.06.2022 08:00:00 Finish 13.09.2023 17:00:00
New Finish Date 13.09.2025
0 BZP V01
Start 10.06.2024 08:00:00 Finish 12.09.2025 17:00:00
Can you please help me to find the error.