I got a collection of 'Users' which are working on task between two dates (firstPerformance and LastPerformance) for some hours. I would like to asign that information to a task with creating asignments and setting their Start, Finish and Work:
Assignment a = task.Assignments.Add(ResourceID: user.Resource.Id);
a.Start = user.Performances.FirstPerformance;
a.Finish = user.Performances.LastPerformance;
a.Work = user.Performances.TotalTime * 60 // TotalTime is in hours while Work is in minutes
Before I do that I remove all assignments on the task and set it to pjFixedWork:
task.Type = PjTaskFixedType.pjFixedWork;
foreach (Assignment a in task.Assignments) a.Delete();
This results in strange behaivor: On the first run it sets Work and Start in Project correct and assigns the correct resource. On the second run it sets Work, Start and Finish correct And on the third run it also fixes the Unit
For example:
- Start: 19.10.21 Finish: 02.02.22 Work: 288,75h Resource: Andreas
- Start: 19.10.21 Finish: 27.01.22 Work: 288,75h Resource: Andreas [57%]
- Start: 19.10.21 Finish: 27.01.22 Work: 288,75h Resource: Andreas [60%]
Of course the input is on all three runs the same!
While still not understanding this behavior I experience something different if there is more than one resource to be assigned.
The data I'm assigning looks like:
User 1 First: 14.09.2021 Last: 02.12.2021 Total Time: 82,75
User 2 First: 31.08.2021 Last: 28.01.2022 Total Time: 263,5
User 3 First: 08.09.2021 Last: 09.09.2021 Total Time: 4,5
User 4 First: 02.12.2021 Last: 02.12.2021 Total Time: 1
User 5 First: 19.10.2021 Last: 28.01.2022 Total Time: 223
User 6 First: 06.12.2021 Last: 25.01.2022 Total Time: 18,5
User 7 First: 07.09.2021 Last: 14.12.2021 Total Time: 126
The results of different runs look like:
- Start: 31.08.21 Finish: 14.01.22 Work: 170h Resource: User1; User2; ...
- Start: 31.08.21 Finish: 14.01.22 Work: 169,04h Resource: User1; User2; ...
- Start: 31.08.21 Finish: 14.01.22 Work: 169,04h Resource: User1; User2; ... NO CHANGES
Since I have assigned 1€/hour on the resouces I can see that something is going on since the costs are:
User 1 0,21€
User 2 2,59€
User 3 0,16€
User 4 0,07€
User 5 30,79€
User 6 9,22€
User 7 126,00€
What adds up to 169,04.
What am I doing wrong here?
Best Regards
Andreas