Ejemplo n.º 1
0
        /// <summary>
        /// 车厅设置确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (!CStaticClass.CheckPushService())
            {// 检查服务
                return;
            }

            QueryServiceClient proxy = new QueryServiceClient();
            PushServiceClient  push  = new PushServiceClient(new System.ServiceModel.InstanceContext(CStaticClass.myCallback));

            try
            {
                if (string.IsNullOrEmpty(this.CboHallWareHouse.Text) || string.IsNullOrEmpty(this.CboHallID.Text) || 0 > this.CboHallType.SelectedIndex)
                {
                    MessageBox.Show("库区,车厅设备以及车厅类型都不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                DialogResult dr = MessageBox.Show("确定修改吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

                if (dr == DialogResult.OK)
                {
                    int         nWareHouse  = CStaticClass.ConvertWareHouse(this.CboHallWareHouse.Text);
                    int         nHallID     = CStaticClass.ConvertHallDescp(nWareHouse, this.CboHallID.Text);
                    EnmHallType enmHallType = CStaticClass.ConvertHallType(this.CboHallType.Text);
                    CarLocationPanelLib.PushService.EnmFaultType type = push.SetHallType(nWareHouse, nHallID, enmHallType);

                    switch (type)
                    {
                    case CarLocationPanelLib.PushService.EnmFaultType.Success:
                    {
                        MessageBox.Show("设置车厅类型成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotFoundEquip:
                    {
                        MessageBox.Show("没有找到指定的车厅!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.WorkQueueNotEmpty:
                    {
                        MessageBox.Show("有人排队取车,不允许修改车厅类型!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.FailToUpdate:
                    {
                        MessageBox.Show("修改数据库失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.InvalidWareHouseID:
                    {
                        MessageBox.Show("无效库区号!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.FailToSendTelegram:
                    {
                        MessageBox.Show("发送报文失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.FailConnection:
                    {
                        MessageBox.Show("PLC网络连接中断,请检查网络连接再继续", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.Exception:
                    {
                        MessageBox.Show(CStaticClass.GetExceptionInfo(null), "连接异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }

                    default:
                    {
                        MessageBox.Show("设置车厅类型失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }
                    }
                }
            }
            catch (TimeoutException)
            {
                MessageBox.Show("The service operation timed out. ", "超时", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "SOAP错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (CommunicationException exception)
            {
                MessageBox.Show("There was a communication problem. " + CStaticClass.GetExceptionInfo(exception), "通信错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "应用程序异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            proxy.Close();
            push.Close();
        }