订单图片不显示问题修复 读单拍单卡死问题修复

This commit is contained in:
wule committed 2026-08-04 22:52:02 +08:00
1 parent fb4bafd4d8
commit 4a7af051b2
13 files changed
+295 -120

No files matched your search

@@ -24,7 +24,7 @@ namespace _29WxOrderWpf.Converters
//var bitMap = new BitmapImage(new Uri(url));
BitmapImage bitMap = null;
//bitMap = LoadImageFromUrl(url + "?imageView2/1/w/100/format/webp|imageMogr2/auto-orient=");
bitMap = LoadImageFromUrl(url);
bitMap = AllBase.ImageBuild.LoadBitmipImageFromUrl(url);
return bitMap;
//string errStr = "";
//var bitmapImg = GetUrlImg(url, out errStr);
@@ -43,38 +43,5 @@ namespace _29WxOrderWpf.Converters
{
throw new NotImplementedException(); // 不需要反向转换,所以不实现。
}
public static BitmapImage LoadImageFromUrl(string url)
{
BitmapImage bitmap = new BitmapImage();
try
{
using (WebClient webClient = new WebClient())
{
// 下载图片数据到内存流
using (MemoryStream stream = new MemoryStream(webClient.DownloadData(url)))
{
stream.Position = 0; // 重置流的位置到开始处
bitmap.BeginInit();
bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
bitmap.CacheOption = BitmapCacheOption.OnLoad; // 或者使用 BitmapCacheOption.OnLoad 以减少内存使用
bitmap.UriSource = null; // 清除可能的旧UriSource,防止缓存问题
bitmap.StreamSource = stream;
bitmap.EndInit();
bitmap.Freeze(); // 防止后续更改,提高性能
}
}
}
catch (Exception ex)
{
// 处理异常,例如打印错误信息或设置一个默认图片等
//Console.WriteLine("Error loading image: " + ex.Message);
return null;
}
return bitmap;
}
}
}
@@ -53,9 +53,9 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
ChromiumWebBrowser cefWebBrowser = null;
public string cefAddress = "";
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 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();
@@ -100,7 +100,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
void filterBuyerOrder()
{
lstFilterPddBuyerOrderInfoLite = new ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>(lstPddBuyerOrderInfoLite.Where(o => filterOneBuyerOrder(o) == false));
lstFilterPddBuyerOrderInfoLite = new ObservableCollection<PddBuyerOrderLiteInfo>(lstPddBuyerOrderInfoLite.Where(o => filterOneBuyerOrder(o) == false));
if (dgBuyerOrder != null)
this.dgBuyerOrder.ItemsSource = lstFilterPddBuyerOrderInfoLite;
@@ -155,9 +155,12 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
this.chkAutoReadBuyerOrder.IsChecked = buyerReadOrderConfig.IsAutoReadOrder;
this.chkAutoAfterSale.IsChecked = buyerReadOrderConfig.IsAutoAfterSale;
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>>("pdd_buyer_order_list");
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderLiteInfo>>("pdd_buyer_order_list");
if (lstPddBuyerOrderInfoLite == null)
lstPddBuyerOrderInfoLite = new ObservableCollectionThreadSafe<PddBuyerOrderLiteInfo>();
lstPddBuyerOrderInfoLite = new ConcurrentList<PddBuyerOrderLiteInfo>();
// 移除所有null值
lstPddBuyerOrderInfoLite.RemoveAll(o => o == null);
foreach (var item in lstPddBuyerOrderInfoLite.ToList())
{
if (item.OrderTime < DateTime.Now.AddMonths(-1))
@@ -166,11 +169,12 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
item.WxSendTypeStr = "直发";
}
lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>>("pdd_buyer_after_sale_list");
lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerAfterSaleLiteInfo>>("pdd_buyer_after_sale_list");
if (lstPddBuyerAfterSaleInfoLite == null)
lstPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>();
lstPddBuyerAfterSaleInfoLite = new ConcurrentList<PddBuyerAfterSaleLiteInfo>();
lstPddBuyerAfterSaleInfoLite = new ObservableCollectionThreadSafe<PddBuyerAfterSaleLiteInfo>(lstPddBuyerAfterSaleInfoLite.Where(af => af != null));
// 移除所有null值
lstPddBuyerAfterSaleInfoLite.RemoveAll(af => af == null);
foreach (var item in lstPddBuyerAfterSaleInfoLite.ToList())
{
if (item.orderDate < DateTime.Now.AddMonths(-2).ToString("yyMMdd").ParseToInt())
@@ -740,6 +744,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
}
bool isUpdate = false;
PddBuyerOrderLiteInfo order = null;
Dispatcher.Invoke(new Action(() =>
{
@@ -748,6 +753,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
if (order == null)
{
order = o;
isUpdate = true;
Dispatcher.Invoke(new Action(() =>
{
lstPddBuyerOrderInfoLite.Add(order);
@@ -755,8 +761,10 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
else
{
// 现在先注释掉,每次刷新订单都复写数据库,后面跑稳了以后拿掉,有更新才复写数据库
//if (JsonHelper.SerializeObject(order) != JsonHelper.SerializeObject(o))
string orderStr = JsonHelper.SerializeObject(order);
string oStr = JsonHelper.SerializeObject(o);
if (JsonHelper.SerializeObject(order) != JsonHelper.SerializeObject(o))
{
if (order.order_sn == "260730-501334709841478")
{
@@ -860,6 +868,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
// 待发货直接售后,并通知中转仓接口修改退货状态
var afterSaleRst = PddDirectAutoAfterSale(order);
isUpdate = true;
}
}
SendOrderE57(order);
@@ -873,6 +882,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
// 待发货直接售后,并通知中转仓接口修改退货状态
var afterSaleRst = PddTransitAutoAfterSale(order);
isUpdate = true;
}
}
if (order.TransitWarehouseRawMessage.ParseToString().Contains("超出派送范围"))
@@ -881,12 +891,13 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
// 待发货直接售后,并通知中转仓接口修改退货状态
var afterSaleRst = PddTransitAutoAfterSale(order);
isUpdate = true;
}
}
SendTransitOrderE57(order);
}
if (!string.IsNullOrEmpty(order.ShopOrderIdStr)/* && order.WxSendTypeStr != "直发"*/)
if (isUpdate && !string.IsNullOrEmpty(order.ShopOrderIdStr)/* && order.WxSendTypeStr != "直发"*/)
{
// 买手订单状态记录到数据库
order_pdd_buyer_order pddBuyerOrder = new order_pdd_buyer_order()
@@ -1052,7 +1063,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
{
afterSale = lstPddBuyerAfterSaleInfoLite.FirstOrDefault(aft => aft.afterSalesId == af.afterSalesId);
var afterSaleTmp = JsonHelper.DeserializeJsonToObject<PddBuyerAfterSaleLiteInfo>(JsonHelper.SerializeObject(afterSale));
afterSaleTmp.sendStatus = ""; // 比较订单变化,如果有变化,才写库或者处理(设置为空强制变化)
//afterSaleTmp.sendStatus = ""; // 比较订单变化,如果有变化,才写库或者处理(设置为空强制变化)
afterSaleTmp.AfterSaleStatusOldStr = null; // 设置null,比较订单变化,如果有变化,才写
afterSaleTmp.listItemMallVO = new ListItemMallVO(); // 这个值每次获取的时候都会变,设置为新对象,不干扰比较订单变化
var afTmp = JsonHelper.DeserializeJsonToObject<PddBuyerAfterSaleLiteInfo>(JsonHelper.SerializeObject(af));
@@ -1210,7 +1221,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
// 买手已退款,尝试作废仓库订单
if (afterSale.TransitBuyerOrderRefundStatus == "买手退款成功" && afterSale.WxSendTypeStr != "直发")
if (isUpdate && afterSale.TransitBuyerOrderRefundStatus == "买手退款成功" && afterSale.WxSendTypeStr != "直发")
{
// 订单是未退款的仓库单(因一个微信订单,可以作废重拍多次,可能存在多个拼多多买手单,此处要使用买手单号对应的 transitItem 作为是否作废的判断依据
if (orderItem != null && orderItem.refund_status <= 1 && transitItem != null && transitItem.order_void_status == 0)
@@ -1233,7 +1244,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
// 获取买手退款地址并显示,如果是中转仓,填写退货地址并发送包裹
if (!string.IsNullOrEmpty(afterSale?.ShopOrderIdStr))
if (isUpdate && !string.IsNullOrEmpty(afterSale?.ShopOrderIdStr))
{
// 待用户发货 获取地址
if(string.IsNullOrWhiteSpace(afterSale.AfterSaleAddress))
@@ -1242,7 +1253,7 @@ namespace _29WxOrderWpf.Ctrls.BuyerCtrls
}
// 记录到买手退货表
if (!string.IsNullOrEmpty(afterSale?.ShopOrderIdStr) /* && afterSale.WxSendTypeStr != "直发"*/)
if (isUpdate && !string.IsNullOrEmpty(afterSale?.ShopOrderIdStr) /* && afterSale.WxSendTypeStr != "直发"*/)
{
// 买手退款单状态记录到数据库
order_pdd_buyer_after_sale pddBuyerAfterSale = new order_pdd_buyer_after_sale()
@@ -75,7 +75,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
//lstOrder.Add(new oms_wei_order_info() { id = 1, IsSelect = false, order_id = ("3737033423685556736".ParseToLong() + Randomx.GetId(0,100)).ParseToString(), shop_name = "媛卡曦工厂优选" });
GlobalConfig.lstOrder.Add(new oms_wei_order_info() { id = 1, IsSelect = false, order_id = Randomx.GetId(1000, 10000).ParseToString(), shop_name = "媛卡曦工厂优选" });
}
GlobalConfig.lstOrder.SortDesc(o => o.order_id.ParseToLong());
//GlobalConfig.lstOrder.SortDesc(o => o.order_id.ParseToLong());
}
public void AutoGetOrder()
@@ -135,6 +135,11 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
{
break;
}
Dispatcher.Invoke(new Action(() =>
{
imgLoading.Visibility = Visibility.Visible;
btnSearch.IsEnabled = false;
}));
page++;
var url = BaseClass.Build29WxObjString("order/get_erp_order_list");
@@ -416,7 +421,9 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (string.IsNullOrEmpty(orderIds))
GetShopWaybillExceptionOrder();
hasReadOrder = true;
if (string.IsNullOrEmpty(orderIds))
hasReadOrder = true;
Dispatcher.Invoke(new Action(() =>
{
imgLoading.Visibility = Visibility.Collapsed;
@@ -140,9 +140,9 @@
<uc:UcWaterMarkTextBox1 WaterMark="进价" Text="{Binding purchase_price_str}" Grid.Column="1" Grid.Row="3" Margin="36,0,4,0" VerticalAlignment="Top"
Background="Transparent" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" Visibility="{Binding purchase_price_visibility}"/>
<TextBox Text="运费:" Grid.Column="1" Grid.Row="4" Margin="0,0,4,0" VerticalAlignment="Top" Background="Transparent" IsReadOnly="True" BorderThickness="0"
Visibility="{Binding freight_visibility}"/>
Visibility="{Binding FreightVisibility}"/>
<uc:UcWaterMarkTextBox1 WaterMark="运费" Text="{Binding freight_str}" Grid.Column="1" Grid.Row="4" Margin="36,0,4,0" VerticalAlignment="Top"
Background="Transparent" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" Visibility="{Binding freight_visibility}"/>
Background="Transparent" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" Visibility="{Binding FreightVisibility}"/>
<TextBox Text="平台服务费:" Grid.Column="1" Grid.Row="5" Margin="0,0,4,0" VerticalAlignment="Top" Background="Transparent" IsReadOnly="True" BorderThickness="0"/>
<uc:UcWaterMarkTextBox1 WaterMark="平台服务费" Text="{Binding predict_commission_fee_str}" Grid.Row="5" Margin="72,0,4,0" VerticalAlignment="Center"
Background="Transparent" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap"/>
@@ -550,6 +550,9 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
return;
}
//BaseMsgWindow.ShowAnimateMessage("触发成功!" + DateTime.Now.ParseToString(), "Msg", 5);
//return;
// 打开拍单窗口
Dispatcher.Invoke(new Action(() =>
{
@@ -612,7 +615,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
// 异步加载图片防止卡顿
// 缩略图在有的电脑上无法显示
//BitmapImage bImg = ImageUrlToBitmapImageConverter.LoadImageFromUrl(order_item.thumb_img + "?imageView2/1/w/100/format/webp|imageMogr2/auto-orient=");
BitmapImage bImg = ImageUrlToBitmapImageConverter.LoadImageFromUrl(order_item.thumb_img);
BitmapImage bImg = AllBase.ImageBuild.LoadBitmipImageFromUrl(order_item.thumb_img);
Thread.Sleep(Randomx.GetId(1000));
Dispatcher.Invoke(new Action(() =>
{
@@ -1153,6 +1156,9 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
return;
}
//BaseMsgWindow.ShowAnimateMessage("触发成功!" + DateTime.Now.ParseToString(), "Msg", 5);
//return;
// 打开拍单窗口
Dispatcher.Invoke(new Action(() =>
{
@@ -39,7 +39,7 @@ namespace _29WxOrderWpf.Ctrls.ShopCtrls
private void shopListCtrl_Loaded(object sender, RoutedEventArgs e)
{
this.lbxShop.ItemsSource = GlobalConfig.ShopLoginList;
this.lbxShop.ItemsSource = new ObservableCollection<ShopLoginInfo>(GlobalConfig.ShopLoginList);
Task.Run(() => {
while(MainWindow.Instance.hasReadShop == false)
@@ -168,7 +168,7 @@ namespace _29WxOrderWpf.Ctrls.ShopCtrls
txtShopName.Text = "";
cmbNotes.Text = "";
cmbGroup.Text = "";
this.lbxShop.ItemsSource = GlobalConfig.ShopLoginList;
this.lbxShop.ItemsSource = new ObservableCollection<ShopLoginInfo>(GlobalConfig.ShopLoginList);
}
private void btnRefreshShop_Click(object sender, RoutedEventArgs e)
+1 -1
View File
@@ -32,7 +32,7 @@ namespace AllBase
/// 版本ID
/// </summary>
public static int VersionCount = 205;
public static int VersionCount = 207;
public static string ServerUrl { get; set; } = "http://1.13.195.131:9000";
public static string DebugUrl { get; set; } = "http://localhost:9000";
+103 -50
View File
@@ -15,6 +15,7 @@ using System.IO;
using System.IO.Compression;
using System.Net;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
@@ -1147,66 +1148,118 @@ Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrom
/// <returns></returns>
public static string PostUtf8(string url, string postData, string contentType = "", int timeOut = -1)
{
//return PostUtf8(url, Encoding.UTF8.GetBytes(postData));
//bool isError = false;
string[] l = UserAgent.Split('\n');
HttpWebResponse response = null;
string result;
try
{
string codeType = "utf-8";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = l[new Random(Guid.NewGuid().GetHashCode()).Next(l.Length)].Trim();
byte[] byteData = Encoding.GetEncoding(codeType).GetBytes(postData);
request.Method = "POST";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
if (timeOut == -1)
{
request.Timeout = BaseClass.TimeOut * 1000;
request.ReadWriteTimeout = BaseClass.TimeOut * 1000;
}
else
{
request.Timeout = timeOut * 1000;
request.ReadWriteTimeout = timeOut * 1000;
}
request.Proxy = null;
HttpWebRequest request;
request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
request.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
request.Headers.Add("sec-ch-ua", @"""Not(A:Brand"";v=""8"", ""Chromium"";v=""144"", ""Google Chrome"";v=""144""");
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
request.Headers.Add("Upgrade-Insecure-Requests", @"1");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
request.Headers.Add("Sec-Fetch-Site", @"none");
request.Headers.Add("Sec-Fetch-Mode", @"navigate");
request.Headers.Add("Sec-Fetch-User", @"?1");
request.Headers.Add("Sec-Fetch-Dest", @"document");
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.ContentType = "application/x-www-form-urlencoded; charset=" + codeType;
if (!string.IsNullOrEmpty(contentType))
{
request.ContentType = contentType;
}
request.ContentLength = byteData.Length;
request.Referer = url;
request.CookieContainer = new CookieContainer();
request.AllowAutoRedirect = false;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(byteData, 0, byteData.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.GetEncoding(codeType));
//string data = readStream.ReadToEnd().Trim();
//if (string.IsNullOrEmpty(data))
//{
// return "{\"code\": 400,\"data\": []}";
//}
//return data;
return ReadResponse(response);
string body = postData;
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = ReadResponse(response);
return result;
}
else return ex.Message;
}
catch (Exception e)
{
//LogSave.Add(url + "---------" + e.ToString());
//if (!isError)
//{
// isError = true;
// goto reTry;
//}
return "{\"code\": 400,\"msg\":\"" + e.Message + "\"}";
if (response != null) response.Close();
return e.Message;
}
result = ReadResponse(response);
return result;
////return PostUtf8(url, Encoding.UTF8.GetBytes(postData));
////bool isError = false;
//string[] l = UserAgent.Split('\n');
//try
//{
// string codeType = "utf-8";
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
// request.UserAgent = l[new Random(Guid.NewGuid().GetHashCode()).Next(l.Length)].Trim();
// byte[] byteData = Encoding.GetEncoding(codeType).GetBytes(postData);
// request.Method = "POST";
// request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
// if (timeOut == -1)
// {
// request.Timeout = BaseClass.TimeOut * 1000;
// request.ReadWriteTimeout = BaseClass.TimeOut * 1000;
// }
// else
// {
// request.Timeout = timeOut * 1000;
// request.ReadWriteTimeout = timeOut * 1000;
// }
// request.Proxy = null;
// request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
// request.ContentType = "application/x-www-form-urlencoded; charset=" + codeType;
// if (!string.IsNullOrEmpty(contentType))
// {
// request.ContentType = contentType;
// }
// request.ContentLength = byteData.Length;
// request.Referer = url;
// request.CookieContainer = new CookieContainer();
// request.AllowAutoRedirect = false;
// using (Stream requestStream = request.GetRequestStream())
// {
// requestStream.Write(byteData, 0, byteData.Length);
// }
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Stream receiveStream = response.GetResponseStream();
// StreamReader readStream = new StreamReader(receiveStream, Encoding.GetEncoding(codeType));
// //string data = readStream.ReadToEnd().Trim();
// //if (string.IsNullOrEmpty(data))
// //{
// // return "{\"code\": 400,\"data\": []}";
// //}
// //return data;
// return ReadResponse(response);
//}
//catch (Exception e)
//{
// //LogSave.Add(url + "---------" + e.ToString());
// //if (!isError)
// //{
// // isError = true;
// // goto reTry;
// //}
// return "{\"code\": 400,\"msg\":\"" + e.Message + "\"}";
//}
}
/// <summary>
/// post 数据
+4 -4
View File
@@ -26,11 +26,11 @@ namespace AllBase.Helper
/// <summary>
/// 店铺列表
/// </summary>
public static ObservableCollectionThreadSafe<ShopLoginInfo> ShopLoginList { get; set; } = new ObservableCollectionThreadSafe<ShopLoginInfo>();
public static ConcurrentList<ShopLoginInfo> ShopLoginList { get; set; } = new ConcurrentList<ShopLoginInfo>();
/// <summary>
/// 拼多多买手列表
/// </summary>
public static ObservableCollectionThreadSafe<BuyerLoginInfo> PDDBuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
public static ObservableCollection<BuyerLoginInfo> PDDBuyerLoginList { get; set; } = new ObservableCollection<BuyerLoginInfo>();
/// <summary>
/// 当前拼多多买手
/// </summary>
@@ -38,11 +38,11 @@ namespace AllBase.Helper
/// <summary>
/// 订单列表
/// </summary>
public static ObservableCollectionThreadSafe<oms_wei_order_info> lstOrder { get; set; } = new ObservableCollectionThreadSafe<oms_wei_order_info>();
public static ConcurrentList<oms_wei_order_info> lstOrder { get; set; } = new ConcurrentList<oms_wei_order_info>();
/// <summary>
/// 过滤的订单列表
/// </summary>
public static ObservableCollectionThreadSafe<oms_wei_order_info> lstFilterOrder { get; set; } = new ObservableCollectionThreadSafe<oms_wei_order_info>();
public static ObservableCollection<oms_wei_order_info> lstFilterOrder { get; set; } = new ObservableCollection<oms_wei_order_info>();
/// <summary>
/// 当前标签头
/// </summary>
+107
View File
@@ -3,7 +3,9 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
namespace AllBase
@@ -334,5 +336,110 @@ namespace AllBase
DeleteObject(h);
return icon;
}
public static Image LoadBitmapLoadBitmipImageFromUrl(string url)
{
try
{
BitmapImage bi = LoadBitmipImageFromUrl(url);
return BitmapImageToSystemDrawingImage(bi);
}
catch (Exception e)
{
return null;
}
}
public static Image BitmapImageToSystemDrawingImage(BitmapImage bitmapImage)
{
// 方法1 会乱码花屏
//int width = bitmapImage.PixelWidth;
//int height = bitmapImage.PixelHeight;
//int stride = width * ((bitmapImage.Format.BitsPerPixel + 7) / 8);
//byte[] pixels = new byte[stride * height];
//bitmapImage.CopyPixels(pixels, stride, 0);
//Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
//BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
//Marshal.Copy(pixels, 0, bmpData.Scan0, pixels.Length);
//bitmap.UnlockBits(bmpData);
//return bitmap;
// 方法2
using (MemoryStream stream = new MemoryStream())
{
BitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
encoder.Save(stream);
stream.Position = 0;
Bitmap bitmap = new Bitmap(stream);
stream.Close();
//// 现在你可以将这个Bitmap对象用于Windows Forms的PictureBox或其他图像显示控件
//PictureBox pictureBox = new PictureBox();
//pictureBox.Image = bitmap; // 或者如果你已经有了一个PictureBox控件,直接设置其Image属性
return bitmap;
}
}
public static BitmapImage LoadBitmipImageFromUrl(string url)
{
BitmapImage bitmap = new BitmapImage();
try
{
using (WebClient webClient = new WebClient())
{
// 下载图片数据到内存流
using (MemoryStream stream = new MemoryStream(webClient.DownloadData(url)))
{
stream.Position = 0; // 重置流的位置到开始处
bitmap.BeginInit();
bitmap.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
bitmap.CacheOption = BitmapCacheOption.OnLoad; // 或者使用 BitmapCacheOption.OnLoad 以减少内存使用
bitmap.UriSource = null; // 清除可能的旧UriSource,防止缓存问题
bitmap.StreamSource = stream;
bitmap.EndInit();
bitmap.Freeze(); // 防止后续更改,提高性能
}
}
}
catch (Exception ex)
{
// 处理异常,例如打印错误信息或设置一个默认图片等
//Console.WriteLine("Error loading image: " + ex.Message);
return null;
}
return bitmap;
}
//public string BitmapImageToBase64(BitmapImage bitmapImage)
//{
// // 创建一个 RenderTargetBitmap 对象来渲染 BitmapImage
// RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(
// (int)bitmapImage.PixelWidth,
// (int)bitmapImage.PixelHeight,
// bitmapImage.DpiX,
// bitmapImage.DpiY,
// System.Windows.Media.PixelFormats.Pbgra32);
// renderTargetBitmap.Render(bitmapImage);
// // 将 RenderTargetBitmap 保存到内存流中
// PngBitmapEncoder encoder = new PngBitmapEncoder();
// encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
// using (MemoryStream memoryStream = new MemoryStream())
// {
// encoder.Save(memoryStream);
// byte[] imageBytes = memoryStream.ToArray();
// string base64String = Convert.ToBase64String(imageBytes);
// return base64String;
// }
//}
}
}
@@ -797,9 +797,10 @@ namespace AllBase.Model.DBModel
/// <summary>
/// 运费文本是否可见
/// </summary>
public Visibility freight_visibility
public Visibility FreightVisibility
{
get { if (ItemOrder.out_amount > 0 || ItemTransitOrder?.out_amount > 0) return Visibility.Collapsed; return Visibility.Visible; }
//get { if (ItemOrder.freight > 0) return Visibility.Visible; return Visibility.Collapsed; }
set { }
}
+1 -1
View File
@@ -166,7 +166,7 @@ namespace TemuKJD.ToolForms
}
}
pictureBox1.ImageLocation = orderItem.thumb_img;
this.pictureBox1.Image = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(orderItem.thumb_img);
this.txtShopSkuId.Text = orderItem.sku_id;
this.txtShopGoodsId.Text = orderItem.product_id;
this.txtUpSpuCode.Text = orderItem.out_product_id.IsNullOrEmpty() ? orderItem.product_id : orderItem.out_product_id;
+29 -6
View File
@@ -1,9 +1,12 @@
using System;
using AllBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -24,14 +27,22 @@ namespace Work._29Tools.Forms.ToolForms
if (!string.IsNullOrEmpty(currentImgUrl))
{
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
//if (currentImgUrl.Contains("wxapp"))
// this.pictureBox1.ImageLocation = currentImgUrl;
//else
// this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
//string getImgError = "";
//var image = AllBase.GetHtml.GetUrlImg(currentImgUrl, out getImgError);
//if (!string.IsNullOrEmpty(getImgError))
// //BaseMsgForm.ShowError("图片加载失败 " + getImgError);
// image = TemuKJD.Properties.Resources.errpic;
// image = Properties.Resources.errpic;
//this.pictureBox1.Image = image;
//"ivborw" , "/9j/" , "uklgr" , "r0lgod"
//UklGRkoxAgBXRUJQVlA4WAoAAAAgAAAAHwMAHwMASUNDUEgMAAAAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAA
//UklGRjInAwBXRUJQVlA4WAoAAAAgAAAAnwUAnwUASUNDUAgCAAAAAAIIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAA
this.pictureBox1.Image = ImageBuild.LoadBitmapLoadBitmipImageFromUrl(currentImgUrl);
}
}
@@ -45,7 +56,13 @@ namespace Work._29Tools.Forms.ToolForms
if (!string.IsNullOrEmpty(currentImgUrl))
{
if (picDic != null)
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
{
if (currentImgUrl.Contains("wxapp"))
this.pictureBox1.ImageLocation = currentImgUrl;
else
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
}
}
}
@@ -83,7 +100,10 @@ namespace Work._29Tools.Forms.ToolForms
if (index == imgDic.Keys.Count)
index = 0;
currentImgUrl = imgDic.Keys.ToList()[index];
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
if (currentImgUrl.Contains("wxapp"))
this.pictureBox1.ImageLocation = currentImgUrl;
else
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
break;
}
if (imgDic[imgDic.Keys.ToList()[i]] == currentImgUrl)
@@ -92,7 +112,10 @@ namespace Work._29Tools.Forms.ToolForms
if (index == imgDic.Keys.Count)
index = 0;
currentImgUrl = imgDic[imgDic.Keys.ToList()[index]];
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
if (currentImgUrl.Contains("wxapp"))
this.pictureBox1.ImageLocation = currentImgUrl;
else
this.pictureBox1.ImageLocation = currentImgUrl.Replace("https", "http");
break;
}
}