Beispiel #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);
                }
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #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());
                }
            }
        }
Beispiel #5
0
        void restoreUpload()
        {
            List <CUploadData> up = SqliteDataService.GetAllUploadFromSqlite <YKBoxInfo>();

            foreach (var v in up)
            {
                SqliteDataService.delUploadFromSqlite(v.Guid);
                addToSavingQueue(v.Data as YKBoxInfo);
            }
        }
Beispiel #6
0
        private void btnReupload_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    CUploadData box = row.Tag as CUploadData;
                    SqliteDataService.delUploadFromSqlite(box.Guid);
                    mParent.addToSavingQueue(box.Data as YKBoxInfo);
                }
                MetroMessageBox.Show(this, "成功加入上传队列", "提示");
                initData();
            }
        }
Beispiel #7
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();
            }
        }
Beispiel #8
0
        private void btnReupload_Click(object sender, EventArgs e)
        {
            List <DataGridViewRow> rows = GetCheckedRows();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataGridViewRow row in rows)
                {
                    CUploadData data = row.Tag as CUploadData;
                    SqliteDataService.delUploadFromSqlite(data.Guid);
                    CJJBox box = data.Data as CJJBox;
                    mParent.saveAndUpdate(box);
                    mParent.addgrid(box);
                }
                initData();
            }
        }
Beispiel #9
0
        private void btnReturn_Click(object sender, EventArgs e)
        {
            if (grid.SelectedRows.Count > 0)
            {
                if (MetroMessageBox.Show(this, "确认要清除记录吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (DataGridViewRow row in grid.SelectedRows)
                    {
                        CUploadData box = row.Tag as CUploadData;
                        SqliteDataService.delUploadFromSqlite(box.Guid);
                    }

                    MetroMessageBox.Show(this, "成功清除", "提示");
                    initData();
                }
            }
        }
Beispiel #10
0
 private void btnReupload_Click(object sender, EventArgs e)
 {
     if (grid.SelectedRows.Count > 0)
     {
         Thread t = new Thread(new ThreadStart(() =>
         {
             ShowLoading("正在上传...");
             foreach (DataGridViewRow row in grid.SelectedRows)
             {
                 CUploadData box = row.Tag as CUploadData;
                 SqliteDataService.delUploadFromSqlite(box.Guid);
                 mUploadMethod.Upload(box);
             }
             initData();
             HideLoading();
         }));
         t.IsBackground = true;
         t.Start();
     }
 }