public static void AckTruckMessage(Guid MessageID) { TruckMessage foundMessage = theseMessages.Find(delegate(TruckMessage myMessage) { return(myMessage.MessageID == MessageID); }); foundMessage.Acked = true; foundMessage.AckedTime = DateTime.Now; SQL.SQLCode mySQL = new SQL.SQLCode(); mySQL.AckTruckMessage(foundMessage); }
public static void AddTruckMessage(TruckMessage thisMessage) { SQL.SQLCode mySQL = new SQL.SQLCode(); TruckMessage foundMessage = theseMessages.Find(delegate(TruckMessage myMessage) { return(myMessage.MessageID == thisMessage.MessageID); }); if (foundMessage == null) { theseMessages.Add(thisMessage); mySQL.LogTruckMessage(thisMessage); } else { foundMessage = thisMessage; mySQL.LogTruckMessage(thisMessage); } }
//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); } }
private static void sendAMessage(string data) { //split the header from the message string shift = string.Empty; string[] splitter = data.Split('/'); string header = splitter[0]; string body = splitter[1]; string[] splitHead = header.Split('.'); string callSign = splitHead[1].ToString(); if (callSign.Substring(0, 1) == "A" || callSign.Substring(0, 1) == "B" || callSign.Substring(0, 1) == "*") { switch (callSign.Substring(0, 1)) { case "A": shift = "AM"; break; case "*": shift = "MID"; break; case "B": shift = "PM"; break; } callSign = callSign.Substring(1, callSign.Length - 1); } /* string msg = splitter[splitter.Length - 1].Replace(".M/", ""); string[] splitMsg = msg.Split(':'); string subject = splitMsg[1].Replace("Message:", ""); string message = splitMsg[2]; * */ TowTruck.TowTruck t; if (!string.IsNullOrEmpty(shift)) { t = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find) { return find.Driver.callSign == callSign && find.Driver.AssignedShift.ToUpper().Contains(shift); }); } else { t = DataClasses.GlobalData.currentTrucks.Find(delegate(TowTruck.TowTruck find) { return find.Driver.callSign == callSign; }); } if (t != null) { //found a truck, send it the message. TruckMessage tm = new TruckMessage(); tm.Acked = false; tm.MessageID = Guid.NewGuid(); tm.MessageText = body; tm.MessageType = 0; tm.TruckIP = t.Identifier; tm.Driver = t.Driver.LastName + ", " + t.Driver.FirstName; tm.CallSign = callSign; tm.TruckNumber = t.TruckNumber; tm.Beat = t.beatNumber; tm.UserEmail = "CHP CAD"; DataClasses.GlobalData.AddTruckMessage(tm); } }
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; }
private static void checkForDispatches() { foreach (wazeXML x in wazes) { if (x.dispatched == false) { //look for the beat by segment beatInformation bi = (from b in BeatData.Beats.beatInfos where b.beatSegmentList.Contains(x.segment) select b).FirstOrDefault(); if (bi != null) //we found a beat, find out if we have a vehicle //check to see if beat is active. Inactive beats don't get messages { if (activeBeats.Contains(bi.BeatID)) { List <truckDistance> tdList = new List <truckDistance>(); var tList = from trucks in DataClasses.GlobalData.currentTrucks where trucks.beatNumber == bi.BeatID && trucks.Status.VehicleStatus != "ON INCIDENT" select trucks; foreach (TowTruck.TowTruck t in tList) { BeatData.Haversine h = new BeatData.Haversine(); BeatData.Position pW = new BeatData.Position(); pW.Latitude = x.lat; pW.Longitude = x.lon; BeatData.Position tW = new BeatData.Position(); tW.Latitude = t.GPSPosition.Lat; tW.Longitude = t.GPSPosition.Lon; double dist = h.Distance(pW, tW, BeatData.DistanceType.Miles); truckDistance td = new truckDistance(); td.t = t; td.distance = dist; tdList.Add(td); } TowTruck.TowTruck ft = null; if (tdList.Count > 0) { tdList = tdList.OrderBy(t => t.distance).ToList <truckDistance>(); ft = tdList[0].t; } if (ft != null) { TruckMessage tm = new TruckMessage(); tm.Acked = false; tm.Beat = bi.BeatID; tm.CallSign = ft.Driver.callSign; tm.Driver = ft.Driver.LastName + ", " + ft.Driver.FirstName; tm.MessageID = Guid.NewGuid(); tm.MessageText = "You have a WAZE request for an assist. Please respond."; tm.streetInformation = x.street; tm.MessageType = 4; tm.SentTime = DateTime.Now; tm.TruckIP = ft.Identifier; tm.TruckNumber = ft.TruckNumber; tm.UserEmail = "WAZE DISPATCH"; tm.lat = x.lat; tm.lon = x.lon; tm.WazeUUID = x.uuid; tm.WazeType = x.type; tm.WazeSubType = x.subtype; DataClasses.GlobalData.theseMessages.Add(tm); x.dispatched = true; x.dispatchVehicle = ft.TruckNumber; x.dispatchedTime = DateTime.Now; SQL.SQLCode sql = new SQL.SQLCode(); sql.dispatchWaze(x); } } } } } }