Exemple #1
0
        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 void LocationAlarmFunction()
        {
            List <LocationAlarm> UdpAlarm  = new List <LocationAlarm>();
            List <LocationAlarm> UdpAlarm2 = new List <LocationAlarm>();

            DateTime dt = DateTime.Now;
            long     dl = Location.TModel.Tools.TimeConvert.ToStamp(DateTime.Now);


            while (true)
            {
                if (alarmPosLit != null)
                {
                    try
                    {
                        Log.Info("LocationAlarm", "判断定位告警:" + alarmPosLit.Count);
                        NewAlarms = ab.GetNewAlarms(alarmPosLit.ToList(), UdpAlarm);

                        //LocationAlarm lc = new LocationAlarm();
                        //lc.Id = 13;
                        //lc.AlarmType = LocationAlarmType.求救信号;
                        //lc.AlarmTime = DateTime.Now;
                        //lc.AlarmTimeStamp = dl;
                        //UdpAlarm.Add(lc);

                        if (UdpAlarm != null && UdpAlarm.Count > 0)
                        {
                            // Log.Info("UdpAlarm", "求救信号:"+ UdpAlarm.Count);
                            SendUdpAlarm(UdpAlarm, UdpAlarm2);

                            if (UdpAlarm2.Count == 0)
                            {
                                UdpAlarm2 = new List <LocationAlarm>(UdpAlarm);
                            }

                            UdpAlarm.Clear();
                        }
                        if (NewAlarmsFired != null)
                        {
                            if (NewAlarms != null && NewAlarms.Count != 0)
                            {
                                Log.Info("LocationAlarm", "NewAlarmsFired:" + NewAlarms.Count);
                                NewAlarmsFired(NewAlarms);
                            }
                        }
                        alarmPosLit = null;
                    }
                    catch (Exception ex)
                    {
                        Log.Error("LocationAlarmThread", ex);
                    }
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }