public static bool initTagPos = false;//初始化标签位置信息(随机模拟的)

        public void InitTagPositions(bool initRoles, bool initTags = false)
        {
            bool r1 = LocationAlarms.Clear(); //清空告警
            bool r2 = LocationCards.Clear();  //清空标签卡

            if (initRoles)
            {
                bool r3 = CardRoles.Clear(); //清空角色
                iniRole = new CardRoleInitializer(_bll);
                iniRole.InitData();          //初始化标签角色
            }
            var roles = GetRoles();

            if (initTags == false)
            {
                return;//正式发布时不需要模拟数据
            }
            Random r = new Random(DateTime.Now.Millisecond);

            Log.InfoStart(LogTags.DbInit, "InitTagPositions");
            List <LocationCard> tags = new List <LocationCard>();
            string startCode         = "0906";
            int    startNumber       = Convert.ToInt32(startCode, 16);

            string   CardRoleId  = ConfigurationManager.AppSettings["CardRoleId"];
            int      nCardRoleId = Convert.ToInt32(CardRoleId);
            CardRole role        = roles.Find(i => i.Id == nCardRoleId);

            if (role == null)
            {
                role = roles[nCardRoleId];        //不用作为id了
            }
            for (int i = 0; i < maxTagCount; i++) //400张卡
            {
                //if (i >= 15)
                //{
                int    number = startNumber + i;
                string code   = "0" + Convert.ToString(number, 16).ToUpper();
                //var role = roles[r.Next(roles.Count)];//随机分配角色
                var tag1 = new LocationCard()
                {
                    Name = code, Code = code, CardRoleId = role.Id
                };
                //var tag1 = new LocationCard() { Name = code, Code = code };
                tags.Add(tag1);
                //}
                //else
                //{
                //    var role = roles[r.Next(roles.Count)];//随机分配角色
                //    var tag1 = new LocationCard() { Name = "标签" + i, Code = "000" + (i + 1), CardRoleId = role.Id };
                //    tags.Add(tag1);
                //}
                //bool rr = LocationCards.Add(tag1);
            }
            LocationCards.AddRange(tags);

            //DateTime dt = DateTime.Now;
            //long TimeStamp = TimeConvert.DateTimeToTimeStamp(dt);
            //Position position1 = new Position() { Code = "002", X = -50, Y = -50, Z = -50, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position2 = new Position() { Code = "002", X = 0, Y = 0, Z = 0, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position3 = new Position() { Code = "002", X = 50, Y = 50, Z = 50, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position4 = new Position() { Code = "002", X = 100, Y = 100, Z = 100, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position5 = new Position() { Code = "002", X = 150, Y = 150, Z = 150, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position6 = new Position() { Code = "002", X = 200, Y = 200, Z = 200, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position7 = new Position() { Code = "002", X = 250, Y = 250, Z = 250, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position8 = new Position() { Code = "002", X = 300, Y = 300, Z = 300, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position9 = new Position() { Code = "002", X = 350, Y = 350, Z = 350, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position10 = new Position() { Code = "002", X = 400, Y = 400, Z = 400, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position11 = new Position() { Code = "002", X = 500, Y = 500, Z = 450, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position12 = new Position() { Code = "002", X = 600, Y = 600, Z = 500, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position13 = new Position() { Code = "002", X = 700, Y = 700, Z = 550, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position14 = new Position() { Code = "002", X = 800, Y = 800, Z = 600, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position15 = new Position() { Code = "002", X = 900, Y = 900, Z = 650, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position16 = new Position() { Code = "002", X = 1100, Y = 1100, Z = 700, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position17 = new Position() { Code = "002", X = 1200, Y = 1200, Z = 750, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position18 = new Position() { Code = "002", X = 1300, Y = 1300, Z = 800, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position19 = new Position() { Code = "002", X = 1400, Y = 1400, Z = 850, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position20 = new Position() { Code = "002", X = 1500, Y = 1500, Z = 900, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //List<Position> positions = new List<Position>() { position1, position2, position3, position4, position5, position6, position7, position8, position9, position10, position11, position12, position13, position14, position15, position16, position17, position18, position19, position20 };
            //Positions.Clear();
            //Positions.AddRange(positions);
            Log.InfoEnd("InitTagPositions");
        }
        public void InitTagPositions(bool initRoles)
        {
            LocationAlarms.Clear(); //清空告警
            LocationCards.Clear();  //清空标签卡

            if (initRoles)
            {
                CardRoles.Clear();  //清空角色
                iniRole = new CardRoleInitializer(_bll);
                iniRole.InitData(); //初始化标签角色
            }
            var roles = GetRoles();

            Random r = new Random(DateTime.Now.Millisecond);

            Log.InfoStart("InitTagPositions");
            List <LocationCard> tags = new List <LocationCard>();
            string startCode         = "0906";
            int    startNumber       = Convert.ToInt32(startCode, 16);

            for (int i = 0; i < maxTagCount; i++)//400张卡
            {
                if (i >= 15)
                {
                    int    number = startNumber + i;
                    string code   = "0" + Convert.ToString(number, 16).ToUpper();
                    //var role = roles[r.Next(roles.Count)];//随机分配角色
                    //var tag1 = new LocationCard() { Name = code, Code = code, CardRoleId = role.Id };
                    var tag1 = new LocationCard()
                    {
                        Name = code, Code = code
                    };
                    tags.Add(tag1);
                }
                else
                {
                    var role = roles[r.Next(roles.Count)];//随机分配角色
                    var tag1 = new LocationCard()
                    {
                        Name = "标签" + i, Code = "000" + (i + 1), CardRoleId = role.Id
                    };
                    tags.Add(tag1);
                }
            }
            LocationCards.AddRange(tags);

            //DateTime dt = DateTime.Now;
            //long TimeStamp = TimeConvert.DateTimeToTimeStamp(dt);
            //Position position1 = new Position() { Code = "002", X = -50, Y = -50, Z = -50, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position2 = new Position() { Code = "002", X = 0, Y = 0, Z = 0, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position3 = new Position() { Code = "002", X = 50, Y = 50, Z = 50, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position4 = new Position() { Code = "002", X = 100, Y = 100, Z = 100, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position5 = new Position() { Code = "002", X = 150, Y = 150, Z = 150, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position6 = new Position() { Code = "002", X = 200, Y = 200, Z = 200, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position7 = new Position() { Code = "002", X = 250, Y = 250, Z = 250, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position8 = new Position() { Code = "002", X = 300, Y = 300, Z = 300, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position9 = new Position() { Code = "002", X = 350, Y = 350, Z = 350, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position10 = new Position() { Code = "002", X = 400, Y = 400, Z = 400, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position11 = new Position() { Code = "002", X = 500, Y = 500, Z = 450, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position12 = new Position() { Code = "002", X = 600, Y = 600, Z = 500, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position13 = new Position() { Code = "002", X = 700, Y = 700, Z = 550, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position14 = new Position() { Code = "002", X = 800, Y = 800, Z = 600, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position15 = new Position() { Code = "002", X = 900, Y = 900, Z = 650, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:1" };
            //Position position16 = new Position() { Code = "002", X = 1100, Y = 1100, Z = 700, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position17 = new Position() { Code = "002", X = 1200, Y = 1200, Z = 750, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position18 = new Position() { Code = "002", X = 1300, Y = 1300, Z = 800, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position19 = new Position() { Code = "002", X = 1400, Y = 1400, Z = 850, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //Position position20 = new Position() { Code = "002", X = 1500, Y = 1500, Z = 900, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = 0, Flag = "0:0:0:0:0" };
            //List<Position> positions = new List<Position>() { position1, position2, position3, position4, position5, position6, position7, position8, position9, position10, position11, position12, position13, position14, position15, position16, position17, position18, position19, position20 };
            //Positions.Clear();
            //Positions.AddRange(positions);
            Log.InfoEnd("InitTagPositions");
        }