check for null reference when deleting a source step that has associated enhanced (found during fix for B2016-228)

B2016-228: when creating section/procedure enhanced items, set ‘Number’
B2016-228: when modifying source section or procedure, save ‘Number’ also
B2016-198: User hold point no longer overwrites the ‘INIT/DATE’ signoff heading
This commit is contained in:
Kathy Ruffing 2016-11-29 13:52:43 +00:00
parent 1ff60597c3
commit 3a2759470d
4 changed files with 14 additions and 4 deletions

View File

@ -3077,6 +3077,7 @@ namespace VEPROMS.CSLA.Library
if (sc.MyEnhancedDocuments != null && sc.MyEnhancedDocuments.Count == 1 && sc.MyEnhancedDocuments[0].Type == 0)
{
ItemInfo ii = ItemInfo.Get(sc.MyEnhancedDocuments[0].ItemID);
if (ii == null) return false; // when deleting a source step, this was causing a crash (null ii)
return (ii.MyContent.DTS > MyProcedure.ChangeBarDate);
}
// if there is no override & return whether there was a change to the text.

View File

@ -1527,7 +1527,7 @@ namespace VEPROMS.CSLA.Library
if (exEnh.IsStep)
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
else
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, MyContent.Type, edSource.Type, this.ItemID);
}
}
iiCur = iiCur.MyPrevious;
@ -1546,7 +1546,7 @@ namespace VEPROMS.CSLA.Library
if (exEnh.IsStep)
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
else
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, MyContent.Type, edSource.Type, this.ItemID);
}
}
iiNxt = iiNxt.GetNextItem();
@ -1567,7 +1567,7 @@ namespace VEPROMS.CSLA.Library
{
// get the enhaced docversioninfo:
DocVersionInfo enhDVInfo = DocVersionInfo.Get(ded.VersionID);
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] : null, null, "New Procedure", 0))
using (Procedure newenhProcedure = Procedure.MakeProcedure(enhDVInfo, enhDVInfo.Procedures.Count != 0 ? enhDVInfo.Procedures[enhDVInfo.Procedures.Count - 1] :null, MyContent.Number, "New Procedure", 0))
{
newEnh = ItemInfo.Get(newenhProcedure.ItemID);
string scng = null;
@ -1596,7 +1596,7 @@ namespace VEPROMS.CSLA.Library
if (exEnh.IsStep)
newEnh = exEnh.InsertEnhancedSteps(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
else
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, null, addtype, MyContent.Type, edSource.Type, this.ItemID);
newEnh = exEnh.InsertEnhancedItems(MyContent.Text, MyContent.Number, addtype, MyContent.Type, edSource.Type, this.ItemID);
break;
}
}

View File

@ -638,6 +638,14 @@ namespace VEPROMS.CSLA.Library
DisplayText dt = new DisplayText(ii, ii.MyContent.Text, false);
string str = ItemInfo.Get(tmp.ContentItems[0].ItemID).DisplayTextKeepSpecialChars;
dt.Save(str);
if (tmp.Type < 20000 && ii.MyContent.Number != tmp.Number) // update number for sections & procedures, B2016-228
{
using (Content enhCont = Content.Get(ii.MyContent.ContentID))
{
enhCont.Number = tmp.Number;
enhCont.Save();
}
}
}
}
}

View File

@ -2558,6 +2558,7 @@ namespace Volian.Print.Library
get
{
if (TopMostChild.PartsAbove.Count == 0) return false;
if (TopMostChild.PartsContainer != null && TopMostChild.PartsContainer.Count > 0) return false; // B2016-198: not 'EmptyTopMostPart' if there is a box.
foreach (vlnPrintObject po in TopMostChild.PartsAbove)
{
vlnHeader hd = po as vlnHeader;