Hello Aspose Team,
I am getting the exception when adding the task assignment baseline and calculating the project.
if (task.Baselines != null && task.Baselines.Count > 0)
{
totalBaselineWork = task.Baselines[0].Work.TimeSpan;
totalUnits = task.Assignments.Sum(a => a.Units);
if (totalUnits != 0 && totalBaselineWork.TotalHours > 0)
{
foreach (var a in task.Assignments)
{
if ((a.Baselines == null || a.Baselines.Count == 0 || a.Baselines[0].Work.TimeSpan == TimeSpan.Zero))
{
double proportion = a.Units / totalUnits;
var newBaselineHrs = TimeSpan.FromHours(totalBaselineWork.TotalHours * proportion);
var duration = task.ParentProject.GetDuration(newBaselineHrs.TotalHours);
a.Baselines.Add(new AssignmentBaseline()
{
Start = task.Baselines[0].Start,
Finish = task.Baselines[0].Finish,
Work = duration,
});
a.Work = task.ParentProject.GetDuration(newBaselineHrs.TotalHours);
a.TimephasedData.Clear();
recalculateRequired = true;
}
}
}
}
I have attached sample mpp file. I am reading all tasks and adding task baseline assignment if assignment is not available. When I recalculate the project, getting the below exception.
date cannot be DateTime.MinValue (Parameter ‘date’)
at Aspose.Tasks.Calendar.#=ziqT6fxWcPFD$(DateTime #=zBBoIJ$8=)
Aspose8.zip (2.0 MB)
Thanks,
Imrankhan Pathan