public void UpdateGISUnitLocations(List <GIS.UnitLocation> ull) { // Need to add a modification to this process that records when we successfully get data // and then if that date is outside of our acceptable range, we send an email. // basically, it's an addendum to the CheckNewestGISData to account for the case // where we don't get any data because the sql query doesn't return. CheckNewestGISData(UnitLocationsLastUpdated); if (ull == null || ull.Count() == 0) { return; } UnitLocationsLastUpdated = DateTime.Now; CheckNewestGISData((from u in ull select u.timestampLocal).Max()); foreach (GIS.UnitLocation ul in ull) { var dateCheck = DateTime.Now.AddMinutes(5); var now = DateTime.Now; var found = (from ut in utl where ut.imei == ul.deviceId || ut.phoneNumberNormalized == ul.deviceId select ut); int count = found.Count(); if (count == 0) { new ErrorLog("Unknown Unit Found in AVL Data", ul.deviceId.ToString(), "", "", ""); } else { if (count == 1) { UnitTracking u = found.First(); if (u.dateLastCommunicated < ul.timestampLocal) // don't update it if it's older than our current data. { u.isChanged = true; u.dateLastCommunicated = ul.timestampLocal > dateCheck ? now : ul.timestampLocal; u.dateUpdated = ul.timestampLocal > dateCheck ? now : ul.timestampLocal; u.latitude = ul.Location.Latitude; u.longitude = ul.Location.Longitude; u.ipAddress = ul.ipAddress; u.gpsSatelliteCount = ul.satelliteCount; u.direction = ul.direction; u.dataSource = "AVL"; u.velocityMPH = ul.velocityMPH; } } else // more than one row was found. { // if we hit this, we've found more than one unit with this unit's phone number/imei // we're going to ignore this data and throw an error that we can follow up on manually. new ErrorLog("Too many Unit matches Found in AVL Data", ul.deviceId.ToString(), "", "", ""); } } } }
public void UpdateTrackingData() { utl = UnitTracking.Get(); }