Hello Sebastien,
In the mentioned example in MsProjectImportHelper we are generating GanttTasks from the provided xml. Similarly we can generate SqlTask instead of GanttTask as the SqlTask is also an IGanttTask.We should add the missing UniqueId property in the SqlTask class.
If you wish to convert each GanttTask generated from the MsProjectImportHelper.GetMsTasks() to SqlTask you can use something like that:
Hope this helps.
Regards,
Polya
Telerik
In the mentioned example in MsProjectImportHelper we are generating GanttTasks from the provided xml. Similarly we can generate SqlTask instead of GanttTask as the SqlTask is also an IGanttTask.We should add the missing UniqueId property in the SqlTask class.
If you wish to convert each GanttTask generated from the MsProjectImportHelper.GetMsTasks() to SqlTask you can use something like that:
private
static
Dictionary<GanttTask, SqlTask> generatedTasks =
new
Dictionary<GanttTask, SqlTask>();
public
SqlTask ConvertGanttTaskToSqlTask(GanttTask gTask)
{
var sTask =
new
SqlTask()
{
Start = gTask.Start,
End = gTask.End,
Title = gTask.Title,
Deadline = gTask.Deadline,
UniqueId = gTask.UniqueId,
Description = gTask.Description,
Duration = gTask.Duration,
};
var currentSqlTaskChildTasks = (ObservableCollection<SqlTask>)sTask.Children;
foreach
(var childGanttTask
in
gTask.Children)
{
currentSqlTaskChildTasks.Add(
this
.ConvertGanttTaskToSqlTask((GanttTask)childGanttTask));
}
sTask.Children = currentSqlTaskChildTasks;
generatedTasks.Add(gTask, sTask);
return
sTask;
}
//After all SqlTasks are Generated we should add their dependencies.
public
void
AddSqlDependenciesToGeneratedSqlTask(GanttTask gTask)
{
var sTask = generatedTasks[gTask];
foreach
(var dependency
in
gTask.Dependencies)
{
sTask.Dependencies.Add(
new
SqlDependency() { FromTask = generatedTasks[(GanttTask)dependency.FromTask], DependencyType = dependency.Type });
}
}
Hope this helps.
Regards,
Polya
Telerik
See What's Next in App Development. Register for TelerikNEXT.