Handle Range Transitions for Invalid Transitions

Add a prefix to transitions converted to text which were invalid
Add counters for invalid transitions converted to text.
Added a method to convert invalid transitions to text
Cleanup debug
Changed the panel so that it only requires a default section if the default is not set and it is required
Fix invalid transitions when a step is activated.
Don't fail when you open a step with an invalid transition.
Display Transition Refresh Statistics
This commit is contained in:
Rich
2018-01-18 15:09:06 +00:00
parent 88db9605ed
commit 849b7230f2
7 changed files with 130 additions and 35 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;