예제 #1
0
        /// <summary>
        /// 根据size随机寻找一个空闲有用的柜子
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public Box Find(Box.Size size)
        {
            try
            {
                List <Box>            boxs = new List <Box>();
                IDictionaryEnumerator enu  = BoxsDictionary.GetEnumerator();

                while (enu.MoveNext())
                {
                    Box cab = (Box)(enu.Entry.Value);

                    if (cab.IsIdle && cab.ThisSize.Equals(size) && !cab.CurrentState.Equals(Box.State.Fault))
                    {
                        boxs.Add(cab);
                    }
                }

                if (boxs.Count == 0)
                {
                    CLog4net.LogError("根据size随机寻找一个空闲有用的柜子失败:" + size.ToString());
                    return(null);
                }
                int index = new Random().Next(boxs.Count);

                return(this.BoxsDictionary[boxs[index].Code]);
            }
            catch (Exception e)
            {
                CLog4net.LogError("Box Find:" + e);
                return(null);
            }
        }
예제 #2
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);
        }
예제 #3
0
 private void FindBox(Box.Size size)
 {
     this.checkedBox = frmMain.boxsManager.Find(size);
     if (this.checkedBox == null)
     {
         frmMain.ShowSystemPromptMessage("找不到合适的箱子");
         return;
     }
     checkedInfo       = Box.Size.L;
     labelMessage.Text = "提示信息: " + checkedBox.ToString() + "号箱子";
     CLog4net.LogInfo("选取箱子:" + checkedBox.Code);
 }
예제 #4
0
 private void smallbox_Click(object sender, EventArgs e)
 {
     this.checkedBox = boxsManager.Find(Box.Size.S);
     if (this.checkedBox == null)
     {
         errMsg.Text = "找不到合适的柜子";
         return;
     }
     checkedInfo        = Box.Size.S;
     this.boxChose.Text = checkedBox.CoordinateInfo.X.ToString() + checkedBox.CoordinateInfo.Y.ToString() + "号小柜";
     CLog4net.LogInfo("选取柜门:" + checkedBox.Code);
 }
예제 #5
0
        /// <summary>
        /// 根据size随机寻找一个空闲有用的柜子
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public Box Find(Box.Size size)
        {
            #region 方法1
            //try
            //{
            //    List<Box> boxs = new List<Box>();
            //    IDictionaryEnumerator enu = BoxsDictionary.GetEnumerator();

            //    while (enu.MoveNext())
            //    {
            //        Box cab = (Box)(enu.Entry.Value);

            //        if (cab.IsIdle && cab.ThisSize.Equals(size) && !cab.CurrentState.Equals(Box.State.Fault))
            //        {
            //            boxs.Add(cab);
            //        }
            //    }

            //    if (boxs.Count == 0)
            //    {
            //        CLog4net.LogError("根据size随机寻找一个空闲有用的柜子失败:"+size.ToString());
            //        return null;
            //    }
            //    int index = new Random().Next(boxs.Count);

            //    return this.BoxsDictionary[boxs[index].Code];
            //}
            //catch (Exception e)
            //{
            //    CLog4net.LogError("Box Find:" + e);
            //    return null;
            //}
            #endregion

            #region 方法2
            try
            {
                Box box = databaseService.GetIdleBoxBySize(size);
                return(box);
            }
            catch (Exception e)
            {
                CLog4net.LogError("Box Find:" + e);
                return(null);
            }
            #endregion
        }
예제 #6
0
        public int GetIdleBoxCount(Box.Size size)
        {
            DataTable   table = null;
            LoggingData data  = new LoggingData(ip, username, password, database);

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

            if (table == null || table.Rows.Count == 0)
            {
                CLog4net.LogError("获取箱子数目失败:" + size);
                return(0);
            }

            int count = 0;

            count = Convert.ToInt32(table.Rows[0][0]);

            return(count);
        }