diff --git a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs index c2289a6..fc03750 100644 --- a/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs +++ b/29WxOrderWpf/Ctrls/BuyerCtrls/PDDBuyerOrderReadCtrl.xaml.cs @@ -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 lstPddBuyerOrderInfoLite { get; set; } = new ObservableCollection(); - public static ObservableCollection lstFilterPddBuyerOrderInfoLite { get; set; } = new ObservableCollection(); - public static ObservableCollection lstPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollection(); - public static ObservableCollection lstFilterPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollection(); + public static ObservableCollectionThreadSafe lstPddBuyerOrderInfoLite { get; set; } = new ObservableCollectionThreadSafe(); + public static ObservableCollectionThreadSafe lstFilterPddBuyerOrderInfoLite { get; set; } = new ObservableCollectionThreadSafe(); + public static ObservableCollectionThreadSafe lstPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollectionThreadSafe(); + public static ObservableCollectionThreadSafe lstFilterPddBuyerAfterSaleInfoLite { get; set; } = new ObservableCollectionThreadSafe(); public static ConcurrentList lstPddBuyerOrderVoidAfterSaleOrderSn { get; set; } = new ConcurrentList(); 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(lstPddBuyerOrderInfoLite + lstFilterPddBuyerOrderInfoLite = new ObservableCollectionThreadSafe(lstPddBuyerOrderInfoLite .Where(o => filterOneBuyerOrder(o) == true)); if (dgBuyerOrder != null) this.dgBuyerOrder.ItemsSource = lstFilterPddBuyerOrderInfoLite; - lstFilterPddBuyerAfterSaleInfoLite = new ObservableCollection(lstPddBuyerAfterSaleInfoLite + lstFilterPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe(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>("pdd_buyer_order_list"); + lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("pdd_buyer_order_list"); if (lstPddBuyerOrderInfoLite == null) - lstPddBuyerOrderInfoLite = new ObservableCollection(); + lstPddBuyerOrderInfoLite = new ObservableCollectionThreadSafe(); foreach (var item in lstPddBuyerOrderInfoLite.ToList()) { if (item.OrderTime < DateTime.Now.AddMonths(-1)) lstPddBuyerOrderInfoLite.Remove(item); } - lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("pdd_buyer_after_sale_list"); + lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig>("pdd_buyer_after_sale_list"); if (lstPddBuyerAfterSaleInfoLite == null) - lstPddBuyerAfterSaleInfoLite = new ObservableCollection(); + lstPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe(); - lstPddBuyerAfterSaleInfoLite = new ObservableCollection(lstPddBuyerAfterSaleInfoLite.Where(af => af != null)); + lstPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe(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") { } diff --git a/AllBase/Util/ObservableCollectionThreadSafe.cs b/AllBase/Util/ObservableCollectionThreadSafe.cs index 599f991..6105474 100644 --- a/AllBase/Util/ObservableCollectionThreadSafe.cs +++ b/AllBase/Util/ObservableCollectionThreadSafe.cs @@ -23,6 +23,40 @@ namespace AllBase.Util _dispatcher = Dispatcher.CurrentDispatcher; _lock = new ReaderWriterLockSlim(); } + + public ObservableCollectionThreadSafe(List list) : base((IList)((list != null) ? new List(list.Count) : list)) + { + _dispatcher = Dispatcher.CurrentDispatcher; + _lock = new ReaderWriterLockSlim(); + + CopyFrom(list); + } + + public ObservableCollectionThreadSafe(IEnumerable collection) + { + if (collection == null) + { + throw new ArgumentNullException("collection"); + } + + _dispatcher = Dispatcher.CurrentDispatcher; + _lock = new ReaderWriterLockSlim(); + CopyFrom(collection); + } + + private void CopyFrom(IEnumerable collection) + { + IList items = base.Items; + if (collection == null || items == null) + { + return; + } + + foreach (T item in collection) + { + items.Add(item); + } + } #endregion