C2022-001 logic to handle the new parent/child format of the RO.FST
This commit is contained in:
parent
c66c01332e
commit
8a2b19521d
@ -312,47 +312,78 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
// C2021-026 Get the child RO value if it exists, otherwise to the default (parent) RO value
|
// C2021-026 Get the child RO value if it exists, otherwise to the default (parent) RO value
|
||||||
|
// C2022-001 new logic to handle new format of Parent/Child RO.FST
|
||||||
|
// The RO.FST will not have a specific child value if that child value is the same as the default value
|
||||||
public string GetParentChildROValue(rochild roc)
|
public string GetParentChildROValue(rochild roc)
|
||||||
{
|
{
|
||||||
string roval = roc.value;
|
string roval = roc.value;
|
||||||
// B2021-093 Don't look for child RO values if "roval" is null
|
// B2021-093 Don't look for child RO values if "roval" is null
|
||||||
if (roval == null) return null;
|
if (roval == null) return null;
|
||||||
// get the child (slave) information and set the rtnchld.value to the corresponding RO Value
|
//string childName = MyDocVersionInfo.DocVersionConfig.Unit_Name;
|
||||||
|
MatchCollection mm = Regex.Matches(roval, "(<APL [^<?]+) /APL>");
|
||||||
|
if (mm.Count > 1)
|
||||||
|
Console.WriteLine("Matches {0}", mm.Count);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int lastIndex = 0;
|
||||||
|
// Get selected child Idx
|
||||||
int selChldIdx = MyDocVersionInfo.DocVersionConfig.SelectedSlave;
|
int selChldIdx = MyDocVersionInfo.DocVersionConfig.SelectedSlave;
|
||||||
string childName = MyDocVersionInfo.DocVersionConfig.Unit_Name;
|
|
||||||
string aplString = roval;
|
|
||||||
string ChldValue = "";
|
|
||||||
// C2021-065 see if we need to get the RO information for the "Other" Child applicability value
|
// C2021-065 see if we need to get the RO information for the "Other" Child applicability value
|
||||||
if (OtherChild != null && OtherChild != "")
|
if (OtherChild != null && OtherChild != "")
|
||||||
{
|
|
||||||
selChldIdx = Convert.ToInt32(OtherChild); // the OTHER unit number
|
selChldIdx = Convert.ToInt32(OtherChild); // the OTHER unit number
|
||||||
childName = MyDocVersionInfo.DocVersionConfig.Other_Unit_Name;
|
foreach (Match m in mm)
|
||||||
}
|
|
||||||
// if the RO Value contains Parent/Child values, parse out default value and the child (slave or unit specific) value
|
|
||||||
while (roval != null && roval.Contains("<APL DefaultVal="))
|
|
||||||
{
|
{
|
||||||
int startCVIdx = roval.IndexOf("<APL DefaultVal=");
|
sb.Append(roval.Substring(lastIndex, m.Index - lastIndex));
|
||||||
int EndCVidx = roval.IndexOf(" /APL>", startCVIdx);
|
Console.WriteLine("Index={0},Length={1},value={2}",m.Index,m.Length,m.Value);
|
||||||
aplString = roval.Substring(startCVIdx, EndCVidx + 6 - startCVIdx);
|
string aplString = m.Value;
|
||||||
int endDefIdx = aplString.IndexOf(",UnitIdx=",startCVIdx); // look for more than just a comma incase value contains a comma
|
string chldValStr = string.Format("UnitIdx={0} Value=", selChldIdx);
|
||||||
string defValue = aplString.Substring(16,endDefIdx-16); // save the default RO value
|
int offsetIdx = aplString.IndexOf(chldValStr);//m.Value.IndexOf(chldValStr);
|
||||||
int idx = aplString.IndexOf("UnitIdx=" + selChldIdx.ToString()); // look for a specific child (slave/unit) value
|
int nextIDX = -1;
|
||||||
if (selChldIdx > 0 && idx > -1 && idx < aplString.Length)
|
if (offsetIdx == -1)
|
||||||
{
|
offsetIdx = aplString.IndexOf("DefaultVal=") + 11;
|
||||||
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)// if last child value is up to " /APL>"
|
|
||||||
idxEndVal = aplString.IndexOf(" /APL>", idx); // B2021-141 get end of Parent/Child RO Values for this RO reference
|
|
||||||
if (idxEndVal > idx)
|
|
||||||
ChldValue = aplString.Substring(idx, idxEndVal - idx); // selected Child RO value
|
|
||||||
else
|
else
|
||||||
ChldValue = defValue; // incomplete "<APL ..." structure use default value
|
offsetIdx += chldValStr.Length;
|
||||||
|
nextIDX = aplString.IndexOf(",UnitIdx", offsetIdx);
|
||||||
|
if (nextIDX == -1) nextIDX = aplString.IndexOf(" /APL>");
|
||||||
|
sb.Append(aplString.Substring(offsetIdx, nextIDX - offsetIdx));
|
||||||
|
lastIndex += m.Index + m.Length;
|
||||||
}
|
}
|
||||||
else
|
return sb.ToString();
|
||||||
ChldValue = defValue; // could not find a value for the selected child so use the default value
|
//int startCVIdx = roval.IndexOf("<APL DefaultVal=");
|
||||||
roval = roval.Replace(aplString, ChldValue); // replace the entire Parent/Child value string ("<APL ... /APL>") with the specifc value
|
//// Get default value from DefaultVal= to UnitIdx= or /APL>;
|
||||||
}
|
|
||||||
return roval;
|
//int EndCVidx = roval.IndexOf(" /APL>", startCVIdx);
|
||||||
|
//int endDefIdx = roval.IndexOf(",UnitIdx=", startCVIdx); // look for more than just a comma incase value contains a comma
|
||||||
|
//string defValue = roval.Substring(16, (endDefIdx > 0 ? endDefIdx : EndCVidx) - 16); // save the default RO value
|
||||||
|
//// Get
|
||||||
|
//// Get selected child Idx
|
||||||
|
//int selChldIdx = MyDocVersionInfo.DocVersionConfig.SelectedSlave;
|
||||||
|
//// Get selected value
|
||||||
|
////return either default value or child value as appropriate
|
||||||
|
//return defValue;
|
||||||
|
// get the child (slave) information and set the rtnchld.value to the corresponding RO Value
|
||||||
|
//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 != null && roval.Contains("<APL DefaultVal="))
|
||||||
|
////{
|
||||||
|
// aplString = roval.Substring(startCVIdx, EndCVidx + 6 - startCVIdx);
|
||||||
|
// 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)// if last child value is up to " /APL>"
|
||||||
|
// idxEndVal = aplString.IndexOf(" /APL>", idx); // B2021-141 get end of Parent/Child RO Values for this RO reference
|
||||||
|
// 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
|
// this only gets rochild values. Later we may want another
|
||||||
// dictionary to get groups.
|
// dictionary to get groups.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user