1: public static void GetDocuments(string StartDirectory,string OutputDirecotry)
2: {
3: List<System.IO.FileInfo> Files=Utilities.FileManager.FileList(StartDirectory);
4: List<System.IO.DirectoryInfo> Directories = Utilities.FileManager.DirectoryList(StartDirectory);
5: foreach (System.IO.FileInfo File in Files)
6: {
7: if (File.Extension.Equals(".nsf", StringComparison.CurrentCultureIgnoreCase))
8: {
9: XmlDocument TempDoc = GetFromNSFdb(File.FullName);
10: string DocumentName = "";
11: List<Values> Docs = ParseKeys(TempDoc, File.FullName, out DocumentName);
12: if (File.Name.Equals("Main.nsf"))
13: {
14: GetDocuments(Docs, OutputDirecotry, File.FullName);
15: }
16: else
17: {
18: if (Docs.Count > 0)
19: {
20: Utilities.FileManager.CreateDirectory(OutputDirecotry + "/" + DocumentName);
21: GetDocuments(Docs, OutputDirecotry + "/" + DocumentName, File.FullName);
22: }
23: }
24: }
25: }
26: foreach (System.IO.DirectoryInfo Directory in Directories)
27: {
28: if (!Directory.Name.Equals("Search.ft", StringComparison.CurrentCultureIgnoreCase))
29: {
30: Utilities.FileManager.CreateDirectory(OutputDirecotry + "/" + Directory.Name);
31: GetDocuments(Directory.FullName, OutputDirecotry + "/" + Directory.Name);
32: }
33: }
34: }
35:
36: public static XmlDocument GetFromNSFdb(string strNSFdbName)
37: {
38:
39: try
40: {
41: Domino.ISession session = new NotesSessionClass();
42: session.Initialize(YOURPASSWORD);
43: Domino.NotesDatabase database = session.GetDatabase("", strNSFdbName, false);
44: Domino.NotesNoteCollection noteCollecton = database.CreateNoteCollection(true);
45: noteCollecton.SelectAllAdminNotes(true);
46: noteCollecton.SelectAllCodeElements(true);
47: noteCollecton.SelectAllDataNotes(true);
48: noteCollecton.SelectAllDesignElements(true);
49: noteCollecton.SelectAllFormatElements(true);
50: noteCollecton.SelectAllIndexElements(true);
51: noteCollecton.SelectForms = true;
52: noteCollecton.BuildCollection();
53: Domino.NotesDXLExporter exporter = (Domino.NotesDXLExporter)session.CreateDXLExporter();
54: string strNsfXML = exporter.Export(noteCollecton);
55: string strDocrmv = strNsfXML.Replace("<!DOCTYPE database SYSTEM 'xmlschemas/domino_6_5_3.dtd'>", "").Replace("xmlns='http://www.lotus.com/dxl'", ""); XmlDocument xDocLoad = new XmlDocument();
56: xDocLoad.LoadXml(strDocrmv);
57: return xDocLoad;
58: }
59: catch { return null; }
60: }
61:
62: public static List<Values> ParseKeys(XmlDocument TempDoc,string strNSFdbName,out string DocumentName)
63: {
64: XmlNode TempNode = TempDoc["database"];
65: DocumentName = TempNode.Attributes["title"].Value;
66: List<Values> TempDic = new List<Values>();
67: string CurrentKey = "";
68: string FileName = "";
69: foreach (XmlNode Child in TempNode.ChildNodes)
70: {
71: if (Child.HasChildNodes)
72: {
73: foreach (XmlNode Child2 in Child.ChildNodes)
74: {
75: if (Child2.Name.Equals("noteinfo", StringComparison.CurrentCultureIgnoreCase)
76: && Child2.Attributes["noteid"]!=null)
77: {
78: CurrentKey = Child2.Attributes["noteid"].Value;
79: break;
80: }
81: }
82: foreach (XmlNode Child2 in Child.ChildNodes)
83: {
84: if (Child2.HasChildNodes)
85: {
86: if (Child2.Name.Equals("item", StringComparison.CurrentCultureIgnoreCase)
87: && Child2.Attributes["name"]!=null
88: && Child2.Attributes["name"].Value.Equals("$FILE", StringComparison.CurrentCultureIgnoreCase))
89: {
90: foreach (XmlNode Child3 in Child2.ChildNodes)
91: {
92: if (Child3.Name.Equals("object", StringComparison.CurrentCultureIgnoreCase))
93: {
94: foreach (XmlNode Child4 in Child3.ChildNodes)
95: {
96: if (Child4.Name.Equals("file", StringComparison.CurrentCultureIgnoreCase))
97: {
98: FileName = Child4.Attributes["name"].Value;
99: Values TempValue = new Values();
100: TempValue.Key = FileName;
101: TempValue.Value = CurrentKey;
102: TempDic.Add(TempValue);
103: }
104: }
105: }
106: }
107: }
108: }
109: }
110: }
111: }
112: return TempDic;
113: }
114:
115: public static void GetDocuments(List<Values> Docs, string OutputDirectory, string strNSFdbName)
116: {
117: Domino.ISession session = new NotesSessionClass();
118: session.Initialize(YOURPASSWORD);
119: Domino.NotesDatabase database = session.GetDatabase("", strNSFdbName, false);
120: foreach (Values Key in Docs)
121: {
122: Domino.NotesDocumentClass TempDoc = (Domino.NotesDocumentClass)database.GetDocumentByID(Key.Value);
123: Domino.NotesEmbeddedObjectClass Object = (Domino.NotesEmbeddedObjectClass)TempDoc.GetAttachment(Key.Key);
124: Object.ExtractFile(OutputDirectory + "/" + Key.Key);
125: }
126: }
127:
128: public class Values
129: {
130: public string Key;
131: public string Value;
132: }