0
Answer

Read data from MicrosoftProjectFile as Root & Children task

Hello everyone,
 Some one please tell me how we can import data from  MicrosoftProjectFile (.mpp) in hierarchy like Root task and its children task in sql server 2012 database.
I have written code to read data from file but still I am not able to get it in hierarchy (Root and Children format). My code is
 
ApplicationClass projectApp = new ApplicationClass();
// Open the file. There are a number of options in this constructor as you can see
projectApp.FileOpen(@"D:\proj.mpp", true, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
PjPoolOpen.pjDoNotOpenPool, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
// Get the active project
Microsoft.Office.Interop.MSProject.Project proj = projectApp.ActiveProject;
int cont = proj.Tasks.Count;
// Enumerate the tasks
string pname = proj.Name;
foreach (Microsoft.Office.Interop.MSProject.Task task in proj.Tasks)
{
string name = task.Name;
string subproject = task.Subproject;
string Project = task.Project;
string PredecessorTasks = task.PredecessorTasks.ToString();
string Milestone = task.Milestone.ToString();
int Index = task.Index;
int Id = task.ID;
string DurationText = task.DurationText;
string Application = task.Application.ToString();
task.OutlineShowSubTasks();
task.OutlineShowAllTasks();
// Project stores the number of minutes in a workday, so 8 hours per workday * 60 = 480. 480 is a project "day"
int duration_in_days = Int32.Parse(task.Duration.ToString()) / 480;
DateTime start = DateTime.Parse(task.Start.ToString());
DateTime finish = DateTime.Parse(task.Finish.ToString());
double percent_complete = Double.Parse(task.PercentComplete.ToString());
string actual_finish = "";
if (task.ActualFinish.ToString() != "NA" && task.ActualFinish != "")
actual_finish = task.ActualFinish.ToString();
string predecessors = task.Predecessors.ToString();
int Duration = (finish - start).Days;
//string TemplateDuration = task.
string Deadlines = task.Deadline.ToString();
string Notes = task.Notes.ToString();
//string TemplatesNotes=task.te
//string summary = task.Summary.ToString();
// Do something with each task here
}
 
Please  help me it's urgent. 
Thanks in advance