B2022-098: ROs not being resolved in Word Sections
This commit is contained in:
@@ -129,7 +129,8 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public const string RoMissingDefaultValue = "[TBD]";
|
||||
|
||||
private static List<RoExtension> _extensions;
|
||||
private List<RoExtension> _extensions;
|
||||
private List<string> _baseAccPageKeys;
|
||||
|
||||
// RofstLookup/Conversion Variables
|
||||
private int _rofstID;
|
||||
@@ -197,6 +198,18 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> BaseAccPageKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_baseAccPageKeys == null)
|
||||
{
|
||||
_baseAccPageKeys = GetBaseAccPageKeys();
|
||||
}
|
||||
|
||||
return _baseAccPageKeys;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutoCombineSingleRetValues
|
||||
{
|
||||
@@ -304,82 +317,34 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public string FormatAccPageKey(string accPageID)
|
||||
{
|
||||
if (string.IsNullOrEmpty(accPageID))
|
||||
return accPageID;
|
||||
string accPageBase = string.Empty;
|
||||
string accPageExt = string.Empty;
|
||||
|
||||
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);
|
||||
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
|
||||
}
|
||||
|
||||
public string FormatAccPageKey(string accPageID, ref string accPageBase, ref string accPageExt, bool useDefaultExt = true)
|
||||
public string FormatAccPageKey(string accPageID, ref string accPageBase, ref string accPageExt)
|
||||
{
|
||||
string accPageKey = FormatAccPageKey(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;
|
||||
|
||||
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;
|
||||
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
|
||||
}
|
||||
|
||||
public static string FormatAccPageKey(string accPageID, string spDefault, string igDefault)
|
||||
public string FormatAccPageKey(string accPageID, string spDefault, string igDefault)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(accPageID))
|
||||
{
|
||||
accPageID = accPageID.ToUpper();
|
||||
|
||||
if (!accPageID.StartsWith("<"))
|
||||
accPageID = string.Format("<{0}", accPageID);
|
||||
string accPageBase = string.Empty;
|
||||
string accPageExt = string.Empty;
|
||||
|
||||
if (!accPageID.EndsWith(">"))
|
||||
accPageID = string.Format("{0}>", accPageID);
|
||||
|
||||
accPageID = accPageID.Replace("<U>", "<U-NUMBER>");
|
||||
accPageID = accPageID.ToCleanString(); // Removes any spaces
|
||||
|
||||
// Clean up the AccPageID before using it to do a lookup
|
||||
if (!string.IsNullOrEmpty(spDefault))
|
||||
accPageID = accPageID.Replace("<SP-", "<" + spDefault + "-");
|
||||
|
||||
if (!string.IsNullOrEmpty(igDefault))
|
||||
accPageID = accPageID.Replace("<IG-", "<" + igDefault + "-");
|
||||
|
||||
if (!accPageID.StartsWith("<U-"))
|
||||
accPageID = accPageID.Trim("<>".ToCharArray()); // String < and >
|
||||
|
||||
accPageID = regRoKeyHigh.Replace(accPageID, "_HIGH$3");
|
||||
accPageID = regRoKeyLow.Replace(accPageID, "_LOW$3");
|
||||
accPageID = accPageID.ToUpper();
|
||||
}
|
||||
|
||||
return accPageID;
|
||||
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
|
||||
}
|
||||
|
||||
public static string FormatAccPageKey(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt, bool useDefaultExt = true)
|
||||
public string FormatAccPageKey(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt)
|
||||
{
|
||||
string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault);
|
||||
|
||||
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;
|
||||
return FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
|
||||
}
|
||||
|
||||
public ROFSTLookup.rochild GetROChildByAccPageID(string accPageID)
|
||||
@@ -392,16 +357,19 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public ROFSTLookup.rochild GetROChildByAccPageID(string accPageID, string spDefault, string igDefault)
|
||||
{
|
||||
string accPageBase = string.Empty;
|
||||
string accPageExt = string.Empty;
|
||||
|
||||
// Cleanup accPageID if necessary [Note* This will also handle any UnitInfo Ro Values (ex: "<U-NUMBER>")]
|
||||
string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault);
|
||||
string accPageKey = FormatAccPageKeyWithExt(accPageID, spDefault, igDefault, ref accPageBase, ref accPageExt);
|
||||
|
||||
ROFSTLookup.rochild rc = RofstDataGetChildByAccPageID(_rofstID, accPageID, spDefault, igDefault);
|
||||
ROFSTLookup.rochild rc = RofstDataGetChildByAccPageID(_rofstID, accPageBase);
|
||||
|
||||
if (!string.IsNullOrEmpty(rc.roid) && rc.roid.Length < 16 && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0)
|
||||
//if (rc.ID >=0 && rc.roid.Length < 16 && Regex.IsMatch(accPageKey, @".*\.[A-Z]") && rc.children != null && rc.children.Count() > 0)
|
||||
if (rc.ID >= 0 && rc.roid.Length < 16 && !string.IsNullOrEmpty(accPageExt) && 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
|
||||
var accPageExt = Convert.ToString(accPageKey.ToCharArray().LastOrDefault());
|
||||
var roExt = Extensions.Where(x => x.AccPageExt.Equals(accPageExt)).SingleOrDefault();
|
||||
|
||||
return (rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt && !string.IsNullOrEmpty(x.value)).Any()) ? rc.children.Where(x => x.roid.Substring(12, 4) == roExt.RoidExt).Single() : rc.children.First();
|
||||
@@ -476,12 +444,12 @@ namespace VEPROMS.CSLA.Library
|
||||
|
||||
public string GetTranslatedRoValue(string roid, bool DoCaret, bool DoDOSSuperSubScript)
|
||||
{
|
||||
roid = FormatRoidKey(roid);
|
||||
roid = FormatRoidKey(roid, true);
|
||||
|
||||
string retval = GetRoChild(roid).value;
|
||||
|
||||
if (string.IsNullOrEmpty(retval))
|
||||
return string.Empty;
|
||||
return "?"; // Returning a "?" character indicates that the selected RO Value no longer exists or has been deleted.
|
||||
|
||||
retval = ReplaceUnicode(retval, DoCaret);
|
||||
retval = ConvertFortranFormatToScienctificNotation(retval);
|
||||
@@ -1216,6 +1184,40 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetBaseAccPageKeys()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> lst = new List<string>();
|
||||
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = cn.CreateCommand())
|
||||
{
|
||||
cmd.CommandTimeout = Database.DefaultTimeout;
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = "vesp_RofstDataGetBaseAccPageKeys";
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@RofstID", SqlDbType.Int)).Value = _rofstID;
|
||||
|
||||
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
lst.Add(dr.GetValue("BaseAccPageID").ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lst;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("RofstData.vesp_RofstDataGetBaseAccPageKeys", ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region (Core/Base logic for RO Values & UnitInfo RO Values)
|
||||
@@ -1263,17 +1265,14 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
|
||||
private ROFSTLookup.rochild RofstDataGetChildByAccPageID(int rofstID, string accPageID, string spDefault, string igDefault, bool loadChildren = false, bool loadAllChildren = false)
|
||||
private ROFSTLookup.rochild RofstDataGetChildByAccPageID(int rofstID, string accPageID)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Cleanup / Reformat the AccPageID if necessary (Note* This method also handles the UnitInfo Ro Values. ex: "<U-NUMBER>")
|
||||
string accPageKey = FormatAccPageKey(accPageID, spDefault, igDefault);
|
||||
|
||||
// Check if roid is for a Unit Information RO Value Tag
|
||||
if (!string.IsNullOrEmpty(accPageKey) && accPageKey.StartsWith("<U-"))
|
||||
if (!string.IsNullOrEmpty(accPageID) && accPageID.StartsWith("<U-"))
|
||||
{
|
||||
return GetUnitInfoRoChild(GetUnitInfoRoidByAccPageID(accPageKey));
|
||||
return GetUnitInfoRoChild(GetUnitInfoRoidByAccPageID(accPageID));
|
||||
}
|
||||
|
||||
// Lookup RO Value in the database based on the AccPageKey
|
||||
@@ -1286,13 +1285,13 @@ namespace VEPROMS.CSLA.Library
|
||||
cmd.CommandText = "vesp_RofstDataGetChildByAccPageID";
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@RofstID", SqlDbType.Int)).Value = rofstID;
|
||||
cmd.Parameters.Add(new SqlParameter("@AccPageID", SqlDbType.VarChar)).Value = accPageKey;
|
||||
cmd.Parameters.Add(new SqlParameter("@AccPageID", SqlDbType.VarChar)).Value = accPageID;
|
||||
|
||||
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
|
||||
{
|
||||
if (dr.Read())
|
||||
{
|
||||
return ConvertToRochildObject(dr, loadChildren, loadAllChildren);
|
||||
return ConvertToRochildObject(dr, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1306,6 +1305,53 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
|
||||
private string FormatAccPageKeyWithExt(string accPageID, string spDefault, string igDefault, ref string accPageBase, ref string accPageExt)
|
||||
{
|
||||
accPageBase = string.Empty;
|
||||
accPageExt = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(accPageID))
|
||||
{
|
||||
accPageID = accPageID.ToUpper();
|
||||
|
||||
if (!accPageID.StartsWith("<")) accPageID = string.Format("<{0}", accPageID);
|
||||
if (!accPageID.EndsWith(">")) accPageID = string.Format("{0}>", accPageID);
|
||||
|
||||
accPageID = accPageID.Replace("<U>", "<U-NUMBER>");
|
||||
accPageID = accPageID.ToCleanString(); // Removes any spaces
|
||||
|
||||
// Clean up the AccPageID before using it to do a lookup
|
||||
if (accPageID.StartsWith("<U-"))
|
||||
{
|
||||
accPageBase = accPageID;
|
||||
accPageExt = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(spDefault)) accPageID = accPageID.Replace("<SP-", "<" + spDefault + "-");
|
||||
if (!string.IsNullOrEmpty(igDefault)) accPageID = accPageID.Replace("<IG-", "<" + igDefault + "-");
|
||||
|
||||
accPageID = regRoKeyHigh.Replace(accPageID, "_HIGH$3");
|
||||
accPageID = regRoKeyLow.Replace(accPageID, "_LOW$3");
|
||||
accPageID = accPageID.Trim("<>".ToCharArray()); // String < and >
|
||||
|
||||
// Check the end of the AccPageID to determine if its an extension or part of the base key
|
||||
// If the AccPageID doesn't have an extension then set to default
|
||||
if (!Regex.IsMatch(accPageID, @".*\.[A-Z]") || BaseAccPageKeys.Contains(accPageID))
|
||||
{
|
||||
// No Extension, set to default
|
||||
accPageID = string.Format("{0}.A", accPageID);
|
||||
}
|
||||
|
||||
// Set AccPage Base and Extension return values
|
||||
accPageBase = accPageID.Substring(0, (accPageID.Length - 2));
|
||||
accPageExt = Convert.ToString(accPageID.ToCharArray().LastOrDefault());
|
||||
}
|
||||
}
|
||||
|
||||
return (!string.IsNullOrEmpty(accPageID)) ? accPageID.ToUpper() : accPageID;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region (Parse/Load)
|
||||
|
Reference in New Issue
Block a user