private void FaintAlarmFunction()
        {
            string nFaintScope        = faintAL.FaintScope;
            int    nFaintTime         = faintAL.FaintTime;
            int    nFaintIntervalTime = faintAL.FaintIntervalTime;

            nFaintIntervalTime = nFaintIntervalTime * 60 * 1000;

            List <LocationAlarm> newAlarms2 = new List <LocationAlarm>();

            while (true)
            {
                try
                {
                    //if (bll == null)
                    //{
                    //    bll = GetLocationBll();
                    //}

                    using (var bll = GetLocationBll())
                    {
                        if (ab == null)
                        {
                            ab = AuthorizationBuffer.Instance(bll);
                        }

                        Log.Info("FaintAlarm", "判断晕倒告警");
                        newAlarms2 = ab.GetFaintAlarm(nFaintScope, nFaintTime);
                        if (newAlarms2.Count <= 0)
                        {
                            Thread.Sleep(nFaintIntervalTime);
                            continue;
                        }

                        if (NewAlarmsFired != null)
                        {
                            Log.Info("FaintAlarm", "NewAlarmsFired:" + newAlarms2.Count);
                            NewAlarmsFired(newAlarms2);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("FaintAlarmThread", ex);
                }

                Thread.Sleep(nFaintIntervalTime);
            }
        }
        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);
            }
        }