コード例 #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.CboWareHouse.Text))
                {
                    MessageBox.Show("库区不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                int nWareHouse = CStaticClass.ConvertWareHouse(this.CboWareHouse.Text);

                if (this.RbtnInJog.Checked)
                {
                    DialogResult dr = MessageBox.Show("确认车辆挪移?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                    #region 车辆挪移
                    if (string.IsNullOrEmpty(this.CTxtSrcLocAddr.Text) || string.IsNullOrEmpty(this.CTxtDestLocAddr.Text))
                    {
                        MessageBox.Show("源地址、目的地址都不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    CarLocationPanelLib.PushService.EnmFaultType type = push.VehicleMove(nWareHouse, this.CTxtSrcLocAddr.Text.Trim(), this.CTxtDestLocAddr.Text.Trim());

                    switch (type)
                    {
                    case CarLocationPanelLib.PushService.EnmFaultType.Success:
                    {
                        MessageBox.Show("车辆挪移成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Close();
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotFoundEquip:
                    {
                        MessageBox.Show("没有空闲设备,分配设备失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotFoundCarPOSN:
                    {
                        MessageBox.Show("指定的源或目的车位不存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotNormalCarPOSN:
                    {
                        MessageBox.Show("源车位或目的车位不是正常车位!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.HallEquip:
                    {
                        MessageBox.Show("源车位或目的车位是车厅!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NoCarInGarage:
                    {
                        MessageBox.Show("源车位没有车!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.CarInGarage:
                    {
                        MessageBox.Show("目的车位有车!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.TaskOnICCard:
                    {
                        MessageBox.Show("目的车位的车辆正在作业!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NoICCardInfo:
                    {
                        MessageBox.Show("源车位的IC卡没有制卡!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.FixedCarPOSN:
                    {
                        MessageBox.Show("目的车位是其他车主的固定车位,临时卡或定期卡无法挪移到固定车位卡的车位上!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.OverCarInSize:
                    {
                        MessageBox.Show("目的车位尺寸无法满足源车位的车辆!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

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

                    case CarLocationPanelLib.PushService.EnmFaultType.InvalidEquipID:
                    {
                        MessageBox.Show("无效设备!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotMatch:
                    {
                        MessageBox.Show("目的车位是其他车主的固定车位!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotAvailable:
                    {
                        MessageBox.Show("设备不可接收指令!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

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

                    case CarLocationPanelLib.PushService.EnmFaultType.FailToUpdate:
                    {
                        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;
                    }
                    }
                    #endregion
                }
                else if (this.RbtnMove.Checked)
                {
                    DialogResult dr = MessageBox.Show("确认移动设备?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                    #region 移动设备
                    if (string.IsNullOrEmpty(this.CboDeviceID.Text) || string.IsNullOrEmpty(this.CTxtDestLocAddr.Text))
                    {
                        MessageBox.Show("设备、目的地址都不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    int nEquipID = CStaticClass.ConvertETVDescp(this.CboDeviceID.Text);
                    CarLocationPanelLib.PushService.EnmFaultType type = push.EquipMove(nWareHouse, nEquipID, this.CTxtDestLocAddr.Text);

                    switch (type)
                    {
                    case CarLocationPanelLib.PushService.EnmFaultType.Success:
                    {
                        MessageBox.Show("移动设备成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Close();
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotFoundEquip:
                    {
                        MessageBox.Show("没有指定设备,需要确认库区号和设备号无误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.IsNotETVEquip:
                    {
                        MessageBox.Show("要移动的设备不是ETV或TV设备!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotAutomatic:
                    {
                        MessageBox.Show("非全自动模式!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotFoundCarPOSN:
                    {
                        MessageBox.Show("无效目的地址,请选择一个有效的车位地址!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotAvailable:
                    {
                        MessageBox.Show("设备不可接收指令!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotAllowed:
                    {
                        MessageBox.Show("设备不可用!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

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

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

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

                    case CarLocationPanelLib.PushService.EnmFaultType.FailToUpdate:
                    {
                        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;
                    }
                    }
                    #endregion
                }
                else if (this.RbtnOut.Checked)
                {
                    DialogResult dr = MessageBox.Show("确认车辆出库?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                    #region 车辆出库
                    if (string.IsNullOrEmpty(this.CTxtSrcLocAddr.Text) || string.IsNullOrEmpty(this.CboHallID.Text))
                    {
                        MessageBox.Show("源地址、出库车厅都不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    CarLocationPanelLib.PushService.EnmFaultType type = push.VehicleExit(nWareHouse, this.CTxtSrcLocAddr.Text, CStaticClass.ConvertHallDescp(nWareHouse, this.CboHallID.Text).ToString());

                    switch (type)
                    {
                    case CarLocationPanelLib.PushService.EnmFaultType.Success:
                    {
                        MessageBox.Show("车辆出库成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Close();
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotFoundCarPOSN:
                    {
                        MessageBox.Show("指定的源车位不存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

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

                    case CarLocationPanelLib.PushService.EnmFaultType.IsNotHallEquip:
                    {
                        MessageBox.Show("指定的目的地址不是车厅!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.HallEnter:
                    {
                        MessageBox.Show("车厅是进车厅不允许出车!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NotAvailable:
                    {
                        MessageBox.Show("当前卡没有车存在车库!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.NoCarInGarage:
                    {
                        MessageBox.Show("车厅设备不可接收指令!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

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

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

                    case CarLocationPanelLib.PushService.EnmFaultType.TaskOnICCard:
                    case CarLocationPanelLib.PushService.EnmFaultType.Exit:
                    {
                        MessageBox.Show("正在为您出车,请稍后!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.Wait:
                    {
                        MessageBox.Show("已经将您加到取车队列,请排队等候!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

                    case CarLocationPanelLib.PushService.EnmFaultType.Add:
                    {
                        MessageBox.Show("前面有人正在取车,已经将您加到取车队列,请排队等候!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        break;
                    }

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

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

                    case CarLocationPanelLib.PushService.EnmFaultType.NotNormalCarPOSN:
                    {
                        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;
                    }
                    }
                    #endregion
                }
                else
                {
                    MessageBox.Show("请选择具体动作指令!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            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();
        }