From 19ea2f2363b0d5eb21d546b18c74e5e2f6040d2b Mon Sep 17 00:00:00 2001 From: geh <1923421292@qq.com> Date: Mon, 15 Sep 2025 18:45:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=85=AC=E5=8F=B8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=92=8C=E4=B8=8A=E6=8A=A5=E7=9D=A3=E6=9F=A5=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUBQHSE/BLL/OpenService/FileInsertService.cs | 24 ++++++++++++++----- .../BLL/WebService/CNCECHSSEGetWebService.cs | 5 ++-- .../APIItem/CNCEC/DCGLCheckRectifyItem.cs | 9 +++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/SUBQHSE/BLL/OpenService/FileInsertService.cs b/SUBQHSE/BLL/OpenService/FileInsertService.cs index 3f19aac..f36cd23 100644 --- a/SUBQHSE/BLL/OpenService/FileInsertService.cs +++ b/SUBQHSE/BLL/OpenService/FileInsertService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Collections; using System.IO; +using System.Text.RegularExpressions; using System.Web; namespace BLL @@ -62,17 +63,28 @@ namespace BLL if (strs.Count() > i) { string physicalpath = Funs.RootPath; - //HttpContext.Current.Request.PhysicalApplicationPath; - string fullPath = physicalpath + strs[i]; + string fpath = strs[i]; + string fullPath = physicalpath + fpath; if (!File.Exists(fullPath)) { byte[] fileContext = item; - int index = fullPath.LastIndexOf("\\"); - string filePath = fullPath.Substring(0, index); + string fileName = Regex.Match(fullPath, @"[^/\\?]+(\?.*)?$").Value; + string filePath = fullPath.Replace(fileName, ""); + //int index = fullPath.LastIndexOf("\\"); + //string filePath = fullPath.Substring(0, index) ; + //string filePath = index > 0 ? fullPath.Substring(0, index) : fullPath; - if (!Directory.Exists(filePath)) + try { - Directory.CreateDirectory(filePath); + if (!Directory.Exists(filePath)) + { + Directory.CreateDirectory(filePath); + } + } + catch (Exception ex) + { + ErrLogInfo.WriteLog($"附件【{filePath}】获取异常!"); + //continue; } //string savePath = fullPath + fileName; diff --git a/SUBQHSE/BLL/WebService/CNCECHSSEGetWebService.cs b/SUBQHSE/BLL/WebService/CNCECHSSEGetWebService.cs index f266e86..7297023 100644 --- a/SUBQHSE/BLL/WebService/CNCECHSSEGetWebService.cs +++ b/SUBQHSE/BLL/WebService/CNCECHSSEGetWebService.cs @@ -1714,8 +1714,9 @@ ToKeyId = x.ToKeyId2, AttachSource = x.AttachSource2, AttachUrl = x.AttachUrl2, - ////附件转为字节传送 - FileContext = FileStructService.GetMoreFileStructByAttachUrl(x.AttachUrl2), + FilePath = Funs.SGGLUrl + //////附件转为字节传送 + //FileContext = FileStructService.GetMoreFileStructByAttachUrl(x.AttachUrl2), }; string baseurl = SysConstSetService.CNCECPath + "/api/HSSEData/UpDCGLCheckRectifyTable"; diff --git a/SUBQHSE/Model/APIItem/CNCEC/DCGLCheckRectifyItem.cs b/SUBQHSE/Model/APIItem/CNCEC/DCGLCheckRectifyItem.cs index 55be12d..7c7c575 100644 --- a/SUBQHSE/Model/APIItem/CNCEC/DCGLCheckRectifyItem.cs +++ b/SUBQHSE/Model/APIItem/CNCEC/DCGLCheckRectifyItem.cs @@ -264,6 +264,15 @@ set; } + /// + /// 附件路径域名地址 + /// + public string FilePath + { + get; + set; + } + /// /// 附件路径 ///