public override void Execute()
        {
            try
            {
                int    productID = 0, quantity = 0;
                object state = AutomationContext.Read(memoryServiceName, memoryItemName);
                object obj   = ObjectUtil.GetObjects(state);
                if (obj is Array)
                {
                    Array arrayObj = (Array)obj;
                    if (arrayObj.Length == 2)
                    {
                        productID = Convert.ToInt32(arrayObj.GetValue(0));
                        quantity  = Convert.ToInt32(arrayObj.GetValue(1));
                    }
                }
                if (productID == 0 || quantity == 0)
                {
                    return;
                }

                state = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Scan_Request);
                state = ObjectUtil.GetObject(state);
                if (state == null || !Convert.ToBoolean(state))
                {
                    return;
                }

                if (!ScanManagerView.InitCigaretteScanInfoStack())
                {
                    return;
                }
                var scanInfo = CigaretteScanInfoStack
                               .Where(c => c.Value.ProductNo == productID &&
                                      c.Value.State == "0")
                               .Select(c => c.Value)
                               .FirstOrDefault();
                if (scanInfo == null)
                {
                    Logger.Info("当前整托盘入库品牌已经由件烟扫码开始进行扫码或没有扫码任务!");
                    return;
                }

                using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable))
                {
                    taskDal.TransactionScopeManager = TM;
                    int taskID = taskDal.GetTask(productID, quantity);
                    if (taskID != 0)
                    {
                        string positionName = taskDal.GetTaskNextPosition(taskID);
                        if (positionName != string.Empty)
                        {
                            int[] data = new int[] { taskID, Convert.ToInt32(positionName), 1 };
                            AutomationContext.Write(plcServiceName, O_Whole_Pallet_StockIn_Task_Info, data);
                            Thread.Sleep(sleepTime);
                            obj = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Task_Info);
                            obj = ObjectUtil.GetObjects(obj);
                            if (obj is Array)
                            {
                                Array arrayObj = (Array)obj;
                                if (arrayObj.Length == 3 &&
                                    data[0] == Convert.ToInt32(arrayObj.GetValue(0)) &&
                                    data[1] == Convert.ToInt32(arrayObj.GetValue(1)) &&
                                    data[2] == Convert.ToInt32(arrayObj.GetValue(2)))
                                {
                                    //更新任务状态为,到达当前位置;
                                    taskDal.UpdateTaskPositionStateToArrived(taskID);
                                    AutomationContext.Write(plcServiceName, O_Whole_Pallet_StockIn_Task_Info_Complete, 1);
                                    TM.Commit();
                                    scanInfo.ScanQuantity += quantity;
                                    AutomationContext.Write(memoryServiceName1, memoryItemName1, CigaretteScanInfoStack);
                                    Logger.Info(string.Format("任务号[{0}]整托盘入库成功!", taskID));
                                    return;
                                }
                            }
                        }
                    }
                    Logger.Info(string.Format("整托盘入库失败,简码:[{0}],数量: [{0}]", productID, quantity));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("WholePalletTaskRequestProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace);
            }
        }
        public override void Execute()
        {
            try
            {
                if (!ScanManagerView.InitCigaretteScanInfoStack())
                {
                    return;
                }

                object state = AutomationContext.Read(scanServiceName, scanItemName);
                if (state == null)
                {
                    return;
                }

                string barcode = state.ToString();

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

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

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

                Logger.Info(barcode);

                var info = CigaretteScanInfoStack.Values.Where(c => c.State == "3");

                if (info.Count() == 0)
                {
                    info = CigaretteScanInfoStack.Values.Where(c => c.State == "2")
                           .OrderBy(c => c.Index);
                    var item = info.FirstOrDefault();
                    if (item != null && item.Quantity - item.ScanQuantity >= 1 && item.Barcode == barcode)
                    {
                        item.ScanQuantity++;
                        item.State = "3";
                        if (item.Quantity == item.ScanQuantity)
                        {
                            item.Index = 0;
                            item.State = "4";
                            lock (CigaretteScanInfoStack)
                            {
                                CigaretteScanInfoStack.Remove(item.ProductCode);
                            }
                        }
                        AutomationContext.Write(memoryServiceName, memoryItemName, CigaretteScanInfoStack);
                        AutomationContext.Write(plcServiceName, O_Stockin_Scan_Alarm, 0);
                    }
                    else
                    {
                        string text = scanItemName + "号条码扫描器处理失败!详情:当前品牌扫码任务不存在或未轮到当前品牌扫码!";
                        Logger.Error(text);
                        AutomationContext.Write(plcServiceName, O_Stockin_Scan_Alarm, 1);
                        return;
                    }
                }
                else if (info.Count() == 1)
                {
                    var item = info.Single();
                    if (item.Quantity - item.ScanQuantity >= 1 &&
                        item.Barcode == barcode)
                    {
                        item.ScanQuantity++;
                        item.State = "3";
                        if (item.Quantity == item.ScanQuantity)
                        {
                            item.Index = 0;
                            item.State = "4";
                            lock (CigaretteScanInfoStack)
                            {
                                CigaretteScanInfoStack.Remove(item.ProductCode);
                            }
                        }
                        AutomationContext.Write(memoryServiceName, memoryItemName, CigaretteScanInfoStack);
                        AutomationContext.Write(plcServiceName, O_Stockin_Scan_Alarm, 0);
                    }
                    else
                    {
                        string text = scanItemName + "号条码扫描器处理失败!详情:当前品牌扫码任务不存在或未轮到当前品牌扫码!";
                        Logger.Error(text);
                        AutomationContext.Write(plcServiceName, O_Stockin_Scan_Alarm, 1);
                        return;
                    }
                }
                else if (info.Count() > 1)
                {
                    string text = scanItemName + "号条码扫描器处理失败!详情:当前只充许一个品牌入库扫码!";
                    Logger.Error(text);
                    AutomationContext.Write(plcServiceName, O_Stockin_Scan_Alarm, 1);
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("PiecesOfTobaccoScanProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace);
            }
        }