private bool InsertPostions(List <Position> list1) { //if (list1.Count < 20) return false; bool r = false; Stopwatch watch1 = new Stopwatch(); watch1.Start(); if (bll == null) { bll = GetLocationBll(); } if (ab == null) { ab = new AuthorizationBuffer(bll); } //using (var bll = GetLocationBll()) { r = bll.AddPositionsEx(list1); //todo:添加定位权限判断 if (r) { NewAlarms = ab.GetNewAlarms(list1); if (NewAlarmsFired != null) { NewAlarmsFired(NewAlarms); } //AlarmHub.SendLocationAlarms(obj.ToTModel().ToArray()); } } watch1.Stop(); WriteLogRight(GetLogText(string.Format("写入{0}条数据 End 用时:{1}", list1.Count, watch1.Elapsed))); return(r); }
private bool InsertPostions(List <Position> list1) { try { //if (list1.Count < 20) return false; bool r = false; Stopwatch watch1 = new Stopwatch(); watch1.Start(); if (bll == null) { bll = GetLocationBll(); } //using (var bll = GetLocationBll()) //用完就释放,会导致定位数据缓存被清空,无法存入历史数据库 //{ if (ab == null) { ab = AuthorizationBuffer.Instance(bll); } r = bll.AddPositionsEx(list1); //todo:添加定位权限判断 if (r) { List <Position> temp = new List <Position>(list1); //alarmPosLit = temp; alarmPosLit = new ConcurrentBag <Position>(); foreach (var item in temp) { if (alarmPosLit != null) { alarmPosLit.Add(item); } } if (LocationAlarmThread == null) { LocationAlarmThread = new Thread(LocationAlarmFunction); LocationAlarmThread.IsBackground = true; LocationAlarmThread.Start(); } //AlarmHub.SendLocationAlarms(obj.ToTModel().ToArray()); } SendNsqPos(list1); watch1.Stop(); WriteLogRight(GetLogText(string.Format("写入{0}条数据 End 用时:{1}", list1.Count, watch1.Elapsed))); if (r == false) { ErrorMessage = bll.ErrorMessage; } return(r); //} } catch (Exception ex) { Log.Error("InsertPostions", ex); return(false); } }