From 8a2b19521dc0a2da761ba377e7274890b96e82a8 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 21 Jan 2022 14:33:49 +0000 Subject: [PATCH] C2022-001 logic to handle the new parent/child format of the RO.FST --- .../Config/ROFSTLookup.cs | 89 +++++++++++++------ 1 file changed, 60 insertions(+), 29 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index 2ae6ba5f..e55beb62 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -312,47 +312,78 @@ namespace VEPROMS.CSLA.Library return val; } // 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) { string roval = roc.value; // B2021-093 Don't look for child RO values if "roval" is 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, "("); + 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; - 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 if (OtherChild != null && OtherChild != "") - { selChldIdx = Convert.ToInt32(OtherChild); // the OTHER unit number - childName = MyDocVersionInfo.DocVersionConfig.Other_Unit_Name; - } - // 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("", 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)// 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 "") with the specifc 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; } - return roval; + return sb.ToString(); + //int startCVIdx = roval.IndexOf("", 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("" + // 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 "") with the specifc value + ////} + //return roval; } // this only gets rochild values. Later we may want another // dictionary to get groups.