diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs index 49228ba7..f069cd52 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs @@ -139,7 +139,8 @@ namespace VEPROMS.CSLA.Library string newvalue = value; string findLink = @""; MatchCollection ms = Regex.Matches(Text, findLink); - string lookFor = string.Format(@"", rousg.ROUsageID); + //string lookFor = string.Format(@"", rousg.ROUsageID); + string lookFor = string.Format(@"^$", rousg.ROUsageID); int lastIndex = 0; string newText = Text; foreach (Match mm in ms) @@ -150,9 +151,17 @@ namespace VEPROMS.CSLA.Library { string prefix = GetMyPrefix(mm.Index, lastIndex); string suffix = GetMySuffix(mm.Index + mm.Length); - System.Text.RegularExpressions.Group g = m.Groups[3]; + 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); + gg = gg.Replace("{", @"\{").Replace("}", @"\}"); string part1 = newText.Substring(0, mm.Index); - string part2 = g.Value; + string part2 = gg; string part3 = newText.Substring(mm.Index + mm.Length); //modify part1 based on prefix if (prefix == @"\v ") @@ -164,19 +173,27 @@ namespace VEPROMS.CSLA.Library part3 = part3.Substring(4); else part3 = suffix.Replace(@"\v0","") + part3.Substring(suffix.Length); - System.Text.RegularExpressions.Group g2 = m.Groups[2]; - if (g2.Value.StartsWith(@"\u8209?")) - { - string gg = g2.Value + " " + g.Value; - retval = gg; - part2 = retval; - } - else - //else if (g.ToString() != newvalue) - { - retval = g.Value; - part2 = retval; - } + 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); + } + //System.Text.RegularExpressions.Group g2 = m.Groups[2]; + //if (g2.Value.StartsWith(@"\u8209?")) + //{ + // string gg = g2.Value + " " + g.Value; + // retval = gg; + // part2 = retval; + //} + //else + ////else if (g.ToString() != newvalue) + //{ + // retval = g.Value; + // part2 = retval; + //} Text = part1 + part2 + part3; break; // Text has been processed } @@ -204,8 +221,9 @@ namespace VEPROMS.CSLA.Library { // 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); + //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); int nmsg = msg.Count; for (int i = nmsg - 1; i >= 0; i--) { @@ -214,12 +232,32 @@ namespace VEPROMS.CSLA.Library 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); - } + 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 (gg != newvalue) + { + MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength); + } + //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); + //} } } } @@ -234,6 +272,7 @@ namespace VEPROMS.CSLA.Library { string retval = null; string newvalue = value; + newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}"); string findLink = @""; MatchCollection ms = Regex.Matches(Text, findLink); //string lookFor = string.Format(@"", rousg.ROUsageID); diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs index 76b92b49..10e92ccc 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs @@ -978,6 +978,7 @@ namespace VEPROMS.CSLA.Library myLength += m.Groups[3].Length; } string gg = myTI.ContentText.Substring(myIndex, myLength); + gg = gg.Replace("{", @"\{").Replace("}", @"\}"); cc.AddTransitionToCheck(myTI.TransitionID, gg); // System.Text.RegularExpressions.Group g = m.Groups[3]; // cc.AddTransitionToCheck(myTI.TransitionID, g.ToString());