using System; using System.Collections.Generic; using System.Linq; using System.Text; using Telerik.WinControls.UI; using MapGoogle; using System.Collections; using System.Drawing; using SafeMobileLib; using Telerik.WinControls.UI.Docking; using System.Net.NetworkInformation; using System.Net; using System.IO; using System.Web.Script.Serialization; using System.ComponentModel; using Telerik.WinControls; using Telerik.WinControls.Layouts; using System.Windows.Forms; using Telerik.WinControls.Enumerations; using System.Xml; using System.Text.RegularExpressions; namespace Safedispatch_4_0 { public enum API { RADIO_ENABLE_DISABLE_REQ = 150, POLL_GPS_REQ = 154, POLL_ARS_REQ = 149, RECORDING_RECEIVED = 155, STOLEN_REQ = 208, EMERGENCY_REC = 138 }; public class transfer125 { public Int32 callStatus = 0; public Int32 callType = 0; public Int32 grpID = 0; public Int64 intvalID = 0; public String gwID = "0"; public String radioGwID = "0"; public transfer125(Int32 _callStatus, Int32 _callType, Int32 _grpID,Int64 _intvalID) { callStatus = _callStatus; callType = _callType; grpID = _grpID; intvalID = _intvalID; } } public class TabInstance { public String tabName=""; public Boolean isCreated = false; public TabInstance(String _tabName,Boolean _isCreated) { tabName = _tabName; isCreated = _isCreated; } } public class GridData { public String col0 { get; set; } public String col1 { get; set; } public String col2 { get; set; } public String col3 { get; set; } public Int32 status { get; set; } public String email { get; set; } public Int32 idx { get; set; } } public class XYcoord { public Double lat; public Double lng; public Double dlat; public Double dlng; } //public enum car_state_e //{ // CAR_RUNNING = 0, // CAR_START, // CAR_STOP, // CAR_HW //}; //public enum rep_type //{ // RFID = 0, // GEOFENC, // SPEED, // EMERG, // LAND, // LOG, // ENDOFDAY, // STOP, // IDLE, // FLEET, // SMSRECIVE, // SMSSEND, // CALLRECIVE, // CALLSEND, // TELEMETRY_ALARM, // TELEMETRY_EVENT, // HIST, // ALLALARM, // SMS_LOCATION, // JOB_TICKETING //}; public enum track_type { LIVE = 0, HIST, LANDZONE, SMS, TICKETING, VOICE, TELEM, REPORTS, SYSTEM, HELP, RADIO }; //public enum StartItems //{ // HISTTAB = 0, // LIVETAB, // SPEED, // GEOFENC, // LAND, // EMERG, // VIEWLOG, // SMSINBOX, // SMSOUTBOX //}; public class SMSfromDB { public int sc_id_sour; public int sc_id_Dest; public int sc_id; public Int32 date; public string mes; public int status; public int idx; public string email; public Color color; public SMSfromDB(int _sc_id, Int32 _date, string _mes, int _status, int _idx, string _email) { sc_id_sour = 0; sc_id_Dest = 0; sc_id = _sc_id; date = _date; mes = _mes; status = _status; idx = _idx; email = _email; } public SMSfromDB(int _sc_id_sour, int _sc_id_Dest, Int32 _date, string _mes, int _status, int _idx, string _email) { sc_id_sour = _sc_id_sour; sc_id_Dest = _sc_id_Dest; sc_id = 0; date = _date; mes = _mes; status = _status; idx = _idx; email = _email; } } public class LocAndColor { //public Locationx[] location; public ArrayList latlng = new ArrayList(); public Color color; public Int32 startTime; public Int32 endTime; } #region TABS /// /// Class equal with an enum containing a string as a returned value /// public sealed class Tabs { private readonly String name; private readonly int value; public static readonly Tabs LIVE = new Tabs(1, "LIVE"); public static readonly Tabs GEOFENCE = new Tabs(2, "GEOFENCE"); public static readonly Tabs HISTORY = new Tabs(3, "HISTORY"); public static readonly Tabs TEXT = new Tabs(4, "TEXT"); public static readonly Tabs TICKETING = new Tabs(5, "TICKETING"); public static readonly Tabs REPORTS = new Tabs(6, "REPORTS"); public static readonly Tabs VOICE = new Tabs(7, "VOICE"); public static readonly Tabs TELEMETRY = new Tabs(8, "TELEMETRY"); public static readonly Tabs SYSTEM = new Tabs(9, "SYSTEM"); public static readonly Tabs ALERTS = new Tabs(10, "ALERTS"); public static readonly Tabs RADIO = new Tabs(11, "RADIO"); private Tabs(int value, String name) { this.name = name; this.value = value; } public override String ToString() { return name; } /// /// Detect if a string tag can be converted to a TAB enume /// /// Name of the enum which needs to be converted /// True is the string is a TAB enum public bool Contains(String tag) { try { if (LIVE.ToString().Equals(tag) || HISTORY.ToString().Equals(tag) || GEOFENCE.ToString().Equals(tag) || REPORTS.ToString().Equals(tag) || TELEMETRY.ToString().Equals(tag) || TEXT.ToString().Equals(tag) || TICKETING.ToString().Equals(tag) || VOICE.ToString().Equals(tag) || RADIO.ToString().Equals(tag) || SYSTEM.ToString().Equals(tag) || ALERTS.ToString().Equals(tag) ) return true; } catch (Exception ex) { Utils.WriteLine(ex.ToString(), ConsoleColor.Red); } return false; } } #endregion #region GEOFENCE public class GeofenceUI { public Int32 Idx { get; set; } public String Name { get; set; } public Color FillColor { get; set; } public Double FillOpacity { get; set; } public Color BorderColor { get; set; } public Double BorderOpacity { get; set; } public Double BorderWidth { get; set; } public Int32 UserIdx { get; set; } public AlertType AlertTypee { get; set; } public List points { get; set; } public Boolean SendUnitMessage { get; set; } public String UnitMessage { get; set; } public Boolean SendUnitsMessage { get; set; } public String UnitsMessage { get; set; } public List UnitsIds { get; set; } public List UnitsImeis { get; set; } public Boolean SendEmail { get; set; } public String EmailAddress { get; set; } public String EmailSubject { get; set; } public String EmailBody { get; set; } public Int32 SpeedLimit { get; set; } public Boolean Callout { get; set; } public int CalloutSeverity { get; set; } public enum AlertType { IN = 1, OUT = 2, IN_OUT = 3, NONE = 4 }; } public class GeofencePoint { public Int32 Idx { get; set; } public Double Latitude { get; set; } public Double Longitude { get; set; } public Int32 GeofeceId { get; set; } } #endregion #region LANNDMARK public class LandmarkUI { public Int32 Idx { get; set; } public String Name { get; set; } public String Description { get; set; } public String Address { get; set; } public Double Latitude { get; set; } public Double Longitude { get; set; } public Int32 TypeIdx { get; set; } public Int32 UserIdx { get; set; } public Color Color { get; set; } public String IconName { get; set; } public IconSize Size { get; set; } public Boolean Callout { get; set; } public int CalloutSeverity { get; set; } /// /// Class equal with an enum containing a string as a returned value /// public sealed class IconSize { private readonly String name; private readonly int value; public static readonly IconSize SMALL = new IconSize(1, "s"); public static readonly IconSize MEDIUM = new IconSize(2, "m"); public static readonly IconSize LARGE = new IconSize(3, "l"); private IconSize(int value, String name) { this.name = name; this.value = value; } public override String ToString() { return name; } public String ToDBString() { return value == 1 ? "small" : (value == 2 ? "medium" : "large"); } public static IconSize GetIconSize(string size) { if(size.ToLower().Equals("small")) return IconSize.SMALL; else if(size.ToLower().Equals("large")) return IconSize.LARGE; else return IconSize.MEDIUM; } } } public class LandmarkType { public Int32 CrtIdx { get; set; } public Int32 Idx { get; set; } public String IconName { get; set; } public String TypeName { get; set; } } #endregion public class Zone_type { public string name; public Int32 idx; public Int32 driver_id; public Zone_type(String paramName, Int32 paramidx, Int32 paramdriver) { name = paramName; idx = paramidx; driver_id = paramdriver; } public String Name { get { return name; } } } public class Zones { private String name; public double latMAX; public double lngMAX; public double latMIN; public double lngMIN; private Int32 idx; private Int32 position = 0; //0=nu stiu 2=IN 1=OUT public Zones(String paramName, Double lat1, Double lng1, Double lat2, Double lng2, Int32 paramidx) { name = paramName; idx = paramidx; if (lat1 > lat2) { latMAX = lat1; latMIN = lat2; } else { latMAX = lat2; latMIN = lat1; } if (lng1 > lng2) { lngMAX = lng1; lngMIN = lng2; } else { lngMAX = lng2; lngMIN = lng1; } position = 0; } public Boolean CheckZone(Double _lat, Double _lng) { Boolean tmp = false; if (((_lat >= latMIN) && (_lat <= latMAX)) && ((_lng >= lngMIN) && (_lng <= lngMAX))) { if (position == 1) { tmp = true; } position = 2; } else { if (position == 2) { tmp = true; } position = 1; } return tmp; } public Int32 zone_id { get { return idx; } } public Int32 action { get { return position; } } } public class ReportDefinition { public Int32 Idx { get; set; } public Int32 StartDate { get; set; } public Int32 EndDate { get; set; } public String UnitIds { get; set; } public Int32 GeofenceId { get; set; } public Int32 TypeStat { get; set; } public Int32 ReportId { get; set; } public String Email { get; set; } public Int32 IdleTime { get; set; } public Boolean LatLng { get; set; } public Int32 UserId { get; set; } public String TicketStatus { get; set; } public String TicketDate { get; set; } public String ReportType { get; set; } public String Day { get; set; } public Boolean IsActive { get; set; } } /// /// used in report form in order to store the imeis and the scIDs of the units and groups /// public class DropListItem : RadListDataItem { public Image Image { get; set; } public String ValueImei { get; set; } public String ValueScID { get; set; } public Boolean IsGroup { get; set; } public DropListItem() { this.Image = null; this.ValueImei = ""; this.ValueScID = ""; this.IsGroup = false; } public DropListItem(String name, Image image, String valueImei, String valueScID, Boolean isGroup) { this.Text = name; this.Image = image; this.ValueImei = valueImei; this.ValueScID = valueScID; this.IsGroup = isGroup; } } public class VehandID { private string name; private Int32 idx; private string imei; public Int32 color = 0; public Int32 IconID = 0; public Int32 veh_id = 0; public Int32 report_int = 0; public Boolean check = false; public Boolean is_stolen = false; public Int32 groupID; public String groupName; public String GwandRadioID = "0.0"; public bool hasEmergencyAlert = false; public bool hasZoneAlert = false; public bool hasLoneWorkerAlert = false; public bool hasSpeedAlert = false; public bool hasEmailAlert = false; public bool hasLandmarkAlert = false; public bool hasTelemetryAlert = false; public bool canMakeSipCalls = false; public int sipID = -1; public string Imei { get { return imei; } set { imei = value; } } public VehandID(String paramName, Int32 paramidx, string pimei) { name = paramName; idx = paramidx; imei = pimei; } public VehandID(String paramName, Int32 paramidx, string pimei, Int32 color_param, Int32 IconID_param, Int32 veh_id_param,Int32 report_int_param, Boolean checkpar) { name = paramName; idx = paramidx; //sc_id imei = pimei; color = color_param; IconID = IconID_param; veh_id = veh_id_param; check = checkpar; report_int = report_int_param; is_stolen = false; } public VehandID(String paramName, Int32 paramidx, string pimei, Int32 color_param, Int32 IconID_param, Int32 veh_id_param, Int32 report_int_param, Boolean checkpar, Boolean is_stolenParam) { name = paramName; idx = paramidx; //sc_id imei = pimei; color = color_param; IconID = IconID_param; veh_id = veh_id_param; check = checkpar; report_int = report_int_param; is_stolen = is_stolenParam; } public String Name { get { return name; } } public Int32 sc_id { get { return idx; } } } public class TeleNames { private string name; private Int32 id; public TeleNames(String _name, Int32 _id) { name = _name; id = _id; } public Int32 Id { get { return id; } set { id = value; } } public string Name { get { return name; } set { name = value; } } } enum StopTypes : int { NA, NORMAL, DEPOT, RRXING, NEW, SCHOOL } enum PeopleTypes : int { STUDENT, DRIVER } public enum ActionSMS : int { INSERT, CONFIRM, VIEW } public class SMposition { public double m_lat { get; set; } public double m_lng { get; set; } public double m_alt { get; set; } public Int32 m_time { get; set; } public string m_vehName { get; set; } public string m_imei { get; set; } public byte m_di { get; set; } public byte m_motostat { get; set; } public byte m_do { get; set; } public byte m_speed { get; set; } public Int32 m_heading { get; set; } public Int32 m_evnt_id { get; set; } public string m_address { get; set; } public Int32 m_posID { get; set; } public double m_scevMSSQL { get; set; } public SMposition() { m_imei = ""; m_vehName = ""; m_time = 0; m_lat = m_lng = m_alt = 0.0; m_scevMSSQL = 0; m_di = m_do = m_speed = 0; m_address = ""; m_posID = 0; m_motostat = 0; } public SMposition(double LAT, double LNG, double ALT) { m_lat = LAT; m_lng = LNG; m_alt = ALT; } public override string ToString() { return String.Format("IMEI: {0}, time: {1}, Lat: {2}, Lng:{3}, DI: {4}, DO: {5}, Speed: {6}", m_imei, m_time, m_lat, m_lng, m_di, m_do, m_speed); } } public class SMSrecv { public Int32 timeGMT { get; set; } public Int32 sc_id { get; set; } public String mess { get; set; } public Int32 idx { get; set; } public String vehname { get; set; } public Boolean onscreen { get; set; } } public class Stops { public String name; public Int32 start, stop; public Double lat, lng; public car_state_e type; public Stops() { name = ""; } } public class Place { public string name; public string desc { get; set; } public double lat { get; set; } public double lng { get; set; } public string type { get; set; } public string pic { get; set; } public string address { get; set; } public Int32 idx { get; set; } public Int32 useridx { get; set; } public ESRI.ArcGIS.Display.IPictureMarkerSymbol GISsymb = null; public Hashtable SymbGIS = new Hashtable(); public String iconName { get; set; } public String iconSize { get; set; } public String color { get; set; } public Boolean callout { get; set; } public int callout_severity { get; set; } public String Name { get { return name; } } public String Type { get { return type; } } } public class Car { public string name; public string fileName; public string listFilePath; public string googleAddresPath; public string iconPattern; public string displayedName; public string desc; public Int32 idx; public Symbolx symb; public ESRI.ArcGIS.Display.IPictureMarkerSymbol GISsymb =null; public Hashtable SymbMap = new Hashtable(); public Hashtable SymbGIS = new Hashtable(); } public class TwoIntOneStr { public String cmd; public Int32 timeout; public Int32 id; } public class PassengerClass { public String RFID { get; set; } public String Name { get; set; } public String VehName { get; set; } public Int32 sc_id { get; set; } public String VehNameAssign { get; set; } public Int32 sc_idAssign { get; set; } public Int32 TimePick { get; set; } public Int32 TimeDrop { get; set; } public String NameCOM { get { return Name; } } } public class GroupClass { public GroupClass(String _name, Int32 _id, Int32 _cps_id, ArrayList _arr, ArrayList _arrImei) { id = _id; name = _name; arrSc_id = _arr; cps_id = _cps_id; arrImei = _arrImei; } public GroupClass(String _name, Int32 _id, Int32 _cps_id) { name = _name; id = _id; cps_id = _cps_id; } public GroupClass() { } public ArrayList arrSc_id; public string name; public Int32 id; public Int32 cps_id; public ArrayList arrImei; } //public class ZoneClass //{ // public ZoneClass(String _name, Int32 _id, Int32 _color, Int32 _useridx, ArrayList _arr) // { // id = _id; // name = _name; // 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; // color = _color; // useridx = _useridx; // } // 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; // sentmsg2 = _oldzone.sentmsg2; // msgbody2 = _oldzone.msgbody2; // speed = _oldzone.speed; // } // 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) // { // 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; // } // public ArrayList arrSc_id; // public ArrayList new_arrSc_id; // public string name; // public Int32 id; // public Int32 color; // private Int32 position = 0; //0=nu stiu 2=IN 1=OUT // public Int32 useridx = 0; // public Int32 AlarmType = 3; // public Boolean sentmsg = true; // public String msgbody = ""; // public String unitids = ""; // public Boolean sentemail = true; // public String email = ""; // public String subj = ""; // public String body = ""; // public Boolean sentmsg2 = true; // public String msgbody2 = ""; // public Int32 speed = 0; // public String Name // { // get // { // return name; // } // } // public String CheckZone(Double _lat, Double _lng) // { // String response = ""; // Boolean tmp = false; // PointonZone oldPoint = (PointonZone)arrSc_id[arrSc_id.Count - 1]; // 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; } // return response; // } //} public class Square { public Square(Double latParam, Double lngParam, Double lat2Param, Double lng2Param, Int32 IdParam) { lat = latParam; lng = lngParam; lat2 = lat2Param; lng2 = lng2Param; Id = IdParam; } public Double lat, lng, lat2, lng2; public Int32 Id; } public class Lines { public Lines(Double latParam, Double lngParam, Double lat2Param, Double lng2Param, String nameParam) { lat = latParam; lng = lngParam; lat2 = lat2Param; lng2 = lng2Param; name = nameParam; } public Double lat, lng, lat2, lng2; public String name; } public class Points { public Points(Double latParam, Double lngParam, String Name1Param, String Name2Param, String Name3Param, String Name4Param, String Name5Param) { lat = latParam; lng = lngParam; name1 = Name1Param; name2 = Name2Param; name3 = Name3Param; name4 = Name4Param; name5 = Name5Param; } public Double lat, lng; public String name1, name2, name3, name4, name5; } //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 TimerAndResp { public System.Threading.Timer timer = null; public Boolean wait = true; public Boolean Respose = false; public Boolean StatusON = false; public Int64 intval = 0; public Int32 typeID = 0; public Int32 callStatus = 0; public Int32 callType = 0; public Int32 GrpID = 0; public String gwID = "0"; public String radioGwID = "0"; public TimerAndResp(System.Threading.Timer _timer, Boolean _wait) { timer = _timer; wait = _wait; } public TimerAndResp(System.Threading.Timer _timer, Boolean _wait,Int32 _typeID) { timer = _timer; wait = _wait; typeID = _typeID; } } public struct sDevice { public int index; public string name; } public class messBody { public string body; public string name; public messBody(String _body,String _name) { body = _body; name = _name; } } public class LiveTabWind { public ToolWindow toolwind; public LiveTab livetab=null; public LiveTabGIS livetabgis = null; public LiveTabWind(ToolWindow _toolwind, LiveTab _livetab) { toolwind = _toolwind; livetab = _livetab; } public LiveTabWind(ToolWindow _toolwind, LiveTabGIS _livetabgis) { toolwind = _toolwind; livetabgis = _livetabgis; } } public class HistTabWind { public ToolWindow toolwind; public HistoryTab histtab = null; public HistTabWind(ToolWindow _toolwind, HistoryTab _livetab) { toolwind = _toolwind; histtab = _livetab; } } public class Commands { public Commands(Int32 _type, String _imei, Int32 _time, Double _lat, Double _lng, Int32 _speed, Int32 _di, Double _alt) { type = _type; imei = _imei; time = _time; lat = _lat; lng = _lng; alt = _alt; speed = _speed; di = _di; } public Commands(Int32 _type, String _imei, Boolean _ARSon) { type = _type; imei = _imei; ARSon = _ARSon; } public Commands(Int32 _type, String _imei, String _mess, String _email) { type = _type; imei = _imei; messages = _mess; email = _email; } public Commands(Int32 _type, String _imei, String _zone) { type = _type; imei = _imei; zone = _zone; } public Commands(Int32 _type, String _imei,Int32 _di,Boolean _diNew) { type = _type; imei = _imei; di = _di; diNew = _diNew; } public Int32 type; public Int32 speed; public Int32 time; public Int32 di; public Boolean diNew = false; public string imei; public string messages; public string email; public string zone; public Double lat; public Double lng; public Double alt; public Boolean ARSon; } public class UnitsGroupClass { public ArrayList arrSc_id; public string name; } public class GatewayIDandIP { public Int32 GWID; public Int32 ID; public String IP; public GatewayIDandIP(Int32 _ID, Int32 _GWID, String _IP) { GWID = _GWID; ID = _ID; IP = _IP; } } public class DimensionsGoogle { public DimensionsGoogle(int HeightParam, int WidthParam) { Height = HeightParam; Width = WidthParam; } public int Height = 100; public int Width = 100; } /* public class AddrAndID { public String Address = ""; public Int32 ID = 0; public Int32 mapPointID = 0; public Double LAT = 0; public Double LNG = 0; public Int32 step = 0; public String Name = ""; public AddrAndID(Int32 _ID, Double _LAT, Double _LNG) { ID = _ID; LAT = _LAT; LNG = _LNG; Name = ""; step = 0; mapPointID = 0; } public AddrAndID(String _Name, Double _LAT, Double _LNG) { ID = 0; LAT = _LAT; LNG = _LNG; Name = _Name; step = 0; mapPointID = 0; } public AddrAndID(String _Name, Int32 _mapPointID,Double _LAT, Double _LNG) { ID = 0; LAT = _LAT; LNG = _LNG; Name = _Name; step = 0; mapPointID = _mapPointID; } public AddrAndID(AddrAndID _instanta) { ID = _instanta.ID; LAT = _instanta.LAT; LNG = _instanta.LNG; Name = _instanta.Name; step = 0; mapPointID = _instanta.mapPointID; } }*/ public class DataforGRID : INotifyPropertyChanged { private object _lock = new object(); private Int32 nrOfUpdates; public Int32 NrOfUpdates { get { return nrOfUpdates; } set { lock (_lock) { //The property changed event will get fired whenever //the value changes. The subscriber will do work if the value is //1. This way you can keep your business logic outside of the setter if (value != nrOfUpdates) { nrOfUpdates = value; NotifyPropertyChanged("nrOfUpdates"); } } } } private void NotifyPropertyChanged(string propertyName) { //Raise PropertyChanged event if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } public event PropertyChangedEventHandler PropertyChanged; private String id; public string Id { get { return id; } set { id = value; } } private string vehName; public string VehName { get { return vehName; } set { vehName = value; } } private DateTime datatime; public DateTime Datatime { get { return datatime; } set { datatime = value; } } private string address; public string Address { get { return address; } set { address = value; } } private string speed; public string Speed { get { return speed; } set { speed = value; } } private string di; public string DI { get { return di; } set { di = value; } } private string dox; public string DO { get { return dox; } set { dox = value; } } private string lat; public string Lat { get { return lat; } set { lat = value; } } private string alt; public string Alt { get { return alt; } set { alt = value; } } private string lng; public string Lng { get { return lng; } set { lng = value; } } private string zone; public string Zone { get { return zone; } set { zone = value; } } private string head; public string Head { get { return head; } set { head = value; } } private Int32 heading_int; public Int32 Heading_int { get { return heading_int; } set { heading_int = value; } } public DataforGRID(string _id, string _vehName, DateTime _datatime, string _address, string _speed, string _di, string _do, string _lat, string _lng, string _alt,Int32 _heading_Int32) { id = _id; vehName = _vehName; datatime = _datatime; address = _address; speed = _speed; di = _di; dox = _do; lat = _lat; lng = _lng; zone = ""; alt = _alt; heading_int = _heading_Int32; } public DataforGRID(string _id, string _vehName, DateTime _datatime, string _address, string _speed, string _head, string _di, string _do, string _lat, string _lng, String _zone, string _alt) { id =""; vehName = _vehName; datatime = _datatime; address = _address; speed = _speed; head = _head; di = _di; dox = _do; lat = _lat; lng = _lng; zone = _zone; alt = _alt; } } public class DataforRecording { private Image _buttonCol; public Image ButtonCol { get { return _buttonCol; } set { _buttonCol = value; } } private string _id; public string id { get { return _id; } set { _id = value; } } private Image _calltype; public Image calltype { get { return _calltype; } set { _calltype = value; } } private string _from; public string from { get { return _from; } set { _from = value; } } private string _to; public string to { get { return _to; } set { _to = value; } } private string _start; public string start { get { return _start; } set { _start = value; } } private string _stop; public string stop { get { return _stop; } set { _stop = value; } } private string _lngStart; public string lngStart { get { return _lngStart; } set { _lngStart = value; } } private string _lngStop; public string lngStop { get { return _lngStop; } set { _lngStop = value; } } private Int32 _duration; public Int32 duration { get { return _duration; } set { _duration = value; } } private Int32 _calltypeint; public Int32 calltypeint { get { return _calltypeint; } set { _calltypeint = value; } } public DataforRecording(Image V_buttonCol, string V_id, Image V_calltype, string V_from, string V_to, string V_start, string V_stop, string V_lngStart, string V_lngStop,Int32 V_duration,Int32 V_calltypeint) { _buttonCol = V_buttonCol; _id = V_id; _calltype = V_calltype; _from = V_from; _to = V_to; _start = V_start; _stop = V_stop; _lngStart = V_lngStart; _lngStop = V_lngStop; _duration = V_duration; _calltypeint = V_calltypeint; } } public class DataforVehList : INotifyPropertyChanged { private object _lock = new object(); private Int32 nrOfUpdates; public Int32 NrOfUpdates { get { return nrOfUpdates; } set { lock (_lock) { //The property changed event will get fired whenever //the value changes. The subscriber will do work if the value is //1. This way you can keep your business logic outside of the setter if (value != nrOfUpdates) { nrOfUpdates = value; NotifyPropertyChanged("nrOfUpdates"); } } } } private void NotifyPropertyChanged(string propertyName) { //Raise PropertyChanged event if(PropertyChanged!= null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } public event PropertyChangedEventHandler PropertyChanged; private string grpName; public string GrpName { get { return grpName; } set { grpName = value; } } private Image pict; public Image Pict { get { return pict; } set { pict = value; } } private string unitName; public string UnitName { get { return unitName; } set { unitName = value; } } private Boolean onMap; public Boolean OnMap { get { return onMap; } set { onMap = value; } } private string status; public string Status { get { return status; } set { // save current status as previous one prevStatus = status; // update the current status value status = value; } } private string prevStatus; public string PreviousStatus { get { return prevStatus; } } private Status_for_tab unitStatus; public Status_for_tab UnitStatus { get { return unitStatus; } set { unitStatus = value; status = Vehicle.GetString_Status(unitStatus); } } private Boolean isEmergency; public Boolean IsEmergency { get { return isEmergency; } set { isEmergency = value; } } private Int32 emerg0off1on; public Int32 Emerg0off1on { get { return emerg0off1on; } set { emerg0off1on = value; } } private Double latitude; public Double Latitude { get { return latitude; } set { latitude = value; } } private Double longitue; public Double Longitude { get { return longitue; } set { longitue = value; } } private string address; public string Address { get { return address; } set { address = value; } } private DateTime positionTime; public DateTime PositionTime { get { return positionTime; } set { positionTime = value; string timeAgo = Utils.GetDateTimeAgo(positionTime); if (timeAgo.Equals(MainForm2.returnLNGString("scheduled"))) positionTimeAgo = MainForm2.returnLNGString("inTheFuture"); else positionTimeAgo = timeAgo; } } private String positionTimeAgo; public String PositionTimeAgo { get { return positionTimeAgo; } set { positionTimeAgo = value; } } private Int16 speed; public Int16 Speed { get { return speed; } set { speed = value; } } private Boolean isMPH; public Boolean IsMPH { get { return isMPH; } set { isMPH = value; } } private Boolean hasAlerts; public Boolean HasAlerts { get { return hasAlerts; } set { hasAlerts = value; } } private Boolean stolen; public Boolean Stolen { get { return stolen; } set { this.stolen = value; nrOfUpdates++; } } public Boolean HasVoice { get; set; } public Boolean HasText { get; set; } private String radioId; public String RadioId { get { return radioId; } set { radioId = value; } } private Int32 sipId; public Int32 SipId { get { return sipId; } set { sipId = value; } } private String radioGateway; public String RadioGateway { get { return radioGateway; } set { radioGateway = value; } } public DataforVehList() { PositionTime = new DateTime(1970,1,1); } public DataforVehList(string _grpName, Image _pict, String _unitName, Boolean _onMap, string _status, Int32 _emerg0off1on) { grpName = _grpName; pict = _pict; unitName = _unitName; onMap = _onMap; status = _status; emerg0off1on = _emerg0off1on; PositionTime = new DateTime(1970, 1, 1); radioGateway = ""; } } public class DataforHistList { private Boolean checkItem; public Boolean CheckItem { get { return checkItem; } set { checkItem = value; } } private Image pict; public Image Pict { get { return pict; } set { pict = value; } } private string unitName; public string UnitName { get { return unitName; } set { unitName = value; } } public DataforHistList(Boolean _checkItem, Image _pict, String _unitName) { checkItem = _checkItem; pict = _pict; unitName = _unitName; } } public class DataforAlarmList { private String unitName; public String UnitName { get { return unitName; } set { unitName = value; } } private DateTime timex; public DateTime Timex { get { return timex; } set { timex = value; } } private string descript; public string Descript { get { return descript; } set { descript = value; } } public DataforAlarmList(String _unitName, DateTime _timex, String _desc) { descript = _desc; timex = _timex; unitName = _unitName; } } public class DataforSystemList { public enum SystemEvent { ARS, GPS, POLL, CALLCOMMAND, CALLBROADCAST, DEKEY, SMS, TICKETING, TELEMETRY, DISPATCHERS, EMERGENCY, ENABLE_DISABLE, REMOTE, DISPATCH_ALERTS, EMAIL_REPORTS, RADIO_STATUS, RECORDINGS, UNKNOWN, CHANNEL, FAILOVER } private Int32 direct; public Int32 Direct { get { return direct; } set { direct = value; } } private String typestr; public String Typestr { get { return typestr; } set { typestr = value; } } private string opcode; public string Opcode { get { return opcode; } set { Opcode = value; } } private string imei; public string Imei { get { return imei; } set { imei = value; } } private DateTime timecmd; public DateTime Timecmd { get { return timecmd; } set { timecmd = value; } } private string cmd; public string Cmd { get { return cmd; } set { cmd = value; } } private string humanMsg; public string HumanMsg { get { return humanMsg; } set { humanMsg = value; } } private Color color; public Color Color { get { return color; } set { color = value; } } private SystemEvent sysEvent; public SystemEvent SysEvent { get { return sysEvent; } set { sysEvent = value; } } private CheckState checkState = CheckState.Unchecked; public CheckState CheckState { get { return checkState; } set { checkState = value; } } private String sysEventMsg; public String SysEventMsg { get { return sysEventMsg; } set { sysEventMsg = value; } } public DataforSystemList() { color = Color.White; } public DataforSystemList(Int32 _direct, string _typestr, string _opcode, String _imei, DateTime _timecmd, string _cmd, ContactType callSourceType = ContactType.UNIT) { color = Color.White; direct = _direct; typestr = _typestr; opcode = _opcode; imei = _imei; timecmd = _timecmd; cmd = _cmd; sysEvent = GetSystemEventFromOpCode(opcode, callSourceType); color = GetColorForEvent(sysEvent, false); } private SystemEvent GetSystemEventFromOpCode(string opCode, ContactType callSourceType = ContactType.UNIT) { humanMsg = " - "; try { string[] splitCmd = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); switch (opCode) { case "10": { // nothing here, only BUSY sysEventMsg = "BUSY"; return SystemEvent.UNKNOWN; } case "100": { // nothing here, "ON/OFF" for radio gatways from Gws; sysEventMsg = "ON/OFF"; return SystemEvent.UNKNOWN; } case "101": { #region ALL CALL INIT sysEventMsg = "All Call Initiating"; imei = "Gateway " + imei; humanMsg = String.Format(MainForm2.returnLNGString("allCallInit")); return SystemEvent.CALLCOMMAND; #endregion } case "121": { #region ALL CALL INIT ACK sysEventMsg = "All Call Initiating ACK"; imei = "Gateway " + imei; humanMsg = String.Format(MainForm2.returnLNGString("ackAllCallInitReq")); return SystemEvent.CALLCOMMAND; #endregion } case "111": { #region ALL CALL INIT ACK sysEventMsg = "All Call Ending"; imei = "Gateway " + imei; humanMsg = String.Format(MainForm2.returnLNGString("allCallEndingReq")); return SystemEvent.CALLCOMMAND; #endregion } case "115": { #region ALL CALL INIT ACK sysEventMsg = "All Call Ending ACK"; imei = "Gateway " + imei; humanMsg = String.Format(MainForm2.returnLNGString("ackAllCallEndingReq")); return SystemEvent.CALLCOMMAND; #endregion } case "103": { #region PRIVATE CALL INIT sysEventMsg = "Group Call Initiating"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); imei = "Gateway " + imei; vehicleName = split[2]; humanMsg = String.Format(MainForm2.returnLNGString("privCallInitGroup"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "123": { #region GROUP CALL INIT ACK sysEventMsg = "Group Call Initiating ACK"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length >= 3) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("ackGroupCallInitReq"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "113": { #region GROUP CALL END sysEventMsg = "Group Call Ending"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); vehicleName = split[2]; imei = "Gateway " + id; humanMsg = String.Format(MainForm2.returnLNGString("groupCallEndingReq"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "117": { #region GROUP CALL END ACK sysEventMsg = "Group Call Ending ACK"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) { Int32.TryParse(split[2], out id); vehicleName = split[2]; } imei = "Gateway" + imei; humanMsg = String.Format(MainForm2.returnLNGString("ackGroupCallEndingReq"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "102": { #region PRIVATE CALL INIT sysEventMsg = "Private Call Initiating"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("privCallInitVeh"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "122": { #region PRIVATE CALL INIT ACK sysEventMsg = "Private Call Initiating ACK"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("ackPrivCallInitReq"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "112": { #region PRIVATE CALL END sysEventMsg = "Private Call Ending"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("privCallEndingReq"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "116": { #region PRIVATE CALL END ACK sysEventMsg = "Private Call Ending ACK"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("ackPrivCallEndingReq"), vehicleName); return SystemEvent.CALLCOMMAND; #endregion } case "94": { #region CHANNEL QUERY sysEventMsg = "Gateway channel query"; humanMsg = string.Format(MainForm2.returnLNGString("voicetabChQueryForGW"), imei); imei = "Gateway " + imei; return SystemEvent.CHANNEL; #endregion } case "104": { #region CHANNEL REQUEST sysEventMsg = "Chanel info request"; humanMsg = string.Format(MainForm2.returnLNGString("chanelInfoReqGW"), imei); imei = "Gateway " + imei; return SystemEvent.CHANNEL; #endregion } case "124": { #region CHANNEL RECEIVED sysEventMsg = "Chanel info received"; humanMsg = string.Format(MainForm2.returnLNGString("chanelInfoRecGW"), imei); imei = "Gateway " + imei; return SystemEvent.CHANNEL; #endregion } case "125": { #region CALL STATUS sysEventMsg = "Call status"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // get the id of the unit if (split.Length > 2) Int32.TryParse(split[2], out id); if (callSourceType == ContactType.UNIT) { // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = "unit with id " + id; imei = id + ""; } } else if (callSourceType == ContactType.USER) { // find user if (MainForm2.userIDHash.ContainsKey(id)) // check if source radio id is a dispatcher (for sip group calls) { imei = MainForm2.userIDHash[id].ToString(); vehicleName = "dispatcher " + imei; } else { vehicleName = "unit with id " + id; imei = id + ""; } } else { vehicleName = "unit with id " + id; imei = id + ""; } String callMsg = ""; String[] split2 = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); if (split2.Length >= 7) { string callType = split2[5]; string callStatus = split2[4]; string calledImei = split2[6]; if (callType.EndsWith("3")) callType = "GROUP CALL"; else if (callType.EndsWith("1")) callType = "ALL CALL"; else if (callType.EndsWith("2")) callType = "PRIVATE CALL"; if (callStatus.Equals("1")) callStatus = "in progress"; else if (callStatus.Equals("2")) callStatus = "hang timed"; else if (callStatus.Equals("3")) callStatus = "ended"; callMsg = callType + " " + callStatus; // set the called user name if (callType.Equals("PRIVATE CALL")) { String calledName = ""; if (MainForm2.VehIMEIHash.Contains(calledImei + "")) calledName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[calledImei + ""].ToString()])).busName; else calledName = calledImei; callMsg += " with " + calledName.ToUpper(); } else if (callType.Equals("GROUP CALL")) { String calledName = ""; /* if (MainForm2.VehIMEIHash.Contains(calledImei)) calledName = ((GroupClass)(MainForm2.GroupHash[MainForm2.VehIMEIHash[calledImei + ""].ToString()])).name; else*/ calledName = calledImei; callMsg += " with " + calledName.ToUpper(); } } humanMsg = String.Format(MainForm2.returnLNGString("from"), callMsg, vehicleName); return SystemEvent.CALLBROADCAST; #endregion } case "130": { #region ARS RECEIVED sysEventMsg = "ARS received"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; humanMsg = String.Format(MainForm2.returnLNGString("ARSfrom"), split[4], vehicleName); return SystemEvent.ARS; #endregion } case "230": { sysEventMsg = "POLL ARS"; return SystemEvent.ARS; } case "131": { #region LOCATION RECEIVED sysEventMsg = "Location received"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; humanMsg = String.Format(MainForm2.returnLNGString("positionFrom"), Math.Round(Double.Parse(split[6]), 5), Math.Round(Double.Parse(split[7]), 5), vehicleName); return SystemEvent.GPS; #endregion } case "132": { if (cmd.Contains("")) { #region TICKET RECEIVED sysEventMsg = "Ticket received"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length >= 5) Int32.TryParse(split[3], out id); try { String ticketMsg = split[4]; String ticketNr = "0"; String ticketStatus = "unknown".ToUpper(); ticketNr = Regex.Match(ticketMsg, @"\d+").Value; ticketStatus = ticketMsg.Substring(ticketMsg.IndexOf(ticketNr + "") + ticketNr.Length).ToUpper(); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + imei; } humanMsg = String.Format(MainForm2.returnLNGString("ticketStatusEventLog"), ticketNr, ticketStatus, vehicleName); } catch (Exception) { humanMsg = String.Format(MainForm2.returnLNGString("ticketStatusUpdate"), vehicleName); } return SystemEvent.TICKETING; #endregion } else { sysEventMsg = "SMS RECEIVED"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String textMessage = ""; if (split.Length > 5) textMessage = split[4]; String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + imei; } humanMsg = String.Format("Text message [{0}] received from {1}", textMessage, vehicleName); return SystemEvent.TICKETING; } } case "232": { #region TEXT MESSAGE ACK sysEventMsg = "Text message acknowledge"; String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei + ""].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; humanMsg = String.Format(MainForm2.returnLNGString("smsACK"), vehicleName); return SystemEvent.SMS; #endregion } case "142": case "143": { if (cmd.Contains("")) { #region TICKET SEND sysEventMsg = opCode.Equals("142") ? MainForm2.returnLNGString("tkSent") : MainForm2.returnLNGString("tkResent"); String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = string.Format(MainForm2.returnLNGString("toUnit"), id); imei = id + ""; } humanMsg = String.Format(sysEventMsg + vehicleName); return SystemEvent.TICKETING; #endregion } else { #region SMS SEND sysEventMsg = opCode.Equals("142") ? MainForm2.returnLNGString("smsSent") : MainForm2.returnLNGString("smsResent"); String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = string.Format(MainForm2.returnLNGString("toUnit"), id); imei = id + ""; } humanMsg = String.Format(sysEventMsg + vehicleName); return SystemEvent.SMS; #endregion } } case "242": { #region TEXT MESSAGE ACK sysEventMsg = "Text message acknowledge"; String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei + ""].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; humanMsg = String.Format(MainForm2.returnLNGString("smsACK"), vehicleName); return SystemEvent.SMS; #endregion } case "144": { sysEventMsg = "SMS GROUP SEND"; return SystemEvent.SMS; } case "244": { sysEventMsg = "SMS GROUP ACK"; return SystemEvent.SMS; } case "133": { #region TELEMETRY REQUEST sysEventMsg = "Telemetry request"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // get the id of the unit if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = "unit with id " + id; imei = id + ""; } String telemetryMsg = ""; String[] split2 = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); if (split2.Length >= 5) { string telemOptions = split2[4]; string pin = (telemOptions.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries))[0]; if (pin.Equals("10")) telemetryMsg = " [" + MainForm2.returnLNGString("telemRefresh").ToUpper() + "]"; else { string option = (telemOptions.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries))[1]; if (option.Equals("0")) option = MainForm2.returnLNGString("telemSet").ToUpper(); else if (option.Equals("1")) option = MainForm2.returnLNGString("telemClear").ToUpper(); else if (option.Equals("2")) option = MainForm2.returnLNGString("telemToggle").ToUpper(); else if (option.Equals("3")) option = MainForm2.returnLNGString("telemPulse").ToUpper(); telemetryMsg = " [" + option + " " + MainForm2.returnLNGString("telemPin").ToLower() + " " + pin + "]"; } } humanMsg = String.Format(MainForm2.returnLNGString("telReq"), vehicleName, telemetryMsg); return SystemEvent.TELEMETRY; #endregion } case "233": { #region TELEMETRY RECEIVED sysEventMsg = "Telemetry received"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length >= 5) Int32.TryParse(split[4], out id); // get the pin from int value string pin = split[4]; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; humanMsg = String.Format(MainForm2.returnLNGString("telRec"), vehicleName, pin); return SystemEvent.TELEMETRY; #endregion } case "231": { sysEventMsg = "Poll Location"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; humanMsg = String.Format("Poll response [{0:0.0000},{1:0.0000}] from {2}", Math.Round(Double.Parse(split[6]), 5), Math.Round(Double.Parse(split[7]), 5), vehicleName); return SystemEvent.POLL; } case "207": { #region CHANNEL BUSY/FREE imei = "Gateway " + imei; int status = 0; //string[] splitCmd = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); // set the type value if (splitCmd.Length >= 6) Int32.TryParse(splitCmd[5], out status); sysEventMsg = "Channel " + (status == 1 ? "Busy" : "Free"); humanMsg = String.Format(MainForm2.returnLNGString("chnStatus"), splitCmd[4], (status == 0 ? MainForm2.returnLNGString("Free") : MainForm2.returnLNGString("Busy")), imei); return SystemEvent.CHANNEL; #endregion } case "202": { #region DISPATCHER ON sysEventMsg = "Dispatcher ON"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String dispatcherName = ""; int id = 0; // set the id if (split.Length >= 4) Int32.TryParse(split[3], out id); // check if contains the user id if (MainForm2.allDispatchersNames.ContainsKey(id)) dispatcherName = MainForm2.allDispatchersNames[id]; imei = dispatcherName; humanMsg = "Dispatcher " + (dispatcherName.Length > 0 ? dispatcherName.ToUpper() : "with id " + id) + " has signed in"; return SystemEvent.DISPATCHERS; #endregion } case "212": { #region DISPATCHER OFF sysEventMsg = "Dispatcher OFF"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String dispatcherName = ""; int id = 0; // set the id if (split.Length >= 4) Int32.TryParse(split[3], out id); // check if contains the user id if (MainForm2.allDispatchersNames.ContainsKey(id)) dispatcherName = MainForm2.allDispatchersNames[id]; imei = dispatcherName; humanMsg = "Dispatcher " + (dispatcherName.Length > 0 ? dispatcherName.ToUpper() : "with id " + id) + " has signed out"; return SystemEvent.DISPATCHERS; #endregion } case "201": { sysEventMsg = "USER CALL"; return SystemEvent.DISPATCHERS; } case "221": { sysEventMsg = "ACK USER CALL"; return SystemEvent.DISPATCHERS; } case "211": { sysEventMsg = "END USER CALL"; return SystemEvent.DISPATCHERS; } case "134": case "138": { sysEventMsg = "EMERGENCY"; String vehicleName = ""; int emergType = -1; string emergDesc = ""; if (splitCmd.Count() > 4) int.TryParse(splitCmd[4], out emergType); if (emergType != -1) emergDesc = $"\"{((EmergencyTypes)emergType).ToString()}\""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + imei; } humanMsg = $"Emergency {emergDesc} received from {vehicleName}"; return SystemEvent.EMERGENCY; } case "238": { // #48#2.1507709848636433174488152074#238#0.0.115#3 String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } AlarmTypes alarmType = AlarmTypes.unknown; int emergType = -1; if (splitCmd.Count() > 4) int.TryParse(splitCmd[4], out emergType); if (emergType != -1) alarmType = (AlarmTypes)emergType; if (alarmType != AlarmTypes.unknown && alarmType != AlarmTypes.all) { sysEventMsg = $"{alarmType.ToString().FirstLetterToUpper()} alarm ACK"; humanMsg = $"{alarmType.ToString().FirstLetterToUpper()} alarm acknowledgment for {vehicleName}"; } else { alarmType = AlarmTypes.all; sysEventMsg = $"{alarmType.ToString().FirstLetterToUpper()} alarms ACK"; humanMsg = $"{alarmType.ToString().FirstLetterToUpper()} alarms acknowledged for {vehicleName}"; } return SystemEvent.EMERGENCY; } case "208": { #region STOLEN REQUEST sysEventMsg = "Stolen Request"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei + ""].ToString()])).busName; imei = vehicleName; } else vehicleName = " unit with id " + imei; int type = 0; // set the type value if (splitCmd.Length >= 5) Int32.TryParse(splitCmd[4], out type); humanMsg = String.Format(MainForm2.returnLNGString("stolenReq"), vehicleName); return SystemEvent.ENABLE_DISABLE; #endregion } case "150": { #region ENABLE/DISABLE REQ sysEventMsg = "Enable/Disable Request"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the imei value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = " unit with id " + id; imei = id + ""; } int type = 0; //string[] splitCmd = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); // set the type value if (splitCmd.Length >= 5) Int32.TryParse(splitCmd[4], out type); humanMsg = String.Format(MainForm2.returnLNGString("req"), (type == 1 ? MainForm2.returnLNGString("Enable") : MainForm2.returnLNGString("Disable")), vehicleName); return SystemEvent.ENABLE_DISABLE; #endregion } case "151": { sysEventMsg = "Enable/Disable STAT"; return SystemEvent.ENABLE_DISABLE; } case "250": { #region ENABLE/DISABLE RESPONSE sysEventMsg = "Enable/Disable Broadcast"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei + ""].ToString()])).busName; imei = vehicleName; } else vehicleName = "Unit with id " + imei; int type = 0; //string[] splitCmd = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); // set the type value if (splitCmd.Length >= 5) Int32.TryParse(splitCmd[4], out type); humanMsg = String.Format(MainForm2.returnLNGString("isNow"), vehicleName, (type == 1 ? MainForm2.returnLNGString("Enabled") : MainForm2.returnLNGString("Disabled"))); return SystemEvent.ENABLE_DISABLE; #endregion } case "160": { sysEventMsg = "Radio DeKEY"; return SystemEvent.DEKEY; } case "161": { sysEventMsg = "Remote Monitor"; return SystemEvent.REMOTE; } case "162": { sysEventMsg = "Remote Monitor Response"; return SystemEvent.REMOTE; } case "172": { sysEventMsg = "End Remote Monitor"; return SystemEvent.REMOTE; } case "135": { sysEventMsg = "Speed Alarm"; int speedValue = -1; if (splitCmd.Count() > 4 && splitCmd[4].Contains("_")) int.TryParse(splitCmd[4].Split('_')[0], out speedValue); String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = "Unit with id " + imei; humanMsg = String.Format($"{vehicleName} was speeding with {speedValue} {(splitCmd[4].EndsWith("m") ? "mph" : "kph")}"); return SystemEvent.DISPATCH_ALERTS; } case "136": { sysEventMsg = "Zone Alarm"; String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = "Unit with id " + imei; if (splitCmd.Count() > 4) humanMsg = $"{splitCmd[4]}"; return SystemEvent.DISPATCH_ALERTS; } case "137": { sysEventMsg = "LandMark Alarm"; String vehicleName = ""; // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = "Unit with id " + imei; if (splitCmd.Count() > 4) humanMsg = $"{splitCmd[4]}"; return SystemEvent.DISPATCH_ALERTS; } case "139": { sysEventMsg = "Subs. Location"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; // set the status value if (split.Length >= 6) imei = split[5]; // get the status from int value String gateway = ""; if (split.Length >= 5) gateway = split[4]; humanMsg = String.Format("{0} registered on gateway {1}", vehicleName, ""); cmd = "ddsdds"; return SystemEvent.UNKNOWN; } case "140": { sysEventMsg = "DI alarm"; return SystemEvent.DISPATCH_ALERTS; } case "149": { #region Radio Check Online Request sysEventMsg = "Radio Online Check"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = "Unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("radioOnlineCheckReqFor"), vehicleName); return SystemEvent.ARS; #endregion } case "154": { #region POLL REQUEST sysEventMsg = "Poll request"; String[] split = imei.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length > 2) Int32.TryParse(split[2], out id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(id + "")) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[id + ""].ToString()])).busName; imei = vehicleName; } else { vehicleName = "Unit with id " + id; imei = id + ""; } humanMsg = String.Format(MainForm2.returnLNGString("pollReqFor"), vehicleName); return SystemEvent.POLL; #endregion } case "152": { sysEventMsg = "Email report"; return SystemEvent.EMAIL_REPORTS; } case "153": { #region UNIT STATUS sysEventMsg = "Unit Status"; String[] split = cmd.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries); String vehicleName = ""; int id = 0; // set the status value if (split.Length >= 5) Int32.TryParse(split[4], out id); // get the status from int value String status = ""; status = Utils.GetStatusFromInt(id); // check if vehicle name exists if (MainForm2.VehIMEIHash.Contains(imei)) { vehicleName = ((Vehicle)(MainForm2.vehicleHT[MainForm2.VehIMEIHash[imei].ToString()])).busName; imei = vehicleName; } else vehicleName = "Unit with id " + imei; humanMsg = String.Format(MainForm2.returnLNGString("statusIsNow"), vehicleName, status); return SystemEvent.RADIO_STATUS; #endregion } case "155": { #region RECORDINGS sysEventMsg = "Recordings"; humanMsg = MainForm2.returnLNGString("newRec"); return SystemEvent.RECORDINGS; #endregion } case "610": { sysEventMsg = "Failover module"; string message = MainForm2.returnLNGString(splitCmd[4]); humanMsg = string.IsNullOrEmpty(message) ? $"missing message for {splitCmd[4]}" : message ; return SystemEvent.FAILOVER; } default: { sysEventMsg = "RESERVED"; humanMsg = MainForm2.returnLNGString("reservedMsg"); return SystemEvent.UNKNOWN; } } } catch (Exception ex) { Utils.WriteLine("Error on display Systemlog:" + ex.ToString() + " OP code:" + opCode, ConsoleColor.Red); sysEventMsg = "RESERVED"; humanMsg = MainForm2.returnLNGString("reservedMsg"); return SystemEvent.UNKNOWN; } } private Color GetColorForEvent(SystemEvent ev, bool isFirstColor) { switch(ev) { case SystemEvent.ARS: { if(isFirstColor) return Color.FromArgb(173,35,35); else return Color.FromArgb(29, 105, 20); } case SystemEvent.GPS: return Color.FromArgb(42,75,215); case SystemEvent.POLL: return Color.FromArgb(92, 157, 228); case SystemEvent.CALLCOMMAND: return Color.FromArgb(255,238,51); case SystemEvent.CALLBROADCAST: return Color.FromArgb(221,204,0); case SystemEvent.DEKEY: return Color.Black; case SystemEvent.SMS: return Color.FromArgb(129,74,25); case SystemEvent.TICKETING: return Color.FromArgb(162,36,139); case SystemEvent.TELEMETRY: return Color.FromArgb(83,52,146); case SystemEvent.EMERGENCY: return Color.FromArgb(255,0,0); case SystemEvent.ENABLE_DISABLE: return Color.FromArgb(87,87,87); case SystemEvent.REMOTE: return Color.FromArgb(129,38,192); case SystemEvent.DISPATCHERS: return Color.FromArgb(41,208,208); case SystemEvent.DISPATCH_ALERTS: return Color.FromArgb(129, 197, 122); case SystemEvent.EMAIL_REPORTS: return Color.FromArgb(233,222,187); case SystemEvent.RADIO_STATUS: return Color.White; } return Color.White; } } public class DataforTelemList { private string grpName; public string GrpName { get { return grpName; } set { grpName = value; } } private Image pict; public Image Pict { get { return pict; } set { pict = value; } } private string unitName; public string UnitName { get { return unitName; } set { unitName = value; } } private Image digi1; public Image Digi1 { get { return digi1; } set { digi1 = value; } } private Image digi2; public Image Digi2 { get { return digi2; } set { digi2 = value; } } private Image digi3; public Image Digi3 { get { return digi3; } set { digi3 = value; } } private Image digi4; public Image Digi4 { get { return digi4; } set { digi4 = value; } } private Image digi5; public Image Digi5 { get { return digi5; } set { digi5 = value; } } public DataforTelemList(string _grpName, Image _pict, String _unitName, Image _digi1, Image _digi2, Image _digi3, Image _digi4, Image _digi5) { grpName = _grpName; pict = _pict; unitName = _unitName; digi1 = _digi1; digi2 = _digi2; digi3 = _digi3; digi4 = _digi4; digi5 = _digi5; } } public class SMSDataforGRID { private Int32 idx; public Int32 Idx { get { return idx; } set { idx = value; } } //image part private Bitmap icon; public Bitmap Icon { get { return icon; } set { icon = value; } } private string source; public string Source { get { return source; } set { source = value; } } private string dest; public string Dest { get { return dest; } set { dest = value; } } private string dispMess; public string DisplayMessage { get { return dispMess; } set { dispMess = value; } } private string msg; public string Message { get { return msg; } set { msg = value; } } private string data; public string Date { get { return data; } set { data = value; } } private Int32 stat; public Int32 Status { get { return stat; } set { stat = value; } } private string emailprv; public string email { get { return emailprv; } set { emailprv = value; } } private Int32 sc_id_source_prv; public Int32 sc_id_source { get { return sc_id_source_prv; } set { sc_id_source_prv = value; } } private Int32 sc_id_dest_prv; public Int32 sc_id_dest { get { return sc_id_dest_prv; } set { sc_id_dest_prv = value; } } private string timeAgo; public string TimeAgo { get { return timeAgo; } set { timeAgo = value; } } private Color color; public Color Color { get { return color; } set { color = value; } } private DateTime _dateTime; public DateTime DateTime { get { return _dateTime; } } public SMSDataforGRID(Int32 _idx, Bitmap _icon, String _source, string _dest, string _dispmess, string _mess, string _date, Int32 _stat, string _email, Int32 _sc_id_source, Int32 _sc_id_dest, DateTime date) { idx = _idx; icon = _icon; source = _source; dest = _dest; dispMess = _dispmess; msg = _mess; data = _date; stat = _stat; emailprv = _email; sc_id_source_prv = _sc_id_source; sc_id_dest_prv = _sc_id_dest; _dateTime = date; String timeAgoStr = Utils.GetDateTimeAgo(date.ToLocalTime()); if (timeAgoStr.Equals(MainForm2.returnLNGString("scheduled"))) timeAgo = MainForm2.returnLNGString("inTheFuture"); else timeAgo = timeAgoStr; } } public class SystemLog { public String cmd = ""; public Boolean Senddata; public SystemLog(Boolean _Senddata, String _cmd) { Senddata = _Senddata; cmd = _cmd; } } public class SoundandPopup { public Boolean EMsound { get; set; } public Boolean EMpopup { get; set; } public Boolean GEOsound { get; set; } public Boolean GEOpopup { get; set; } public Boolean SPEEDsound { get; set; } public Boolean SPEEDpopup { get; set; } public Boolean TELEMsound { get; set; } public Boolean TELEMpopup { get; set; } public Int32 sc_id = 0; public SoundandPopup() { } public SoundandPopup(Int32 _sc_id,Boolean _EMsound, Boolean _EMpopup, Boolean _GEOsound, Boolean _GEOpopup, Boolean _SPEEDsound, Boolean _SPEEDpopup, Boolean _TELEMsound, Boolean _TELEMpopup) { EMsound = _EMsound; EMpopup = _EMpopup; GEOsound = _GEOsound; GEOpopup = _GEOpopup; SPEEDsound = _SPEEDsound; SPEEDpopup = _SPEEDpopup; TELEMsound = _TELEMsound; TELEMpopup = _TELEMpopup; sc_id = _sc_id; } } public class GoogleGeoCodeResponse { public string status { get; set; } public results[] results { get; set; } } public class results { public string formatted_address { get; set; } public geometry geometry { get; set; } public string[] types { get; set; } public address_component[] address_components { get; set; } } public class geometry { public string location_type { get; set; } public location location { get; set; } } public class location { public string lat { get; set; } public string lng { get; set; } } public class address_component { public string long_name { get; set; } public string short_name { get; set; } public string[] types { get; set; } } public class OpenStreetGeoCodeResponse { public string place_id { get; set; } public string licence { get; set; } public string osm_type { get; set; } public string osm_id { get; set; } public string lat { get; set; } public string lon { get; set; } public string display_name { get; set; } public address_type address { get; set; } } public class address_type { public string house_number { get; set; } public string road { get; set; } public string suburb { get; set; } public string city { get; set; } public string county { get; set; } public string state_district { get; set; } public string state { get; set; } public string postcode { get; set; } public string country { get; set; } public string country_code { get; set; } } public class POSIDGIS { public Int32 GISID = 0; public SMposition SMpos = null; public Boolean Select = false; public POSIDGIS(Int32 _GISID,SMposition _SMpos) { GISID = _GISID; SMpos = _SMpos; Select = false; } } public enum RADIO_STATUS { OFF = 0x00, FREE = 0x01, ALLcall_INIT = 101, ALLcall_INPROGRES = 121, PrivateCall_INIT = 102, PrivateCall_INPROGRES = 122, GroupCall_INIT = 103, GroupCall_INPROGRES = 123, ChannelQuery = 104, CallEvent = 125, RemoteMonitor = 161, RemoteMonitor_INPROGRES = 162, DKEY = 160, EnableDisable = 150, HangTime = 108, } ///code from telerik public class CustomListVisualItem : RadListVisualItem { #region Fields private RadLabelElement label = new RadLabelElement(); private RadCheckBox checkBox = new RadCheckBox(); private RadHostItem host; #endregion #region Initialization static CustomListVisualItem() { RadListVisualItem.SynchronizationProperties.Add(CustomListDataItem.CheckedProperty); RadListVisualItem.SynchronizationProperties.Add(CustomListDataItem.NameProperty); } #endregion #region Overrides protected override Type ThemeEffectiveType { get { return typeof(RadListVisualItem); } } protected override void CreateChildElements() { base.CreateChildElements(); this.host = new RadHostItem(checkBox); this.checkBox.ToggleStateChanged += this.ToggleStateChanged; this.label.StretchHorizontally = true; this.label.Margin = new System.Windows.Forms.Padding(15, 0, 0, 0); this.host.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); StackLayoutPanel stack = new StackLayoutPanel(); stack.Orientation = Orientation.Horizontal; stack.Children.Add(host); stack.Children.Add(label); this.Children.Add(stack); } protected override void PropertySynchronized(RadProperty property) { CustomListDataItem dataItem = (CustomListDataItem)this.Data; if (property == CustomListDataItem.CheckedProperty) { bool newValue = dataItem.Checked; this.checkBox.Checked = newValue; string itemName = dataItem.Text; //this.label.Text = this.GetAvailabilityText(itemName, newValue); this.label.Text = itemName; } if (property == CustomListDataItem.NameProperty) { string itemName = dataItem.Text; bool available = dataItem.Checked; //this.label.Text = this.GetAvailabilityText(itemName, available); this.label.Text = itemName; } this.Text = ""; } #endregion #region Private Methods /* private string GetAvailabilityText(string itemName, bool available) { string yesno = available ? " " : " not "; return itemName + " is" + yesno + "checked"; }*/ private void ToggleStateChanged(object sender, StateChangedEventArgs args) { ((CustomListDataItem)this.Data).Checked = this.checkBox.Checked; } #endregion } public class CustomListDataItem : RadListDataItem { #region Contructors public CustomListDataItem() { this.PropertyChanged += new PropertyChangedEventHandler(item_PropertyChanged); } public CustomListDataItem(string text) : base(text) { this.PropertyChanged += new PropertyChangedEventHandler(item_PropertyChanged); } #endregion #region RadProperties public static readonly RadProperty CheckedProperty = RadProperty.Register("Checked", typeof(bool), typeof(CustomListDataItem), new RadElementPropertyMetadata(false)); public static readonly RadProperty NameProperty = RadProperty.Register("Name", typeof(string), typeof(CustomListDataItem), new RadElementPropertyMetadata("")); #endregion #region Properties public bool Checked { get { return (bool)this.GetValue(CustomListDataItem.CheckedProperty); } set { //Console.WriteLine(this.Text + " " + value); this.SetValue(CustomListDataItem.CheckedProperty, value); } } public string Name { get { return (string)this.GetValue(CustomListDataItem.NameProperty); } set { this.SetValue(CustomListDataItem.NameProperty, value); } } #endregion #region Private Methods private void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { //Console.WriteLine("Valori: "+e.PropertyName); //if ((e.PropertyName == "Checked") || (e.PropertyName == "Selected") || (e.PropertyName == "Active")) if (e.PropertyName.Equals("Selected")) { RadMultiSelectDropDownList ddlControl = (RadMultiSelectDropDownList)((DropDownPopupForm)this.Owner.ElementTree.Control).OwnerDropDownListElement.ElementTree.Control; ddlControl.SetText(); } } #endregion } public enum CMDTYPE { DisableCMD = 0, EnableCMD = 1, POLLGPSCMD = 2, StolenONCMD = 3, StolenOFFCMD = 4, POLLARSCMD = 5, RADIO_CHECK_CMD = 6 } //public enum RADIOTYPE //{ // MOTO = 0, // HYT = 1, // HARRIS = 2, // ATLAS = 3, // UNKNOWN = 4, // TETRA = 5, // CONECTPLUS = 6, // REPEATER_TRBO = 7, // SIMOCO = 8, // LINX = 9, // LINXB = 10, // EXCERA = 11 //} public enum IconType { ICONS = 0, ARROWS = 1, EMERG = 2, } public class MyDynamicCollection : IList { RadMultiSelectDropDownList owner; public MyDynamicCollection(RadMultiSelectDropDownList owner) { this.owner = owner; } public void Add(CustomListDataItem item) { item.Checked = true; } public void Clear() { for (int i = 0; i < owner.Items.Count; i++) { ((CustomListDataItem)owner.Items[i]).Checked = false; } } public bool Contains(CustomListDataItem item) { for (int i = 0; i < owner.Items.Count; i++) { if (((CustomListDataItem)owner.Items[i]).Checked) { if (owner.Items[i] == item) { return true; } } } return false; } public void CopyTo(CustomListDataItem[] array, int arrayIndex) { throw new NotImplementedException(); } public int Count { get { int counter = 0; for (int i = 0; i < owner.Items.Count; i++) { if (((CustomListDataItem)owner.Items[i]).Checked) { counter++; } } Console.WriteLine(owner.Items[0].Selected + " " + owner.Items[1].Selected + " " + owner.Items[2].Selected + " " + owner.Items[3].Selected + " " + owner.Items[4].Selected); Console.WriteLine("SelectedItems Count " + counter); return counter; } } public bool IsReadOnly { get { return false; } } public bool Remove(CustomListDataItem item) { item.Checked = false; return true; } public IEnumerator GetEnumerator() { return new MyCollectionEnumerator(owner, this); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new MyCollectionEnumerator(owner, this); } public int IndexOf(CustomListDataItem item) { int counter = 0; for (int i = 0; i < owner.Items.Count; i++) { if (((CustomListDataItem)owner.Items[i]).Checked) { if (owner.Items[i] == item) { return counter; } counter++; } } return -1; } public void Insert(int index, CustomListDataItem item) { // throw new NotImplementedException(); } public void RemoveAt(int index) { int counter = 0; for (int i = 0; i < owner.Items.Count; i++) { if (((CustomListDataItem)owner.Items[i]).Checked) { if (counter == index) { ((CustomListDataItem)owner.Items[i]).Checked = false; } counter++; } } } public CustomListDataItem this[int index] { get { int counter = 0; for (int i = 0; i < owner.Items.Count; i++) { if (((CustomListDataItem)owner.Items[i]).Checked) { if (counter == index) { return (CustomListDataItem)owner.Items[i]; } counter++; } } throw new IndexOutOfRangeException(); } set { int counter = 0; for (int i = 0; i < owner.Items.Count; i++) { if (((CustomListDataItem)owner.Items[i]).Checked) { if (counter == index) { owner.Items[i] = value; } counter++; } } throw new IndexOutOfRangeException(); } } public override string ToString() { string selectedItems = String.Empty; for (int i = 0; i < this.Count; i++) { selectedItems += this[i].Text + " "; } return selectedItems; } } public class MyCollectionEnumerator : IEnumerator { int current = 0; RadMultiSelectDropDownList owner; MyDynamicCollection ownerCollection; public MyCollectionEnumerator(RadMultiSelectDropDownList owner, MyDynamicCollection ownerCollection) { this.owner = owner; this.ownerCollection = ownerCollection; } public CustomListDataItem Current { get { return (CustomListDataItem)owner.Items[current]; } } public void Dispose() { } object System.Collections.IEnumerator.Current { get { return this.Current; } } public bool MoveNext() { if (current < ownerCollection.Count - 1) { current++; return true; } return false; } public void Reset() { current = 0; } } public class RadMultiSelectDropDownList : RadDropDownList { MyDynamicCollection selectedItems; public RadMultiSelectDropDownList() { selectedItems = new MyDynamicCollection(this); } public MyDynamicCollection SelectedItems { get { return selectedItems; } } protected override void OnCreatingVisualItem(object sender, CreatingVisualListItemEventArgs args) { base.OnCreatingVisualItem(sender, args); args.VisualItem = new CustomListVisualItem(); } public override string ThemeClassName { get { return typeof(RadDropDownList).FullName; } } protected override void OnSelectedIndexChanged(object sender, int newIndex) { base.OnSelectedIndexChanged(sender, newIndex); SetText(); } internal void SetText() { try { Int32 count = 0; Boolean valid = true; try { foreach (CustomListDataItem item in this.Items) { if (item.Checked) { // this.DropDownListElement.EditableElementText += item.Text + "; "; count++; } } } catch (Exception exe) { SM.Debug("Not able to pasres:"+exe.ToString()); valid = false; } if ((valid) && (count == 0)) valid = false; String newText = String.Empty; if (valid) { //this.BeginUpdate(); //this.Text = String.Empty; foreach (CustomListDataItem item in this.Items) { if (item.Checked) { newText += item.Text + "; "; } } //this.EndUpdate(); // update text this.DropDownListElement.EditableElementText = newText; } else if (!valid && count == 0) { this.DropDownListElement.EditableElementText = newText; } } catch (Exception ex) { SM.Debug("Error on set text on combobox"); } } } public class GRPEventArgs : EventArgs { private Int32 index; private Boolean status; public GRPEventArgs(Int32 _index,Boolean _status) { index = _index; status = _status; } public Int32 idx { get { return index; } set { index = value; } } public Boolean stat { get { return status; } set { status = value; } } } public class CustomGroupHeaderCell : GridGroupContentCellElement { public static Boolean CheckBoxClicked = false; public event EventHandler GoupCheckBoxStateChanged; public RadCheckBoxElement checkbox; public CustomGroupHeaderCell(GridViewColumn column, GridRowElement row) : base(column, row) { this.DrawText = false; this.DrawFill = true; this.NumberOfColors = 1; //this.BackColor = Color.FromArgb(27, 161, 226); } protected override Type ThemeEffectiveType { get { return typeof(GridGroupContentCellElement); } } protected override void CreateChildElements() { base.CreateChildElements(); checkbox = new RadCheckBoxElement(); checkbox.MinSize = new System.Drawing.Size(5, 5); checkbox.ToggleStateChanged += new StateChangedEventHandler(checkbox_ToggleStateChanged); checkbox.Click += checkbox_Click; Children.Insert(0, checkbox); } void checkbox_Click(object sender, EventArgs e) { CheckBoxClicked = true; } protected override void SetContentCore(object value) { try { base.SetContentCore(value); if (this.RowInfo.Tag != null) this.checkbox.ToggleState = (bool)this.RowInfo.Tag ? ToggleState.On : ToggleState.Off; else this.checkbox.ToggleState = ToggleState.Indeterminate; this.checkbox.TextElement.Text = this.Text.ToUpper(); this.checkbox.TextElement.ForeColor = Color.Black; Font fontGroup = new Font( "Segoe UI", 12, FontStyle.Bold, GraphicsUnit.Pixel); this.checkbox.Font = fontGroup; } catch (Exception ex) { SM.Debug("Error on SetContentCore:"+ex.ToString()); } } private void checkbox_ToggleStateChanged(object sender, StateChangedEventArgs args) { Boolean decision = (this.checkbox.ToggleState == ToggleState.On); this.RowInfo.Tag = decision; if (GoupCheckBoxStateChanged != null) { if (CheckBoxClicked) GoupCheckBoxStateChanged(this, new GRPEventArgs(this.RowIndex, decision)); CheckBoxClicked = false; } } protected override System.Drawing.SizeF ArrangeOverride(System.Drawing.SizeF finalSize) { SizeF size = base.ArrangeOverride(finalSize); RectangleF rect = this.GetClientRectangle(finalSize); if (this.checkbox != null) { this.checkbox.Arrange(new RectangleF(30, rect.Top + (rect.Height - this.checkbox.DesiredSize.Height) / 2, this.checkbox.DesiredSize.Width, this.checkbox.DesiredSize.Height)); } return size; } } public class CallType_Drop { public int Id { get; set; } public string Name { get; set; } public Image Image { get; set; } public CallType_Drop(int id, string name, Image image) { this.Id = id; this.Name = name; this.Image = image; } } public class CallType_DropCollection : BindingList { public CallType_DropCollection() { this.Add(new CallType_Drop(0, "Private call made", global::Dispatcher.Properties.Resources.call_made_24x20)); this.Add(new CallType_Drop(1, "Group call made", global::Dispatcher.Properties.Resources.call_made_group_24x20)); this.Add(new CallType_Drop(2, "All call made", global::Dispatcher.Properties.Resources.call_made_all_24x20)); this.Add(new CallType_Drop(3, "Dispatcher call made", global::Dispatcher.Properties.Resources.remmonitor24x20)); this.Add(new CallType_Drop(4, "Private call received", global::Dispatcher.Properties.Resources.call_received_24X20)); this.Add(new CallType_Drop(5, "Group call received", global::Dispatcher.Properties.Resources.call_received_group_24x20)); this.Add(new CallType_Drop(6, "All call received", global::Dispatcher.Properties.Resources.call_received_all_24x20)); this.Add(new CallType_Drop(9, "Dispatcher call received", global::Dispatcher.Properties.Resources.remmonitor24x20)); this.Add(new CallType_Drop(7, "Remote Monitor", global::Dispatcher.Properties.Resources.remmonitor24x20)); } } public class SmsUtils { public static int GetMaxNumberOfCharacters(RADIOTYPE radioType) { switch (radioType) { case RADIOTYPE.CONECTPLUS: return 141; case RADIOTYPE.TETRA: return 171; case RADIOTYPE.MOTO: return 141; case RADIOTYPE.REPEATER_TRBO: return 141; case RADIOTYPE.ATLAS: return 141; case RADIOTYPE.HARRIS: return 141; case RADIOTYPE.HYT: return 141; case RADIOTYPE.SIMOCO: return 23; case RADIOTYPE.EXCERA: return 50; case RADIOTYPE.LINX: return 900; case RADIOTYPE.LINXB: return 900; default: return 100; } } public static int GetMaxNumberOfCharacters(int gatewayType) { switch (gatewayType) { case (int)GatewayType.Broadband: return 900; case (int)GatewayType.Tier2Radio: return 141; case (int)GatewayType.Tier3Radio: return 23; case (int)GatewayType.Unknown: return 141; default: return 100; } } } ///end code from telerik /// }