B2022-088: Find Doc Ro button not working in Word Sections

B2022-089: Updating RO Crashes
This commit is contained in:
Jake
2022-08-08 10:04:21 +00:00
parent b6d69fbd4c
commit f8269a7ac6
13 changed files with 271 additions and 125 deletions

View File

@@ -137,6 +137,8 @@ namespace VEPROMS.CSLA.Library
private int _selectedSlave;
private string _otherChild = string.Empty;
private bool _autoCombineSingleRetValues = true;
private List<string> _lstRoValues;
private List<string> _multiRoValues;
private Dictionary<string, string> _dicRoVars;
@@ -195,6 +197,13 @@ namespace VEPROMS.CSLA.Library
}
}
public bool AutoCombineSingleRetValues
{
get { return _autoCombineSingleRetValues; }
set { _autoCombineSingleRetValues = value; }
}
#endregion
#region Constructors
@@ -293,6 +302,35 @@ namespace VEPROMS.CSLA.Library
#region (RO Info By AccPageID)
public string FormatAccPageKey(string accPageID)
{
if (string.IsNullOrEmpty(accPageID))
return accPageID;
string spDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_setpointprefix : string.Empty;
string igDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_graphicsprefix : string.Empty;
return FormatAccPageKey(accPageID, spDefault, igDefault);
}
public string FormatAccPageKey(string accPageID, ref string accPageBase, ref string accPageExt, bool useDefaultExt = true)
{
string accPageKey = FormatAccPageKey(accPageID);
if (Regex.IsMatch(accPageKey, @".*\.[A-Z]"))
{
accPageBase = accPageKey.Substring(0, accPageKey.Length - 2);
accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault());
}
else
{
accPageBase = accPageKey;
accPageExt = (!accPageKey.StartsWith("<U-") && useDefaultExt) ? "A" : string.Empty;
}
return accPageKey;
}
public static string FormatAccPageKey(string accPageID, string spDefault, string igDefault)
{
if (!string.IsNullOrEmpty(accPageID))
@@ -305,7 +343,7 @@ namespace VEPROMS.CSLA.Library
if (!accPageID.EndsWith(">"))
accPageID = string.Format("{0}>", accPageID);
accPageID = accPageID.Replace("<U>", "<U-ID>");
accPageID = accPageID.Replace("<U>", "<U-NUMBER>");
accPageID = accPageID.ToCleanString(); // Removes any spaces
// Clean up the AccPageID before using it to do a lookup
@@ -344,13 +382,22 @@ namespace VEPROMS.CSLA.Library
return accPageKey;
}
public ROFSTLookup.rochild GetROChildByAccPageID(string accPageID)
{
string spDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_setpointprefix : string.Empty;
string igDefault = (MyDocVersionInfo != null && MyDocVersionInfo.DocVersionConfig != null) ? MyDocVersionInfo.DocVersionConfig.RODefaults_graphicsprefix : string.Empty;
return GetROChildByAccPageID(accPageID, spDefault, igDefault);
}
public ROFSTLookup.rochild GetROChildByAccPageID(string accPageID, string spDefault, string igDefault)
{
// Cleanup accPageID if necessary [Note* This will also handle any UnitInfo Ro Values (ex: "<U-NUMBER>")]
string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault);
ROFSTLookup.rochild rc = RofstDataGetChildByAccPageID(_rofstID, accPageID, spDefault, igDefault);
if (!string.IsNullOrEmpty(rc.roid) && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0)
if (!string.IsNullOrEmpty(rc.roid) && rc.roid.Length < 16 && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0)
{
// Check if AccPageID/Key has a return value specific extension. Try to find the RoChild record with the specific return value type,
// If not found Or the specific extension value is (Null or Empty), then just return the first/default return value type in the list of children
@@ -372,12 +419,19 @@ namespace VEPROMS.CSLA.Library
if (!string.IsNullOrEmpty(roid))
{
roid = roid.ToUpper();
roid = roid.Replace("<U>", "<U-ID>");
roid = roid.Replace("<U>", "<U-NUMBER>");
roid = roid.ToCleanString(); // Removes any spaces
if ((!roid.StartsWith("<U-")) && ((roid.Length == 16 && roid.EndsWith("0000")) || (check16Digits && roid.Length < 16)))
{
roid = string.Format("{0}0041", roid.Substring(0, 12));
// Pad roid with zeros to ensure the minimum length of any roid is (12) digits.
// This fixes any roids that are less than (12) digits or ones that have (16) digits and end with the older "0000" default ext.
// The default extension for any RoChild return value is now "0041", which is always the first RoChild Return Value object in the "Childrens" collection for
// the RO Base Object and is also used as the Default Return Value if the specified extension specific return value doesn't exist or has been deleted.
// This applies to all RoChild Return Values (Single / Multiple / Unit Info Tags)
// [Example: Unit Info Roid(12) "FFFF00000002" ==> "FFFF000000020041"]
roid = string.Format("{0}00000000", roid).Substring(0, 12) + "0041";
}
}
@@ -403,12 +457,12 @@ namespace VEPROMS.CSLA.Library
public ROFSTLookup.rochild GetRoChild(string roid, bool loadChildren = false, bool loadAllChildren = false)
{
// Cleanup Roid if necessary (Note* This method also handles the UnitInfo Ro Values. ex: "<U-NUMBER>")
// Cleanup roid if necessary [Note* This will also handle any UnitInfo Ro Values (ex: "<U-NUMBER>")]
roid = FormatRoidKey(roid);
ROFSTLookup.rochild rc = GetRoChild12(roid, loadChildren, loadAllChildren);
if (!roid.StartsWith("FFFF") && roid.Length == 16 && rc.children != null && rc.children.Length > 0)
if (!roid.StartsWith("FFFF") && rc.children != null && rc.children.Length > 0 && roid.Length == 16)
{
// If specific match exists for multi-return values, then return specified value, otherwise default to the first child
if (rc.children.Where(x => x.roid.ToUpper() == roid.ToUpper()).Any())
@@ -420,18 +474,15 @@ namespace VEPROMS.CSLA.Library
return rc;
}
public string GetRoValue(string roid)
{
return GetRoChild(roid).value;
}
public string GetTranslatedRoValue(string roid, bool DoCaret, bool DoDOSSuperSubScript)
{
roid = FormatRoidKey(roid);
string retval = GetRoValue(roid);
string retval = GetRoChild(roid).value;
if (string.IsNullOrEmpty(retval))
return string.Empty;
retval = ReplaceUnicode(retval, DoCaret);
retval = ConvertFortranFormatToScienctificNotation(retval);
@@ -446,41 +497,6 @@ namespace VEPROMS.CSLA.Library
return (!string.IsNullOrEmpty(retval)) ? retval.Replace("\r\n", @"\par ") : retval;
}
public static string GetParentChildDefaultValue(string roval)
{
var test = GetParentChildROValue(roval, 0);
// C2021-026 Get the Parent (Default) RO value if the return value include P/C information otherwise return the RO value as is.
// This is used for the insert RO interface on the Step Properties panel
if (string.IsNullOrEmpty(roval))
return null;
string rntval = roval.Replace("\xFF", "\xa0").Replace(@"\u160?", " ");
while (rntval.Contains("<APL DefaultVal=")) // C2021-026 remove Parent/Child values for the menu item text
{
int startCVIdx = rntval.IndexOf("<APL DefaultVal=");
int EndCVidx = rntval.IndexOf(" /APL>", startCVIdx);
string aplicValues = rntval.Substring(startCVIdx, EndCVidx + 6 - startCVIdx);
int endDefIdx = rntval.IndexOf(",", startCVIdx);
// C2022-001 - handle if there is no child value in the RO FSt
// B2022-051 - was sometimes leaving "/APL>" when processing return value made up from multiple RO (editor) fields
// added check to make where next found comma was within the current <APL ... /APL>
string defValue = rntval.Substring(startCVIdx + 16, ((endDefIdx > 0 && endDefIdx < EndCVidx) ? endDefIdx : EndCVidx) - (startCVIdx + 16));
rntval = rntval.Replace(aplicValues, defValue);
}
rntval = rntval.Trim();
// If Default Value is selected (selChldIdx = 0), and return value is empty then replace with Standard Missing Default Value
return (string.IsNullOrEmpty(rntval)) ? ROFSTLookup.RoMissingDefaultValue : rntval;
//return rntval;
}
public List<string> GetValueDifferences(int originalRofstID, ref List<string> delList)
{
return RofstDataGetValueDifferences(originalRofstID, _rofstID, ref delList);
@@ -1087,6 +1103,11 @@ namespace VEPROMS.CSLA.Library
private Dictionary<string, string> RofstDataSearch(int rofstID, string value, int searchTypeID, bool onlyRoid16, int? maxNumRecords)
{
// Currently, the RO Value Search only uses the default values for each of the (16) digit Ext Specific RO Return Values
// The defaults for each (16) digit Ext Specific RO Return Value are stored separately in the [RofstDefaultValue] table so they can be indexed / optimized
// for performance. In the future, the search can easily be modified to also include all unit specific return values as well. All we need to do is
// add a new table [RofstReturnValue] in the database to hold all of the different extension specific return values for each unit when applicable.
// All of the records in the [RofstReturnValue] will have a Foreign Key reference back to their RO Child Base objects in the [RofstChild] table.
Dictionary<string, string> dic = new Dictionary<string, string>();
if (string.IsNullOrEmpty(value))
@@ -1508,13 +1529,15 @@ namespace VEPROMS.CSLA.Library
rc.title = (string)dr.GetValue("title");
rc.roid = (string)dr.GetValue("roid");
if (!string.IsNullOrEmpty((string)dr.GetValue("appid")))
rc.appid = (string)dr.GetValue("appid");
if (!string.IsNullOrEmpty((string)dr.GetValue("value")))
if (!string.IsNullOrEmpty((string)dr.GetValue("appid")))
{
rc.value = (string)dr.GetValue("value");
ProcessROReturnValue(ref rc, rc.value, GetRODatabaseTitleIndex(rc.roid));
rc.appid = (string)dr.GetValue("AccPageID");
if (!string.IsNullOrEmpty((string)dr.GetValue("value")))
{
rc.value = (string)dr.GetValue("value");
ProcessROReturnValue(ref rc, rc.value, GetRODatabaseTitleIndex(rc.roid));
}
}
else if (loadChildren || loadAllChildren)
{
@@ -1561,6 +1584,7 @@ namespace VEPROMS.CSLA.Library
{
child.children = new ROFSTLookup.rochild[lstValues.Count];
// Load all extension specific return values (1 to many)
for (int i = 0; i < lstValues.Count; i++)
{
var roExt = Extensions.Where(x => x.Offset.Equals(i + 1)).SingleOrDefault();
@@ -1577,7 +1601,23 @@ namespace VEPROMS.CSLA.Library
child.children[i].children = new List<ROFSTLookup.rochild>().ToArray();
}
child.value = null;
if (AutoCombineSingleRetValues && lstValues.Count == 1)
{
// When the RO object only has only return value and the "AutoCombineSingleRetValues" is set to True.
// Instead of returning the RoChildBase object with a single RoReturnVal object attached, just return the single Ro ReturnValue object.
var roRetVal = child.children.First();
//child.title = roRetVal.title;
child.appid = roRetVal.appid;
child.roid = roRetVal.roid;
child.value = roRetVal.value;
child.children = new List<ROFSTLookup.rochild>().ToArray();
}
else
{
child.value = null;
}
}
_lstRoValues.Clear();
@@ -1645,7 +1685,6 @@ namespace VEPROMS.CSLA.Library
// If Default Value is selected (selChldIdx = 0), and return value is empty then replace with Standard Missing Default Value
return (selChldIdx == 0 && sb.ToString().Trim().Length <= 0) ? ROFSTLookup.RoMissingDefaultValue : sb.ToString().Trim();
//return sb.ToString();
}
private List<string> GetROReturnValue(string roval)
@@ -1888,7 +1927,8 @@ namespace VEPROMS.CSLA.Library
private string ReplaceUnicode(string s2, bool DoCaret)
{
string orig = s2;
if (string.IsNullOrEmpty(s2))
return s2;
s2 = s2.Replace(@"\u160?", "<HSP>"); // convert hard spaces bug fix: B2016-206
s2 = s2.Replace(@"\", @"\u9586?"); // convert backslashes to a backslash symbol
@@ -1935,9 +1975,10 @@ namespace VEPROMS.CSLA.Library
s2 = s2.Replace("\xD6", @"\u8595?"); // Down Arrow
if (DoCaret) s2 = s2.Replace("^", @"\u916?");
// Convert dash to a non-breaking dash. This is a unicode character.
// This character will be used in veproms rather than a dash.
//if the dash is preceeded byte a token remove the space following the token
// Convert dash to a non-breaking dash. This is a Unicode character.
// This character will be used in PROMS rather than a dash.
// if the dash is proceeded byte a token remove the space following the token
s2 = Regex.Replace(s2, @"(\\[^ \\?]*) \-", @"$1\u8209?");
s2 = s2.Replace("-", @"\u8209?");