public void addToQueue(UploadPKBoxInfo box) { lock (_lockObject) { CurrentUploadQueue.Enqueue(box); } }
/// <summary> /// 插入待上传sap发运箱信息到本地sqlite /// </summary> /// <param name="data"></param> public static void InsertUploadData(UploadPKBoxInfo data) { string sql = string.Format("INSERT INTO UploadData(Guid,Data,IsUpload,CreateTime) VALUES('{0}','{1}',0,'{2}')", data.Guid, JsonConvert.SerializeObject(data), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); int result = SqliteDBHelp.ExecuteSql(sql); if (result <= 0) { LogHelper.WriteLine(JsonConvert.SerializeObject(data)); } }
/// <summary> /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条 /// </summary> public void Upload() { if (CurrentUploadQueue.Count > 0) { UploadPKBoxInfo box = null; lock (_lockObject) { // 取出任务上传 box = CurrentUploadQueue.Dequeue() as UploadPKBoxInfo; } if (box != null) { SapResult sr = SAPDataService.UploadPKBoxInfo(box); SqliteDataService.DeleteUploaded(box.Guid); if (!sr.SUCCESS && box.InventoryResult) { box.UploadMsg = sr.MSG; SqliteDataService.InsertUploadData(box); } } } }
private void btnReturn_Click(object sender, EventArgs e) { List <DataGridViewRow> rows = GetCheckedRows(); if (rows != null && rows.Count > 0) { if (MetroMessageBox.Show(this, "确认要清除箱记录提示?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK) { foreach (DataGridViewRow row in rows) { UploadPKBoxInfo box = row.Tag as UploadPKBoxInfo; List <string> picktaskList = box.DeliverErrorBoxList.Select(i => i.PICK_TASK).Distinct().ToList(); //检查该下架单在服务器上是否已经下架 bool existNoOut = false; if (picktaskList != null && picktaskList.Count > 0) { foreach (string picktask in picktaskList) { List <InventoryOutLogDetailInfo> list = SAPDataService.GetHLAShelvesSingleTask(SysConfig.LGNUM, picktask); if (list != null && list.Count > 0) { if (list[0].IsOut != 1) { existNoOut = true; break; } } } } if (existNoOut) { /* * MetroMessageBox.Show(this, string.Format("箱号:{0},存在未下架的下架单,不允许清除该箱记录!", box.HU), "提示" * , MessageBoxButtons.OK, MessageBoxIcon.Information); */ DialogResult result = MetroMessageBox.Show(this, string.Format("箱号:{0},存在未下架的下架单,是否还要清除?", box.HU), "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { } else { return; } } if (SqliteDataService.DeleteUploaded(box.Guid)) { } else { MetroMessageBox.Show(this, "清除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } initData(); } } }