Improved conversion ot Referenced Objects and Transitions to text

Added code to implement deleting pdfs
Fixed problems with searching by Textm Annotations, Referenced Objects and Transitions
This commit is contained in:
Rich
2015-02-18 02:36:42 +00:00
parent f16fcf1470
commit cb52bad3e9
4 changed files with 167 additions and 46 deletions

View File

@@ -32,13 +32,25 @@ namespace VEPROMS.CSLA.Library
// if (g.ToString() != transText)
// Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
//}
string newvalue = tran.ResolvePathTo();
string newvalue = tran != null ? tran.ResolvePathTo() : string.Empty;
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);
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);
string lookFor;
if (tran == null)
{
int loc1 = Text.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
int loc2 = Text.IndexOf(" ", loc1);
string trantype = Text.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
loc2 = Text.IndexOf(" ", loc1);
string tranid = Text.Substring(loc1, loc2 - loc1);
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);
}
else
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);
@@ -57,8 +69,9 @@ namespace VEPROMS.CSLA.Library
{
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);
Transition.Delete(tran.TransitionID);
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, AnnotationType.GetByName("Verification Required"), "", string.Format("Transition ({0}) converted to text", ItemInfo.ConvertToDisplayText(gg)), null);
if(tran != null)
Transition.Delete(tran.TransitionID);
break;
}
else if ((gg.Contains("\\u8209?") ? gg.Replace("\\u8209?", "-") : gg) != (newvalue.Contains("\\u8209?") ? newvalue.Replace("\\u8209?", "-") : newvalue))
@@ -69,7 +82,7 @@ namespace VEPROMS.CSLA.Library
}
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
if (tran != null && tran.MyContent.MyGrid != null)
{
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
//Match mg = Regex.Match(MyGrid.Data, lookForXml);
@@ -128,7 +141,19 @@ namespace VEPROMS.CSLA.Library
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);
string lookFor;
if (tran == null)
{
int loc1 = Text.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
int loc2 = Text.IndexOf(" ", loc1);
string trantype = Text.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
loc2 = Text.IndexOf(" ", loc1);
string tranid = Text.Substring(loc1, loc2 - loc1);
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);
}
else
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)
@@ -403,7 +428,7 @@ namespace VEPROMS.CSLA.Library
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);
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, AnnotationType.GetByName("Verification Required"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(retval)), null);
RoUsage.Delete(rousg.ROUsageID);
return retval;
}
@@ -545,9 +570,9 @@ namespace VEPROMS.CSLA.Library
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii)
{
FixTransitionText(tran, tranLookup, ii, false);
FixTransitionText(tran, tranLookup, ii, "");
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, bool forceConvertToText)
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, string 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);
@@ -565,7 +590,7 @@ namespace VEPROMS.CSLA.Library
newvalue = tran.ResolvePathTo();
else
newvalue = tran.ResolvePathTo(tranLookup);
if (forceConvertToText)
if (forceConvertToText != string.Empty)
newvalue = "?";
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
@@ -592,7 +617,7 @@ namespace VEPROMS.CSLA.Library
if (newvalue == "?")
{
gg = ItemInfo.ConvertToDisplayText(gg);
newvalue = "Invalid Transition";
newvalue = forceConvertToText;
OnStaticContentInfoChange(ii, new StaticContentInfoEventArgs(gg, newvalue, "TX"));
break;
}
@@ -666,9 +691,9 @@ namespace VEPROMS.CSLA.Library
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii)
{
FixTransitionText(tran, ii, false);
FixTransitionText(tran, ii, "");
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, bool forceConvertToText)
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, string forceConvertToText)
{
FixTransitionText(tran, null, ii, forceConvertToText);
//string transText = tran.ResolvePathTo(tranLookup);