订单图片不显示问题修复 读单拍单卡死问题修复
This commit is contained in:
1 parent
fb4bafd4d8
commit
4a7af051b2
13 files changed
+295
-120
No files matched your search
@@ -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
@@ -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 数据
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 { }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user