优化买手单读取
This commit is contained in:
1 parent
7380763c1d
commit
fd07c9ba40
8 files changed
+4383
-129
No files matched your search
@@ -21,7 +21,9 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@@ -52,22 +54,43 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
/// <summary>
|
||||
/// PDDBuyerOrderReadCtrl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PDDBuyerOrderReadCtrl : UserControl
|
||||
public partial class PDDBuyerOrderReadCtrl : UserControl, INotifyPropertyChanged
|
||||
{
|
||||
private static readonly object locker = new object();
|
||||
|
||||
string lblMsgStr = "当前没有任何操作";
|
||||
public string LblMsgStr
|
||||
{
|
||||
get { return lblMsgStr; }
|
||||
set
|
||||
{
|
||||
if (lblMsgStr != value)
|
||||
{
|
||||
lblMsgStr = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("LblMsgStr"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged(PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, propertyChangedEventArgs);
|
||||
}
|
||||
|
||||
Dictionary<BuyerLoginInfo, PddPickInfo> dicPddPickInfo = new Dictionary<BuyerLoginInfo, PddPickInfo>();
|
||||
ConcurrentList<yh_sync_logistics> lstSyncLogistics = new ConcurrentList<yh_sync_logistics>();
|
||||
|
||||
ChromiumWebBrowser cefWebBrowser = null;
|
||||
public string cefAddress = "";
|
||||
ChromiumWebBrowser cefShowShopOrderLstWebBrowser = null;
|
||||
public string cefAddress = "";
|
||||
public static ConcurrentList<PddBuyerOrderLiteInfo> lstPddBuyerOrderInfoLite { get; set; } = new ConcurrentList<PddBuyerOrderLiteInfo>();
|
||||
public static ObservableCollection<PddBuyerOrderLiteInfo> lstFilterPddBuyerOrderInfoLite { get; set; } = new ObservableCollection<PddBuyerOrderLiteInfo>();
|
||||
public static ConcurrentList<PddBuyerAfterSaleLiteInfo> lstPddBuyerAfterSaleInfoLite { get; set; } = new ConcurrentList<PddBuyerAfterSaleLiteInfo>();
|
||||
public static ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo> lstFilterPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>();
|
||||
public static ConcurrentList<string> lstPddBuyerOrderVoidAfterSaleOrderSn { get; set; } = new ConcurrentList<string>();
|
||||
public CancellationTokenSource cancellationTokenSource { get; set; } = new CancellationTokenSource();
|
||||
//public ChromiumWebBrowser cefWebBrowser = null;
|
||||
public BuyerReadOrderConfig buyerReadOrderConfig = new BuyerReadOrderConfig();
|
||||
public DateTime nextGetOrderTime = DateTime.MinValue;
|
||||
public DateTime lastCefReadOrderTime = DateTime.Now;
|
||||
@@ -105,7 +128,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
public PDDBuyerOrderReadCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
this.lblMsg.DataContext = this;
|
||||
}
|
||||
|
||||
void filterBuyerOrder()
|
||||
{
|
||||
@@ -157,8 +182,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
}
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.lbPddBuyer.ItemsSource = GlobalConfig.PDDBuyerLoginList;
|
||||
{
|
||||
//this.DataContext = this;
|
||||
this.lbPddBuyer.ItemsSource = GlobalConfig.PDDBuyerLoginList;
|
||||
|
||||
buyerReadOrderConfig = NaiBa.Util.Helper.ConfigHelper.LoadConfig<BuyerReadOrderConfig>("pdd_buyer_read_order_config");
|
||||
if (buyerReadOrderConfig == null)
|
||||
@@ -262,24 +288,46 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
{
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
buyer.wpf_browser = WPFCEFBrowser.CreateChromiumWebBrowser("about:blank", false);
|
||||
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
|
||||
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||||
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||||
buyer.wpf_browser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
|
||||
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
|
||||
buyer.wpf_browser.LifeSpanHandler = lifeSapnHandler;
|
||||
buyer.wpf_browser.KeyboardHandler = new KeyboardHandler();
|
||||
buyer.wpf_browser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||||
buyer.wpf_browser.AddressChanged += CefWebBrowser_AddressChanged;
|
||||
buyer.wpf_browser.LoadError += CefWebBrowser_LoadError;
|
||||
Grid.SetRow(buyer.wpf_browser, 0);
|
||||
this.GridCef.Children.Add(buyer.wpf_browser);
|
||||
}));
|
||||
}
|
||||
Thread.Sleep(1);
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
if (cefWebBrowser == null)
|
||||
{
|
||||
cefWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser("about:blank", false);
|
||||
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
|
||||
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||||
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||||
cefWebBrowser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
|
||||
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
|
||||
cefWebBrowser.LifeSpanHandler = lifeSapnHandler;
|
||||
cefWebBrowser.KeyboardHandler = new CefKeyboardHandler();
|
||||
cefWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||||
cefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
|
||||
cefWebBrowser.LoadError += CefWebBrowser_LoadError;
|
||||
Grid.SetRow(cefWebBrowser, 0);
|
||||
this.GridCef.Children.Add(cefWebBrowser);
|
||||
}
|
||||
if (buyer.wpf_browser == null)
|
||||
buyer.wpf_browser = cefWebBrowser;
|
||||
|
||||
if (cefShowShopOrderLstWebBrowser == null)
|
||||
{
|
||||
cefShowShopOrderLstWebBrowser = WPFCEFBrowser.CreateChromiumWebBrowser("about:blank", false);
|
||||
LocalResourceRequestHandler resourceRequestHandler = new LocalResourceRequestHandler();
|
||||
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||||
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||||
cefShowShopOrderLstWebBrowser.RequestHandler = new LocalRequestHandler(resourceRequestHandler);
|
||||
var lifeSapnHandler = new LocalLifeSpanHandler(PopWindowType.SelfWindow);
|
||||
cefShowShopOrderLstWebBrowser.LifeSpanHandler = lifeSapnHandler;
|
||||
cefShowShopOrderLstWebBrowser.KeyboardHandler = new CefKeyboardHandler();
|
||||
cefShowShopOrderLstWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||||
cefShowShopOrderLstWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
|
||||
cefShowShopOrderLstWebBrowser.LoadError += CefWebBrowser_LoadError;
|
||||
Grid.SetRow(cefShowShopOrderLstWebBrowser, 0);
|
||||
this.GridCef.Children.Add(cefShowShopOrderLstWebBrowser);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void CefWebBrowser_LoadError(object sender, LoadErrorEventArgs e)
|
||||
@@ -317,11 +365,17 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
var noPickupPackageData = BaseRegex.GetJsonObjStrJson(ref data1, "noPickupPackageData").FirstOrDefault();
|
||||
if (!noPickupPackageData.IsNullOrEmpty() && send1 is ChromiumWebBrowser cef)
|
||||
{
|
||||
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(buy => buy.wpf_browser == cef);
|
||||
if (buyer != null)
|
||||
var cookies = WPFCEFBrowser.GetCookieList("yangkeduo.com", cef.GetCookieManager(null));
|
||||
var pddUserId = cookies.FirstOrDefault(c => c.Name == "pdd_user_id")?.Value;
|
||||
|
||||
if (!string.IsNullOrEmpty(pddUserId))
|
||||
{
|
||||
dicPddPickInfo[buyer] = JsonHelper.DeserializeJsonToObject<PddPickInfo>(noPickupPackageData);
|
||||
SetPickUpNo(dicPddPickInfo[buyer]);
|
||||
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(buy => buy.buyer_id == pddUserId);
|
||||
if (buyer != null)
|
||||
{
|
||||
dicPddPickInfo[buyer] = JsonHelper.DeserializeJsonToObject<PddPickInfo>(noPickupPackageData);
|
||||
SetPickUpNo(dicPddPickInfo[buyer]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,8 +447,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
}
|
||||
|
||||
// 读订单
|
||||
if (/*(cefAddress.Contains("orders.html")) &&*/ url1.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v"))
|
||||
//https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v4?pdduid=6766109923730
|
||||
if (/*(cefAddress.Contains("orders.html")) &&*/ url1.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v")) //https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v4?pdduid=6766109923730
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
@@ -1411,7 +1464,8 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
|
||||
|
||||
TimeSpan PauseTick = new TimeSpan(1);
|
||||
private void chkAutoReadBuyerOrder_CheckedChanged(object sender, RoutedEventArgs e)
|
||||
|
||||
private void chkAutoReadBuyerOrder_CheckedChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isLoad)
|
||||
{
|
||||
@@ -1433,13 +1487,361 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
|
||||
void GetOrderAndAfterSale()
|
||||
{
|
||||
GetPddOrder();
|
||||
ScrollGetPddOrder();
|
||||
//MakeWxToPddAfterSales();
|
||||
|
||||
nextGetOrderTime = DateTime.Now.AddMinutes(25);
|
||||
}
|
||||
|
||||
void GetPddOrder()
|
||||
void JsGetPddOrder()
|
||||
{
|
||||
isReadBuyerOrder = true;
|
||||
lstPddBuyerOrderVoidAfterSaleOrderSn.Clear();
|
||||
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var tokenSource = cancellationTokenSource;
|
||||
while (isInitBuyerOrder || isInitBuyerAfterSale)
|
||||
{
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(null, "已取消读取");
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
currentReadBuyer = "";
|
||||
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
|
||||
if (buyer.IsSelect != true)
|
||||
{
|
||||
foreach (var b in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
b.IsSelect = false;
|
||||
}
|
||||
buyer.IsSelect = true;
|
||||
}
|
||||
}));
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
bool isInitial = false;
|
||||
while (isInitial == false)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
if (buyer.wpf_browser != null && buyer.wpf_browser.IsBrowserInitialized)
|
||||
{
|
||||
var frame = buyer.wpf_browser.GetBrowser().MainFrame;
|
||||
isInitial = buyer.wpf_browser != null && buyer.wpf_browser.IsBrowserInitialized && frame.IsValid;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
WPFCEFBrowser.DeleteCookie(buyer.wpf_browser.GetCookieManager(null));
|
||||
|
||||
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
|
||||
var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), buyer.wpf_browser.GetCookieManager(null));
|
||||
t.Wait();
|
||||
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/personal.html");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/psnl_goods_help.html?_t_module_name=assistant_search&refer_scene=no_pickup_package_express&refer_page_name=goods_express");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
string readBuyer = "";
|
||||
int top = 0;
|
||||
int times = 0;
|
||||
|
||||
#region 售后
|
||||
if (1 == 1)
|
||||
{
|
||||
readBuyer = buyer.buyer_id;
|
||||
currentReadBuyer = buyer.buyer_id;
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/complaint_list.html?refer_page_name=personal&refer_page_sn=10001&tab=all");
|
||||
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
|
||||
if (buyer.IsSelect != true)
|
||||
{
|
||||
foreach (var b in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
b.IsSelect = false;
|
||||
}
|
||||
buyer.IsSelect = true;
|
||||
}
|
||||
}));
|
||||
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 售后读取中"; }));
|
||||
BindBuyerOrderReadInfo(buyer, "正在读取售后");
|
||||
|
||||
top = 0;
|
||||
times = 0;
|
||||
lastCefReadOrderTime = DateTime.Now;
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (isSkipNext)
|
||||
break;
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
|
||||
{
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "店铺掉线");
|
||||
break;
|
||||
}
|
||||
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
|
||||
break;
|
||||
}
|
||||
|
||||
top += Randomx.GetId(450, 600);
|
||||
Thread.Sleep(Randomx.GetId(100, 300));
|
||||
|
||||
var jsStr = @"window.scroll({
|
||||
top: document.body.scrollHeight,
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
jsStr = @"window.scroll({
|
||||
top: " + top + @",
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
//var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
//t1.Wait(1000);
|
||||
var client = buyer.wpf_browser.GetDevToolsClient();
|
||||
if (client != null)
|
||||
{
|
||||
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||||
result.Wait(5000);
|
||||
}
|
||||
}
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
}
|
||||
#endregion
|
||||
|
||||
// 待发货
|
||||
readBuyer = buyer.buyer_id;
|
||||
currentReadBuyer = buyer.buyer_id;
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
|
||||
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
|
||||
if (buyer.IsSelect != true)
|
||||
{
|
||||
foreach (var b in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
b.IsSelect = false;
|
||||
}
|
||||
buyer.IsSelect = true;
|
||||
}
|
||||
}));
|
||||
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 待发货读取中"; }));
|
||||
BindBuyerOrderReadInfo(buyer, "正在读取待发货");
|
||||
|
||||
top = 0;
|
||||
lastCefReadOrderTime = DateTime.Now;
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (isSkipNext)
|
||||
break;
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
|
||||
{
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "店铺掉线");
|
||||
break;
|
||||
}
|
||||
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
|
||||
break;
|
||||
}
|
||||
|
||||
if (times % 100 == 0)
|
||||
{
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
}
|
||||
if (buyer.status != "在线")
|
||||
break;
|
||||
times++;
|
||||
|
||||
top += Randomx.GetId(450, 600);
|
||||
Thread.Sleep(Randomx.GetId(100, 300));
|
||||
|
||||
var jsStr = @"window.scroll({
|
||||
top: document.body.scrollHeight,
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
jsStr = @"window.scroll({
|
||||
top: " + top + @",
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
//var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
//t1.Wait(1000);
|
||||
var client = buyer.wpf_browser.GetDevToolsClient();
|
||||
if (client != null)
|
||||
{
|
||||
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||||
result.Wait(5000);
|
||||
}
|
||||
}
|
||||
if (isSkipNext)
|
||||
{
|
||||
isSkipNext = false;
|
||||
continue;
|
||||
}
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 已发货读取中"; }));
|
||||
BindBuyerOrderReadInfo(buyer, "正在读取已发货");
|
||||
|
||||
// 已发货
|
||||
readBuyer = buyer.buyer_id;
|
||||
currentReadBuyer = buyer.buyer_id;
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/orders.html?type=3");
|
||||
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Panel.SetZIndex(buyer.wpf_browser, maxZIndex++);
|
||||
if (buyer.IsSelect != true)
|
||||
{
|
||||
foreach (var b in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
b.IsSelect = false;
|
||||
}
|
||||
buyer.IsSelect = true;
|
||||
}
|
||||
}));
|
||||
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
top = 0;
|
||||
lastCefReadOrderTime = DateTime.Now;
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (isSkipNext)
|
||||
break;
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
|
||||
{
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "店铺掉线");
|
||||
break;
|
||||
}
|
||||
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
|
||||
break;
|
||||
}
|
||||
|
||||
top += Randomx.GetId(450, 600);
|
||||
Thread.Sleep(Randomx.GetId(100, 300));
|
||||
|
||||
var jsStr = @"window.scroll({
|
||||
top: document.body.scrollHeight,
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
jsStr = @"window.scroll({
|
||||
top: " + top + @",
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
//var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
//t1.Wait(1000);
|
||||
var client = buyer.wpf_browser.GetDevToolsClient();
|
||||
if (client != null)
|
||||
{
|
||||
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||||
result.Wait(5000);
|
||||
}
|
||||
}
|
||||
if (isSkipNext)
|
||||
{
|
||||
isSkipNext = false;
|
||||
continue;
|
||||
}
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (isSkipNext)
|
||||
{
|
||||
isSkipNext = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(6000, 8000));
|
||||
}
|
||||
isReadBuyerOrder = false;
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = "订单读取已结束,等待下次读取"; }));
|
||||
BindBuyerOrderReadInfo(null, "订单读取已结束,等待下次读取");
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
void ScrollGetPddOrder()
|
||||
{
|
||||
isReadBuyerOrder = true;
|
||||
lstPddBuyerOrderVoidAfterSaleOrderSn.Clear();
|
||||
@@ -1455,7 +1857,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
{
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(null, "已取消读取");
|
||||
BindBuyerOrderReadInfo(null, "已取消读取");
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
@@ -1485,17 +1887,6 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
if (buyer.status != "在线")
|
||||
continue;
|
||||
|
||||
//var row = dgvBuyer.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colBuyerNick"].Value.ParseToString() == buyer.buyer_nick);
|
||||
//if (row == null)
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
//if (row.Cells["colSelect"].Value.ParseToBool() != true)
|
||||
//{
|
||||
// Invoke(new Action(() => { row.Cells["colMessage"].Value = "未勾选买手号,跳过"; }));
|
||||
// continue;
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
bool isInitial = false;
|
||||
@@ -1518,13 +1909,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), buyer.wpf_browser.GetCookieManager(null));
|
||||
t.Wait();
|
||||
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/psnl_goods_help.html?_t_module_name=assistant_search&refer_scene=no_pickup_package_express&refer_page_name=goods_express");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/personal.html");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
string readBuyer = "";
|
||||
buyer.wpf_browser.Load("https://mobile.yangkeduo.com/psnl_goods_help.html?_t_module_name=assistant_search&refer_scene=no_pickup_package_express&refer_page_name=goods_express");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
string readBuyer = "";
|
||||
int top = 0;
|
||||
int times = 0;
|
||||
|
||||
@@ -1551,7 +1942,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 售后读取中"; }));
|
||||
BindBuyer(buyer, "正在读取售后");
|
||||
BindBuyerOrderReadInfo(buyer, "正在读取售后");
|
||||
|
||||
top = 0;
|
||||
times = 0;
|
||||
@@ -1563,7 +1954,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(buyer, "已取消读取");
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1572,10 +1963,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
{
|
||||
BindBuyer(buyer, "店铺掉线");
|
||||
BindBuyerOrderReadInfo(buyer, "店铺掉线");
|
||||
break;
|
||||
}
|
||||
BindBuyer(buyer, "停滞时间超过30秒,跳过");
|
||||
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1603,7 +1994,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
}
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(buyer, "已取消读取");
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
@@ -1631,7 +2022,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 待发货读取中"; }));
|
||||
BindBuyer(buyer, "正在读取待发货");
|
||||
BindBuyerOrderReadInfo(buyer, "正在读取待发货");
|
||||
|
||||
top = 0;
|
||||
lastCefReadOrderTime = DateTime.Now;
|
||||
@@ -1642,7 +2033,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(buyer, "已取消读取");
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1651,10 +2042,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
{
|
||||
BindBuyer(buyer, "店铺掉线");
|
||||
BindBuyerOrderReadInfo(buyer, "店铺掉线");
|
||||
break;
|
||||
}
|
||||
BindBuyer(buyer, "停滞时间超过30秒,跳过");
|
||||
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1695,13 +2086,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
}
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(buyer, "已取消读取");
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = buyer.buyer_nick + " 已发货读取中"; }));
|
||||
BindBuyer(buyer, "正在读取已发货");
|
||||
BindBuyerOrderReadInfo(buyer, "正在读取已发货");
|
||||
|
||||
// 已发货
|
||||
readBuyer = buyer.buyer_id;
|
||||
@@ -1732,7 +2123,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(buyer, "已取消读取");
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1741,10 +2132,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
PddMobileLoginViewModel.CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||||
if (buyer.status != "在线")
|
||||
{
|
||||
BindBuyer(buyer, "店铺掉线");
|
||||
BindBuyerOrderReadInfo(buyer, "店铺掉线");
|
||||
break;
|
||||
}
|
||||
BindBuyer(buyer, "停滞时间超过30秒,跳过");
|
||||
BindBuyerOrderReadInfo(buyer, "停滞时间超过30秒,跳过");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1777,14 +2168,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
}
|
||||
if (tokenSource.IsCancellationRequested)
|
||||
{
|
||||
BindBuyer(buyer, "已取消读取");
|
||||
BindBuyerOrderReadInfo(buyer, "已取消读取");
|
||||
break;
|
||||
}
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// if (row.Cells["colMessage"].Value.ParseToString().StartsWith("正在读取"))
|
||||
// BindBuyer(buyer, " ");
|
||||
//}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1799,11 +2185,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
isReadBuyerOrder = false;
|
||||
|
||||
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.Title = "订单读取已结束,等待下次读取"; }));
|
||||
}, cancellationTokenSource.Token);
|
||||
BindBuyerOrderReadInfo(null, "订单读取已结束,等待下次读取");
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
private void BindBuyer(BuyerLoginInfo buyer, string msg = "", List<string> selectIds = null)
|
||||
private void BindBuyerOrderReadInfo(BuyerLoginInfo buyer, string msg = "", List<string> selectIds = null)
|
||||
{
|
||||
this.LblMsgStr = buyer?.buyer_name + " " + msg + " " + DateTime.Now.ToString("yyMMdd HH:mm:ss");
|
||||
}
|
||||
|
||||
private void btnSendBuyerOrder_Click(object sender, RoutedEventArgs e)
|
||||
@@ -2826,40 +3214,96 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
Panel.SetZIndex(MainWindow.Instance.gridTbBuyerOrderReadCtrl, -1);
|
||||
}
|
||||
|
||||
private void CheckBox_Click(object sender, RoutedEventArgs e)
|
||||
private async void CheckBox_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is CheckBox chk)
|
||||
{
|
||||
if (chk.DataContext is BuyerLoginInfo pddBuyer)
|
||||
{
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
buyer.IsSelect = false;
|
||||
}
|
||||
pddBuyer.IsSelect = true;
|
||||
if (pddBuyer.wpf_browser != null)
|
||||
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
|
||||
}
|
||||
}
|
||||
//if (e.Source)
|
||||
}
|
||||
//if (sender is CheckBox chk)
|
||||
//{
|
||||
// if (chk.DataContext is BuyerLoginInfo pddBuyer)
|
||||
// {
|
||||
// foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
// {
|
||||
// buyer.IsSelect = false;
|
||||
// }
|
||||
// pddBuyer.IsSelect = true;
|
||||
// if (pddBuyer.wpf_browser != null)
|
||||
// Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
|
||||
// }
|
||||
//}
|
||||
//if (e.Source)
|
||||
if (sender is CheckBox chk)
|
||||
{
|
||||
if (chk.DataContext is BuyerLoginInfo pddBuyer)
|
||||
{
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
buyer.IsSelect = false;
|
||||
}
|
||||
pddBuyer.IsSelect = true;
|
||||
if (currentReadBuyer == pddBuyer.buyer_id && pddBuyer.wpf_browser != null)
|
||||
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
|
||||
else if (cefShowShopOrderLstWebBrowser != null)
|
||||
{
|
||||
WPFCEFBrowser.DeleteCookie(cefShowShopOrderLstWebBrowser.GetCookieManager());
|
||||
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(pddBuyer?.cookie);
|
||||
//var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefShowShopOrderLstWebBrowser.GetCookieManager(null));
|
||||
//t.Wait();
|
||||
foreach (var cook in cookieLst)
|
||||
{
|
||||
await WPFCEFBrowser.SetCookieAsync(cook.Domain.Trim('.'), cook.Name + "=" + cook.Value + ";", cefShowShopOrderLstWebBrowser.GetCookieManager(null));
|
||||
}
|
||||
|
||||
private void txtBuyerNick_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
Panel.SetZIndex(this.cefShowShopOrderLstWebBrowser, maxZIndex++);
|
||||
//cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com");
|
||||
cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com/personal.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void txtBuyerNick_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is TextBox txt)
|
||||
{
|
||||
if (txt.DataContext is BuyerLoginInfo pddBuyer)
|
||||
{
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
buyer.IsSelect = false;
|
||||
}
|
||||
pddBuyer.IsSelect = true;
|
||||
if (pddBuyer.wpf_browser != null)
|
||||
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (sender is TextBox txt)
|
||||
//{
|
||||
// if (txt.DataContext is BuyerLoginInfo pddBuyer)
|
||||
// {
|
||||
// foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
// {
|
||||
// buyer.IsSelect = false;
|
||||
// }
|
||||
// pddBuyer.IsSelect = true;
|
||||
// if (pddBuyer.wpf_browser != null)
|
||||
// Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
|
||||
// }
|
||||
//}
|
||||
if (sender is TextBox txt)
|
||||
{
|
||||
if (txt.DataContext is BuyerLoginInfo pddBuyer)
|
||||
{
|
||||
foreach (var buyer in GlobalConfig.PDDBuyerLoginList)
|
||||
{
|
||||
buyer.IsSelect = false;
|
||||
}
|
||||
pddBuyer.IsSelect = true;
|
||||
if (currentReadBuyer == pddBuyer.buyer_id && pddBuyer.wpf_browser != null)
|
||||
Panel.SetZIndex(pddBuyer.wpf_browser, maxZIndex++);
|
||||
else if (cefShowShopOrderLstWebBrowser != null)
|
||||
{
|
||||
WPFCEFBrowser.DeleteCookie(cefShowShopOrderLstWebBrowser.GetCookieManager());
|
||||
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(pddBuyer?.cookie);
|
||||
//var t = WPFCEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefShowShopOrderLstWebBrowser.GetCookieManager(null));
|
||||
//t.Wait();
|
||||
foreach (var cook in cookieLst)
|
||||
{
|
||||
await WPFCEFBrowser.SetCookieAsync(cook.Domain.Trim('.'), cook.Name + "=" + cook.Value + ";", cefShowShopOrderLstWebBrowser.GetCookieManager(null));
|
||||
}
|
||||
|
||||
Panel.SetZIndex(this.cefShowShopOrderLstWebBrowser, maxZIndex++);
|
||||
//cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com");
|
||||
cefShowShopOrderLstWebBrowser.Load("https://mobile.yangkeduo.com/personal.html");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void txtBuyerNick_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user