thanks for your answer. But I don't use the XMLGanttProvider but a GanttCustomProvider which inherits from GanttProviderBase. The only thing I want to do is to replace my temporary Ids through the Ids of the tasks, which are assigned by and stored inside the database after the user clicks the save-button inside my GetTasks-method of my GanttCustomProvider like this:
public class GanttCustomProvider : GanttProviderBase, IGanttCustomProvider
{
public override ITaskFactory TaskFactory
{
get { return new CustomGanttTaskFactory(); }
}
public override List<
ITask
> GetTasks()
{
var tasks = new List<
ITask
>();
//Load projectElmentDtos from the session
foreach (var task in GetTasksFromDatabase())
{
tasks.Add(new CustomTask
{
ID = task.Id,
Title = task.Title,
ParentID = task.ParentId,
OrderID = task.OrderId,
Start = task.StartDate,
End = task.EndDate,
Summary = task.Summary,
Expanded =task.Expanded,
PercentComplete = Convert.ToDecimal(task.PercentComplete),
TaskDuration = task.TaskDuration
});
}
}
return tasks;
}
public override ITask InsertTask(ITask task)
{
//Set a temporary random guid because if an update to a non-persistent ganttTask happens
//the object has to be indentified
task.ID = Guid.NewGuid();
GanttTask ganttTask = ToGanttTask(task);
InsertTaskToDatabase(ganttTask);
}
public override List<
IDependency
> GetDependencies()
{
var dependencies = new List<
IDependency
>();
foreach (var dependency in GetDependenciesFromDatabase())
{
dependencies.Add(new Dependency
{
ID = dependency.Id,
PredecessorID = dependency.PredecessorId,
SuccessorID = dependency.SuccessorId,
Type = (DependencyType)dependency.Type
});
}
}
return dependencies;
}
}
public class CustomGanttTaskFactory : ITaskFactory
{
Task ITaskFactory.CreateTask()
{
return new CustomTask();
}
}
public class CustomTask : Task
{
public CustomTask() : base(){}
public double TaskDuration
{
get { return (double)(ViewState["TaskDuration"] ?? 0.0); }
set { ViewState["TaskDuration"] = value; }
}
protected override IDictionary<
string
, object> GetSerializationData()
{
var dict = base.GetSerializationData();
dict["TaskDuration"] = TaskDuration.ToString(CultureInfo.InvariantCulture);
return dict;
}
public override void LoadFromDictionary(IDictionary values)
{
base.LoadFromDictionary(values);
if (values["TaskDuration"] != null)
TaskDuration = Double.Parse(values["TaskDuration"].ToString());
}
But if I set the Ids inside "public override List<ITask> GetTasks()"-method or "public override List<IDependency> GetDependencies()-method the ids inside the list with the tasks are not replaced. Hope this explanation is sufficient. Thanks.