B2017-060 the update of RO usages of an imported procedure, if RO was not found in the ROUsage table, the import would be aborted instead of converting the invalid RO to text
B2017-060 the update of RO usages of an imported procedure, if RO was not found in the ROUsage table, the import would be aborted instead of converting the invalid RO to text. Part of B2017-060 fix were we need to prevent the content text from being disposed when Item is used in a Using statement.
This commit is contained in:
@@ -75,6 +75,7 @@ namespace VEPROMS.CSLA.Library
|
||||
//Text = Text.Substring(0, myIndex - 14) + gg + Text.Substring(myIndex + myLength);
|
||||
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);
|
||||
}
|
||||
@@ -381,13 +382,20 @@ namespace VEPROMS.CSLA.Library
|
||||
return @"\v";
|
||||
}
|
||||
public string ConvertROToText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo)
|
||||
{
|
||||
return ConvertROToText(rousg, value, rotype, origROFstInfo, "");
|
||||
}
|
||||
// B2017-060 added roidFrmImportStep to pass in a ROID to use when rousg is null (import procedure uses this)
|
||||
public string ConvertROToText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, string roidFrmImportStep)
|
||||
{
|
||||
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:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
|
||||
string strROUID = (rousg != null) ? rousg.ROUsageID.ToString() : roidFrmImportStep;
|
||||
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>$", strROUID);
|
||||
int lastIndex = 0;
|
||||
string newText = Text;
|
||||
foreach (Match mm in ms)
|
||||
@@ -457,7 +465,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
//Console.WriteLine("Text: {0} NewText: {1}", Text, newText);
|
||||
// see if there is a grid to update too.
|
||||
if (rousg.MyContent.MyGrid != null)
|
||||
if (_MyGrid != null) //(rousg.MyContent.MyGrid != null)
|
||||
{
|
||||
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||
{
|
||||
@@ -478,13 +486,12 @@ 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);
|
||||
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);
|
||||
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>$", strROUID);
|
||||
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)
|
||||
{
|
||||
@@ -496,6 +503,8 @@ namespace VEPROMS.CSLA.Library
|
||||
myLength += mg.Groups[3].Length;
|
||||
}
|
||||
string gg = MyGrid.Data.Substring(myIndex, myLength);
|
||||
if (value == "?")
|
||||
newvalue = gg; // B2017-060 the text part of the RO link
|
||||
if (newvalue.Contains(@"\u8209?"))
|
||||
{
|
||||
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
|
||||
@@ -512,38 +521,48 @@ namespace VEPROMS.CSLA.Library
|
||||
else
|
||||
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + m.Groups[3].Value);
|
||||
}
|
||||
if (gg != newvalue)
|
||||
if (value == "?" || gg != newvalue)
|
||||
{
|
||||
MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength);
|
||||
MyGrid.Data = Content.ConvertGridROsToText(MyGrid.Data, mmg, mg, newvalue); // B2017-060 convert the RO in the grid (table) to text
|
||||
}
|
||||
//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 == null ? "" : retval;
|
||||
}
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||
// B2017-060 logic pulled from dlgExportImport to covert a RO in a table (grid) to text
|
||||
public static string ConvertGridROsToText(string data, Match mmg, Match mg, string ss)
|
||||
{
|
||||
return FixContentText(rousg, value, rotype, origROFstInfo, null);
|
||||
int ii = data.Substring(0, mmg.Index).LastIndexOf(@"\v");
|
||||
int iil = data.Substring(mmg.Index + mg.Value.Length).IndexOf(@"\v0");
|
||||
string part1 = data.Substring(0, ii); // length up to \v
|
||||
string part2 = data.Substring(ii + 2, mmg.Index - (ii + 2));
|
||||
string part3 = ss;
|
||||
string part4 = data.Substring(mmg.Index + mg.Value.Length, iil);
|
||||
string part5 = data.Substring(mmg.Index + (mg.Value.Length + iil + 3));
|
||||
data = part1 + part2 + part3 + part4 + part5;
|
||||
return data;
|
||||
}
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo,string fileNameOnly) // string newvalue)
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo)
|
||||
{
|
||||
return FixContentText(rousg, value, rotype, origROFstInfo, null, "");
|
||||
}
|
||||
// B2017-060 added roidFrmImportStep to pass in a ROID to use when rousg is null (import procedure uses this)
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, string fileNameOnly, string roidFrmImportStep)
|
||||
{
|
||||
string retval = null;
|
||||
if (value == "?")
|
||||
{
|
||||
retval = this.ConvertROToText(rousg, value, rotype, origROFstInfo);
|
||||
retval = this.ConvertROToText(rousg, value, rotype, origROFstInfo, roidFrmImportStep);
|
||||
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 RO is converted to text
|
||||
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(retval)), null);
|
||||
}
|
||||
RoUsage.Delete(rousg.ROUsageID);
|
||||
if (rousg != null)
|
||||
RoUsage.Delete(rousg.ROUsageID);
|
||||
return retval;
|
||||
}
|
||||
string newvalue = value;
|
||||
@@ -595,8 +614,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:
|
||||
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:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
|
||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||
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);
|
||||
foreach (Match mmg in msg)
|
||||
{
|
||||
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||
|
@@ -753,6 +753,7 @@ namespace VEPROMS.CSLA.Library
|
||||
oldText = content.ConvertROToText(rousage, roval, roch.type, rofstinfo);
|
||||
using (Item myitem = content.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 RO is converted to text
|
||||
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
|
||||
}
|
||||
@@ -795,6 +796,7 @@ namespace VEPROMS.CSLA.Library
|
||||
oldText = content.ConvertROToText(rousage, roval, roch.type, rofstinfo);
|
||||
using (Item myitem = content.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 RO is converted to text
|
||||
Annotation.MakeAnnotation(myitem, AnnotationType.GetByNameOrCreate("Link Converted To Text"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
|
||||
}
|
||||
|
Reference in New Issue
Block a user