Ejemplo n.º 1
0
        private void KeepAliveThread()
        {
            int i = 0;

            try
            {
                DBPCaller.InitReplenishProcess(MyData.GetUser(), MyData.GetStationId());
            }
            catch (Exception ex)
            {
                ShowHint("InitReplenishProcess:" + ex.Message, Color.Red);
            }

            while (runFlag)
            {
                try
                {
                    DBPCaller.KeepAlive(MyData.GetStationId());
                }
                catch (Exception ex)
                {
                    Log.Error("KeepAlive:" + ex.Message);
                }

                while (runFlag)
                {
                    if (i < 30)
                    {
                        i++;
                    }
                    else
                    {
                        i = 0;
                        break;
                    }
                    Thread.Sleep(100);
                }
            }

            try
            {
                DBPCaller.DeinitProcess(MyData.GetStationId());
            }
            catch (Exception ex)
            {
                ShowHint("DeinitProcess:" + ex.Message, Color.Red);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            _dic.Clear();

            string station = "";
            string type    = "";

            foreach (object obj in tableLayoutPanel2.Controls)
            {
                //判断控件类型
                if ((obj as CheckBox) != null)  //选中
                {
                    CheckBox cb = (CheckBox)obj;
                    if (cb.Checked)
                    {
                        station = cb.Text.Replace("站点", "").Trim();
                    }
                    else
                    {
                        station = "";
                    }
                }
                else if ((obj as ComboBox) != null) //出A材
                {
                    ComboBox cbb = (ComboBox)obj;
                    if (!string.IsNullOrEmpty(station))  //站点选中
                    {
                        if (cbb.SelectedIndex == 0)
                        {
                            type = "A";
                        }
                        else
                        {
                            type = "-";
                        }

                        if (_dic.ContainsKey(station))
                        {
                            _dic[station] = type;
                        }
                        else
                        {
                            _dic.Add(station, type);
                        }

                        station = "";
                        type    = "";
                    }
                }
            }
            if (_dic.Count == 0)
            {
                MessageBox.Show("请至少选择一个出库站点!");
                return;
            }

            bool result = false;

            foreach (KeyValuePair <string, string> kv in _dic)
            {
                int cnt = GetTaskCnt(kv.Key);  //查看其他站点是否有任务正在出库
                if (cnt == -1)
                {
                    return; //异常
                }
                if (cnt > 0)
                {
                    MessageBox.Show("站点" + kv.Key + "有任务正在出库!");
                    return;
                }
                if (kv.Value.Equals("A"))
                {
                    result = true;
                    break;
                }
            }
            if (!result)
            {
                MessageBox.Show("请至少选择一个站点出A材!");
                return;
            }

            //设置其他站点状态
            foreach (KeyValuePair <string, string> kv in _dic)
            {
                try
                {
                    DBPCaller.DeinitProcess(int.Parse(kv.Key));
                    if (kv.Value.Contains("A"))
                    {
                        DBPCaller.InitPartialPickStation(MyData.GetUser(), int.Parse(kv.Key));
                    }
                    else
                    {
                        DBPCaller.InitPickProcess(MyData.GetUser(), int.Parse(kv.Key));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            //返回
            this.DialogResult = DialogResult.OK;
        }