Exemplo n.º 1
0
        public void Upload(CUploadData ud)
        {
            CDianShangBox box = ud.Data as CDianShangBox;

            saveAndUpdate(box);
            addgrid(box);
        }
Exemplo n.º 2
0
        public void saveData(CDianShangBox box)
        {
            if (box == null)
            {
                return;
            }
            try
            {
                CUploadData data = saveToSqlite(box);
                //uplad to sap
                string sapRe  = "";
                string sapMsg = "";
                SAPDataService.uploadDianShangBox(box, ref sapRe, ref sapMsg);
                box.sapRe  = sapRe;
                box.sapMsg = sapMsg;

                if (sapRe == SUCCESS)
                {
                    //save to local
                    LocalDataService.saveDianShangBox(box);

                    SqliteDataService.delUploadFromSqlite(data.Guid);
                }
                else
                {
                    SqliteDataService.updateMsgToSqlite(data.Guid, sapMsg);
                }
            }
            catch (Exception ex)
            {
                Log4netHelper.LogError(ex);
            }
        }
Exemplo n.º 3
0
        public void addgrid(CDianShangBox box)
        {
            try
            {
                List <string> mats = box.tags.Select(i => i.MATNR).Distinct().ToList();
                Invoke(new Action(() =>
                {
                    foreach (var item in mats)
                    {
                        int c = box.tags.Count(i => i.MATNR == item && !i.IsAddEpc);

                        CDianShangQty qty = new CDianShangQty();
                        if (box.qty.Exists(i => i.mat == item))
                        {
                            qty = box.qty.FirstOrDefault(i => i.mat == item);
                        }
                        TagDetailInfo ti = box.tags.First(i => i.MATNR == item && !i.IsAddEpc);
                        grid.Rows.Insert(0, box.hu, ti.ZSATNR, ti.ZCOLSN, ti.ZSIZTX, c, qty.hasQty, qty.allQty, box.inventoryMsg + " " + "SAP:" + box.sapMsg);
                        if (box.inventoryRe == "E" || box.sapRe == FAILURE)
                        {
                            grid.Rows[0].DefaultCellStyle.BackColor = Color.OrangeRed;
                        }
                    }
                }));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 4
0
        /*
         * private void savingDataThreadFunc()
         * {
         *  while (true)
         *  {
         *      CUploadData upData = null;
         *      lock (savingDataLockObject)
         *      {
         *          if (savingData.Count > 0)
         *          {
         *              upData = savingData.Dequeue();
         *          }
         *      }
         *      if (upData != null)
         *      {
         *          SaveData(upData);
         *      }
         *
         *      Thread.Sleep(1000);
         *  }
         * }
         */

        public void updateBoxList(CDianShangBox curBox)
        {
            if (curBox != null && !string.IsNullOrEmpty(curBox.hu))
            {
                mCurDanBoxList.RemoveAll(i => i.doc == mJiaoJieDan.doc && i.hu == curBox.hu);
                mCurDanBoxList.Add(curBox);
            }
        }
Exemplo n.º 5
0
 public void saveRecord(CDianShangBox box)
 {
     try
     {
         LocalDataService.saveDianShangBoxRecord(box);
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 6
0
        public CUploadData saveToSqlite(CDianShangBox data)
        {
            CUploadData cu = new CUploadData();

            cu.Guid       = Guid.NewGuid().ToString();
            cu.IsUpload   = 0;
            cu.Data       = data;
            cu.CreateTime = DateTime.Now;
            SqliteDataService.saveToSqlite(cu);
            return(cu);
        }
Exemplo n.º 7
0
        public void saveAndUpdate(CDianShangBox box)
        {
            if (box == null)
            {
                return;
            }

            saveData(box);

            if (box.inventoryRe == "S" && box.sapRe == SUCCESS)
            {
                updateBoxList(box);
                updateHuCount();
            }
        }
Exemplo n.º 8
0
        public override void StopInventory()
        {
            if (isInventory)
            {
                Invoke(new Action(() => {
                    label11_status.Text = "停止扫描";
                }));
                isInventory = false;
                reader.StopInventory();

                List <CDianShangQty> qty         = new List <CDianShangQty>();
                CheckResult          checkResult = check(label17_currentHu.Text, out qty);

                if (checkResult.InventoryResult)
                {
                    checkResult.UpdateMessage(Consts.Default.RIGHT);
                }

                Invoke(new Action(() => {
                    lblInventoryRe.Text = checkResult.InventoryResult ? "正常" : "异常";
                }));

                CDianShangBox curBox = getCurBox(checkResult, qty);

                saveRecord(curBox);

                if (checkResult.InventoryResult)
                {
                    PrintRightTag(getTags(), label17_currentHu.Text);
                    //上传
                    saveAndUpdate(curBox);
                }

                //add grid
                addgrid(curBox);

                playSound(curBox.inventoryRe == "S" && curBox.sapRe == SUCCESS);

                if (checkResult.InventoryResult)
                {
                    SetInventoryResult(1);
                }
                else
                {
                    SetInventoryResult(1);
                }
            }
        }
Exemplo n.º 9
0
        private void initData()
        {
            Invoke(new Action(() => {
                grid.Rows.Clear();

                List <CUploadData> list = SqliteDataService.GetExpUploadFromSqlite <CDianShangBox>();
                if (list != null && list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        CDianShangBox ju = item.Data as CDianShangBox;
                        if (ju != null)
                        {
                            grid.Rows.Insert(0, false, ju.hu, item.MSG);
                            grid.Rows[0].Tag = item;
                        }
                    }
                }
            }));
        }
Exemplo n.º 10
0
        CDianShangBox getCurBox(CheckResult cr)
        {
            CDianShangBox re = new CDianShangBox();

            try
            {
                re.doc  = mJiaoJieDan.doc;
                re.hu   = label17_currentHu.Text;
                re.tags = tagDetailList.ToList();
                re.epc  = epcList.ToList();

                re.inventoryRe  = cr.InventoryResult ? "S" : "E";
                re.inventoryMsg = cr.Message;
            }
            catch (Exception e)
            {
                Log4netHelper.LogError(e);
            }

            return(re);
        }
Exemplo n.º 11
0
        bool boxSame(string hu)
        {
            CDianShangBox box = mCurDanBoxList.First(i => i.hu == hu);

            return(LocalDataService.compareListStr(box.epc, epcList));
        }