The previous article was a simple read and output, a little bit deeper here, and the contents of the read are stored in a DataTable by field.
1StringBuilder SB =NewStringBuilder ();2notessession NS =Newnotessession ();3 //NS. Initialize ("test1234");4 NS. Initialize ();5 if(ns = =NULL)6 {7MessageBox.Show ("failed to initialize");8 return;9 }Ten //notesdatabase db = ns. Getdatabase ("", @ "Names.nsf", false); OneNotesDatabase db = ns. Getdatabase ("",@"Todo/120006.nsf",false); A if(db = =NULL) - { -MessageBox.Show ("failed to initialize database"); the return; - } -Notesview view = db. GetView (@"v5\01. todo file"); - if(View = =NULL)return; +DataTable dt =NewDataTable (); - Object[] cols =view. ColumnNames; +dictionary<int,Object> dic =Newdictionary<int,Object>(); A if(Cols! =NULL) at { - intIX =0; - foreach(ObjectObjinchcols) - { - DiC. Add (ix, obj); - if(obj! =NULL) in { -Sb. Append (string. Format ("{0};", obj)); to if(!dt. Columns.contains (obj. ToString ())) + { -DataColumn DC =NewDataColumn (obj. ToString ()); the dt. Columns.Add (DC); * } $ Panax Notoginseng } -ix++; the } + } ANotesDocument doc =view. Getfirstdocument (); the while(Doc! =NULL) + { - Object[] Objs = (Object[]) doc. Columnvalues; $ if(Objs = =NULL)return; $ intIX =0; -DataRow dr =dt. NewRow (); - foreach(ObjectObjinchObjs) the { - if(obj = =NULL)Continue;Wuyikeyvaluepair<int,Object> kv = dic. FirstOrDefault (m = M.key = =ix); theType TP =obj. GetType (); - if(TP.) Name.contains ("object[]")) Wu { - Object[] Nobjs = (Object[]) obj; Aboutlist<string> list =Newlist<string>(); $ foreach(varNobjinchNobjs) - { -Sb. Append (string. Format ("{0}\r\n", Nobj)); -List. ADD (string. Format ("{0}", Nobj)); A } +Dr[kv. Value.tostring ()] =string. Join ("|", list); the } - Else $ { theSb. Append (string. Format ("{0}\r\n", obj)); theDr[kv. Value.tostring ()] =obj; the } theix++; - } in dt. Rows.Add (DR); theDoc =view. GetNextDocument (DOC); the}
. NET reads the Lotus Domino file database and writes it to a DataTable