using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AndroidLIB { public class AndroidMSG:MSG { public int gwIMEI; public string radioIP; public String userID = ""; public string smsTXT = ""; public String seqIDsms = ""; public int smsSCID = -1; public int timeGMT = 0; public int his_sc_id = 0; public int his_startGMT = 0; public int his_stopGMT = 0; public int alarm_id = 0; public int alarm_type = 0; public int gw_id = 0; public int radio_gw_id = 0; public Int64 play_id = 0; public string unitName = ""; public string sourceIP; public AndroidMSG(byte[] data, int dataLen, string sourceIP) : base(data, dataLen) { SMd.Debug("AndroidMSG constructor"); this.sourceIP = sourceIP; Parse(); } private void Parse() { switch (base.opCode) { case (int)Android_MSG_type.Init_req: { string dat = base.data.Replace("#", ""); if ((dat.Split('&')).Length > 1) { radioIP = (dat.Split('&'))[0]; gwIMEI = Int32.Parse((dat.Split('&'))[1]); } break; } case (int)Android_MSG_type.Login_List_req: { break; } case (int)Android_MSG_type.Veh_req: { string dat = base.data.Replace("#", ""); userID = dat; break; } case (int)Android_MSG_type.Recording_req: { string[] temparr = base.data.Split('#'); int i; string dat = temparr[0]; //data not OK ... mark message as corupted!!! if (!Int32.TryParse(dat, out i)) { base.OK = false; break; } userID = dat; gw_id = Int32.Parse(temparr[1]); radio_gw_id = Int32.Parse(temparr[2]); break; } case (int)Android_MSG_type.SMS_req: { string[] temparr = base.data.Split('#'); int i; string dat = temparr[0]; //data not OK ... mark message as corupted!!! if (!Int32.TryParse(dat, out i)) { base.OK = false; break; } smsSCID = Int32.Parse(dat); timeGMT = Int32.Parse(temparr[1]); break; } case (int)Android_MSG_type.Alarmhistory_req: { string[] temparr = base.data.Split('#'); userID = temparr[0]; break; } case (int)Android_MSG_type.AlarmAck_req: { string[] temparr = base.data.Split('#'); int i; string dat = temparr[0]; //data not OK ... mark message as corupted!!! if (!Int32.TryParse(dat, out i)) { base.OK = false; break; } alarm_id = Int32.Parse(dat); alarm_type = Int32.Parse(temparr[1]); userID = temparr[2]; unitName = temparr[3]; break; } case (int)Android_MSG_type.SMS_last_req: { string[] temparr = base.data.Split('#'); userID = temparr[0]; break; } case (int)Android_MSG_type.LastPos_req: { string[] temparr = base.data.Split('#'); userID =temparr[0]; break; } case (int)Android_MSG_type.RecordPlay_req: { string dat = base.data.Replace("#", ""); play_id = Int64.Parse(dat); break; } case (int)Android_MSG_type.SMS_send: { string[] temparr = base.data.Split('#'); //data not OK ... mark message as corupted!!! if(temparr.Length < 3) { base.OK = false; break; } int i; //data not OK ... mark message as corupted!!! if (!Int32.TryParse(temparr[1], out i)) { base.OK = false; break; } seqIDsms = base.seqID; userID = temparr[0]; //SeqID = temparr[0]; smsSCID = Int32.Parse(temparr[1]); smsTXT = temparr[2]; break; } case (int)Android_MSG_type.GPShistory_req: { try { string[] temparr = base.data.Split('#'); his_sc_id = Int32.Parse(temparr[0]); his_startGMT = Int32.Parse(temparr[1]); his_stopGMT = Int32.Parse(temparr[2]); } catch (Exception ex) { base.OK = false; SMd.Debug(ex.ToString()); } break; } default: break; } } } }