using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CobXmlSupport { public class qualifieldhlp { private CobRow qualifiedRow; private List qualRows; private Dictionary locIndexis; private string qfhCode, qfhInd ; private string[] indexStrs; public string indexText { get { return qfhInd; } } public string[] indexStrings { get { return indexStrs; } } public qualifieldhlp() { qualifiedRow = null; initQualifieldhlp(); } private void initQualifieldhlp() { qualRows = null; qfhCode = string.Empty; locIndexis = null; } public qualifieldhlp(CobRow actRow, Dictionary all_Inds) { initQualifieldhlp(); qualifiedRow = actRow; initQualRows(ref all_Inds); generateFieldCode(); } public void generateFieldCode() { generateFieldCode(false); } public void generateFieldCode(bool exp) { if (qualRows.Count > 0) { qfhCode = ""; foreach (CobRow localCobRow in qualRows) { if (qfhCode.Length > 0) { qfhCode += " OF "; } if (exp) qfhCode += localCobRow.FieldName.Replace(S.ettingPrefix, S.ettingExpPrefix); else qfhCode += localCobRow.FieldName; if (localCobRow.isOccurs) { string tmpInd; locIndexis.TryGetValue(localCobRow.FieldName, out tmpInd); qfhCode += " *> ( " + tmpInd + " )"; } qfhCode += "\r\n"; } if (this.indexText.Length > 0) { qfhCode += this.indexText ; } } } private void initLocIndexTxt() { qfhInd = ""; indexStrs = null; if (locIndexis!=null && locIndexis.Count > 0) { indexStrs=new string[locIndexis.Count]; int indCnt = 0; foreach (KeyValuePair tmpInd in locIndexis) { indexStrs[indCnt] = tmpInd.Value; if (qfhInd.Length == 0) { qfhInd = "( " + tmpInd.Value; } else { qfhInd += ",\r\n" + tmpInd.Value; } } qfhInd += " )\r\n"; } } private void initQualRows(ref Dictionary allInds) { CobRow tmpRow = qualifiedRow; if (qualRows == null) { qualRows = new List(); } while (true) { if (tmpRow.isOccurs) { if (locIndexis == null) locIndexis = new Dictionary(); string indVarName = ""; if (!allInds.TryGetValue(tmpRow.FieldName, out indVarName)) { indVarName = CobRow.checkLongNames(tmpRow.FieldName, 25) + "_ind"; allInds.Add(tmpRow.FieldName, indVarName); } locIndexis.Add(tmpRow.FieldName, indVarName); } qualRows.Add(tmpRow); if (tmpRow.LevelParent != null) { tmpRow = tmpRow.LevelParent; } else break; } initLocIndexTxt(); } public override string ToString() { return qfhCode; } public string ToExpString() { generateFieldCode(true); return qfhCode; } } }