diff --git a/PROMS/DataLoader/dlgExportImport.cs b/PROMS/DataLoader/dlgExportImport.cs index 167b171f..00c840d3 100644 --- a/PROMS/DataLoader/dlgExportImport.cs +++ b/PROMS/DataLoader/dlgExportImport.cs @@ -53,11 +53,14 @@ namespace DataLoader PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database; if (!Directory.Exists(PEIPath)) Directory.CreateDirectory(PEIPath); + if (_MyMode == "Import") + { if (MyFolder.ChildFolderCount == 0) { Directory.Delete(PEIPath, true); Directory.CreateDirectory(PEIPath); } + } pnlExport.Dock = DockStyle.Fill; pnlImport.Dock = DockStyle.Fill; if (_MyMode.ToLower() == "export") @@ -586,6 +589,19 @@ namespace DataLoader //if (!Old2NewContent.ContainsKey(oldid)) Old2NewContent.Add(oldid, newid); } + ze = MyImpxZipFile["libdocs.xml"]; + ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently); + fn = PEIPath + @"\libdocs.xml"; + xd = new XmlDocument(); + xd.Load(fn); + nl = xd.SelectNodes("//libdoc"); + foreach (XmlNode nd in nl) + { + int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); + int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); + //if (!Old2NewContent.ContainsKey(oldid)) + Old2NewLibDoc.Add(oldid, newid); + } ze = MyImpxZipFile["transitions.xml"]; ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently); fn = PEIPath + @"\transitions.xml"; @@ -721,6 +737,7 @@ namespace DataLoader { Old2NewItem = new Dictionary(); Old2NewContent = new Dictionary(); + Old2NewLibDoc = new Dictionary(); PendingTransitions = new XmlDocument(); FileInfo fi = new FileInfo(ofd.FileName); string dn = fi.Directory.Name; @@ -763,6 +780,15 @@ namespace DataLoader MyImpxZipFile.AddFile(fn, ""); MyImpxZipFile.Save(); File.Delete(fn); + //libdocids + xd = new XmlDocument(); + xe = xd.CreateElement("libdocs"); + xd.AppendChild(xe); + fn = PEIPath + @"\libdocs.xml"; + xd.Save(fn); + MyImpxZipFile.AddFile(fn, ""); + MyImpxZipFile.Save(); + File.Delete(fn); } } } @@ -1769,12 +1795,14 @@ namespace DataLoader } private Dictionary Old2NewItem; private Dictionary Old2NewContent; + private Dictionary Old2NewLibDoc; private XmlDocument PendingTransitions; private RODb MyRODb = null; private Folder AddFolder(Folder folder, XmlReader xr) { Old2NewItem = new Dictionary(); Old2NewContent = new Dictionary(); + Old2NewLibDoc = new Dictionary(); string title = xr.GetAttribute("title"); string name = xr.GetAttribute("name"); string shortname = xr.GetAttribute("shortname"); @@ -2634,6 +2662,15 @@ namespace DataLoader } private Document AddDocument(XmlNode xn) { + Document d; + int docid = int.Parse(xn.Attributes.GetNamedItem("docid").InnerText); + if (Old2NewLibDoc.ContainsKey(docid)) + { + docid = Old2NewLibDoc[docid]; + d = Document.Get(docid); + } + else + { string libtitle = xn.Attributes.GetNamedItem("libtitle").InnerText; byte[] doccontent = Convert.FromBase64String(xn.Attributes.GetNamedItem("doccontent").InnerText); string docascii = xn.Attributes.GetNamedItem("docascii").InnerText; @@ -2641,8 +2678,10 @@ namespace DataLoader string userid = xn.Attributes.GetNamedItem("userid").InnerText; DateTime dts = DateTime.Parse(xn.Attributes.GetNamedItem("dts").InnerText); string fileextension = xn.Attributes.GetNamedItem("fileextension").InnerText; - Document d = Document.MakeDocument(libtitle, doccontent, docascii, config, dts, userid, fileextension); + d = Document.MakeDocument(libtitle, doccontent, docascii, config, dts, userid, fileextension); d.Save(); + Old2NewLibDoc.Add(docid, d.DocID); + } return d; } #endregion diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 4d923425..e6b1c2fb 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -53,10 +53,13 @@ namespace VEPROMS PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database; if (!Directory.Exists(PEIPath)) Directory.CreateDirectory(PEIPath); - if (MyFolder.ChildFolderCount == 0) + if (_MyMode == "Import") { - Directory.Delete(PEIPath,true); - Directory.CreateDirectory(PEIPath); + if (MyFolder.ChildFolderCount == 0) + { + Directory.Delete(PEIPath, true); + Directory.CreateDirectory(PEIPath); + } } pnlExport.Dock = DockStyle.Fill; pnlImport.Dock = DockStyle.Fill; @@ -586,6 +589,19 @@ namespace VEPROMS //if (!Old2NewContent.ContainsKey(oldid)) Old2NewContent.Add(oldid, newid); } + ze = MyImpxZipFile["libdocs.xml"]; + ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently); + fn = PEIPath + @"\libdocs.xml"; + xd = new XmlDocument(); + xd.Load(fn); + nl = xd.SelectNodes("//libdoc"); + foreach (XmlNode nd in nl) + { + int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); + int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); + //if (!Old2NewContent.ContainsKey(oldid)) + Old2NewLibDoc.Add(oldid, newid); + } ze = MyImpxZipFile["transitions.xml"]; ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently); fn = PEIPath + @"\transitions.xml"; @@ -721,6 +737,7 @@ namespace VEPROMS { Old2NewItem = new Dictionary(); Old2NewContent = new Dictionary(); + Old2NewLibDoc = new Dictionary(); PendingTransitions = new XmlDocument(); FileInfo fi = new FileInfo(ofd.FileName); string dn = fi.Directory.Name; @@ -763,6 +780,15 @@ namespace VEPROMS MyImpxZipFile.AddFile(fn, ""); MyImpxZipFile.Save(); File.Delete(fn); + //libdocids + xd = new XmlDocument(); + xe = xd.CreateElement("libdocs"); + xd.AppendChild(xe); + fn = PEIPath + @"\libdocs.xml"; + xd.Save(fn); + MyImpxZipFile.AddFile(fn, ""); + MyImpxZipFile.Save(); + File.Delete(fn); } } } @@ -1769,12 +1795,14 @@ namespace VEPROMS } private Dictionary Old2NewItem; private Dictionary Old2NewContent; + private Dictionary Old2NewLibDoc; private XmlDocument PendingTransitions; private RODb MyRODb = null; private Folder AddFolder(Folder folder, XmlReader xr) { Old2NewItem = new Dictionary(); Old2NewContent = new Dictionary(); + Old2NewLibDoc = new Dictionary(); string title = xr.GetAttribute("title"); string name = xr.GetAttribute("name"); string shortname = xr.GetAttribute("shortname"); @@ -2634,15 +2662,26 @@ namespace VEPROMS } private Document AddDocument(XmlNode xn) { - string libtitle = xn.Attributes.GetNamedItem("libtitle").InnerText; - byte[] doccontent = Convert.FromBase64String(xn.Attributes.GetNamedItem("doccontent").InnerText); - string docascii = xn.Attributes.GetNamedItem("docascii").InnerText; - string config = xn.Attributes.GetNamedItem("config").InnerText; - string userid = xn.Attributes.GetNamedItem("userid").InnerText; - DateTime dts = DateTime.Parse(xn.Attributes.GetNamedItem("dts").InnerText); - string fileextension = xn.Attributes.GetNamedItem("fileextension").InnerText; - Document d = Document.MakeDocument(libtitle, doccontent, docascii, config, dts, userid, fileextension); - d.Save(); + Document d; + int docid = int.Parse(xn.Attributes.GetNamedItem("docid").InnerText); + if (Old2NewLibDoc.ContainsKey(docid)) + { + docid = Old2NewLibDoc[docid]; + d = Document.Get(docid); + } + else + { + string libtitle = xn.Attributes.GetNamedItem("libtitle").InnerText; + byte[] doccontent = Convert.FromBase64String(xn.Attributes.GetNamedItem("doccontent").InnerText); + string docascii = xn.Attributes.GetNamedItem("docascii").InnerText; + string config = xn.Attributes.GetNamedItem("config").InnerText; + string userid = xn.Attributes.GetNamedItem("userid").InnerText; + DateTime dts = DateTime.Parse(xn.Attributes.GetNamedItem("dts").InnerText); + string fileextension = xn.Attributes.GetNamedItem("fileextension").InnerText; + d = Document.MakeDocument(libtitle, doccontent, docascii, config, dts, userid, fileextension); + d.Save(); + Old2NewLibDoc.Add(docid, d.DocID); + } return d; } #endregion