Added code to support conversion to text of invalid referenced objects and invalid transitions
Added command line switch NOUPDATERO to prevent updating referenced objects Added code to support conversion to text of invalid transitions
This commit is contained in:
@@ -18,6 +18,10 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran)
|
||||
{
|
||||
FixTransitionText(tran, false);
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, bool forceConvertToText)
|
||||
{
|
||||
//string transText = tran.ResolvePathTo();
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
////string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
@@ -29,6 +33,8 @@ namespace VEPROMS.CSLA.Library
|
||||
// Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
//}
|
||||
string newvalue = tran.ResolvePathTo();
|
||||
if (forceConvertToText)
|
||||
newvalue = "?";
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
@@ -38,7 +44,7 @@ namespace VEPROMS.CSLA.Library
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
int myIndex = m.Groups[4].Index + mm.Index;
|
||||
int myIndex = m.Groups[4].Index + mm.Index;
|
||||
int myLength = m.Groups[4].Length;
|
||||
if (m.Groups[3].Value != " ")
|
||||
{
|
||||
@@ -47,7 +53,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
string gg = Text.Substring(myIndex, myLength);
|
||||
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
|
||||
if (gg != newvalue)
|
||||
if (gg != newvalue && newvalue == "?")
|
||||
{
|
||||
string rv = ConvertTransitionToText(tran, newvalue);
|
||||
//Text = Text.Substring(0, myIndex - 14) + gg + Text.Substring(myIndex + myLength);
|
||||
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, ItemInfo.VolianCommentType, "", string.Format("Transition ({0}) converted to text", ItemInfo.ConvertToDisplayText(gg)), null);
|
||||
break;
|
||||
}
|
||||
else if (gg != newvalue)
|
||||
{
|
||||
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
|
||||
break; // Text has been processed
|
||||
@@ -106,6 +119,120 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
public string ConvertTransitionToText(TransitionInfo tran, string value)
|
||||
{
|
||||
string retval = null;
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
//string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
|
||||
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
int lastIndex = 0;
|
||||
string newText = Text;
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
int offset = mm.Index;
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
string prefix = GetMyPrefix(mm.Index, lastIndex);
|
||||
string suffix = GetMySuffix(mm.Index + mm.Length);
|
||||
int myIndex = m.Groups[4].Index + mm.Index;
|
||||
int myLength = m.Groups[4].Length;
|
||||
if (m.Groups[3].Value != " ")
|
||||
{
|
||||
myIndex = m.Groups[3].Index + mm.Index;
|
||||
myLength += m.Groups[3].Length;
|
||||
}
|
||||
string gg = newText.Substring(myIndex, myLength);
|
||||
retval = gg;
|
||||
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
|
||||
string part1 = newText.Substring(0, mm.Index);
|
||||
string part2 = gg;
|
||||
string part3 = newText.Substring(mm.Index + mm.Length);
|
||||
//modify part1 based on prefix
|
||||
if (prefix == @"\v ")
|
||||
part1 = part1.Substring(0, part1.Length - 3);
|
||||
else
|
||||
part1 = part1.Substring(0, part1.Length - 3) + " ";
|
||||
//modify part3 based on suffix
|
||||
if (suffix == @"\v0 ")
|
||||
part3 = part3.Substring(4);
|
||||
else
|
||||
part3 = suffix.Replace(@"\v0", "") + part3.Substring(suffix.Length);
|
||||
if (gg.Contains(@"\u8209?"))
|
||||
{
|
||||
Match mmm = Regex.Match(gg, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||
if (mmm == null)
|
||||
newvalue = newvalue.Replace(@"\u8209?", "-");
|
||||
else
|
||||
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
|
||||
}
|
||||
Text = part1 + part2 + part3;
|
||||
break; // Text has been processed
|
||||
}
|
||||
lastIndex = mm.Index + mm.Length;
|
||||
}
|
||||
Console.WriteLine("Text: {0} NewText: {1}", Text, newText);
|
||||
return retval;
|
||||
}
|
||||
public string ConvertTransitionToText(int tranID, int tranType, string value)
|
||||
{
|
||||
string retval = null;
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tranType, tranID);
|
||||
int lastIndex = 0;
|
||||
string newText = Text;
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
int offset = mm.Index;
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
string prefix = GetMyPrefix(mm.Index, lastIndex);
|
||||
string suffix = GetMySuffix(mm.Index + mm.Length);
|
||||
int myIndex = m.Groups[4].Index + mm.Index;
|
||||
int myLength = m.Groups[4].Length;
|
||||
if (m.Groups[3].Value != " ")
|
||||
{
|
||||
myIndex = m.Groups[3].Index + mm.Index;
|
||||
myLength += m.Groups[3].Length;
|
||||
}
|
||||
string gg = newText.Substring(myIndex, myLength);
|
||||
retval = gg;
|
||||
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
|
||||
string part1 = newText.Substring(0, mm.Index);
|
||||
string part2 = gg;
|
||||
string part3 = newText.Substring(mm.Index + mm.Length);
|
||||
//modify part1 based on prefix
|
||||
if (prefix == @"\v ")
|
||||
part1 = part1.Substring(0, part1.Length - 3);
|
||||
else
|
||||
part1 = part1.Substring(0, part1.Length - 3) + " ";
|
||||
//modify part3 based on suffix
|
||||
if (suffix == @"\v0 ")
|
||||
part3 = part3.Substring(4);
|
||||
else
|
||||
part3 = suffix.Replace(@"\v0", "") + part3.Substring(suffix.Length);
|
||||
if (gg.Contains(@"\u8209?"))
|
||||
{
|
||||
Match mmm = Regex.Match(gg, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||
if (mmm == null)
|
||||
newvalue = newvalue.Replace(@"\u8209?", "-");
|
||||
else
|
||||
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
|
||||
}
|
||||
Text = part1 + part2 + part3;
|
||||
break; // Text has been processed
|
||||
}
|
||||
lastIndex = mm.Index + mm.Length;
|
||||
}
|
||||
Console.WriteLine("Text: {0} NewText: {1}", Text, newText);
|
||||
return retval;
|
||||
}
|
||||
private string GetMySuffix(int start)
|
||||
{
|
||||
string txt = Text.Substring(start);
|
||||
@@ -159,6 +286,7 @@ namespace VEPROMS.CSLA.Library
|
||||
myLength += m.Groups[3].Length;
|
||||
}
|
||||
string gg = newText.Substring(myIndex, myLength);
|
||||
retval = gg;
|
||||
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
|
||||
string part1 = newText.Substring(0, mm.Index);
|
||||
string part2 = gg;
|
||||
@@ -271,6 +399,12 @@ namespace VEPROMS.CSLA.Library
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo,string fileNameOnly) // string newvalue)
|
||||
{
|
||||
string retval = null;
|
||||
if (value == "?")
|
||||
{
|
||||
retval = this.ConvertROToText(rousg, value, rotype, origROFstInfo);
|
||||
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, ItemInfo.VolianCommentType, "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(retval)), null);
|
||||
return retval;
|
||||
}
|
||||
string newvalue = value;
|
||||
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
@@ -407,9 +541,12 @@ namespace VEPROMS.CSLA.Library
|
||||
if (id == ContentID) return true;
|
||||
return false;
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii)
|
||||
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii)
|
||||
{
|
||||
FixTransitionText(tran, tranLookup, ii, false);
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, bool forceConvertToText)
|
||||
{
|
||||
if (ii.InList(4706)) Console.WriteLine("jcb");
|
||||
//string transText = tran.ResolvePathTo();
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
////string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
@@ -427,6 +564,8 @@ namespace VEPROMS.CSLA.Library
|
||||
newvalue = tran.ResolvePathTo();
|
||||
else
|
||||
newvalue = tran.ResolvePathTo(tranLookup);
|
||||
if (forceConvertToText)
|
||||
newvalue = "?";
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
@@ -510,7 +649,11 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, ItemInfo ii)
|
||||
{
|
||||
FixTransitionText(tran, null, ii);
|
||||
FixTransitionText(tran, ii, false);
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, bool forceConvertToText)
|
||||
{
|
||||
FixTransitionText(tran, null, ii, forceConvertToText);
|
||||
//string transText = tran.ResolvePathTo(tranLookup);
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
////string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
|
Reference in New Issue
Block a user