Exemplo n.º 1
0
        public bool AsynUploadOutLogInfo(string picktask, string louceng, List <InventoryOutLogDetailInfo> outLogList,
                                         List <OutLogErrorRecord> errorList, List <ShippingBox> boxList, List <ShippingBoxDetail> boxdetailList,
                                         bool togAutoprint, bool BoxIsPrintMergeTag, out string errorMsg)
        {
            //满箱自动打印开关:开启时为异步操作,不需要下架成功再打印;
            //关闭时为同步操作,需下架成功再打印所有标签,下架失败需弹窗提示。
            errorMsg = "";
            OutLogDataInfo outLog = new OutLogDataInfo();

            outLog.BoxDetailList = boxdetailList != null ? new List <ShippingBoxDetail>(boxdetailList) : null;
            outLog.BoxList       = boxList != null ? new List <ShippingBox>(boxList) : null;
            outLog.ErrorList     = errorList != null ? new List <OutLogErrorRecord>(errorList) : null;
            outLog.LGNUM         = SysConfig.LGNUM;
            outLog.LOUCENG       = louceng;
            outLog.OutLogList    = outLogList != null ? new List <InventoryOutLogDetailInfo>(outLogList) : null;
            outLog.PickTask      = picktask;
            if (togAutoprint)
            {
                if (CurrentUploadQueue.Count > 99)
                {
                    errorMsg = "上传下架单序列已满失败!请检查网络环境并稍后提交。";
                    return(false);
                }
                UploadOutLogDataInfo upload = new UploadOutLogDataInfo(SysConfig.DeviceNO, outLog);
                // 加入队列,并存入数据库
                if (!LocalDataService.InsertUploadData(upload))
                {
                    errorMsg = "下架单上传云服务器失败!";
                    return(false);
                }
                else
                {
                    CurrentUploadQueue.Push(upload);
                }
            }
            else
            {
                bool isUpload = SAPDataService.UploadOutLogInfo(outLog.LGNUM, outLog.PickTask, outLog.LOUCENG,
                                                                outLog.OutLogList, outLog.ErrorList, outLog.BoxList, outLog.BoxDetailList, out errorMsg);
                if (isUpload)
                {
                    UploadSuccessOption(outLog.PickTask);
                    return(true);
                }
                else
                {
                    //上传下架单失败
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            lock (_lockObject)
            {
                if (isbusy)
                {
                    return;
                }
                else
                {
                    isbusy = true;
                }

                if (CurrentUploadQueue.Count > 0)
                {
                    if (OnUploadCount != null)
                    {
                        OnUploadCount(true);
                    }
                    // 取出任务上传
                    object o = CurrentUploadQueue.Pop();
                    if (o.GetType() == typeof(UploadOutLogDataInfo))
                    {
                        OutLogDataInfo log      = (o as UploadOutLogDataInfo).UploadData;
                        string         errorMsg = "";
                        /*判断数据类型*/
                        string zxjd_TYPE = string.Empty;
                        string seqNo     = string.Empty;
                        if (log.OutLogList != null && log.OutLogList.Count > 0)
                        {
                            zxjd_TYPE = log.OutLogList.Find(i => i.PICK_TASK == log.PickTask).ZXJD_TYPE;
                            seqNo     = log.OutLogList.Find(i => i.PICK_TASK == log.PickTask).PICK_TASK_ITEM;
                        }
                        bool isUpload = false;
                        if (zxjd_TYPE != "4")
                        {
                            isUpload = SAPDataService.UploadOutLogInfo(log.LGNUM, log.PickTask, log.LOUCENG, log.OutLogList, log.ErrorList, log.BoxList, log.BoxDetailList, out errorMsg);
                        }
                        else
                        {
                            isUpload = SAPDataService.UploadOutLogInfo_051(log.LGNUM, seqNo, log.PickTask, log.LOUCENG, log.OutLogList, log.ErrorList, log.BoxList, log.BoxDetailList, out errorMsg);
                        }
                        if (isUpload)
                        {
                            UploadSuccessOption(log.PickTask);
                            LocalDataService.DeleteUploaded((o as UploadOutLogDataInfo).Guid);  //删除已上传成功的数据
                            AudioHelper.PlayWithSystem("Resources/success.wav");
                        }
                        else
                        {
                            //(o as UploadOutLogDataInfo).RetryTimes++;
                            //上传下架单失败,记录错误信息到数据库,同时将信息再次放入队列等待下次重试,自动重试次数不超过3次
                            LocalDataService.UpdateErrorOfUploadData((o as UploadOutLogDataInfo).Guid, errorMsg);
                            //if ((o as UploadOutLogDataInfo).RetryTimes < 3)
                            //{
                            //CurrentUploadQueue.Push(o);
                            //}
                            AudioHelper.PlayWithSystem("Resources/fail.wav");
                        }
                    }
                }
                else
                {
                    if (OnUploadCount != null)
                    {
                        OnUploadCount(false);
                    }
                }
                isbusy = false;
            }
        }