C2018-039: Upgrade – User Control of Format
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using VEPROMS.CSLA.Library;
|
||||
using Volian.Controls.Library;
|
||||
using Volian.Base.Library;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
@@ -39,8 +40,10 @@ namespace VEPROMS
|
||||
set { _ExternalTransitionItem = value; }
|
||||
}
|
||||
private Dictionary<int, int> floatFoldout;
|
||||
private Dictionary<int, string> oldFormat;
|
||||
private Dictionary<string, int> newFormat;
|
||||
private Dictionary<int, string> importedFormat;
|
||||
private Dictionary<string, int> existingFormat;
|
||||
private Dictionary<string, string> renamedUCFFormatName; // if format is renamed, this is its new name so references to it can be made
|
||||
private Dictionary<int, int> renamedUCFFormatId; // if format is renamed, this is its old->new formatid
|
||||
private int oldRODbID;
|
||||
private int newRODbID;
|
||||
private FolderInfo _MyNewFolder;
|
||||
@@ -65,24 +68,30 @@ namespace VEPROMS
|
||||
xa.InnerText = value;
|
||||
return xa;
|
||||
}
|
||||
public dlgExportImport(string mode, FolderInfo folderInfo, frmVEPROMS myFrmVEPROMS)
|
||||
public dlgExportImport(string mode, FolderInfo folderInfo, frmVEPROMS myFrmVEPROMS, E_UCFImportOptions frset)
|
||||
{
|
||||
UCFImportDefaultFromSettings = frset;
|
||||
MyFrmVEPROMS = myFrmVEPROMS;// Save frmVEPROMS for Import to shutoff SessionPing
|
||||
_MyMode = mode;
|
||||
MyFolder = folderInfo;
|
||||
InitializeComponent();
|
||||
this.Text = mode + " Dialog for " + folderInfo.Name;
|
||||
}
|
||||
public dlgExportImport(string mode, DocVersionInfo docVersionInfo, frmVEPROMS myFrmVEPROMS)
|
||||
public dlgExportImport(string mode, DocVersionInfo docVersionInfo, frmVEPROMS myFrmVEPROMS, E_UCFImportOptions frset)
|
||||
{
|
||||
UCFImportDefaultFromSettings = frset;
|
||||
MyFrmVEPROMS = myFrmVEPROMS;// Save frmVEPROMS for Import to shutoff SessionPing
|
||||
_MyMode = mode;
|
||||
MyDocVersion = docVersionInfo;
|
||||
InitializeComponent();
|
||||
this.Text = mode + " Dialog for " + docVersionInfo.Name + " of " + docVersionInfo.MyFolder.Name;
|
||||
if (mode.ToUpper().Contains("FORMAT"))
|
||||
this.Text = mode;
|
||||
else
|
||||
this.Text = mode + " Dialog for " + docVersionInfo.Name + " of " + docVersionInfo.MyFolder.Name;
|
||||
}
|
||||
public dlgExportImport(string mode, ProcedureInfo procedureInfo, frmVEPROMS myFrmVEPROMS)
|
||||
public dlgExportImport(string mode, ProcedureInfo procedureInfo, frmVEPROMS myFrmVEPROMS, E_UCFImportOptions frset)
|
||||
{
|
||||
UCFImportDefaultFromSettings = frset;
|
||||
MyFrmVEPROMS = myFrmVEPROMS;// Save frmVEPROMS for Import to shutoff SessionPing
|
||||
_MyMode = mode;
|
||||
MyProcedure = procedureInfo;
|
||||
@@ -105,20 +114,43 @@ namespace VEPROMS
|
||||
}
|
||||
pnlExport.Dock = DockStyle.Fill;
|
||||
pnlImport.Dock = DockStyle.Fill;
|
||||
if (_MyMode.ToLower() == "export")
|
||||
int formsize = 2;
|
||||
if (_MyMode.ToLower().Contains("export"))
|
||||
{
|
||||
// if doing formats, make various controls invisible:
|
||||
if (_MyMode.ToUpper().Contains("FORMAT"))
|
||||
{
|
||||
cbxExportAudits.Visible = false;
|
||||
lblExportProcedure.Visible = lblExportSection.Visible = lblExportStep.Visible = false;
|
||||
pbExportProcedure.Visible = pbExportSection.Visible = pbExportStep.Visible = false;
|
||||
lblExportTime.Visible = false;
|
||||
formsize = 4;
|
||||
}
|
||||
sfd.InitialDirectory = PEIPath;
|
||||
pnlExport.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_MyMode.ToUpper().Contains("FORMAT"))
|
||||
{
|
||||
cbxImportAudits.Visible = false;
|
||||
lblImportProcedure.Visible = lblImportSection.Visible = lblImportStep.Visible = false;
|
||||
pbImportProcedure.Visible = pbImportSection.Visible = pbImportStep.Visible = false;
|
||||
lblExportTime.Visible = false;
|
||||
formsize = 4;
|
||||
}
|
||||
ofd.InitialDirectory = PEIPath;
|
||||
pnlImport.BringToFront();
|
||||
}
|
||||
this.Height = this.Height / 2;
|
||||
this.Height = this.Height / formsize;
|
||||
}
|
||||
private void btnExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_MyMode.ToUpper().Contains("FORMAT"))
|
||||
{
|
||||
txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, "UCF");
|
||||
return;
|
||||
}
|
||||
if (MyFolder != null)
|
||||
{
|
||||
//Database.SelectedDatabase
|
||||
@@ -158,7 +190,19 @@ namespace VEPROMS
|
||||
{
|
||||
btnExport.Enabled = false;
|
||||
string msg = "Finished Exporting:\n\n";
|
||||
if (MyFolder != null)
|
||||
if (_MyMode.ToUpper().Contains("FORMAT"))
|
||||
{
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
MyStart = DateTime.Now;
|
||||
btnDoExport.Enabled = false;
|
||||
lblExportStatus.Text = "Performing Export of UC Formats";
|
||||
SaveExportUCF();
|
||||
|
||||
TimeSpan elapsed = DateTime.Now.Subtract(MyStart);
|
||||
lblExportStatus.Text = "Format Export Completed in " + elapsed.ToString();
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
else if (MyFolder != null)
|
||||
{
|
||||
this.Cursor = Cursors.WaitCursor;
|
||||
MyStart = DateTime.Now;
|
||||
@@ -181,19 +225,43 @@ namespace VEPROMS
|
||||
pbExportProcedure.Maximum = 1;
|
||||
XmlDocument xd = new XmlDocument();
|
||||
ExportItem(xd, MyProcedure, "procedure");
|
||||
XmlElement xe = xd.CreateElement("formats");
|
||||
xd.DocumentElement.AppendChild(xe);
|
||||
ExportFormats(FormatInfoList.GetFormatInfoListUsed(), xe, "formats", false);
|
||||
xd.Save(txtExport.Text);
|
||||
TimeSpan elapsed = DateTime.Now.Subtract(MyStart);
|
||||
lblExportStatus.Text = "Export Completed in " + elapsed.ToString();
|
||||
this.Cursor = Cursors.Default;
|
||||
}
|
||||
// added message to user when export of a procedure or procedure set has completed
|
||||
if (successfullExport)
|
||||
msg += MyProcedure;
|
||||
else
|
||||
msg = "Could not complete export";
|
||||
if (successfullExport)
|
||||
{
|
||||
if (!_MyMode.ToUpper().Contains("FORMAT"))
|
||||
msg += MyProcedure;
|
||||
else
|
||||
msg += "Formats";
|
||||
}
|
||||
else
|
||||
msg = "Could not complete export";
|
||||
MessageBox.Show(msg, "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
btnCloseExport.Enabled = true;
|
||||
}
|
||||
|
||||
private void SaveExportUCF()
|
||||
{
|
||||
lblExportStatus.Text = "Exporting UC Formats...";
|
||||
Application.DoEvents();
|
||||
XmlDocument xd = new XmlDocument();
|
||||
XmlElement xe = xd.CreateElement("ucformats");
|
||||
xd.AppendChild(xe);
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
{
|
||||
if (fi.Config != null && fi.Config != "")
|
||||
ExportFormat(xe, fi, "ucformat");
|
||||
}
|
||||
xd.Save(txtExport.Text);
|
||||
}
|
||||
private void SaveExportData()
|
||||
{
|
||||
XmlDocument xd = new XmlDocument();
|
||||
@@ -228,7 +296,26 @@ namespace VEPROMS
|
||||
_DidProcessTransitions = false; // B2017-076 to know if we processed any transition (used in status message at the end of importing)
|
||||
_DidProcessROs = false; // B2017-076 to know if we processed any transition (used in status message at the end of importing)
|
||||
//LoadImportDataReader();
|
||||
if (MyFolder != null) // import a folder - a .expx file
|
||||
if (_MyMode.ToUpper().Contains("FORMAT"))
|
||||
{
|
||||
TurnChangeManagerOff.Execute();
|
||||
MyFrmVEPROMS.DisablePing = true;// Turn-off SessionPing
|
||||
bool result = TryToImportUCFs(ref isImported, ref canceledPressed);
|
||||
MyFrmVEPROMS.DisablePing = false;// Turn-on SessionPing
|
||||
TurnChangeManagerOn.Execute();
|
||||
if (!result) return;
|
||||
if (isImported)
|
||||
{
|
||||
TimeSpan elapsed = DateTime.Now.Subtract(MyStart);
|
||||
lblImportStatus.Text = "Format Import Completed in " + elapsed.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
btnImport.Enabled = true;
|
||||
btnDoImport.Enabled = true;
|
||||
}
|
||||
}
|
||||
else if (MyFolder != null) // import a folder - a .expx file
|
||||
{
|
||||
TurnChangeManagerOff.Execute();
|
||||
MyFrmVEPROMS.DisablePing = true;// Turn-off SessionPing
|
||||
@@ -289,6 +376,71 @@ namespace VEPROMS
|
||||
btnCloseImport.PerformClick();
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryToImportUCFs(ref bool isImported, ref bool canceledPressed)
|
||||
{
|
||||
try
|
||||
{
|
||||
existingFormat = new Dictionary<string, int>();
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
existingFormat.Add(fi.Name, fi.FormatID);
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.Load(txtImport.Text);
|
||||
XmlNodeList nl = xd.SelectNodes("ucformats/ucformat");
|
||||
foreach (XmlNode nd in nl)
|
||||
{
|
||||
int formatid = int.Parse(nd.Attributes.GetNamedItem("formatid").InnerText);
|
||||
string name = nd.Attributes.GetNamedItem("name").InnerText;
|
||||
string config = null;
|
||||
XmlNode cfg = nd.Attributes.GetNamedItem("config");
|
||||
if (cfg != null) config = cfg.InnerText;
|
||||
string pname = nd.Attributes.GetNamedItem("pname").InnerText;
|
||||
string description = null;
|
||||
XmlNode descript = nd.Attributes.GetNamedItem("description");
|
||||
if (descript != null) description = descript.InnerText;
|
||||
string userid = nd.Attributes.GetNamedItem("userid").InnerText;
|
||||
DateTime dts = DateTime.Parse(nd.Attributes.GetNamedItem("dts").InnerText);
|
||||
if (!existingFormat.ContainsKey(pname)) return false;
|
||||
int pid = existingFormat[pname];
|
||||
Format pformat = Format.Get(pid);
|
||||
if (existingFormat.ContainsKey(name)) // this UCF already exists in database, just update the record.
|
||||
{
|
||||
FormatInfo exFI = FormatInfo.Get(existingFormat[name]);
|
||||
if (exFI.Config != config)
|
||||
{
|
||||
using (Format f = Format.Get(exFI.FormatID))
|
||||
{
|
||||
f.Name = name;
|
||||
f.MyParent = pformat;
|
||||
f.Description = description;
|
||||
f.UserID = userid;
|
||||
f.DTS = dts;
|
||||
f.Config = config;
|
||||
f.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
else // doesn't exist in the database, add it
|
||||
{
|
||||
|
||||
Format rec = Format.MakeFormat(pformat, name, description, null, null, dts, userid);
|
||||
rec.Config = config;
|
||||
rec.Save();
|
||||
}
|
||||
}
|
||||
isImported = true;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
_MyLog.Warn("Failed during UC Formats Import", ex);
|
||||
this.Close();
|
||||
isImported = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private bool TryToImportProcedure(ref bool isImported, ref bool canceledPressed)
|
||||
{
|
||||
try
|
||||
@@ -411,7 +563,14 @@ namespace VEPROMS
|
||||
}
|
||||
#endregion
|
||||
} // end - need to select RO Path
|
||||
|
||||
bool didImp = LoadFormats(xd, "procedure/formats/format");
|
||||
if (!didImp)
|
||||
{
|
||||
this.Cursor = Cursors.Default;
|
||||
this.btnImport.Enabled = true; // allow user to select a different export file to import
|
||||
this.btnDoImport.Enabled = true; // allow user to change mind and perform the import
|
||||
return false; // Return False to Indicate that the Import did not succeed
|
||||
}
|
||||
// use resolvedProcNum to determine if procedure is 'unique', i.e. if the procedure number exists
|
||||
// and user does not overwrite or copy, then the procedure should NOT be imported. Fix for B2016-045
|
||||
bool resolvedProcNum = true;
|
||||
@@ -472,8 +631,28 @@ namespace VEPROMS
|
||||
ImportProcedureNew(xd);
|
||||
isImported = true;
|
||||
}
|
||||
if (isImported && UCFImportCase==E_UCFImportOptions.LoadForSetOnly) UpdateFormatForUCFInSet();
|
||||
return true;// Import Suceeded
|
||||
}
|
||||
private void UpdateFormatForUCFInSet()
|
||||
{
|
||||
// this gets called if the UCFImportCase == LoadForSetOnly, i.e. only items in this PROCEDURE Set whose formats point to a
|
||||
// UCF format should point to the updated (copied) UCF format.
|
||||
if (renamedUCFFormatId == null) return;
|
||||
foreach (int key in renamedUCFFormatId.Keys)
|
||||
{
|
||||
using (ContentInfoList cil = ContentInfoList.FixFormatIDAfterImport(MyDocVersion.VersionID.ToString(), renamedUCFFormatId[key], key))
|
||||
{
|
||||
foreach (ContentInfo ci in cil)
|
||||
{
|
||||
using (Content c = ci.Get())
|
||||
{
|
||||
ContentInfo.Refresh(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Added Error Handling to assure that Change Manager is turned-on regardless of success or failure of the import
|
||||
private void TryToLoadImportDataDocument()
|
||||
{
|
||||
@@ -490,14 +669,14 @@ namespace VEPROMS
|
||||
{
|
||||
//add imported procedure
|
||||
floatFoldout = new Dictionary<int, int>();
|
||||
oldFormat = new Dictionary<int, string>();
|
||||
newFormat = new Dictionary<string, int>();
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
{
|
||||
oldFormat.Add(fi.FormatID, fi.Name);
|
||||
newFormat.Add(fi.Name, fi.FormatID);
|
||||
}
|
||||
importedFormat = new Dictionary<int, string>();
|
||||
existingFormat = new Dictionary<string, int>();
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
{
|
||||
importedFormat.Add(fi.FormatID, fi.Name);
|
||||
existingFormat.Add(fi.Name, fi.FormatID);
|
||||
}
|
||||
Old2NewItem = new Dictionary<int, int>();
|
||||
Old2NewContent = new Dictionary<int, int>();
|
||||
Old2NewLibDoc = new Dictionary<int, int>();
|
||||
@@ -519,13 +698,13 @@ namespace VEPROMS
|
||||
private void ImportProcedureCopy(XmlDocument xd)
|
||||
{
|
||||
floatFoldout = new Dictionary<int, int>();
|
||||
oldFormat = new Dictionary<int, string>();
|
||||
newFormat = new Dictionary<string, int>();
|
||||
importedFormat = new Dictionary<int, string>();
|
||||
existingFormat = new Dictionary<string, int>();
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
{
|
||||
oldFormat.Add(fi.FormatID, fi.Name);
|
||||
newFormat.Add(fi.Name, fi.FormatID);
|
||||
importedFormat.Add(fi.FormatID, fi.Name);
|
||||
existingFormat.Add(fi.Name, fi.FormatID);
|
||||
}
|
||||
Old2NewItem = new Dictionary<int, int>();
|
||||
Old2NewContent = new Dictionary<int, int>();
|
||||
@@ -558,13 +737,13 @@ namespace VEPROMS
|
||||
private bool ImportProcedureOverwrite(XmlDocument xd, ProcedureInfo pi)
|
||||
{
|
||||
floatFoldout = new Dictionary<int, int>();
|
||||
oldFormat = new Dictionary<int, string>();
|
||||
newFormat = new Dictionary<string, int>();
|
||||
importedFormat = new Dictionary<int, string>();
|
||||
existingFormat = new Dictionary<string, int>( );
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
{
|
||||
oldFormat.Add(fi.FormatID, fi.Name);
|
||||
newFormat.Add(fi.Name, fi.FormatID);
|
||||
importedFormat.Add(fi.FormatID, fi.Name);
|
||||
existingFormat.Add(fi.Name, fi.FormatID);
|
||||
}
|
||||
Old2NewItem = new Dictionary<int, int>();
|
||||
Old2NewContent = new Dictionary<int, int>();
|
||||
@@ -620,7 +799,14 @@ namespace VEPROMS
|
||||
ze.Extract(PEIPath, ExtractExistingFileAction.OverwriteSilently);
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.Load(fn);
|
||||
LoadFormats(xd);
|
||||
bool didImp = LoadFormats(xd, "folder/formats/format");
|
||||
if (!didImp)
|
||||
{
|
||||
this.Cursor = Cursors.Default;
|
||||
this.btnImport.Enabled = true; // allow user to select a different export file to import
|
||||
this.btnDoImport.Enabled = true; // allow user to change mind and perform the import
|
||||
return; // Return False to Indicate that the Import did not succeed
|
||||
}
|
||||
Folder ff = AddFolder(Folder.Get(MyFolder.FolderID), xd);
|
||||
if (ff == null)
|
||||
{
|
||||
@@ -656,33 +842,33 @@ namespace VEPROMS
|
||||
FixFloatingFoldouts();
|
||||
SaveTransitionAndItemContentIDs();
|
||||
}
|
||||
private void FixSectionStart(ProcedureInfo pi)
|
||||
{
|
||||
Content c = Content.Get(pi.MyContent.ContentID);
|
||||
XmlDocument xd = new XmlDocument();
|
||||
// If the config field is empty, add an empty xml node.
|
||||
if (c.Config == "") c.Config = "<Config/>";
|
||||
xd.LoadXml(c.Config);
|
||||
XmlNode xn = xd.SelectSingleNode("Config/Procedure/@SectionStart");
|
||||
if (xn != null)
|
||||
{
|
||||
int iid = int.Parse(xn.InnerText);
|
||||
if (Old2NewItem.ContainsKey(iid))
|
||||
iid = Old2NewItem[iid];
|
||||
else
|
||||
{
|
||||
int oldid = iid;
|
||||
iid = pi.ItemID;
|
||||
XmlAttribute xa = xd.CreateAttribute("ErrorSectionStart");
|
||||
xa.InnerText = oldid.ToString();
|
||||
XmlNode xp = xd.SelectSingleNode("Config/Procedure");
|
||||
xp.Attributes.SetNamedItem(xa);
|
||||
}
|
||||
xn.InnerText = iid.ToString();
|
||||
c.Config = xd.OuterXml;
|
||||
c.Save();
|
||||
}
|
||||
}
|
||||
private void FixSectionStart(ProcedureInfo pi)
|
||||
{
|
||||
Content c = Content.Get(pi.MyContent.ContentID);
|
||||
XmlDocument xd = new XmlDocument();
|
||||
// If the config field is empty, add an empty xml node.
|
||||
if (c.Config == "") c.Config = "<Config/>";
|
||||
xd.LoadXml(c.Config);
|
||||
XmlNode xn = xd.SelectSingleNode("Config/Procedure/@SectionStart");
|
||||
if (xn != null)
|
||||
{
|
||||
int iid = int.Parse(xn.InnerText);
|
||||
if (Old2NewItem.ContainsKey(iid))
|
||||
iid = Old2NewItem[iid];
|
||||
else
|
||||
{
|
||||
int oldid = iid;
|
||||
iid = pi.ItemID;
|
||||
XmlAttribute xa = xd.CreateAttribute("ErrorSectionStart");
|
||||
xa.InnerText = oldid.ToString();
|
||||
XmlNode xp = xd.SelectSingleNode("Config/Procedure");
|
||||
xp.Attributes.SetNamedItem(xa);
|
||||
}
|
||||
xn.InnerText = iid.ToString();
|
||||
c.Config = xd.OuterXml;
|
||||
c.Save();
|
||||
}
|
||||
}
|
||||
private void FixFloatingFoldouts()
|
||||
{
|
||||
foreach (int key in floatFoldout.Keys)
|
||||
@@ -699,24 +885,241 @@ namespace VEPROMS
|
||||
c.Save();
|
||||
}
|
||||
}
|
||||
|
||||
// note that his is only used when importing a folder
|
||||
private void LoadFormats(XmlDocument xd)
|
||||
private E_UCFImportOptions UCFImportDefaultFromSettings;
|
||||
private E_UCFImportOptions UCFImportCase = E_UCFImportOptions.LoadOnlyImported;
|
||||
Dictionary<string, string> existingCopyFCName = new Dictionary<string, string>();
|
||||
// note that this is used when importing a folder or a procedure (procedure was added for UCF changes)
|
||||
private bool LoadFormats(XmlDocument xd, string xmlpath)
|
||||
{
|
||||
oldFormat = new Dictionary<int, string>();
|
||||
XmlNodeList nl = xd.SelectNodes("folder/formats/format");
|
||||
foreach (XmlNode nd in nl)
|
||||
{
|
||||
int formatid = int.Parse(nd.Attributes.GetNamedItem("formatid").InnerText);
|
||||
string name = nd.Attributes.GetNamedItem("name").InnerText;
|
||||
oldFormat.Add(formatid, name);
|
||||
}
|
||||
newFormat = new Dictionary<string, int>();
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
newFormat.Add(fi.Name, fi.FormatID);
|
||||
existingFormat = new Dictionary<string, int>();
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
foreach (FormatInfo fi in fil)
|
||||
existingFormat.Add(fi.Name, fi.FormatID);
|
||||
|
||||
importedFormat = new Dictionary<int, string>();
|
||||
XmlNodeList nl = xd.SelectNodes(xmlpath);
|
||||
|
||||
bool conflictingUCFdata = false;
|
||||
List<string> existingFC = new List<string>();
|
||||
List<string> importedFC = new List<string>();
|
||||
List<string> fname = new List<string>();
|
||||
|
||||
foreach (XmlNode nd in nl)
|
||||
{
|
||||
string copyOfUCF = null;
|
||||
// see if any of the imported formats are 'UCF' formats, i.e. have config data. If they are UCF,
|
||||
// see if this is different that what is in the database. If it is, the user needs to decide
|
||||
// whether to associate sections with existing UCF format or the new one. All UCF formats will be
|
||||
// connected the same way, i.e. existing or new.
|
||||
int formatid = int.Parse(nd.Attributes.GetNamedItem("formatid").InnerText);
|
||||
string name = nd.Attributes.GetNamedItem("name").InnerText;
|
||||
string config = null;
|
||||
XmlNode cfg = nd.Attributes.GetNamedItem("config");
|
||||
if (cfg != null) config = cfg.InnerText;
|
||||
if (existingFormat.ContainsKey(name) && config != null && config != "")
|
||||
{
|
||||
FormatInfo exFI = FormatInfo.Get(existingFormat[name]);
|
||||
if (exFI.Config != config && exFI.Config != "" && exFI.Config != null && config != "" && config != null)
|
||||
{
|
||||
// See if there are copies of this UCF format, if so, this may match (have same config) one of those and should
|
||||
// use it before stating there is conflicting data.
|
||||
copyOfUCF = ContentsOfUCFExists(name, config);
|
||||
if (copyOfUCF == null)
|
||||
{
|
||||
existingFC.Add(exFI.Config);
|
||||
importedFC.Add(config);
|
||||
conflictingUCFdata = true;
|
||||
fname.Add(name);
|
||||
}
|
||||
else
|
||||
existingCopyFCName.Add(name, copyOfUCF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// there is a difference in UCF data, see if user wants sections to use the existing or new ucf data:
|
||||
if (conflictingUCFdata)
|
||||
{
|
||||
// Bring up dialog to allow user to choose how the UCF data is handled:
|
||||
// Importing of a procedure(s) (names of UCF exist in current DB and in exported DB)
|
||||
//Case 0 - ignore (don't bring in new UCF)
|
||||
//Case 1 - bringing in new UCF and not using it
|
||||
//Case 2 - bringing in new UCF and only using it for imported data
|
||||
//Case 3 - bringing in new UCF and using it across the board
|
||||
//Case 4 - bringing in new UCF and using it for the current procedure set (not applicable for procedure sets)
|
||||
UCFImportCase = UCFImportDefaultFromSettings; // from the options/settings
|
||||
dlgUCFImportOptions ucfoptDlg = new dlgUCFImportOptions(fname, existingFC, importedFC, UCFImportCase, xmlpath);
|
||||
DialogResult dr = ucfoptDlg.ShowDialog();
|
||||
if (dr != DialogResult.OK) return false;
|
||||
UCFImportCase = ucfoptDlg.UCFImportOptionsCase; // may be reset from dialog.
|
||||
}
|
||||
// first see if any of the imported formats have different data. If so,
|
||||
foreach (XmlNode nd in nl)
|
||||
{
|
||||
int formatid = int.Parse(nd.Attributes.GetNamedItem("formatid").InnerText);
|
||||
string name = nd.Attributes.GetNamedItem("name").InnerText;
|
||||
string config = null;
|
||||
XmlNode cfg = nd.Attributes.GetNamedItem("config");
|
||||
if (cfg != null) config = cfg.InnerText;
|
||||
string pname = nd.Attributes.GetNamedItem("pname").InnerText;
|
||||
string description = null;
|
||||
XmlNode descript = nd.Attributes.GetNamedItem("description");
|
||||
if (descript != null) description = descript.InnerText;
|
||||
string userid = nd.Attributes.GetNamedItem("userid").InnerText;
|
||||
DateTime dts = DateTime.Parse(nd.Attributes.GetNamedItem("dts").InnerText);
|
||||
// If the format that is being imported exists as a copy (already was imported and a 'Copy x of name' was created) and the imported and
|
||||
// existing config match, use the existing (copied) format's name rather than importing it again (the dictionary was set up during
|
||||
// the import formats process.
|
||||
if (existingCopyFCName.ContainsKey(name)) name = existingCopyFCName[name];
|
||||
|
||||
// compare this imported format to the original in the database.
|
||||
// If format name exists, or if it has same config data, just use it.
|
||||
if (existingFormat.ContainsKey(name))
|
||||
{
|
||||
// Note that Data & Genmac fields can have different contents. The format information should always be used from
|
||||
// the original database, not the export file. So no processing is done on these fields when exporting & importing.
|
||||
// Data or Genmac can be different if formats were updated in one database & not the other.
|
||||
FormatInfo exFI = FormatInfo.Get(existingFormat[name]);
|
||||
if ((exFI.Config == config || ((exFI.Config == "" || exFI.Config == null) && (config == "" || config == null))))
|
||||
{
|
||||
// importedFormat is used to set correct formatid on imported sections (if different formatid <-> name between
|
||||
// the current database and the one from which export came)
|
||||
importedFormat.Add(formatid, name);
|
||||
continue; // go on to next format in import list
|
||||
}
|
||||
}
|
||||
// parent format will always be in there, if it is a new format, it will be added before the child. Check just in case (no null reference).
|
||||
if (!existingFormat.ContainsKey(pname)) break;
|
||||
int pid = existingFormat[pname];
|
||||
Format pformat = Format.Get(pid);
|
||||
|
||||
// if the new format doesn't exist, it will be added (after these other checks). Otherwise, handle the
|
||||
// various cases listed above:
|
||||
if (existingFormat.ContainsKey(name))
|
||||
{
|
||||
// if case 0 and this ucf already exists, ignore it:
|
||||
if (UCFImportCase == E_UCFImportOptions.Ignore) continue;
|
||||
|
||||
// if case 1, 2, 4 and the name exists, make a 'copy' of the newly imported format:
|
||||
// need to add this format - name must be unique so add 'COPY(x) of 'original name'' where x is unique number:
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (FormatInfo fi in fil) if (fi.Name.EndsWith(name)) count++;
|
||||
if (count > 0)
|
||||
{
|
||||
string origname = name;
|
||||
name = string.Format("Copy {0} of {1}", count.ToString(), name);
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly)
|
||||
{
|
||||
if (renamedUCFFormatName == null) renamedUCFFormatName = new Dictionary<string, string>();
|
||||
renamedUCFFormatName.Add(origname, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if case 3, take the existing config data and create in a record whose name is Old(x) of 'original name' (the record
|
||||
// creation gets done below). Then modify the existing record to have the config data. The result is that any
|
||||
// sections that used this UCF throughout the database will have the new config data.
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadUseAll)
|
||||
{
|
||||
string savname = name;
|
||||
int count = 0;
|
||||
foreach (FormatInfo fi in fil) if (fi.Name.EndsWith(name)) count++;
|
||||
if (count > 0)
|
||||
{
|
||||
name = string.Format("Old {0} of {1}", count.ToString(), name);
|
||||
}
|
||||
// update the 'old' record by getting the original config data.
|
||||
string savdesc = null;
|
||||
DateTime savdts = DateTime.Now;
|
||||
string savuid = null;
|
||||
int savpar = 0;
|
||||
string savconfig = null;
|
||||
using (Format origRecord = Format.Get(existingFormat[savname]))
|
||||
{
|
||||
savdesc = origRecord.Description;
|
||||
savdts = origRecord.DTS;
|
||||
savuid = origRecord.UserID;
|
||||
savpar = origRecord.ParentID;
|
||||
savconfig = origRecord.Config;
|
||||
origRecord.Name = savname;
|
||||
origRecord.Description = description;
|
||||
origRecord.DTS = dts;
|
||||
origRecord.UserID = userid;
|
||||
origRecord.MyParent = pformat;
|
||||
origRecord.Config = config;
|
||||
origRecord.Save();
|
||||
description = savdesc;
|
||||
dts = savdts;
|
||||
userid = savuid;
|
||||
pformat = Format.Get(savpar);
|
||||
config = savconfig;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (UCFImportCase == 0) // ignore it
|
||||
{
|
||||
importedFormat.Add(formatid, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format rec = Format.MakeFormat(pformat, name, description, null, null, dts, userid);
|
||||
rec.Config = config;
|
||||
rec.Save();
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadNotUsed || UCFImportCase == E_UCFImportOptions.LoadUseAll) // don't reset format id (case 1 don't use it, case 3 copies new data into original record
|
||||
importedFormat.Add(formatid, name);
|
||||
else if (UCFImportCase == E_UCFImportOptions.LoadOnlyImported || UCFImportCase == E_UCFImportOptions.LoadForSetOnly) // case 2 uses it for any items imported, case 4 uses it for any sections within current set
|
||||
{
|
||||
existingFormat.Add(name, rec.FormatID); // change to original name?
|
||||
importedFormat.Add(rec.FormatID, name);
|
||||
|
||||
// get format id for the original named format
|
||||
if (UCFImportCase == E_UCFImportOptions.LoadForSetOnly && renamedUCFFormatName != null)
|
||||
{
|
||||
int origformatid = -1;
|
||||
foreach (var kvp in renamedUCFFormatName)
|
||||
{
|
||||
if (kvp.Value == name)
|
||||
{
|
||||
origformatid = existingFormat[kvp.Key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (origformatid != -1)
|
||||
{
|
||||
if (renamedUCFFormatId == null) renamedUCFFormatId = new Dictionary<int, int>();
|
||||
renamedUCFFormatId.Add(rec.FormatID, origformatid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FormatInfoList.Reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
private string ContentsOfUCFExists(string name, string config)
|
||||
{
|
||||
// See if there is an existing format file that was created as a copy. If so, check if the passed in format's
|
||||
// config is the same as an existing 'Copy of' format - if so, use rather than importing the same format as
|
||||
// defined by config.
|
||||
foreach (var existname in existingFormat)
|
||||
{
|
||||
if (existname.Key.Contains(name))
|
||||
{
|
||||
string cpy = existname.Key;
|
||||
if (cpy.StartsWith("Copy") && cpy.Contains("of " + name))
|
||||
{
|
||||
FormatInfo exFI = FormatInfo.Get(existingFormat[cpy]);
|
||||
if (exFI.Config == config) return cpy;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//jsj 4-29-2016 appears to not be used
|
||||
//Dictionary<int, ItemInfo> dicParentItem = null;
|
||||
//private void UpdateParentItem(int depth, ItemInfo ii)
|
||||
@@ -1257,6 +1660,13 @@ namespace VEPROMS
|
||||
|
||||
private void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_MyMode.ToUpper().Contains("FORMAT"))
|
||||
{
|
||||
ofd.Filter = "PROMS Procedure Export Files|*.pxml";
|
||||
if (ofd.ShowDialog(this) == DialogResult.OK)
|
||||
txtImport.Text = ofd.FileName;
|
||||
return;
|
||||
}
|
||||
if (MyFolder != null)
|
||||
{
|
||||
if (ofd.ShowDialog(this) == DialogResult.OK)
|
||||
@@ -1376,25 +1786,38 @@ namespace VEPROMS
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xd, "formatfilename",formatFileName));
|
||||
xd.AppendChild(xe);
|
||||
ExportAnnotationTypes(xe, "annotationtypes");
|
||||
ExportFormats(xe, "formats");
|
||||
ExportFormats(FormatInfoList.GetFormatInfoListUsed(), xe, "formats", true);
|
||||
if (fi.FolderDocVersionCount > 0)
|
||||
foreach (DocVersionInfo dvi in fi.FolderDocVersions)
|
||||
ExportDocVersion(xe, dvi, "docversion");
|
||||
}
|
||||
private void ExportFormats(XmlElement xn, string nodename)
|
||||
private void ExportFormats(FormatInfoList fil, XmlElement xn, string nodename, bool doElement)
|
||||
{
|
||||
XmlElement xe = xn.OwnerDocument.CreateElement(nodename);
|
||||
FormatInfoList fil = FormatInfoList.Get();
|
||||
XmlElement xe = null;
|
||||
if (doElement) xe = xn.OwnerDocument.CreateElement(nodename);
|
||||
else xe = xn;
|
||||
foreach (FormatInfo fi in fil)
|
||||
ExportFormat(xe, fi, "format");
|
||||
xn.AppendChild(xe);
|
||||
if (doElement) xn.AppendChild(xe);
|
||||
}
|
||||
private void ExportFormat(XmlElement xn, FormatInfo fi, string nodename)
|
||||
{
|
||||
XmlElement xe = xn.OwnerDocument.CreateElement(nodename);
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatid", fi.FormatID.ToString()));
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "name", fi.Name));
|
||||
xn.AppendChild(xe);
|
||||
XmlElement xe = xn.OwnerDocument.CreateElement(nodename);
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatid", fi.FormatID.ToString()));
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "name", fi.Name));
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "pname", fi.MyParent==null?"null":fi.MyParent.Name));
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "description", fi.Description));
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", fi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", fi.UserID));
|
||||
|
||||
if (fi.Config != null && fi.Config != "")
|
||||
{
|
||||
FormatConfig MyFormatConfig = FormatConfig.Get(fi.Config);
|
||||
string scf = MyFormatConfig.ConvertToString();
|
||||
scf = Regex.Replace(scf, " *<[a-zA-Z ]+/>\r\n", "");
|
||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", scf));
|
||||
}
|
||||
xn.AppendChild(xe);
|
||||
}
|
||||
private void ExportAnnotationTypes(XmlElement xn, string nodename)
|
||||
{
|
||||
@@ -2931,10 +3354,11 @@ namespace VEPROMS
|
||||
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
|
||||
if (formatID >= importedFormat.Count) return null; // formatID not found, use default file name
|
||||
formatName = importedFormat[formatID]; // for backwards compatibility with older export files
|
||||
}
|
||||
formatID = newFormat[formatName];
|
||||
if (renamedUCFFormatName != null && renamedUCFFormatName.ContainsKey(formatFileName)) formatName = renamedUCFFormatName[formatName];
|
||||
formatID = existingFormat[formatName];
|
||||
return Format.Get(formatID);
|
||||
}
|
||||
catch
|
||||
@@ -3198,33 +3622,35 @@ namespace VEPROMS
|
||||
config = StripEnhanced(config);
|
||||
string userid = xc.Attributes.GetNamedItem("userid").InnerText;
|
||||
DateTime dts = DateTime.Parse(xc.Attributes.GetNamedItem("dts").InnerText);
|
||||
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),formatfilename);
|
||||
p.MyContent.Config = config;
|
||||
p.MyContent.DTS = dts;
|
||||
p.MyContent.UserID = userid;
|
||||
p.Save();
|
||||
if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)))
|
||||
Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), p.ItemID);
|
||||
else
|
||||
Old2NewItem[int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)] = p.ItemID; // B2016-176, B2016-197 refresh saved ItemId with current ItemID
|
||||
if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)))
|
||||
Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), p.MyContent.ContentID);
|
||||
else
|
||||
Old2NewContent[int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)] = p.MyContent.ContentID; // B2016-176, B2016-197 refresh saved ContentID with current ContentID
|
||||
if (xn.SelectNodes("annotation").Count > 0)
|
||||
AddAnnotations(p.ItemID, xn);
|
||||
if (xc.SelectNodes("rousage").Count > 0)
|
||||
AddROUsages(p.MyContent, xc);
|
||||
if (xc.SelectNodes("transition").Count > 0)
|
||||
AddTransitions(p.MyContent, xc);
|
||||
procInfo = ProcedureInfo.Get(p.ItemID);
|
||||
using (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), formatfilename);
|
||||
p.MyContent.Config = config;
|
||||
p.MyContent.DTS = dts;
|
||||
p.MyContent.UserID = userid;
|
||||
p.Save();
|
||||
if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)))
|
||||
Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), p.ItemID);
|
||||
else
|
||||
Old2NewItem[int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)] = p.ItemID; // B2016-176, B2016-197 refresh saved ItemId with current ItemID
|
||||
if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)))
|
||||
Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), p.MyContent.ContentID);
|
||||
else
|
||||
Old2NewContent[int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)] = p.MyContent.ContentID; // B2016-176, B2016-197 refresh saved ContentID with current ContentID
|
||||
if (xn.SelectNodes("annotation").Count > 0)
|
||||
AddAnnotations(p.ItemID, xn);
|
||||
if (xc.SelectNodes("rousage").Count > 0)
|
||||
AddROUsages(p.MyContent, xc);
|
||||
if (xc.SelectNodes("transition").Count > 0)
|
||||
AddTransitions(p.MyContent, xc);
|
||||
procInfo = ProcedureInfo.Get(p.ItemID);
|
||||
}
|
||||
if (xc.HasChildNodes)
|
||||
AddParts(xc, procInfo);
|
||||
FixSectionStart(procInfo);
|
||||
@@ -4116,37 +4542,44 @@ namespace VEPROMS
|
||||
CheckForFloatingFoldout(contentid, config);
|
||||
string userid = xc.Attributes.GetNamedItem("userid").InnerText;
|
||||
DateTime dts = DateTime.Parse(xc.Attributes.GetNamedItem("dts").InnerText);
|
||||
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), formatfilename);
|
||||
sect.MyContent.Config = config;
|
||||
sect.MyContent.DTS = dts;
|
||||
sect.MyContent.UserID = userid;
|
||||
sect.Save();
|
||||
if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)))
|
||||
Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), sect.MyContent.ContentID);
|
||||
else
|
||||
Old2NewContent[int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)] = sect.MyContent.ContentID; // B2016-176, B2016-197 refresh saved ContentID with current ContentID
|
||||
if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)))
|
||||
Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), sect.ItemID);
|
||||
else
|
||||
Old2NewItem[int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)] = sect.ItemID; // B2016-176, B2016-197 refresh saved ItemId with current ItemID
|
||||
if (xn.SelectNodes("annotation").Count > 0)
|
||||
AddAnnotations(sect.ItemID, xn);
|
||||
if (xc.SelectNodes("entry").Count > 0)
|
||||
AddEntry(sect.MyContent, xc);
|
||||
if (xc.SelectNodes("rousage").Count > 0)
|
||||
AddROUsages(sect.MyContent, xc);
|
||||
if (xc.SelectNodes("transition").Count > 0)
|
||||
AddTransitions(sect.MyContent, xc);
|
||||
prevInfo = SectionInfo.Get(sect.ItemID);
|
||||
if (xc.HasChildNodes)
|
||||
AddParts(xc, prevInfo);
|
||||
using (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 this formatfile is a copy in this database (was not in exported database), use the copy name (note that the
|
||||
// Config data must match and this was checked in the code that loads the formats:
|
||||
if (formatid != string.Empty)
|
||||
{
|
||||
if (existingCopyFCName.ContainsKey(formatfilename)) formatfilename = existingCopyFCName[formatfilename];
|
||||
sect.MyContent.MyFormat = OldToNewFormat(int.Parse(formatid), formatfilename);
|
||||
}
|
||||
sect.MyContent.Config = config;
|
||||
sect.MyContent.DTS = dts;
|
||||
sect.MyContent.UserID = userid;
|
||||
sect.Save();
|
||||
if (!Old2NewContent.ContainsKey(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)))
|
||||
Old2NewContent.Add(int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText), sect.MyContent.ContentID);
|
||||
else
|
||||
Old2NewContent[int.Parse(xc.Attributes.GetNamedItem("contentid").InnerText)] = sect.MyContent.ContentID; // B2016-176, B2016-197 refresh saved ContentID with current ContentID
|
||||
if (!Old2NewItem.ContainsKey(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)))
|
||||
Old2NewItem.Add(int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText), sect.ItemID);
|
||||
else
|
||||
Old2NewItem[int.Parse(xn.Attributes.GetNamedItem("itemid").InnerText)] = sect.ItemID; // B2016-176, B2016-197 refresh saved ItemId with current ItemID
|
||||
if (xn.SelectNodes("annotation").Count > 0)
|
||||
AddAnnotations(sect.ItemID, xn);
|
||||
if (xc.SelectNodes("entry").Count > 0)
|
||||
AddEntry(sect.MyContent, xc);
|
||||
if (xc.SelectNodes("rousage").Count > 0)
|
||||
AddROUsages(sect.MyContent, xc);
|
||||
if (xc.SelectNodes("transition").Count > 0)
|
||||
AddTransitions(sect.MyContent, xc);
|
||||
prevInfo = SectionInfo.Get(sect.ItemID);
|
||||
if (xc.HasChildNodes)
|
||||
AddParts(xc, prevInfo);
|
||||
}
|
||||
return prevInfo;
|
||||
}
|
||||
private string StripEnhanced(string config)
|
||||
|
Reference in New Issue
Block a user