拼多多拍单关联闪退修复
This commit is contained in:
1 parent
b2d6d81e07
commit
ebccdbc28c
4 files changed
+140
-81
No files matched your search
@@ -38,6 +38,7 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
||||
@@ -190,6 +190,41 @@ namespace _29WxOrderWpf.ViewModels
|
||||
CefWebBrowser = null;
|
||||
}
|
||||
|
||||
public int GetRenderProcessId()
|
||||
{
|
||||
int parentPid = Process.GetCurrentProcess().Id;
|
||||
// 查找所有名为 CefSharp.BrowserSubprocess 且父进程为当前应用的进程
|
||||
var subprocesses = Process.GetProcessesByName("CefSharp.BrowserSubprocess")
|
||||
.Where(p =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return p.SessionId == Process.GetCurrentProcess().SessionId && GetParentProcessId(p.Id) == parentPid;
|
||||
}
|
||||
catch { return false; }
|
||||
});
|
||||
|
||||
// 返回第一个匹配的 Render 进程 ID,实际可能有多个
|
||||
return subprocesses.FirstOrDefault()?.Id ?? -1;
|
||||
}
|
||||
|
||||
// 辅助方法:获取父进程 ID (需引用 System.Management 或使用 P/Invoke)
|
||||
private static int GetParentProcessId(int processId)
|
||||
{
|
||||
using (var query = new System.Management.ManagementObjectSearcher(
|
||||
$"SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {processId}"))
|
||||
{
|
||||
using (var results = query.Get())
|
||||
{
|
||||
foreach (System.Management.ManagementObject obj in results)
|
||||
{
|
||||
return Convert.ToInt32(obj["ParentProcessId"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void CleanupBrowserSubprocesses(List<Process> processes = null)
|
||||
{
|
||||
// 有可能释放错误导致程序崩溃,废弃
|
||||
|
||||
@@ -49,8 +49,8 @@ XDYGZC ;广州仓 ;何外华 ;13826339849 ;广州市增城区朱村街
|
||||
XDYWHC ;武汉2仓 ;杨先生 ;13044121071 ;湖北省武汉市江汉区民族街道沿江大道轮渡龙王庙码头 ;13 ;180 ;1546 ;湖北省 ;武汉市 ;江汉区 ;民族街道 ;沿江大道轮渡龙王庙码头
|
||||
XDYSHANDC ;山东2仓 ;鸿鹄小申 ;13044121239 ;山东省临沂市费县南外环东转盘往东200米顺通快递有限公司(仓库二楼) ;22 ;292 ;2415 ;山东省 ;临沂市 ;费县 ;费城街道 ;南外环东转盘往东200米顺通快递有限公司(仓库二楼)
|
||||
XDYSHC ;上海新仓 ;纪先生 ;13044121150 ;上海市上海市普陀区真如镇街道真北路2653弄T区 ;25 ;321 ;2709 ;上海市 ;上海市 ;普陀区 ;真如镇街道 ;真北路2653弄T区
|
||||
XDYSZC ;深圳仓 ;峰峰 ;15343351331 ;广东省东莞市凤岗镇浸校塘东良巷逸乐轩E栋5号楼 ;6 ;79 ;732 ;广东省 ;东莞市 ;凤岗镇 ;凤岗街道 ;浸校塘东良巷逸乐轩E栋5号楼
|
||||
XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省义乌市后宅街道金城高尔夫二期别墅区401栋 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;后宅街道 ;金城高尔夫二期别墅区401栋";
|
||||
XDYSZC ;深圳仓 ;峰峰 ;15343351331 ;广东省东莞市凤岗镇浸校塘东良巷逸乐轩E栋5号楼 ;6 ;79 ;732 ;广东省 ;东莞市 ;凤岗镇 ;凤岗街道 ;浸校塘东良巷逸乐轩E栋5号楼";
|
||||
//XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省义乌市后宅街道金城高尔夫二期别墅区401栋 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;后宅街道 ;金城高尔夫二期别墅区401栋
|
||||
//XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省金华市义乌市北苑街道西站大道妈妈商贸18号库39号楼誉达 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;北苑街道 ;西站大道妈妈商贸18号库39号楼誉达
|
||||
//XDYJJC ;晋江仓 ;安群 ;19905951984 ;福建省泉州市南安市霞美镇温山村431号鸿鹄大厦 ;4 ;58 ;569 ;福建省 ;泉州市
|
||||
//XDYCDC ;成都仓 ;谢春虹 ;15828201479 ;四川省资阳市乐至县仙鹤大道桑都街15-19号仓库(不要放驿站,送到仓库) ;26 ;340 ;2898 ;四川省 ;资阳市
|
||||
|
||||
@@ -1009,6 +1009,8 @@ namespace TemuKJD.ToolForms
|
||||
pddFrontGoodsLite.goodsId = BaseRegex.GetLongJson(ref data, "goodsId");
|
||||
pddFrontGoodsLite.mallName = BaseRegex.GetStringJson(ref data, "mallName");
|
||||
pddFrontGoodsLite.mallId = BaseRegex.GetLongJson(ref data, "mallId");
|
||||
if (pddFrontGoodsLite.mallId == 0)
|
||||
pddFrontGoodsLite.mallId = -1;
|
||||
}
|
||||
|
||||
private void ShopLoginForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||
@@ -1050,39 +1052,60 @@ namespace TemuKJD.ToolForms
|
||||
|
||||
private async void btnManualUpdateTransitWarehouse_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sendProvince = txtSendProvince.Text.Trim();
|
||||
if (transitWarehouse == null && !cmbTransitWarehouse.Text.Trim().IsNullOrEmpty())
|
||||
{
|
||||
transitWarehouse = TransitWarehouseData.TransitWarehouseList.FirstOrDefault(t => t.TransName + " " + t.TransFullAddress == cmbTransitWarehouse.Text.Trim().ParseToString());
|
||||
}
|
||||
try
|
||||
{
|
||||
await ManualUpdateTransitWarehouse();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (transitWarehouse == null)
|
||||
{
|
||||
BaseMsgForm.ShowError("仓库不能为空");
|
||||
return;
|
||||
}
|
||||
public async Task ManualUpdateTransitWarehouse()
|
||||
{
|
||||
var sendProvince = txtSendProvince.Text.Trim();
|
||||
if (transitWarehouse == null && !cmbTransitWarehouse.Text.Trim().IsNullOrEmpty())
|
||||
{
|
||||
transitWarehouse = TransitWarehouseData.TransitWarehouseList.FirstOrDefault(t => t.TransName + " " + t.TransFullAddress == cmbTransitWarehouse.Text.Trim().ParseToString());
|
||||
}
|
||||
|
||||
if (transitWarehouse == null)
|
||||
{
|
||||
BaseMsgForm.ShowError("仓库不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this.pddFrontGoodsLite?.goodsId).IsNullOrZero() || (this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var jsStr = "document.getElementById('orderGoodsBlock').getElementsByTagName('div')[0].click();";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("(function(){\r\n");
|
||||
sb.Append("var orderGoodsBlock = document.getElementById('orderGoodsBlock')\r\n");
|
||||
sb.Append("if (orderGoodsBlock) {\r\n");
|
||||
sb.Append(" orderGoodsBlock.getElementsByTagName('div')[0].click();\r\n");
|
||||
sb.Append(" return 'success';\r\n");
|
||||
sb.Append("}\r\n");
|
||||
sb.Append("else\r\n");
|
||||
sb.Append(" return 'failed';\r\n");
|
||||
sb.Append("})();\r\n");
|
||||
//var jsStr = "document.getElementById('orderGoodsBlock').getElementsByTagName('div')[0].click();";
|
||||
var jsStr = sb.ToString();
|
||||
|
||||
var host = cefWebBrowser.GetBrowser().GetHost();
|
||||
var client = cefWebBrowser.GetDevToolsClient();
|
||||
var ts1 = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||||
ts1.Wait(500);
|
||||
for (int i = 0; i < 80; i++)
|
||||
{
|
||||
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
||||
break;
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
});
|
||||
var host = cefWebBrowser.GetBrowser().GetHost();
|
||||
var client = cefWebBrowser.GetDevToolsClient();
|
||||
var rst = await client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||||
for (int i = 0; i < 80; i++)
|
||||
{
|
||||
if (rst.Result.Value.ParseToString() == "failed")
|
||||
break;
|
||||
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
||||
break;
|
||||
await Task.Delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
this.Enabled = false;
|
||||
if (!this.cefWebBrowser.Address.StartsWith("https://mobile.yangkeduo.com/order.html?order_sn=") && (this.pddFrontGoodsLite?.goodsId).ParseToString() == txtMapGoodsId.Text.Trim())
|
||||
if (this.cefWebBrowser != null &&
|
||||
!this.cefWebBrowser.Address.StartsWith("https://mobile.yangkeduo.com/order.html?order_sn=") && (this.pddFrontGoodsLite?.goodsId).ParseToString() == txtMapGoodsId.Text.Trim())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1091,14 +1114,14 @@ namespace TemuKJD.ToolForms
|
||||
string upSkuCode = txtSkuCode.Text.Trim();
|
||||
// 保存sku及商品关联信息
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&spu_code=" + GetHtml.UrlEncodeUtf8(upSpuCode)
|
||||
+ "&sku_code=" + GetHtml.UrlEncodeUtf8(upSkuCode)
|
||||
+ "&main_user_name=" + BaseClass.MainUserName
|
||||
+ "&map_goods_name=" + txtMapGoodsName.Text.Trim()
|
||||
+ "&map_spec_name=" + txtMapSkuName.Text.Trim()
|
||||
+ "&map_goods_id=" + txtMapGoodsId.Text.Trim()
|
||||
+ "&map_sku_id=" + txtMapSkuId.Text.Trim()
|
||||
+ "&map_send_address=" + sendProvince
|
||||
+ "&spu_code=" + GetHtml.UrlEncodeUtf8(upSpuCode)
|
||||
+ "&sku_code=" + GetHtml.UrlEncodeUtf8(upSkuCode)
|
||||
+ "&main_user_name=" + BaseClass.MainUserName
|
||||
+ "&map_goods_name=" + txtMapGoodsName.Text.Trim()
|
||||
+ "&map_spec_name=" + txtMapSkuName.Text.Trim()
|
||||
+ "&map_goods_id=" + txtMapGoodsId.Text.Trim()
|
||||
+ "&map_sku_id=" + txtMapSkuId.Text.Trim()
|
||||
+ "&map_send_address=" + sendProvince
|
||||
+ "&transit_warehouse_id=" + transitWarehouse?.TransId;
|
||||
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero() && this.pddFrontGoodsLite.goodsId.ParseToString() == txtMapGoodsId.Text.Trim())
|
||||
{
|
||||
@@ -1160,29 +1183,29 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
url = BaseClass.Build29WxObjString("order/wx_add_mdy_buy_prod_map");
|
||||
var result = await GetHtml.PostUtf8Async(url, data);
|
||||
if (!result.Contains("\"code\":200"))
|
||||
result = await GetHtml.PostUtf8Async(url, data);
|
||||
if (!result.Contains("\"code\":200"))
|
||||
{
|
||||
if (!result.Contains("\"code\":200"))
|
||||
result = await GetHtml.PostUtf8Async(url, data);
|
||||
if (!result.Contains("\"code\":200"))
|
||||
{
|
||||
this.Enabled = true;
|
||||
BaseMsgForm.ShowError("保存失败" + BaseRegex.GetStringJson(ref result, "msg") + ",请稍后重试");
|
||||
}
|
||||
else
|
||||
{
|
||||
var urlMap = BaseClass.Build29WxObjString("order/wx_get_buy_prod_map");
|
||||
var dataMap = UserLogin.GetSignaturex()
|
||||
+ "&spu_codes=" + upSpuCode;
|
||||
else
|
||||
{
|
||||
var urlMap = BaseClass.Build29WxObjString("order/wx_get_buy_prod_map");
|
||||
var dataMap = UserLogin.GetSignaturex()
|
||||
+ "&spu_codes=" + upSpuCode;
|
||||
//dataMap += "&sku_codes=" + upSkuCode;
|
||||
dataMap += "&main_user_name=" + BaseClass.MainUserName;
|
||||
var resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
||||
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
||||
resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
||||
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
||||
{
|
||||
var resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
||||
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
||||
resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
||||
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
List<WXBuyMapInfo> buyMapList = new List<WXBuyMapInfo>();
|
||||
else
|
||||
{
|
||||
List<WXBuyMapInfo> buyMapList = new List<WXBuyMapInfo>();
|
||||
try
|
||||
{
|
||||
buyMapList = JsonHelper.DeserializeJsonToList<WXBuyMapInfo>(JObject.Parse(resultMap)["data"].ParseToString());
|
||||
@@ -1193,38 +1216,38 @@ namespace TemuKJD.ToolForms
|
||||
catch
|
||||
{
|
||||
}
|
||||
var pddBuyMap = buyMapList.FirstOrDefault(b => b.spu_code == upSpuCode && b.sku_code == upSkuCode && b.platform == "pdd");
|
||||
if (pddBuyMap != null)
|
||||
{
|
||||
foreach (var order in GlobalConfig.lstOrder)
|
||||
{
|
||||
if (order.IsWaitBuy)
|
||||
{
|
||||
foreach (var item in order.orderItems)
|
||||
{
|
||||
if ((item.out_product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
||||
(item.out_product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code) ||
|
||||
(item.product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
||||
(item.product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code))
|
||||
{
|
||||
item.PddBuyMap = pddBuyMap;
|
||||
var pddBuyMap = buyMapList.FirstOrDefault(b => b.spu_code == upSpuCode && b.sku_code == upSkuCode && b.platform == "pdd");
|
||||
if (pddBuyMap != null)
|
||||
{
|
||||
foreach (var order in GlobalConfig.lstOrder)
|
||||
{
|
||||
if (order.IsWaitBuy)
|
||||
{
|
||||
foreach (var item in order.orderItems)
|
||||
{
|
||||
if ((item.out_product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
||||
(item.out_product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code) ||
|
||||
(item.product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
||||
(item.product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code))
|
||||
{
|
||||
item.PddBuyMap = pddBuyMap;
|
||||
|
||||
if (filterOrderAction != null)
|
||||
{
|
||||
item.SetOrderItemTextProperty();
|
||||
filterOrderAction(order, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseMsgForm.ShowInfo("保存成功!");
|
||||
if (filterOrderAction != null)
|
||||
{
|
||||
item.SetOrderItemTextProperty();
|
||||
filterOrderAction(order, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseMsgForm.ShowInfo("保存成功!");
|
||||
this.IsClose = true;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void btnManualUpdateBuyOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user