B2017-118 - Don't access RO Association unless there is a RO Usage

B2017-118 - Restore Children, Sibling, Text or Table cell text when no RO Association has been established
This commit is contained in:
Rich 2017-06-13 17:41:05 +00:00
parent 0d0bd7661b
commit 7ff0dbd98f
2 changed files with 29 additions and 18 deletions

View File

@ -1867,14 +1867,17 @@ namespace VEPROMS.CSLA.Library
ctmp.Save(); ctmp.Save();
} }
//ROFstInfo myrofst = tmp.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst; //ROFstInfo myrofst = tmp.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst;
if (tmp.ContentRoUsages.Count != 0) // B2017-118 If no ROUsages ignore ROFST
{
ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion); ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion);
foreach(RoUsageInfo rou in tmp.ContentRoUsages) foreach (RoUsageInfo rou in tmp.ContentRoUsages)
{ {
string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta); string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID); ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
int mytype = rocc.type; int mytype = rocc.type;
ctmp.FixContentText(rou, myvalue, mytype, myRoFst); ctmp.FixContentText(rou, myvalue, mytype, myRoFst);
} }
}
Content cctmp = ctmp; Content cctmp = ctmp;
if (ctmp.IsDirty) if (ctmp.IsDirty)
{ {

View File

@ -626,10 +626,12 @@ namespace Volian.Controls.Library
} }
if (MessageBox.Show(this, "Do you want to restore this content change?", "Confirm Content Change Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show(this, "Do you want to restore this content change?", "Confirm Content Change Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (MyItemInfo.MyDocVersion.DocVersionAssociations != null)
myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
if (myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ContentInfo ci = ContentInfo.RestoreContent(cai,myRoFst); ContentInfo ci = ContentInfo.RestoreContent(cai,myRoFst);
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
RefreshRequired = true; RefreshRequired = true;
UpdateHistory(); UpdateHistory();
myRTB.Clear(); myRTB.Clear();
@ -648,10 +650,12 @@ namespace Volian.Controls.Library
ItemInfo ii = null; ItemInfo ii = null;
if (iai.Level == 2) if (iai.Level == 2)
{ {
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if(MyItemInfo.MyDocVersion.DocVersionAssociations != null)
myRoFst= MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
if(myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ii = MyItemInfo.RestoreItem(iai,myRoFst); ii = MyItemInfo.RestoreItem(iai,myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
//_MyEditItem.AddChild((E_FromType)fromtype, contenttype); //_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
//ii.ItemParts[0].FromType //ii.ItemParts[0].FromType
//ii.MyContent.Type //ii.MyContent.Type
@ -718,10 +722,12 @@ namespace Volian.Controls.Library
} }
else else
{ {
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (MyItemInfo.MyDocVersion.DocVersionAssociations != null)
myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
if (myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ii = MyItemInfo.RestoreSibling(iai,myRoFst); ii = MyItemInfo.RestoreSibling(iai,myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (ii.IsStep) if (ii.IsStep)
ii = StepInfo.Get(ii.ItemID); ii = StepInfo.Get(ii.ItemID);
else if (ii.IsSection) else if (ii.IsSection)
@ -780,10 +786,12 @@ namespace Volian.Controls.Library
if (MessageBox.Show(this, "Do you want to restore this table?", "Confirm Table Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show(this, "Do you want to restore this table?", "Confirm Table Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
ContentAuditInfo cai = ContentAuditInfo.Get(gai.ContentAuditID); ContentAuditInfo cai = ContentAuditInfo.Get(gai.ContentAuditID);
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (MyItemInfo.MyDocVersion.DocVersionAssociations != null)
myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
if (myRoFst != null) myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ContentInfo ci = ContentInfo.RestoreContent(cai,myRoFst); ContentInfo ci = ContentInfo.RestoreContent(cai,myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate); if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
RefreshRequired = true; RefreshRequired = true;
UpdateHistory(); UpdateHistory();
myRTB.Clear(); myRTB.Clear();