diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index e64fa8c..3aae8b9 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -76,7 +76,7 @@ namespace Lskj.PubBomImport FileInfo childInfo = fileInfos.Where(n => n.Name.StartsWith(fileName)).FirstOrDefault(); if (childInfo == null) { - string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%'"; + string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%' and speciesno = '010106' and parentId in (select dirid from p_fm_directorytab where dllcoid = '1000202'"; DataRow fileRow = BaseImpl.GetDataRowResult(fileSql); string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : ""; @@ -306,7 +306,7 @@ namespace Lskj.PubBomImport string fileName = (parentRow["图号"] + "").Trim(); if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD")) { - string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%'"; + string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%' and speciesno = '010106' and parentId in (select dirid from p_fm_directorytab where dllcoid = '1000202'"; DataRow fileRow = BaseImpl.GetDataRowResult(fileSql); string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : ""; @@ -752,7 +752,7 @@ namespace Lskj.PubBomImport if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD")) { - string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%'"; + string fileSql = $"select webpath,sName from P_fm_FileTab where sName like '{fileName}%' and speciesno = '010106' and parentId in (select dirid from p_fm_directorytab where dllcoid = '1000202')"; DataRow fileRow = BaseImpl.GetDataRowResult(fileSql); string webpath = fileRow != null ? fileRow["webpath"] + "" : ""; string sName = fileRow != null ? fileRow["sName"] + "" : ""; @@ -1618,7 +1618,7 @@ namespace Lskj.PubBomImport int finishCount = (int)((decimal)(1 + childIndex) / (sourceTable.Rows.Count) * 100); Model = frmMain.Model; DataRow execRow = BaseImpl.GetDataRowResult($"select * from p_bomImportExecTab where isnull(success,0) = 0 and guid = '{execGuid}'"); - if (execRow != null) + if (!string.IsNullOrEmpty(execGuid) && execRow != null) { string masterSql = execRow["masterSql"] + ""; string detailSql = execRow["detailSql"] + ""; @@ -1634,37 +1634,34 @@ namespace Lskj.PubBomImport if (result == 1) { BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'"); - using (WebClient webClient = new WebClient()) - { - try - { - DataRow fileRow = BaseImpl.GetDataRowResult($"select webpath,sname from p_fm_filetab where fileId = '{fileId}'"); - if (fileRow != null) - { - string webpath = fileRow["webpath"] + ""; - string sName = fileRow["sname"] + ""; - webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}"; - string url = $"{SystemInfo.Instance.OAUrl}/{webpath}"; - string tempFileName = $"BomImportTemp/{sName}"; - webClient.DownloadFile(url, tempFileName); - bool isUpload = UploadFileToAudit(tempFileName, productid, "010106", out string msg, out string otherFieldId); - } - else - { - throw new Exception($"Bom明细附件{productid}获取失败\r\nBom导入失败"); - } - } - catch (Exception) - { - throw new Exception($"Bom明细附件{productid}获取失败\r\nBom导入失败"); - } - } } else { throw new Exception($"保存Bom失败\r\n{tipMsg}"); } } + using (WebClient webClient = new WebClient()) + { + try + { + int.TryParse(fileId, out int convertFileId); + DataRow fileRow = BaseImpl.GetDataRowResult($"select webpath,sname from p_fm_filetab where fileId = '{fileId}'"); + if (convertFileId > 0 && fileRow != null) + { + string webpath = fileRow["webpath"] + ""; + string sName = fileRow["sname"] + ""; + webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}"; + string url = $"{SystemInfo.Instance.OAUrl}/{webpath}"; + string tempFileName = $"BomImportTemp/{sName}"; + webClient.DownloadFile(url, tempFileName); + bool isUpload = UploadFileToAudit(tempFileName, productid, "010106", out string msg, out string otherFieldId); + } + } + catch (Exception) + { + throw new Exception($"Bom明细附件{productid}获取失败\r\nBom导入失败"); + } + } } this.DialogResult = DialogResult.OK; }