C2021-026 Parent/Child applicability in RO Editor

This commit is contained in:
2021-07-29 18:28:12 +00:00
parent 697490d5bf
commit ce9e9e182e
16 changed files with 1103 additions and 263 deletions

View File

@@ -300,6 +300,40 @@ namespace VEPROMS.CSLA.Library
}
return val;
}
// C2021-026 Get the child RO value if it exists, otherwise to the default (parent) RO value
public string GetParentChildROValue(rochild roc)
{
string roval = roc.value;
// get the child (slave) information and set the rtnchld.value to the corresponding RO Value
int selChldIdx = MyDocVersionInfo.DocVersionConfig.SelectedSlave;
string childName = MyDocVersionInfo.DocVersionConfig.Unit_Name;
string aplString = roval;
string ChldValue = "";
// if the RO Value contains Parent/Child values, parse out default value and the child (slave or unit specific) value
while (roval.Contains("<APL DefaultVal="))
{
int startCVIdx = roval.IndexOf("<APL DefaultVal=");
int EndCVidx = roval.IndexOf(" /APL>", startCVIdx);
aplString = roval.Substring(startCVIdx, EndCVidx + 6 - startCVIdx);
int endDefIdx = aplString.IndexOf(",UnitIdx=",startCVIdx); // look for more than just a comma incase value contains a comma
string defValue = aplString.Substring(16,endDefIdx-16); // save the default RO value
int idx = aplString.IndexOf("UnitIdx=" + selChldIdx.ToString()); // look for a specific child (slave/unit) value
if (selChldIdx > 0 && idx > -1 && idx < aplString.Length)
{
idx = aplString.IndexOf("Value=", idx) + 6;
int idxEndVal = aplString.IndexOf(",UnitIdx=", idx); // look for more than just a comma incase value contains a comma
if (idxEndVal == -1) idxEndVal = EndCVidx; // if last child value is up to " /APL>"
if (idxEndVal > idx)
ChldValue = aplString.Substring(idx, idxEndVal - idx); // selected Child RO value
else
ChldValue = defValue; // incomplete "<APL ..." structure use default value
}
else
ChldValue = defValue; // could not find a value for the selected child so use the default value
roval = roval.Replace(aplString, ChldValue); // replace the entire Parent/Child value string ("<APL ... /APL>") with the specifc value
}
return roval;
}
// this only gets rochild values. Later we may want another
// dictionary to get groups.
public string GetRoValue(string ROID16)
@@ -311,14 +345,14 @@ namespace VEPROMS.CSLA.Library
{
rochild rochld = (rochild)dicRos[ROID.ToUpper()];
if (rochld.value != null && rochld.value != string.Empty)
return FixUnitROs( rochld.value);
return FixUnitROs(GetParentChildROValue(rochld));
if (rochld.children != null)
{
foreach (rochild child in rochld.children)
if (child.roid.ToUpper() == ROID16.ToUpper() || (child.roid.EndsWith("0041") && ROID16.EndsWith("0000")))
return FixUnitROs(child.value ?? "?");
// if there isn't a specific match for multi-return values, default to the first child.
return FixUnitROs(rochld.children[0].value ?? "?");
return FixUnitROs(GetParentChildROValue(child) ?? "?");
// if there isn't a specific match for multi-return values, default to the first child.
return FixUnitROs(GetParentChildROValue(rochld.children[0]) ?? "?");
}
}
//if (ROID == "FFFF00000001") return _ROFstInfo.ROFstAssociations[0].MyDocVersion.DocVersionConfig.Unit_Number;
@@ -1140,7 +1174,7 @@ namespace VEPROMS.CSLA.Library
{
rochild? child = GetROChildByAccPageID(accPageID, spDefault, igDefault);
if (child == null) return null;
return ((rochild)child).value;
return GetParentChildROValue((rochild)child); // C2021-026 get the P/C value if it exists, otherwise get the non-P/C value
}
public int? GetROTypeByAccPagID(string accPageID, string spDefault, string igDefault)
{