private static void SimulateTrack(long trackId, Action <TrackPoint> action = null) { System.Console.WriteLine("Start to simulateTrack."); var track = TrackDao.GetTrack(trackId); DateTime?endDate = track.EndTime; track.EndTime = null; (new TrackDao()).Update(track); var trackPointDao = new TrackPointDao(); var point = TrackPointDao.GetTrackPoints(track); foreach (var p in point) { p.IsActive = false; trackPointDao.Update(p); } TrackPoint lastp = null; foreach (var p in point) { if (lastp != null && p.GpsTime == lastp.GpsTime) { continue; } p.IsActive = true; trackPointDao.Update(p); if (action != null) { action(p); } System.Console.Write("Press any Key."); System.Console.ReadLine(); //System.Threading.Thread.Sleep(5000); System.Console.WriteLine(string.Format("write trackpoint at {0}", p.GpsTime)); lastp = p; } track.EndTime = endDate; (new TrackDao()).Update(track); System.Console.WriteLine("Finish."); }
private static void SimulateTrack(long trackId, Action <TrackPoint> action4TrackPoint = null, Action <WayPoint> action4WayPoint = null) { System.Console.WriteLine("Start to simulateTrack."); var track = TrackDao.GetTrack(trackId); DateTime?endDate = track.EndTime; track.EndTime = null; (new TrackDao()).Update(track); var trackPointDao = new TrackPointDao(); var wayPointDao = new WayPointDao(); var trackPoints = TrackPointDao.GetTrackPoints(track); foreach (var p in trackPoints) { p.IsActive = false; trackPointDao.Update(p); } var wayPoints = WayPointDao.GetWaypoints(track); foreach (var p in wayPoints) { p.IsActive = false; wayPointDao.Update(p); } int wayPointIdx = 0; TrackPoint lastp = null; foreach (var p in trackPoints) { //if (lastp != null && p.GpsTime == lastp.GpsTime) // continue; p.IsActive = true; trackPointDao.Update(p); if (action4TrackPoint != null) { action4TrackPoint(p); } if (wayPointIdx < wayPoints.Count && p.MessageTime >= wayPoints[wayPointIdx].MessageTime) { wayPoints[wayPointIdx].IsActive = true; wayPointDao.Update(wayPoints[wayPointIdx]); action4WayPoint(wayPoints[wayPointIdx]); wayPointIdx++; } System.Console.Write("Press any Key."); System.Console.ReadLine(); //System.Threading.Thread.Sleep(5000); System.Console.WriteLine(string.Format("write trackpoint at {0}", p.GpsTime)); lastp = p; } track.EndTime = endDate; (new TrackDao()).Update(track); System.Console.WriteLine("Finish."); }
//public void 更新作业监控状态1(车辆作业 车辆作业) //{ // using(IRepository rep = this.GenerateRepository()) // { // var glist = rep.List<TrackPoint>("Track = @Track ORDER BY Id DESC", new Dictionary<string, object> { { "@Track", 车辆作业.Track } }); // //var slist = rep.List<作业监控状态>("车辆作业 = @车辆作业", new Dictionary<string, object> { { "@车辆作业", 车辆作业 } }); // foreach (var gpsData in glist) // { // bool b = 更新作业监控状态(rep, 车辆作业, gpsData); // if (b) // break; // } // } //} private void 检查车辆行驶异常(IRepository rep, 作业监控状态 entity, string importantRoad, string importantAreaName, DateTime gpsTime) { // 在二期等重要地点 if (!string.IsNullOrEmpty(importantAreaName)) { return; } if (string.IsNullOrEmpty(importantRoad)) { if (entity.车辆作业.最新作业状态.异常情况 != "车辆脱离预定路线" || entity.车辆作业.最新作业状态.异常参数 != entity.车辆位置) { 作业异常Dao 作业异常Dao = new 作业异常Dao(); 作业异常Dao.新作业异常(rep, entity.车辆作业, "车辆脱离预定路线", entity.车辆位置, gpsTime); } } else { entity.车辆规划道路 = importantRoad; if (entity.车辆作业.Track.HasValue) { var track = TrackDao.GetTrack(entity.车辆作业.Track.Value); if (track.Route != null) { var nowRoute = RouteDao.GetRoute(track.Route.Name); if (nowRoute != null) { if (!string.IsNullOrEmpty(nowRoute.DirectionReal)) { var b = Feng.Utils.RouteHelper.IsInRoute(nowRoute.DirectionReal, importantRoad); if (!b) { if (entity.车辆作业.最新作业状态.异常情况 != "车辆脱离预定路线" || entity.车辆作业.最新作业状态.异常参数 != entity.车辆位置) { 作业异常Dao 作业异常Dao = new 作业异常Dao(); 作业异常Dao.新作业异常(rep, entity.车辆作业, "车辆脱离预定路线", importantRoad, gpsTime); } } } } } } // Todo //var nowDirection = DirectionDao.GetDirection(importantRoad); //if (nowDirection != null && nowDirection.Time > 0) //{ // var oldList = (rep as Feng.NH.INHibernateRepository).Session.CreateCriteria<作业监控状态>() // .Add(NHibernate.Criterion.Expression.Eq("车辆作业", entity.车辆作业)) // .Add(NHibernate.Criterion.Expression.Eq("车辆规划道路", importantRoad)) // .AddOrder(NHibernate.Criterion.Order.Asc("时间")) // .SetMaxResults(1).List<作业监控状态>(); // if (oldList.Count > 0) // { // if ((gpsTime - oldList[0].时间).TotalMinutes > nowDirection.Time) // { // if (entity.车辆作业.最新作业状态.异常情况 != "车辆运行超出预定时间" // || entity.车辆作业.最新作业状态.异常参数 != entity.车辆规划道路) // { // 作业异常Dao 作业异常Dao = new 作业异常Dao(); // 作业异常Dao.新作业异常(rep, entity.车辆作业, "车辆运行超出预定时间", entity.车辆规划道路, gpsTime); // } // } // } //} } }
public void LoadTrack(long trackId) { var track = TrackDao.GetTrack(trackId); LoadTrack(track); }