c# 4.0 - MPXJ consistently adds blank task name...is MPXJ better than Interop? -


i'm trying use mpxj create project file hierarchy exists in code. following hierarchy needs converted:

  • division
    • customer
      • contract
        • projects
          • project details (start/end dates, etc.)

my code creating .mpx follows:

private void buildexport()     {          net.sf.mpxj.projectfile file = new net.sf.mpxj.projectfile();         net.sf.mpxj.projectcalendar cal = file.adddefaultbasecalendar();          //microsoft.office.interop.msproject.application projapp = new microsoft.office.interop.msproject.application();         //projapp.visible = true;         //projapp.filenew();          string firstdate = string.empty;          foreach (izcptreeviewitem div in divisions)         {             net.sf.mpxj.task divtask = file.addtask();             divtask.setname(div.name);              //microsoft.office.interop.msproject.task newtask = projapp.activeproject.tasks.add(div.name);              //newtask.outlinelevel = 1;              foreach (izcptreeviewitem cust in div.subitems)             {                 net.sf.mpxj.task custtask = null;                  if (cust.subitems.count > 0)                 {                     custtask = divtask.addtask();                     custtask.setname(cust.name);                 }                                      //microsoft.office.interop.msproject.task custtask = newtask.outlinechildren.add(cust.name);                  //custtask.outlinelevel = 2;                  foreach (izcptreeviewitem contractvm in cust.subitems)                 {                     net.sf.mpxj.task conttask = custtask.addtask();                     conttask.setname(contractvm.name);                      //microsoft.office.interop.msproject.task contracttask = custtask.outlinechildren.add(contractvm.name);                      //contracttask.outlinelevel = 3;                      foreach (zcpprojectviewmodel proj in (contractvm zcpcontractviewmodel).projects)                     {                         net.sf.mpxj.task projtask = conttask.addtask();                         projtask.setname(proj.name);                          //microsoft.office.interop.msproject.task projtask = contracttask.outlinechildren.add(proj.project.name);                          //projtask.outlinelevel = 4;                          foreach (zcpprojectdetailviewmodel detail in proj.projectdetail)                         {                             net.sf.mpxj.task projdtask = projtask.addtask();                             projdtask.setname(detail.projectdetail.costclass);                             projdtask.setstart(detail.startdate.hasvalue ? new java.util.date(detail.startdate.tostring()) : null);                              //microsoft.office.interop.msproject.task projdetailtask = projtask.outlinechildren.add(detail.projectdetail.costclass);                              //projdetailtask.start = string.format("{0}", detail.startdate.tostring());                             //projdetailtask.finish = string.format("{0}", detail.enddate.tostring());                              //projdetailtask.outlinelevel = 5;                         }                     }                 }             }         }          net.sf.mpxj.writer.projectwriter writer = new mpxwriter();         writer.write(file, "example.mpx");     } 

the commented out code interop code using before found mpxj. problem after run block, .mpx file has customers blank (even though put breakpoints in when adding these customers , ensured names not empty). there else need set ensure names use?

should go using incredibly slow (17 minutes create ~6000 tasks) interop code. there way write projcet file using interop without having project file open.

thanks!!

having spoken ryan offline, , looked @ data - here found.

ryan can generate both mpx , mspdi files using mpxj, minimal set of attributes each task. in example code shown above, name , start date being supplied. of task names appear expected in both mpx , mspdi files.

when opened in project 2003 or project 2007, of task names visible... if start working through file , collapsing task hierarchy (in case of data ryan has generated, collapsing of tasks beneath customer level) 1 of tasks blanked out. of data task disappear, , no amount of expanding , collapsing task hierarchy bring back.

the behaviour seems worse in project 2010, many of task names blank project loads.

it looks weird ms project issue related importing files don't have attributes present. in case ryan added finish date export, , seemed trick. when opened in project 2010, files include finish date attribute correctly display of task names. when opened in project 2003, couldn't reporduce random "blanking" problem saw original file.

on more general note, there example class ships mpxj called mpxjcreate gives example of minimum set of attributes required ensure tasks, resources, , resource assignments display expected when files created mpxj opened in ms project.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -