优化代码

This commit is contained in:
wule_5900x committed 2026-01-27 00:48:43 +08:00
1 parent ddc5f6490f
commit 625f4d9420
4 files changed
+44 -43

No files matched your search

+10 -9
View File
@@ -493,7 +493,7 @@ namespace TemuKJD.ToolForms
Task.Run(() => { });
//"&product_get_type=" + HttpUtility.UrlEncode("厂商直采", Encoding.UTF8);
ConcurrentList<DataGridViewRow> rowLst = new ConcurrentList<DataGridViewRow>();
List<DataGridViewRow> rowLst = new List<DataGridViewRow>();
rowLst.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true));
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
@@ -667,17 +667,18 @@ namespace TemuKJD.ToolForms
var shop = new ShopLoginInfo();
shop.Cookies = JsonHelper.SerializeObject(cookieList);
ConcurrentList<DataGridViewRow> rowLst = new ConcurrentList<DataGridViewRow>();
rowLst.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>());
foreach (DataGridViewRow row in rowLst)
List<string> pIds = new List<string>();
pIds.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>().Select(r => r.Cells["colProductId"].Value.ParseToString()).ToList());
foreach (var prodId in pIds)
{
if (cancellationTokenSource.IsCancellationRequested)
break;
if (row.Index < 0 || row.Cells["colCheck"].Value.ParseToBool() != true)
var row = dgvProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colProductId"].Value.ParseToString() == prodId);
if (row == null || row.Index < 0 || row.Cells["colCheck"].Value.ParseToBool() != true)
continue;
var prodId = row.Cells["colProductId"].Value.ParseToString();
var prod = lstJSTListProductInfo.FirstOrDefault(c => c.id == prodId);
// 不存在或已经采集过
if (prod == null || prod?.dbProduct?.product_json?.ParseToString().Length > 10)
@@ -743,7 +744,7 @@ namespace TemuKJD.ToolForms
prod.dbProduct.price_text = priceMin + "-" + priceMax;
prod.getProductMsg = "采集成功";
Invoke(new Action(() =>
MainForm.instance.Invoke(new Action(() =>
{
row.Cells["colMsg"].Value = prod.getProductMsg;
row.Cells["colCate"].Value = prod.categoryName.IsNullOrEmpty() ? prod?.dbProduct?.cat_id : prod.categoryName;
@@ -759,7 +760,7 @@ namespace TemuKJD.ToolForms
}));
}
if (rowLst.IndexOf(row) % 20 == 0 )
if (pIds.IndexOf(prodId) % 20 == 0 )
NaiBa.Util.Helper.ConfigHelper.SaveConfig("supplier_product_list_" + MainForm.ProcessCount, lstJSTListProductInfo);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("supplier_product_list_" + MainForm.ProcessCount, lstJSTListProductInfo);
@@ -783,7 +784,7 @@ namespace TemuKJD.ToolForms
var shop = new ShopLoginInfo();
shop.Cookies = JsonHelper.SerializeObject(cookieList);
ConcurrentList<DataGridViewRow> rowLst = new ConcurrentList<DataGridViewRow>();
List<DataGridViewRow> rowLst = new List<DataGridViewRow>();
rowLst.AddRange(dgvProduct.Rows.Cast<DataGridViewRow>());
foreach (DataGridViewRow row in rowLst)
{