Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /*
             * if (Session["Logon"] == null)
             * {
             *  Response.Redirect("Logon.aspx");
             * }
             * string logon = Session["Logon"].ToString();
             * if (logon != "true")
             * {
             *  Response.Redirect("Logon.aspx");
             * }
             * */
            if (!Page.IsPostBack)
            {
                LoadContractors();
            }
            string ip = System.Web.HttpContext.Current.Request.UserHostAddress;

            if (ip == "::1")
            {
                ip = "127.0.0.1";
            }
            lblIPAddress.Text = ip;
            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(ip);
            double            lat       = 0.0;
            double            lon       = 0.0;

            if (thisTruck != null)
            {
                lat = thisTruck.GPSPosition.Lat;
                lon = thisTruck.GPSPosition.Lon;
                //use these values in labels or boxes or something
            }
        }
Esempio n. 2
0
        private void ConstructMessage()
        {
            string msg = "<" + ddlMessages.Text + ">";

            msg += "<Id>" + MakeMsgID() + "</Id>";
            string VarName  = string.Empty;
            string VarValue = string.Empty;

            if (ddlMessages.Text == "GetVar")
            {
                VarName = ddlVarNames.Text;
                msg    += "<Name>" + VarName + "</Name>";
            }
            if (ddlMessages.Text == "SetVar")
            {
                if (string.IsNullOrEmpty(ddlVarNames.Text) || string.IsNullOrEmpty(txtVarValue.Text))
                {
                    Response.Write("No data for either var name or var value, aborting");
                    return;
                }
                VarName  = ddlVarNames.Text;
                VarValue = txtVarValue.Text;
                msg     += "<" + VarName + ">" + VarValue + "</" + VarName + ">";
            }

            msg += "</" + ddlMessages.Text + ">";
            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(ddlFTTs.SelectedValue.ToString());
            if (thisTruck != null)
            {
                thisTruck.SendMessage(msg);
            }
        }
Esempio n. 3
0
 public static void RemoveTowTruckByTruckID(string TruckNumber)
 {
     TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.TruckNumber == TruckNumber); });
     if (thisFoundTruck != null)
     {
         currentTrucks.Remove(thisFoundTruck);
     }
 }
Esempio n. 4
0
 public static void RemoveTowTruck(string _ipaddress)
 {
     TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.Identifier == _ipaddress); });
     if (thisFoundTruck != null)
     {
         currentTrucks.Remove(thisFoundTruck);
     }
 }
Esempio n. 5
0
        protected void btnStartSurvey_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRunTime.Text) || string.IsNullOrEmpty(txtStartDT.Text) || (chkDownload.Checked == false && chkUpload.Checked == false && chkPing.Checked == false))
            {
                Response.Write("No run time or start time or upload, download, and ping are unchecked");
                return;
            }
            if (!string.IsNullOrEmpty(ddlTrucks.Text))
            {
                TowTruck.TowTruck tFound = DataClasses.GlobalData.FindTowTruckByVehicleNumber(ddlTrucks.Text);
                if (tFound == null)
                {
                    Response.Write("Couldn't find truck");
                    return;
                }
                string IPAddress = tFound.Identifier;
                string msg       = string.Empty;

                string dt       = txtStartDT.Text;
                string duration = txtRunTime.Text;
                string ud       = string.Empty;
                if (chkUpload.Checked == true)
                {
                    ud += "U";
                }
                if (chkDownload.Checked == true)
                {
                    ud += "D";
                }
                if (chkPing.Checked == true)
                {
                    ud += "P";
                }
                msg = "<Survey>" + dt + "|" + duration + "|" + ud + "</Survey>";
                UDP.SendMessage sm = new UDP.SendMessage();
                sm.SendMyMessage(msg, IPAddress);
                TowTruck.SurveyTruck st         = new TowTruck.SurveyTruck();
                string[]             splitStart = txtStartDT.Text.Split(' ');
                string   startDate = splitStart[0].ToString() + " 00:00:00";
                DateTime dtEndDate = Convert.ToDateTime(txtStartDT.Text).AddMinutes(Convert.ToInt32(txtRunTime.Text));
                string   endDate   = dtEndDate.ToString();
                st.TruckNumber = ddlTrucks.Text;
                st.StartTime   = Convert.ToDateTime(txtStartDT.Text);
                st.EndTime     = dtEndDate;

                TowTruck.SurveyTruck stAdd = DataClasses.GlobalData.surveyTrucks.Find(delegate(TowTruck.SurveyTruck find) { return(find.TruckNumber == ddlTrucks.Text); });
                if (stAdd == null)
                {
                    DataClasses.GlobalData.surveyTrucks.Add(st);
                }
                else
                {
                    DataClasses.GlobalData.surveyTrucks.Remove(stAdd);
                    DataClasses.GlobalData.surveyTrucks.Add(st);
                }
                LoadTruckGrid();
            }
        }
Esempio n. 6
0
        public static string FindTowTruckStatusByID(Guid TruckID)
        {
            string CurrentStatus = "UNKNOWN";

            TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t){ return(t.Extended.FleetVehicleID == TruckID); });
            if (thisFoundTruck != null)
            {
                CurrentStatus = thisFoundTruck.Status.VehicleStatus;
            }
            return(CurrentStatus);
        }
Esempio n. 7
0
 public static TowTruck.TowTruck FindTowTruckByVehicleNumber(string _vehicleNumber)
 {
     TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.TruckNumber == _vehicleNumber); });
     if (thisFoundTruck != null)
     {
         return(thisFoundTruck);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 8
0
 public static string FindContractorByTruckNumber(string TruckNumber)
 {
     TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.TruckNumber == TruckNumber); });
     if (thisFoundTruck != null)
     {
         return(thisFoundTruck.Extended.ContractorName);
     }
     else
     {
         return("Truck Not Found");
     }
 }
Esempio n. 9
0
 public static string FindTruckNumberByID(Guid _FleetVehicleID)
 {
     TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.Extended.FleetVehicleID == _FleetVehicleID); });
     if (thisFoundTruck != null)
     {
         return(thisFoundTruck.TruckNumber);
     }
     else
     {
         return("Unknown");
     }
 }
Esempio n. 10
0
        private void driverLogoff(string truckNumber)
        {
            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruckByVehicleNumber(truckNumber);
            if (thisTruck != null)
            {
                SQL.SQLCode mySQL = new SQL.SQLCode();
                thisTruck.tts.startStatus("LogOff", thisTruck.TruckNumber, thisTruck.Driver.FirstName + " " + thisTruck.Driver.LastName,
                                          thisTruck.Driver.TowTruckCompany, thisTruck.beatNumber, thisTruck.GPSPosition.Lat, thisTruck.GPSPosition.Lon, thisTruck.runID, thisTruck.location,
                                          thisTruck.GPSPosition.Speed, thisTruck.GPSPosition.Head, thisTruck.Driver.schedule.scheduleID);
                mySQL.LogEvent(thisTruck.Driver.DriverID, "Driver Log Off");
                DataClasses.GlobalData.RemoveCover(thisTruck.TruckNumber);
                string cadMSG = "DU.";
                cadMSG += thisTruck.shiftType + "." + thisTruck.Driver.callSign;
                Global.cSender.sendMessage(cadMSG);
                mySQL.closeOutTruck(thisTruck.runID);
                thisTruck.Status.VehicleStatus   = "Waiting for Driver Login";
                thisTruck.Driver.DriverID        = new Guid("00000000-0000-0000-0000-000000000000");
                thisTruck.Driver.FSPID           = "";
                thisTruck.Driver.FirstName       = "No Driver";
                thisTruck.Driver.LastName        = "No Driver";
                thisTruck.Driver.TowTruckCompany = "No Driver";
                thisTruck.Driver.schedule        = null;
                //thisTruck.Driver.BreakStarted = Convert.ToDateTime("01/01/2001 00:00:00");

                /* OLD OCTA CODE - NOT USED IN MTC
                 * thisTruck.assignedBeat.BeatID = new Guid("00000000-0000-0000-0000-000000000000");
                 * thisTruck.assignedBeat.BeatExtent = null;
                 * thisTruck.assignedBeat.BeatNumber = "Not Assigned";
                 * thisTruck.assignedBeat.Loaded = false;
                 * */
                thisTruck.beatNumber                = "NOBEAT";
                thisTruck.Status.SpeedingTime       = Convert.ToDateTime("01/01/2001 00:00:00");
                thisTruck.Status.OutOfBoundsTime    = Convert.ToDateTime("01/01/2001 00:00:00");
                thisTruck.Status.SpeedingValue      = "0.0";
                thisTruck.Status.OutOfBoundsMessage = "Not logged on";
                thisTruck.Status.OutOfBoundsAlarm   = false;
                thisTruck.Status.SpeedingAlarm      = false;
                thisTruck.Status.StatusStarted      = DateTime.Now;
                //thisTruck.thisSchedule = null;
                thisTruck.runID = new Guid("00000000-0000-0000-0000-000000000000");
                //reset status and alarms for truck
                thisTruck.tts             = null;
                thisTruck.tta             = null;
                thisTruck.tts             = new TowTruck.TruckStatus();
                thisTruck.tta             = new TowTruck.TowTruckAlarms();
                thisTruck.wentOnPatrol    = false;
                thisTruck.rolledIn        = false;
                thisTruck.Driver.schedule = null;
                thisTruck.cadCallSign     = "NA";
                string msg = "<SetVar><Id>" + MakeMsgID() + "</Id><LoggedOn>F</LoggedOn></SetVar>";
                thisTruck.SendMessage(msg);
            }
        }
Esempio n. 11
0
        protected void btnAddNewTruck_Click(object sender, EventArgs e)
        {
            Guid ContractorID = new Guid(ddlContractors.SelectedValue);

            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(txtIPAddress.Text);
            if (thisTruck != null)
            {
                thisTruck.TruckNumber = txtTruckNumber.Text;
            }
            DataClasses.GlobalData.UpdateTowTruck(txtIPAddress.Text, thisTruck);
            SQL.SQLCode mySQL = new SQL.SQLCode();
            mySQL.FixTruckNumber(txtIPAddress.Text, txtTruckNumber.Text, ContractorID);
        }
Esempio n. 12
0
        public static bool truckAvailable(string data)
        {
            bool available = false;

            string[] splitter  = data.Split('\\');
            string[] splitData = splitter[1].Split('.');
            string   _callSign = splitData[1];
            string   shift     = string.Empty;

            if (_callSign.Substring(0, 1) == "A" || _callSign.Substring(0, 1) == "*" || _callSign.Substring(0, 1) == "B")
            {
                switch (_callSign.Substring(0, 1))
                {
                case "A":
                    shift = "AM";
                    break;

                case "B":
                    shift = "PM";
                    break;

                case "*":
                    shift = "MID";
                    break;
                }
                _callSign = _callSign.Substring(1, _callSign.Length - 1);
            }

            /*
             * if (_callSign.Substring(_callSign.Length - 1, 1) == "A" || _callSign.Substring(_callSign.Length - 1, 1) == "B")
             * {
             *  _callSign = _callSign.Substring(0, _callSign.Length - 1);
             * }
             */
            TowTruck.TowTruck truck = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find)
            {
                return(find.Driver.callSign == _callSign && find.Driver.AssignedShift.ToUpper().Contains(shift));
            });
            if (truck != null)
            {
                if (truck.Status.VehicleStatus.ToUpper() == "ENROUTE" || truck.Status.VehicleStatus.ToUpper() == "ON INCIDENT" || truck.Status.VehicleStatus.ToUpper() == "EN ROUTE")
                {
                    available = false;
                }
                else
                {
                    available = true;
                }
            }
            return(available);
        }
Esempio n. 13
0
        /*
         * public static void AssignTruckToAssist(Guid AssistID, TowTruck.TowTruck thisTruck)
         * {
         *  MiscData.Assist thisFoundAssist = Assists.Find(delegate(MiscData.Assist a) { return a.AssistID == AssistID; });
         *  if (thisFoundAssist != null)
         *  {
         *      thisFoundAssist.FleetVehicleID = thisTruck.Extended.FleetVehicleID;
         *  }
         * }
         *
         * public static void RemoveTruckFromIncident(Guid AssistID)
         * {
         *  MiscData.Assist thisFoundAssist = Assists.Find(delegate(MiscData.Assist a) { return a.AssistID == AssistID; });
         *  if (thisFoundAssist != null)
         *  {
         *      thisFoundAssist.FleetVehicleID = new Guid("00000000-0000-0000-0000-000000000000");
         *  }
         * }
         */


        #endregion

        #region " Add, remove, return incidents "

        public static void UpdateIncidentBeat(Guid _IncidentiD, Guid _FleetVehicleID)
        {
            string BeatNumber = "";

            MiscData.Incident thisFoundIncident = Incidents.Find(delegate(MiscData.Incident i) { return(i.IncidentID == _IncidentiD); });
            if (thisFoundIncident != null)
            {
                TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.Extended.FleetVehicleID == _FleetVehicleID); });
                if (thisFoundTruck != null)
                {
                    BeatNumber = thisFoundTruck.assignedBeat.BeatNumber;
                }
                thisFoundIncident.BeatNumber = BeatNumber;
            }
        }
Esempio n. 14
0
 private void queueMessage(string _message, string _ipaddr)
 {
     TowTruck.TowTruck towTruck = DataClasses.GlobalData.FindTowTruck(_ipaddr);
     if (towTruck == null)
     {
         try
         {
             towTruck = new TowTruck.TowTruck(_ipaddr);
             towTruck.TowTruckChangedEventHandler   += this.TowTruckChanged;
             towTruck.TowTruckGPSUpdateEventHandler += this.TowTruckGPSUpdated;
         }
         catch (Exception ex)
         {
             logger.LogEvent(DateTime.Now.ToString() + Environment.NewLine + "Error queueing message" + Environment.NewLine + ex.ToString(), true);
         }
     }
 }
Esempio n. 15
0
 void tmrCheck_Elapsed(object sender, ElapsedEventArgs e)
 {
     for (int i = DataClasses.GlobalData.surveyTrucks.Count - 1; i >= 0; i--)
     {
         if (DataClasses.GlobalData.surveyTrucks[i].EndTime < DateTime.Now)
         {
             //send a notification to the truck to shut down the survey, just to be sure
             TowTruck.TowTruck t = DataClasses.GlobalData.FindTowTruckByVehicleNumber(DataClasses.GlobalData.surveyTrucks[i].TruckNumber);
             if (t != null)
             {
                 string          IPAddress = t.Identifier;
                 string          cmd       = "<Survey>F</Survey>";
                 UDP.SendMessage sm        = new UDP.SendMessage();
                 sm.SendMyMessage(cmd, IPAddress);
             }
             DataClasses.GlobalData.surveyTrucks.RemoveAt(i);
         }
     }
 }
Esempio n. 16
0
        private List <TowTruck.TowTruck> getSelectedTrucks(List <string> TruckNumbers)
        {
            List <TowTruck.TowTruck> trucks = new List <TowTruck.TowTruck>();

            foreach (string s in TruckNumbers)
            {
                TowTruck.TowTruck found = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.TruckNumber == s); });
                if (found != null)
                {
                    TowTruck.TowTruck listTruck = trucks.Find(delegate(TowTruck.TowTruck t) { return(t.TruckNumber == found.TruckNumber); });
                    if (listTruck == null)
                    {
                        trucks.Add(found);
                    }
                }
            }

            return(trucks);
        }
Esempio n. 17
0
 public static void ForceDriverLogoff(Guid _DriverID)
 {
     TowTruck.TowTruck thisFoundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck t) { return(t.Driver.DriverID == _DriverID); });
     if (thisFoundTruck != null)
     {
         thisFoundTruck.Status.VehicleStatus   = "Waiting for Driver Login";
         thisFoundTruck.Driver.DriverID        = new Guid("00000000-0000-0000-0000-000000000000");
         thisFoundTruck.Driver.FSPID           = "";
         thisFoundTruck.Driver.FirstName       = "No Driver";
         thisFoundTruck.Driver.LastName        = "No Driver";
         thisFoundTruck.Driver.TowTruckCompany = "No Driver";
         //thisTruck.Driver.BreakStarted = Convert.ToDateTime("01/01/2001 00:00:00");
         thisFoundTruck.assignedBeat.BeatID     = new Guid("00000000-0000-0000-0000-000000000000");
         thisFoundTruck.assignedBeat.BeatExtent = null;
         thisFoundTruck.assignedBeat.BeatNumber = "Not Assigned";
         thisFoundTruck.assignedBeat.Loaded     = false;
         thisFoundTruck.Extended.ContractorName = "No Driver";
         thisFoundTruck.Extended.ContractorID   = new Guid("00000000-0000-0000-0000-000000000000");
     }
 }
Esempio n. 18
0
 protected void btnForceStop_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(ddlTrucks.Text))
     {
         TowTruck.TowTruck tFound = DataClasses.GlobalData.FindTowTruckByVehicleNumber(ddlTrucks.Text);
         if (tFound == null)
         {
             Response.Write("Couldn't find truck");
             return;
         }
         string          IPAddress = tFound.Identifier;
         string          cmd       = "<Survey>F</Survey>";
         UDP.SendMessage sm        = new UDP.SendMessage();
         sm.SendMyMessage(cmd, IPAddress);
         TowTruck.SurveyTruck find = DataClasses.GlobalData.surveyTrucks.Find(delegate(TowTruck.SurveyTruck get) { return(get.TruckNumber == tFound.TruckNumber); });
         if (find != null)
         {
             DataClasses.GlobalData.surveyTrucks.Remove(find);
         }
         LoadTruckGrid();
     }
 }
Esempio n. 19
0
        private void ConstructMessage()
        {
            string msg = "<" + ddlMessages.Text + ">";

            msg += "<Id>" + MakeMsgID() + "</Id>";
            if (ddlMessages.Text == "GetVar" || ddlMessages.Text == "SetVar")
            {
                string[] splitter = txtMessageVal.Text.Split('|');
                string   VarName  = splitter[0].ToString();
                string   VarValue = splitter[1].ToString();
                msg += "<" + VarName + ">" + VarValue + "</" + VarName + ">";
            }
            msg += "</" + ddlMessages.Text + ">";
            //ListItem li = ddlFTTs.SelectedItem;
            //string TruckNumber = li.Text;
            //string IP = li.Value;
            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(ddlFTTs.SelectedValue.ToString());
            if (thisTruck != null)
            {
                thisTruck.SendMessage(msg);
            }
        }
Esempio n. 20
0
 //force a message pop-up on the client
 private static void sendMessageToTruck(string data)
 {
     string[] splitBody = data.Split('.');
     string[] splitter = splitBody[2].ToString().Split('/');
     string _truckNumber = splitBody[1].ToString();
     //return bodyData;
     TowTruck.TowTruck t = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find) { return find.TruckNumber == _truckNumber; });
     if (t != null)
     {
         TruckMessage tm = new TruckMessage();
         tm.UserEmail = "CAD SYSTEM";
         tm.SentTime = DateTime.Now;
         tm.MessageID = Guid.NewGuid();
         tm.TruckIP = t.Identifier;
         tm.TruckNumber = _truckNumber;
         tm.Beat = t.beatNumber;
         tm.CallSign = t.Driver.callSign;
         tm.Driver = t.Driver.LastName + ", " + t.Driver.FirstName;
         tm.MessageText = splitter[1].ToString();
         tm.MessageType = 0;
         DataClasses.GlobalData.AddTruckMessage(tm);
     }
 }
Esempio n. 21
0
 public static void AddTowTruck(TowTruck.TowTruck thisTruck)
 {
     UDP.SendMessage msgAck = new UDP.SendMessage();
     try
     {
         TowTruck.TowTruck foundTruck = currentTrucks.Find(delegate(TowTruck.TowTruck myTruck)
         {
             return(myTruck.Identifier == thisTruck.Identifier);
         });
         lock (currentTrucks)
         {
             if (foundTruck == null)
             {
                 currentTrucks.Add(thisTruck);
             }
         }
         //ack moved to TowTruck object's update functions
         //msgAck.SendMyMessage("MsgID: " + thisTruck.GPSPosition.MessageID.ToString() + " Received");
     }
     catch (Exception ex)
     {
         string msg = "IP Address: " + thisTruck.Identifier + Environment.NewLine;
         msg += "VehicleNumber: " + thisTruck.Identifier + Environment.NewLine;
         msg += "Contractor: " + thisTruck.Extended.ContractorName + Environment.NewLine;
         msg += "VehicleStatus: " + thisTruck.Status.VehicleStatus + Environment.NewLine;
         msg += "Direction: " + thisTruck.GPSPosition.Head + Environment.NewLine;
         msg += "LastUpdate: " + thisTruck.GPSPosition.Time.ToString() + Environment.NewLine;
         msg += "BeatSegmentID: " + thisTruck.GPSPosition.BeatSegmentID + Environment.NewLine;
         msg += "Speed: " + thisTruck.GPSPosition.Speed + Environment.NewLine;
         msg += "Alarms: " + thisTruck.Status.SpeedingAlarm + Environment.NewLine;
         msg += "Lat: " + thisTruck.GPSPosition.Lat.ToString() + Environment.NewLine;
         msg += "Lon: " + thisTruck.GPSPosition.Lon.ToString() + Environment.NewLine;
         logger.LogEvent(DateTime.Now.ToString() + " Error adding/updating tow truck" + Environment.NewLine + msg + Environment.NewLine
                         + ex.ToString() + Environment.NewLine, true);
         msgAck.SendMyMessage("MsgID: " + thisTruck.GPSPosition.Id.ToString() + " Failed To Process");
     }
 }
Esempio n. 22
0
        private void UDPListenThread()
        {
            logger = new Logging.EventLogger(); //for the initial dev phase we're going to log a lot, disable this before
            //rolling out to production
            udpListener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            IPEndPoint ourEndPoint = new IPEndPoint(IPAddress.Any, 9017);
            IPEndPoint end         = new IPEndPoint(IPAddress.Any, 9017);
            EndPoint   Identifier  = (EndPoint)end;

            udpListener.Bind(ourEndPoint);

            while (true)
            {
                string message = null;;
                try
                {
                    bool fwdThisMessage = true;
                    int  length         = udpListener.ReceiveFrom(data, ref Identifier);
                    message = System.Text.Encoding.UTF8.GetString(data, 0, length);
                    string _ipaddr = ((IPEndPoint)Identifier).Address.ToString();
                    if (message.Contains("<FWD>"))
                    {
                        //it's a forwarded message, remove the <FWD> tags and find the specified IPAddress
                        //then treat it like a normal packet
                        message = message.Replace("<FWD>", "");
                        int firstLT = message.IndexOf('<');
                        _ipaddr        = message.Substring(0, firstLT);
                        message        = message.Replace(_ipaddr + "</FWD>", "");
                        fwdThisMessage = false;
                        //done, let it move on
                    }
                    //JavaScriptSerializer js = new JavaScriptSerializer();
                    TowTruck.TowTruck thisTruck;
                    thisTruck = DataClasses.GlobalData.FindTowTruck(_ipaddr);
                    string type = "";
                    try
                    {
                        if (message.Contains("<GPS>"))
                        {
                            type = "GPS";
                            if (forward == true && fwdThisMessage == true)
                            {
                                string fwdMsg = "<FWD>" + _ipaddr + "</FWD>" + message;
                                foreach (string s in OtherServers)
                                {
                                    udpSend.ForwardMessage(fwdMsg, s);
                                }
                            }
                        }
                    }
                    catch
                    { }
                    try
                    {
                        if (message.Contains("<State>"))
                        {
                            type = "State";
                            if (forward == true && fwdThisMessage == true)
                            {
                                string fwdMsg = "<FWD>" + _ipaddr + "</FWD>" + message;
                                foreach (string s in OtherServers)
                                {
                                    udpSend.ForwardMessage(fwdMsg, s);
                                }
                            }
                        }
                    }
                    catch
                    { }
                    try
                    {
                        if (message.Contains("<IPHistory>"))
                        {
                            type = "IPHistory";
                            if (forward == true && fwdThisMessage == true)
                            {
                                string fwdMsg = "<FWD>" + _ipaddr + "</FWD>" + message;
                                foreach (string s in OtherServers)
                                {
                                    udpSend.ForwardMessage(fwdMsg, s);
                                }
                            }
                        }
                    }
                    catch
                    { }

                    /*
                     * string[] splitMsg = message.Split('|');
                     * string type = splitMsg[0].ToString();
                     * string msg = splitMsg[1].ToString();
                     * */
                    TowTruck.GPS       thisGPS   = null;
                    TowTruck.State     thisState = null;
                    TowTruck.IPHistory history   = null;
                    if (type == "GPS")
                    {
                        //thisGPS = js.Deserialize<TowTruck.GPS>(msg);
                        XmlSerializer ser = new XmlSerializer(typeof(TowTruck.GPS));
                        StringReader  rdr = new StringReader(message);
                        thisGPS = (TowTruck.GPS)ser.Deserialize(rdr);
                        SqlGeographyBuilder builder = new SqlGeographyBuilder();
                        builder.SetSrid(4326);
                        builder.BeginGeography(OpenGisGeographyType.Point);
                        builder.BeginFigure(thisGPS.Lat, thisGPS.Lon);
                        builder.EndFigure();
                        builder.EndGeography();
                        thisGPS.Position = builder.ConstructedGeography;
                    }
                    else if (type == "State")
                    {
                        XmlSerializer ser = new XmlSerializer(typeof(TowTruck.State));
                        //testing, this was causing an error on parse, but couldn't find a reason why
                        message = message.Replace(" xmlns=''", "");
                        StringReader rdr = new StringReader(message);
                        thisState = (TowTruck.State)ser.Deserialize(rdr);
                    }
                    else if (type == "IPHistory")
                    {
                        XmlSerializer ser = new XmlSerializer(typeof(TowTruck.IPHistory));
                        StringReader  rdr = new StringReader(message);
                        history = (TowTruck.IPHistory)ser.Deserialize(rdr);
                    }
                    if (thisTruck != null)
                    {
                        try
                        {
                            thisTruck.LastMessage.LastMessageReceived = DateTime.Now;
                            DataClasses.GlobalData.UpdateTowTruck(_ipaddr, thisTruck);
                            //DataClasses.GlobalData.AddTowTruck(thisTruck);
                            if (string.IsNullOrEmpty(thisTruck.Extended.TruckNumber))
                            {
                                SQL.SQLCode mySQL = new SQL.SQLCode();
                                TowTruck.TowTruckExtended thisExtended = mySQL.GetExtendedData(thisTruck.Identifier);
                                thisTruck.Extended    = thisExtended;
                                thisTruck.TruckNumber = thisExtended.TruckNumber;
                            }

                            /*if (thisTruck.assignedBeat.Loaded == false)  //
                             * {
                             *  SQL.SQLCode mySQL = new SQL.SQLCode();
                             *  TowTruck.AssignedBeat thisAssignedBeat = mySQL.GetAssignedBeat(thisTruck.Extended.FleetVehicleID);
                             *  if (thisAssignedBeat != null)
                             *  {
                             *      thisTruck.assignedBeat = thisAssignedBeat;
                             *  }
                             * }*/
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            thisTruck = new TowTruck.TowTruck(_ipaddr);
                            DataClasses.GlobalData.AddTowTruck(thisTruck);
                            SQL.SQLCode mySQL = new SQL.SQLCode();
                            TowTruck.TowTruckExtended thisExtended = mySQL.GetExtendedData(thisTruck.Identifier);
                            thisTruck.Extended             = thisExtended;
                            thisTruck.TruckNumber          = thisExtended.TruckNumber;
                            thisTruck.Status.StatusStarted = DateTime.Now;
                        }
                        catch { }
                    }
                    if (type == "GPS")
                    {
                        thisTruck.UpdateGPS(thisGPS);
                        thisTruck.TowTruckGPSUpdate();
                    }
                    if (type == "State")
                    {
                        thisTruck.UpdateState(thisState);
                        thisTruck.TowTruckChanged();
                    }
                    if (type == "IPHistory")
                    {
                        if (thisTruck.State != null && string.IsNullOrEmpty(thisTruck.State.IPList))
                        {
                            thisTruck.State.IPList += history.IP;
                        }
                        else if (thisTruck.State != null && !string.IsNullOrEmpty(thisTruck.State.IPList))
                        {
                            thisTruck.State.IPList += "," + history.IP;
                        }
                    }
                    thisTruck.TTQueue.Enqueue(message);
                }
                catch (Exception ex)
                {
                    logger.LogEvent(DateTime.Now.ToString() + " Error in UDP Listening Thread" + Environment.NewLine + ex.ToString() +
                                    Environment.NewLine + "Original Message:" + Environment.NewLine + message, true);
                }
            }
        }
Esempio n. 23
0
        private void LoadTruckData()
        {
            string ip = Request.QueryString["ip"];

            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(ip);
            if (thisTruck != null)
            {
                lblTruck.Text               = thisTruck.Extended.TruckNumber;
                lblVehicleNumber.Text       = thisTruck.Extended.TruckNumber;
                lblDriverName.Text          = thisTruck.Driver.LastName + ", " + thisTruck.Driver.FirstName;
                lblContractCompanyName.Text = thisTruck.Extended.ContractorName;
                lblVehicleStatus.Text       = thisTruck.Status.VehicleStatus;
                lblStatusStarted.Text       = thisTruck.Status.StatusStarted.ToString();
                //Check for alarm status, set green or red accordingly.
                if (thisTruck.Status.SpeedingAlarm == true)
                {
                    lblSpeedingAlarm.ForeColor = System.Drawing.Color.Red;
                    lblSpeedingValue.ForeColor = System.Drawing.Color.Red;
                    lblSpeedingTime.ForeColor  = System.Drawing.Color.Red;
                }
                else
                {
                    lblSpeedingAlarm.ForeColor = System.Drawing.Color.Green;
                    lblSpeedingValue.ForeColor = System.Drawing.Color.Green;
                    lblSpeedingTime.ForeColor  = System.Drawing.Color.Green;
                }
                lblSpeedingAlarm.Text = thisTruck.Status.SpeedingAlarm.ToString();
                lblSpeedingValue.Text = thisTruck.Status.SpeedingValue.ToString();
                lblSpeedingTime.Text  = thisTruck.Status.SpeedingTime.ToString();

                if (thisTruck.Status.OutOfBoundsAlarm == true)
                {
                    lblOutOfBoundsAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblOutOfBoundsMessage.ForeColor   = System.Drawing.Color.Red;
                    lblOutOfBoundsTime.ForeColor      = System.Drawing.Color.Red;
                    lblOutOfBoundsStartTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblOutOfBoundsAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblOutOfBoundsMessage.ForeColor   = System.Drawing.Color.Green;
                    lblOutOfBoundsTime.ForeColor      = System.Drawing.Color.Green;
                    lblOutOfBoundsStartTime.ForeColor = System.Drawing.Color.Green;
                }

                lblOutOfBoundsAlarm.Text     = thisTruck.Status.OutOfBoundsAlarm.ToString();
                lblOutOfBoundsMessage.Text   = thisTruck.Status.OutOfBoundsMessage;
                lblOutOfBoundsTime.Text      = thisTruck.Status.OutOfBoundsTime.ToString();
                lblOutOfBoundsStartTime.Text = thisTruck.Status.OutOfBoundsStartTime.ToString();

                if (thisTruck.Status.LogOnAlarm == true)
                {
                    lblLogOnAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblLogOnAlarmTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblLogOnAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblLogOnAlarmTime.ForeColor = System.Drawing.Color.Green;
                }

                lblLogOnAlarm.Text         = thisTruck.Status.LogOnAlarm.ToString();
                lblLogOnAlarmTime.Text     = thisTruck.Status.LogOnAlarmTime.ToString();
                lblLogOnAlarmCleared.Text  = thisTruck.Status.LogOnAlarmCleared.ToString();
                lblLogOnAlarmExcused.Text  = thisTruck.Status.LogOnAlarmExcused.ToString();
                lblLogOnAlarmComments.Text = thisTruck.Status.LogOnAlarmComments;

                if (thisTruck.Status.RollOutAlarm == true)
                {
                    lblRollOutAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblRollOutAlarmTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblRollOutAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblRollOutAlarmTime.ForeColor = System.Drawing.Color.Green;
                }

                lblRollOutAlarm.Text         = thisTruck.Status.RollOutAlarm.ToString();
                lblRollOutAlarmTime.Text     = thisTruck.Status.RollOutAlarmTime.ToString();
                lblRollOutAlarmCleared.Text  = thisTruck.Status.RollOutAlarmCleared.ToString();
                lblRollOutAlarmExcused.Text  = thisTruck.Status.RollOutAlarmExcused.ToString();
                lblRollOutAlarmComments.Text = thisTruck.Status.RollOutAlarmComments;

                if (thisTruck.Status.OnPatrolAlarm == true)
                {
                    lblOnPatrolAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblOnPatrolAlarmTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblOnPatrolAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblOnPatrolAlarmTime.ForeColor = System.Drawing.Color.Green;
                }

                lblOnPatrolAlarm.Text         = thisTruck.Status.OnPatrolAlarm.ToString();
                lblOnPatrolAlarmTime.Text     = thisTruck.Status.OnPatrolAlarmTime.ToString();
                lblOnPatrolAlarmCleared.Text  = thisTruck.Status.OnPatrolAlarmCleared.ToString();
                lblOnPatrolAlarmExcused.Text  = thisTruck.Status.OnPatrolAlarmExcused.ToString();
                lblOnPatrolAlarmComments.Text = thisTruck.Status.OnPatrolAlarmComments;

                if (thisTruck.Status.RollInAlarm == true)
                {
                    lblRollInAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblRollInAlarmTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblRollInAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblRollInAlarmTime.ForeColor = System.Drawing.Color.Green;
                }

                lblRollInAlarm.Text         = thisTruck.Status.RollInAlarm.ToString();
                lblRollInAlarmTime.Text     = thisTruck.Status.RollInAlarmTime.ToString();
                lblRollInAlarmCleared.Text  = thisTruck.Status.RollInAlarmCleared.ToString();
                lblRollInAlarmExcused.Text  = thisTruck.Status.RollInAlarmExcused.ToString();
                lblRollInAlarmComments.Text = thisTruck.Status.RollInAlarmComments;

                if (thisTruck.Status.LogOffAlarm == true)
                {
                    lblLogOffAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblLogOffAlarmTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblLogOffAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblLogOffAlarmTime.ForeColor = System.Drawing.Color.Green;
                }

                lblLogOffAlarm.Text         = thisTruck.Status.LogOffAlarm.ToString();
                lblLogOffAlarmTime.Text     = thisTruck.Status.LogOffAlarmTime.ToString();
                lblLogOffAlarmCleared.Text  = thisTruck.Status.LogOffAlarmCleared.ToString();
                lblLogOffAlarmExcused.Text  = thisTruck.Status.LogOffAlarmExcused.ToString();
                lblLogOffAlarmComments.Text = thisTruck.Status.LogOffAlarmComments;

                if (thisTruck.Status.IncidentAlarm == true)
                {
                    lblIncidentAlarm.ForeColor     = System.Drawing.Color.Red;
                    lblIncidentAlarmTime.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblIncidentAlarm.ForeColor     = System.Drawing.Color.Green;
                    lblIncidentAlarmTime.ForeColor = System.Drawing.Color.Green;
                }

                lblIncidentAlarm.Text         = thisTruck.Status.IncidentAlarm.ToString();
                lblIncidentAlarmTime.Text     = thisTruck.Status.IncidentAlarmTime.ToString();
                lblIncidentAlarmCleared.Text  = thisTruck.Status.IncidentAlarmCleared.ToString();
                lblIncidentAlarmExcused.Text  = thisTruck.Status.IncidentAlarmExcused.ToString();
                lblIncidentAlarmComments.Text = thisTruck.Status.IncidentAlarmComments;

                if (thisTruck.Status.GPSIssueAlarm == true)
                {
                    lblGPSIssueAlarm.ForeColor = System.Drawing.Color.Red;
                    lblGPSIssueStart.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblGPSIssueAlarm.ForeColor = System.Drawing.Color.Green;
                    lblGPSIssueStart.ForeColor = System.Drawing.Color.Green;
                }

                lblGPSIssueAlarm.Text    = thisTruck.Status.GPSIssueAlarm.ToString();
                lblGPSIssueStart.Text    = thisTruck.Status.GPSIssueAlarmStart.ToString();
                lblGPSIssueCleared.Text  = thisTruck.Status.GPSIssueAlarmCleared.ToString();
                lblGPSIssueExcused.Text  = thisTruck.Status.GPSIssueAlarmExcused.ToString();
                lblGPSIssueComments.Text = thisTruck.Status.GPSIssueAlarmComments;

                if (thisTruck.Status.StationaryAlarm == true)
                {
                    lblStationaryAlarm.ForeColor = System.Drawing.Color.Red;
                    lblStationaryStart.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblStationaryAlarm.ForeColor = System.Drawing.Color.Green;
                    lblStationaryStart.ForeColor = System.Drawing.Color.Green;
                }

                lblStationaryAlarm.Text    = thisTruck.Status.StationaryAlarm.ToString();
                lblStationaryStart.Text    = thisTruck.Status.StationaryAlarmStart.ToString();
                lblStationaryCleared.Text  = thisTruck.Status.StationaryAlarmCleared.ToString();
                lblStationaryExcused.Text  = thisTruck.Status.StationaryAlarmExcused.ToString();
                lblStationaryComments.Text = thisTruck.Status.StationaryAlarmComments;
            }
        }
Esempio n. 24
0
 private void UpdateTowTruck(TowTruck.TowTruck towTruck)
 {
     towTruck.LastMessage.LastMessageReceived = DateTime.Now;
 }
Esempio n. 25
0
 public void TowTruckGPSUpdated(TowTruck.TowTruck towTruck)
 {
 }
Esempio n. 26
0
 public void TowTruckChanged(TowTruck.TowTruck towTruck)
 {
 }
Esempio n. 27
0
        private void LoadTruckData()
        {
            string ip = Request.QueryString["ip"];

            TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(ip);
            if (thisTruck != null)
            {
                lblTruck.Text               = thisTruck.Extended.TruckNumber;
                lblVehicleNumber.Text       = thisTruck.Extended.TruckNumber;
                lblDriverName.Text          = thisTruck.Driver.LastName + ", " + thisTruck.Driver.FirstName;
                lblContractCompanyName.Text = thisTruck.Extended.ContractorName;
                lblVehicleStatus.Text       = thisTruck.Status.VehicleStatus;
                lblStatusStarted.Text       = thisTruck.Status.StatusStarted.ToString();
                if (thisTruck.Driver.schedule != null)
                {
                    lblScheduleName.Text = thisTruck.Driver.schedule.ScheduleName;
                }
                else
                {
                    lblScheduleName.Text = "no schedule";
                }
                //Check for alarm status, set green or red accordingly.
                #region " Speeding Alarms **FIXED TO NEW WAY**"

                TowTruck.AlarmTimer aSpeed = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "Speeding"); });
                if (aSpeed != null)
                {
                    if (aSpeed.hasAlarm == true)
                    {
                        lblSpeedingAlarm.ForeColor = System.Drawing.Color.Red;
                        lblSpeedingValue.ForeColor = System.Drawing.Color.Red;
                        lblSpeedingTime.ForeColor  = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblSpeedingAlarm.ForeColor = System.Drawing.Color.Green;
                        lblSpeedingValue.ForeColor = System.Drawing.Color.Green;
                        lblSpeedingTime.ForeColor  = System.Drawing.Color.Green;
                    }
                    lblSpeedingAlarm.Text = aSpeed.hasAlarm.ToString();
                    lblSpeedingValue.Text = aSpeed.alarmValue;
                    //lblSpeedingValue.Text = thisTruck.GPSPosition.Speed.ToString() + " / MAX: " + thisTruck.GPSPosition.MaxSpd.ToString();
                    lblSpeedingTime.Text = aSpeed.alarmStart.ToString("hh:mm:ss");
                }
                #endregion

                #region " Out of Bounds Alarms **FIXED TO NEW WAY** "

                TowTruck.AlarmTimer aOOB = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "OffBeat"); });
                if (aOOB != null)
                {
                    if (aOOB.hasAlarm == true)
                    {
                        lblOutOfBoundsAlarm.ForeColor     = System.Drawing.Color.Red;
                        lblOutOfBoundsMessage.ForeColor   = System.Drawing.Color.Red;
                        lblOutOfBoundsTime.ForeColor      = System.Drawing.Color.Red;
                        lblOutOfBoundsStartTime.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblOutOfBoundsAlarm.ForeColor     = System.Drawing.Color.Green;
                        lblOutOfBoundsMessage.ForeColor   = System.Drawing.Color.Green;
                        lblOutOfBoundsTime.ForeColor      = System.Drawing.Color.Green;
                        lblOutOfBoundsStartTime.ForeColor = System.Drawing.Color.Green;
                    }
                }

                lblOutOfBoundsAlarm.Text     = aOOB.hasAlarm.ToString();
                lblOutOfBoundsMessage.Text   = "";
                lblOutOfBoundsTime.Text      = aOOB.getStatusMinutes().ToString();
                lblOutOfBoundsStartTime.Text = aOOB.alarmStart.ToString("hh:mm:ss");

                #endregion


                #region " Log On Alarms DEPRECATED"

                /* OLD
                 * if (thisTruck.Status.LogOnAlarm == true)
                 * {
                 *  lblLogOnAlarm.ForeColor = System.Drawing.Color.Red;
                 *  lblLogOnAlarmTime.ForeColor = System.Drawing.Color.Red;
                 * }
                 * else
                 * {
                 *  lblLogOnAlarm.ForeColor = System.Drawing.Color.Green;
                 *  lblLogOnAlarmTime.ForeColor = System.Drawing.Color.Green;
                 * }
                 *
                 * lblLogOnAlarm.Text = thisTruck.Status.LogOnAlarm.ToString();
                 * lblLogOnAlarmTime.Text = thisTruck.Status.LogOnAlarmTime.ToString();
                 * lblLogOnAlarmCleared.Text = thisTruck.Status.LogOnAlarmCleared.ToString();
                 * lblLogOnAlarmExcused.Text = thisTruck.Status.LogOnAlarmExcused.ToString();
                 * lblLogOnAlarmComments.Text = thisTruck.Status.LogOnAlarmComments;
                 */
                #endregion

                #region " Old "

                /*
                 #region " Roll Out Alarms "
                 *
                 * if (thisTruck.Status.RollOutAlarm == true)
                 * {
                 *  lblRollOutAlarm.ForeColor = System.Drawing.Color.Red;
                 *  lblRollOutAlarmTime.ForeColor = System.Drawing.Color.Red;
                 * }
                 * else
                 * {
                 *  lblRollOutAlarm.ForeColor = System.Drawing.Color.Green;
                 *  lblRollOutAlarmTime.ForeColor = System.Drawing.Color.Green;
                 * }
                 *
                 * lblRollOutAlarm.Text = thisTruck.Status.RollOutAlarm.ToString();
                 * lblRollOutAlarmTime.Text = thisTruck.Status.RollOutAlarmTime.ToString();
                 * lblRollOutAlarmCleared.Text = thisTruck.Status.RollOutAlarmCleared.ToString();
                 * lblRollOutAlarmExcused.Text = thisTruck.Status.RollOutAlarmExcused.ToString();
                 * lblRollOutAlarmComments.Text = thisTruck.Status.RollOutAlarmComments;
                 */
                #endregion

                #region " On Patrol Alarms "

                TowTruck.AlarmTimer aOP = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "LateOnPatrol"); });
                if (aOP != null)
                {
                    if (aOP.hasAlarm == true)
                    {
                        lblOnPatrolAlarm.ForeColor        = System.Drawing.Color.Red;
                        lblOnPatrolAlarmMessage.ForeColor = System.Drawing.Color.Red;
                        lblOnPatrolAlarmTime.ForeColor    = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblOnPatrolAlarm.ForeColor        = System.Drawing.Color.Green;
                        lblOnPatrolAlarmMessage.ForeColor = System.Drawing.Color.Green;
                        lblOnPatrolAlarmTime.ForeColor    = System.Drawing.Color.Green;
                    }
                    lblOnPatrolAlarm.Text        = aOP.hasAlarm.ToString();
                    lblOnPatrolAlarmTime.Text    = aOP.alarmStart.ToString("hh:mm:ss");
                    lblOnPatrolAlarmMessage.Text = aOP.alarmValue;
                    lblOnPatrolAlarmCleared.Text = aOP.alarmCleared.ToString();
                    lblOnPatrolAlarmExcused.Text = aOP.alarmExcused.ToString();
                }

                #endregion


                #region " Roll In Alarms "

                TowTruck.AlarmTimer aRI = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "EarlyOutOfService"); });
                if (aRI != null)
                {
                    if (aRI.hasAlarm == true)
                    {
                        lblRollInAlarm.ForeColor        = System.Drawing.Color.Red;
                        lblRollInAlarmTime.ForeColor    = System.Drawing.Color.Red;
                        lblRollInAlarmMessage.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblRollInAlarm.ForeColor        = System.Drawing.Color.Green;
                        lblRollInAlarmTime.ForeColor    = System.Drawing.Color.Green;
                        lblRollInAlarmMessage.ForeColor = System.Drawing.Color.Green;
                    }
                    lblRollInAlarm.Text        = aRI.hasAlarm.ToString();
                    lblRollInAlarmTime.Text    = aRI.alarmStart.ToString("hh:mm:ss");
                    lblRollInAlarmMessage.Text = aRI.alarmValue;
                    lblRollInAlarmCleared.Text = aRI.alarmCleared.ToString();
                    lblRollInAlarmExcused.Text = aRI.alarmExcused.ToString();
                }

                #endregion

                #region " Log Off Alarms "

                /*
                 * if (thisTruck.Status.LogOffAlarm == true)
                 * {
                 *  lblLogOffAlarm.ForeColor = System.Drawing.Color.Red;
                 *  lblLogOffAlarmTime.ForeColor = System.Drawing.Color.Red;
                 * }
                 * else
                 * {
                 *  lblLogOffAlarm.ForeColor = System.Drawing.Color.Green;
                 *  lblLogOffAlarmTime.ForeColor = System.Drawing.Color.Green;
                 * }
                 *
                 * lblLogOffAlarm.Text = thisTruck.Status.LogOffAlarm.ToString();
                 * lblLogOffAlarmTime.Text = thisTruck.Status.LogOffAlarmTime.ToString();
                 * lblLogOffAlarmCleared.Text = thisTruck.Status.LogOffAlarmCleared.ToString();
                 * lblLogOffAlarmExcused.Text = thisTruck.Status.LogOffAlarmExcused.ToString();
                 * lblLogOffAlarmComments.Text = thisTruck.Status.LogOffAlarmComments;
                 */
                #endregion

                #region  " Long Incident Alarms **Fixed** "

                TowTruck.AlarmTimer aLI = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "LongIncident"); });
                if (aLI != null)
                {
                    if (aLI.hasAlarm == true)
                    {
                        lblIncidentAlarm.ForeColor     = System.Drawing.Color.Red;
                        lblIncidentAlarmTime.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblIncidentAlarm.ForeColor     = System.Drawing.Color.Green;
                        lblIncidentAlarmTime.ForeColor = System.Drawing.Color.Green;
                    }
                }

                lblIncidentAlarm.Text         = aLI.hasAlarm.ToString();
                lblIncidentAlarmTime.Text     = aLI.alarmStart.ToString("hh:mm:ss");
                lblIncidentAlarmCleared.Text  = aLI.alarmCleared.ToString();
                lblIncidentAlarmExcused.Text  = aLI.alarmExcused.ToString();
                lblIncidentAlarmComments.Text = aLI.comment;

                #endregion

                #region " GPS Issue Alarms **FIXED TO NEW WAY** "

                TowTruck.AlarmTimer aGPS = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "GPSIssue"); });
                if (aGPS != null)
                {
                    if (aGPS.hasAlarm == true)
                    {
                        lblGPSIssueAlarm.ForeColor = System.Drawing.Color.Red;
                        lblGPSIssueStart.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblGPSIssueAlarm.ForeColor = System.Drawing.Color.Green;
                        lblGPSIssueStart.ForeColor = System.Drawing.Color.Green;
                    }
                }

                lblGPSIssueAlarm.Text    = aGPS.hasAlarm.ToString();
                lblGPSIssueStart.Text    = aGPS.alarmStart.ToString("hh:mm:ss");
                lblGPSIssueCleared.Text  = aGPS.alarmCleared.ToString();
                lblGPSIssueExcused.Text  = aGPS.alarmExcused.ToString();
                lblGPSIssueComments.Text = aGPS.comment;

                #endregion

                #region  " Stationary Alarms **FIXED TO NEW WAY** "
                TowTruck.AlarmTimer aStationary = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "Stationary"); });
                if (aStationary != null)
                {
                    if (aStationary.hasAlarm == true)
                    {
                        lblStationaryAlarm.ForeColor = System.Drawing.Color.Red;
                        lblStationaryStart.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblStationaryAlarm.ForeColor = System.Drawing.Color.Green;
                        lblStationaryStart.ForeColor = System.Drawing.Color.Green;
                    }
                }

                lblStationaryAlarm.Text    = aStationary.hasAlarm.ToString();
                lblStationaryStart.Text    = aStationary.alarmStart.ToString("hh:mm:ss");
                lblStationaryCleared.Text  = aStationary.alarmCleared.ToString();
                lblStationaryExcused.Text  = aStationary.alarmExcused.ToString();
                lblStationaryComments.Text = aStationary.comment;

                #endregion

                #region " Long Lunch Alarms "

                TowTruck.AlarmTimer aLongLunch = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "LongLunch"); });
                if (aLongLunch != null)
                {
                    if (aLongLunch.hasAlarm == true)
                    {
                        lblLongLunchAlarm.ForeColor    = System.Drawing.Color.Red;
                        lblLongLunchComments.ForeColor = System.Drawing.Color.Red;
                        lblLongLunchStart.ForeColor    = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblLongLunchAlarm.ForeColor    = System.Drawing.Color.Green;
                        lblLongLunchComments.ForeColor = System.Drawing.Color.Green;
                        lblLongLunchStart.ForeColor    = System.Drawing.Color.Green;
                    }
                    lblLongLunchAlarm.Text    = aLongLunch.hasAlarm.ToString();
                    lblLongLunchStart.Text    = aLongLunch.GetStartTime();
                    lblLongLunchComments.Text = aLongLunch.alarmValue;
                    lblLongLunchCleared.Text  = aLongLunch.alarmCleared.ToString();
                    lblLongLunchExcused.Text  = aLongLunch.alarmExcused.ToString();
                }

                #endregion

                #region  " Long Break Alarms "

                TowTruck.AlarmTimer aLongBreak = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "LongBreak"); });
                if (aLongBreak != null)
                {
                    if (aLongBreak.hasAlarm == true)
                    {
                        lblLongBreakAlarm.ForeColor    = System.Drawing.Color.Red;
                        lblLongBreakComments.ForeColor = System.Drawing.Color.Red;
                        lblLongBreakStart.ForeColor    = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblLongBreakAlarm.ForeColor    = System.Drawing.Color.Green;
                        lblLongBreakComments.ForeColor = System.Drawing.Color.Green;
                        lblLongBreakStart.ForeColor    = System.Drawing.Color.Green;
                    }
                    lblLongBreakAlarm.Text    = aLongBreak.hasAlarm.ToString();
                    lblLongBreakStart.Text    = aLongBreak.GetStartTime();
                    lblLongBreakComments.Text = aLongBreak.alarmValue;
                    lblLongBreakCleared.Text  = aLongBreak.alarmCleared.ToString();
                    lblLongBreakExcused.Text  = aLongBreak.alarmExcused.ToString();
                }

                #endregion

                #region " Overtime "

                TowTruck.AlarmTimer aOvertime = thisTruck.tta.truckAlarms.Find(delegate(TowTruck.AlarmTimer find) { return(find.alarmName == "OvertimeActivity"); });
                if (aOvertime != null)
                {
                    if (aOvertime.hasAlarm == true)
                    {
                        lblOvertimeAlarm.ForeColor    = System.Drawing.Color.Red;
                        lblOvertimeComments.ForeColor = System.Drawing.Color.Red;
                        lblOvertimeStart.ForeColor    = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lblOvertimeAlarm.ForeColor    = System.Drawing.Color.Green;
                        lblOvertimeComments.ForeColor = System.Drawing.Color.Green;
                        lblOvertimeStart.ForeColor    = System.Drawing.Color.Green;
                    }
                    lblOvertimeAlarm.Text    = aOvertime.hasAlarm.ToString();
                    lblOvertimeStart.Text    = aOvertime.GetStartTime();
                    lblOvertimeComments.Text = aOvertime.alarmValue;
                    lblOvertimeCleared.Text  = aOvertime.alarmCleared.ToString();
                    lblOvertimeExcused.Text  = aOvertime.alarmExcused.ToString();
                }

                #endregion
            }
        }
Esempio n. 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Logon"] == null)
            {
                Response.Redirect("Logon.aspx");
            }
            string logon = Session["Logon"].ToString();

            if (logon != "true")
            {
                Response.Redirect("Logon.aspx");
            }
            IPAddress = Request.QueryString["ip"];
            if (!string.IsNullOrEmpty(IPAddress))
            {
                TowTruck.TowTruck thisTruck = DataClasses.GlobalData.FindTowTruck(IPAddress);
                if (thisTruck != null)
                {
                    if (!string.IsNullOrEmpty(thisTruck.Driver.LastName))
                    {
                        lblDriverName.Text = thisTruck.Driver.LastName + ", " + thisTruck.Driver.FirstName;
                    }
                    else
                    {
                        lblDriverName.Text = "unknown";
                    }
                    if (!string.IsNullOrEmpty(thisTruck.Driver.FSPID))
                    {
                        lblDriverFSPID.Text = thisTruck.Driver.FSPID;
                    }
                    else
                    {
                        lblDriverFSPID.Text = "unknown";
                    }
                    if (!string.IsNullOrEmpty(thisTruck.assignedBeat.BeatNumber))
                    {
                        lblAssignedBeat.Text = thisTruck.assignedBeat.BeatNumber;
                    }
                    else
                    {
                        lblAssignedBeat.Text = "unknown";
                    }
                    if (!string.IsNullOrEmpty(thisTruck.Extended.VehicleType))
                    {
                        lblVehicleType.Text = thisTruck.Extended.VehicleType;
                    }
                    else
                    {
                        lblVehicleType.Text = "unknown";
                    }
                    if (thisTruck.Extended.VehicleYear != 0)
                    {
                        lblVehicleYear.Text = thisTruck.Extended.VehicleYear.ToString();
                    }
                    else
                    {
                        lblVehicleYear.Text = "unknown";
                    }
                    if (!string.IsNullOrEmpty(thisTruck.Extended.VehicleModel))
                    {
                        lblVehicleModel.Text = thisTruck.Extended.VehicleModel;
                    }
                    else
                    {
                        lblVehicleModel.Text = "unknown";
                    }
                    if (!string.IsNullOrEmpty(thisTruck.Extended.LicensePlate))
                    {
                        lblLicensePlate.Text = thisTruck.Extended.LicensePlate;
                    }
                    else
                    {
                        lblLicensePlate.Text = "unknown";
                    }
                    if (thisTruck.Extended.RegistrationExpireDate != null)
                    {
                        lblRegistrationExpiration.Text = thisTruck.Extended.RegistrationExpireDate.ToString();
                    }
                    else
                    {
                        lblRegistrationExpiration.Text = "unknown";
                    }
                    if (thisTruck.Extended.InsuranceExpireDate != null)
                    {
                        lblInsuranceExpiration.Text = thisTruck.Extended.InsuranceExpireDate.ToString();
                    }
                    else
                    {
                        lblRegistrationExpiration.Text = "unknown";
                    }
                    if (thisTruck.Extended.LastCHPInspection != null)
                    {
                        lblLastCHPInspection.Text = thisTruck.Extended.LastCHPInspection.ToString();
                    }
                    else
                    {
                        lblLastCHPInspection.Text = "unknown";
                    }
                    if (thisTruck.Extended.ProgramEndDate != null)
                    {
                        lblProgramEndDate.Text = thisTruck.Extended.ProgramEndDate.ToString();
                    }
                    else
                    {
                        lblProgramEndDate.Text = "unknown";
                    }
                }
            }
        }
Esempio n. 29
0
        private static string makeBodyData(string data)
        {
            string bodyData = string.Empty;
            string[] splitBody = data.Split('.');
            bodyData += "Command: " + splitBody[0] + Environment.NewLine;
            if (splitBody[0] == "US")
            {
                bodyData += "Unit Number: " + splitBody[1] + Environment.NewLine;
            }
            if (splitBody[0] == "IS")
            {
                bodyData += "Incident Status: " + splitBody[1] + Environment.NewLine;
            }
            if (splitBody[0] == "RM")
            {
                //message rejected, don't parse the rest
                bodyData = "Inbound data was rejected by CAD";
                return bodyData;
            }
            if (splitBody[0] == "SM") //I don't think this is what the CAD is sending, it should be TO (see further down)
            {
                //message to a truck
                bodyData = "SEND MESSAGE:" + Environment.NewLine;
                bodyData += "Truck Number: " + splitBody[1].ToString() + Environment.NewLine;
                string[] splitter = splitBody[2].ToString().Split('/');
                bodyData += "Message: " + splitter[1].ToString();
                string _truckNumber = splitBody[1].ToString();
                //return bodyData;
                TowTruck.TowTruck t = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find) { return find.TruckNumber == _truckNumber; });
                if (t != null)
                {
                    TruckMessage tm = new TruckMessage();
                    tm.UserEmail = "CAD SYSTEM";
                    tm.SentTime = DateTime.Now;
                    tm.MessageID = Guid.NewGuid();
                    tm.TruckIP = t.Identifier;
                    tm.TruckNumber = _truckNumber;
                    tm.Beat = t.beatNumber;
                    tm.CallSign = t.Driver.callSign;
                    tm.Driver = t.Driver.LastName + ", " + t.Driver.FirstName;
                    tm.MessageText = splitter[1].ToString();
                    tm.MessageType = 0;
                    DataClasses.GlobalData.AddTruckMessage(tm);
                    return "SENT";
                }
            }

            for (int i = 2; i < splitBody.Length; i++)
            {

                if (splitBody[i].Substring(0, 2) == "S/")
                {
                    //status component
                    string[] splitter = splitBody[i].Split('/');
                    bodyData += "Status: " + splitter[1] + Environment.NewLine;
                }
                if (splitBody[i].Substring(0, 2) == "DT")
                {
                    //date component
                    string[] splitter = splitBody[i].Split('/');
                    bodyData += "Date: " + splitter[1].Substring(0, 2) + "/" + splitter[1].Substring(2, 2) + "/" +
                        splitter[1].Substring(4, 2) + Environment.NewLine;
                }
                if (splitBody[i].Substring(0, 2) == "TM")
                {
                    //time component
                    string[] splitter = splitBody[i].Split('/');
                    bodyData += "Time: " + splitter[1].Substring(0, 2) + ":" + splitter[1].Substring(2, 2) + ":" +
                        splitter[1].Substring(4, 2) + Environment.NewLine;
                }
                if (splitBody[i].Substring(0, 2) == "II") //gives us incident number
                {
                    string[] splitter = splitBody[i].Split('/');
                    bodyData += "Incident ID: " + splitter[1].ToString();
                }
            }
            return bodyData;
        }
Esempio n. 30
0
        private static void processCADMessage(string data)
        {
            try
            {
                string bodyData = string.Empty;
                string shift = string.Empty;
                string[] splitBody = data.Split('.');
                if (splitBody[0] == "SM") //I don't think this is what the CAD actually sends for a message to a truck, it should be TO (see further down)
                {
                    sendMessageToTruck(data);
                }
                if (splitBody[0] == "US")
                {
                    //check to see if there's any incident information in the packet
                    string[] splitData = data.Split('.');

                    //int incIndex = Array.IndexOf(splitData, "II");
                    string incNumber = string.Empty;
                    if (data.Contains("II/"))
                    {
                        incNumber = Array.Find(splitData, i => i.StartsWith("II/")).ToString().Replace("II/", "");
                    }
                    if (!string.IsNullOrEmpty(incNumber))
                    {
                        string _callSign = splitData[1];

                        if (_callSign.Substring(0, 1) == "A" || _callSign.Substring(0, 1) == "*" || _callSign.Substring(0, 1) == "B")
                        {
                            switch (_callSign.Substring(0, 1))
                            {
                                case "A":
                                    shift = "AM";
                                    break;
                                case "B":
                                    shift = "PM";
                                    break;
                                case "*":
                                    shift = "MID";
                                    break;
                            }
                            _callSign = _callSign.Substring(1, _callSign.Length - 1);

                        }
                        /*
                        if (_callSign.Substring(_callSign.Length - 1, 1) == "A" || _callSign.Substring(_callSign.Length - 1, 1) == "B")
                        {
                            _callSign = _callSign.Substring(0, _callSign.Length - 1);
                        }
                        */
                        TowTruck.TowTruck truck;
                        if (!string.IsNullOrEmpty(shift))
                        {
                            truck = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find)
                            {
                                return find.Driver.callSign == _callSign && find.Driver.AssignedShift.ToUpper().Contains(shift);
                            });
                        }
                        else
                        {
                            truck = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find)
                            {
                                return find.Driver.callSign == _callSign;
                            });
                        }
                        if (truck != null)
                        {
                            //if a truck is currently on an incident or en route to an incident, reject the CAD message
                            if (truck.Status.VehicleStatus.ToUpper() == "ON INCIDENT" || truck.Status.VehicleStatus.ToUpper() == "EN ROUTE" ||
                                truck.Status.VehicleStatus.ToUpper() == "ENROUTE")
                            {
                                //TODO add reject message code
                            }
                            //Got a truck, check Incident Status
                            //incident is created when the truck enters the scene, check to see if we've got a current incidentid
                            MTCIncident i = null; //old
                            Incident iNew = null;
                            if (truck.currentIncidentID != new Guid("00000000-0000-0000-0000-000000000000"))
                            {
                                i = DataClasses.GlobalData.Incidents.Find(delegate(MTCIncident iFind) { return iFind.IncidentID == truck.currentIncidentID; });
                            }
                            if (truck.currentIncident != null) {
                                //nothing we can do, the truck is currently on incident
                                iNew = truck.currentIncident;
                                if (!string.IsNullOrEmpty(incNumber) && string.IsNullOrEmpty(truck.currentIncident.CHPLogNumber)) {
                                    truck.currentIncident.CHPLogNumber = incNumber;
                                }
                            }

                            //new incident and assist code
                            if (truck.currentIncident == null && data.Contains("ENRT")) {
                                //This is a CAD Dispatched message. 1097 means a self-dispatch message. Self
                                //dispatches are handled elsewhere but the CAD still sends a CHP Incident Log Number that we have to process
                                iNew = new Incident();
                                // this is new stuff
                                iNew.incidentID = Guid.NewGuid();
                                iNew.fromTruck = false;
                                iNew.incidentDatePosted = DateTime.Now;
                                iNew.CHPLogNumber = incNumber;
                                iNew.logID = cadMsgID;
                                iNew.userPosted = "CHP CAD";

                                truck.addIncident(iNew);
                            }
                            else if (truck.currentIncident == null && !data.Contains("ENRT")) {
                                //this is usually a response message from CAD
                                /*
                                i = new MTCIncident();
                                List<MTCAssist> assistList = new List<MTCAssist>();
                                MTCPreAssistData pad = new MTCPreAssistData();
                                i.assistList = assistList;
                                i.preAssist = pad;
                                i.preAssist.CHPLogNumber = incNumber;
                                i.Acked = true;
                                i.sentToTruck = true;
                                iNew = new Incident();
                                iNew.incidentID = cadMsgID;

                                SQL.SQLCode mySQL = new SQL.SQLCode();
                                i.IncidentID = mySQL.PostMTCIncident("CHP CAD", i.TruckNumber, "0", 0, 0.0, 0.0);
                                DataClasses.GlobalData.addIncident(i);
                                truck.currentIncidentID = i.IncidentID;
                                truck.incidentID = incNumber;
                                 */
                                iNew = new Incident();
                                iNew.incidentID = Guid.NewGuid();
                                iNew.fromTruck = false;
                                iNew.incidentDatePosted = DateTime.Now;
                                iNew.CHPLogNumber = incNumber;
                                iNew.logID = cadMsgID;
                                iNew.userPosted = "CHP CAD";
                                iNew.logID = cadMsgID;
                                truck.addIncident(iNew);
                            }

                            if (i == null && data.Contains("ENRT"))//enrt means it's a CAD dispatched message, 1097 means a self-dispatch message.  Self
                            //dispatches are handled elsewhere but the CAD still sends a CHP Incident Log Number that we have to process
                            {
                                //brand new incident
                                Guid g = Guid.NewGuid();
                                i = new MTCIncident(); //old

                                /* this is old stuff */
                                List<MTCAssist> assistList = new List<MTCAssist>();
                                MTCPreAssistData pad = new MTCPreAssistData();
                                i.IncidentID = g;
                                i.assistList = assistList;
                                i.DatePosted = DateTime.Now;
                                i.fromTruck = 0;
                                i.preAssist = pad;
                                i.preAssist.CHPLogNumber = incNumber;
                                i.UserPosted = "CHP CAD";
                                i.Acked = true;
                                i.sentToTruck = true;
                                i.IPAddr = truck.Identifier;
                                i.TruckNumber = truck.TruckNumber;
                                i.incidentComplete = false;
                                SQL.SQLCode mySQL = new SQL.SQLCode();
                                i.IncidentID = mySQL.PostMTCIncident("CHP CAD", i.TruckNumber, "0", 0, 0.0, 0.0);
                                DataClasses.GlobalData.addIncident(i);
                                truck.incidentID = incNumber;
                                truck.currentIncidentID = i.IncidentID;

                            }
                            else if (i == null && !data.Contains("ENRT")) //this is usually a response message
                            {
                                i = new MTCIncident();
                                List<MTCAssist> assistList = new List<MTCAssist>();
                                MTCPreAssistData pad = new MTCPreAssistData();
                                i.assistList = assistList;
                                i.preAssist = pad;
                                i.preAssist.CHPLogNumber = incNumber;
                                i.Acked = true;
                                i.sentToTruck = true;
                                iNew = new Incident();
                                iNew.incidentID = cadMsgID;

                                SQL.SQLCode mySQL = new SQL.SQLCode();
                                i.IncidentID = mySQL.PostMTCIncident("CHP CAD", i.TruckNumber, "0", 0, 0.0, 0.0);
                                DataClasses.GlobalData.addIncident(i);
                                truck.currentIncidentID = i.IncidentID;
                                truck.incidentID = incNumber;
                            }
                            else
                            {
                                if (i.preAssist != null)
                                {
                                    i.preAssist.CHPLogNumber = incNumber;
                                }
                            }
                        }
                    }
                    setTruckStatus(data); //if .II/x we need to create an incident and hold on to the Incident ID number from the ./II data
                }
                if (splitBody[0] == "IS") //this should just set up the incident, not create it.
                {

                    //should never have an IS message without an II first setting up the incident.  If an IS message comes through that relates to
                    //an incident that we don't have, bag it.
                    TowTruck.TowTruck t = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find) {
                        return find.currentIncident != null && find.currentIncident.CHPLogNumber == splitBody[1];
                    });
                    if (t != null) {
                        //this is the new way
                        setIncident(data);
                    }
                    MTCIncident check = DataClasses.GlobalData.Incidents.Find(delegate(MTCIncident finder) { return finder.preAssist.CHPLogNumber == splitBody[1]; });
                    if (check != null)
                    {
                        setIncident(data);
                    }
                    else
                    {
                        string[] splitter = data.Split('.');
                        string _beatData = Array.Find(splitter, b => b.StartsWith("B/")).ToString().Replace("B/", "");
                        string _callSign = string.Empty;
                        if (_beatData.Substring(0, 1) == "A" || _beatData.Substring(0, 1) == "*" || _beatData.Substring(0, 1) == "B")
                        {
                            switch (_beatData.Substring(0, 1))
                            {
                                case "A":
                                    shift = "AM";
                                    break;
                                case "*":
                                    shift = "MID";
                                    break;
                                case "B":
                                    shift = "PM";
                                    break;
                            }
                            _callSign = _beatData.Substring(1, _beatData.Length - 1);
                        }
                        else
                        {
                            _callSign = _beatData;
                        }

                        TowTruck.TowTruck truck;
                        if (!string.IsNullOrEmpty(shift))
                        {
                            truck = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find)
                            {
                                return find.Driver.callSign == _callSign && find.Driver.AssignedShift.ToUpper().Contains(shift);
                            });
                        }
                        else
                        {
                            truck = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find)
                            {
                                return find.Driver.callSign == _callSign;
                            });
                        }

                        if (truck != null)
                        {
                            MTCIncident mi = DataClasses.GlobalData.Incidents.Find(delegate(MTCIncident finder) { return
                                finder.TruckNumber == truck.TruckNumber &&
                                finder.incidentComplete == false;
                            });
                            if (mi != null)
                            {
                                int incIndex = Array.IndexOf(splitter, "IS");
                                string IncidentID = splitter[incIndex + 1];
                                truck.incidentID = IncidentID;
                                truck.currentIncident.CHPLogNumber = IncidentID;
                                //test for CAD Assigned incident id
                                string cadMSG = "US." + truck.shiftType + truck.Driver.callSign + ".S/1097.II/" + truck.currentIncident.CHPLogNumber + makeCADDate(DateTime.Now) + makeCADTime(DateTime.Now);
                                //this was removed, it doesn't appear we need it. In fact, it might be breaking things.
                                Global.cSender.sendMessage(cadMSG);
                                if (mi.preAssist != null)
                                {
                                    mi.preAssist.CHPLogNumber = IncidentID;
                                }
                                else
                                {
                                    MTCPreAssistData pad = new MTCPreAssistData();
                                    pad.CHPLogNumber = IncidentID;
                                    mi.preAssist = pad;
                                }
                            }
                        }
                    }
                }
                if (splitBody[0] == "AM")
                {
                    //message accept from CAD
                    //Don't worry about it
                }
                if (splitBody[0] == "TO")
                {
                    //this is a message from CAD to the tablet
                    sendAMessage(data);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ERROR PROCESSING INCOMING CAD MESSAGE: " + ex.Message + Environment.NewLine + data);
            }
        }