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,13 +1867,16 @@ namespace VEPROMS.CSLA.Library
ctmp.Save();
}
//ROFstInfo myrofst = tmp.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst;
ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion);
foreach(RoUsageInfo rou in tmp.ContentRoUsages)
if (tmp.ContentRoUsages.Count != 0) // B2017-118 If no ROUsages ignore ROFST
{
string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
int mytype = rocc.type;
ctmp.FixContentText(rou, myvalue, mytype, myRoFst);
ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion);
foreach (RoUsageInfo rou in tmp.ContentRoUsages)
{
string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
int mytype = rocc.type;
ctmp.FixContentText(rou, myvalue, mytype, myRoFst);
}
}
Content cctmp = ctmp;
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)
{
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
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);
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
RefreshRequired = true;
UpdateHistory();
myRTB.Clear();
@ -648,10 +650,12 @@ namespace Volian.Controls.Library
ItemInfo ii = null;
if (iai.Level == 2)
{
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
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);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
//_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
//ii.ItemParts[0].FromType
//ii.MyContent.Type
@ -718,10 +722,12 @@ namespace Volian.Controls.Library
}
else
{
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
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);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (ii.IsStep)
ii = StepInfo.Get(ii.ItemID);
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)
{
ContentAuditInfo cai = ContentAuditInfo.Get(gai.ContentAuditID);
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ROFstInfo myRoFst = null; // B2017-118 If No ROFST don't crash
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);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (myRoFst != null) myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
RefreshRequired = true;
UpdateHistory();
myRTB.Clear();