From 5d1f6128a502834a0cb56b1f8891c9cd690b6ce0 Mon Sep 17 00:00:00 2001 From: zhuyiyi <649091362@qq.com> Date: Tue, 17 Mar 2026 16:37:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=80=9A=E7=9F=A5=E6=8A=A5=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autocopy.aspx.cs | 70 +++++++++++++++++++++++++++++++++++++++++++++- uploadFile.aspx.cs | 9 ++++-- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/autocopy.aspx.cs b/autocopy.aspx.cs index 5079d97..bf41188 100644 --- a/autocopy.aspx.cs +++ b/autocopy.aspx.cs @@ -1,5 +1,6 @@ using BizCom; using ICSharpCode.SharpZipLib.Zip; +using MSharp.Framework; using SQLData; using System; using System.Collections.Generic; @@ -7,7 +8,10 @@ using System.Configuration; using System.Data; using System.Data.SqlClient; using System.IO; +using System.Net.Http; +using System.Net.Http.Headers; using System.Text; +using System.Threading.Tasks; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; @@ -64,7 +68,7 @@ public partial class autocopy : System.Web.UI.Page return; } StringBuilder sqlnew = new StringBuilder(); - sqlnew.AppendFormat("select ctid,tid,seller_memo,FinishDesignTime,OrderState,SupplierId,SupplierName,orderSn from view_erptradecell where (orderstate=3 or orderstate=4) and ctid='{0}'", newctid); + sqlnew.AppendFormat("select ctid,tid,seller_memo,FinishDesignTime,OrderState,SupplierId,SupplierName,orderSn,payment,ProductId from view_erptradecell where (orderstate=3 or orderstate=4) and ctid='{0}'", newctid); DataTable dtnew = CeErpTradeCell.ExecuteDataset(sqlnew.ToString()).Tables[0]; if (dtnew == null || dtnew.Rows.Count < 1) { @@ -203,6 +207,15 @@ public partial class autocopy : System.Web.UI.Page //string sqlpng = string.Format("insert into s_cdrtopng(name,addtime)values('{0}',getdate()) ;", newPathFileName); //CeErpTradeLog.ExecuteNonQuery(sqlpng); } + if (!Convert.IsDBNull(newDr["ProductId"])) + { + CeErpProduct product = CeErpProduct.GetById(Convert.ToInt32(newDr["ProductId"])); + if (product != null) + { + string param = "[{ \"product_type\": \"" + product.PType + "\",\"remark\": \"" + newDr["seller_memo"] + "\",\"index\": \"" + orderSn + "\",\"orderid\": \"" + newDr["ctid"] + "\",\"price\": \"" + newDr["payment"] + "\"}]"; + sysHttpClient(param); + } + } CeErpTradeLog.AddLog(newctid, 5, userId, "自动上传老客户文件-" + newPathFileName); string fileSql = string.Format("INSERT INTO [dbo].[CE_ErpTradeCellFile]([tid], [ctid], [isDel], [url], [createtime], [type]) SELECT '{0}', '{1}', isDel ,url,getdate(),type FROM [dbo].[CE_ErpTradeCellFile] WHERE tid='{2}' and ctid='{3}' and isDel = 0 and type = 'AUTH_FILE'", dtnew.Rows[0]["tid"], dtnew.Rows[0]["tid"], dt.Rows[0]["tid"], dt.Rows[0]["tid"]); CeErpTradeCell.ExecuteNonQuery(fileSql); @@ -218,6 +231,43 @@ public partial class autocopy : System.Web.UI.Page } } + + public void sysHttpClient(string param) + { + Task.Run(async () => + { + var client = new HttpClient(); + var request = new HttpRequestMessage + { + Method = HttpMethod.Post, + RequestUri = new Uri("http://47.122.57.102:11004/quotations/batch"), + Content = new StringContent(param) + { + Headers = + { + ContentType = new MediaTypeHeaderValue("application/json") + } + } + }; + var task = Task.Run(() => + { + try + { + var response = client.SendAsync(request).Result; + response.EnsureSuccessStatusCode(); + writeLog(param + "-" + response.Content.ReadAsStringAsync().Result); + return response.Content.ReadAsStringAsync().Result; + } + catch (Exception e) + { + return ""; + } + + + }); + }); + } + public static string MidStrEx(string sourse, string startstr, string endstr) { string result = string.Empty; @@ -360,5 +410,23 @@ public partial class autocopy : System.Web.UI.Page Response.Flush(); Response.End(); } + + + private static string logPath = ConfigurationManager.AppSettings["curPath"] + "\\log"; + private static object logFlag = new object(); + public static void writeLog(string log) + { + lock (logFlag) + { + using (FileStream fileStream = new FileStream(logPath + "\\" + DateTime.Now.ToString("yy-MM-dd") + ".log", FileMode.Append, FileAccess.Write)) + { + using (StreamWriter sw = new StreamWriter(fileStream, Encoding.Default)) + { + sw.Write(log + " ------时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + sw.Flush(); + } + } + } + } } diff --git a/uploadFile.aspx.cs b/uploadFile.aspx.cs index a0a6f14..852c063 100644 --- a/uploadFile.aspx.cs +++ b/uploadFile.aspx.cs @@ -79,6 +79,7 @@ public partial class uploadFile : System.Web.UI.Page // return; //} //CeErpTradeCell.GetByCtid("1717009344450030601"); + if (Request.Files.Count < 1) { conErc("空文件!"); @@ -424,8 +425,11 @@ public partial class uploadFile : System.Web.UI.Page //CeErpTradeCell.UpdateRelationOrder(entity); CeErpTradeCell.UpdateRelationOrder(entity.ctid); CeErpProduct product = CeErpProduct.GetById(entity.ProductId); - string param = "[{ \"product_type\": \"" + product.PType + "\", \"remark\": \"" + entity.seller_memo + "\" }]"; - sysHttpClient(param); + if (product != null) + { + string param = "[{ \"product_type\": \"" + product.PType + "\",\"remark\": \"" + entity.seller_memo + "\",\"index\": \"" + entity.OrderSn + "\",\"orderid\": \"" + entity.ctid + "\",\"price\": \"" + entity.payment + "\"}]"; + sysHttpClient(param); + } CeErpTradeLog.AddLog(entity.ctid, entity.OrderState, userId, "上传设计文件-" + saveFile); if (ctid.IndexOf("S_") >= -1) { @@ -650,6 +654,7 @@ public partial class uploadFile : System.Web.UI.Page { var response = client.SendAsync(request).Result; response.EnsureSuccessStatusCode(); + writeLog(param + "-" + response.Content.ReadAsStringAsync().Result); return response.Content.ReadAsStringAsync().Result; } catch (Exception e)