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); } } }
//[WebMethod] public bool SendTrackPoint(string gpsId, string gpsData) { Logger.Info(string.Format("SendTrackPoint: {0}, {1}", gpsId, gpsData)); //vehicleName = ProcessVehicleName(vehicleName); var trackPoint = ConvertToGpsData(gpsId, gpsData); if (!m_locks.ContainsKey(gpsId)) m_locks[gpsId] = new object(); lock (m_locks[gpsId]) { using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { try { rep.BeginTransaction(); Track nowTrack = GetNowTrack(rep, gpsId, trackPoint.GpsTime, false); Logger.Warn(string.Format("{0}'s Track is null", gpsId)); if (nowTrack != null) { trackPoint.Track = nowTrack; SaveGpsData(rep, trackPoint); } rep.CommitTransaction(); return true; } catch (Exception ex) { rep.RollbackTransaction(); Logger.Error("Error " + ex.Message); return false; } } } }
public StringValue SendTruckState(string sWorkerId, string state) { DisableCache(); Logger.Info(string.Format("SendTruckState: {0}, {1}", sWorkerId, state)); StringValue okValue = new StringValue { Value = "Ok" }; DateTime nowDate = System.DateTime.Now; using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { try { rep.BeginTransaction(); var clzy = rep.Get<车辆作业>(new Guid(sWorkerId)); if (clzy != null && clzy.开始时间.HasValue) { if (state == "途中休息" || state == "堵车" || state == "故障处理") { 作业异常Dao 作业异常Dao = new 作业异常Dao(); 作业异常Dao.新作业异常(clzy, state, null, nowDate); } else if (state.StartsWith("动作")) { string[] sIdxs = state.Split(new char[] { '-' }); int idx = Convert.ToInt32(sIdxs[1]); int idx2 = Convert.ToInt32(sIdxs[2]); int[] taskIdx = null; string[] importantAreas = null; string[] importantTaskStatus = null; string[] importantWorkStatus = null; ModelHelper.Get任务状态(clzy.专家任务, out taskIdx, out importantAreas, out importantTaskStatus, out importantWorkStatus); if (idx >= 0 && idx < importantAreas.Length) { 作业监控Dao zyjkDao = new 作业监控Dao(); zyjkDao.更新作业监控状态2(rep, clzy, nowDate, importantAreas[idx], idx2 == 0 ? "开始" : "结束"); 动作时间数据 entity2 = new 动作时间数据(); entity2.时间 = nowDate; entity2.地点 = importantAreas[idx]; entity2.动作 = (idx2 == 0 ? "开始" : "结束") + importantWorkStatus[idx]; entity2.车辆作业 = clzy; Zkzx.Model.BaseDao<动作时间数据> dao = new Zkzx.Model.BaseDao<动作时间数据>(); dao.Save(rep, entity2); } else { okValue = null; } } else if (state.StartsWith("箱号")) { string[] sIdxs = state.Split(new char[] { '-' }); int idx = Convert.ToInt32(sIdxs[1]); int[] taskIdx = null; string[] importantAreas = null; string[] importantTaskStatus = null; string[] importantWorkStatus = null; ModelHelper.Get任务状态(clzy.专家任务, out taskIdx, out importantAreas, out importantTaskStatus, out importantWorkStatus); if (idx >= 0 && idx < importantAreas.Length && !string.IsNullOrEmpty(sIdxs[2])) { var rw = clzy.专家任务.任务[taskIdx[idx]]; rw.箱号 = sIdxs[2]; (new Zkzx.Model.任务Dao()).Update(rep, rw); } else { okValue = null; } } else if (state.StartsWith("封号")) { string[] sIdxs = state.Split(new char[] { '-' }); int idx = Convert.ToInt32(sIdxs[1]); int[] taskIdx = null; string[] importantAreas = null; string[] importantTaskStatus = null; string[] importantWorkStatus = null; ModelHelper.Get任务状态(clzy.专家任务, out taskIdx, out importantAreas, out importantTaskStatus, out importantWorkStatus); if (idx >= 0 && idx < importantAreas.Length && !string.IsNullOrEmpty(sIdxs[2])) { var rw = clzy.专家任务.任务[taskIdx[idx]]; rw.封志号 = sIdxs[2]; (new Zkzx.Model.任务Dao()).Update(rep, rw); } else { okValue = null; } } } else { okValue = null; } rep.CommitTransaction(); return okValue; } catch (Exception) { rep.RollbackTransaction(); } } return null; }
public bool SendWayPoint(string gpsId, string gpsData) { Logger.Info(string.Format("SendWayPoint: {0}, {1}", gpsId, gpsData)); //vehicleName = ProcessVehicleName(vehicleName); var wayPoint = ConvertToGpsData2(gpsId, gpsData); if (!m_locks.ContainsKey(gpsId)) m_locks[gpsId] = new object(); lock (m_locks[gpsId]) { using (Feng.IRepository rep = new Feng.NH.Repository("zkzx.model.config")) { //var tracks = GetTracksFromVehicleName(gpsId, trackPoint.GpsTime, rep); try { rep.BeginTransaction(); Track nowTrack = GetNowTrack(rep, gpsId, wayPoint.GpsTime, false); if (nowTrack != null) { wayPoint.Track = nowTrack; //wayPoint.Action = actionData; SaveGpsData(rep, wayPoint); } rep.CommitTransaction(); return true; } catch (Exception) { rep.RollbackTransaction(); return false; } } } }