diff --git a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs index 66419b0c..a49f25b3 100644 --- a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs +++ b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs @@ -60,6 +60,7 @@ namespace VEPROMS public frmVersionsProperties(DocVersionConfig docVersionConfig) { _DocVersionConfig = docVersionConfig; + docVersionConfig.RefreshMyEnhancedDocuments(); _Initializing = true; InitializeComponent(); btnGeneral.PerformClick(); // always start with General tab or button @@ -195,6 +196,7 @@ namespace VEPROMS dvc.SaveDVEnhancedDocuments(); dv.Config = dvc.ToString(); dv.Save(); + DocVersionInfo.Refresh(dv); } } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs index 35dd29b8..bf0590e0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/DocVersionConfig.cs @@ -19,12 +19,24 @@ namespace VEPROMS.CSLA.Library DVEnhancedDocuments eds = new DVEnhancedDocuments(); foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced")) { - eds.Add( xn.Attributes["Name"].Value, - int.Parse(xn.Attributes["Type"].Value), - int.Parse(xn.Attributes["VersionID"].Value), - int.Parse(xn.Attributes["PdfX"].Value), - xn.Attributes["PdfToken"].Value - ); + int dvid = int.Parse(xn.Attributes["VersionID"].Value); + DocVersionInfo dvi = DocVersionInfo.Get(dvid); + if (dvi != null) + { + eds.Add(xn.Attributes["Name"].Value, + int.Parse(xn.Attributes["Type"].Value), + int.Parse(xn.Attributes["VersionID"].Value), + int.Parse(xn.Attributes["PdfX"].Value), + xn.Attributes["PdfToken"].Value + ); + } + else + { + // B2018-025: If there is config data in the source pointing to a non-existent enhanced, remove + // this from the internal data structure so no errors will occur: + XmlNode xnx = _Xp.XmlContents.SelectSingleNode(string.Format("//Enhanced[@VersionID='{0}']", dvid)); + xnx.ParentNode.RemoveChild(xnx); + } } return eds; } @@ -103,6 +115,17 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class DocVersionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged { + // B2018-025: Allow refresh of enhanced document data structure, RefreshMyEnhancedDocuments, and remove link data, RemoveEnhancedLink. + public void RefreshMyEnhancedDocuments() + { + _MyEnhancedDocuments = null; + } + public void RemoveEnhancedLink(int dvid) + { + // from this config, remove the link to the input dvid: + XmlNode xnx = _Xp.XmlContents.SelectSingleNode(string.Format("//Enhanced[@VersionID='{0}']", dvid)); + xnx.ParentNode.RemoveChild(xnx); + } private DVEnhancedDocuments _MyEnhancedDocuments = null; public DVEnhancedDocuments MyEnhancedDocuments { diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 12762d58..dce61be4 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -2950,7 +2950,23 @@ namespace Volian.Controls.Library { foreach (DVEnhancedDocument dve in dvc.MyEnhancedDocuments) { - if (dve.Type != 0) DocVersion.Delete(dve.VersionID); + if (dve.Type != 0) + DocVersion.Delete(dve.VersionID); + else + { + // B2018-025: for the input source docversion (id), clear out its enhanced document link information + // dvi is the source, remove this (_LastDocVersionInfo) background link from the source's config + DocVersionInfo dvi = DocVersionInfo.Get(dve.VersionID); + DocVersionConfig dvci = dvi.MyConfig as DocVersionConfig; + dvci.RemoveEnhancedLink(_LastDocVersionInfo.VersionID); + string dvccfg = dvci.ToString(); + using (DocVersion dv = dvi.Get()) + { + dv.Config = dvccfg; + dv.Save(); + DocVersionInfo.Refresh(dv); + } + } } } DocVersion.Delete(_LastDocVersionInfo.VersionID);