2013ProjectTemplate.zip (28.1 KB)
Am trying to create a project with task as shown below, while assigning the resource getting an error “TimeSpan does not accept floating point Not-a-Number value”
string testTemplate = "2013ProjectTemplate.mpt";
Project oMPPPRoj = new Project(sPath + testTemplate)
{
CalculationMode = CalculationMode.Manual
};
Resource res2 = oMPPPRoj.Resources.Add("Resource 2");
DateTime projectstartdate = Convert.ToDateTime("03-Jul-2019");
DateTime projectenddate = Convert.ToDateTime("10-Jul-2019");
oMPPPRoj.Set(Prj.StartDate, projectstartdate);
oMPPPRoj.Set(Prj.FinishDate, projectenddate);
DateTime tskstartdate = Convert.ToDateTime("05-Jul-2019");
DateTime tskenddate = Convert.ToDateTime("09-Jul-2019");
Aspose.Tasks.Task tsk3 = oMPPPRoj.RootTask.Children.Add("Task 3");
tsk3.Set(Tsk.Type, TaskType.FixedDuration);
tsk3.Set(Tsk.IsManual, true);
tsk3.Set(Tsk.Start, tskstartdate);
tsk3.Set(Tsk.Finish, tskstartdate);
tsk3.Set(Tsk.Deadline, tskenddate);
Duration oTskDuration = oMPPPRoj.GetDuration(8, TimeUnitType.Hour);
tsk3.Set(Tsk.Work, oTskDuration);
ResourceAssignment resAsn5 = oMPPPRoj.ResourceAssignments.Add(tsk3, res2);
resAsn5.Set(Asn.Units, 1);
oMPPPRoj.Save("SavedMPP.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP);
Can you please confirm what is wrong here.