Hi,
I have an MPP that is a “proper” network, in that everything is connected from start to finish. I expect that if I load the project and just change end date of the first task (milestone), all successor task dates will re-calculate automatically through the project.
My code is of the form:
Dim reader As ProjectReader = New ProjectReader()
prj = reader.Read(MyOriginalMPP)
Dim collector As ChildTasksCollector = New ChildTasksCollector()
TaskUtils.Apply(prj.RootTask, collector, 0)
Dim tsk As Aspose.Tasks.Task = prj.GetTaskByUid(MyStoredTskUID)
tsk.Start = myNewstartdate
tsk.Finish = rmyNewenddate
prj.Save(myUpdatedMPP, Saving.SaveFileFormat.MPP)
So if I then save the project I SHOULD have a new MPP with all dates shifted. Indeed if I do this in Microsoft Project that is what happens on this MPP. But only this ONE date is updated.
Is my understanding correct or do I need to recalculate anything eg Update refereneces of the project or recalculate task ID’s.
What could prevent this from happening if I do it via Aspose, that does not in Microsoft Project.
Regards
Richard
Hi Richard,
After updating a task, you need to recalculate the task for its effects by calling Task.Recalculate(UpdatedTask). Please give it a try at your end and let us know your feedback. I would request you to provide us your sample file in case the problem persists.
Oh I see that makes sense.
The problem is I have been doing various recalcs and sometimes it worked.
But not this spcifuc one.
any thanks , will try it.
Hi
So now before the save I put
Task.Recalculate(tsk)
But still only the one task is changed.
But its not obvious to me how the task recalculation gets fed back into the whole project for aall the related tasks.
Note the tasks being changed are milestones and both the start date and end date has been changed (eg moved forward by a number of days), but the duration has been retained. There are 66+ milestones dependent on the first milestone and in the past somehow I did get 66 to change using tsk.recalculate (not Tasks.recalculate(tsk)), but I cant seem to get back to that.
I really dont think its related to the MPP, because it happens with many different MPP’s I have tried. I think I have a conceptual misunderstanding.
My problem is I demonstrated this to our customer when it was working (although only partially), but now its not at all. I have to show this again on Monday.
Perhaps you could post some code as an example, Im sure Im missing something simple. Note the scheduling we are doing is only being applied to milestones, and they are typically duaration 1 day.
Perhaps the problem is that Im not changing any milestone duration, just trying to shift the milestones all by a number of days, simply by moving the first milestone.
Hi Richard,
Writing updated task data back to MPP is as demonstrated in our online article HERE. I have tried to reproduce this issue at my end using the following lines of code, but couldn’t reproduce it. Could you please give it a try at your end and let us know your feedback?
Sample Code:
string newProject = “SourceProject.mpp”;
Project project = new Project(newProject);
string testFile = "OutputMSP.mpp";
//Declare ChildTasksCollector class object
ChildTasksCollector collector = new ChildTasksCollector();
//Use TaskUtils to get all children tasks in RootTask
TaskUtils.Apply(project.RootTask, collector, 0);
Task task1 = project.GetTaskById(1);
task1.Start = new DateTime(2013, 07, 02, 8, 0, 0);
project.RootTask.Start = task1.Start;
Task.Recalculate(project.RootTask);
project.UpdateReferences();
project.CalcTaskIds();
project.CalcTaskUids();
//Save the Project
project.Save(testFile, Aspose.Tasks.Saving.SaveFileFormat.MPP);
In case the problem still exists, please provide us a sample file so as we can assist you further as soon as possible.
Hi,
Yes this is the scenario (or close enought to it).
I see you have added:
project.UpdateReferences();
project.CalcTaskIds();
project.CalcTaskUids();
This is the difference. Not sure I understand why the second two would be needd if the task structure hasn’t changed.
But I will try this.
Regards
Richard
Well now as before if I recalculate the task it works, but on one MPP it doesn’t. Althought it passes the verify check.
Also please confirm that if I do NOT change the task structure, only dates for exuisting tasks, I do not need:
project.UpdateReferences();
project.CalcTaskIds();
project.CalcTaskUids();
Please explain carefully what they do.
Regards
Richard
Hi Richard,
Could you please send us the MPP where it doesn’t work? We will analyze it and assist you further.
Regarding your query related to the usage of fields, there are certain internal parameters whose updating depends on these method calls and after updating tasks, these need to be called. I’ll get further information about this from our development team and update you soon here.
Hi,
Thanks, the point is if we change the MPP structure slightly eg , add a milestone we do NOT want to change the existing UID’s.
So I would like to understand the implications of each of these methods … especially since, for the mpp’s that work, they do not appear to be needed.
The data is confidential and we will need to sanitize it first. Give me a few days.
Regards
Richard
Hi Richard,
You are right. In case tasks structure remains the same, you don’t need these statements and recalculating the task will do the work for you. There are a number of internal dependencies for which UpdateReferences need to be called if you add a new Task or Resource to project Resources and based on this, the IDs and UIDs of tasks need to be recalculated as well. MSP relies on a lot of different fields for recalculations and if something is not set, then MSP can behave not as expected.
If you could further provide us some sample files where these don’t work, we’ll investigate the issue and assist you further then.
Hi Again,
attached is an MPP that doesnt work.
I have sanitized it for security reasons.
The issues are
1. There is an orphan milestone that will cause the application to fail on tasks.recalculate(tsk). It will loop in aspose tasks, run out of memory and crash the application. I am guessing this will happen on recalculating any task that has no dependencies. I now check for this and warn the user to correct the MPP, so it is not urgent.
2. You see task 15 (j) has a number of predecessors. Recalculate the project START end date using the mpp and everything works perfectly. Eg shift it forward by some days. But using Aspose the predecessor rules are not honored and the task J is not calculated correctly. Eg the total extent of the project is reduced.
My customer is already concerned about the validity of using Aspose tasks because of point 1., although as you can see I have worked around it.
Now I urgently need to work around point2.
Regards
Richard
Hi Richard,
Please spare us little time as we are investigating the issue and will share our findings shortly.
Thanks for your patience in this regard.
I suppose you have the ZIP already. I realized it still contains personal data, so I had to remove it. If you dont have rthe zip then I can put it up again briefly. This thread is also now marked as privae.
Hi Richard,
Following are my findings:
richard.schneller@teammacro.com:
1. There is an orphan milestone that will cause the application to fail on tasks.recalculate(tsk). It will loop in aspose tasks, run out of memory and crash the application. I am guessing this will happen on recalculating any task that has no dependencies. I now check for this and warn the user to correct the MPP, so it is not urgent.
I have tried to reproduce this issue using your sample file but could not observe the hanging on Task.Recalculate(). Could you please provide the sample application which can be used with this sample Bad.MPP to re-produce the hanging. It will help us to provide assistance in this regard.
richard.schneller@teammacro.com:
2. You see task 15 (j) has a number of predecessors. Recalculate the project START end date using the mpp and everything works perfectly. Eg shift it forward by some days. But using Aspose the predecessor rules are not honored and the task J is not calculated correctly. Eg the total extent of the project is reduced.
I was able to reproduce this issue at my end using the latest version of Aspose.Tasks for .NET 5.6.0 and have logged it in our bug tracking system under issue id: TASKS-33379. Development team will look into it and once we have any information regarding the resolution of this issue, we'll update you here via this thread.
If you have any other query/inquiry regarding Aspose.Tasks, please feel free to post to us. We'll try to assist you further as soon as possible.
Sorry dis not explain clearly. You already have it. There is an inactive task in bad.mpp, just make it active.
Sorry did not explain clearly. You already have it. There is an inactive task in bad.mpp, just make it active.
for point 2, is there a workaround? If we cannot resolve this quickly we will have to forget Aspose Taks as being too unreliable. I will have to review it with the customer later today and tell them the bad news.