public static void addBeatInfoData(beatInformation b) { for (int i = beatInfos.Count - 1; i >= 0; i--) { if (beatInfos[i].ID == b.ID) { beatInfos.RemoveAt(i); } } SQL.SQLCode sql = new SQL.SQLCode(); sql.updateBeatInfos(b); beatInfos.Add(b); }
public ActionResult SaveBeat(beatInformation data) { try { using (var service = new TowTruckServiceClient()) { service.updateBeatInfoData(data); return(Json(true, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Utilities.LogError($"SaveBeat Error: {ex.Message}"); return(Json(false, JsonRequestBehavior.AllowGet)); } }
public static string findBeat(double lat, double lon) { string beatName = "NOT FOUND"; try { foreach (beatInformation bi in beatInfos) { var bsFound = from bs in BeatSegments.bsPolyList where bi.beatSegmentList.Contains(bs.segmentID) select bs; foreach (beatSegmentPolygonData bsd in bsFound) { if (lat >= bsd.minLat && lon <= bsd.maxLat && lon >= bsd.minLon && lon <= bsd.maxLat) { int i; int j = bsd.geoFence.Count - 1; for (i = 0; i < bsd.geoFence.Count; i++) { if (bsd.geoFence[i].lon < lon && bsd.geoFence[j].lon >= lon || bsd.geoFence[j].lon < lon && bsd.geoFence[i].lon >= lon) { if (bsd.geoFence[i].lat + (lon - bsd.geoFence[i].lon) / (bsd.geoFence[j].lon - bsd.geoFence[i].lon) * (bsd.geoFence[j].lat - bsd.geoFence[i].lat) < lat) { beatInformation biRet = (beatInformation)bsFound; beatName = biRet.BeatName; return(beatName); } } j = i; } } } } } catch (Exception ex) { Logging.EventLogger logger = new Logging.EventLogger(); logger.LogEvent(ex.ToString(), true); } return(beatName); }
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); } } } } } }