B2018-043 The code to fix Invalid Transitions did not handle an instance where the Transition Text was missing. This fix will remove transitions with no text.
This commit is contained in:
parent
d5c8e1ae7e
commit
2dd35e476b
@ -712,6 +712,7 @@ namespace VEPROMS.CSLA.Library
|
||||
public static bool ConvertInvalidTransitionsToText(ItemInfo itemInfo)
|
||||
{
|
||||
bool retval = true;
|
||||
RemoveEmptyTransitions(itemInfo);//B2018-043 Cleanup Empty Transitions
|
||||
MatchCollection mc = Regex.Matches(itemInfo.MyContent.Text, @"\#Link\:Transition");
|
||||
if (itemInfo.MyContent.ContentTransitionCount <= 0 || mc.Count > itemInfo.MyContent.ContentTransitionCount)
|
||||
{
|
||||
@ -741,23 +742,8 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
else // B2018-043 Eliminate infinite loop for invalid transition structure
|
||||
{
|
||||
bool hasAnnotation = false;
|
||||
AnnotationType myType = AnnotationType.GetByNameOrCreate("Link Converted To Text");
|
||||
if (itemInfo.ItemAnnotations != null)
|
||||
{
|
||||
foreach (AnnotationInfo anot in itemInfo.ItemAnnotations)
|
||||
{
|
||||
if (anot.TypeID == myType.TypeID && anot.SearchText == "Invalid Transition Format")
|
||||
hasAnnotation = true;
|
||||
}
|
||||
if (!hasAnnotation)
|
||||
{
|
||||
using (Item myItem = itemInfo.Get())
|
||||
{
|
||||
Annotation.MakeAnnotation(myItem, myType, "", "Invalid Transition Format", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add annotation for Invalid Transition
|
||||
AddInvalidTransitionAnnotation(itemInfo,"Invalid Transition Format");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -765,6 +751,48 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static void AddInvalidTransitionAnnotation(ItemInfo itemInfo, string msg)
|
||||
{
|
||||
bool hasAnnotation = false;
|
||||
AnnotationType myType = AnnotationType.GetByNameOrCreate("Link Converted To Text");
|
||||
if (itemInfo.ItemAnnotations != null)
|
||||
{
|
||||
foreach (AnnotationInfo anot in itemInfo.ItemAnnotations)
|
||||
{
|
||||
if (anot.TypeID == myType.TypeID && anot.SearchText == msg)
|
||||
hasAnnotation = true;
|
||||
}
|
||||
if (!hasAnnotation)
|
||||
{
|
||||
using (Item myItem = itemInfo.Get())
|
||||
{
|
||||
Annotation.MakeAnnotation(myItem, myType, "", msg, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void RemoveEmptyTransitions(ItemInfo itemInfo)
|
||||
{
|
||||
ContentInfo myContent = itemInfo.MyContent;
|
||||
string txt = myContent.Text;
|
||||
string regDelete = @"(\\v |)\<START\]\#Link\:Transition(|Range)\:[0-9]+ [0-9]+ [0-9]+(| [0-9]+)\[END\>(\\v0 |)";
|
||||
string txt2=txt;
|
||||
do{
|
||||
txt = txt2;
|
||||
txt2 = Regex.Replace(txt, regDelete, "");
|
||||
} while(txt2 != txt);
|
||||
if(txt2 != myContent.Text)
|
||||
{
|
||||
using(Content tmp = myContent.Get())
|
||||
{
|
||||
tmp.Text = txt2;
|
||||
tmp.Save();
|
||||
}
|
||||
AddInvalidTransitionAnnotation(itemInfo, "Removed Empty Transition Text");
|
||||
}
|
||||
}
|
||||
//private static bool IsTransitionToDisconnected(TransitionInfo ti)
|
||||
//{
|
||||
// foreach (TransitionInfo til in TransitionsToDisconnected)
|
||||
|
Loading…
x
Reference in New Issue
Block a user