本地直发逻辑
This commit is contained in:
1 parent
ac0430f3f7
commit
f00cdee502
19 files changed
+1590
-520
No files matched your search
@@ -178,6 +178,7 @@
|
||||
<Compile Include="Model\DBModel\user_payment_record.cs" />
|
||||
<Compile Include="Model\DBModel\WaybillHelper.cs" />
|
||||
<Compile Include="Model\Division\Division.cs" />
|
||||
<Compile Include="Model\Division\PddDivision.cs" />
|
||||
<Compile Include="Model\Result\PddBuyerAfterSaleLiteInfo.cs" />
|
||||
<Compile Include="Model\Result\PddBuyerOrderLiteInfo.cs" />
|
||||
<Compile Include="Model\DBModel\ShopLoginInfo.cs" />
|
||||
@@ -213,6 +214,7 @@
|
||||
<Compile Include="TempFileReadWrite.cs" />
|
||||
<Compile Include="Threadx.cs" />
|
||||
<Compile Include="TreadTime.cs" />
|
||||
<Compile Include="Util\ObservableCollectionThreadSafe.cs" />
|
||||
<Compile Include="WebClientx.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace AllBase
|
||||
/// 版本ID
|
||||
/// </summary>
|
||||
|
||||
public static int VersionCount = 190;
|
||||
public static int VersionCount = 195;
|
||||
|
||||
public static string ServerUrl { get; set; } = "http://1.13.195.131:9000";
|
||||
public static string DebugUrl { get; set; } = "http://localhost:9000";
|
||||
|
||||
@@ -11,11 +11,17 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace AllBase.Helper
|
||||
{
|
||||
public class GlobalConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色等图形元素需要在主线程操作
|
||||
/// </summary>
|
||||
public static Dispatcher Dispatcher { get; set; }
|
||||
/// <summary>
|
||||
/// 店铺列表
|
||||
/// </summary>
|
||||
@@ -41,7 +47,10 @@ namespace AllBase.Helper
|
||||
/// </summary>
|
||||
public static string OrderTabHeaderStr { get; set; } = "";
|
||||
|
||||
public static Dictionary<string, oms_wei_order_info> DicDecryptOrderAddress { get; set; } = new Dictionary<string, oms_wei_order_info>();
|
||||
|
||||
public static ConcurrentList<Division> Divisions { get; set; } = new ConcurrentList<Division>();
|
||||
public static ConcurrentList<PddDivision> PddDivisions { get; set; } = new ConcurrentList<PddDivision>();
|
||||
|
||||
public static SystemSettings SystemSettings { get; set; }
|
||||
|
||||
@@ -62,6 +71,7 @@ namespace AllBase.Helper
|
||||
public static string dangerItemWords = "打火机,压力罐,刀具,铡刀,充电宝,罂粟,礼炮,煤气罐,仿制枪,暖手宝,灭火器,火炮,纸炮枪,手枪,毫安,喷漆,酒精,锂电,电池,火柴,气罐,气泡弹";
|
||||
public static List<string> lstDangerItemWord { get; set; } = dangerItemWords.Split(',').ToList();
|
||||
|
||||
#region 界面颜色
|
||||
public static System.Drawing.Color DefaultMainColor { get; set; } = System.Drawing.Color.FromArgb(63, 126, 255);
|
||||
public static System.Drawing.Color DefaultMainColorLight { get; set; } = System.Drawing.Color.FromArgb(185, 215, 255);
|
||||
public static System.Drawing.Color DefaultBorderColor { get; set; } = System.Drawing.Color.FromArgb(25, 98, 200);
|
||||
@@ -77,7 +87,39 @@ namespace AllBase.Helper
|
||||
public static System.Drawing.Color WeiXinMainColor { get; set; } = System.Drawing.Color.FromArgb(152, 99, 143);
|
||||
public static System.Drawing.Color WeiXinMainColorLight { get; set; } = System.Drawing.Color.FromArgb(245, 235, 255);
|
||||
public static System.Drawing.Color WeiXinBorderColor { get; set; } = System.Drawing.Color.FromArgb(107, 83, 147);
|
||||
#endregion
|
||||
|
||||
public static BuyConfig BuyConfig { get; set; }
|
||||
|
||||
#region 文本颜色
|
||||
public static SolidColorBrush GreenBrush = new SolidColorBrush(Color.FromArgb(255, 19, 206, 102));
|
||||
public static SolidColorBrush GreenBrush75 = new SolidColorBrush(Color.FromArgb(75, 19, 206, 102));
|
||||
public static SolidColorBrush GreenBrush35 = new SolidColorBrush(Color.FromArgb(35, 19, 206, 102));
|
||||
|
||||
public static SolidColorBrush PurpleBrush = new SolidColorBrush(Color.FromArgb(255, 152, 99, 143));
|
||||
public static SolidColorBrush PurpleBrush100 = new SolidColorBrush(Color.FromArgb(100, 152, 99, 143));
|
||||
public static SolidColorBrush PurpleBrush75 = new SolidColorBrush(Color.FromArgb(75, 152, 99, 143));
|
||||
public static SolidColorBrush PurpleBrush50 = new SolidColorBrush(Color.FromArgb(50, 152, 99, 143));
|
||||
public static SolidColorBrush PurpleBrush35 = new SolidColorBrush(Color.FromArgb(35, 152, 99, 143));
|
||||
|
||||
public static SolidColorBrush YellowBrush = new SolidColorBrush(Color.FromArgb(255, 255, 186, 0));
|
||||
public static SolidColorBrush YellowBrush75 = new SolidColorBrush(Color.FromArgb(75, 255, 186, 0));
|
||||
public static SolidColorBrush YellowBrush35 = new SolidColorBrush(Color.FromArgb(35, 255, 186, 0));
|
||||
|
||||
public static SolidColorBrush LightOrangeBrush = new SolidColorBrush(Color.FromArgb(255, 255, 155, 0));
|
||||
public static SolidColorBrush OrangeBrush = new SolidColorBrush(Color.FromArgb(255, 250, 127, 51));
|
||||
public static SolidColorBrush OrangeBrush50 = new SolidColorBrush(Color.FromArgb(50, 250, 127, 51));
|
||||
|
||||
public static SolidColorBrush RedBrush = new SolidColorBrush(Color.FromArgb(255, 255, 73, 73));
|
||||
public static SolidColorBrush RedBrush75 = new SolidColorBrush(Color.FromArgb(75, 255, 73, 73));
|
||||
public static SolidColorBrush RedBrush35 = new SolidColorBrush(Color.FromArgb(35, 255, 73, 73));
|
||||
|
||||
public static SolidColorBrush GrayBrush = new SolidColorBrush(Color.FromArgb(255, 127, 127, 127));
|
||||
|
||||
public static SolidColorBrush GreenTextBrush = new SolidColorBrush(Color.FromArgb(255, 103, 194, 58));
|
||||
public static SolidColorBrush RedTextBrush = new SolidColorBrush(Color.FromArgb(255, 250, 71, 51));
|
||||
public static SolidColorBrush RedTextBrush205 = new SolidColorBrush(Color.FromArgb(205, 250, 71, 51));
|
||||
public static SolidColorBrush RedTextBrush50 = new SolidColorBrush(Color.FromArgb(50, 250, 71, 51));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.MvvmBaseClasses;
|
||||
using NaiBa.Util.Extension;
|
||||
using NPOI.OpenXmlFormats.Dml.Diagram;
|
||||
using NPOI.OpenXmlFormats.Spreadsheet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -11,11 +12,23 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
|
||||
namespace AllBase.Model.DBModel
|
||||
{
|
||||
public class oms_wei_order_info : PropertyNotifyObject
|
||||
{
|
||||
public string OrderBuyType
|
||||
{
|
||||
get { return this.GetValue(x => x.OrderBuyType); }
|
||||
set { this.SetValue(x => x.OrderBuyType, value); }
|
||||
}
|
||||
public SolidColorBrush OrderBuyTypeColor
|
||||
{
|
||||
get { return this.GetValue(x => x.OrderBuyTypeColor); }
|
||||
set { this.SetValue(x => x.OrderBuyTypeColor, value); }
|
||||
}
|
||||
|
||||
public ObservableCollection<oms_wei_order_item_info> orderItems { get; set; } = new ObservableCollection<oms_wei_order_item_info>();
|
||||
|
||||
public oms_wei_order_item_info order_item1 { get { return orderItems?.Count > 0 ? orderItems[0] : null; } }
|
||||
@@ -38,7 +51,7 @@ namespace AllBase.Model.DBModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (order_id == "3737846414389704448")
|
||||
if (order_id == "3738070866253717760")
|
||||
{
|
||||
}
|
||||
if (status != 20 && status != 21) return false;
|
||||
@@ -47,9 +60,11 @@ namespace AllBase.Model.DBModel
|
||||
if (gift_order_status == 1 || gift_order_status == 2) return false;
|
||||
if (!string.IsNullOrEmpty(out_order_no))
|
||||
{
|
||||
var oi = orderItems.FirstOrDefault(o => o.ItemTransitOrders.Any(t => t.out_order_no == out_order_no && t.order_void_status == 1));
|
||||
if (oi == null && out_after_sale_status != "退款成功")
|
||||
return false;
|
||||
//var oi = orderItems.FirstOrDefault(o => o.ItemTransitOrders.Any(t => t.out_order_no == out_order_no && t.order_void_status == 1));
|
||||
//if (oi == null && out_after_sale_status != "退款成功")
|
||||
// return false;
|
||||
if (out_after_sale_status != "退款成功")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -63,7 +78,7 @@ namespace AllBase.Model.DBModel
|
||||
//get { return (purchase_status == 1 || !string.IsNullOrEmpty(out_order_no)) && (status == 20 || status == 21); }
|
||||
get
|
||||
{
|
||||
if (order_id == "3737846414389704448")
|
||||
if (order_id == "3738070866253717760")
|
||||
{
|
||||
|
||||
}
|
||||
@@ -74,8 +89,10 @@ namespace AllBase.Model.DBModel
|
||||
if (gift_order_status == 1 || gift_order_status == 2) return false;
|
||||
if (!string.IsNullOrEmpty(out_order_no))
|
||||
{
|
||||
var oi = orderItems.FirstOrDefault(o => o.ItemTransitOrders.Any(t => t.out_order_no == out_order_no && t.order_void_status == 1));
|
||||
if (oi != null || out_after_sale_status == "退款成功")
|
||||
//var oi = orderItems.FirstOrDefault(o => o.ItemTransitOrders.Any(t => t.out_order_no == out_order_no && t.order_void_status == 1));
|
||||
//if (oi != null || out_after_sale_status == "退款成功")
|
||||
// return false;
|
||||
if (out_after_sale_status == "退款成功")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -460,7 +477,21 @@ namespace AllBase.Model.DBModel
|
||||
set
|
||||
{
|
||||
this.SetValue(x => x.house_number, value);
|
||||
|
||||
this.AddressStr = user_name + " " + tel_number + " " + province_name + " " + city_name + " " + county_name + " " + detail_info;
|
||||
if (GlobalConfig.DicDecryptOrderAddress.ContainsKey(this.order_id))
|
||||
{
|
||||
var addressOrder = GlobalConfig.DicDecryptOrderAddress[this.order_id];
|
||||
|
||||
this.user_name = addressOrder.user_name;
|
||||
this.tel_number = addressOrder.tel_number;
|
||||
this.tel_number_ext_info = addressOrder.tel_number_ext_info;
|
||||
this.province_name = addressOrder.province_name;
|
||||
this.city_name = addressOrder.city_name;
|
||||
this.county_name = addressOrder.county_name;
|
||||
this.detail_info = addressOrder.detail_info;
|
||||
this.AddressStr = addressOrder.AddressStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -595,5 +626,25 @@ namespace AllBase.Model.DBModel
|
||||
/// 中转仓的状态 0未使用,1已创建,2创建失败(购买失败),3已创建未有上游快递单号,4已创建有上游快递单号
|
||||
/// </summary>
|
||||
public decimal? transfer_warehouse_status { get; set; }
|
||||
|
||||
public void SetOrderTextProperty()
|
||||
{
|
||||
if (order_id == "3737914129536416512")
|
||||
{
|
||||
|
||||
}
|
||||
if (this.orderItems.Any(oi => oi.OrderItemExt?.buy_type == "直发"))
|
||||
{
|
||||
OrderBuyType = "直发";
|
||||
OrderBuyTypeColor = GlobalConfig.RedTextBrush205;
|
||||
}
|
||||
else if (this.orderItems.Any(oi => oi.ItemTransitOrderWithVoid != null))
|
||||
{
|
||||
OrderBuyType = "云仓";
|
||||
OrderBuyTypeColor = GlobalConfig.GreenTextBrush;
|
||||
}
|
||||
else
|
||||
OrderBuyType = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,6 @@ namespace AllBase.Model.DBModel
|
||||
{
|
||||
public class oms_wei_order_item_info : PropertyNotifyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色等图形元素需要在主线程操作
|
||||
/// </summary>
|
||||
public Dispatcher Dispatcher { get; set; }
|
||||
/// <summary>
|
||||
/// 订单对应店铺
|
||||
/// </summary>
|
||||
@@ -243,13 +239,14 @@ namespace AllBase.Model.DBModel
|
||||
else
|
||||
TransitOrderWaybillFromWareHouseStr = "仓库物流:" + ItemTransitOrder.express_2_company + "-" + ItemTransitOrder.express_2_waybill;
|
||||
|
||||
if (order_id == "3737937905497545216")
|
||||
if (order_id == "3737914129536416512")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 仓库物流售后按钮上的文字,仓库作废单不存在仓库物流,所以此处必须是有效的仓库单(含作废失败)
|
||||
if (this.ItemTransitOrder == null || !this.ItemOrder.IsRefundWithCancel)
|
||||
//if (this.ItemTransitOrder == null || !this.ItemOrder.IsRefundWithCancel)
|
||||
if (this.ItemTransitOrderWithVoid == null || (!this.ItemOrder.IsEmergency && !this.ItemOrder.isAbnormal))
|
||||
AddEditTransitWarehouseAfterSaleStr = "";
|
||||
else
|
||||
AddEditTransitWarehouseAfterSaleStr = this.ItemTransitOrderAfterSale == null ? "添加" : "查看";
|
||||
@@ -353,15 +350,9 @@ namespace AllBase.Model.DBModel
|
||||
}
|
||||
|
||||
// 文本确定后设置颜色
|
||||
if (Dispatcher != null)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
SetBuyerTransitWaybillStatusStrColor();
|
||||
SetBuyerTransitWaybillStatusBorderColor();
|
||||
SetBuyerTransitWaybillStatusBackColor();
|
||||
}));
|
||||
}
|
||||
SetBuyerTransitWaybillStatusStrColor();
|
||||
SetBuyerTransitWaybillStatusBorderColor();
|
||||
SetBuyerTransitWaybillStatusBackColor();
|
||||
}
|
||||
public SolidColorBrush BuyerTransitWaybillStatusStrColor
|
||||
{
|
||||
@@ -371,15 +362,15 @@ namespace AllBase.Model.DBModel
|
||||
public void SetBuyerTransitWaybillStatusStrColor()
|
||||
{
|
||||
if (BuyerTransitWaybillStatusStr.StartsWith("买手已退款"))
|
||||
BuyerTransitWaybillStatusStrColor = PurpleBrush;
|
||||
BuyerTransitWaybillStatusStrColor = GlobalConfig.PurpleBrush;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手已送达"))
|
||||
BuyerTransitWaybillStatusStrColor = GreenBrush;
|
||||
BuyerTransitWaybillStatusStrColor = GlobalConfig.GreenBrush;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手已发货"))
|
||||
BuyerTransitWaybillStatusStrColor = YellowBrush;
|
||||
BuyerTransitWaybillStatusStrColor = GlobalConfig.YellowBrush;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手未发货"))
|
||||
BuyerTransitWaybillStatusStrColor = RedBrush;
|
||||
BuyerTransitWaybillStatusStrColor = GlobalConfig.RedBrush;
|
||||
else
|
||||
BuyerTransitWaybillStatusStrColor = RedBrush;
|
||||
BuyerTransitWaybillStatusStrColor = GlobalConfig.RedBrush;
|
||||
}
|
||||
public SolidColorBrush BuyerTransitWaybillStatusBorderColor
|
||||
{
|
||||
@@ -389,15 +380,15 @@ namespace AllBase.Model.DBModel
|
||||
public void SetBuyerTransitWaybillStatusBorderColor()
|
||||
{
|
||||
if (BuyerTransitWaybillStatusStr.StartsWith("买手已退款"))
|
||||
BuyerTransitWaybillStatusBorderColor = PurpleBrush75;
|
||||
BuyerTransitWaybillStatusBorderColor = GlobalConfig.PurpleBrush75;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手已送达"))
|
||||
BuyerTransitWaybillStatusBorderColor = GreenBrush75;
|
||||
BuyerTransitWaybillStatusBorderColor = GlobalConfig.GreenBrush75;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手已发货"))
|
||||
BuyerTransitWaybillStatusBorderColor = YellowBrush75;
|
||||
BuyerTransitWaybillStatusBorderColor = GlobalConfig.YellowBrush75;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手未发货"))
|
||||
BuyerTransitWaybillStatusBorderColor = RedBrush75;
|
||||
BuyerTransitWaybillStatusBorderColor = GlobalConfig.RedBrush75;
|
||||
else
|
||||
BuyerTransitWaybillStatusBorderColor = RedBrush75;
|
||||
BuyerTransitWaybillStatusBorderColor = GlobalConfig.RedBrush75;
|
||||
}
|
||||
public SolidColorBrush BuyerTransitWaybillStatusBackColor
|
||||
{
|
||||
@@ -407,15 +398,15 @@ namespace AllBase.Model.DBModel
|
||||
public void SetBuyerTransitWaybillStatusBackColor()
|
||||
{
|
||||
if (BuyerTransitWaybillStatusStr.StartsWith("买手已退款"))
|
||||
BuyerTransitWaybillStatusBackColor = PurpleBrush35;
|
||||
BuyerTransitWaybillStatusBackColor = GlobalConfig.PurpleBrush35;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手已送达"))
|
||||
BuyerTransitWaybillStatusBackColor = GreenBrush35;
|
||||
BuyerTransitWaybillStatusBackColor = GlobalConfig.GreenBrush35;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手已发货"))
|
||||
BuyerTransitWaybillStatusBackColor = YellowBrush35;
|
||||
BuyerTransitWaybillStatusBackColor = GlobalConfig.YellowBrush35;
|
||||
else if (BuyerTransitWaybillStatusStr.StartsWith("买手未发货"))
|
||||
BuyerTransitWaybillStatusBackColor = RedBrush35;
|
||||
BuyerTransitWaybillStatusBackColor = GlobalConfig.RedBrush35;
|
||||
else
|
||||
BuyerTransitWaybillStatusBackColor = RedBrush35;
|
||||
BuyerTransitWaybillStatusBackColor = GlobalConfig.RedBrush35;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -470,12 +461,12 @@ namespace AllBase.Model.DBModel
|
||||
//if (WarehouseWaybillStatusStr.StartsWith("中转已作废"))
|
||||
// return PurpleBrush;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转已出库"))
|
||||
return GreenBrush;
|
||||
return GlobalConfig.GreenBrush;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转已入库") || WarehouseWaybillStatusStr.StartsWith("中转已取号") || WarehouseWaybillStatusStr.StartsWith("中转提前取号"))
|
||||
return YellowBrush;
|
||||
return GlobalConfig.YellowBrush;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转待取号"))
|
||||
return RedBrush;
|
||||
return RedBrush;
|
||||
return GlobalConfig.RedBrush;
|
||||
return GlobalConfig.RedBrush;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -490,12 +481,12 @@ namespace AllBase.Model.DBModel
|
||||
//if (WarehouseWaybillStatusStr.StartsWith("中转已作废"))
|
||||
// return PurpleBrush75;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转已出库"))
|
||||
return GreenBrush75;
|
||||
return GlobalConfig.GreenBrush75;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转已入库") || WarehouseWaybillStatusStr.StartsWith("中转已取号") || WarehouseWaybillStatusStr.StartsWith("中转提前取号"))
|
||||
return YellowBrush75;
|
||||
return GlobalConfig.YellowBrush75;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转待取号"))
|
||||
return RedBrush75;
|
||||
return RedBrush75;
|
||||
return GlobalConfig.RedBrush75;
|
||||
return GlobalConfig.RedBrush75;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -506,12 +497,12 @@ namespace AllBase.Model.DBModel
|
||||
//if (WarehouseWaybillStatusStr.StartsWith("中转已作废"))
|
||||
// return PurpleBrush35
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转已出库"))
|
||||
return GreenBrush35;
|
||||
return GlobalConfig.GreenBrush35;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转已入库") || WarehouseWaybillStatusStr.StartsWith("中转已取号") || WarehouseWaybillStatusStr.StartsWith("中转提前取号"))
|
||||
return YellowBrush35;
|
||||
return GlobalConfig.YellowBrush35;
|
||||
if (WarehouseWaybillStatusStr.StartsWith("中转待取号"))
|
||||
return RedBrush35;
|
||||
return RedBrush35;
|
||||
return GlobalConfig.RedBrush35;
|
||||
return GlobalConfig.RedBrush35;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -566,10 +557,10 @@ namespace AllBase.Model.DBModel
|
||||
get
|
||||
{
|
||||
if (TransitRefundStatusStr.Contains("退款成功"))
|
||||
return GreenBrush;
|
||||
return GlobalConfig.GreenBrush;
|
||||
if (TransitRefundStatusStr.Contains("需手动申请售后"))
|
||||
return RedBrush;
|
||||
return LightOrangeBrush;
|
||||
return GlobalConfig.RedBrush;
|
||||
return GlobalConfig.LightOrangeBrush;
|
||||
//return YellowBrush;
|
||||
}
|
||||
set
|
||||
@@ -613,7 +604,7 @@ namespace AllBase.Model.DBModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return OutOrderTimeQualifiedStr.EndsWith("√") ? GreenTextBrush : RedTextBrush;
|
||||
return OutOrderTimeQualifiedStr.EndsWith("√") ? GlobalConfig.GreenTextBrush : GlobalConfig.RedTextBrush;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,12 +641,12 @@ namespace AllBase.Model.DBModel
|
||||
get
|
||||
{
|
||||
if ("未知状态,未付款已取消,售后完成订单取消".Contains(OrderItemStatusStr))
|
||||
return RedBrush;
|
||||
return GlobalConfig.RedBrush;
|
||||
if ("订单完成".Contains(OrderItemStatusStr))
|
||||
return GreenBrush;
|
||||
return GlobalConfig.GreenBrush;
|
||||
if ("待买家收货,店铺部分发货,待店铺发货,待付款".Contains(OrderItemStatusStr))
|
||||
return YellowBrush;
|
||||
return YellowBrush;
|
||||
return GlobalConfig.YellowBrush;
|
||||
return GlobalConfig.YellowBrush;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -664,12 +655,12 @@ namespace AllBase.Model.DBModel
|
||||
get
|
||||
{
|
||||
if ("未知状态,未付款已取消,售后完成订单取消".Contains(OrderItemStatusStr))
|
||||
return RedBrush75;
|
||||
return GlobalConfig.RedBrush75;
|
||||
if ("订单完成".Contains(OrderItemStatusStr))
|
||||
return GreenBrush75;
|
||||
return GlobalConfig.GreenBrush75;
|
||||
if ("待买家收货,店铺部分发货,待店铺发货,待付款".Contains(OrderItemStatusStr))
|
||||
return YellowBrush75;
|
||||
return YellowBrush75;
|
||||
return GlobalConfig.YellowBrush75;
|
||||
return GlobalConfig.YellowBrush75;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -678,12 +669,12 @@ namespace AllBase.Model.DBModel
|
||||
get
|
||||
{
|
||||
if ("未知状态,未付款已取消,售后完成订单取消".Contains(OrderItemStatusStr))
|
||||
return RedBrush35;
|
||||
return GlobalConfig.RedBrush35;
|
||||
if ("订单完成".Contains(OrderItemStatusStr))
|
||||
return GreenBrush35;
|
||||
return GlobalConfig.GreenBrush35;
|
||||
if ("待买家收货,店铺部分发货,待店铺发货,待付款".Contains(OrderItemStatusStr))
|
||||
return YellowBrush35;
|
||||
return YellowBrush35;
|
||||
return GlobalConfig.YellowBrush35;
|
||||
return GlobalConfig.YellowBrush35;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -773,10 +764,13 @@ namespace AllBase.Model.DBModel
|
||||
//get { return "¥" + (ItemOrder.out_amount * 0.01m).ParseToDecimal().ToString("0.00"); }
|
||||
get
|
||||
{
|
||||
if (ItemTransitOrder?.out_amount > 0)
|
||||
return "¥" + (ItemTransitOrder.out_amount * 0.01m).ParseToDecimal().ToString("0.00");
|
||||
//if (ItemTransitOrder?.out_amount > 0)
|
||||
// return "¥" + (ItemTransitOrder.out_amount * 0.01m).ParseToDecimal().ToString("0.00");
|
||||
|
||||
if (ItemTransitOrders.Any(t => t.refund_status != "买手退款成功"))
|
||||
return "¥" + (ItemTransitOrders.Where(t => t.refund_status != "买手退款成功").Sum(t => t.out_amount) * 0.01m).ParseToDecimal().ToString("0.00");
|
||||
else
|
||||
return "¥" + (commission_amount.ParseToInt() * 0.01m).ParseToDecimal().ToString("0.00");
|
||||
return "¥" + ((ItemOrder?.out_amount).ParseToInt() * 0.01m).ParseToDecimal().ToString("0.00");
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -825,9 +819,9 @@ namespace AllBase.Model.DBModel
|
||||
get
|
||||
{
|
||||
if (refund_status == 2 || refund_status == 3 || refund_status == 4 || refund_status == 11)
|
||||
return GrayBrush;
|
||||
return GlobalConfig.GrayBrush;
|
||||
//return ProfitCount > 0 ? new SolidColorBrush(Color.FromRgb(103, 194, 58)) : new SolidColorBrush(Color.FromRgb(250, 71, 51));
|
||||
return ProfitCount > 0 ? GreenTextBrush : RedTextBrush;
|
||||
return ProfitCount > 0 ? GlobalConfig.GreenTextBrush : GlobalConfig.RedTextBrush;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@@ -874,6 +868,53 @@ namespace AllBase.Model.DBModel
|
||||
set { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拼多多秒退异常重拍按钮可见条件
|
||||
/// </summary>
|
||||
public Visibility BtnAbnormalBtnVisibility
|
||||
{
|
||||
get { return this.GetValue(x => x.BtnAbnormalBtnVisibility); }
|
||||
set { this.SetValue(x => x.BtnAbnormalBtnVisibility, value); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 直发按钮可见条件
|
||||
/// </summary>
|
||||
public Visibility BtnDirectBuyOrderVisibility
|
||||
{
|
||||
get { return this.GetValue(x => x.BtnDirectBuyOrderVisibility); }
|
||||
set { this.SetValue(x => x.BtnDirectBuyOrderVisibility, value); }
|
||||
}
|
||||
public void SetAbnormalAndDirectBtnVisibility()
|
||||
{
|
||||
// 买手秒退异常重拍
|
||||
BtnAbnormalBtnVisibility = Visibility.Visible;
|
||||
// 不是异常单的不可异常重拍
|
||||
if (this.ItemOrder?.isAbnormal != true)
|
||||
BtnAbnormalBtnVisibility = Visibility.Collapsed;
|
||||
// 买手未退款的,中转正式取号以后的,不可异常重拍
|
||||
else if (this.ItemTransitOrder?.refund_status != "买手退款成功" ||
|
||||
this.WarehouseWaybillStatusStr == "中转已取号" || this.WarehouseWaybillStatusStr == "中转已入库" || this.WarehouseWaybillStatusStr == "中转已出库")
|
||||
BtnAbnormalBtnVisibility = Visibility.Collapsed;
|
||||
// 已正式取号的,不可异常重拍
|
||||
if (this.ItemTransitOrder?.pre_allocated_order_no == 1 || this.ItemTransitOrder?.pre_allocated_order_no == 3)
|
||||
BtnAbnormalBtnVisibility = Visibility.Collapsed;
|
||||
// 仓库异常的异常单不可异常重拍
|
||||
List<string> rawMsgKeyWords = new List<string> { "取号异常", "无法调用" };
|
||||
if (rawMsgKeyWords.Any(k => (this.ItemTransitOrderWithVoid?.raw_message).ParseToString().Contains(k)) && this.ItemTransitOrderWithVoid?.transfer_warehouse_status != 1)
|
||||
BtnAbnormalBtnVisibility = Visibility.Collapsed;
|
||||
|
||||
// 直拍按钮
|
||||
BtnDirectBuyOrderVisibility = Visibility.Collapsed;
|
||||
if (this.ItemOrder?.IsWaitBuy == true && this.BuyGoodsBtnTxt != "关联拍单")
|
||||
BtnDirectBuyOrderVisibility = Visibility.Visible;
|
||||
if (this.ItemOrder?.isAbnormal == true)
|
||||
{
|
||||
//if (BtnAbnormalBtnVisibility == Visibility.Collapsed && (this.ItemOrder.out_order_no.IsNullOrEmpty() || this.ItemOrder.out_after_sale_status == "退款成功"))
|
||||
if (this.ItemOrder.out_order_no.IsNullOrEmpty() || this.ItemOrder.out_after_sale_status == "退款成功")
|
||||
BtnDirectBuyOrderVisibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 订单商品表数据库id
|
||||
/// </summary>
|
||||
@@ -1017,73 +1058,20 @@ namespace AllBase.Model.DBModel
|
||||
/// </summary>
|
||||
public int? refund_status { get; set; }
|
||||
|
||||
|
||||
|
||||
public static SolidColorBrush PurpleBrush;
|
||||
public static SolidColorBrush PurpleBrush75;
|
||||
public static SolidColorBrush PurpleBrush50;
|
||||
public static SolidColorBrush PurpleBrush35;
|
||||
|
||||
public static SolidColorBrush GreenBrush;
|
||||
public static SolidColorBrush GreenBrush75;
|
||||
public static SolidColorBrush GreenBrush35;
|
||||
|
||||
public static SolidColorBrush YellowBrush;
|
||||
public static SolidColorBrush YellowBrush75;
|
||||
public static SolidColorBrush YellowBrush35;
|
||||
|
||||
public static SolidColorBrush LightOrangeBrush;
|
||||
public static SolidColorBrush OrangeBrush;
|
||||
public static SolidColorBrush OrangeBrush50;
|
||||
|
||||
public static SolidColorBrush RedBrush;
|
||||
public static SolidColorBrush RedBrush75;
|
||||
public static SolidColorBrush RedBrush35;
|
||||
|
||||
public static SolidColorBrush GrayBrush;
|
||||
|
||||
public static SolidColorBrush GreenTextBrush;
|
||||
public static SolidColorBrush RedTextBrush;
|
||||
public static SolidColorBrush RedTextBrush50;
|
||||
|
||||
public void SetOrderItemTextProperty()
|
||||
{
|
||||
CreateDateTime = BaseClass.StampToDateTime((ItemOrder?.create_time).ParseToInt());
|
||||
CreateDateTimeStr = CreateDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
UpdateTimeStr = BaseClass.StampToDateTime((ItemOrder?.update_time).ParseToInt()).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (PurpleBrush == null && this.Dispatcher != null)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
PurpleBrush = new SolidColorBrush(Color.FromArgb(255, 152, 99, 143));
|
||||
PurpleBrush75 = new SolidColorBrush(Color.FromArgb(75, 152, 99, 143));
|
||||
PurpleBrush50 = new SolidColorBrush(Color.FromArgb(50, 152, 99, 143));
|
||||
PurpleBrush35 = new SolidColorBrush(Color.FromArgb(35, 152, 99, 143));
|
||||
|
||||
GreenBrush = new SolidColorBrush(Color.FromArgb(255, 19, 206, 102));
|
||||
GreenBrush75 = new SolidColorBrush(Color.FromArgb(75, 19, 206, 102));
|
||||
GreenBrush35 = new SolidColorBrush(Color.FromArgb(35, 19, 206, 102));
|
||||
|
||||
YellowBrush = new SolidColorBrush(Color.FromArgb(255, 255, 186, 0));
|
||||
YellowBrush75 = new SolidColorBrush(Color.FromArgb(75, 255, 186, 0));
|
||||
YellowBrush35 = new SolidColorBrush(Color.FromArgb(35, 255, 186, 0));
|
||||
|
||||
LightOrangeBrush = new SolidColorBrush(Color.FromArgb(255, 255, 155, 0));
|
||||
OrangeBrush = new SolidColorBrush(Color.FromArgb(255, 250, 127, 51));
|
||||
OrangeBrush50 = new SolidColorBrush(Color.FromArgb(50, 250, 127, 51));
|
||||
|
||||
RedBrush = new SolidColorBrush(Color.FromArgb(255, 255, 73, 73));
|
||||
RedBrush75 = new SolidColorBrush(Color.FromArgb(75, 255, 73, 73));
|
||||
RedBrush35 = new SolidColorBrush(Color.FromArgb(35, 255, 73, 73));
|
||||
|
||||
GrayBrush = new SolidColorBrush(Color.FromArgb(255, 127, 127, 127));
|
||||
|
||||
GreenTextBrush = new SolidColorBrush(Color.FromArgb(255, 103, 194, 58));
|
||||
RedTextBrush = new SolidColorBrush(Color.FromArgb(255, 250, 71, 51));
|
||||
RedTextBrush50 = new SolidColorBrush(Color.FromArgb(50, 250, 71, 51));
|
||||
}));
|
||||
}
|
||||
//if (PurpleBrush == null && GlobalConfig.Dispatcher != null)
|
||||
//{
|
||||
// // 初始化笔刷,必修Invoke;
|
||||
// GlobalConfig.Dispatcher.Invoke(new Action(() =>
|
||||
// {
|
||||
|
||||
// }));
|
||||
//}
|
||||
|
||||
this.SetTransitOrder();
|
||||
this.SetItemRefund();
|
||||
@@ -1092,6 +1080,7 @@ namespace AllBase.Model.DBModel
|
||||
|
||||
// 拍单、代发等信息判断并控制拍单按钮
|
||||
this.UpdateOrderItemBuyButton();
|
||||
this.SetAbnormalAndDirectBtnVisibility();
|
||||
}
|
||||
|
||||
public void UpdateOrderItemBuyButton()
|
||||
@@ -1101,39 +1090,44 @@ namespace AllBase.Model.DBModel
|
||||
if (GlobalConfig.lstDangerItemWord.Any(d => order_item.title.Contains(d)))
|
||||
{
|
||||
order_item.IsBuyGoodsBtnEnabled = false;
|
||||
order_item.BuyGoodsBtnBackColor = RedTextBrush50;
|
||||
order_item.BuyGoodsBtnColor = RedTextBrush;
|
||||
order_item.BuyGoodsBtnBackColor = GlobalConfig.RedTextBrush50;
|
||||
order_item.BuyGoodsBtnColor = GlobalConfig.RedTextBrush;
|
||||
order_item.BuyGoodsBtnTxt = "危险品不支持中转拍单";
|
||||
}
|
||||
else if (Shop == null || (Shop?.LoginStatus != "登录成功" /*&& Shop?.Is29Supplier == null*/))
|
||||
{
|
||||
order_item.IsBuyGoodsBtnEnabled = false;
|
||||
//order_item.IsBuyGoodsBtnEnabled = true;
|
||||
order_item.BuyGoodsBtnBackColor = RedTextBrush50;
|
||||
order_item.BuyGoodsBtnColor = RedTextBrush;
|
||||
order_item.BuyGoodsBtnBackColor = GlobalConfig.RedTextBrush50;
|
||||
order_item.BuyGoodsBtnColor = GlobalConfig.RedTextBrush;
|
||||
order_item.BuyGoodsBtnTxt = "请登录店铺";
|
||||
}
|
||||
else if (Shop?.LoginStatus == "登录成功" && Shop?.Is29Supplier == null)
|
||||
{
|
||||
order_item.IsBuyGoodsBtnEnabled = false;
|
||||
order_item.BuyGoodsBtnBackColor = OrangeBrush50;
|
||||
order_item.BuyGoodsBtnColor = OrangeBrush;
|
||||
order_item.BuyGoodsBtnBackColor = GlobalConfig.OrangeBrush50;
|
||||
order_item.BuyGoodsBtnColor = GlobalConfig.OrangeBrush;
|
||||
order_item.BuyGoodsBtnTxt = "代发状态读取中请稍候";
|
||||
}
|
||||
else if (Shop?.Is29Supplier == false)
|
||||
{
|
||||
//order_item.IsBuyGoodsBtnEnabled = false;
|
||||
order_item.IsBuyGoodsBtnEnabled = true;
|
||||
order_item.BuyGoodsBtnBackColor = RedTextBrush50;
|
||||
order_item.BuyGoodsBtnColor = RedTextBrush;
|
||||
order_item.BuyGoodsBtnBackColor = GlobalConfig.RedTextBrush50;
|
||||
order_item.BuyGoodsBtnColor = GlobalConfig.RedTextBrush;
|
||||
order_item.BuyGoodsBtnTxt = "去店铺后台绑定代发";
|
||||
}
|
||||
else
|
||||
{
|
||||
order_item.IsBuyGoodsBtnEnabled = true;
|
||||
order_item.BuyGoodsBtnTxt = order_item.BuyMap == null ? "关联拍单" : "拍单";
|
||||
order_item.BuyGoodsBtnBackColor = PurpleBrush50;
|
||||
order_item.BuyGoodsBtnColor = PurpleBrush;
|
||||
order_item.BuyGoodsBtnTxt = order_item.BuyMap == null ? "关联拍单" : "云仓拍单";
|
||||
if (order_item.BuyMap == null)
|
||||
{
|
||||
order_item.BuyGoodsBtnBackColor = GlobalConfig.PurpleBrush100;
|
||||
}
|
||||
else
|
||||
order_item.BuyGoodsBtnBackColor = GlobalConfig.PurpleBrush35;
|
||||
order_item.BuyGoodsBtnColor = GlobalConfig.PurpleBrush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,14 @@ namespace AllBase.Model.DBModel
|
||||
public long? id { get; set; }
|
||||
public string order_id { get; set; }
|
||||
public string sku_id { get; set; }
|
||||
public string out_order_id { get; set; }
|
||||
public string shop_app_id { get; set; }
|
||||
public string shop_name { get; set; }
|
||||
/// <summary>
|
||||
/// 直发/云仓(一般只有直发才会写值,直发会覆盖中转)
|
||||
/// </summary>
|
||||
public string buy_type { get; set; }
|
||||
/// <summary>
|
||||
/// 订单异常文本
|
||||
/// </summary>
|
||||
public string abnormal_text { get; set; }
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Model.Division
|
||||
{
|
||||
public class PddDivision
|
||||
{
|
||||
public int? code { get; set; } // null,
|
||||
public int? national_code { get; set; } // null,
|
||||
public int? pdd_region_id { get; set; } // 500,
|
||||
public int? parent_id { get; set; } // 52,
|
||||
public string name { get; set; } // "东城区",
|
||||
public string level { get; set; } // "district",
|
||||
public int? region_type { get; set; } // 3,
|
||||
public List<PddDivision> children { get; set; } // [],
|
||||
public int? region_tag { get; set; } // 1,
|
||||
public int? is_virtual { get; set; } // 0,
|
||||
public bool? is_capital { get; set; } // false,
|
||||
public int? is_state_subsidy_supported { get; set; } // 1,
|
||||
public int? street_required_for_state_subsidy { get; set; } // 0,
|
||||
public PddDivisionLocation location { get; set; } // { "lat": 39.92855, "lng": 116.41637 },
|
||||
public bool? pdd_only { get; set; } // true
|
||||
}
|
||||
|
||||
public class PddDivisionLocation
|
||||
{
|
||||
public decimal? lat { get; set; } // 39.92855
|
||||
public decimal? lng { get; set; } // 116.41637
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,15 @@ namespace AllBase.Model.Result
|
||||
if (expressCompanyName.Contains("其他快递")) return "OTHER";
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否直发
|
||||
/// </summary>
|
||||
public string IsDirectStr
|
||||
{
|
||||
get { return this.GetValue(x => x.IsDirectStr); }
|
||||
set { this.SetValue(x => x.IsDirectStr, value); }
|
||||
}
|
||||
public string ShopOrderIdStr
|
||||
{
|
||||
get { return this.GetValue(x => x.ShopOrderIdStr); }
|
||||
@@ -346,7 +355,7 @@ namespace AllBase.Model.Result
|
||||
[JsonIgnore]
|
||||
public string outExpressCompanyMsg
|
||||
{
|
||||
get { return extra_info.order_hint?.message; }
|
||||
get { return extra_info?.order_hint?.message; }
|
||||
set { }
|
||||
}
|
||||
/// <summary>
|
||||
@@ -388,8 +397,22 @@ namespace AllBase.Model.Result
|
||||
}
|
||||
public string sendStatus
|
||||
{
|
||||
get { return this.GetValue(x => x.sendStatus); }
|
||||
set { this.SetValue(x => x.sendStatus, value); }
|
||||
get
|
||||
{
|
||||
if (this.order_sn == "260729-658558174861688")
|
||||
{
|
||||
|
||||
}
|
||||
return this.GetValue(x => x.sendStatus);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.order_sn == "260729-658558174861688")
|
||||
{
|
||||
|
||||
}
|
||||
this.SetValue(x => x.sendStatus, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 微信退款单状态
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace AllBase.Util
|
||||
{
|
||||
public class ObservableCollectionThreadSafe<T>
|
||||
: ObservableCollection<T>, IDisposable
|
||||
{
|
||||
#region Data
|
||||
private Dispatcher _dispatcher;
|
||||
private ReaderWriterLockSlim _lock;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public ObservableCollectionThreadSafe()
|
||||
{
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
_lock = new ReaderWriterLockSlim();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Overrides
|
||||
|
||||
/// <summary>
|
||||
/// Clear all items
|
||||
/// </summary>
|
||||
protected override void ClearItems()
|
||||
{
|
||||
_dispatcher.InvokeIfRequired(() =>
|
||||
{
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
base.ClearItems();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}, DispatcherPriority.DataBind);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item
|
||||
/// </summary>
|
||||
protected override void InsertItem(int index, T item)
|
||||
{
|
||||
_dispatcher.InvokeIfRequired(() =>
|
||||
{
|
||||
if (index > this.Count)
|
||||
return;
|
||||
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
base.InsertItem(index, item);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}, DispatcherPriority.DataBind);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves an item
|
||||
/// </summary>
|
||||
protected override void MoveItem(int oldIndex, int newIndex)
|
||||
{
|
||||
_dispatcher.InvokeIfRequired(() =>
|
||||
{
|
||||
_lock.EnterReadLock();
|
||||
int itemCount = this.Count;
|
||||
_lock.ExitReadLock();
|
||||
|
||||
if (oldIndex >= itemCount |
|
||||
newIndex >= itemCount |
|
||||
oldIndex == newIndex)
|
||||
return;
|
||||
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
base.MoveItem(oldIndex, newIndex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}, DispatcherPriority.DataBind);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item
|
||||
/// </summary>
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
|
||||
_dispatcher.InvokeIfRequired(() =>
|
||||
{
|
||||
if (index >= this.Count)
|
||||
return;
|
||||
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}, DispatcherPriority.DataBind);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets an item
|
||||
/// </summary>
|
||||
protected override void SetItem(int index, T item)
|
||||
{
|
||||
_dispatcher.InvokeIfRequired(() =>
|
||||
{
|
||||
_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
base.SetItem(index, item);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}, DispatcherPriority.DataBind);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Return as a cloned copy of this Collection
|
||||
/// </summary>
|
||||
public T[] ToSyncArray()
|
||||
{
|
||||
_lock.EnterReadLock();
|
||||
try
|
||||
{
|
||||
T[] _sync = new T[this.Count];
|
||||
this.CopyTo(_sync, 0);
|
||||
return _sync;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false; // To detect redundant calls
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_lock != null)
|
||||
_lock.Dispose();
|
||||
}
|
||||
|
||||
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
|
||||
// TODO: set large fields to null.
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: override a finalize only if Dispose(bool disposing) above has code to free unmanaged resources.
|
||||
// ~ObservableCollectionThreadSafe() {
|
||||
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
// Dispose(false);
|
||||
// }
|
||||
|
||||
// This code added to correctly implement the disposable pattern.
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
// TODO: uncomment the following line if the finalize is overridden above.
|
||||
// GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WPF Threading extension methods
|
||||
/// </summary>
|
||||
public static class WPFControlThreadingExtensions
|
||||
{
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// A simple WPF threading extension method, to invoke a delegate
|
||||
/// on the correct thread if it is not currently on the correct thread
|
||||
/// Which can be used with DispatcherObject types
|
||||
/// </summary>
|
||||
/// <param name="disp">The Dispatcher object on which to do the Invoke</param>
|
||||
/// <param name="performAction">The delegate to run</param>
|
||||
/// <param name="priority">The DispatcherPriority</param>
|
||||
public static void InvokeIfRequired(this Dispatcher disp,
|
||||
Action performAction, DispatcherPriority priority)
|
||||
{
|
||||
if (disp.Thread != Thread.CurrentThread)
|
||||
{
|
||||
disp.Invoke(priority, performAction);
|
||||
}
|
||||
else
|
||||
performAction();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user