using System; using System.Xml; using System.Collections.Generic; using System.Collections; using System.Text; using System.Data; using System.IO; using System.Windows.Forms; using Npgsql; namespace SafeMobileLib { public class ZoneClass { public ZoneClass(String _name, Int32 _id, ArrayList _arr) { id = _id; name = _name; arrSc_id = _arr; new_arrSc_id = _arr; } public ZoneClass(ZoneClass _oldzone, Int32 _id, ArrayList _arr) { id = _id; arrSc_id = _arr; new_arrSc_id = new ArrayList(); foreach (PointonZone obj in arrSc_id) { PointonZone tmp = new PointonZone(obj.lat, obj.lng, obj.idx); new_arrSc_id.Add(tmp); } position = 0; name = _oldzone.name; color = _oldzone.color; useridx = _oldzone.useridx; AlarmType = _oldzone.AlarmType; sentmsg = _oldzone.sentmsg; msgbody = _oldzone.msgbody; unitids = _oldzone.unitids; sentemail = _oldzone.sentemail; email = _oldzone.email; subj = _oldzone.subj; body = _oldzone.body; imeilist = _oldzone.imeilist; sentmsg2 = _oldzone.sentmsg2; msgbody2 = _oldzone.msgbody2; speed = _oldzone.speed; callout = _oldzone.callout; calloutSeverity = _oldzone.calloutSeverity; } public Int32 zone_id { get { return id; } } public Int32 action { get { return position; } } public ArrayList arrSc_id; public ArrayList new_arrSc_id; public string name; public Int32 id; private Int32 position = 0; //0=nu stiu 2=IN 1=OUT public ZoneClass(String _name, Int32 _color, Int32 _useridx, Int32 _AlarmType, Boolean _sentmsg, String _msgbody, String _unitids, Boolean _sentemail, String _email, String _subj, String _body, String _imeilist, Boolean _sentmsg2, String _msgbody2,Int32 _speed, Boolean _callout, int _calloutSeverity) { position = 0; name = _name; color = _color; useridx = _useridx; AlarmType = _AlarmType; sentmsg = _sentmsg; msgbody = _msgbody; unitids = _unitids; sentemail = _sentemail; email = _email; subj = _subj; body = _body; imeilist = _imeilist; sentmsg2 = _sentmsg2; msgbody2 = _msgbody2; speed = _speed; callout = _callout; calloutSeverity = _calloutSeverity; } public ZoneClass(String _name, Int32 _color, Int32 _useridx, Int32 _AlarmType, Boolean _sentmsg, String _msgbody, String _unitids, Boolean _sentemail, String _email, String _subj, String _body, Boolean _sentmsg2, String _msgbody2, Int32 _speed, Boolean _callout, int _calloutSeverity) { position = 0; name = _name; color = _color; useridx = _useridx; AlarmType = _AlarmType; sentmsg = _sentmsg; msgbody = _msgbody; unitids = _unitids; sentemail = _sentemail; email = _email; subj = _subj; body = _body; sentmsg2 = _sentmsg2; msgbody2 = _msgbody2; speed = _speed; callout = _callout; calloutSeverity = _calloutSeverity; } public Int32 color; public Int32 speed; public Int32 useridx = 0; public String speedUnit = "k"; public Int32 AlarmType = 3; public Boolean sentmsg = true; public String msgbody = ""; public Boolean sentmsg2 = true; public String msgbody2 = ""; public String imeilist = ""; public String unitids = ""; public Boolean sentemail = true; public String email = ""; public String subj = ""; public String body = ""; public String Name { get { return name; } } public String CheckZone(Double _lat, Double _lng, out Int32 _position) { String response = ""; Boolean tmp = false; PointonZone oldPoint=null; if (arrSc_id.Count > 0) oldPoint = (PointonZone)arrSc_id[arrSc_id.Count - 1]; else { _position = 0; return response; } foreach (PointonZone obj in arrSc_id) { if (((obj.lat > _lat) != (oldPoint.lat > _lat)) && (_lng < (oldPoint.lng - obj.lng) * (_lat - obj.lat) / (oldPoint.lat - obj.lat) + obj.lng)) tmp = !tmp; oldPoint = obj; } if ((position != 2) && (tmp)) { position = 2; response = "IN " + name; } else if ((position != 1) && (!tmp)) { position = 1; response = "OUT " + name; } _position = position; return response; } public Boolean callout = true; public int calloutSeverity = 3; } public class PointonZone { public PointonZone(Double latParam, Double lngParam, Int32 idxParam) { lat = latParam; lng = lngParam; idx = idxParam; } public Double lat, lng; public Int32 idx; } public class LandMark { public String name; public double lat; public double lng; private Int32 idx; private Int32 position; //0=nu stiu 2=IN 1=OUT public Int32 useridx = 0; public String speedUnit = "k"; public Boolean callout = true; public int calloutSeverity = 3; public LandMark(String paramName, Double lat1, Double lng1, Int32 paramidx, Int32 _useridx, Boolean _callout, int _calloutSeverity) { name = paramName; idx = paramidx; lat = lat1; lng = lng1; position = 0; useridx = _useridx; callout = _callout; calloutSeverity = _calloutSeverity; } public String CheckPosition(Double _lat, Double _lng) { double pi = 3.1415926535897932384626433832795; double rad = 180 / pi; double dist = (3958 * pi * Math.Sqrt((lat - _lat) * (lat - _lat) + Math.Cos(lat / rad) * Math.Cos(_lat / rad) * (lng - _lng) * (lng - _lng)) / 180); double Distance = Math.Round(((dist * 1.609344) * 1000)) / 1000; String tmp = ""; if (Distance < 0.05) { if (position != 2) { tmp = "IN " + name; } position = 2; } else { if (position != 1) { tmp = "OUT " + name; } position = 1; } return tmp; } public Int32 land_id { get { return idx; } } public Int32 action { get { return position; } } } public class imei_and_message { public String mess; public String imei; public Double lat; public Double lng; public UInt32 TimeGMT; public Int32 Speed; public Int32 DI; public imei_and_message(String _mess, String _imei, Double _lat, Double _lng, UInt32 _TimeGMT, Int32 _Speed) { mess = _mess; imei = _imei; lat = _lat; lng = _lng; TimeGMT = _TimeGMT; Speed = _Speed; DI = 0; } public imei_and_message(String _mess, String _imei, Double _lat, Double _lng, UInt32 _TimeGMT, Int32 _Speed, Int32 _DI) { mess = _mess; imei = _imei; lat = _lat; lng = _lng; TimeGMT = _TimeGMT; Speed = _Speed; DI = _DI; } } public class Messages4vAL { public int msgType; public String IMEI; public String cmd; public Int32 IdxDB; public String TelNumber; public Int32 Status; public Messages4vAL(Int32 _IsPoll, string _IMEI, string _cmd, Int32 _IdxDB, String _TelNumber, int _status) { msgType = _IsPoll; IMEI = _IMEI; cmd = _cmd; IdxDB = _IdxDB; TelNumber = _TelNumber; Status = _status; } } public class RFIDs { public Int32 id; public Int32 sc_id; public string Vehicle_Name; public string Passenger_Name; public string RFID; //pa.id,pa.rfid,pa.name,veh.name,pa.sc_id public RFIDs(string _rfid, string _name, string _vehname, Int32 _sc_id,Int32 _id) { id = _id; sc_id = _sc_id; Vehicle_Name = _vehname; Passenger_Name = _name; RFID = _rfid; } } public class Vehicle_sc_id { public int sc_id; private string name; public Vehicle_sc_id(int _id, string _name) { sc_id = _id; name = _name; } public string Name { get { return name; } } } public class Vehicle_Data { public String Name; public int sc_id; public int sip_id; public int type; public string imei; public double lat; public double lng; public ArrayList zonelist; public ArrayList landlist; public Alarm alm; public bool active; public Vehicle_Data(int _sc_id, int _sip_id, string _imei, double _lat, double _lng, string _name, Alarm _alm) { sc_id = _sc_id; sip_id = _sip_id; imei = _imei; Name = _name; lat = _lat; lng = _lng; zonelist = new ArrayList(); landlist = new ArrayList(); alm = _alm; active = false; } } }