From 2e008744139dbb443f9013fe4b6940a1520198b8 Mon Sep 17 00:00:00 2001 From: wyf Date: Thu, 8 May 2025 07:19:44 +0000 Subject: [PATCH] SVN r553 SVN-Revision: r553 --- 插件库/Lskj.PubBomImport/FrmProgress.cs | 74 ++++++++++++------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index d73ca1e..cd0b39f 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -1983,6 +1983,23 @@ namespace Lskj.PubBomImport } if (!string.IsNullOrEmpty(token)) { + string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '1000202') and speciesno = '{speciesno}' and sname = '{name.Replace(" ", "")}'"; + DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql); + if (deleteTable != null && deleteTable.Rows.Count > 0) + { + foreach (DataRow deleteRow in deleteTable.Rows) + { + string field = HttpUtility.UrlEncode(deleteRow["fileId"] + ""); + string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + ""); + //删除文件 + string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; + deleteUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete"); + HttpHelper.Setting("application/x-www-form-urlencoded", null, null); + Dictionary deleteHeaderDic = new Dictionary(); + deleteHeaderDic.Add("Authorization", $"Bearer {token}"); + HttpWebResponse deleteWebResponse = HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult); + } + } postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, "1000202", HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(name), "DoWebUpload", speciesno); HttpTools.setting("application/x-www-form-urlencoded", null, null); string result = ""; @@ -1992,7 +2009,7 @@ namespace Lskj.PubBomImport HttpWebResponse webResponse = HttpTools.Post(postUrl, fileStream, null, headerDic, HttpTools.Method.POST, out cookieCollection, out result); if (webResponse != null && !string.IsNullOrEmpty(result)) { - JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); + JObject jsonObject = (JObject)JsonConvert.DeserializeObject(result); string isSuccess = jsonObject["success"] + ""; if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) { @@ -2092,7 +2109,23 @@ namespace Lskj.PubBomImport } if (!string.IsNullOrEmpty(token)) { - //DeleteFileExists(token, name, Model.ModuleCode, idValue, speciesno); + string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '1000202') and speciesno = '{speciesno}' and sname = '{name.Replace(" ", "")}'"; + DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql); + if (deleteTable != null && deleteTable.Rows.Count > 0) + { + foreach (DataRow deleteRow in deleteTable.Rows) + { + string field = HttpUtility.UrlEncode(deleteRow["fileId"] + ""); + string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + ""); + //删除文件 + string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; + deleteUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete"); + HttpHelper.Setting("application/x-www-form-urlencoded", null, null); + Dictionary deleteHeaderDic = new Dictionary(); + deleteHeaderDic.Add("Authorization", $"Bearer {token}"); + HttpWebResponse deleteWebResponse = HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult); + } + } postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, "1000202", HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(name), "DoWebUpload", speciesno); HttpTools.setting("application/x-www-form-urlencoded", null, null); string result = ""; @@ -2145,39 +2178,4 @@ namespace Lskj.PubBomImport throw new Exception($"文件{Path.GetFileName(filePath)}上传失败\r\n{ex.Message}"); isUpload = false; } - msg = returnMsg; - outFileId = fileId; - return isUpload; - } - /// - /// 删除已经存在的附件 - /// - private void DeleteFileExists(string token, string filename, string moduleid, string idValue, string speciesno) - { - try - { - if (!string.IsNullOrEmpty(token)) - { - DataTable fileTable = BaseImpl.GetDataTableResult($"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{moduleid}') and speciesno = '{speciesno}' and sname = '{filename.Replace(" ", "")}'"); - if (fileTable != null && fileTable.Rows.Count > 0) - { - foreach (DataRow deleteRow in fileTable.Rows) - { - string field = HttpUtility.UrlEncode(deleteRow["fileId"] + ""); - string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + ""); - //删除文件 - string postUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; - postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete"); - HttpTools.setting("application/x-www-form-urlencoded", null, null); - string result = ""; - CookieCollection cookieCollection = null; - HttpWebResponse webResponse = HttpTools.Post(postUrl, "", null, HttpTools.Method.POST, out cookieCollection, out result); - if (webResponse != null && !string.IsNullOrEmpty(result)) - { - } - } - } - } - } - catch (Exception ex) - \ No newline at end of file + msg = returnM \ No newline at end of file