If a task has a predecessor and it ends at 5pm, the next task will still start at 5pm of the same day instead of the next day.
Hi Albert,
Thank you for writing to Aspose support team.
I have tried this scenario using following sample code but could not reproduce it. Could you please send us a simple console application (along with the template file if any) which can be compiled and executed here for our reference? It will help us to observe the problem and provide assistance accordingly.
Project proj = new Project();
Task tsk1 = proj.RootTask.Children.Add("Task 1");
Task tsk2 = proj.RootTask.Children.Add("Task 2");
proj.TaskLinks.Add(tsk1, tsk2,TaskLinkType.FinishToStart);
proj.Save("output.xml",SaveFileFormat.XML);
Hello,
This is the code of how I generated the mpp
Aspose.Tasks.Project project = new Aspose.Tasks.Project();
project.Set(Prj.StartDate, startDate);
project.Set(Prj.DefaultStartTime, startDate);
project.Set(Prj.StatusDate, startDate);
foreach (var task in projectPlan.Tasks)
{
var parent = projectPlan.Tasks.Take(projectPlan.Tasks.IndexOf(task)).LastOrDefault(t => t.TaskLevel < task.TaskLevel);
Task asposeTask = (parent != null) ? project.RootTask.Children.GetByUid(parent.ID).Children.Add(task.TaskName) : project.RootTask.Children.Add(task.TaskName);
asposeTask.Set(Tsk.IsManual, false);
asposeTask.Set(Tsk.Start, task.StartDate);
asposeTask.Set(Tsk.DurationFormat, TimeUnitType.Day);
asposeTask.Set(Tsk.Duration, project.GetDuration((double)task.Duration, TimeUnitType.Day));
asposeTask.Set(Tsk.IsMilestone, task.IsMilestone);
task.ID = asposeTask.Get(Tsk.Uid);
}
foreach (var task in projectPlan.Tasks.Where(x => x.Predecessors.Any()))
{
Task ptask = project.RootTask.Children.GetByUid(task.ID);
foreach (ProjectTaskPredecessor pred in task.Predecessors) {
Task ppredtask = project.RootTask.Children.GetByUid(projectPlan.Tasks.FirstOrDefault(pr => pr.ProjectTaskID == pred.ProjectTaskIDPre).ID);
TaskLinkType linkType = TaskLinkType.FinishToStart;
if (pred.TaskRelationshipID.Value == (int)TaskRelationshipValue.FF) linkType = TaskLinkType.FinishToFinish;
else if (pred.TaskRelationshipID.Value == (int)TaskRelationshipValue.SF) linkType = TaskLinkType.StartToFinish;
else if (pred.TaskRelationshipID.Value == (int)TaskRelationshipValue.SS) linkType = TaskLinkType.StartToStart;
TaskLink taskLink = project.TaskLinks.Add(ppredtask, ptask, linkType);
}
I’ve also attachd a resulting mpp. On the file, Task Closing (ID 13) has a predecessor Task Executing (ID 2), Task 2 ends at 5pm while Task 13 still starts at 5pm of the same day
Hi Albert,
Hello,
I’ve attached the data and code in the zip file. I’ve also attached the problem where the predecessor starts on the end of the day
Hi Albert,
Hello,
Sorry, not familiar with the terms. What if the leaf task and how do I set the leaf?
Hello,
The dates are still wrong. Ive set the predecessors to the leaf but the summary task stays as the start date of the project. Also when the leaf is a milestone, it still would start at the end of the same day
Hi Albert,
We have investigated the issue and following are the findings:
Beheviour of MSP in cases of Automatic and Manual planning is different. In case of Automatic planning the start and finish date of the succeeding task will be set to the finish date of the preceeding task. In case of manual task planning the start and finish date of the succeeding task will be set to the next working day start of the preceeding task. I prepared 2 samples, one with manual and one with automatic task planning (1744_ManualTasks.mpp and 1744_AutoTasks.mpp). As in your code sample tasks are set to Automatic planning ( asposeTask.Set(Tsk.IsManual, false); ). So when you try to set a preceeding task of 7 to 3, MSP set the start and finish date of task 7 to the finish date of task 3 i.e. 10/4/16 5:00 PM.
You can check this behavior by creating two MPP files in MSP such that one file contains automatic tasks only where as other mpp file contains manual tasks only. Then try to set the predecessor tasks and check the behavior. Sample MPP files are attached here for testing MSP behavior. Set predecessor task 2 against task 4 and 5 in both the MPP files by opening them in MSP and observe the difference for date calculation of task with 0 duration.
Similarly please notice that if some constraint is implemented for some task like “start no earlier than”, then setting the predecessor task may not change date if new calculated date is prior to the constraint date.
Please test you r scenarios again and share the feedback.
1744_AutoTasks.zip (25.2 KB)
1744_ManualTasks.zip (24.7 KB)