Exemple #1
0
        /// <summary>
        /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条
        /// </summary>
        public void Upload()
        {
            CUploadData task = null;

            if (CurrentUploadQueue.Count > 0)
            {
                lock (_lockObject)
                {
                    // 取出任务上传
                    task = CurrentUploadQueue.Dequeue() as CUploadData;
                }
            }

            if (task != null)
            {
                //upload
                SapResult re = SAPDataService.UploadJianHuoData(task.Data as CJianHuoUpload);
                if (re.SUCCESS)
                {
                    SqliteDataService.delUploadFromSqlite(task.Guid);
                }
                else
                {
                    SqliteDataService.updateMsgToSqlite(task.Guid, re.MSG);
                    OnUploaded?.Invoke(task.Data as CJianHuoUpload, re);
                }
            }
        }
Exemple #2
0
        public void uploadSAP(CCancelUpload uploadData, out string sapRe, out string sapMsg)
        {
            sapRe  = "";
            sapMsg = "";

            CUploadData ud = new CUploadData();

            ud.Guid       = Guid.NewGuid().ToString();
            ud.Data       = uploadData;
            ud.IsUpload   = 0;
            ud.CreateTime = DateTime.Now;
            SqliteDataService.saveToSqlite(ud);

            //upload
            SAPDataService.UploadCancelData(uploadData, ref sapRe, ref sapMsg);

            if (sapRe != "S")
            {
                SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg);
                playSoundWarn();
            }
            else
            {
                SqliteDataService.delUploadFromSqlite(ud.Guid);
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        private void savingDataThreadFunc()
        {
            while (true)
            {
                try
                {
                    if (mCancel)
                    {
                        return;
                    }

                    CUploadData ud = getQueueData();

                    if (ud != null)
                    {
                        YKBoxInfo upData = ud.Data as YKBoxInfo;
                        if (upData != null)
                        {
                            //upload
                            string uploadRe = "";
                            string sapMsg   = "";

                            SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, upData);
                            uploadRe = result.STATUS;
                            sapMsg   = result.MSG;

                            if (uploadRe == "E")
                            {
                                SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg);
                                playSoundWarn();
                            }
                            else
                            {
                                SqliteDataService.delUploadFromSqlite(ud.Guid);
                            }

                            upData.SapRemark = result.MSG;
                            upData.SapStatus = result.STATUS;

                            //save
                            YKBoxService.SaveBox(upData);

                            if (upData.Status == "S" && uploadRe == "S")
                            {
                                updateBoxList(upData);
                                UpdateTotalInfo();
                            }

                            updateUploadCount();
                            updateExpButton();
                        }
                    }
                    Thread.Sleep(500);
                }
                catch (Exception)
                {
                    //LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace.ToString());
                }
            }
        }
Exemple #5
0
        public void updateSAP(YKBoxInfo uploadData)
        {
            CUploadData ud = new CUploadData();

            ud.Guid       = Guid.NewGuid().ToString();
            ud.Data       = uploadData;
            ud.IsUpload   = 0;
            ud.CreateTime = DateTime.Now;
            SqliteDataService.saveToSqlite(ud);

            YKBoxInfo upData = ud.Data as YKBoxInfo;

            if (upData == null)
            {
                return;
            }

            string uploadRe = "";
            string sapMsg   = "";

            SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, upData);

            uploadRe = result.STATUS;
            sapMsg   = result.MSG;

            if (uploadRe == "E")
            {
                SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg);
            }
            else
            {
                SqliteDataService.delUploadFromSqlite(ud.Guid);
            }

            upData.SapRemark = result.MSG;
            upData.SapStatus = result.STATUS;

            //save
            YKBoxService.SaveBox(upData);

            if (upData.Status == "S" && uploadRe == "S")
            {
                updateBoxList(upData);
                UpdateTotalInfo();
            }
        }