Exemplo n.º 1
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());
                }
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
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))
                        {
                            YKBoxInfo box = (o as SqliteUploadDataInfo).Data;
                            //if(box.Status == "S")
                            //{
                            SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, box);
                            box.SapRemark = result.MSG;
                            box.SapStatus = result.STATUS;
                            bool xdSaveResult = YKBoxService.SaveBox(box);
                            YKBoxSqliteService.SetUploaded((o as SqliteUploadDataInfo).Guid);
                            if (OnUploaded != null)
                            {
                                OnUploaded(box);
                            }
                            //}
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                }

                isbusy = false;
            }
        }
Exemplo n.º 4
0
        void uploadSap(YKBoxInfo box)
        {
            try
            {
                SqliteUploadDataInfo ud = new SqliteUploadDataInfo();
                ud.Guid       = Guid.NewGuid().ToString();
                ud.Data       = box;
                ud.IsUpload   = 0;
                ud.CreateTime = DateTime.Now;
                YKBoxSqliteService.InsertUploadData(ud);

                SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, box);
                box.SapRemark = result.MSG;
                box.SapStatus = result.STATUS;
                bool xdSaveResult = YKBoxService.SaveBox(box);
                YKBoxSqliteService.SetUploaded(ud.Guid);
            }
            catch (Exception e)
            {
                Log4netHelper.LogError(e);
            }
        }