示例#1
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;
            }
        }
示例#2
0
        /// <summary>
        /// 开始上传线程,检查是否还有未上传的信息,如果有,则弹出对话框问是否显示
        /// </summary>
        /// <returns>true 表示有未上传信息,需要提示;false 表示没有未上传信息</returns>
        public bool Start()
        {
            bool haveUndoInfo = false;
            // 此处到数据库检查是否还有未上传的信息,如果有,返回true,主界面则弹出对话框问是否显示
            // 目前此处是不会将上次关闭系统前未上传的任务继续上传的,需要手动上传
            List <SqliteUploadDataInfo> undoList = YKBoxSqliteService.GetUnUploadDataList();

            if (undoList != null && undoList.Count > 0)
            {
                foreach (SqliteUploadDataInfo item in undoList)
                {
                    CurrentUploadQueue.Push(item);
                }
            }
            // 开始定时上传
            uploadTimer.Elapsed += UploadTimer_Elapsed;
            uploadTimer.Start();

            return(haveUndoInfo);
        }