public override void Execute()
        {
            try
            {
                object state = AutomationContext.Read(memoryServiceName1, memoryItemName1);
                if (state == null || state.ToString() != "WholePalletScan") return;

                state = AutomationContext.Read(scanServiceName, scanItemName);
                if (state == null || state.ToString() == string.Empty) return;

                string barcode = state.ToString();

                state = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Scan_Request);
                state = ObjectUtil.GetObject(state);
                if (state == null || !Convert.ToBoolean(state))
                {
                    Logger.Info("当前PLC未请求扫码!");
                    return;
                }

                if (barcode == "NOREAD")
                {
                    string text = scanItemName + "号条码扫描器处理失败!详情:NOREAD!";
                    Logger.Error(text);
                    return;
                }

                if (barcode.Length == 32)
                {
                    barcode = barcode.Substring(2, 6);
                }

                if (barcode.Length != 6)
                {
                    string text = scanItemName + "号条码扫描器处理失败!详情:条码格式不正确!【" + barcode + "】";
                    Logger.Error(text);
                    return;
                }

                //弹出输入窗,获取数量;
                state = AutomationContext.Read(memoryServiceName3, memoryItemName3);
                if (state != null)
                {
                    UserLookAndFeel.Default.SetSkinStyle(state.ToString());
                }

                ScanDialog scanDialog = new ScanDialog();
                scanDialog.Text = "整盘入库手工扫码!";
                scanDialog.SetBarcode(barcode);
                if (scanDialog.ShowDialog() == DialogResult.OK)
                {
                    int[] data = new int[] { scanDialog.ProductNo, scanDialog.Quantity };
                    AutomationContext.Write(memoryServiceName2, memoryItemName2, data);
                }
                scanDialog = null;
                GC.Collect();
            }
            catch (Exception ex)
            {
                Logger.Error("WholePalletScanProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace);
            }
        }
        private void btnHandScan_Click(object sender, EventArgs e)
        {
            try
            {
                object state = AutomationContext.Read(memoryServiceName1, memoryItemName1);
                if (state == null || state.ToString() != "WholePalletScan")
                {
                    XtraMessageBox.Show("当手持扫码模式不是 [手持扫码整托盘入库]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                state = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Scan_Request);
                state = ObjectUtil.GetObject(state);
                if (state == null || !Convert.ToBoolean(state))
                {
                    XtraMessageBox.Show("当前PLC未请求扫码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                ScanDialog scanDialog = new ScanDialog();
                scanDialog.Text = "整盘入库手工扫码!";
                if (scanDialog.ShowDialog() == DialogResult.OK)
                {
                    int[] data = new int[] { scanDialog.ProductNo, scanDialog.Quantity };
                    AutomationContext.Write(memoryServiceName2, memoryItemName2, data);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(string.Format("手工扫码失败,详情原因 : {0}", ex.Message), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }