internal Dictionary <string, object> toMdo(string[] response, VistaFile theFile) { if (response == null || response.Length == 0) { return(null); } Dictionary <string, object> result = new Dictionary <string, object>(response.Length); for (int lineIdx = 0; lineIdx < response.Length; lineIdx++) { //Need to instantiate the mdo here Object theMdo = Activator.CreateInstance(Type.GetType(theFile.MdoName), new object[] { }); Type theClass = theMdo.GetType(); string[] flds = StringUtils.split(response[lineIdx], StringUtils.CARET); for (int fldIdx = 0; fldIdx < flds.Length; fldIdx++) { VistaField vf = (VistaField)((DictionaryEntry)theFile.Fields[fldIdx]).Value; FieldInfo theField = theClass.GetField(vf.MdoName, BindingFlags.NonPublic | BindingFlags.Instance); if (vf.MdoType == "string") { if (vf.Mapping != null && vf.Mapping.Type == "decode") { if (vf.Mapping.DecodeMap.ContainsKey(flds[fldIdx])) { theField.SetValue(theMdo, vf.Mapping.DecodeMap[flds[fldIdx]]); } else { theField.SetValue(theMdo, flds[fldIdx]); } } else { theField.SetValue(theMdo, flds[fldIdx]); } } else if (vf.MdoType == "kvp") { string key = flds[fldIdx]; string value = ""; if (vf.Mapping != null && vf.Mapping.Type == "decode") { value = vf.Mapping.DecodeMap[key]; } else { StringDictionary lookupTbl = getLookupTable(vf.Mapping.VistaFileNumber); if (lookupTbl.ContainsKey(key)) { value = lookupTbl[key]; } } theField.SetValue(theMdo, new KeyValuePair <string, string>(key, value)); //KeyValuePair<string, string> kvp = new KeyValuePair<string, string>(key, value); } } result.Add(flds[0], theMdo); } return(result); }
void setFields() { fields = new Dictionary <string, VistaField>(NFLDS); VistaField f = new VistaField(); f.VistaName = "IEN"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".01"; f.VistaName = "NAME"; f.VistaNode = "0"; f.VistaPiece = "1"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".02"; f.VistaName = "CONTEXTOPTION"; f.VistaNode = "0"; f.VistaPiece = "2"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".03"; f.VistaName = "APPLICATIONCODE"; f.VistaNode = "0"; f.VistaPiece = "3"; fields.Add(f.VistaName, f); }
internal static DdrFiler buildAddRecordQuery(AbstractConnection cxn, RemoteApplicationRecord rec, CallBackFileRecord subrec) { DdrFiler query = new DdrFiler(cxn); query.Operation = "ADD"; ArrayList lst = new ArrayList(7); VistaField f = rec.Fields["NAME"]; lst.Add(FILE_NUMBER + "^" + f.VistaNumber + "^+1,^" + f.VistaValue); f = rec.Fields["CONTEXTOPTION"]; VistaUserDao dao = new VistaUserDao(cxn); lst.Add(FILE_NUMBER + "^" + f.VistaNumber + "^+1,^" + dao.getOptionIen(f.VistaValue)); f = rec.Fields["APPLICATIONCODE"]; lst.Add(FILE_NUMBER + "^" + f.VistaNumber + "^+1,^" + f.VistaValue); f = subrec.Fields["CALLBACKTYPE"]; lst.Add(CALLBACK_FILE_NUMBER + "^" + f.VistaNumber + "^+2,+1^" + f.VistaValue); f = subrec.Fields["CALLBACKPORT"]; lst.Add(CALLBACK_FILE_NUMBER + "^" + f.VistaNumber + "^+2,+1^" + f.VistaValue); f = subrec.Fields["CALLBACKSERVER"]; lst.Add(CALLBACK_FILE_NUMBER + "^" + f.VistaNumber + "^+2,+1^" + f.VistaValue); f = subrec.Fields["URLSTRING"]; lst.Add(CALLBACK_FILE_NUMBER + "^" + f.VistaNumber + "^+2,+1^" + f.VistaValue); query.Args = (string[])lst.ToArray(typeof(string)); return(query); }
public Dictionary <string, VistaField> getFields(VistaFile file) { Dictionary <string, VistaField> result = new Dictionary <string, VistaField>(); string currentFieldName = getVariableValue(String.Format("$O(^DD({0},\"B\",\"{1}\"))", file.FileNumber, "")); while (!String.IsNullOrEmpty(currentFieldName)) { VistaField currentField = getField(file, currentFieldName, ref currentFieldName); // passed by reference because RPC below fetches next field name for loop if (!result.ContainsKey(currentField.VistaNumber)) { result.Add(currentField.VistaNumber, currentField); } //currentFieldName = getVariableValue(String.Format("$O(^DD({0},\"B\",\"{1}\"))", file.FileNumber, currentFieldName)); } return(result); }
void setFields() { fields = new Dictionary <string, VistaField>(NFLDS); VistaField f = new VistaField(); f.VistaName = "IEN"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".01"; f.VistaName = "CALLBACKTYPE"; f.VistaNode = "0"; f.VistaPiece = "1"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".02"; f.VistaName = "CALLBACKPORT"; f.VistaNode = "0"; f.VistaPiece = "2"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".03"; f.VistaName = "CALLBACKSERVER"; f.VistaNode = "0"; f.VistaPiece = "3"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".04"; f.VistaName = "URLSTRING"; f.VistaNode = "0"; f.VistaPiece = "4"; fields.Add(f.VistaName, f); }
internal void getFileDefs() { VistaFile currentFile = null; VistaField currentFld = null; fileDefs = new Hashtable(); XmlReader reader = new XmlTextReader(VistaConstants.VISTA_FILEDEFS_PATH); while (reader.Read()) { switch ((int)reader.NodeType) { case (int)XmlNodeType.Element: string name = reader.Name; if (name == "File") { currentFile = new VistaFile(); currentFile.FileName = reader.GetAttribute("name"); currentFile.FileNumber = reader.GetAttribute("number"); currentFile.Global = reader.GetAttribute("global"); currentFile.MdoName = reader.GetAttribute("mdo"); } else if (name == "fields") { currentFile.Fields = new DictionaryHashList(); } else if (name == "field") { currentFld = new VistaField(); currentFld.Pos = Convert.ToInt16(reader.GetAttribute("pos")); } else if (name == "vista") { currentFld.VistaName = reader.GetAttribute("name"); currentFld.VistaNumber = reader.GetAttribute("number"); currentFld.VistaNode = reader.GetAttribute("node"); currentFld.VistaPiece = reader.GetAttribute("piece"); currentFile.Fields.Add(currentFld.Pos.ToString(), currentFld); } else if (name == "mdo") { currentFld.MdoName = reader.GetAttribute("name"); currentFld.MdoType = reader.GetAttribute("type"); } else if (name == "mapping") { string mappingType = reader.GetAttribute("type"); currentFld.Mapping = new VistaFieldMapping(mappingType); if (currentFld.Mapping.Type == "pointer") { currentFld.Mapping.VistaFileNumber = reader.GetAttribute("file"); } else if (currentFld.Mapping.Type == "decode") { currentFld.Mapping.DecodeMap = new StringDictionary(); } } else if (name == "map") { currentFld.Mapping.DecodeMap.Add(reader.GetAttribute("code"), reader.GetAttribute("value")); } break; case (int)XmlNodeType.EndElement: name = reader.Name; if (name == "File") { fileDefs.Add(currentFile.FileNumber, currentFile); } else if (name == "fields") { } else if (name == "field") { } else if (name == "vista") { } else if (name == "mdo") { } else if (name == "mapping") { } else if (name == "map") { } break; } } }
void setFields() { fields = new Dictionary<string, VistaField>(NFLDS); VistaField f = new VistaField(); f.VistaName = "IEN"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".01"; f.VistaName = "NAME"; f.VistaNode = "0"; f.VistaPiece = "1"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".02"; f.VistaName = "CONTEXTOPTION"; f.VistaNode = "0"; f.VistaPiece = "2"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".03"; f.VistaName = "APPLICATIONCODE"; f.VistaNode = "0"; f.VistaPiece = "3"; fields.Add(f.VistaName, f); }
void setFields() { fields = new Dictionary<string, VistaField>(NFLDS); VistaField f = new VistaField(); f.VistaName = "IEN"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".01"; f.VistaName = "CALLBACKTYPE"; f.VistaNode = "0"; f.VistaPiece = "1"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".02"; f.VistaName = "CALLBACKPORT"; f.VistaNode = "0"; f.VistaPiece = "2"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".03"; f.VistaName = "CALLBACKSERVER"; f.VistaNode = "0"; f.VistaPiece = "3"; fields.Add(f.VistaName, f); f = new VistaField(); f.VistaNumber = ".04"; f.VistaName = "URLSTRING"; f.VistaNode = "0"; f.VistaPiece = "4"; fields.Add(f.VistaName, f); }
private VistaField setPropsForCodes(VistaField result, string p) { throw new NotImplementedException(); }
internal VistaField getField(VistaFile file, string fieldName, ref string nextField) { VistaField result = new VistaField(); result.VistaName = fieldName; // get next field, get field number and get field props with one combined query delimited with the |^| string string combinedQuery = String.Format("$O(^DD({0},\"B\",\"{1}\"))_\"|^|\"_$O(^DD({0},\"B\",\"{1}\",0))_\"|^|\"_$G(^DD({0},$O(^DD({0},\"B\",\"{1}\",0)),0))", file.FileNumber, fieldName); string combinedResults = getVariableValue(combinedQuery); string[] pieces = StringUtils.split(combinedResults, "|^|"); nextField = pieces[0]; result.VistaNumber = pieces[1]; string fieldProps = pieces[2]; //result.VistaNumber = getVariableValue(String.Format("$O(^DD({0},\"B\",\"{1}\",0))", file.FileNumber, fieldName)); //string fieldProps = getVariableValue(String.Format("$G(^DD({0},{1},0))", file.FileNumber, result.VistaNumber)); string[] propPieces = StringUtils.split(fieldProps, StringUtils.CARET); if (propPieces.Length < 4) { return(result); } result.Type = propPieces[1]; result.VistaNode = String.Concat("(", propPieces[3], ")"); if (propPieces.Length > 2 && !String.IsNullOrEmpty(propPieces[1])) { if (propPieces[1].Contains("P") && !String.IsNullOrEmpty(propPieces[2])) { result.IsPointer = true; string pointedToFileHeader = getVariableValue(String.Format("$G(^{0}0))", propPieces[2])); // need to put carat back in because string split removes it string[] pointedToFileHeaderPieces = StringUtils.split(pointedToFileHeader, StringUtils.CARET); result.PointsTo = new VistaFile() { Global = "^" + propPieces[2], // need to put carat back in because string split removes it FileName = pointedToFileHeaderPieces[0], FileNumber = pointedToFileHeaderPieces[1] }; } else if (String.Equals(propPieces[1], "S", StringComparison.CurrentCultureIgnoreCase)) { if (!String.IsNullOrEmpty(propPieces[2])) { result.Externals = new Dictionary <string, string>(); String[] externalsKeysAndVals = propPieces[2].Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (String individual in externalsKeysAndVals) { String[] keyAndVal = individual.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries); if (!result.Externals.ContainsKey(keyAndVal[0])) { result.Externals.Add(keyAndVal[0], keyAndVal[1]); } else { System.Console.WriteLine("Found dupe: " + keyAndVal[0] + " - " + keyAndVal[1] + " which was a duplicate of: " + keyAndVal[0] + ":" + result.Externals[keyAndVal[0]]); } } } } } if (propPieces.Length == 4) // multiple or WP - Need to do some work figuring out what all these characters mean - here??? -> http://www.hardhats.org/fileman/u2/fa_cond.htm { decimal trash = 0; if (Decimal.TryParse(propPieces[1], out trash)) { result.IsMultiple = true; result.Multiple = new VistaFile() { FileNumber = propPieces[1] }; //result.Multiple.FieldsDict = getFields(result.Multiple); } else { result.IsWordProc = true; } } // re-assemble transform if (propPieces.Length > 4) { StringBuilder sb = new StringBuilder(); for (int i = 4; i < propPieces.Length; i++) { sb.Append(propPieces[i]); sb.Append("^"); } sb = sb.Remove(sb.Length - 1, 1); result.Transform = sb.ToString(); } return(result); }