B2021-115 The starting and ending steps were sometimes flipped when entering a “through” transition.

This commit is contained in:
John Jenko 2021-10-18 15:12:08 +00:00
parent 1f8be43773
commit bfaad2aa6a

View File

@ -1013,6 +1013,17 @@ namespace Volian.Controls.Library
{
if (sid.IsStepSection && sid.ActiveFormat.PlantFormat.FormatData.TransData.NoDefaultSectReq) return sid.ItemID;
}
// 3) Find if any of the section titles contain 'PROCEDURES STEPS'
foreach (SectionInfo sit in prcitm.Sections)
{
if (sit.DisplayText.ToUpper().Contains("PROCEDURE STEPS"))
return sit.ItemID;
}
foreach (SectionInfo sit in prcitm.Sections)
{
if (sit.DisplayText.ToUpper().Equals("PROCEDURE"))// bug fix: B2015-003
return sit.ItemID;
}
}
// 5) Display messagebox to tell user to specify which section should be used as the 'default section'.
//MessageBox.Show("No default step section was found. Set the appropriate Step Section as the default by using the Section Property Page, Format Tab.", "Transition using Default Step Section in Format", MessageBoxButtons.OK,MessageBoxIcon.Error);
@ -1135,6 +1146,46 @@ namespace Volian.Controls.Library
private void btnTranRangeClear_Click(object sender, EventArgs e)
{
ClearRangeTransition();
}
// B2021-115 - the start and end step of range transition were sometimes being flipped when they should not have been
// RangeItemAndToItemNeedsSwitch() was written to compare each item's short search path to determine if
// the starting step and the ending step (rangeitem) should be switched. This could happen if the the user
// selected a starting step that was after the ending step when creating the transition.
private bool RangeItemAndToItemNeedsSwitched(ItemInfo startItem, ItemInfo endItem)
{
// the ShortSearchPath is being used because each step level is represented as a number, even the the step tab is displayed as a letter
// i.e. if the step tab is "3.2.B", the ShortSearchPath would be "3.2.2"
// each step level in the ShortSearchPath is separated by '\a'
string[] startItemSearchPathList = startItem.ShortSearchPath.Split('\a');
string[] endItemSearchPathList = endItem.ShortSearchPath.Split('\a');
int ii = 0;
while (ii < startItemSearchPathList.Length && ii < endItemSearchPathList.Length)
{
if (startItemSearchPathList[ii] == endItemSearchPathList[ii]) ii++; // same at this level, check the next
else
{
// the tab strings are different, so check each "number" (level), split on the '.' that between each number in the tab string.
string[] ss = startItemSearchPathList[ii].Split('.');
string[] ee = endItemSearchPathList[ii].Split('.');
int iii = 0;
while (iii < ss.Length && iii < ee.Length)
{
int start = Convert.ToInt32(ss[iii]);
int end = Convert.ToInt32(ee[iii]);
if (start == end)
iii++; // The number is the same at this level
else if (start > end)
return true; // The starting transition step is after the ending transition step
else return false; // The starting transition step is before the ending transition step - no change needed
}
if (ss.Length > ee.Length)
return true; // The starting transition step is after (goes down one more level) the ending transition step
else
return false; // The ending transition step is after (goes down one more level) the starting transition step - no change needed
}
}
return false; // shouldn't hit this line because both the start and end steps are the same
}
private void btnTranSave_Click(object sender, EventArgs e)
{
@ -1196,8 +1247,7 @@ namespace Volian.Controls.Library
{
Boolean switchIds = false;
// check for order of hls first, then do within sibling list.
if (toItem.MyHLS.Ordinal > rangeItem.MyHLS.Ordinal) switchIds = true;
else if ((toItem.StepLevel == rangeItem.StepLevel) && toItem.Ordinal > rangeItem.Ordinal) switchIds = true; // B2017-040 don't switch if To and From HLS are not the same
switchIds = RangeItemAndToItemNeedsSwitched(toItem, rangeItem); // B2021-115 switchIds was being set to true when it should not have
if (switchIds)
{
ItemInfo switchItem = toItem;