Exemplo n.º 1
0
        /// <summary>
        /// 随机获取箱子
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public Box GetIdleBoxBySize(Box.Size size)
        {
            DataTable   table = null;
            LoggingData data  = new LoggingData(ip, username, password, database);

            table = data.GetIdleBoxBySize((int)size);

            if (table == null || table.Rows.Count == 0)
            {
                CLog4net.LogError("未找到合适大小箱子:" + size);
                return(null);
            }

            Box cb = new Box();

            foreach (System.Data.DataRow d in table.Rows)
            {
                cb.Id   = Convert.ToInt32(d[TbBox.id]);
                cb.Code = Convert.ToInt32(d[TbBox.code]);
                Box.Coordinate location = new Box.Coordinate();
                location.X        = Convert.ToInt32(d[TbBox.locationX]);
                location.Y        = Convert.ToInt32(d[TbBox.locationY]);
                cb.CoordinateInfo = location;
                cb.CurrentState   = (Box.State)Convert.ToByte(d[TbBox.state]);
                cb.IsIdle         = Convert.ToBoolean(d[TbBox.idle]);
                cb.ThisSize       = (Box.Size)Convert.ToByte(d[TbBox.size]);
                cb.RemarkInfo     = Convert.ToString(d[TbBox.remark]);
            }
            return(cb);
        }