B2018-002 Handle Range Transitions for Invalid Transitions

Add a prefix to transitions converted to text which were invalid
B2018-002 Add counters for invalid transitions converted to text.
Added a method to convert invalid transitions to text
B2018-002 Cleanup debug
B2018-002 Changed the panel so that it only requires a default section if the default is not set and it is required
B2018-010 Logic fixed to display the Requires Default tooltip only when it is required.
B2018-002 Fix invalid transitions when a step is activated.
B2018-002 Don't fail when you open a step with an invalid transition.
B2018-002 Display Transition Refresh Statistics
This commit is contained in:
Rich 2018-01-24 14:47:34 +00:00
parent 58c23de1ea
commit 01ce36b86a
7 changed files with 133 additions and 37 deletions

View File

@ -46,7 +46,11 @@ namespace VEPROMS.CSLA.Library
string lookFor;
if (tran == null)
{
int loc1 = Text.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
// B2018-002 - Invalid Transitions - Handle Range Transitions
int loc1 = Text.IndexOf("#Link:Transition:", 0);
if(loc1 > 0) loc1+=("#Link:Transition:").Length;
else
loc1 = Text.IndexOf("#Link:TransitionRange:", 0)+ ("#Link:TransitionRange:").Length;;
int loc2 = Text.IndexOf(" ", loc1);
string trantype = Text.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
@ -77,8 +81,12 @@ namespace VEPROMS.CSLA.Library
using (Item myitem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// B2016-225 (follow through) added more descriptive Annotation Type when transition is converted to text
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", string.Format("Transition ({0}) converted to text", ItemInfo.ConvertToDisplayText(gg)), null);
// B2016-225 (follow through) added more descriptive Annotation Type when transition is converted to text]
//Check for validity
// B2018-002 - Invalid Transitions - Add a prefix of invalid if the transition record is missing
string prefix = "";
if (tran == null) prefix = "Invalid ";
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", prefix + string.Format("Transition ({0}) converted to text", ItemInfo.ConvertToDisplayText(gg)), null);
}
if(tran != null)
Transition.Delete(tran.TransitionID);
@ -174,7 +182,12 @@ namespace VEPROMS.CSLA.Library
string lookFor;
if (tran == null)
{
int loc1 = MyGrid.Data.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
// B2018-002 - Invalid Transitions - Added code to support range transitions
int loc1 = MyGrid.Data.IndexOf("#Link:Transition:", 0);
if (loc1 > 0) loc1 += ("#Link:Transition:").Length;
else
loc1 = MyGrid.Data.IndexOf("#Link:TransitionRange:", 0) + ("#Link:TransitionRange:").Length; ;
//int loc1 = MyGrid.Data.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
int loc2 = MyGrid.Data.IndexOf(" ", loc1);
string trantype = MyGrid.Data.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
@ -228,7 +241,11 @@ namespace VEPROMS.CSLA.Library
string lookFor;
if (tran == null)
{
int loc1 = Text.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
// B2018-002 - Invalid Transitions - Added code to support range transitions
int loc1 = Text.IndexOf("#Link:Transition:", 0);
if (loc1 > 0) loc1 += ("#Link:Transition:").Length;
else
loc1 = Text.IndexOf("#Link:TransitionRange:", 0) + ("#Link:TransitionRange:").Length; ;
int loc2 = Text.IndexOf(" ", loc1);
string trantype = Text.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
@ -758,7 +775,8 @@ namespace VEPROMS.CSLA.Library
return _CacheByPrimaryKey.ContainsKey(contentID.ToString());
}
public static event StaticContentInfoEvent StaticContentInfoChange;
private static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
// B2018-002 - Invalid Transitions - Changed to Public
public static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (StaticContentInfoChange != null)
StaticContentInfoChange(sender, args);

View File

@ -590,9 +590,11 @@ namespace VEPROMS.CSLA.Library
{
TranCheckCount = 0;
TranFixCount = 0;
TranConvertCount = 0;// B2018-002 - Invalid Transitions - Initialize Transition Conversion Count
}
public static int TranCheckCount = 0;
public static int TranFixCount = 0;
public static int TranConvertCount = 0;// B2018-002 - Invalid Transitions - Declare Transition Conversion Count
internal static TransitionInfoList TransitionsToDisconnected;
internal static TransitionInfoList TransitionsToNonEditable;
internal static void MyRefreshTransitions(ItemInfo itemInfo, IVEDrillDownReadOnly itemParent, SectionInfo sectionInfo, ProcedureInfo procInfo, DocVersionInfo docVersionInfo, TransitionLookup tranLookup)
@ -621,7 +623,9 @@ namespace VEPROMS.CSLA.Library
//foreach (ItemInfo ii in myItems)
MyRefreshTransitions(ii, itemInfo, (itemInfo as SectionInfo) ?? sectionInfo, procInfo, docVersionInfo, tranLookup);
}
if (itemInfo.MyContent.ContentTransitionCount > 0)
// B2018-002 - Invalid Transitions - Convert Invalid Transitions to Text
// An invalid transition is a transition embedded in the content text that does not match the transition table record.
if(ConvertInvalidTransitionsToText(itemInfo))
{
itemInfo.ResetOrdinal();
foreach (TransitionInfo traninfo in itemInfo.MyContent.ContentTransitions)
@ -661,14 +665,14 @@ namespace VEPROMS.CSLA.Library
if (itemInfo.MyProcedure.ItemID != traninfo.MyItemToID.MyProcedure.ItemID) //different proc
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("other proc")) //B2017-068 paste with transition fix
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to External Procedure using Internal Format");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
}
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to External Procedure using Internal Format");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
}
}
if (!forceConvertToText)
{
@ -676,14 +680,14 @@ namespace VEPROMS.CSLA.Library
{
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("other proc")) //B2017-068 paste with transition fix
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to Outside Procedure using Internal Format");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
}
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to Outside Procedure using Internal Format");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
}
}
}
if (!forceConvertToText)
@ -693,7 +697,7 @@ namespace VEPROMS.CSLA.Library
string newText = itemInfo.MyContent.Text;
// B2017-165 added check of newValue (special case for old 16-bit transition that was not fixed by the customer)
string newValue = traninfo.ResolvePathTo(itemInfo.ActiveFormat, itemInfo, traninfo.TranType, traninfo.MyItemToID, traninfo.MyItemRangeID);
if (newText != oldText|| newValue == "?")
if (newText != oldText || newValue == "?")
{
TranFixCount++;
Content content = Content.Get(itemInfo.MyContent.ContentID);
@ -704,6 +708,42 @@ namespace VEPROMS.CSLA.Library
}
}
}
// // B2018-002 - Invalid Transitions - Method to check for invalid transitions and convert them to text
public static bool ConvertInvalidTransitionsToText(ItemInfo itemInfo)
{
bool retval = true;
MatchCollection mc = Regex.Matches(itemInfo.MyContent.Text, @"\#Link\:Transition");
if (itemInfo.MyContent.ContentTransitionCount <= 0 || mc.Count > itemInfo.MyContent.ContentTransitionCount)
{
retval = false;
if (itemInfo.MyContent.Text.Contains("Link:Transition"))
{
//Console.WriteLine("\"TranCount\"\t\"{0}\"\t{1}\t{2}\t{3}", itemInfo.ShortPath, itemInfo.ItemID, mc.Count, itemInfo.MyContent.ContentTransitionCount);
Content content = Content.Get(itemInfo.MyContent.ContentID);
//if (itemInfo.InList(616031, 615898, 5516866))
// Console.WriteLine("here");
if (itemInfo.MyContent.ContentTransitions != null)
foreach (TransitionInfo ct in itemInfo.MyContent.ContentTransitions)
Transition.Delete(ct.TransitionID);
itemInfo.MyContent.RefreshContentTransitions();
//if (content.Text.Contains("Link:TransitionRange"))
// Console.WriteLine("Here");
while (content.Text.Contains("Link:Transition"))
{
TranCheckCount++;
TranConvertCount++;
if (content.FixTransitionText(null, true))
{
ContentInfo.OnStaticContentInfoChange(itemInfo, new StaticContentInfoEventArgs("", "", ""));
if (itemInfo.MyContent.MyGrid != null)
content.ConvertTransitionToTextInGrid(null, null);
content.Save();
}
}
}
}
return retval;
}
//private static bool IsTransitionToDisconnected(TransitionInfo ti)
//{
// foreach (TransitionInfo til in TransitionsToDisconnected)

View File

@ -1456,8 +1456,6 @@ namespace VEPROMS.CSLA.Library
string str = BuildSectionPath(ToSections);
str = Regex.Replace(str, @"\<U\>", tb._ToItem.MyDocVersion.DocVersionConfig.Unit_Number, RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\<ID\>", tb._ToItem.MyDocVersion.DocVersionConfig.Unit_ID, RegexOptions.IgnoreCase);
if(str != str1)
Console.WriteLine("Difference In Strings: {0}\r\n{1}",str,str1);
//if (!str.EndsWith(".") && tb._ToItem.ItemID != tb._ToItem.ActiveSection.ItemID)
tb.StepPrefix = ".";
tb.SectionNumberLength = str.Length;

View File

@ -162,7 +162,8 @@ namespace Volian.Controls.Library
_OrigGroupPanelProcs = groupPanelTransitionProcs.Style.BackColor;
_OrigGroupPanelSects = groupPanelTransitionSect.Style.BackColor;
_OrigGroupPanelSteps = groupPanelTranstionSteps.Style.BackColor;
// B2018-002 - Invalid Transitions - Get default section - side effect sets HasDefault
if (_CurItemFrom != null) FindSectionStart(_CurItemFrom.MyProcedure);
ListBoxTranFmtFillIn();
// if new, use _CurItemFrom to setup the initial selections in the controls,
@ -214,6 +215,7 @@ namespace Volian.Controls.Library
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
if ((etm & E_TransUI.SectDefault) == E_TransUI.SectDefault)
{
NeedsDefault = true; // B2018-002 - Invalid Transitions - if (SectDefault set in TransFormat set NeedsDefault to true
secStartId = FindSectionStart(_CurrentProcedure);
if (secStartId > -1)
{
@ -223,6 +225,10 @@ namespace Volian.Controls.Library
else
btnTranSave.Enabled = false; // if there is an invalid section start - don't allow save.
}
else
{
NeedsDefault = false;// B2018-002 - Invalid Transitions - if (SectDefault not set in TransFormat set NeedsDefault to false
}
cbTranSectsFillIn(secitm, secitm == null ? -1 : secStartId, true);
// Fill step items, passing in the active step to the selected item, or the first
// step if the selection was not at the step level.
@ -248,6 +254,7 @@ namespace Volian.Controls.Library
tvTran.Nodes.Clear();
}
SetControlsEnabling();
SaveCancelEnabling();// B2018-002 - Invalid Transitions - Set button enabled or disabled
}
private void tvInitHiliteRange() //bool rangeSameLevel, ItemInfo stpitm, ItemInfo rngitm, int uplevel)
{
@ -474,9 +481,12 @@ namespace Volian.Controls.Library
listBoxTranFmt.Items.Add(new TransItem(ttl[i].TransMenu.Replace("?.",""),ttl[i].TransFormat.Replace("?.","")));
//listBoxTranFmt.Items.Add(ttl[i].TransFormat.Replace("?.",""));
listBoxTranFmt.SelectedIndex = _TranFmtIndx;
groupPanelTranFmt.Style.BackColor = (_CurTrans == null && _TranFmtIndx==0) ? Color.Yellow : Color.Orange;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
_DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast;
// B2018-002 - Invalid Transitions - Determine if a default section is required for this format
NeedsDefault = ((etm & E_TransUI.SectDefault) == E_TransUI.SectDefault);
// B2018-002 - Invalid Transitions - Set backcolor to red if it doesn't have a default section and it Needs a Default Section
groupPanelTranFmt.Style.BackColor = !HasDefault && NeedsDefault ? Color.Red : Color.Orange;
}
private void tvTranFillIn(ItemInfo startitm)
{
@ -595,6 +605,8 @@ namespace Volian.Controls.Library
}
// Do section combo, in 16-bit system it was types 0, 3, 4, 5
// B2018-002 - Invalid Transitions - Determine if a default section is required for this format
NeedsDefault = (etm & E_TransUI.SectDefault) == E_TransUI.SectDefault;
if (cbTranSects.Items.Count > 0 &&
( (((etm & E_TransUI.SectDefault) == E_TransUI.SectDefault &&
_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.DoSectionTransitions) ||
@ -800,11 +812,15 @@ namespace Volian.Controls.Library
IList chldrn = _CurrentProcedure.GetChildren();
int secIdForCbSect = secitm == null ? sectstartid : secitm.ItemID;
// if this transition format requires the default section, use it:
if ((etmnew & E_TransUI.SectDefault) == E_TransUI.SectDefault) secIdForCbSect = sectstartid;
if ((etmnew & E_TransUI.SectDefault) == E_TransUI.SectDefault)
secIdForCbSect = sectstartid;
if (chldrn != null && chldrn.Count > 0) cbTranSectsFillIn((ItemInfo)chldrn[0], secIdForCbSect, true); //sectstartid);
}
// B2018-002 - Invalid Transitions - Determine if Default Section is required
NeedsDefault = ((etmnew & E_TransUI.SectDefault) == E_TransUI.SectDefault);
_TranFmtIndx = listBoxTranFmt.SelectedIndex;
groupPanelTranFmt.Style.BackColor = (_CurTrans == null && _TranFmtIndx == 0) ? Color.Yellow : Color.Orange;
// B2018-002 - Invalid Transitions - Set the backcolor to red if it doesn't have a default section and it needs one
groupPanelTranFmt.Style.BackColor = !HasDefault && NeedsDefault ? Color.Red : Color.Orange;
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[_TranFmtIndx].TransUI;
_DoingRange = (etm & E_TransUI.StepLast) == E_TransUI.StepLast;
// get section selected and if it's a step section, fill in the treeview of steps
@ -883,8 +899,12 @@ namespace Volian.Controls.Library
SaveCancelEnabling();
}
}
// B2018-002 - Invalid Transitions - Declare Default Section variables
private bool NeedsDefault;
private bool HasDefault;
private int FindSectionStart(ItemInfo prcitm)
{
HasDefault = true;// B2018-002 - Invalid Transitions - Initialize Has Default to true
// Steps to get the section start. continue down list until finding a valid id. If none is found
// put up a message dialog - and if returns a result of -1, caller should disable the 'ok' button
// so that a transition cannot be entered until the default section is defined:
@ -959,7 +979,8 @@ namespace Volian.Controls.Library
}
}
// 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);
//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);
HasDefault = false;// B2018-002 - Invalid Transitions - Set Has default to false
return -1;
}
private void cbTranProcs_SelectedIndexChanged(object sender, EventArgs e)
@ -1032,8 +1053,20 @@ namespace Volian.Controls.Library
// || ( selii != null && _CurTrans.ToID != selii.ItemID);
bool hasChanged = SettingsChanged;
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnTranSave.Enabled = !isenh && hasChanged && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
// B2018-002 - Invalid Transitions - Set button enabled if it has a default section or it doesn't need a default
btnTranSave.Enabled = (HasDefault || !NeedsDefault) && !isenh && hasChanged && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
btnTranCancel.Enabled = _CurTrans != null && hasChanged;
groupPanelTranFmt.Text = (!HasDefault && NeedsDefault) ? "Requires Default" : "Select Format";
// B2018-002 - Invalid Transitions - Set tool tip based upon HasDefault and NeedsDefault
if (!HasDefault && NeedsDefault)// B2018-010 Logic was incorrect to determine which tooltip to show
this.superToolTipDispTran.SetSuperTooltip(this.listBoxTranFmt,
new DevComponents.DotNetBar.SuperTooltipInfo("Requires Default", "",
"The selected Transition Format requires a Default Section.\r\n" +
"This can be set on the format tab of the section property window.", null, null, DevComponents.DotNetBar.eTooltipColor.Yellow));
else
this.superToolTipDispTran.SetSuperTooltip(this.listBoxTranFmt, new DevComponents.DotNetBar.SuperTooltipInfo("", "",
"This is where transition types are selected. This also defines how the transition will look in the text.",
null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
//btnTranSave.Enabled = allowSave;
//if (CurTrans != null && selii != null)
//{

View File

@ -445,7 +445,8 @@ namespace Volian.Controls.Library
EditItem lastEI = _SelectedEditItem;
if (value != null) value.SetActive(); // Set the active color
if (lastEI == value) return; // Same - No Change
// B2018-002 - Invalid Transitions - If the current step contains an invalid transition convert it to text
if(value != null) ItemInfo.ConvertInvalidTransitionsToText(value.MyItemInfo);
if (lastEI != null && lastEI.BeingDisposed == false)
{
bool shouldDelete = !lastEI.BeingRemoved && lastEI.Empty && (lastEI.MyItemInfo.MyContent.ContentEntryCount <= 0);

View File

@ -281,6 +281,12 @@ namespace Volian.Controls.Library
{
if (args.MyLinkText.LinkInfoText.IndexOf("Transition") > -1)
{
// B2018-002 - Invalid Transitions - Don't fail on invalid transition
if(args.MyLinkText.MyTransitionInfo == null)
{
MessageBox.Show("This transition is invalid\r\n\r\nDelete it and replace it with \r\na valid transition", "Invalid Transition", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return; // Not a valid transition
}
ItemInfo item = args.MyLinkText.MyTranToItemInfo;
if (item == null || item.MyDocVersion == null || (item.PreviousID == null && item.ItemPartCount == 0 && item.ItemDocVersionCount == 0))
{

View File

@ -3317,22 +3317,22 @@ namespace Volian.Controls.Library
}
private void btnTranRefresh_Click(object sender, System.EventArgs e)
{
// This code is disabled - Button is not visible
this.Cursor = Cursors.WaitCursor;
ProcedureInfo.RefreshTransitions(MyItemInfo.MyProcedure as ProcedureInfo);
this.Cursor = Cursors.Default;
// B2018-002 - Invalid Transitions - Display Transition Refresh Statistics
//MessageBox.Show(this, string.Format("Checked {0} transitions, modified {1} transitions, converted to text {2} transitions", ProcedureInfo.TranCheckCount, ProcedureInfo.TranFixCount, ProcedureInfo.TranConvertCount), "Results of Refresh Transitions", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(this, string.Format("Checked {0} transitions, modified {1} transitions, converted to text {2} transitions", ProcedureInfo.TranCheckCount, ProcedureInfo.TranFixCount, ProcedureInfo.TranConvertCount), "Results of Refresh Transitions", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnRefObjRefresh_Click(object sender, System.EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
// This code is disabled - Button is not visible
this.Cursor = Cursors.WaitCursor;
ProcedureInfo.ResetROCounters();
ProcedureInfo.RefreshReferenceObjects(MyItemInfo.MyProcedure as ProcedureInfo);
this.Cursor = Cursors.Default;
MessageBox.Show(this, string.Format("Checked {0} referenced objects, fixed {1} referenced objects", ProcedureInfo.ROCheckCount, ProcedureInfo.ROFixCount), "Results of Refresh Referenced Objects", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
//private FindReplace dlgFindReplace = null;
private void btnFindRplDlg_Click(object sender, EventArgs e)
{