From ba68b95a50df4ec6359880d552bec206122aebb5 Mon Sep 17 00:00:00 2001 From: wyf Date: Mon, 9 Jun 2025 08:05:15 +0000 Subject: [PATCH] SVN r693 SVN-Revision: r693 --- 插件库/Lskj.Control/Model/MyControl.cs | 46 +++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/插件库/Lskj.Control/Model/MyControl.cs b/插件库/Lskj.Control/Model/MyControl.cs index 3375f3e..5c1e7cb 100644 --- a/插件库/Lskj.Control/Model/MyControl.cs +++ b/插件库/Lskj.Control/Model/MyControl.cs @@ -2984,9 +2984,10 @@ namespace Lskj.Control.Model if (!string.IsNullOrEmpty(token)) { string speciesno = "010106"; + GetFileCodeInfo(Path.GetFileNameWithoutExtension(filePath), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); byte[] fileBytes = UploadFileUtil.ConvertFileToBytes(filePath); string fileStream = Convert.ToBase64String(fileBytes); - string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{Model.ModuleCode}') and speciesno = '{speciesno}' and sname = '{Path.GetFileName(filePath).Replace(" ", "")}'"; + string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{Model.ModuleCode}') and speciesno = '{speciesno}' and sname like '{sourceCode}%'"; DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql); if (deleteTable != null && deleteTable.Rows.Count > 0) { @@ -3003,7 +3004,7 @@ namespace Lskj.Control.Model HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult); } } - string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&speciesno={8}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}"; + string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&speciesno={8}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}&confirm=1"; postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, Model.ModuleCode, HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(Path.GetFileName(filePath)), "DoWebUpload", speciesno); bool isUpload = UploadFileUtil.UploadFile(token, postUrl, fileStream, out string fileId, out string rtnMsg); if (!isUpload) @@ -3164,8 +3165,45 @@ namespace Lskj.Control.Model return result == 1; } - - + /// + /// 解析code信息 + /// + /// + /// + /// + /// + /// + private void GetFileCodeInfo(string sourceCode, out string code, out string name, out string bb, out int bc) + { + string namepattern = @"^(.*-S[A-Z]\d*)(.*)$"; + string pattern = @"^(.*?)(\d+)?$"; + string childcode = ""; + string childname = ""; + string childsourceCode = ""; + string childsourceBB = ""; + int childsourceBC = 0; + Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(sourceCode).Trim(), namepattern); + if (namematch.Success) + { + childcode = namematch.Groups[1].Value.Trim(); + childname = namematch.Groups[2].Value.Trim(); + } + Match match = Regex.Match(childcode, pattern); + if (match.Success) + { + childsourceCode = match.Groups[1].Value; + int.TryParse(match.Groups[2].Value, out childsourceBC);//版次 + Match bbMatch = Regex.Match(childsourceCode, @"^.*?([A-Za-z]+)(\d*)$"); + if (bbMatch.Success) + { + childsourceBB = bbMatch.Groups[1].Value.Trim(); + } + } + code = childsourceCode; + name = childname; + bb = childsourceBB; + bc = childsourceBC; + } /// /// 说明:执行最后一次查询