B2018-025: Proms crashes opening Working Draft if associated enhanced Working Draft had been deleted

This commit is contained in:
Kathy Ruffing 2018-03-01 15:34:22 +00:00
parent 181008c9f9
commit 60b83e9926
3 changed files with 48 additions and 7 deletions

View File

@ -60,6 +60,7 @@ namespace VEPROMS
public frmVersionsProperties(DocVersionConfig docVersionConfig) public frmVersionsProperties(DocVersionConfig docVersionConfig)
{ {
_DocVersionConfig = docVersionConfig; _DocVersionConfig = docVersionConfig;
docVersionConfig.RefreshMyEnhancedDocuments();
_Initializing = true; _Initializing = true;
InitializeComponent(); InitializeComponent();
btnGeneral.PerformClick(); // always start with General tab or button btnGeneral.PerformClick(); // always start with General tab or button
@ -195,6 +196,7 @@ namespace VEPROMS
dvc.SaveDVEnhancedDocuments(); dvc.SaveDVEnhancedDocuments();
dv.Config = dvc.ToString(); dv.Config = dvc.ToString();
dv.Save(); dv.Save();
DocVersionInfo.Refresh(dv);
} }
} }
} }

View File

@ -19,12 +19,24 @@ namespace VEPROMS.CSLA.Library
DVEnhancedDocuments eds = new DVEnhancedDocuments(); DVEnhancedDocuments eds = new DVEnhancedDocuments();
foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced")) foreach (XmlNode xn in _Xp.XmlContents.SelectNodes("//Enhanced"))
{ {
eds.Add( xn.Attributes["Name"].Value, int dvid = int.Parse(xn.Attributes["VersionID"].Value);
int.Parse(xn.Attributes["Type"].Value), DocVersionInfo dvi = DocVersionInfo.Get(dvid);
int.Parse(xn.Attributes["VersionID"].Value), if (dvi != null)
int.Parse(xn.Attributes["PdfX"].Value), {
xn.Attributes["PdfToken"].Value 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; return eds;
} }
@ -103,6 +115,17 @@ namespace VEPROMS.CSLA.Library
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]
public class DocVersionConfig : ConfigDynamicTypeDescriptor, INotifyPropertyChanged 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; private DVEnhancedDocuments _MyEnhancedDocuments = null;
public DVEnhancedDocuments MyEnhancedDocuments public DVEnhancedDocuments MyEnhancedDocuments
{ {

View File

@ -2950,7 +2950,23 @@ namespace Volian.Controls.Library
{ {
foreach (DVEnhancedDocument dve in dvc.MyEnhancedDocuments) 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); DocVersion.Delete(_LastDocVersionInfo.VersionID);