Пример #1
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            lock (_lockObject)
            {
                if (isbusy)
                {
                    return;
                }
                else
                {
                    isbusy = true;
                }

                if (CurrentUploadQueue.Count > 0)
                {
                    // 取出任务上传
                    object o = CurrentUploadQueue.Pop();

                    if (o.GetType() == typeof(UploadEbBoxInfo))
                    {
                        UploadEbBoxInfo box      = o as UploadEbBoxInfo;
                        bool            isUpload = SAPDataService.UploadEbBoxInfo(box.LGNUM, box.EQUIP_HLA, box.HU, box.ChangeTime, box.InventoryResult, box.ErrorMsg, box.SubUser, box.TagDetailList);
                        if (isUpload)
                        {
                            SqliteDataService.DeleteUploaded(box.Guid);  //删除已上传成功的数据
                        }
                        else
                        {
                            box.RetryTimes++;
                            if (box.RetryTimes < 3) //最多重试3次
                            {
                                CurrentUploadQueue.Push(o);
                            }
                            else
                            {
                                SqliteDataService.DeleteUploaded(box.Guid);            //删除超过3次上传失败的数据
                                LogHelper.WriteLine(JsonConvert.SerializeObject(box)); //并记录日志,防止将来还需要使用
                            }
                        }
                    }
                    else if (o.GetType() == typeof(EbBoxCheckRecordInfo))
                    {
                        EbBoxCheckRecordInfo record = o as EbBoxCheckRecordInfo;
                        LocalDataService.InsertEbCheckRecord(record, HLACommonLib.Model.ENUM.CheckType.电商收货复核);
                    }
                    else if (o.GetType() == typeof(EbBoxErrorRecordInfo))
                    {
                        EbBoxErrorRecordInfo record = o as EbBoxErrorRecordInfo;
                        LocalDataService.InsertEbBoxErrorRecord(record, HLACommonLib.Model.ENUM.CheckType.电商收货复核);
                    }
                }
                isbusy = false;
            }
        }
Пример #2
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            lock (_lockObject)
            {
                if (isbusy)
                {
                    return;
                }
                else
                {
                    isbusy = true;
                }
                try
                {
                    if (CurrentUploadQueue.Count > 0)
                    {
                        // 取出任务上传
                        object o = CurrentUploadQueue.Pop();
                        if (o.GetType() == typeof(SqliteUploadDataInfo))
                        {
                            UploadBoxInfo box    = (o as SqliteUploadDataInfo).Data;
                            SapResult     result = new SapResult();
                            //if (box.Box.RESULT == "S")
                            //{
                            result = SAPDataService.UploadPackingBox(box.LGNUM, box.Box.HU, box.EQUIP_HLA, box.Box.RESULT, box.Box.MSG, box.Box.MX, box.LOUCENG, box.SUBUSER, box.Box.Details);

                            //(box.LGNUM, box.Box.HU, box.EQUIP_HLA, box.LOUCENG, box.SUBUSER, box.Box.Details);
                            box.Box.PACKMSG    = result.MSG;
                            box.Box.PACKRESULT = result.STATUS;
                            //if (!result.SUCCESS) box.Box.RESULT = "SE";
                            //if (!result.SUCCESS && OnUploadError != null) OnUploadError();
                            //}
                            if (result.STATUS == "E")
                            {
                                box.Box.Details.Clear();
                            }
                            bool xdSaveResult = PackingBoxService.SaveBox(box.Box);
                            SqliteDataService.DeleteUploaded((o as SqliteUploadDataInfo).Guid);
                            if (OnUploaded != null)
                            {
                                OnUploaded(box.Box);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                }

                isbusy = false;
            }
        }
Пример #3
0
 /// <summary>
 /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
 /// </summary>
 public void Upload()
 {
     if (CurrentUploadQueue.Count > 0)
     {
         UploadPKBoxInfo box = null;
         lock (_lockObject)
         {
             // 取出任务上传
             box = CurrentUploadQueue.Dequeue() as UploadPKBoxInfo;
         }
         if (box != null)
         {
             SapResult sr = SAPDataService.UploadPKBoxInfo(box);
             SqliteDataService.DeleteUploaded(box.Guid);
             if (!sr.SUCCESS && box.InventoryResult)
             {
                 box.UploadMsg = sr.MSG;
                 SqliteDataService.InsertUploadData(box);
             }
         }
     }
 }
Пример #4
0
        private void btnReturn_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                if (MetroMessageBox.Show(this, "确认要清除箱记录提示?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (DataGridViewRow row in rows)
                    {
                        UploadPKBoxInfo box          = row.Tag as UploadPKBoxInfo;
                        List <string>   picktaskList = box.DeliverErrorBoxList.Select(i => i.PICK_TASK).Distinct().ToList();
                        //检查该下架单在服务器上是否已经下架
                        bool existNoOut = false;
                        if (picktaskList != null && picktaskList.Count > 0)
                        {
                            foreach (string picktask in picktaskList)
                            {
                                List <InventoryOutLogDetailInfo> list = SAPDataService.GetHLAShelvesSingleTask(SysConfig.LGNUM, picktask);

                                if (list != null && list.Count > 0)
                                {
                                    if (list[0].IsOut != 1)
                                    {
                                        existNoOut = true;
                                        break;
                                    }
                                }
                            }
                        }

                        if (existNoOut)
                        {
                            /*
                             * MetroMessageBox.Show(this, string.Format("箱号:{0},存在未下架的下架单,不允许清除该箱记录!", box.HU), "提示"
                             *          , MessageBoxButtons.OK, MessageBoxIcon.Information);
                             */

                            DialogResult result = MetroMessageBox.Show(this, string.Format("箱号:{0},存在未下架的下架单,是否还要清除?", box.HU), "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                            }
                            else
                            {
                                return;
                            }
                        }
                        if (SqliteDataService.DeleteUploaded(box.Guid))
                        {
                        }
                        else
                        {
                            MetroMessageBox.Show(this, "清除失败", "提示",
                                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }

                    initData();
                }
            }
        }