public Location GetLastLocation(string sTrackId) { if (string.IsNullOrEmpty(sTrackId)) return null; long trackId = Convert.ToInt64(sTrackId); IList<TrackPoint> list = null; using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { Track track = rep.Get<Track>(trackId); if (track != null) { list = rep.List<TrackPoint>("from TrackPoint g where g.Track = :Track order by g.GpsTime desc", new Dictionary<string, object> { { "Track", track }, { "MaxResults", 1 } }); } } if (list == null) return null; TrackPoint gpsData = list[0]; GMap.NET.PointLatLng p1 = new GMap.NET.PointLatLng { Lat = gpsData.Latitude, Lng = gpsData.Longitude }; GMap.NET.PointLatLng p2; lock (Feng.Map.GoogleMapChinaOffset.Instance) { p2 = Feng.Map.GoogleMapChinaOffset.Instance.GetOffseted(p1); } return new Location { Latitude = p1.Lat, Longitude = p1.Lng, Heading = gpsData.Heading, LatitudeChina = p2.Lat, LongitudeChina = p2.Lng }; }
private void OnTrackPoint(string gpsId, string gpsData) { Logger.Info(string.Format("{0} send trackPoint of {1}", gpsId, gpsData)); //vehicleName = ProcessVehicleName(vehicleName); var trackPoint = GpsService.ConvertToGpsData(gpsId, gpsData); if (!m_locks.ContainsKey(gpsId)) m_locks[gpsId] = new object(); lock (m_locks[gpsId]) { 车辆作业 selectedClzy = null; using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { try { rep.BeginTransaction(); var clzys = rep.List<车辆作业>("from 车辆作业 g where g.车载Id号 = :gpsId and Track is not null and 结束时间 is null and 开始时间 is not null order by 开始时间 desc", new Dictionary<string, object> { { "gpsId", gpsId } }); if (clzys.Count == 0) { //Logger.Warn(string.Format("{0}'s Track is null", gpsId)); //return; } else { selectedClzy = clzys[0]; var nowTrack = selectedClzy.Track; trackPoint.Track = rep.Get<Track>(nowTrack.Value); } s_trackPointDao.Save(rep, trackPoint); rep.CommitTransaction(); } catch (Exception ex) { rep.RollbackTransaction(); Logger.Error("Error " + ex.Message); } } if (selectedClzy != null) { s_zyjkDao.更新作业监控状态1(selectedClzy, trackPoint); } } }
public StringValue GetWorkerIdByTruckId(string sTruckId, string sIdx) { DisableCache(); Logger.Info(string.Format("GetWorkerIdByTruckId: {0}, {1}", sTruckId, sIdx)); int idx = 0; if (!string.IsNullOrEmpty(sIdx)) idx = Convert.ToInt32(sIdx); using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { var tracks = rep.List<Zkzx.Model.车辆作业>("from 车辆作业 g where g.车载Id号 = :gpsId and 结束时间 is null order by case when 开始时间 is null then 1 else 0 end, 开始时间, 作业号 desc", new Dictionary<string, object> { { "gpsId", sTruckId } }); if (tracks.Count > idx && idx >= 0) return new StringValue { Value = tracks[idx].ID.ToString() }; else return new StringValue { Value = string.Empty }; } }
private IList<TrackPoint> ReloadTrackLocation(long trackId) { try { using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { Track track = rep.Get<Track>(trackId); if (track != null) { var list = rep.List<TrackPoint>("from TrackPoint g where g.Track = :Track order by g.GpsTime asc", new Dictionary<string, object> { { "Track", track } }); return list; } } } catch (Exception) { } return null; }