CSLA - Extension

This commit is contained in:
2026-09-01 08:21:41 -04:00
parent dcd2fbc294
commit dab65dbfb6
30 changed files with 2703 additions and 5680 deletions
+140 -364
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
@@ -80,7 +79,7 @@ namespace VEPROMS.CSLA.Library
{
string rv = ConvertTransitionToText(tran, newvalue);
//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
using (Item myitem = 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]
@@ -161,13 +160,11 @@ namespace VEPROMS.CSLA.Library
else
{ // look for rtf font command and insert it around the special char (i.e. symbol char)
int ii = orgText.IndexOf(specChar);
int fnt1 = -1;
int fnt2 = -1;
if (ii > -1)
if (ii > -1)
{
fnt1 = orgText.LastIndexOf(@"\f", ii);
fnt2 = orgText.IndexOf(@"\f", ii);
if (fnt1 != -1 && fnt2 != -1)
int fnt1 = orgText.LastIndexOf(@"\f", ii);
int fnt2 = orgText.IndexOf(@"\f", ii);
if (fnt1 != -1 && fnt2 != -1)
newValue = newValue.Replace(specChar, orgText.Substring(fnt1, 3) + specChar + orgText.Substring(fnt2, 3) + " ");
}
}
@@ -199,11 +196,8 @@ namespace VEPROMS.CSLA.Library
}
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 = MyGrid.Data;
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)
{
@@ -228,8 +222,7 @@ namespace VEPROMS.CSLA.Library
}
break; // Text has been processed
}
lastIndex = mm.Index + mm.Length;
}
}
return;
}
public string ConvertTransitionToText(TransitionInfo tran, string value)
@@ -554,13 +547,13 @@ namespace VEPROMS.CSLA.Library
}
if (value == "?" || gg != newvalue)
{
MyGrid.Data = Content.ConvertGridROsToText(MyGrid.Data, mmg, mg, newvalue); // B2017-060 convert the RO in the grid (table) to text
MyGrid.Data = ConvertGridROsToText(MyGrid.Data, mmg, mg, newvalue); // B2017-060 convert the RO in the grid (table) to text
}
}
}
}
}
return retval == null ? "" : retval;
return retval ?? "";
}
// 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)
@@ -601,8 +594,8 @@ namespace VEPROMS.CSLA.Library
string retval = null;
if (value == "?")
{
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
retval = ConvertROToText(rousg, value, rotype, origROFstInfo, roidFrmImportStep);
using (Item myitem = 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
@@ -638,7 +631,7 @@ namespace VEPROMS.CSLA.Library
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
if (!saveAnnotation)
{
using (Item myitem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
using (Item myitem = 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
@@ -836,21 +829,17 @@ namespace VEPROMS.CSLA.Library
{
return str.Replace(@"\u8209?", "-").Replace(@"\u160?", " "); //dash and hard space
}
//C2022-028 (only used from Amin Tools) check the RO link text - compare with RO Usage information, annotate RO links that are bad
public bool CheckROLinkTextandUsage(ref int BadROLinksCount, ref int CheckROLinksCount, ref int FixedROLinksCount)
//C2022-028 (only used from Admin Tools) check the RO link text - compare with RO Usage information, annotate RO links that are bad
public bool CheckROLinkTextandUsage(ref int BadROLinksCount, ref int CheckROLinksCount)
{
/*** needed if we fix RO link text
bool bFixedROLinks = false;
bool bFixedTableDataText = false;
***/
if (this.Text.Contains("#Link:ReferencedObject:"))
if (Text.Contains("#Link:ReferencedObject:"))
{
if (this.ContentRoUsageCount == 0) // Procedure text has one or more links but no RO Usage records
if (ContentRoUsageCount == 0) // Procedure text has one or more links but no RO Usage records
{
CheckROLinksCount++;
_MyLog.ErrorFormat(string.Format("No RO usage records for RO link(s) - ContentID = {0}", this.ContentID));
using (Item myItem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache
_MyLog.ErrorFormat(string.Format("No RO usage records for RO link(s) - ContentID = {0}", ContentID));
using (Item myItem = ContentItems[0].MyItem) // so that myitem does not stay in cache
{
myItem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed
Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", "Incomplete RO Link Information for all RO References in this text - Relink RO References", null);
@@ -862,7 +851,6 @@ namespace VEPROMS.CSLA.Library
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink); // finds all the links (both RO and Transitions)
string lookFor = "#Link:ReferencedObject:";
string fixedContentText = Text;
if (ms.Count > 0)
{
int roCnt = 0;
@@ -892,18 +880,17 @@ namespace VEPROMS.CSLA.Library
bool GoodROUsageID = false;
bool GoodROID = false;
// Check each ContentRoUsages and look for a matching ROUsageID and ROID
if (iRousage > 0 && this.ContentRoUsageCount > 0)
if (iRousage > 0 && ContentRoUsageCount > 0)
{
int lastROUsageID = -1;
string lastROID = "";
RoUsageInfo badRoUsageInfo = null;
foreach (RoUsageInfo rui in this.ContentItems[0].MyItem.MyItemInfo.MyContent.ContentRoUsages)
foreach (RoUsageInfo rui in ContentItems[0].MyItem.MyItemInfo.MyContent.ContentRoUsages)
{
GoodROID = rui.ROID.Equals(sROid); //does this usage record have a matching ROID with the link text?
GoodROUsageID = rui.ROUsageID.Equals(iRousage); //does the usage record have a matching ROUsageID with the link text?
if (GoodROID && GoodROUsageID)
{
//myROUsages.RemoveAt(myROUsageCnt - 1);
break; // jump out loop - valid RO Usage record found
}
if (GoodROID && !GoodROUsageID)
@@ -918,46 +905,24 @@ namespace VEPROMS.CSLA.Library
{
BadROLinksCount++;
// Add detail information to the error log
_MyLog.ErrorFormat(string.Format("Invalid ROID - ContentID = {0} Link - {1}", this.ContentID, mm.Value));
_MyLog.ErrorFormat(string.Format("Invalid ROID - ContentID = {0} Link - {1}", ContentID, mm.Value));
sAnnotationText += string.Format("Bad RO Instance {0} - RO Needs Relinked - RO Text different than RO Data\n", roCnt);
}
else if (!GoodROUsageID) // Link does not have a valid ROUsage record for that RO link - add annotation
{
BadROLinksCount++;
/*********
//** below is logic to replace the ROUsageID in the linked text with one (for this contentID) that has the same ROID
//** Commented out for now as this was test code for now - don't want to give to customers until we are comfortable
//if (lastROUsageID != -1)
//{
// // set the ROUsageID in the link text to last good ROUsageID found in ROUsage table
// linkText = linkText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
// fixedContentText = fixedContentText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
// bFixedROLinks = true; // set to true so we know to update content text
// _MyLog.InfoFormat(string.Format("Fixed Invalid RO Link - ContentID = {0} badLink - {1} goodLink - {2}",this.ContentID, mm.Value, linkText));
// FixedROLinksCount++;
// 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
// //Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", string.Format("Invalid RO Usage ID for RO Instance {0}",roCnt), null);
// Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Fixed Bad RO link"), "", string.Format("Fixed RO Instance {0} - Verify RO Value", roCnt), null);
// }
//}
*********/
//else
//{
// Add detail information to the error log
_MyLog.ErrorFormat(string.Format("Invalid ROUsageID - ContentID = {0} Link - {1}", this.ContentID, mm.Value));
sAnnotationText += string.Format("RO Instance {0} Needs Relinked - Value Not Able To Update\n", roCnt);
//}
// Add detail information to the error log
_MyLog.ErrorFormat(string.Format("Invalid ROUsageID - ContentID = {0} Link - {1}", ContentID, mm.Value));
sAnnotationText += string.Format("RO Instance {0} Needs Relinked - Value Not Able To Update\n", roCnt);
}
}
}
}
if (roCnt < this.ContentRoUsageCount)
if (roCnt < ContentRoUsageCount)
{
BadROLinksCount++;
// there are more RO Usage records then there links in the step
_MyLog.WarnFormat(string.Format("Possible missing RO links, more RO Usage records than Links - ContentID = {0}", this.ContentID));
_MyLog.WarnFormat(string.Format("Possible missing RO links, more RO Usage records than Links - ContentID = {0}", ContentID));
sAnnotationText += "Possible missing RO links.\n";
}
// if any bad RO links were found, put the information in an Annotation
@@ -965,113 +930,15 @@ namespace VEPROMS.CSLA.Library
{
char[] newLine = { '\n' };
sAnnotationText = sAnnotationText.TrimEnd(newLine);
using (Item myItem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
using (Item myItem = 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
//Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", string.Format("Invalid RO Usage ID for RO Instance {0}",roCnt), null);
Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", sAnnotationText, null);
}
}
/*** COMMENTED OUT BECAUSE WE NOT MAKING CHANGES TO THE DATA - FOR NOW
//if (bFixedROLinks)
//{
// // save content text
// Text = fixedContentText;
//}
*****/
/*******
// if we fix RO links in the RTF then see if there is a grid to update too.
// WE DON'T NEED TO ADD ANNOTATIONS AS THAT IS DONE ABOVE (FOR THE RTF OF THE TABLE - BELOW IS THE XML OF THE TABLE
// *** bFixedROLinks WILL REMAIN FALSE FOR NOW AS WE ARE NOT CHANGING LINK TEXT - THIS WILL PREVENT THE CHECKING OF THE XML TABLE
if (bFixedROLinks && MyGrid != null && MyGrid.Data.Length > 0)
{
string fixedTableDataText = MyGrid.Data;
// **** NEED LOGIC TO CHECK RO TABLES ****
//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 = @"&lt;START\].*?\[END&gt;";
//string lookForXml = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;$", rousg.ROUsageID);
string lookForXml = "#Link:ReferencedObject:";
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
Match mg = Regex.Match(mmg.Value, lookForXml);// look for Referenced Object link in linked text
if (mg != null && mg.Groups.Count > 1)
{
string tblLinkText = mmg.Value; // the link text in the table XML
int rousgidx = mg.Index + mg.Length;
int rousagid_len = mmg.Value.IndexOf(" ", rousgidx) - rousgidx;
string sROusageID = mmg.Value.Substring(rousgidx, rousagid_len); // ROUsageID from link text
int roidIdx = rousgidx + rousagid_len + 1;
int roid_Len = mmg.Value.IndexOf(" ", roidIdx) - roidIdx;
string sROid = mmg.Value.Substring(roidIdx, roid_Len);
// initialize to zero for cases where the ROUsage is <CROUSGID or <NEWID> to force a no match below
// -when a link has either of these, then the process of inserting that RO link did not complete for some reason
int iRousage = 0;
if (!sROusageID.StartsWith("<")) // don't try to convert if link has <CROUSGID or <NEWID> for the ROUsageID value
iRousage = Convert.ToInt32(sROusageID); //ROUsageID as interger
// see if there is a ContentID and ROUsage record match
// Both GoodROUsageID and GoodROUID must match in ROUsage record for link to be good
bool GoodROUsageID = false;
bool GoodROID = false;
// Check each ContentRoUsages and look for a matching ROUsageID and ROID
if (iRousage > 0 && this.ContentRoUsageCount > 0)
{
int lastROUsageID = -1;
string lastROID = "";
RoUsageInfo badRoUsageInfo = null;
foreach (RoUsageInfo rui in this.ContentItems[0].MyItem.MyItemInfo.MyContent.ContentRoUsages)
{
GoodROID = rui.ROID.Equals(sROid); //does this usage record have a matching ROID with the link text?
GoodROUsageID = rui.ROUsageID.Equals(iRousage); //does the usage record have a matching ROUsageID with the link text?
if (GoodROID && GoodROUsageID) break; // jump out loop - valid RO Usage record found
if (GoodROID && !GoodROUsageID)
{
lastROUsageID = rui.ROUsageID;
lastROID = rui.ROID;
}
else if (!GoodROID && GoodROUsageID)
badRoUsageInfo = rui;
}
if (!GoodROUsageID && GoodROID && lastROUsageID != -1) // Link does not have a valid ROUsage record for that RO link - add annotation
{
// set the ROUsageID in the link text to last good ROUsageID found in ROUsage table
tblLinkText = tblLinkText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
fixedTableDataText = fixedTableDataText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
bFixedTableDataText = true; // set to true so we know to update content text
}
if (bFixedTableDataText) // if we changed the table XML, then save it
{
this.MyGrid.Data = fixedTableDataText;
}
}
}
}
}
******* End modify table ****/
}
}
}
/*** needed if we fix RO links
return (bFixedROLinks || bFixedTableDataText);
***/
return false;
}
}
@@ -1079,29 +946,14 @@ namespace VEPROMS.CSLA.Library
public delegate void StaticContentInfoEvent(object sender, StaticContentInfoEventArgs args);
public class StaticContentInfoEventArgs
{
string _OldValue;
public string OldValue
public string OldValue { get; set; }
public string NewValue { get; set; }
public string Type { get; set; }
public StaticContentInfoEventArgs(string oldValue, string newValue, string type)
{
get { return _OldValue; }
set { _OldValue = value; }
}
string _NewValue;
public string NewValue
{
get { return _NewValue; }
set { _NewValue = value; }
}
string _Type;
public string Type
{
get { return _Type; }
set { _Type = value; }
}
public StaticContentInfoEventArgs(string oldValue, string newValue, string type)
{
_OldValue = oldValue;
_NewValue = newValue;
_Type = type;
OldValue = oldValue;
NewValue = newValue;
Type = type;
}
}
@@ -1119,27 +971,14 @@ namespace VEPROMS.CSLA.Library
return sb.ToString();
}
public string LastChangedString
{
get { return ContentInfo.FormatByteArray(_LastChanged); }
}
public string LastChangedString => FormatByteArray(_LastChanged);
public Int64 LastChangedInt64
{
get { return Convert.ToInt64(LastChangedString, 16); }
}
public static bool IsInCache(int contentID)
{
return _CacheByPrimaryKey.ContainsKey(contentID.ToString());
}
public static event StaticContentInfoEvent StaticContentInfoChange;
// B2018-002 - Invalid Transitions - Changed to Public
public static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (StaticContentInfoChange != null)
StaticContentInfoChange(sender, args);
}
public string MyContentMessage = string.Empty;
public long LastChangedInt64 => Convert.ToInt64(LastChangedString, 16);
public static bool IsInCache(int contentID) => _CacheByPrimaryKey.ContainsKey(contentID.ToString());
public static event StaticContentInfoEvent StaticContentInfoChange;
// B2018-002 - Invalid Transitions - Changed to Public
public static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args) => StaticContentInfoChange?.Invoke(sender, args);
public string MyContentMessage = string.Empty;
public string MyGridMessage = string.Empty;
public bool InList(params int[] IDs)
{
@@ -1150,22 +989,13 @@ namespace VEPROMS.CSLA.Library
return false;
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii)
{
FixTransitionText(tran, tranLookup, ii, "");
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii) => FixTransitionText(tran, tranLookup, ii, "");
public void FixTransitionText(TransitionInfo tran, ItemInfo ii)
{
FixTransitionText(tran, ii, "");
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii) => FixTransitionText(tran, ii, "");
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, string forceConvertToText)
{
FixTransitionText(tran, null, ii, forceConvertToText);
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, string forceConvertToText) => FixTransitionText(tran, null, ii, forceConvertToText);
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, string forceConvertToText)
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, string forceConvertToText)
{
string newvalue;
MyContentMessage = string.Empty;
@@ -1199,7 +1029,7 @@ namespace VEPROMS.CSLA.Library
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);
MyContentMessage = string.Format("ContentExt.ContentInfo:Content:{0}, {1}, {2}", ContentID, tran.TransitionID, gg);
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
if ((gg.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\\")) != (newvalue.Replace("\\u8209?", "-").Replace(@"\u9586?", @"\\")) || newvalue == "?") // B2017-165 added check of newvalue
{
@@ -1230,66 +1060,57 @@ namespace VEPROMS.CSLA.Library
// see if there is a grid to update too.
if (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);
//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 = @"&lt;START\].*?\[END&gt;";
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
string lookForXml = string.Format(@"^&lt;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&gt;", 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)
{
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?"))
{
// B2022-058: Printing of '-' in transition in table prints as '?' instead of '-'. Wasn't using correct string to
// look for font character (was using newvalue, not gg)
Match m = Regex.Match(gg, @"(\\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(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + m.Groups[3].Value);
}
if (newvalue.Contains(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + 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));
}
}
}
}
MyGridMessage = string.Empty;
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"^&lt;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&gt;", tran.TranType, tran.TransitionID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
Match mg = Regex.Match(mmg.Value, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
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?"))
{
// B2022-058: Printing of '-' in transition in table prints as '?' instead of '-'. Wasn't using correct string to
// look for font character (was using newvalue, not gg)
Match m = Regex.Match(gg, @"(\\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(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", $@"{m.Groups[1].Value}\u9586?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", $@"{m.Groups[1].Value}\u9586?{m.Groups[3].Value}");
}
MyGridMessage = string.Format("ContentExt.ContentInfo:Grid:{0}, {1}, {2}", ContentID, tran.TransitionID, gg);
if (gg != newvalue)
{
MyGrid.SetData(MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength));
}
}
}
}
}
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, ItemInfo ii)
@@ -1362,10 +1183,6 @@ namespace VEPROMS.CSLA.Library
newvalue = newvalue.Replace($"{(char)916}", @"\u916?");
}
// Debug - jsj 5-19-2017 - left in for initial check-in
//string xx_gg = gg_org.Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
//string xx_nv = newval_org.Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
//Console.WriteLine(xx_gg.CompareTo(xx_nv));
OnStaticContentInfoChange(ii, new StaticContentInfoEventArgs(gg, newvalue, "RO"));
break; // Text has been processed
}
@@ -1378,7 +1195,7 @@ namespace VEPROMS.CSLA.Library
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this.Get(), new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
List<string> retlist = origROFstInfo.OnROTableUpdate(Get(), new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (retlist != null && Text != retlist[0]) _Text = retlist[0]; //B2022-075 added null reference check
}
else
@@ -1412,7 +1229,7 @@ namespace VEPROMS.CSLA.Library
if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u8209?", "-");
else
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u8209?", $@"{m.Groups[1].Value}\u8209?{m.Groups[3].Value}");
}
//B2024-003, B2023-113, B2024-093 - Updating RO Values inside a text Grid,
// This will handle if there is a delta and the column/row of the grid is removed
@@ -1425,7 +1242,7 @@ namespace VEPROMS.CSLA.Library
else if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u916?", $"{(char)916}");
else
newvalue = newvalue.Replace(@"\u916?", m.Groups[1].Value + @"\u916?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u916?", $@"{m.Groups[1].Value}\u916?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u8593?"))
{
@@ -1433,7 +1250,7 @@ namespace VEPROMS.CSLA.Library
if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u8593?", "^");
else
newvalue = newvalue.Replace(@"\u8593?", m.Groups[1].Value + @"\u8593?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u8593?", $@"{m.Groups[1].Value}\u8593?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u9586?"))
@@ -1442,7 +1259,7 @@ namespace VEPROMS.CSLA.Library
if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u9586?", $@"{m.Groups[1].Value}\u9586?{m.Groups[3].Value}");
}
// B2022-064: Translate '<' to '&lt;', '<' is xml token, so xml grid string was incorrect for print.
// Note that the '>' symbol was also translated. This method does NOT save the string to database,
@@ -1469,24 +1286,18 @@ namespace VEPROMS.CSLA.Library
_Text = "?";
}
// C2021-018 used to update the content record when displaying Alarm Pont Table information in the step Editor (BNPP alarms)
public void UpdateAlarmTableInfoView(string updateText)
{
_Text = updateText;
}
// C2021-018 used to update the content record when displaying Alarm Pont Table information in the step Editor (BNPP alarms)
public void UpdateAlarmTableInfoView(string updateText) => _Text = updateText;
public void LoadNonCachedGrid()
public void LoadNonCachedGrid()
{
_MyGrid = GridInfo.GetNonCached(ContentID);
//Console.WriteLine("LoadNonCachedGrid {0},{1},{2}",ContentID,_MyGrid==null,_MyContentInfoUnique);
}
public PartInfoList LocalContentParts
{
get { return _ContentParts; }
}
public PartInfoList LocalContentParts => _ContentParts;
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
{
if (_ContentParts == null)
_ContentParts = new PartInfoList(dr, itemInfo);
@@ -1494,17 +1305,11 @@ namespace VEPROMS.CSLA.Library
_ContentParts.AddPartInfo(dr, itemInfo);
}
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
public override string ToString() => $"{Number} {Text}";
public void ShowChange()
{
OnChange();
}
public void ShowChange() => OnChange();
internal ContentInfo(SafeDataReader dr, bool ForItem)
internal ContentInfo(SafeDataReader dr, bool ForItem)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
@@ -1587,7 +1392,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentListCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1604,7 +1409,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1616,7 +1421,7 @@ namespace VEPROMS.CSLA.Library
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
public static ContentInfoList GetChangedList(byte[] lastChanged)
@@ -1624,7 +1429,6 @@ namespace VEPROMS.CSLA.Library
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ChangeListCriteria(lastChanged));
// ContentInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
@@ -1651,7 +1455,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ChangeListCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1668,7 +1472,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1680,7 +1484,7 @@ namespace VEPROMS.CSLA.Library
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
#region ClearCBOverride
@@ -1725,7 +1529,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1760,29 +1564,15 @@ namespace VEPROMS.CSLA.Library
{
public ClearOverrideFormatsByDocVersionCriteria(string dvlist, int? formatID, int? newformatID)
{
_FormatID = formatID;
_DVList = dvlist;
_NewFormatID = newformatID;
FormatID = formatID;
DVList = dvlist;
NewFormatID = newformatID;
}
private int? _FormatID;
public int? FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
private int? _NewFormatID;
public int? NewFormatID
{
get { return _NewFormatID; }
set { _NewFormatID = value; }
}
private string _DVList;
public string DVList
{
get { return _DVList; }
set { _DVList = value; }
}
}
public int? FormatID { get; set; }
public int? NewFormatID { get; set; }
public string DVList { get; set; }
}
private void DataPortal_Fetch(ClearOverrideFormatsByDocVersionCriteria criteria)
{
@@ -1810,7 +1600,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1841,29 +1631,15 @@ namespace VEPROMS.CSLA.Library
{
public ClearOverrideFormatsByItemCriteria(int itemID, int? formatID, int? newformatID)
{
_FormatID = formatID;
_NewFormatID = newformatID;
_ItemID = itemID;
FormatID = formatID;
NewFormatID = newformatID;
ItemID = itemID;
}
private int? _FormatID;
public int? FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
private int? _NewFormatID;
public int? NewFormatID
{
get { return _NewFormatID; }
set { _NewFormatID = value; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
public int? FormatID { get; set; }
public int? NewFormatID { get; set; }
public int ItemID { get; set; }
}
private void DataPortal_Fetch(ClearOverrideFormatsByItemCriteria criteria)
{
@@ -1891,7 +1667,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1975,7 +1751,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2005,7 +1781,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2069,7 +1845,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2146,7 +1922,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2222,7 +1998,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}