From 0b0ed771bafc5df3ac42ba100516f639dc364ddc Mon Sep 17 00:00:00 2001 From: John Date: Mon, 2 May 2016 20:27:03 +0000 Subject: [PATCH] Fixed issues of not finding correct format, index of range, and duplicating existing library document - B2016-103, B2016-109 --- .../VEPROMS User Interface/dlgExportImport.cs | 1292 +++++++++-------- 1 file changed, 726 insertions(+), 566 deletions(-) diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 93672738..d1a824a4 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -77,6 +77,7 @@ namespace VEPROMS Directory.CreateDirectory(PEIPath); if (_MyMode == "Import") { + //If you try to import a procedure into an empty PROMS folder, the code was deleting the File System Folder including the import file. This happened during D.C. Cook training (12/3/2015). //if (MyFolder != null && MyFolder.ChildFolderCount == 0 ) //{ // Directory.Delete(PEIPath, true); @@ -170,18 +171,22 @@ namespace VEPROMS XmlDocument xd = new XmlDocument(); ExportFolder(xd, MyFolder, "folder"); } - private void SaveExportDataWriter() - { - XmlWriterSettings ws = new XmlWriterSettings(); - ws.Indent = true; - ws.NewLineHandling = NewLineHandling.Entitize; - ws.CheckCharacters = false; - MyWriter = XmlWriter.Create(txtExport.Text, ws); - ExportFolder(MyFolder, "folder"); - MyWriter.Close(); - } + + // appears to not be used -jsj 4-29-2016 + //private void SaveExportDataWriter() + //{ + // XmlWriterSettings ws = new XmlWriterSettings(); + // ws.Indent = true; + // ws.NewLineHandling = NewLineHandling.Entitize; + // ws.CheckCharacters = false; + // MyWriter = XmlWriter.Create(txtExport.Text, ws); + // ExportFolder(MyFolder, "folder"); + // MyWriter.Close(); + //} + private void btnDoImport_Click(object sender, EventArgs e) { + bool isImported = false; bool canceledPressed = false; btnImport.Enabled = false; this.Cursor = Cursors.WaitCursor; @@ -189,19 +194,19 @@ namespace VEPROMS btnDoImport.Enabled = false; lblImportStatus.Text = "Performing Import"; //LoadImportDataReader(); - if (MyFolder != null) + if (MyFolder != null) // import a folder - a .expx file { TurnChangeManagerOff.Execute(); LoadImportDataDocument(); MyDocVersion = null; + isImported = true; TurnChangeManagerOn.Execute(); } - if (MyDocVersion != null) + if (MyDocVersion != null) // import a procedure - a .pxml file { TurnChangeManagerOff.Execute(); XmlDocument xd = new XmlDocument(); xd.Load(txtImport.Text); - bool isImported = false; pbImportProcedure.Maximum = 1; string rofolderpath = xd.DocumentElement.Attributes.GetNamedItem("rofolderpath").InnerText; int rodbid = int.Parse(xd.DocumentElement.Attributes.GetNamedItem("rodbid").InnerText); @@ -281,10 +286,9 @@ namespace VEPROMS // - also found that the message about overwriting or making a copy wasn't appearing because we where not converting the import procedure number // - our standard unicode dash (\u8209?) before conparing the existing and imported // - also found the Overrite and make a copy of messages looked too similar - fixed that as well. - //hyphenImpNum = hyphenImpNum == null ? "" : hyphenImpNum.Replace("\u8030?", "-"); -did not find any reason to have this \u8030? - note retest sourcesafe doc for B2016-084 without this logic and it was fine + //hyphenImpNum = hyphenImpNum == null ? "" : hyphenImpNum.Replace("\u8030?", "-"); -did not find any reason to have this \u8030? - note retested sourcesafe doc for B2016-084 without this logic and it was fine hyphenImpNum = hyphenImpNum == null ? "" : hyphenImpNum.Replace(@"\u8209?", "-").Replace("\u2011", "-"); - //if (pi.ItemID == int.Parse(xd.SelectSingleNode("procedure/@itemid").InnerText) || hyphenNum == hyphenImpNum) if (hyphenNum == hyphenImpNum) { string msg = string.Format("The procedure you are importing{0}already exists in this procedure set.\n\nDo you want to OVERWRITE the existing procedure?", !hyphenImpNum.Equals("")?string.Format(" ({0}) ",hyphenImpNum):" "); @@ -335,7 +339,13 @@ namespace VEPROMS } this.Cursor = Cursors.Default; btnCloseImport.Enabled = true; - if (canceledPressed) btnCloseImport.PerformClick(); + if (isImported) + MessageBox.Show(string.Format("Finished Importing:\n\n{0}",txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\")+1)),"Import",MessageBoxButtons.OK,MessageBoxIcon.Information); + if (canceledPressed) + { + MessageBox.Show(string.Format("Canceling the import of:\n\n{0}",txtImport.Text.Substring(txtImport.Text.LastIndexOf("\\")+1)),"Import",MessageBoxButtons.OK,MessageBoxIcon.Information); + btnCloseImport.PerformClick(); + } } private void ImportProcedureNew(XmlDocument xd) { @@ -536,6 +546,7 @@ namespace VEPROMS } } + // note that his is only used when importing a folder private void LoadFormats(XmlDocument xd) { oldFormat = new Dictionary(); @@ -551,27 +562,34 @@ namespace VEPROMS foreach (FormatInfo fi in fil) newFormat.Add(fi.Name, fi.FormatID); } - Dictionary dicParentItem = null; - private void UpdateParentItem(int depth, ItemInfo ii) - { - if (dicParentItem == null) dicParentItem = new Dictionary(); - if (!dicParentItem.ContainsKey(depth)) dicParentItem.Add(depth, null); - dicParentItem[depth] = ii; - } - Dictionary dicPreviousItem = null; - private void UpdatePreviousItem(int depth, ItemInfo ii) - { - if (dicPreviousItem == null) dicPreviousItem = new Dictionary(); - if (!dicPreviousItem.ContainsKey(depth)) dicPreviousItem.Add(depth, null); - dicPreviousItem[depth] = ii; - } + + //jsj 4-29-2016 appears to not be used + //Dictionary dicParentItem = null; + //private void UpdateParentItem(int depth, ItemInfo ii) + //{ + // if (dicParentItem == null) dicParentItem = new Dictionary(); + // if (!dicParentItem.ContainsKey(depth)) dicParentItem.Add(depth, null); + // dicParentItem[depth] = ii; + //} + + //jsj 4-29-2016 appears to not be used + //Dictionary dicPreviousItem = null; + //private void UpdatePreviousItem(int depth, ItemInfo ii) + //{ + // if (dicPreviousItem == null) dicPreviousItem = new Dictionary(); + // if (!dicPreviousItem.ContainsKey(depth)) dicPreviousItem.Add(depth, null); + // dicPreviousItem[depth] = ii; + //} + Dictionary dicItemDepth = null; - private void UpdateItemDepth(int depth, int id) - { - if (dicItemDepth == null) dicItemDepth = new Dictionary(); - if (!dicItemDepth.ContainsKey(depth)) dicItemDepth.Add(depth, 0); - dicItemDepth[depth] = id; - } + + // jsj 4-29-2016 appears to not be used + //private void UpdateItemDepth(int depth, int id) + //{ + // if (dicItemDepth == null) dicItemDepth = new Dictionary(); + // if (!dicItemDepth.ContainsKey(depth)) dicItemDepth.Add(depth, 0); + // dicItemDepth[depth] = id; + //} // jsj 2016Feb17 - this appears to not be used //private void LoadImportDataReader() //{ @@ -762,7 +780,13 @@ namespace VEPROMS // StoreItemContentIDs(); // ResolveExternalTransitions(folder); //} - private void SaveTransitionAndItemContentIDs() + + // This is called only when we are importing an entire folder. + // if there is a .impx file (a zip file generated from the last folder export file and based on location -folder name- of the export file you are importing), then it updates it with new values, + // else it will create a .impx file, and saves the id information listed below. + // This will create and save the ItemIDs (old and new), ContentIDs (old andnew), library document IDs (old and new), and pending transitions each in their own xml file + // the xml files are then added (or replaced) in the .impx file. + private void SaveTransitionAndItemContentIDs() { XmlDocument xd = new XmlDocument(); XmlElement xe = xd.CreateElement("items"); @@ -820,77 +844,82 @@ namespace VEPROMS MyImpxZipFile.Save(); File.Delete(fn); } - private void StoreItemContentIDs() - { - XmlDocument xd = new XmlDocument(); - string fn = PEIPath + @"\ExternalTransitions.xml"; - xd.Load(fn); - XmlElement xe = (XmlElement)xd.SelectSingleNode("externaltransitions/oldtonewitem"); - foreach (int key in Old2NewItem.Keys) - { - XmlElement xee = xd.CreateElement("item"); - XmlAttribute xa = AddAttribute(xd, "old", key.ToString()); - xee.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "new", Old2NewItem[key].ToString()); - xee.Attributes.SetNamedItem(xa); - xe.AppendChild(xee); - } - xd.Save(fn); - xe = (XmlElement)xd.SelectSingleNode("externaltransitions/oldtonewcontent"); - foreach (int key in Old2NewContent.Keys) - { - XmlElement xee = xd.CreateElement("content"); - XmlAttribute xa = AddAttribute(xd, "old", key.ToString()); - xee.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "new", Old2NewContent[key].ToString()); - xee.Attributes.SetNamedItem(xa); - xe.AppendChild(xee); - } - xd.Save(fn); - } - private void ResolveExternalTransitions(Folder folder) - { - XmlDocument xd = new XmlDocument(); - string fn = PEIPath + @"\ExternalTransitions.xml"; - xd.Load(fn); - AddStoredItemContentIDs(xd); - XmlNodeList nl = xd.SelectNodes("//transition[@folder!='']"); - foreach (XmlNode nd in nl) - { - int transitionid = int.Parse(nd.Attributes.GetNamedItem("transitionid").InnerText); - int fromid = int.Parse(nd.Attributes.GetNamedItem("fromid").InnerText); - int toid = int.Parse(nd.Attributes.GetNamedItem("toid").InnerText); - int rangeid = int.Parse(nd.Attributes.GetNamedItem("rangeid").InnerText); - if (Old2NewContent.ContainsKey(fromid) && Old2NewItem.ContainsKey(toid) && Old2NewItem.ContainsKey(rangeid)) - { - int isrange = int.Parse(nd.Attributes.GetNamedItem("isrange").InnerText); - int trantype = int.Parse(nd.Attributes.GetNamedItem("trantype").InnerText); - string config = nd.Attributes.GetNamedItem("config").InnerText; - string userid = nd.Attributes.GetNamedItem("userid").InnerText; - DateTime dts = DateTime.Parse(nd.Attributes.GetNamedItem("dts").InnerText); - string lookfor; - if (isrange == 0) - lookfor = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - else - lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - fromid = Old2NewContent[fromid]; - toid = Old2NewItem[toid]; - rangeid = Old2NewItem[rangeid]; - Content cc = Content.Get(fromid); - Transition tt = Transition.MakeTransition(cc, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); - transitionid = tt.TransitionID; - string replacewith; - if (isrange == 0) - replacewith = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - else - replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - cc.Text = cc.Text.Replace(lookfor, replacewith); - cc.Save(); - nd.Attributes.GetNamedItem("folder").InnerText = ""; - } - } - xd.Save(fn); - } + // appears to not be used - jsj 4-28-2016 + //private void StoreItemContentIDs() + //{ + // XmlDocument xd = new XmlDocument(); + // string fn = PEIPath + @"\ExternalTransitions.xml"; + // xd.Load(fn); + // XmlElement xe = (XmlElement)xd.SelectSingleNode("externaltransitions/oldtonewitem"); + // foreach (int key in Old2NewItem.Keys) + // { + // XmlElement xee = xd.CreateElement("item"); + // XmlAttribute xa = AddAttribute(xd, "old", key.ToString()); + // xee.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "new", Old2NewItem[key].ToString()); + // xee.Attributes.SetNamedItem(xa); + // xe.AppendChild(xee); + // } + // xd.Save(fn); + // xe = (XmlElement)xd.SelectSingleNode("externaltransitions/oldtonewcontent"); + // foreach (int key in Old2NewContent.Keys) + // { + // XmlElement xee = xd.CreateElement("content"); + // XmlAttribute xa = AddAttribute(xd, "old", key.ToString()); + // xee.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "new", Old2NewContent[key].ToString()); + // xee.Attributes.SetNamedItem(xa); + // xe.AppendChild(xee); + // } + // xd.Save(fn); + //} + //private void ResolveExternalTransitions(Folder folder) + //{ + // XmlDocument xd = new XmlDocument(); + // string fn = PEIPath + @"\ExternalTransitions.xml"; + // xd.Load(fn); + // AddStoredItemContentIDs(xd); + // XmlNodeList nl = xd.SelectNodes("//transition[@folder!='']"); + // foreach (XmlNode nd in nl) + // { + // int transitionid = int.Parse(nd.Attributes.GetNamedItem("transitionid").InnerText); + // int fromid = int.Parse(nd.Attributes.GetNamedItem("fromid").InnerText); + // int toid = int.Parse(nd.Attributes.GetNamedItem("toid").InnerText); + // int rangeid = int.Parse(nd.Attributes.GetNamedItem("rangeid").InnerText); + // if (Old2NewContent.ContainsKey(fromid) && Old2NewItem.ContainsKey(toid) && Old2NewItem.ContainsKey(rangeid)) + // { + // int isrange = int.Parse(nd.Attributes.GetNamedItem("isrange").InnerText); + // int trantype = int.Parse(nd.Attributes.GetNamedItem("trantype").InnerText); + // string config = nd.Attributes.GetNamedItem("config").InnerText; + // string userid = nd.Attributes.GetNamedItem("userid").InnerText; + // DateTime dts = DateTime.Parse(nd.Attributes.GetNamedItem("dts").InnerText); + // string lookfor; + // if (isrange == 0) + // lookfor = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); + // else + // lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); + // fromid = Old2NewContent[fromid]; + // toid = Old2NewItem[toid]; + // rangeid = Old2NewItem[rangeid]; + // Content cc = Content.Get(fromid); + // Transition tt = Transition.MakeTransition(cc, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); + // transitionid = tt.TransitionID; + // string replacewith; + // if (isrange == 0) + // replacewith = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); + // else + // replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); + // cc.Text = cc.Text.Replace(lookfor, replacewith); + // cc.Save(); + // nd.Attributes.GetNamedItem("folder").InnerText = ""; + // } + // } + // xd.Save(fn); + //} + + // This is called only when we are importing an entire folder and there is a .impx file (a zip file) + // the name of the .impx file is based on the folder name containing the export file being imported + // This will read in the saved ItemIDs (old and new), ContentIDs (old andnew), library document IDs (old and new), and pending transitions private void ReadTransitionAndItemContentIDs() { ZipEntry ze = MyImpxZipFile["items.xml"]; @@ -941,128 +970,134 @@ namespace VEPROMS PendingTransitions.Load(fn); File.Delete(fn); } - private void AddStoredItemContentIDs(XmlDocument xd) - { - XmlNodeList nl = xd.SelectNodes("//item"); - foreach (XmlNode nd in nl) - { - int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); - int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); - if (!Old2NewItem.ContainsKey(oldid)) - Old2NewItem.Add(oldid, newid); - } - nl = xd.SelectNodes("//content"); - 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)) - Old2NewContent.Add(oldid, newid); - } - } - private void FixImportDataTransitions() - { - XmlDocument xd = new XmlDocument(); - string fn = PEIPath + @"\ExternalTransitions.xml"; - if (!File.Exists(fn)) - { - XmlElement xe = xd.CreateElement("externaltransitions"); - XmlElement xee = xd.CreateElement("oldtonewitem"); - xe.AppendChild(xee); - xee = xd.CreateElement("oldtonewcontent"); - xe.AppendChild(xee); - xee = xd.CreateElement("transitions"); - xe.AppendChild(xee); - xd.AppendChild(xe); - xd.Save(fn); - } - else - { - xd.Load(fn); - } - FileStream fs = File.OpenRead(txtImport.Text); - XmlReaderSettings rs = new XmlReaderSettings(); - rs.CheckCharacters = false; - XmlReader xr = XmlReader.Create(fs, rs); - while (xr.Read()) - { - if (xr.IsStartElement()) - { - switch (xr.Name) - { - case "transition": - AddTransitions(xr); - break; - case "externaltransition": - { - AddExternalTransition(xr, xd); - break; - } - default: - break; - } - } - } - fs.Close(); - xd.Save(fn); - } - private Dictionary> MyCounts = null; - private Dictionary MySubCounts = null; - private void GetImportDataCounts() - { - int pCount = 0; - int sCount = 0; - int tCount = 0; - MyCounts = new Dictionary>(); - MySubCounts = new Dictionary(); - FileStream fs = File.OpenRead(txtImport.Text); - XmlReaderSettings rs = new XmlReaderSettings(); - rs.CheckCharacters = false; - XmlReader xr = XmlReader.Create(fs, rs); - while (xr.Read()) - { - if (xr.IsStartElement()) - { - switch (xr.Name) - { - case "procedure": - { - if (pCount > 0) - { - MySubCounts.Add(sCount, tCount); - MyCounts.Add(pCount, MySubCounts); - sCount = 0; - tCount = 0; - MySubCounts = new Dictionary(); - } - pCount++; - break; - } - case "section": - { - if (sCount > 0) - { - MySubCounts.Add(sCount, tCount); - tCount = 0; - } - sCount++; - break; - } - case "step": - { - if (xr.Depth == 8) - tCount++; - break; - } - default: - break; - } - } - } - MySubCounts.Add(sCount, tCount); - MyCounts.Add(pCount, MySubCounts); - fs.Close(); - } + // appears not to be used - jsj 4-28-2016 + //private void AddStoredItemContentIDs(XmlDocument xd) + //{ + // XmlNodeList nl = xd.SelectNodes("//item"); + // foreach (XmlNode nd in nl) + // { + // int oldid = int.Parse(nd.Attributes.GetNamedItem("old").InnerText); + // int newid = int.Parse(nd.Attributes.GetNamedItem("new").InnerText); + // if (!Old2NewItem.ContainsKey(oldid)) + // Old2NewItem.Add(oldid, newid); + // } + // nl = xd.SelectNodes("//content"); + // 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)) + // Old2NewContent.Add(oldid, newid); + // } + //} + + // appears not to be used - jsj 4-28-2016 + //private void FixImportDataTransitions() + //{ + // XmlDocument xd = new XmlDocument(); + // string fn = PEIPath + @"\ExternalTransitions.xml"; + // if (!File.Exists(fn)) + // { + // XmlElement xe = xd.CreateElement("externaltransitions"); + // XmlElement xee = xd.CreateElement("oldtonewitem"); + // xe.AppendChild(xee); + // xee = xd.CreateElement("oldtonewcontent"); + // xe.AppendChild(xee); + // xee = xd.CreateElement("transitions"); + // xe.AppendChild(xee); + // xd.AppendChild(xe); + // xd.Save(fn); + // } + // else + // { + // xd.Load(fn); + // } + // FileStream fs = File.OpenRead(txtImport.Text); + // XmlReaderSettings rs = new XmlReaderSettings(); + // rs.CheckCharacters = false; + // XmlReader xr = XmlReader.Create(fs, rs); + // while (xr.Read()) + // { + // if (xr.IsStartElement()) + // { + // switch (xr.Name) + // { + // case "transition": + // AddTransitions(xr); + // break; + // case "externaltransition": + // { + // AddExternalTransition(xr, xd); + // break; + // } + // default: + // break; + // } + // } + // } + // fs.Close(); + // xd.Save(fn); + //} + + // jsj 4-29-2016 appears to not be used + //private Dictionary> MyCounts = null; + //private Dictionary MySubCounts = null; + //private void GetImportDataCounts() + //{ + // int pCount = 0; + // int sCount = 0; + // int tCount = 0; + // MyCounts = new Dictionary>(); + // MySubCounts = new Dictionary(); + // FileStream fs = File.OpenRead(txtImport.Text); + // XmlReaderSettings rs = new XmlReaderSettings(); + // rs.CheckCharacters = false; + // XmlReader xr = XmlReader.Create(fs, rs); + // while (xr.Read()) + // { + // if (xr.IsStartElement()) + // { + // switch (xr.Name) + // { + // case "procedure": + // { + // if (pCount > 0) + // { + // MySubCounts.Add(sCount, tCount); + // MyCounts.Add(pCount, MySubCounts); + // sCount = 0; + // tCount = 0; + // MySubCounts = new Dictionary(); + // } + // pCount++; + // break; + // } + // case "section": + // { + // if (sCount > 0) + // { + // MySubCounts.Add(sCount, tCount); + // tCount = 0; + // } + // sCount++; + // break; + // } + // case "step": + // { + // if (xr.Depth == 8) + // tCount++; + // break; + // } + // default: + // break; + // } + // } + // } + // MySubCounts.Add(sCount, tCount); + // MyCounts.Add(pCount, MySubCounts); + // fs.Close(); + //} + private void btnImport_Click(object sender, EventArgs e) { if (MyFolder != null) @@ -1167,6 +1202,7 @@ namespace VEPROMS */ lblExportStatus.Text = "Exporting Folder..."; Application.DoEvents(); + string formatFileName = (fi.MyFormat != null)? fi.MyFormat.Name:""; FromFolderName = fi.Name; XmlElement xe = xd.CreateElement(nodename); xe.Attributes.SetNamedItem(AddAttribute(xd, "folderid", fi.FolderID.ToString())); @@ -1180,6 +1216,7 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xd, "config", fi.Config)); xe.Attributes.SetNamedItem(AddAttribute(xd, "dts", fi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xd, "usrid", fi.UsrID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xd, "formatfilename",formatFileName)); xd.AppendChild(xe); ExportAnnotationTypes(xe, "annotationtypes"); ExportFormats(xe, "formats"); @@ -1227,42 +1264,46 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ati.UserID.ToString())); xn.AppendChild(xe); } - private void ExportFolder(FolderInfo fi, string nodename) - { - /* - FolderID - ParentID - DBID - Name - Title - ShortName - FormatID - ManualOrder - Config - DTS - UsrID - */ - FromFolderName = fi.Name; - MyWriter.WriteStartDocument(); - MyWriter.WriteStartElement(nodename); - MyWriter.WriteAttributeString("folderid", fi.FolderID.ToString()); - MyWriter.WriteAttributeString("parentid", fi.ParentID.ToString()); - MyWriter.WriteAttributeString("dbid", fi.DBID.ToString()); - MyWriter.WriteAttributeString("name", fi.Name); - MyWriter.WriteAttributeString("title", fi.Title); - MyWriter.WriteAttributeString("shortname", fi.ShortName); - MyWriter.WriteAttributeString("formatid", fi.FormatID.ToString()); - MyWriter.WriteAttributeString("manualorder", fi.ManualOrder.ToString()); - MyWriter.WriteAttributeString("config", fi.Config); - MyWriter.WriteAttributeString("dts", fi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); - MyWriter.WriteAttributeString("usrid", fi.UsrID.ToString()); + + // jsj 4-29-2016 appears to not be used + //private void ExportFolder(FolderInfo fi, string nodename) + //{ + // /* + // FolderID + // ParentID + // DBID + // Name + // Title + // ShortName + // FormatID + // ManualOrder + // Config + // DTS + // UsrID + // */ + // string formatFileName = (fi.MyFormat != null) ? fi.MyFormat.Name : ""; + // FromFolderName = fi.Name; + // MyWriter.WriteStartDocument(); + // MyWriter.WriteStartElement(nodename); + // MyWriter.WriteAttributeString("folderid", fi.FolderID.ToString()); + // MyWriter.WriteAttributeString("parentid", fi.ParentID.ToString()); + // MyWriter.WriteAttributeString("dbid", fi.DBID.ToString()); + // MyWriter.WriteAttributeString("name", fi.Name); + // MyWriter.WriteAttributeString("title", fi.Title); + // MyWriter.WriteAttributeString("shortname", fi.ShortName); + // MyWriter.WriteAttributeString("formatid", fi.FormatID.ToString()); + // MyWriter.WriteAttributeString("manualorder", fi.ManualOrder.ToString()); + // MyWriter.WriteAttributeString("config", fi.Config); + // MyWriter.WriteAttributeString("dts", fi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); + // MyWriter.WriteAttributeString("usrid", fi.UsrID.ToString()); + // MyWriter.WriteAttributeString("formatfilename", formatFileName); - if (fi.FolderDocVersionCount > 0) - foreach (DocVersionInfo dvi in fi.FolderDocVersions) - ExportDocVersion(dvi, "docversion"); - MyWriter.WriteEndElement(); - MyWriter.WriteEndDocument(); - } + // if (fi.FolderDocVersionCount > 0) + // foreach (DocVersionInfo dvi in fi.FolderDocVersions) + // ExportDocVersion(dvi, "docversion"); + // MyWriter.WriteEndElement(); + // MyWriter.WriteEndDocument(); + //} private void ExportDocVersion(XmlElement xn, DocVersionInfo dvi, string nodename) { /* @@ -1279,6 +1320,7 @@ namespace VEPROMS */ lblExportStatus.Text = "Exporting DocVersion..."; Application.DoEvents(); + string formatFileName = (dvi.MyFormat != null) ? dvi.MyFormat.Name : ""; XmlElement xe = xn.OwnerDocument.CreateElement(nodename); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "versionid", dvi.VersionID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "folderid", dvi.FolderID.ToString())); @@ -1290,6 +1332,7 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", dvi.Config)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", dvi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", dvi.UserID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatfilename", formatFileName)); xn.AppendChild(xe); if (dvi.DocVersionAssociationCount > 0) foreach (AssociationInfo ai in dvi.DocVersionAssociations) @@ -1334,6 +1377,7 @@ namespace VEPROMS DTS UserID */ + string formatFileName = (dvi.MyFormat != null) ? dvi.MyFormat.Name : ""; MyWriter.WriteStartElement(nodename); MyWriter.WriteAttributeString("versionid", dvi.VersionID.ToString()); MyWriter.WriteAttributeString("folderid", dvi.FolderID.ToString()); @@ -1345,6 +1389,7 @@ namespace VEPROMS MyWriter.WriteAttributeString("config", dvi.Config); MyWriter.WriteAttributeString("dts", dvi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); MyWriter.WriteAttributeString("userid", dvi.UserID.ToString()); + MyWriter.WriteAttributeString("formatfilename", formatFileName); if (dvi.DocVersionAssociationCount > 0) foreach (AssociationInfo ai in dvi.DocVersionAssociations) ExportAssociation(ai, "association"); @@ -1687,6 +1732,7 @@ namespace VEPROMS XmlElement xe = xn.OwnerDocument.CreateElement(nodename); // strip the link information if we are convertingthe RO and Transitions to text string ciText = (_ConvertROsAndTransitionsToText)?ItemInfo.StripLinks(ci.Text):ci.Text; + string formatFileName = (ci.MyFormat != null) ? ci.MyFormat.Name : ""; xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "contentid", ci.ContentID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "number", ci.Number)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "text", ciText)); @@ -1695,6 +1741,7 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", ci.Config)); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ci.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ci.UserID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatfilename", formatFileName)); //content audits ExportContentAudits(xe, ci); xn.AppendChild(xe); @@ -1756,6 +1803,7 @@ namespace VEPROMS */ // strip the link information if we are convertinga the ROs and Transitions to text string ciText = (_ConvertROsAndTransitionsToText) ? ItemInfo.StripLinks(ci.Text) : ci.Text; + string formatFileName = (ci.MyFormat != null) ? ci.MyFormat.Name : ""; MyWriter.WriteStartElement(nodename); MyWriter.WriteAttributeString("contentid", ci.ContentID.ToString()); MyWriter.WriteAttributeString("number", ci.Number); @@ -1765,6 +1813,7 @@ namespace VEPROMS MyWriter.WriteAttributeString("config", ci.Config); MyWriter.WriteAttributeString("dts", ci.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")); MyWriter.WriteAttributeString("userid", ci.UserID.ToString()); + MyWriter.WriteAttributeString("formatfilename", formatFileName); if (ci.ContentTransitionCount > 0) foreach (TransitionInfo ti in ci.ContentTransitions) ExportTransition(ti, "transition"); @@ -2276,61 +2325,66 @@ namespace VEPROMS } #endregion #region Import for Merge - private void AddExternalTransition(XmlReader xr, XmlDocument xd) - { - XmlElement xe = xd.CreateElement("transition"); - XmlAttribute xa = AddAttribute(xd, "folder", xr.GetAttribute("folder")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "transitionid", xr.GetAttribute("transitionid")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "fromid", xr.GetAttribute("fromid")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "toid", xr.GetAttribute("toid")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "rangeid", xr.GetAttribute("rangeid")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "isrange", xr.GetAttribute("isrange")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "trantype", xr.GetAttribute("trantype")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "config", xr.GetAttribute("config")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "userid", xr.GetAttribute("userid")); - xe.Attributes.SetNamedItem(xa); - xa = AddAttribute(xd, "dts", xr.GetAttribute("dts")); - xe.Attributes.SetNamedItem(xa); - xd.SelectSingleNode("externaltransitions/transitions").AppendChild(xe); - } - private void AddTransitions(XmlReader xr) - { - int transitionid = int.Parse(xr.GetAttribute("transitionid")); - int fromid = int.Parse(xr.GetAttribute("fromid")); - int toid = int.Parse(xr.GetAttribute("toid")); - int rangeid = int.Parse(xr.GetAttribute("rangeid")); - int isrange = int.Parse(xr.GetAttribute("isrange")); - int trantype = int.Parse(xr.GetAttribute("trantype")); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - string lookfor; - if (isrange == 0) - lookfor = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - else - lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - fromid = Old2NewContent[fromid]; - toid = Old2NewItem[toid]; - rangeid = Old2NewItem[rangeid]; - Content cc = Content.Get(fromid); - Transition tt = Transition.MakeTransition(cc, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); - transitionid = tt.TransitionID; - string replacewith; - if (isrange == 0) - replacewith = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); - else - replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); - cc.Text = cc.Text.Replace(lookfor, replacewith); - cc.Save(); - } + + // jsj 4-29-2016 appears to not be used + //private void AddExternalTransition(XmlReader xr, XmlDocument xd) + //{ + // XmlElement xe = xd.CreateElement("transition"); + // XmlAttribute xa = AddAttribute(xd, "folder", xr.GetAttribute("folder")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "transitionid", xr.GetAttribute("transitionid")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "fromid", xr.GetAttribute("fromid")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "toid", xr.GetAttribute("toid")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "rangeid", xr.GetAttribute("rangeid")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "isrange", xr.GetAttribute("isrange")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "trantype", xr.GetAttribute("trantype")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "config", xr.GetAttribute("config")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "userid", xr.GetAttribute("userid")); + // xe.Attributes.SetNamedItem(xa); + // xa = AddAttribute(xd, "dts", xr.GetAttribute("dts")); + // xe.Attributes.SetNamedItem(xa); + // xd.SelectSingleNode("externaltransitions/transitions").AppendChild(xe); + //} + + // jsj 4-29-2016 appears to not be used + //private void AddTransitions(XmlReader xr) + //{ + // int transitionid = int.Parse(xr.GetAttribute("transitionid")); + // int fromid = int.Parse(xr.GetAttribute("fromid")); + // int toid = int.Parse(xr.GetAttribute("toid")); + // int rangeid = int.Parse(xr.GetAttribute("rangeid")); + // int isrange = int.Parse(xr.GetAttribute("isrange")); + // int trantype = int.Parse(xr.GetAttribute("trantype")); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // string lookfor; + // if (isrange == 0) + // lookfor = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); + // else + // lookfor = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); + // fromid = Old2NewContent[fromid]; + // toid = Old2NewItem[toid]; + // rangeid = Old2NewItem[rangeid]; + // Content cc = Content.Get(fromid); + // Transition tt = Transition.MakeTransition(cc, Item.Get(toid), Item.Get(rangeid), isrange, trantype, config, dts, userid); + // transitionid = tt.TransitionID; + // string replacewith; + // if (isrange == 0) + // replacewith = string.Format("#Link:Transition:{0} {1} {2}", trantype, transitionid, toid); + // else + // replacewith = string.Format("#Link:TransitionRange:{0} {1} {2} {3}", trantype, transitionid, toid, rangeid); + // cc.Text = cc.Text.Replace(lookfor, replacewith); + // cc.Save(); + //} + private void AddTransitions(Content content, XmlNode xn) { /* @@ -2514,27 +2568,32 @@ 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"); - string usrid = xr.GetAttribute("usrid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - string formatid = xr.GetAttribute("formatid"); - Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid)); - folder = Folder.MakeFolder(folder, folder.MyConnection, name, title, shortname, format, null, dts, usrid); - //f.Save(); - return folder; - } + + // jsj 4-29-2016 appears to not be used + //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"); + // string usrid = xr.GetAttribute("usrid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // string formatid = xr.GetAttribute("formatid"); + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid),formatfilename); + // folder = Folder.MakeFolder(folder, folder.MyConnection, name, title, shortname, format, null, dts, usrid); + // //f.Save(); + // return folder; + //} + private Folder AddFolder(Folder p, XmlDocument xd) { lblImportStatus.Text = "Creating Folder..."; @@ -2545,17 +2604,31 @@ namespace VEPROMS string usrid = xd.DocumentElement.Attributes.GetNamedItem("usrid").InnerText; DateTime dts = DateTime.Parse(xd.DocumentElement.Attributes.GetNamedItem("dts").InnerText); string formatid = xd.DocumentElement.Attributes.GetNamedItem("formatid").InnerText; - Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid)); + XmlNode fnNode = xd.DocumentElement.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; + Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid),formatfilename); if (Folder.GetByParentID_Name(p.FolderID, name) != null) return null; Folder f = Folder.MakeFolder(p, p.MyConnection, name, title, shortname, format, null, dts, usrid); return f; } - private Format OldToNewFormat(int formatID) + private Format OldToNewFormat(int formatID, string formatFileName) { - string formatName = oldFormat[formatID]; - formatID = newFormat[formatName]; - return Format.Get(formatID); + try + { + string formatName = formatFileName; // B2016-103, new export files include the format filename use that if it exists + if (formatFileName == string.Empty) + { + if (formatID >= oldFormat.Count) return null; // formatID not found, use default file name + formatName = oldFormat[formatID]; // for backwards compatibility with older export files + } + formatID = newFormat[formatName]; + return Format.Get(formatID); + } + catch + { + return null; // format not found return null to use default format + } } private DocVersion AddDocVersion(Folder f, XmlReader xr) { @@ -2565,7 +2638,8 @@ namespace VEPROMS string userid = xr.GetAttribute("userid"); DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); string formatid = xr.GetAttribute("formatid"); - Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid)); + string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid),formatfilename); DocVersion dv = DocVersion.MakeDocVersion(f, versiontype, name, null, null, format, config, dts, userid); return dv; } @@ -2590,7 +2664,9 @@ namespace VEPROMS string userid = xe.Attributes.GetNamedItem("userid").InnerText; DateTime dts = DateTime.Parse(xe.Attributes.GetNamedItem("dts").InnerText); string formatid = xe.Attributes.GetNamedItem("formatid").InnerText; - Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid)); + XmlNode fnNode = xe.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; + Format format = formatid == string.Empty ? null : OldToNewFormat(int.Parse(formatid),formatfilename); DocVersion dv = DocVersion.MakeDocVersion(f, versiontype, name, null, null, format, config, dts, userid); XmlNode xassoc = xe.SelectSingleNode("association"); if (xassoc != null) @@ -2604,27 +2680,32 @@ namespace VEPROMS } return DocVersionInfo.Get(dv.VersionID); } - private Dictionary GetROFstData(XmlReader xr) - { - Dictionary rv = new Dictionary(); - rv.Add("rolookup", xr.GetAttribute("rolookup")); - rv.Add("config", xr.GetAttribute("config")); - rv.Add("userid", xr.GetAttribute("userid")); - rv.Add("dts", xr.GetAttribute("dts")); - return rv; - } - private ROFst AddROFst(Dictionary dic) - { - byte[] rolookup = Convert.FromBase64String(dic["rolookup"]); - string config = dic["config"]; - string userid = dic["userid"]; - DateTime dts = DateTime.Parse(dic["dts"]); - ROFst rv = null; - rv = ROFst.GetByRODbID_DTS(MyRODb.RODbID, dts); //MyRODb.DTS); - if (rv == null) - rv = ROFst.MakeROFst(MyRODb, rolookup, config, dts, userid); - return rv; - } + + // jsj 4-29-2016 appears to not be used + //private Dictionary GetROFstData(XmlReader xr) + //{ + // Dictionary rv = new Dictionary(); + // rv.Add("rolookup", xr.GetAttribute("rolookup")); + // rv.Add("config", xr.GetAttribute("config")); + // rv.Add("userid", xr.GetAttribute("userid")); + // rv.Add("dts", xr.GetAttribute("dts")); + // return rv; + //} + + // jsj 4-29-2016 appears to not be used + //private ROFst AddROFst(Dictionary dic) + //{ + // byte[] rolookup = Convert.FromBase64String(dic["rolookup"]); + // string config = dic["config"]; + // string userid = dic["userid"]; + // DateTime dts = DateTime.Parse(dic["dts"]); + // ROFst rv = null; + // rv = ROFst.GetByRODbID_DTS(MyRODb.RODbID, dts); //MyRODb.DTS); + // if (rv == null) + // rv = ROFst.MakeROFst(MyRODb, rolookup, config, dts, userid); + // return rv; + //} + private ROFst AddROFst(XmlNode xrofst) { lblImportStatus.Text = "Creating ROFst..."; @@ -2669,22 +2750,25 @@ namespace VEPROMS Figure fig = Figure.MakeFigure(rofst, roimage, config, dts, userid); } } - private RODb AddRODb(XmlReader xr) - { - oldRODbID = int.Parse(xr.GetAttribute("rodbid")); - string roname = xr.GetAttribute("roname"); - string folderpath = xr.GetAttribute("folderpath"); - string dbconnectionstring = xr.GetAttribute("dbconnectionstring"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - RODb rv = null; - rv = RODb.GetByFolderPath(folderpath); - if (rv == null) - rv = RODb.MakeRODb(roname, folderpath, dbconnectionstring, config, dts, userid); - newRODbID = rv.RODbID; - return rv; - } + + // jsj 4-29-2016 appears to not be used + //private RODb AddRODb(XmlReader xr) + //{ + // oldRODbID = int.Parse(xr.GetAttribute("rodbid")); + // string roname = xr.GetAttribute("roname"); + // string folderpath = xr.GetAttribute("folderpath"); + // string dbconnectionstring = xr.GetAttribute("dbconnectionstring"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // RODb rv = null; + // rv = RODb.GetByFolderPath(folderpath); + // if (rv == null) + // rv = RODb.MakeRODb(roname, folderpath, dbconnectionstring, config, dts, userid); + // newRODbID = rv.RODbID; + // return rv; + //} + private RODb AddRODb(XmlNode xrodb) { lblImportStatus.Text = "Creating RODb..."; @@ -2703,34 +2787,39 @@ namespace VEPROMS newRODbID = rv.RODbID; return rv; } - private int GetProcedureData(XmlReader xr) - { - return int.Parse(xr.GetAttribute("itemid")); - } - private ItemInfo AddProcedure(XmlReader xr, DocVersion dv, ItemInfo procInfo, int oldid) - { - DocVersionInfo dvInfo = DocVersionInfo.Get(dv.VersionID); - string number = xr.GetAttribute("number"); - string text = xr.GetAttribute("text"); - int proctype = int.Parse(xr.GetAttribute("type")); - string formatid = xr.GetAttribute("formatid"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Procedure p = Procedure.MakeProcedure(dvInfo, procInfo, number, text, proctype); - p.DTS = dts; - p.UserID = userid; - if (formatid != string.Empty) - p.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - p.MyContent.Config = config; - p.MyContent.DTS = dts; - p.MyContent.UserID = userid; - p.Save(); - Old2NewItem.Add(oldid, p.ItemID); - Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), p.MyContent.ContentID); - procInfo = ProcedureInfo.Get(p.ItemID); - return procInfo; - } + + // jsj 4-29-2016 appears to not be used + //private int GetProcedureData(XmlReader xr) + //{ + // return int.Parse(xr.GetAttribute("itemid")); + //} + + // jsj 4-29-2016 appears to not be used + //private ItemInfo AddProcedure(XmlReader xr, DocVersion dv, ItemInfo procInfo, int oldid) + //{ + // DocVersionInfo dvInfo = DocVersionInfo.Get(dv.VersionID); + // string number = xr.GetAttribute("number"); + // string text = xr.GetAttribute("text"); + // int proctype = int.Parse(xr.GetAttribute("type")); + // string formatid = xr.GetAttribute("formatid"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Procedure p = Procedure.MakeProcedure(dvInfo, procInfo, number, text, proctype); + // p.DTS = dts; + // p.UserID = userid; + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // if (formatid != string.Empty) + // p.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid),formatfilename); + // p.MyContent.Config = config; + // p.MyContent.DTS = dts; + // p.MyContent.UserID = userid; + // p.Save(); + // Old2NewItem.Add(oldid, p.ItemID); + // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), p.MyContent.ContentID); + // procInfo = ProcedureInfo.Get(p.ItemID); + // return procInfo; + //} private ProcedureInfo AddProcedure(XmlNode xn, DocVersionInfo dvInfo, ProcedureInfo procInfo) { pbImportProcedure.PerformStep(); @@ -2749,14 +2838,19 @@ namespace VEPROMS Procedure p = Procedure.MakeProcedure(dvInfo, procInfo, number, text, proctype); p.DTS = dts; p.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode !=null)? fnNode.InnerText : ""; if (formatid != string.Empty) - p.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + p.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid),formatfilename); p.MyContent.Config = config; p.MyContent.DTS = dts; p.MyContent.UserID = userid; p.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), p.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), p.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), p.ItemID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), p.MyContent.ContentID); if (xn.SelectNodes("annotation").Count > 0) AddAnnotations(p.ItemID, xn); if (xc.SelectNodes("rousage").Count > 0) @@ -2823,19 +2917,22 @@ namespace VEPROMS content.Save(); } } - private void AddAnnotation(XmlReader xr) - { - int itemid = int.Parse(xr.GetAttribute("itemid")); - itemid = Old2NewItem[itemid]; - Item itm = Item.Get(itemid); - int typeid = int.Parse(xr.GetAttribute("typeid")); - string rtftext = xr.GetAttribute("rtftext"); - string searchtext = xr.GetAttribute("searchtext"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Annotation ann = Annotation.MakeAnnotation(itm, AnnotationType.Get(typeid), rtftext, searchtext, config, dts, userid); - } + + // jsj 4-29-2016 appears to not be used + //private void AddAnnotation(XmlReader xr) + //{ + // int itemid = int.Parse(xr.GetAttribute("itemid")); + // itemid = Old2NewItem[itemid]; + // Item itm = Item.Get(itemid); + // int typeid = int.Parse(xr.GetAttribute("typeid")); + // string rtftext = xr.GetAttribute("rtftext"); + // string searchtext = xr.GetAttribute("searchtext"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Annotation ann = Annotation.MakeAnnotation(itm, AnnotationType.Get(typeid), rtftext, searchtext, config, dts, userid); + //} + private void AddAnnotations(int itemID, XmlNode xn) { Item itm = Item.Get(itemID); @@ -2941,14 +3038,19 @@ namespace VEPROMS step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Table); step.DTS = dts; step.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid),formatfilename); step.MyContent.Config = config; step.MyContent.DTS = dts; step.MyContent.UserID = userid; step.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); if (xc.SelectNodes("grid").Count > 0) AddGrid(step.MyContent, xc); if (xn.SelectNodes("annotation").Count > 0) @@ -2979,29 +3081,32 @@ namespace VEPROMS foreach (XmlNode nd in xn.ChildNodes) prevInfo = AddStep(nd, parentInfo, prevInfo); } - private ItemInfo AddStep(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - { - string number = xr.GetAttribute("number"); - string text = xr.GetAttribute("text"); - int steptype = int.Parse(xr.GetAttribute("type")); - string formatid = xr.GetAttribute("formatid"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Step); - step.DTS = dts; - step.UserID = userid; - if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - step.MyContent.Config = config; - step.MyContent.DTS = dts; - step.MyContent.UserID = userid; - step.Save(); - Old2NewItem.Add(oldid, step.ItemID); - Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - prevInfo = StepInfo.Get(step.ItemID); - return prevInfo; - } + + // jsj 4-29-2016 appears to not be used + //private ItemInfo AddStep(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) + //{ + // string number = xr.GetAttribute("number"); + // string text = xr.GetAttribute("text"); + // int steptype = int.Parse(xr.GetAttribute("type")); + // string formatid = xr.GetAttribute("formatid"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Step); + // step.DTS = dts; + // step.UserID = userid; + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // if (formatid != string.Empty) + // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid),formatfilename); + // step.MyContent.Config = config; + // step.MyContent.DTS = dts; + // step.MyContent.UserID = userid; + // step.Save(); + // Old2NewItem.Add(oldid, step.ItemID); + // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); + // prevInfo = StepInfo.Get(step.ItemID); + // return prevInfo; + //} private ItemInfo AddStep(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -3021,14 +3126,19 @@ namespace VEPROMS step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Step); step.DTS = dts; step.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); step.MyContent.Config = config; step.MyContent.DTS = dts; step.MyContent.UserID = userid; step.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); if (xn.SelectNodes("annotation").Count > 0) AddAnnotations(step.ItemID, xn); if (xc.SelectNodes("rousage").Count > 0) @@ -3057,29 +3167,33 @@ namespace VEPROMS foreach (XmlNode nd in xn.ChildNodes) prevInfo = AddRNO(nd, parentInfo, prevInfo); } - private ItemInfo AddRNO(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - { - string number = xr.GetAttribute("number"); - string text = xr.GetAttribute("text"); - int steptype = int.Parse(xr.GetAttribute("type")); - string formatid = xr.GetAttribute("formatid"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.RNO); - step.DTS = dts; - step.UserID = userid; - if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - step.MyContent.Config = config; - step.MyContent.DTS = dts; - step.MyContent.UserID = userid; - step.Save(); - Old2NewItem.Add(oldid, step.ItemID); - Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - prevInfo = StepInfo.Get(step.ItemID); - return prevInfo; - } + + // jsj 4-29-2016 appears to not be used + //private ItemInfo AddRNO(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) + //{ + // string number = xr.GetAttribute("number"); + // string text = xr.GetAttribute("text"); + // int steptype = int.Parse(xr.GetAttribute("type")); + // string formatid = xr.GetAttribute("formatid"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.RNO); + // step.DTS = dts; + // step.UserID = userid; + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // if (formatid != string.Empty) + // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); + // step.MyContent.Config = config; + // step.MyContent.DTS = dts; + // step.MyContent.UserID = userid; + // step.Save(); + // Old2NewItem.Add(oldid, step.ItemID); + // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); + // prevInfo = StepInfo.Get(step.ItemID); + // return prevInfo; + //} + private ItemInfo AddRNO(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -3099,14 +3213,19 @@ namespace VEPROMS step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.RNO); step.DTS = dts; step.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); step.MyContent.Config = config; step.MyContent.DTS = dts; step.MyContent.UserID = userid; step.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); if (xn.SelectNodes("annotation").Count > 0) AddAnnotations(step.ItemID, xn); if (xc.SelectNodes("rousage").Count > 0) @@ -3135,29 +3254,33 @@ namespace VEPROMS foreach (XmlNode nd in xn.ChildNodes) prevInfo = AddNote(nd, parentInfo, prevInfo); } - private ItemInfo AddNote(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - { - string number = xr.GetAttribute("number"); - string text = xr.GetAttribute("text"); - int steptype = int.Parse(xr.GetAttribute("type")); - string formatid = xr.GetAttribute("formatid"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Note); - step.DTS = dts; - step.UserID = userid; - if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - step.MyContent.Config = config; - step.MyContent.DTS = dts; - step.MyContent.UserID = userid; - step.Save(); - Old2NewItem.Add(oldid, step.ItemID); - Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - prevInfo = StepInfo.Get(step.ItemID); - return prevInfo; - } + + // jsj 4-29-2016 appears to not be used + //private ItemInfo AddNote(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) + //{ + // string number = xr.GetAttribute("number"); + // string text = xr.GetAttribute("text"); + // int steptype = int.Parse(xr.GetAttribute("type")); + // string formatid = xr.GetAttribute("formatid"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Note); + // step.DTS = dts; + // step.UserID = userid; + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // if (formatid != string.Empty) + // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); + // step.MyContent.Config = config; + // step.MyContent.DTS = dts; + // step.MyContent.UserID = userid; + // step.Save(); + // Old2NewItem.Add(oldid, step.ItemID); + // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); + // prevInfo = StepInfo.Get(step.ItemID); + // return prevInfo; + //} + private ItemInfo AddNote(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -3177,14 +3300,19 @@ namespace VEPROMS step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Note); step.DTS = dts; step.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); step.MyContent.Config = config; step.MyContent.DTS = dts; step.MyContent.UserID = userid; step.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); if (xn.SelectNodes("annotation").Count > 0) AddAnnotations(step.ItemID, xn); if (xc.SelectNodes("rousage").Count > 0) @@ -3213,29 +3341,33 @@ namespace VEPROMS foreach (XmlNode nd in xn.ChildNodes) prevInfo = AddCaution(nd, parentInfo, prevInfo); } - private ItemInfo AddCaution(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - { - string number = xr.GetAttribute("number"); - string text = xr.GetAttribute("text"); - int steptype = int.Parse(xr.GetAttribute("type")); - string formatid = xr.GetAttribute("formatid"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Caution); - step.DTS = dts; - step.UserID = userid; - if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - step.MyContent.Config = config; - step.MyContent.DTS = dts; - step.MyContent.UserID = userid; - step.Save(); - Old2NewItem.Add(oldid, step.ItemID); - Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); - prevInfo = StepInfo.Get(step.ItemID); - return prevInfo; - } + + // jsj 4-29-2016 appears to not be used + //private ItemInfo AddCaution(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) + //{ + // string number = xr.GetAttribute("number"); + // string text = xr.GetAttribute("text"); + // int steptype = int.Parse(xr.GetAttribute("type")); + // string formatid = xr.GetAttribute("formatid"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Step step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Caution); + // step.DTS = dts; + // step.UserID = userid; + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // if (formatid != string.Empty) + // step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); + // step.MyContent.Config = config; + // step.MyContent.DTS = dts; + // step.MyContent.UserID = userid; + // step.Save(); + // Old2NewItem.Add(oldid, step.ItemID); + // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), step.MyContent.ContentID); + // prevInfo = StepInfo.Get(step.ItemID); + // return prevInfo; + //} + private ItemInfo AddCaution(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportStep.PerformStep(); @@ -3255,14 +3387,19 @@ namespace VEPROMS step = Step.MakeStep(parentInfo, prevInfo, number, text, steptype, E_FromType.Caution); step.DTS = dts; step.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; if (formatid != string.Empty) - step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + step.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); step.MyContent.Config = config; step.MyContent.DTS = dts; step.MyContent.UserID = userid; step.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), step.ItemID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), step.MyContent.ContentID); if (xn.SelectNodes("annotation").Count > 0) AddAnnotations(step.ItemID, xn); if (xc.SelectNodes("rousage").Count > 0) @@ -3297,29 +3434,33 @@ namespace VEPROMS rv.Add("itemid", xr.GetAttribute("itemid")); return rv; } - private ItemInfo AddSection(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) - { - string number = xr.GetAttribute("number"); - string text = xr.GetAttribute("text"); - int sectiontype = int.Parse(xr.GetAttribute("type")); - string formatid = xr.GetAttribute("formatid"); - string config = xr.GetAttribute("config"); - string userid = xr.GetAttribute("userid"); - DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); - Section sect = Section.MakeSection(parentInfo, prevInfo, number, text, sectiontype); - sect.DTS = dts; - sect.UserID = userid; - if (formatid != string.Empty) - sect.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); - sect.MyContent.Config = config; - sect.MyContent.DTS = dts; - sect.MyContent.UserID = userid; - sect.Save(); - Old2NewItem.Add(oldid, sect.ItemID); - Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), sect.MyContent.ContentID); - prevInfo = SectionInfo.Get(sect.ItemID); - return prevInfo; - } + + // js j4-29-2016 appears to not be used + //private ItemInfo AddSection(XmlReader xr, ItemInfo parentInfo, ItemInfo prevInfo, int oldid) + //{ + // string number = xr.GetAttribute("number"); + // string text = xr.GetAttribute("text"); + // int sectiontype = int.Parse(xr.GetAttribute("type")); + // string formatid = xr.GetAttribute("formatid"); + // string config = xr.GetAttribute("config"); + // string userid = xr.GetAttribute("userid"); + // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); + // Section sect = Section.MakeSection(parentInfo, prevInfo, number, text, sectiontype); + // sect.DTS = dts; + // sect.UserID = userid; + // string formatfilename = xr.GetAttribute("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + // if (formatid != string.Empty) + // sect.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); + // sect.MyContent.Config = config; + // sect.MyContent.DTS = dts; + // sect.MyContent.UserID = userid; + // sect.Save(); + // Old2NewItem.Add(oldid, sect.ItemID); + // Old2NewContent.Add(int.Parse(xr.GetAttribute("contentid")), sect.MyContent.ContentID); + // prevInfo = SectionInfo.Get(sect.ItemID); + // return prevInfo; + //} + private ItemInfo AddSection(XmlNode xn, ItemInfo parentInfo, ItemInfo prevInfo) { pbImportSection.PerformStep(); @@ -3339,14 +3480,19 @@ namespace VEPROMS sect = Section.MakeSection(parentInfo, prevInfo, number, text, sectiontype); sect.DTS = dts; sect.UserID = userid; + // check for a null in case an older export file is being imported (the older files will not have the fromatfilename attribute) + XmlNode fnNode = xc.Attributes.GetNamedItem("formatfilename"); //Bug fix B2016-103 the formatid in an Export file may not match the formatid where you are importing to + string formatfilename = (fnNode != null) ? fnNode.InnerText : ""; if (formatid != string.Empty) - sect.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid)); + sect.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename); sect.MyContent.Config = config; sect.MyContent.DTS = dts; sect.MyContent.UserID = userid; sect.Save(); - Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), sect.ItemID); - Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), sect.MyContent.ContentID); + if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText))) + Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), sect.MyContent.ContentID); + if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText))) + Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), sect.ItemID); if (xn.SelectNodes("annotation").Count > 0) AddAnnotations(sect.ItemID, xn); if (xc.SelectNodes("entry").Count > 0) @@ -3372,6 +3518,7 @@ namespace VEPROMS floatFoldout.Add(contentid, int.Parse(xn.InnerText)); } } + // jsj 2016Feb16 - This appears to not be used //private void AddGrid(XmlReader xr) //{ @@ -3384,6 +3531,7 @@ namespace VEPROMS // DateTime dts = DateTime.Parse(xr.GetAttribute("dts")); // Grid gg = Grid.MakeGrid(content, data, config, dts, userid); //} + private void AddGrid(Content content, XmlNode xc) { XmlNode nd = xc.SelectSingleNode("grid"); @@ -3420,14 +3568,17 @@ namespace VEPROMS Grid gg = Grid.MakeGrid(content, data, config, dts, userid); gg.Save(); } - private Dictionary AddEntry(XmlReader xr) - { - Dictionary dic = new Dictionary(); - dic.Add("contentid", xr.GetAttribute("contentid")); - dic.Add("dts", xr.GetAttribute("dts")); - dic.Add("userid", xr.GetAttribute("userid")); - return dic; - } + + // jsj 4-29-2016 appears to not be used + //private Dictionary AddEntry(XmlReader xr) + //{ + // Dictionary dic = new Dictionary(); + // dic.Add("contentid", xr.GetAttribute("contentid")); + // dic.Add("dts", xr.GetAttribute("dts")); + // dic.Add("userid", xr.GetAttribute("userid")); + // return dic; + //} + private void AddEntry(Content content, XmlNode xc) { XmlNode nd = xc.SelectSingleNode("entry"); @@ -3467,11 +3618,20 @@ namespace VEPROMS else { string libtitle = xn.Attributes.GetNamedItem("libtitle").InnerText; + DateTime dts = DateTime.Parse(xn.Attributes.GetNamedItem("dts").InnerText); + if (libtitle != "") + { + DocumentInfoList dil = DocumentInfoList.GetLibraries(true); + foreach (DocumentInfo di in dil) + { + if (di.LibTitle == libtitle && di.DTS == dts) + return di.Get(); // found library document in exiting database + } + } 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();