Modified how ROs and Transitions are updated based on issues identified by Calvert data. Modified FixTransitionText, ConvertROToText, and FixContentText methods of Content and ContentInfo classes. Added GetMySuffix and GetMyPrefix methods to Content class
This commit is contained in:
parent
7c21fdd3d3
commit
a0402016df
@ -18,58 +18,243 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public void FixTransitionText(TransitionInfo tran)
|
public void FixTransitionText(TransitionInfo tran)
|
||||||
{
|
{
|
||||||
string transText = tran.ResolvePathTo();
|
//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\](\\[^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);
|
////string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||||
Match m = Regex.Match(Text, lookFor);
|
//Match m = Regex.Match(Text, lookFor);
|
||||||
|
//if (m != null && m.Groups.Count > 1)
|
||||||
|
//{
|
||||||
|
// System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||||
|
// if (g.ToString() != transText)
|
||||||
|
// Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||||
|
//}
|
||||||
|
string newvalue = tran.ResolvePathTo();
|
||||||
|
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:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||||
|
foreach (Match mm in ms)
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||||
if (m != null && m.Groups.Count > 1)
|
if (m != null && m.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
int myIndex = m.Groups[4].Index + mm.Index;
|
||||||
if (g.ToString() != transText)
|
int myLength = m.Groups[4].Length;
|
||||||
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
if (m.Groups[3].Value != " ")
|
||||||
|
{
|
||||||
|
myIndex = m.Groups[3].Index + mm.Index;
|
||||||
|
myLength += m.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = Text.Substring(myIndex, myLength);
|
||||||
|
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
|
||||||
|
if (gg != newvalue)
|
||||||
|
{
|
||||||
|
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
|
||||||
|
break; // Text has been processed
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// see if there is a grid to update too.
|
// see if there is a grid to update too.
|
||||||
if (tran.MyContent.MyGrid != null)
|
if (tran.MyContent.MyGrid != null)
|
||||||
{
|
{
|
||||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
//Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||||
|
//if (mg != null && mg.Groups.Count > 1)
|
||||||
|
//{
|
||||||
|
// System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||||
|
// if (g.ToString() != transText)
|
||||||
|
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||||
|
//}
|
||||||
|
string findLinkXml = @"<START\].*?\[END>";
|
||||||
|
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
string lookForXml = 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);
|
||||||
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
|
foreach (Match mmg in msg)
|
||||||
|
{
|
||||||
|
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
int myIndex = mg.Groups[4].Index + mmg.Index;
|
||||||
if (g.ToString() != transText)
|
int myLength = mg.Groups[4].Length;
|
||||||
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
if (mg.Groups[3].Value != " ")
|
||||||
|
{
|
||||||
|
myIndex = mg.Groups[3].Index + mmg.Index;
|
||||||
|
myLength += mg.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = MyGrid.Data.Substring(myIndex, myLength);
|
||||||
|
if (newvalue.Contains(@"\u8209?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", "-");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (newvalue.Contains(@"\u8593?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", "^");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", m.Groups[1].Value + @"\u8593?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (gg != newvalue)
|
||||||
|
{
|
||||||
|
MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
}
|
||||||
|
}
|
||||||
|
private string GetMySuffix(int start)
|
||||||
|
{
|
||||||
|
string txt = Text.Substring(start);
|
||||||
|
int firstSlashVeeZero = txt.IndexOf(@"\v0");
|
||||||
|
if (firstSlashVeeZero == 0 && txt.Length > 3 && txt[3] == ' ') //"\v0 "
|
||||||
|
return Text.Substring(start, 4);
|
||||||
|
return Text.Substring(start, firstSlashVeeZero + 3); //everything upto \v0"
|
||||||
|
}
|
||||||
|
private string GetMyPrefix(int start, int lastIndex)
|
||||||
|
{
|
||||||
|
string defPrefix = Text.Substring(start - 3, 3);
|
||||||
|
if (defPrefix != @"\v ") throw new Exception(string.Format("rtf string {0} does not match expected format", defPrefix));
|
||||||
|
string txt = Text.Substring(lastIndex, start - lastIndex - 3);
|
||||||
|
int lastSlash = txt.LastIndexOf(@"\");
|
||||||
|
int lastSpace = txt.LastIndexOf(" ");
|
||||||
|
int lastCR = txt.LastIndexOf("\r");
|
||||||
|
if (lastSpace < lastCR)
|
||||||
|
lastSpace = lastCR;
|
||||||
|
if (lastSlash <= lastSpace) //this will return "\v "
|
||||||
|
return defPrefix;
|
||||||
|
txt = txt.Substring(lastSlash);
|
||||||
|
if(txt.StartsWith(@"\'")) //this is a hex
|
||||||
|
return defPrefix;
|
||||||
|
if (Regex.IsMatch(txt, @"\\u[0-9].*")) //this is unicode
|
||||||
|
return defPrefix;
|
||||||
|
return @"\v";
|
||||||
|
}
|
||||||
|
public string ConvertROToText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo)
|
||||||
{
|
{
|
||||||
string retval = null;
|
string retval = null;
|
||||||
string newvalue = value;
|
string newvalue = value;
|
||||||
string findLink = @"<START\].*?\[END>";
|
string findLink = @"<START\].*?\[END>";
|
||||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
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 \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
int lastIndex = 0;
|
||||||
|
string newText = Text;
|
||||||
foreach (Match mm in ms)
|
foreach (Match mm in ms)
|
||||||
{
|
{
|
||||||
int offset = mm.Index;
|
int offset = mm.Index;
|
||||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||||
if (m != null && m.Groups.Count > 1)
|
if (m != null && m.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
|
string prefix = GetMyPrefix(mm.Index, lastIndex);
|
||||||
|
string suffix = GetMySuffix(mm.Index + mm.Length);
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||||
|
string part1 = newText.Substring(0, mm.Index);
|
||||||
|
string part2 = g.Value;
|
||||||
|
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);
|
||||||
System.Text.RegularExpressions.Group g2 = m.Groups[2];
|
System.Text.RegularExpressions.Group g2 = m.Groups[2];
|
||||||
if (g2.Value.StartsWith(@"\u8209?"))
|
if (g2.Value.StartsWith(@"\u8209?"))
|
||||||
{
|
{
|
||||||
string gg = g2.Value + " " + g.Value;
|
string gg = g2.Value + " " + g.Value;
|
||||||
if (gg != newvalue)
|
|
||||||
{
|
|
||||||
retval = gg;
|
retval = gg;
|
||||||
Text = Text.Substring(0, offset + g2.Index) + newvalue + Text.Substring(offset + g2.Index + gg.Length);
|
part2 = retval;
|
||||||
break; // Text has been processed
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else if (g.ToString() != newvalue)
|
//else if (g.ToString() != newvalue)
|
||||||
{
|
{
|
||||||
retval = g.Value;
|
retval = g.Value;
|
||||||
Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
|
part2 = retval;
|
||||||
|
}
|
||||||
|
Text = part1 + part2 + part3;
|
||||||
|
break; // Text has been processed
|
||||||
|
}
|
||||||
|
lastIndex = mm.Index + mm.Length;
|
||||||
|
}
|
||||||
|
Console.WriteLine("Text: {0} NewText: {1}", Text, newText);
|
||||||
|
// see if there is a grid to update too.
|
||||||
|
if (rousg.MyContent.MyGrid != null)
|
||||||
|
{
|
||||||
|
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||||
|
{
|
||||||
|
if (origROFstInfo != null)
|
||||||
|
{
|
||||||
|
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||||
|
if (MyGrid.Data != retlist[1])
|
||||||
|
{
|
||||||
|
MyGrid.Data = retlist[1];
|
||||||
|
retval = Text;
|
||||||
|
if (Text != retlist[0])
|
||||||
|
Text = retlist[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||||
|
string findLinkXml = @"<START\].*?\[END>";
|
||||||
|
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
|
int nmsg = msg.Count;
|
||||||
|
for (int i = nmsg - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
Match mmg = msg[i];
|
||||||
|
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
|
||||||
|
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||||
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
|
{
|
||||||
|
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||||
|
if (g.ToString() != newvalue)
|
||||||
|
{
|
||||||
|
retval = g.Value;
|
||||||
|
MyGrid.Data = MyGrid.Data.Substring(0, offset + mmg.Index + g.Index) + newvalue + MyGrid.Data.Substring(offset + mmg.Index + g.Index + g.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||||
|
{
|
||||||
|
return FixContentText(rousg, value, rotype, origROFstInfo, null);
|
||||||
|
}
|
||||||
|
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo,string fileNameOnly) // string newvalue)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
foreach (Match mm in ms)
|
||||||
|
{
|
||||||
|
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 myLength = m.Groups[4].Length;
|
||||||
|
if(m.Groups[3].Value != " ")
|
||||||
|
{
|
||||||
|
myIndex = m.Groups[3].Index + mm.Index;
|
||||||
|
myLength += m.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = Text.Substring(myIndex,myLength);
|
||||||
|
if ((gg.Replace(@"\'b0", @"\'B0") != newvalue.Replace(@"\'b0", @"\'B0")) && ((fileNameOnly == null) || (gg != fileNameOnly)))
|
||||||
|
{
|
||||||
|
retval = gg;
|
||||||
|
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
|
||||||
break; // Text has been processed
|
break; // Text has been processed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,19 +280,42 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||||
string findLinkXml = @"<START\].*?\[END>";
|
string findLinkXml = @"<START\].*?\[END>";
|
||||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
string lookForXml = 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);
|
||||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
foreach (Match mmg in msg)
|
foreach (Match mmg in msg)
|
||||||
{
|
{
|
||||||
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
|
|
||||||
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
int myIndex = mg.Groups[4].Index + mmg.Index;
|
||||||
if (g.ToString() != newvalue)
|
int myLength = mg.Groups[4].Length;
|
||||||
|
if (mg.Groups[3].Value != " ")
|
||||||
{
|
{
|
||||||
retval = g.Value;
|
myIndex = mg.Groups[3].Index + mmg.Index;
|
||||||
MyGrid.Data = MyGrid.Data.Substring(0, offset + mmg.Index + g.Index) + newvalue + MyGrid.Data.Substring(offset + mmg.Index + g.Index + g.Length);
|
myLength += mg.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = MyGrid.Data.Substring(myIndex, myLength);
|
||||||
|
if (newvalue.Contains(@"\u8209?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", "-");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (newvalue.Contains(@"\u8593?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", "^");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", m.Groups[1].Value + @"\u8593?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (gg != newvalue)
|
||||||
|
{
|
||||||
|
retval = gg;
|
||||||
|
MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,72 +326,156 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
public partial class ContentInfo
|
public partial class ContentInfo
|
||||||
{
|
{
|
||||||
public void FixTransitionText(TransitionInfo tran)
|
public string MyContentMessage = string.Empty;
|
||||||
|
public string MyGridMessage = string.Empty;
|
||||||
|
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
|
||||||
{
|
{
|
||||||
string transText = tran.ResolvePathTo();
|
//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\](\\[^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);
|
////string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||||
Match m = Regex.Match(Text, lookFor);
|
//Match m = Regex.Match(Text, lookFor);
|
||||||
|
//if (m != null && m.Groups.Count > 1)
|
||||||
|
//{
|
||||||
|
// System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||||
|
// if (g.ToString() != transText)
|
||||||
|
// _Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||||
|
//}
|
||||||
|
string newvalue;
|
||||||
|
MyContentMessage = string.Empty;
|
||||||
|
if (tranLookup == null)
|
||||||
|
newvalue = tran.ResolvePathTo();
|
||||||
|
else
|
||||||
|
newvalue = tran.ResolvePathTo(tranLookup);
|
||||||
|
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:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||||
|
foreach (Match mm in ms)
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||||
if (m != null && m.Groups.Count > 1)
|
if (m != null && m.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
int myIndex = m.Groups[4].Index + mm.Index;
|
||||||
if (g.ToString() != transText)
|
int myLength = m.Groups[4].Length;
|
||||||
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
if (m.Groups[3].Value != " ")
|
||||||
|
{
|
||||||
|
myIndex = m.Groups[3].Index + mm.Index;
|
||||||
|
myLength += m.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = Text.Substring(myIndex, myLength);
|
||||||
|
MyContentMessage = string.Format("ContentExt.ContentInfo:Content:{0}, {1}, {2}", this.ContentID, tran.TransitionID, gg);
|
||||||
|
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
|
||||||
|
if (gg != newvalue)
|
||||||
|
{
|
||||||
|
_Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
|
||||||
|
break; // Text has been processed
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// see if there is a grid to update too.
|
// see if there is a grid to update too.
|
||||||
if (tran.MyContent.MyGrid != null)
|
if (tran.MyContent.MyGrid != null)
|
||||||
{
|
{
|
||||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
//Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||||
|
//if (mg != null && mg.Groups.Count > 1)
|
||||||
|
//{
|
||||||
|
// System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||||
|
// //if (g.ToString() != transText)
|
||||||
|
// // MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||||
|
//}
|
||||||
|
MyGridMessage = string.Empty;
|
||||||
|
string findLinkXml = @"<START\].*?\[END>";
|
||||||
|
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
string lookForXml = 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);
|
||||||
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
|
foreach (Match mmg in msg)
|
||||||
|
{
|
||||||
|
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
int myIndex = mg.Groups[4].Index + mmg.Index;
|
||||||
|
int myLength = mg.Groups[4].Length;
|
||||||
|
if (mg.Groups[3].Value != " ")
|
||||||
|
{
|
||||||
|
myIndex = mg.Groups[3].Index + mmg.Index;
|
||||||
|
myLength += mg.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = MyGrid.Data.Substring(myIndex, myLength);
|
||||||
|
if (newvalue.Contains(@"\u8209?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", "-");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (newvalue.Contains(@"\u8593?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", "^");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", m.Groups[1].Value + @"\u8593?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
MyGridMessage = string.Format("ContentExt.ContentInfo:Grid:{0}, {1}, {2}", this.ContentID, tran.TransitionID, gg);
|
||||||
|
if (gg != newvalue)
|
||||||
|
{
|
||||||
|
MyGrid.SetData(MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void FixTransitionText(TransitionInfo tran)
|
||||||
|
{
|
||||||
|
FixTransitionText(tran, null);
|
||||||
|
//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);
|
||||||
|
//Match m = Regex.Match(Text, lookFor);
|
||||||
|
//if (m != null && m.Groups.Count > 1)
|
||||||
|
//{
|
||||||
|
// System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||||
// if (g.ToString() != transText)
|
// if (g.ToString() != transText)
|
||||||
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
// _Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||||
}
|
//}
|
||||||
}
|
//// see if there is a grid to update too.
|
||||||
}
|
//if (MyGrid != null)
|
||||||
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
|
//{
|
||||||
{
|
// string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||||
string transText = tran.ResolvePathTo(tranLookup);
|
// Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
// if (mg != null && mg.Groups.Count > 1)
|
||||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
// {
|
||||||
Match m = Regex.Match(Text, lookFor);
|
// System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||||
if (m != null && m.Groups.Count > 1)
|
// if (g.ToString() != transText)
|
||||||
{
|
// MyGrid.SetData(MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length));
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
// }
|
||||||
if (g.ToString() != transText)
|
//}
|
||||||
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
|
||||||
}
|
|
||||||
// see if there is a grid to update too.
|
|
||||||
if (MyGrid != null)
|
|
||||||
{
|
|
||||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
|
||||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
|
||||||
{
|
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
|
||||||
if (g.ToString() != transText)
|
|
||||||
MyGrid.SetData(MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||||
{
|
{
|
||||||
string newvalue = value;
|
string newvalue = value;
|
||||||
string findLink = @"<START\].*?\[END>";
|
string findLink = @"<START\].*?\[END>";
|
||||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
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 \\]+)* (.*?)(\\[^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);
|
||||||
foreach (Match mm in ms)
|
foreach (Match mm in ms)
|
||||||
{
|
{
|
||||||
int offset = mm.Index;
|
int offset = mm.Index;
|
||||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||||
if (m != null && m.Groups.Count > 1)
|
if (m != null && m.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
int myIndex = m.Groups[4].Index + mm.Index;
|
||||||
if (g.ToString() != newvalue)
|
int myLength = m.Groups[4].Length;
|
||||||
|
if (m.Groups[3].Value != " ")
|
||||||
{
|
{
|
||||||
_Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
|
myIndex = m.Groups[3].Index + mm.Index;
|
||||||
|
myLength += m.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = Text.Substring(myIndex, myLength);
|
||||||
|
if ((gg.Replace(@"\'b0", @"\'B0") != newvalue.Replace(@"\'b0", @"\'B0")))
|
||||||
|
{
|
||||||
|
_Text = Text.Substring(0, myIndex) + newvalue + _Text.Substring(myIndex + myLength);
|
||||||
break; // Text has been processed
|
break; // Text has been processed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +493,8 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||||
string findLinkXml = @"<START\].*?\[END>";
|
string findLinkXml = @"<START\].*?\[END>";
|
||||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||||
|
string lookForXml = 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);
|
||||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||||
foreach (Match mmg in msg)
|
foreach (Match mmg in msg)
|
||||||
{
|
{
|
||||||
@ -209,13 +502,36 @@ namespace VEPROMS.CSLA.Library
|
|||||||
Match mg = Regex.Match(mmg.Value, lookForXml);
|
Match mg = Regex.Match(mmg.Value, lookForXml);
|
||||||
if (mg != null && mg.Groups.Count > 1)
|
if (mg != null && mg.Groups.Count > 1)
|
||||||
{
|
{
|
||||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
int myIndex = mg.Groups[4].Index + mmg.Index;
|
||||||
if (g.ToString() != newvalue)
|
int myLength = mg.Groups[4].Length;
|
||||||
|
if (mg.Groups[3].Value != " ")
|
||||||
|
{
|
||||||
|
myIndex = mg.Groups[3].Index + mmg.Index;
|
||||||
|
myLength += mg.Groups[3].Length;
|
||||||
|
}
|
||||||
|
string gg = MyGrid.Data.Substring(myIndex, myLength);
|
||||||
|
if (newvalue.Contains(@"\u8209?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", "-");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (newvalue.Contains(@"\u8593?"))
|
||||||
|
{
|
||||||
|
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||||
|
if (m == null)
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", "^");
|
||||||
|
else
|
||||||
|
newvalue = newvalue.Replace(@"\u8593?", m.Groups[1].Value + @"\u8593?" + m.Groups[3].Value);
|
||||||
|
}
|
||||||
|
if (gg != newvalue)
|
||||||
{
|
{
|
||||||
string prefix1 = MyGrid.Data.Substring(0,mmg.Index);
|
string prefix1 = MyGrid.Data.Substring(0,mmg.Index);
|
||||||
string prefix2 = mmg.Value.Substring(0,g.Index);
|
string prefix2 = mmg.Value.Substring(0,myIndex);
|
||||||
string suffix1 = MyGrid.Data.Substring(mmg.Index + mmg.Length);
|
string suffix1 = MyGrid.Data.Substring(mmg.Index + mmg.Length);
|
||||||
string suffix2 = mmg.Value.Substring(g.Index + g.Length);
|
string suffix2 = mmg.Value.Substring(myIndex + myLength);
|
||||||
MyGrid.SetData(prefix1 + prefix2 + newvalue + suffix2 + suffix1);
|
MyGrid.SetData(prefix1 + prefix2 + newvalue + suffix2 + suffix1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user