带货助手查询功能优化
This commit is contained in:
1 parent
119b2f4f3e
commit
4e862cfb5c
2 files changed
+66
-34
No files matched your search
@@ -490,8 +490,11 @@ namespace TemuKJD.ToolForms
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
dgvProduct.Rows.Clear();
|
||||
lstWxSaleAssistantSpuItemInfo.Clear();
|
||||
if (chkKeepOldData.Checked == false)
|
||||
{
|
||||
dgvProduct.Rows.Clear();
|
||||
lstWxSaleAssistantSpuItemInfo.Clear();
|
||||
}
|
||||
searchPageCount = 0;
|
||||
spuItemsBase = null;
|
||||
getSpuItemsParams = null;
|
||||
@@ -565,15 +568,28 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
|
||||
//{"code":0,"pageContextResp":{"hasNext":false},"requestId":"1778688044492"}
|
||||
int errorCnt = 0;
|
||||
var spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
|
||||
if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false"))
|
||||
spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
|
||||
if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false"))
|
||||
spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
|
||||
if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false"))
|
||||
spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
|
||||
if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false"))
|
||||
spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
|
||||
for (int i = 1; i <= 50; i++) // 重试50次
|
||||
{
|
||||
if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false"))
|
||||
{
|
||||
if (!spuItemsData.Contains("\"code\":0"))
|
||||
errorCnt++;
|
||||
if (errorCnt > 5)
|
||||
break;
|
||||
|
||||
sleepTime = (int)(getDetailWaitSeconds * 1000) - 100 + Randomx.GetId(101, 501);
|
||||
Thread.Sleep(Math.Max(100, sleepTime));
|
||||
|
||||
spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams);
|
||||
}
|
||||
if (i % 10 == 0 && spuItemsData.Contains("\"hasNext\":false"))
|
||||
{
|
||||
if (BaseMsgForm.ShowConfirm("已连续" + i + "次未查询到下一页商品,是否继续?").DialogResult != DialogResult.OK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!spuItemsData.Contains("\"code\":0"))
|
||||
{
|
||||
BaseMsgForm.ShowError(spuItemsData);
|
||||
|
||||
Reference in new issue
Block a user