Browse Source

同步产品报错显示具体SKU

qianyi
shanji 3 years ago
parent
commit
f97199aa96
  1. 20
      BBWY.Server.Business/Sync/ProductSyncBusiness.cs

20
BBWY.Server.Business/Sync/ProductSyncBusiness.cs

@ -37,9 +37,9 @@ namespace BBWY.Server.Business.Sync
this.productBusiness = productBusiness;
}
private void SyncProduct(ShopResponse shop, ProductListResponse productList, out string productId)
private void SyncProduct(ShopResponse shop, ProductListResponse productList)
{
productId = "";
var currentProductId = "";
try
{
var shopId = long.Parse(shop.ShopId);
@ -55,7 +55,7 @@ namespace BBWY.Server.Business.Sync
foreach (var product in productList.Items)
{
productId = product.Id;
currentProductId = product.Id;
var dbProduct = dbProducts.FirstOrDefault(dbp => dbp.Id == product.Id);
if (dbProduct == null)
{
@ -127,7 +127,7 @@ namespace BBWY.Server.Business.Sync
}
catch (Exception ex)
{
throw new Exception(productId, ex);
throw new Exception(currentProductId, ex);
}
}
@ -149,7 +149,7 @@ namespace BBWY.Server.Business.Sync
var productList = productBusiness.GetProductList(request);
if (productList == null || productList.Count == 0)
return;
SyncProduct(shop, productList, out string productId);
SyncProduct(shop, productList);
if (productList.Items.Count < 50 || !IsSyncAllProduct)
break;
request.PageIndex++;
@ -181,11 +181,11 @@ namespace BBWY.Server.Business.Sync
public void SyncAllShopAllProduct()
{
var shopList = venderBusiness.GetShopList();
SyncProduct(shopList.FirstOrDefault(s => s.ShopName == "瑞源玩具专营店"), true); //瑞源玩具专营店
//foreach (var shop in shopList)
//{
// Task.Factory.StartNew(() => SyncProduct(shop, true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler);
//}
//SyncProduct(shopList.FirstOrDefault(s => s.ShopName == "瑞源玩具专营店"), true); //瑞源玩具专营店
foreach (var shop in shopList)
{
Task.Factory.StartNew(() => SyncProduct(shop, true), System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.ProductSyncTaskScheduler);
}
}
}
}

Loading…
Cancel
Save