部分功能优化
This commit is contained in:
1 parent
60ed59fc05
commit
5eea769672
10 files changed
+443
-96
No files matched your search
@@ -1081,6 +1081,109 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
{
|
||||
PreType = cmbPreType.Text.Trim();
|
||||
}
|
||||
|
||||
private void btnDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
var rowLst = dgvSelectProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true).ToList();
|
||||
if (rowLst.Count <= 0)
|
||||
{
|
||||
BaseMsgForm.ShowError("请勾选需要操作的商品!");
|
||||
return;
|
||||
}
|
||||
|
||||
this.pbLoading.Visible = true;
|
||||
this.btnSetPreSale.Enabled = false;
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
SetProdDown(rowLst);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "商品下架完毕";
|
||||
BaseMsgForm.ShowInfo("商品下架完毕");
|
||||
this.pbLoading.Visible = false;
|
||||
this.btnSetPreSale.Enabled = true;
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
|
||||
}
|
||||
|
||||
void SetProdDown(List<DataGridViewRow> rowLst)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.pbLoading.Visible = true;
|
||||
this.statusBar.lblTaskStatus.Text = "正在下架" + "...".Substring(0, DateTime.Now.Second % 4);
|
||||
this.statusBar.pgbTaskProgress.Maximum = dgvSelectProduct.Rows.Count;
|
||||
this.statusBar.UpdateProgressBar(0);
|
||||
}));
|
||||
|
||||
foreach (var row in rowLst)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "";
|
||||
}));
|
||||
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||||
var shopId = row.Cells["colSupplierId"].Value.ParseToString();
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||||
if (shop == null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "店铺不存在";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "店铺掉线";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
var downProdRst = WXPreSale.DownProd(shop, prodId.ParseToLong());
|
||||
System.Threading.Thread.Sleep(Randomx.GetId(100, 200));
|
||||
if (!downProdRst.Contains("\"code\":0"))
|
||||
{
|
||||
if (downProdRst.Contains("biz magic invalid"))
|
||||
{
|
||||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "店铺掉线";
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var errmsg = BaseRegex.GetStringJson(ref downProdRst, "msg");
|
||||
if (string.IsNullOrWhiteSpace(errmsg))
|
||||
errmsg = downProdRst;
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = errmsg;
|
||||
}));
|
||||
}
|
||||
|
||||
if (downProdRst.Contains("\"code\":0"))
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colOpResult"].Value = "下架成功";
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WXPreSale
|
||||
|
||||
Reference in new issue
Block a user