private String[] toStringArray(Hashtable hashedRex) { ArrayList lst = new ArrayList(); for (int recnum = 0; recnum < ienLst.Count; recnum++) { String s = (String)ienLst[recnum]; Hashtable hashedFlds = (Hashtable)hashedRex[ienLst[recnum]]; for (int fldnum = 0; fldnum < requestedFields.Length; fldnum++) { String fmNum = requestedFields[fldnum]; bool external = false; if (fmNum.IndexOf('E') != -1) { fmNum = fmNum.Substring(0, fmNum.Length - 1); external = true; } DdrField fld = (DdrField)hashedFlds[fmNum]; if (external) { s += '^' + fld.ExternalValue; } else { s += '^' + fld.Value; } } lst.Add(s); } return((String[])lst.ToArray(typeof(String))); }
internal String[] toStringArray(Dictionary <String, Dictionary <String, DdrField> > records, Dictionary <String, String> identifierVals) { //ArrayList lst = new ArrayList(); IList <String> results = new List <String>(); for (int recnum = 0; recnum < _ienLst.Count; recnum++) { StringBuilder sb = new StringBuilder(); sb.Append(_ienLst[recnum]); Dictionary <String, DdrField> flds = records[_ienLst[recnum]]; //Hashtable hashedFlds = (Hashtable)records[_ienLst[recnum]]; for (int fldnum = 0; fldnum < _requestedFields.Length; fldnum++) { if (String.Equals(_requestedFields[fldnum], "WID")) { continue; } String fmNum = _requestedFields[fldnum]; bool external = false; if (fmNum.IndexOf('E') != -1) { fmNum = fmNum.Substring(0, fmNum.Length - 1); external = true; } DdrField fld = (DdrField)flds[fmNum]; if (external) { sb.Append('^'); sb.Append(fld.ExternalValue); } else { sb.Append('^'); sb.Append(fld.Value); } } if (identifierVals != null && identifierVals.Count > 0 && identifierVals.ContainsKey(_ienLst[recnum])) { sb.Append("^"); // packed results have this string before start of ID values sb.Append(identifierVals[_ienLst[recnum]]); } results.Add(sb.ToString()); } String[] final = new String[results.Count]; results.CopyTo(final, 0); return(final); }
internal string[] packResult(string[] lines) { int idx = 0; if (lines[idx] == VistaConstants.UNPACKED_NO_RESULTS) { return(new string[] { }); } Dictionary <String, Dictionary <String, DdrField> > rs = new Dictionary <string, Dictionary <string, DdrField> >(); Dictionary <String, String> identifierVals = new Dictionary <String, String>(); if ((idx = StringUtils.getIdx(lines, VistaConstants.BEGIN_ERRS, 0)) != -1) { throw new ConnectionException(getErrMsg(lines, idx)); } if ((idx = StringUtils.getIdx(lines, VistaConstants.BEGIN_DATA, 0)) != -1) { _ienLst = new List <String>(); // new ArrayList(); if (lines[++idx] != VistaConstants.BEGIN_IENS) { throw new UnexpectedDataException("Incorrectly formatted return data"); } idx++; while (lines[idx] != VistaConstants.END_IENS) { _ienLst.Add(lines[idx++]); } idx++; if (lines[idx] != VistaConstants.BEGIN_IDVALS) { throw new UnexpectedDataException("Incorrectly formatted return data"); } //String[] flds = StringUtils.split(lines[++idx], StringUtils.SEMICOLON); -- this line was wrong! see check for [MAP] index above to obtain field names IList <String> adjustedFields = new List <String>(); foreach (String s in _requestedFields) { if (!String.Equals("WID", s)) { adjustedFields.Add(s); } } int recIdx = 0; idx++; while (lines[idx] != VistaConstants.END_IDVALS) { // the last field in flds is the field count, not a field <--- I don't think this is a valid comment... Dictionary <String, DdrField> rec = new Dictionary <string, DdrField>(); //Hashtable rec = new Hashtable(); for (int fldIdx = 0; fldIdx < adjustedFields.Count; fldIdx++) // <--- changing this due to thinking the comment above is invalid { DdrField f = new DdrField(); f.FmNumber = _requestedFields[fldIdx]; String requestedOptions = (String)_requestedFieldsTbl[f.FmNumber]; f.HasExternal = requestedOptions.IndexOf('E') != -1; if (f.HasExternal) { f.ExternalValue = lines[idx++]; } if (requestedOptions.IndexOf('I') != -1) { f.Value = lines[idx++]; } rec.Add(f.FmNumber, f); } rs.Add((String)_ienLst[recIdx++], rec); } // any identifier params? if so, turn them in to a Dictionary<String, String> where key is IEN and all lines are separated by tilde just like packed results if (lines.Length > (idx + 1) && String.Equals(lines[++idx], VistaConstants.BEGIN_WIDVALS)) { idx++; while (!String.Equals(lines[idx], VistaConstants.END_WIDVALS)) { String[] pieces = StringUtils.split(lines[idx], StringUtils.CARET); StringBuilder sb = new StringBuilder(); while (!lines[++idx].StartsWith("WID") && !String.Equals(lines[idx], VistaConstants.END_WIDVALS)) { sb.Append(lines[idx]); sb.Append(StringUtils.TILDE); } sb.Remove(sb.Length - 1, 1); identifierVals.Add(pieces[1], sb.ToString()); } } // at this point line should be VistaConstants.END_DATA // unless more functionality is added. } return(toStringArray(rs, identifierVals)); }
private string[] packResult(string[] lines) { int idx = 0; if (lines[idx] == VistaConstants.UNPACKED_NO_RESULTS) { return new string[] { }; } Hashtable rs = new Hashtable(); if ((idx = StringUtils.getIdx(lines, VistaConstants.BEGIN_ERRS, 0)) != -1) { throw new ConnectionException(getErrMsg(lines,idx)); } if ((idx = StringUtils.getIdx(lines, VistaConstants.BEGIN_DATA, 0)) != -1) { ienLst = new ArrayList(); if (lines[++idx] != VistaConstants.BEGIN_IENS) { throw new UnexpectedDataException("Incorrectly formatted return data"); } idx++; while (lines[idx] != VistaConstants.END_IENS) { ienLst.Add(lines[idx++]); } idx++; if (lines[idx] != VistaConstants.BEGIN_IDVALS) { throw new UnexpectedDataException("Incorrectly formatted return data"); } String[] flds = StringUtils.split(lines[++idx], StringUtils.SEMICOLON); int recIdx = 0; idx++; while (lines[idx] != VistaConstants.END_IDVALS) { // the last field in flds is the field count, not a field Hashtable rec = new Hashtable(); for (int fldIdx = 0; fldIdx < flds.Length-1; fldIdx++) { DdrField f = new DdrField(); f.FmNumber = flds[fldIdx]; String requestedOptions = (String)requestedFieldsTbl[f.FmNumber]; f.HasExternal = requestedOptions.IndexOf('E') != -1; if (f.HasExternal) { f.ExternalValue = lines[idx++]; } if (requestedOptions.IndexOf('I') != -1) { f.Value = lines[idx++]; } rec.Add(f.FmNumber, f); } rs.Add((String)ienLst[recIdx++], rec); } // at this point line should be VistaConstants.END_DATA // unless more functionality is added. } return toStringArray(rs); }
private string[] packResult(string[] lines) { int idx = 0; if (lines[idx] == VistaConstants.UNPACKED_NO_RESULTS) { return(new string[] { }); } Hashtable rs = new Hashtable(); if ((idx = StringUtils.getIdx(lines, VistaConstants.BEGIN_ERRS, 0)) != -1) { throw new ConnectionException(getErrMsg(lines, idx)); } if ((idx = StringUtils.getIdx(lines, VistaConstants.BEGIN_DATA, 0)) != -1) { ienLst = new ArrayList(); if (lines[++idx] != VistaConstants.BEGIN_IENS) { throw new UnexpectedDataException("Incorrectly formatted return data"); } idx++; while (lines[idx] != VistaConstants.END_IENS) { ienLst.Add(lines[idx++]); } idx++; if (lines[idx] != VistaConstants.BEGIN_IDVALS) { throw new UnexpectedDataException("Incorrectly formatted return data"); } String[] flds = StringUtils.split(lines[++idx], StringUtils.SEMICOLON); int recIdx = 0; idx++; while (lines[idx] != VistaConstants.END_IDVALS) { // the last field in flds is the field count, not a field Hashtable rec = new Hashtable(); for (int fldIdx = 0; fldIdx < flds.Length - 1; fldIdx++) { DdrField f = new DdrField(); f.FmNumber = flds[fldIdx]; String requestedOptions = (String)requestedFieldsTbl[f.FmNumber]; f.HasExternal = requestedOptions.IndexOf('E') != -1; if (f.HasExternal) { f.ExternalValue = lines[idx++]; } if (requestedOptions.IndexOf('I') != -1) { f.Value = lines[idx++]; } rec.Add(f.FmNumber, f); } rs.Add((String)ienLst[recIdx++], rec); } // at this point line should be VistaConstants.END_DATA // unless more functionality is added. } return(toStringArray(rs)); }