Hi All,
I have a requirement to Export a DataTable to MPP which i have achieved partially,my main concern in this process is *TIME TAKEN* for export,
I have a DataTable with 1500 rows which i have to export and to my shock it has taken 8 minutes to export this to MPP which is UNACCEPTABLE ,iam unable to solve this, need help,
Iam using the below code to add Tasks to the MPP
private void AddObjects(DataRow dRow, short outLineLevel, short prevOutLineLevel) {
try {
(this.msProj).Resources.Add("Temp", outLineLevel);
MSProject.Resource resource;
resource = this.msProj.Resources[outLineLevel];
MSProject.Task task;
this.msProj.Tasks.Add(dRow["TaskName"].ToString(), System.Reflection.Missing.Value);
this.msProj.Tasks[this.msProj.Tasks.Count].SetField(MSProject.PjField.pjTaskOutlineLevel, outLineLevel.ToString());
task = (((MSProject.Task)((MSProject.Tasks)((MSProject.Pr oject)this.msProj).Tasks)[this.msProj.Tasks.Count]));
DateTime plndStart = Convert.ToDateTime(dRow["PlannedStart"]);
DateTime plndEnd = Convert.ToDateTime(dRow["PlannedEnd"]);
if (!this.projApp.ActiveProject.BaseCalendars[1].Period(plndStart, plndStart).get_Working())
this.projApp.ActiveProject.BaseCalendars[1].Period(plndStart, plndStart).set_Working(true);
if (!this.projApp.ActiveProject.BaseCalendars[1].Period(plndEnd, plndEnd).get_Working())
this.projApp.ActiveProject.BaseCalendars[1].Period(plndEnd, plndEnd).set_Working(true);
task.Start = plndStart;
task.Finish = plndEnd;
task.Duration = dRow["Duration"];
task.ResourceNames = dRow["ResourceName"].ToString();
this.msProj.Tasks[this.msProj.Tasks.Count].SetField(MSProject.PjField.pjTaskOutlineLevel, outLineLevel.ToString());
DataRow[] rows = this.wbsDT.Select("ParentId=" + dRow["Id"]);
DataTable dt = new DataTable();
if (rows.Length > 0) {
for (int i = 0; i < rows.Length; i++) {
int index = prevOutLineLevel + 1;
AddObjects(rows[i], ((short)index), ((short)index));
}
}
}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
}
Need Help,
Best Regards.