public static string putField(Hashtable field, ISOFieldAttribute iXWork) { string r = ""; if (iXWork.classid == "IFA_NUMERIC") { r = setIFA_NUMERIC(field, iXWork); } if (iXWork.classid == "IFA_CHAR") { r = setIFA_CHAR(field, iXWork); } if (iXWork.classid == "IFA_LLCHAR") { r = setIFA_LLCHAR(field, iXWork); } if (iXWork.classid == "IFA_LLLCHAR") { r = setIFA_LLLCHAR(field, iXWork); } if (iXWork.classid == "IFA_LLNUM") { r = setIFA_LLNUM(field, iXWork); } if (iXWork.classid == "IFA_BITMAP") { r = setIFA_BITMAP(field, iXWork); } return(r); }
private static string setIFA_CHAR(Hashtable field, ISOFieldAttribute iXWork) { string r = (string)field[int.Parse(iXWork.id)];; if (r.Length > int.Parse(iXWork.length)) { throw(new ISOFieldPackingException("Invalid field length on field : " + iXWork.id)); } r = r.PadLeft(int.Parse(iXWork.length), '0'); return(r); }
private static string setIFA_AMOUNT(Hashtable field, ISOFieldAttribute iXWork) { string r = (string)field[int.Parse(iXWork.id)]; if (r.Length > int.Parse(iXWork.length)) { throw(new ISOFieldPackingException("Invalid field length on field : " + iXWork.id)); } r = r.PadLeft(int.Parse(iXWork.length) - 1, '0'); r = ((Int32.Parse(r) > 0) ? "C" : "D") + r; return(r); }
private static string setIFA_LLNUM(Hashtable field, ISOFieldAttribute iXWork) { string r = (string)field[int.Parse(iXWork.id)]; if (r.Length > int.Parse(iXWork.length)) { throw(new ISOFieldPackingException("Invalid field length on field : " + iXWork.id)); } string l = r.Length.ToString().PadLeft(2, '0'); r = l + r; return(r); }
public void unpack() { /* * TODO: Add code to start application here **/ try { loadPackager(); iIsoAscii = isoMsg.ASCIIMessage; /// Max Field isoMsg.MaxField = ISOMaxField; /// MTI First iXWork = (ISOFieldAttribute)iField["0"]; isoMsg.MTI = ISOBaseField.pickField(ref iIsoAscii, iXWork); isoMsg.FieldHash[0] = isoMsg.MTI; if (isdebug) { Console.WriteLine("<id_" + iXWork.id + ">" + "<" + iXWork.name + ">" + isoMsg.MTI + "</" + iXWork.name + ">" + "</id_" + iXWork.id + ">"); } /// BitMap iXWork = (ISOFieldAttribute)iField["1"]; string bit = ISOBaseField.pickField(ref iIsoAscii, iXWork); Hashtable bitmap = ISOBaseField.HashBitMap(bit); isoMsg.BitMapHash = bitmap; isoMsg.FieldHash[1] = bit; /// Next Field Automatic Hashmap for (int c = 2; c < ISOMaxField + 1; c++) { if (isoMsg.hasField(c)) { iXWork = (ISOFieldAttribute)iField[c.ToString()]; isoMsg.FieldHash[c] = ISOBaseField.pickField(ref iIsoAscii, iXWork); if (isdebug) { Console.WriteLine("<id_" + iXWork.id + ">" + "<" + iXWork.name + ">" + isoMsg.FieldHash[c] + "</" + iXWork.name + ">" + "</ID_" + iXWork.id + ">"); } } } } catch (Exception ee) { Console.WriteLine(("Invalid ISO Message") + " - " + ee.Message); } }
public void pack() { string r = ""; try { loadPackager(); /* * MTI First * */ iXWork = (ISOFieldAttribute)iField["0"]; r += ISOBaseField.putField(isoMsg.FieldHash, iXWork); if (isdebug) { Console.WriteLine("MTI:" + r); } /* * Bitmap Generator * */ iXWork = (ISOFieldAttribute)iField["1"]; r += ISOBaseField.putField(isoMsg.BitMapHash, iXWork); for (int i = 2; i < isoMsg.MaxField + 1; i++) { if (isoMsg.hasField(i)) { iXWork = (ISOFieldAttribute)iField[i.ToString()]; r += ISOBaseField.putField(isoMsg.FieldHash, iXWork); if (isdebug) { Console.WriteLine("<id_" + iXWork.id + ">" + "<" + iXWork.name + ">" + ISOBaseField.putField(isoMsg.FieldHash, iXWork) + "</" + iXWork.name + ">" + "</id_" + iXWork.id + ">"); } } } isoMsg.ASCIIMessage = r; } catch (Exception ee) { Console.WriteLine("Packing error occured: " + ee.Message); } }
public void pack() { string r = ""; try { loadPackager(); /* * MTI First * */ iXWork = (ISOFieldAttribute)iField["0"]; r += ISOBaseField.putField(isoMsg.FieldHash, iXWork); if (isdebug) Console.WriteLine("MTI:" + r); /* * Bitmap Generator * */ iXWork = (ISOFieldAttribute)iField["1"]; r += ISOBaseField.putField(isoMsg.BitMapHash, iXWork); for (int i=2; i<isoMsg.MaxField+1; i++) { if (isoMsg.hasField(i)) { iXWork = (ISOFieldAttribute)iField[i.ToString()]; r += ISOBaseField.putField(isoMsg.FieldHash, iXWork); if (isdebug) Console.WriteLine("<id_" + iXWork.id + ">" + "<" + iXWork.name + ">" + ISOBaseField.putField(isoMsg.FieldHash, iXWork) + "</" + iXWork.name + ">" + "</id_" + iXWork.id + ">"); } } isoMsg.ASCIIMessage = r; } catch (Exception ee) { Console.WriteLine("Packing error occured: " + ee.Message); } }
private static string setIFA_BITMAP(Hashtable field, ISOFieldAttribute iXWork) { string r = ""; string rs = ""; IDictionaryEnumerator en = field.GetEnumerator(); bool ign = en.MoveNext(); ign = en.MoveNext(); //start from bit 2 int i = 2; bool Bitmap2nd = false; while (en.MoveNext()) { if ((bool)field[i]) { r += "1"; if (i > 64) { Bitmap2nd = true; } } else { r += "0"; } i++; } if (Bitmap2nd) { r = "1" + r; } else { r = "0" + r; r = r.Substring(0, 64); } for (int e = 0; e < r.Length / 16; e++) { rs += ISOGenericFunction.ConvertBinary2Hex(r.Substring(e * 16, 16)); } return(rs); }
public static string pickField(ref string msg, ISOFieldAttribute iXWork) { string r = ""; if (iXWork.classid == "IFA_BITMAP") { r = getIFA_BITMAP(ref msg); } if (iXWork.classid == "IFA_LLNUM") { r = getIFA_LLNUM(ref msg); } if (iXWork.classid == "IFA_NUMERIC") { r = getIFA_NUMERIC(msg, int.Parse(iXWork.length)); msg = msg.Substring(int.Parse(iXWork.length), msg.Length - int.Parse(iXWork.length)); } if (iXWork.classid == "IFA_CHAR") { r = getIFA_CHAR(msg, int.Parse(iXWork.length)); msg = msg.Substring(int.Parse(iXWork.length), msg.Length - int.Parse(iXWork.length)); } if (iXWork.classid == "IFA_LLCHAR") { r = getIFA_LLCHAR(ref msg); } if (iXWork.classid == "IFA_LLLCHAR") { r = getIFA_LLLCHAR(ref msg); } if (iXWork.classid == "IFA_AMOUNT") { r = getIFA_AMOUNT(msg, int.Parse(iXWork.length)); msg = msg.Substring(int.Parse(iXWork.length), msg.Length - int.Parse(iXWork.length)); } return(r); }
public static string pickField(ref string msg, ISOFieldAttribute iXWork) { string r = ""; if (iXWork.classid=="IFA_BITMAP") { r = getIFA_BITMAP(ref msg); } if (iXWork.classid=="IFA_LLNUM") { r = getIFA_LLNUM(ref msg); } if (iXWork.classid=="IFA_NUMERIC") { r = getIFA_NUMERIC(msg, int.Parse(iXWork.length)); msg = msg.Substring(int.Parse(iXWork.length), msg.Length-int.Parse(iXWork.length)); } if (iXWork.classid=="IFA_CHAR") { r = getIFA_CHAR(msg, int.Parse(iXWork.length)); msg = msg.Substring(int.Parse(iXWork.length), msg.Length-int.Parse(iXWork.length)); } if (iXWork.classid=="IFA_LLCHAR") { r = getIFA_LLCHAR(ref msg); } if (iXWork.classid=="IFA_LLLCHAR") { r = getIFA_LLLCHAR(ref msg); } if (iXWork.classid=="IFA_AMOUNT") { r = getIFA_AMOUNT(msg, int.Parse(iXWork.length)); msg = msg.Substring(int.Parse(iXWork.length), msg.Length-int.Parse(iXWork.length)); } return r; }
private static string setIFA_AMOUNT(Hashtable field, ISOFieldAttribute iXWork) { string r = (string)field[int.Parse(iXWork.id)]; if (r.Length > int.Parse(iXWork.length)) throw(new ISOFieldPackingException("Invalid field length on field : " + iXWork.id)); r = r.PadLeft(int.Parse(iXWork.length)-1, '0'); r = ((Int32.Parse(r) > 0) ? "C" : "D") + r ; return r; }
private void loadPackager() { try { isdebug = isoMsg.debug; XmlTextReader reader = new XmlTextReader(isoXmlFile); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: Hashtable attributes = new Hashtable(); string strURI= reader.NamespaceURI; string strName= reader.Name; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); attributes.Add(reader.Name,reader.Value); } } /* * Safe to hashtable * */ if (!(strName.Equals("isopackager"))) { IDictionaryEnumerator en = attributes.GetEnumerator(); ISOFieldAttribute iX = new ISOFieldAttribute(); while (en.MoveNext()) { if (en.Key.ToString()=="id") iX.id = en.Value.ToString(); if (en.Key.ToString()=="length") iX.length = en.Value.ToString(); if (en.Key.ToString()=="name") iX.name = en.Value.ToString(); if (en.Key.ToString()=="class") iX.classid = en.Value.ToString(); if (en.Key.ToString()=="token") iX.token = en.Value.ToString(); if (en.Key.ToString()=="pad") iX.pad = en.Value.ToString(); } iField.Add(iX.id, iX); } else { IDictionaryEnumerator en = attributes.GetEnumerator(); while (en.MoveNext()) { if (en.Key.ToString() == "maxValidField") { ISOMaxField = int.Parse(en.Value.ToString()); iField = new Hashtable(ISOMaxField+1); } } } break; /* * you can handle other cases here : * - case XmlNodeType.EndElement * - case XmlNodeType.Text * */ default: break; } } } catch (XmlException e) { Console.WriteLine("error occured: " + e.Message); } }
public void unpack() { /* * TODO: Add code to start application here **/ try { loadPackager(); iIsoAscii = isoMsg.ASCIIMessage; /// Max Field isoMsg.MaxField = ISOMaxField; /// MTI First iXWork = (ISOFieldAttribute)iField["0"]; isoMsg.MTI = ISOBaseField.pickField(ref iIsoAscii, iXWork); isoMsg.FieldHash[0] = isoMsg.MTI; if (isdebug) Console.WriteLine("<id_" + iXWork.id + ">" + "<" + iXWork.name + ">" + isoMsg.MTI + "</" + iXWork.name + ">" + "</id_" + iXWork.id + ">"); /// BitMap iXWork = (ISOFieldAttribute)iField["1"]; string bit = ISOBaseField.pickField(ref iIsoAscii, iXWork); Hashtable bitmap = ISOBaseField.HashBitMap(bit); isoMsg.BitMapHash = bitmap; isoMsg.FieldHash[1] = bit; /// Next Field Automatic Hashmap for (int c = 2; c<ISOMaxField+1; c++) { if (isoMsg.hasField(c)) { iXWork = (ISOFieldAttribute)iField[c.ToString()]; isoMsg.FieldHash[c] = ISOBaseField.pickField(ref iIsoAscii, iXWork); if (isdebug) Console.WriteLine("<id_" + iXWork.id + ">" + "<" + iXWork.name + ">" + isoMsg.FieldHash[c] + "</" + iXWork.name + ">" + "</ID_" + iXWork.id + ">"); } } } catch (Exception ee) { Console.WriteLine(("Invalid ISO Message") + " - " + ee.Message); } }
public static string putField(Hashtable field, ISOFieldAttribute iXWork) { string r = ""; if (iXWork.classid=="IFA_NUMERIC") { r = setIFA_NUMERIC(field, iXWork); } if (iXWork.classid=="IFA_CHAR") { r = setIFA_CHAR(field, iXWork); } if (iXWork.classid=="IFA_LLCHAR") { r = setIFA_LLCHAR(field, iXWork); } if (iXWork.classid=="IFA_LLLCHAR") { r = setIFA_LLLCHAR(field, iXWork); } if (iXWork.classid=="IFA_LLNUM") { r = setIFA_LLNUM(field, iXWork); } if (iXWork.classid=="IFA_BITMAP") { r = setIFA_BITMAP(field, iXWork); } return r; }
private static string setIFA_NUMERIC(Hashtable field, ISOFieldAttribute iXWork) { string r = ""; r = (string)field[int.Parse(iXWork.id)]; if (r.Length > int.Parse(iXWork.length)) throw(new ISOFieldPackingException("Invalid field length on field : " + iXWork.id)); r = r.PadLeft(int.Parse(iXWork.length), '0'); return r; }
private static string setIFA_LLNUM(Hashtable field, ISOFieldAttribute iXWork) { string r = (string)field[int.Parse(iXWork.id)]; if (r.Length > int.Parse(iXWork.length)) throw(new ISOFieldPackingException("Invalid field length on field : " + iXWork.id)); string l = r.Length.ToString().PadLeft(2, '0'); r = l + r; return r; }
private static string setIFA_BITMAP(Hashtable field, ISOFieldAttribute iXWork) { string r = ""; string rs = ""; IDictionaryEnumerator en = field.GetEnumerator(); bool ign = en.MoveNext(); ign = en.MoveNext(); //start from bit 2 int i = 2; bool Bitmap2nd = false; while (en.MoveNext()) { if ((bool)field[i]) { r += "1"; if (i>64) Bitmap2nd = true; } else { r += "0"; } i++; } if (Bitmap2nd) { r = "1" + r; } else { r = "0" + r; r = r.Substring(0,64); } for (int e=0; e< r.Length/16; e++) { rs += ISOGenericFunction.ConvertBinary2Hex(r.Substring(e*16,16)); } return rs; }
private void loadPackager() { try { isdebug = isoMsg.debug; XmlTextReader reader = new XmlTextReader(isoXmlFile); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: Hashtable attributes = new Hashtable(); string strURI = reader.NamespaceURI; string strName = reader.Name; if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); attributes.Add(reader.Name, reader.Value); } } /* * Safe to hashtable * */ if (!(strName.Equals("isopackager"))) { IDictionaryEnumerator en = attributes.GetEnumerator(); ISOFieldAttribute iX = new ISOFieldAttribute(); while (en.MoveNext()) { if (en.Key.ToString() == "id") { iX.id = en.Value.ToString(); } if (en.Key.ToString() == "length") { iX.length = en.Value.ToString(); } if (en.Key.ToString() == "name") { iX.name = en.Value.ToString(); } if (en.Key.ToString() == "class") { iX.classid = en.Value.ToString(); } if (en.Key.ToString() == "token") { iX.token = en.Value.ToString(); } if (en.Key.ToString() == "pad") { iX.pad = en.Value.ToString(); } } iField.Add(iX.id, iX); } else { IDictionaryEnumerator en = attributes.GetEnumerator(); while (en.MoveNext()) { if (en.Key.ToString() == "maxValidField") { ISOMaxField = int.Parse(en.Value.ToString()); iField = new Hashtable(ISOMaxField + 1); } } } break; /* * you can handle other cases here : * - case XmlNodeType.EndElement * - case XmlNodeType.Text * */ default: break; } } } catch (XmlException e) { Console.WriteLine("error occured: " + e.Message); } }