线程安全的读取拼多多买手订单
This commit is contained in:
1 parent
f00cdee502
commit
ce205c3bf4
2 files changed
+67
-14
No files matched your search
@@ -6,6 +6,7 @@ using AllBase.Helper;
|
||||
using AllBase.Model;
|
||||
using AllBase.Model.DBModel;
|
||||
using AllBase.Model.Result;
|
||||
using AllBase.Util;
|
||||
using CefSharp;
|
||||
using CefSharp.DevTools.LayerTree;
|
||||
using CefSharp.DevTools.Network;
|
||||
@@ -20,6 +21,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
@@ -50,10 +52,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
{
|
||||
ChromiumWebBrowser cefWebBrowser = null;
|
||||
public string cefAddress = "";
|
||||
public static ObservableCollection<PddBuyerOrderLiteInfo> lstPddBuyerOrderInfoLite { get; set; } = new ObservableCollection<PddBuyerOrderLiteInfo>();
|
||||
public static ObservableCollection<PddBuyerOrderLiteInfo> lstFilterPddBuyerOrderInfoLite { get; set; } = new ObservableCollection<PddBuyerOrderLiteInfo>();
|
||||
public static ObservableCollection<PddBuyerAfterSaleLiteInfo> lstPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollection<PddBuyerAfterSaleLiteInfo>();
|
||||
public static ObservableCollection<PddBuyerAfterSaleLiteInfo> lstFilterPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollection<PddBuyerAfterSaleLiteInfo>();
|
||||
public static ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo> lstPddBuyerOrderInfoLite { get; set; } = new ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>();
|
||||
public static ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo> lstFilterPddBuyerOrderInfoLite { get; set; } = new ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>();
|
||||
public static ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo> lstPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollectionThreadSafe<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;
|
||||
@@ -113,14 +115,14 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
// string.IsNullOrEmpty(filterTxt) || x.order_sn.Contains(filterTxt) || x.ShopOrderIdStr.Contains(filterTxt) || x.tracking_number.Contains(filterTxt)
|
||||
//));
|
||||
|
||||
lstFilterPddBuyerOrderInfoLite = new ObservableCollection<PddBuyerOrderLiteInfo>(lstPddBuyerOrderInfoLite
|
||||
lstFilterPddBuyerOrderInfoLite = new ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>(lstPddBuyerOrderInfoLite
|
||||
.Where(o => filterOneBuyerOrder(o) == true));
|
||||
|
||||
if (dgBuyerOrder != null)
|
||||
this.dgBuyerOrder.ItemsSource = lstFilterPddBuyerOrderInfoLite;
|
||||
|
||||
|
||||
lstFilterPddBuyerAfterSaleInfoLite = new ObservableCollection<PddBuyerAfterSaleLiteInfo>(lstPddBuyerAfterSaleInfoLite
|
||||
lstFilterPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>(lstPddBuyerAfterSaleInfoLite
|
||||
.Where(o => filterOneBuyerAfterSale(o) == true));
|
||||
|
||||
if (dgBuyerAfterSale != null)
|
||||
@@ -172,20 +174,20 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
this.chkAutoAfterSale.IsChecked = buyerReadOrderConfig.IsAutoAfterSale;
|
||||
|
||||
|
||||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ObservableCollection<PddBuyerOrderLiteInfo>>("pdd_buyer_order_list");
|
||||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>>("pdd_buyer_order_list");
|
||||
if (lstPddBuyerOrderInfoLite == null)
|
||||
lstPddBuyerOrderInfoLite = new ObservableCollection<PddBuyerOrderLiteInfo>();
|
||||
lstPddBuyerOrderInfoLite = new ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>();
|
||||
foreach (var item in lstPddBuyerOrderInfoLite.ToList())
|
||||
{
|
||||
if (item.OrderTime < DateTime.Now.AddMonths(-1))
|
||||
lstPddBuyerOrderInfoLite.Remove(item);
|
||||
}
|
||||
|
||||
lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ObservableCollection<PddBuyerAfterSaleLiteInfo>>("pdd_buyer_after_sale_list");
|
||||
lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>>("pdd_buyer_after_sale_list");
|
||||
if (lstPddBuyerAfterSaleInfoLite == null)
|
||||
lstPddBuyerAfterSaleInfoLite = new ObservableCollection<PddBuyerAfterSaleLiteInfo>();
|
||||
lstPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>();
|
||||
|
||||
lstPddBuyerAfterSaleInfoLite = new ObservableCollection<PddBuyerAfterSaleLiteInfo>(lstPddBuyerAfterSaleInfoLite.Where(af => af != null));
|
||||
lstPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>(lstPddBuyerAfterSaleInfoLite.Where(af => af != null));
|
||||
foreach (var item in lstPddBuyerAfterSaleInfoLite.ToList())
|
||||
{
|
||||
if (item.orderDate < DateTime.Now.AddMonths(-1).ToString("yyMMdd").ParseToInt())
|
||||
@@ -694,9 +696,18 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
pddO.buyerId = buyer.buyer_id;
|
||||
pddO.buyerName = buyer.buyer_name;
|
||||
|
||||
// 查找店铺订单并更新店铺订单状态
|
||||
|
||||
var orderItemExt = orderExtList.FirstOrDefault(oie => oie.out_order_id == pddO.order_sn);
|
||||
//if (pddO.order_sn == "260730-175762347591006")
|
||||
//{
|
||||
|
||||
//}
|
||||
//else //
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
// 查找店铺订单并更新店铺订单状态
|
||||
var orderItemExt = orderExtList.FirstOrDefault(oie => oie.out_order_id == pddO.order_sn && oie.buy_type == "直发");
|
||||
if (orderItemExt != null)
|
||||
{
|
||||
pddO.IsDirectStr = "是";
|
||||
@@ -835,6 +846,14 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
{
|
||||
//SendOrderE57(order);
|
||||
//if (order.sendStatus.ParseToString().Contains("售后"))
|
||||
//if (order.order_sn == "260730-175762347591006")
|
||||
//{
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
// 根据订单状态 取号/修改取号
|
||||
if (order.IsDirectStr == "是")
|
||||
@@ -1078,7 +1097,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
|
||||
|
||||
if (isUpdate)
|
||||
{
|
||||
if (afterSale.ShopOrderIdStr == "3737682397646176256")
|
||||
if (afterSale.ShopOrderIdStr == "3738098970214154240")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,40 @@ namespace AllBase.Util
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
_lock = new ReaderWriterLockSlim();
|
||||
}
|
||||
|
||||
public ObservableCollectionThreadSafe(List<T> list) : base((IList<T>)((list != null) ? new List<T>(list.Count) : list))
|
||||
{
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
_lock = new ReaderWriterLockSlim();
|
||||
|
||||
CopyFrom(list);
|
||||
}
|
||||
|
||||
public ObservableCollectionThreadSafe(IEnumerable<T> collection)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException("collection");
|
||||
}
|
||||
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
_lock = new ReaderWriterLockSlim();
|
||||
CopyFrom(collection);
|
||||
}
|
||||
|
||||
private void CopyFrom(IEnumerable<T> collection)
|
||||
{
|
||||
IList<T> items = base.Items;
|
||||
if (collection == null || items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (T item in collection)
|
||||
{
|
||||
items.Add(item);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user