SVN r577
SVN-Revision: r577
This commit is contained in:
@@ -1153,9 +1153,11 @@ namespace Lskj.PubBomImport
|
||||
{
|
||||
try
|
||||
{
|
||||
string namepattern = @"^([A-Z]+(?:-[A-Z]+)*(?:-\d+)+-[A-Z]+\d*)\s*(.*)$";
|
||||
//string namepattern = @"^(.+?)\s+(.+)$";
|
||||
string pattern = @"^(.*?)(\d+)?$";
|
||||
if (Directory.Exists("BomImportTemp"))
|
||||
{
|
||||
Directory.Delete("BomImportTemp", true);
|
||||
}
|
||||
Directory.CreateDirectory("BomImportTemp");
|
||||
int execOrder = 1;
|
||||
DataRow mxRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith("MX")).FirstOrDefault();
|
||||
if (mxRow != null)
|
||||
@@ -1175,49 +1177,28 @@ namespace Lskj.PubBomImport
|
||||
FileInfo mxInfo = new FileInfo(mxDirPath);
|
||||
if (mxInfo != null)
|
||||
{
|
||||
string mxcode = "";
|
||||
string mxname = "";
|
||||
string mxsourceCode = "";
|
||||
string mxsourceBB = "";
|
||||
int mxsourceBC = 0;
|
||||
Match namematch = Regex.Match(Path.GetFileNameWithoutExtension(mxInfo.Name).Trim(), namepattern);
|
||||
if (namematch.Success)
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(mxInfo.Name).Trim(), out string mxsourceCode, out string mxname, out string mxsourceBB, out int mxsourceBC);
|
||||
DataTable mxfiletable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{mxsourceCode}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{mxsourceCode}%'");
|
||||
int mxMaxBc = 0;
|
||||
string mxMaxBcFileId = "-1";
|
||||
foreach (DataRow mxfileRow in mxfiletable.Rows)
|
||||
{
|
||||
mxcode = namematch.Groups[1].Value.Trim();
|
||||
mxname = namematch.Groups[2].Value.Trim();
|
||||
string fileName = mxfileRow["sname"] + "";
|
||||
string fileId = mxfileRow["fileId"] + "";
|
||||
GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC);
|
||||
if (fileBC >= mxMaxBc)
|
||||
{
|
||||
mxMaxBc = fileBC;
|
||||
mxMaxBcFileId = fileId;
|
||||
}
|
||||
Match match = Regex.Match(mxcode, pattern);
|
||||
if (match.Success)
|
||||
{
|
||||
mxsourceCode = match.Groups[1].Value;
|
||||
int.TryParse(match.Groups[2].Value, out mxsourceBC);//版次
|
||||
Match bbMatch = Regex.Match(mxsourceCode, @"^.*?([A-Za-z]+)(\d*)$");
|
||||
if (bbMatch.Success)
|
||||
{
|
||||
mxsourceBB = bbMatch.Groups[1].Value.Trim();
|
||||
}
|
||||
if (mxsourceBC > mxMaxBc && mxfiletable.Rows.Count > 0)
|
||||
{
|
||||
throw new Exception($"{mxsourceCode}的版次为{mxsourceBC},大于最大版次{mxMaxBc}\r\n请进行变更");
|
||||
}
|
||||
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||
DataTable parentTable = ExcelToDatatable(mxInfo.FullName, Model, "", 5);
|
||||
parentTable = parentTable.Rows.Cast<DataRow>().Where(n => int.TryParse(n["序号"] + "", out _) && !string.IsNullOrEmpty(n["图号"] + "") && !string.IsNullOrEmpty(n["名称"] + "")).ToList().CopyToDataTable();
|
||||
foreach (DataRow parentRow in parentTable.Rows)
|
||||
{
|
||||
string fileName = (parentRow["图号"] + "").Trim();
|
||||
if (fileName.StartsWith("QD") || fileName.StartsWith("ZZQD"))
|
||||
{
|
||||
DataRow childRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(fileName)).FirstOrDefault();
|
||||
if (childRow != null)
|
||||
{
|
||||
string childFileName = childRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childRow["BomFieldNameDir"] + "";
|
||||
FileInfo childInfo = new FileInfo(childDirPath);
|
||||
if (childInfo == null)
|
||||
{
|
||||
throw new Exception($"MX明细中不包含文件{childFileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (DataRow dataRow in parentTable.Rows)
|
||||
{
|
||||
@@ -1243,66 +1224,88 @@ namespace Lskj.PubBomImport
|
||||
bool isUpload = false;
|
||||
string msg = "";
|
||||
DataRow parentProductRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{productId}'");
|
||||
Dictionary<string, DataRow> maxBcFileDic = new Dictionary<string, DataRow>();
|
||||
Dictionary<string, DataTable> fileTableDic = new Dictionary<string, DataTable>();
|
||||
if (parentProductRow == null)
|
||||
{
|
||||
frmBillInfo.OnBillAdd();
|
||||
SetProcessBar(0, 0);
|
||||
SetProcessMsg($"正在导入:{Path.GetFileName(mxInfo.FullName)}");
|
||||
DataTable childTable = frmBillInfo.GcMainView.GridControl.DataSourceTable().Clone();
|
||||
//foreach (GridColumn gridColumn in frmBillInfo.GcMainView.Columns)
|
||||
//{
|
||||
// if (!childTable.Columns.Contains(gridColumn.FieldName))
|
||||
// {
|
||||
// childTable.Columns.Add(gridColumn.FieldName, gridColumn.ColumnType);
|
||||
// }
|
||||
//}
|
||||
StringBuilder insertbulider = new StringBuilder();
|
||||
insertbulider.AppendLine($"delete FileAttachmentMapping where MaterialCode = '{productId}';");
|
||||
insertbulider.AppendLine($"insert into FileAttachmentMapping (MaterialCode,MxFileName,RelatedAttachmentName) values ('{productId}','{mxsourceCode + mxsourceBC}','{mxsourceCode}');");
|
||||
foreach (DataRow parentRow in parentTable.Rows)
|
||||
{
|
||||
int.TryParse(parentRow["套数"] + "", out int tamount);
|
||||
string code = (parentRow["图号"] + "").Trim();
|
||||
if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
|
||||
insertbulider.AppendLine($"insert into FileAttachmentMapping (MaterialCode,MxFileName,RelatedAttachmentName) values ('{productId}','{mxsourceCode + mxsourceBC}','{code}');");
|
||||
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{code}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{code}%'");
|
||||
fileTableDic[code] = filetable;
|
||||
int childMaxBc = 0;
|
||||
foreach (DataRow fileRow in filetable.Rows)
|
||||
{
|
||||
string fileName = fileRow["sname"] + "";
|
||||
string fileId = fileRow["fileId"] + "";
|
||||
GetFileCodeInfo(fileName, out string fileCode, out string name, out string fileBB, out int fileBC);
|
||||
if (fileBC >= childMaxBc)
|
||||
{
|
||||
childMaxBc = fileBC;
|
||||
maxBcFileDic[code] = fileRow;
|
||||
}
|
||||
}
|
||||
//判断code是否已经上传,如果已经上传则不再上传,
|
||||
//如果附件不存在文件夹中,则直接使用最新的
|
||||
//如果附件不存在则提示
|
||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||
if (childInfoRow != null)
|
||||
{
|
||||
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
FileInfo childInfo = new FileInfo(childDirPath);
|
||||
if (childInfo == null)
|
||||
if (childInfo != null)
|
||||
{
|
||||
throw new Exception($"MX明细中不包含文件{childFileName}");
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
|
||||
//如果文件夹中有附件,则比较版次,如果大于最大版次,则提示
|
||||
if (childsourceBC > childMaxBc && filetable.Rows.Count > 0)
|
||||
{
|
||||
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
|
||||
}
|
||||
}
|
||||
if (childInfo == null && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
string webpath = maxBcFileDic[code]["webpath"] + "";
|
||||
string sName = maxBcFileDic[code]["sName"] + "";
|
||||
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
|
||||
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
|
||||
string tempFileName = $"BomImportTemp/{sName}";
|
||||
if (!File.Exists(tempFileName))
|
||||
{
|
||||
webClient.DownloadFile(url, tempFileName);
|
||||
}
|
||||
childInfo = new FileInfo(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
string childcode = "";
|
||||
string childname = "";
|
||||
string childsourceCode = "";
|
||||
string childsourceBB = "";
|
||||
int childsourceBC = 0;
|
||||
namematch = Regex.Match(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), namepattern);
|
||||
if (namematch.Success)
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string childsourceCode, out string childname, out string childsourceBB, out int childsourceBC);
|
||||
//如果文件夹中有附件,则比较版次,如果大于最大版次,则提示
|
||||
if (childsourceBC > childMaxBc && filetable.Rows.Count > 0)
|
||||
{
|
||||
childcode = namematch.Groups[1].Value.Trim();
|
||||
childname = namematch.Groups[2].Value.Trim();
|
||||
}
|
||||
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();
|
||||
}
|
||||
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
|
||||
}
|
||||
if (code.StartsWith("ZZQD"))
|
||||
{
|
||||
DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
|
||||
//frmMain.Invoke(new Action(() =>
|
||||
//{
|
||||
// zzqdTable = frmMain.ToExcelDataTable(childInfo.FullName, out int count, out int errorCount, true);
|
||||
//}));
|
||||
DataView filterDataView = new DataView(zzqdTable);
|
||||
try
|
||||
{
|
||||
@@ -1329,7 +1332,7 @@ namespace Lskj.PubBomImport
|
||||
childTable.Rows.Add(childRow);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (code.StartsWith("QD"))
|
||||
{
|
||||
DataRow childRow = childTable.NewRow();
|
||||
childRow["ProductId"] = parentRow["图号"] + "";
|
||||
@@ -1342,16 +1345,30 @@ namespace Lskj.PubBomImport
|
||||
childTable.Rows.Add(childRow);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception($"{code}的附件不存在,请检查文件");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception($"{code}的附件不存在,请检查文件");
|
||||
}
|
||||
}
|
||||
}
|
||||
BaseImpl.ExecSqlValue(insertbulider.ToString());
|
||||
SetProcessBar(20, 0);
|
||||
if (childTable.Rows.Count == 0)
|
||||
{
|
||||
throw new Exception($"MX明细数据为空");
|
||||
throw new Exception($"MX明细数据不能空");
|
||||
}
|
||||
SetProcessBar(40, 0);
|
||||
string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productId}') as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid,'{mxcode}' as bak,'{mxsourceBB}' as bombb,'{mxsourceBC}' as bombc";
|
||||
string billMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{productId}') as billdocument_id,'0' affirmer,'0' rtagid,'{productId}' as productid,'{mxsourceCode}' as bak,'{mxsourceBB}' as bombb,'{mxsourceBC}' as bombc";
|
||||
// 处理单据表头数据
|
||||
DataRow masterRow = BillImpl.GetDataRowResult(billMasterSql);
|
||||
SetProcessBar(60, 0);
|
||||
@@ -1359,23 +1376,21 @@ namespace Lskj.PubBomImport
|
||||
string guid = Guid.NewGuid() + "";
|
||||
frmBillInfo.BillSaveSql(guid);
|
||||
SetProcessBar(80, 0);
|
||||
//确认不反写子集
|
||||
//string billdocumentId = Model.MaintabFocusedRow["单据编号"] + "";
|
||||
//string billdocumentId = BaseImpl.GetResult("") + "";//
|
||||
//string idValue = BaseImpl.GetResult($"select top 1 billdocument_id from bom_billListTab where ParentProduct = '{productId}'") + "";
|
||||
//string updateParentVerSql = @"update bom_BillListTab set Ver = '{0}' where Billdocument_Id='{1}' and ProductId='{0}'";
|
||||
//SqlHelper.ExecuteNonQuery(string.Format(updateParentVerSql, idValue, billdocumentId));
|
||||
//上传文件
|
||||
isUpload = UploadFileToAudit(mxInfo.FullName, productId, "010106", out msg, out string fileId);
|
||||
string uploadFileId = mxMaxBcFileId;
|
||||
if (mxfiletable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(mxInfo.FullName, mxsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{mxInfo.Name}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (mxRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(fileId, out int qms_laddf_FileId);
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
mxRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
if (mxRow.Table.Columns.Contains("qms_laddf_Exec"))
|
||||
@@ -1391,12 +1406,20 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
else
|
||||
{
|
||||
isUpload = UploadFileToAudit(mxInfo.FullName, productId, "010106", out msg, out string fileId);
|
||||
string uploadFileId = mxMaxBcFileId;
|
||||
if (mxfiletable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(mxInfo.FullName, mxsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{mxInfo.Name}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (mxRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(fileId, out int qms_laddf_FileId);
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
mxRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
@@ -1411,6 +1434,7 @@ namespace Lskj.PubBomImport
|
||||
int finishCount = (int)((decimal)(1 + nowCount) / (parentTable.Rows.Count + 1) * 100);
|
||||
int.TryParse(dataRow["套数"] + "", out int tamount);
|
||||
string code = (dataRow["图号"] + "").Trim();
|
||||
DataTable filetable = fileTableDic.ContainsKey(code) ? fileTableDic[code] : null;
|
||||
if (code.StartsWith("QD"))
|
||||
{
|
||||
DataRow childInfoRow = selectRows.Where(n => (n[Model.AfterBomFieldName] + "").StartsWith(code)).FirstOrDefault();
|
||||
@@ -1419,35 +1443,36 @@ namespace Lskj.PubBomImport
|
||||
string childFileName = childInfoRow[Model.AfterBomFieldName] + "";
|
||||
string childDirPath = childInfoRow["BomFieldNameDir"] + "";
|
||||
FileInfo childInfo = new FileInfo(childDirPath);
|
||||
if (childInfo == null && maxBcFileDic.ContainsKey(code) && maxBcFileDic[code] != null)
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
string webpath = maxBcFileDic[code]["webpath"] + "";
|
||||
string sName = maxBcFileDic[code]["sName"] + "";
|
||||
webpath = webpath.StartsWith("/") ? webpath : $"/{webpath}";
|
||||
string url = $"{SystemInfo.Instance.OAUrl}/{webpath}";
|
||||
string tempFileName = $"BomImportTemp/{sName}";
|
||||
if (!File.Exists(tempFileName))
|
||||
{
|
||||
webClient.DownloadFile(url, tempFileName);
|
||||
}
|
||||
childInfo = new FileInfo(tempFileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception($"Bom明细附件{code}获取失败\r\nBom导入失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (childInfo == null)
|
||||
{
|
||||
throw new Exception($"MX明细中不包含文件{childFileName}");
|
||||
throw new Exception($"MX明细中的{code}文件不存在");
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
|
||||
string qdcode = "";
|
||||
string qdname = "";
|
||||
string qdsourceCode = "";
|
||||
string qdsourceBB = "";
|
||||
int qdsourceBC = 0;
|
||||
namematch = Regex.Match(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), namepattern);
|
||||
if (namematch.Success)
|
||||
{
|
||||
qdcode = namematch.Groups[1].Value.Trim();
|
||||
qdname = namematch.Groups[2].Value.Trim();
|
||||
}
|
||||
match = Regex.Match(qdcode, pattern);
|
||||
if (match.Success)
|
||||
{
|
||||
qdsourceCode = match.Groups[1].Value;
|
||||
int.TryParse(match.Groups[2].Value, out qdsourceBC);//版次
|
||||
Match bbMatch = Regex.Match(qdsourceCode, @"^.*?([A-Za-z]+)(\d*)$");
|
||||
if (bbMatch.Success)
|
||||
{
|
||||
qdsourceBB = bbMatch.Groups[1].Value.Trim();
|
||||
}
|
||||
}
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC);
|
||||
DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid='{code}'");
|
||||
if (productRow == null)
|
||||
{
|
||||
@@ -1473,7 +1498,7 @@ namespace Lskj.PubBomImport
|
||||
throw new Exception($"{code}明细数据为空");
|
||||
}
|
||||
SetProcessBar(40, allCount);
|
||||
string childBillMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{code}') as billdocument_id,'0' affirmer,'0' rtagid,'{code}' as productid,'{qdcode}' as bak,'{qdsourceBB}' as bombb,'{qdsourceBC}' as bombc";
|
||||
string childBillMasterSql = $"select (select top 1 billdocument_id from bom_BillTab where productid='{code}') as billdocument_id,'0' affirmer,'0' rtagid,'{code}' as productid,'{qdsourceCode}' as bak,'{qdsourceBB}' as bombb,'{qdsourceBC}' as bombc";
|
||||
// 处理单据表头数据
|
||||
DataRow childMasterRow = BillImpl.GetDataRowResult(childBillMasterSql);
|
||||
SetProcessBar(60, allCount);
|
||||
@@ -1492,16 +1517,20 @@ namespace Lskj.PubBomImport
|
||||
//string updateChildVerSql = @"update bom_BillListTab set Ver = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{0}') where Billdocument_Id = (select top 1 billdocument_id from bom_billListTab where ParentProduct = '{1}') and ProductId='{0}'";
|
||||
//SqlHelper.ExecuteNonQuery(string.Format(updateChildVerSql, code, productId));
|
||||
SetProcessBar(80, allCount);
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, code, "010106", out msg, out string childFieldId);
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{childInfo.Name}附件上传失败\r\n{msg}");
|
||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(childFieldId, out int qms_laddf_FileId);
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_Exec"))
|
||||
@@ -1521,16 +1550,20 @@ namespace Lskj.PubBomImport
|
||||
else
|
||||
{
|
||||
SetProcessBar(0, allCount);
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, code, "010106", out msg, out string existFieldId);
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{childInfo.Name}附件上传失败\r\n{msg}");
|
||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(existFieldId, out int qms_laddf_FileId);
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
@@ -1558,16 +1591,21 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
if (childInfo != null)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, productId, "010106", out msg, out string otherFieldId);
|
||||
GetFileCodeInfo(Path.GetFileNameWithoutExtension(childInfo.Name).Trim(), out string qdsourceCode, out string qdname, out string qdsourceBB, out int qdsourceBC);
|
||||
string uploadFileId = maxBcFileDic.ContainsKey(code) ? maxBcFileDic[code]["fileId"] + "" : "-1";
|
||||
if (filetable.Rows.Count == 0)
|
||||
{
|
||||
isUpload = UploadFileToAudit(childInfo.FullName, qdsourceCode, "010106", out msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{childInfo.Name}附件上传失败\r\n{msg}");
|
||||
throw new Exception($"{code}附件上传失败\r\n{msg}");
|
||||
}
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (childInfoRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(otherFieldId, out int qms_laddf_FileId);
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
childInfoRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
@@ -1641,6 +1679,7 @@ namespace Lskj.PubBomImport
|
||||
{
|
||||
string execGuid = sourceRow["qms_wjgg_uuid"] + "";
|
||||
string productid = sourceRow["qms_wjgg_productid"] + "";
|
||||
string afterFilename = sourceRow["qms_wjgg_NewFileName"] + "";
|
||||
int.TryParse(sourceRow["fileId"] + "", out int copyFileId);
|
||||
int.TryParse(sourceRow["qms_wjgg_fileId"] + "", out int coverFileId);
|
||||
int coverTag = (sourceRow["qms_wjgg_iscover"] + "").Equals("True") ? 1 : 0;
|
||||
@@ -1661,11 +1700,12 @@ namespace Lskj.PubBomImport
|
||||
int result = BillImpl.BillSave(masterSql, detailSql, detailTable, ref billNo, detailGuid, billSeq, billWay, comfirm, out string tipMsg, auditFlag, newVer);
|
||||
if (result == 1)
|
||||
{
|
||||
GetFileCodeInfo(afterFilename, out string fileCode, out string name, out string fileBB, out int fileBC);
|
||||
BaseImpl.ExecSqlValue($"update p_bomImportExecTab set success = 1 where guid = '{execGuid}'");
|
||||
List<SqlParameter> sqlParamList = new List<SqlParameter>();
|
||||
sqlParamList.Add(new SqlParameter("@copyFileId", SqlDbType.Int) { Value = copyFileId });
|
||||
sqlParamList.Add(new SqlParameter("@copyToModule", SqlDbType.VarChar, 100) { Value = "1000202" });
|
||||
sqlParamList.Add(new SqlParameter("@copyToIdValue", SqlDbType.VarChar, 100) { Value = productid });
|
||||
sqlParamList.Add(new SqlParameter("@copyToIdValue", SqlDbType.VarChar, 100) { Value = fileCode });
|
||||
sqlParamList.Add(new SqlParameter("@coverFileId", SqlDbType.Int) { Value = coverFileId });
|
||||
sqlParamList.Add(new SqlParameter("@coverTag", SqlDbType.Int) { Value = coverTag });
|
||||
BaseImpl.ExecProcedure("p_CopyAttcFileInfo", sqlParamList.ToArray());
|
||||
@@ -2240,23 +2280,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(deleteUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete");
|
||||
HttpHelper.Setting("application/x-www-form-urlencoded", null, null);
|
||||
Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>();
|
||||
deleteHeaderDic.Add("Authorization", $"Bearer {token}");
|
||||
HttpWebResponse deleteWebResponse = HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult);
|
||||
}
|
||||
}
|
||||
//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(deleteUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete");
|
||||
// HttpHelper.Setting("application/x-www-form-urlencoded", null, null);
|
||||
// Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>();
|
||||
// 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 = "";
|
||||
@@ -2310,4 +2350,52 @@ namespace Lskj.PubBomImport
|
||||
throw new Exception($"文件{Path.GetFileName(filePath)}上传失败\r\n{ex.Message}");
|
||||
isUpload = false;
|
||||
}
|
||||
msg = returnM
|
||||
msg = returnMsg;
|
||||
outFileId = fileId;
|
||||
return isUpload;
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件转换byte[]
|
||||
/// </summary>
|
||||
/// <param name="filePath">附件路径</param>
|
||||
/// <returns>二进制</returns>
|
||||
private byte[] ConvertFileToBytes(string filePath)
|
||||
{
|
||||
byte[] bytContent = null;
|
||||
System.IO.FileStream fs = null;
|
||||
System.IO.BinaryReader br = null;
|
||||
try
|
||||
{
|
||||
fs = new FileStream(filePath, System.IO.FileMode.Open);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fs != null)
|
||||
br = new BinaryReader((Stream)fs);
|
||||
if (br != null)
|
||||
bytContent = br.ReadBytes((Int32)fs.Length);
|
||||
if (fs != null)
|
||||
fs.Dispose();
|
||||
}
|
||||
return bytContent;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解析code信息
|
||||
/// </summary>
|
||||
/// <param name="sourceCode"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="bb"></param>
|
||||
/// <param name="bc"></param>
|
||||
private void GetFileCodeInfo(string sourceCode, out string code, out string name, out string bb, out int bc)
|
||||
{
|
||||
string namepattern = @"^([A-Z]+(?:-[A-Z0-9]+)*)(?:\s+(.*))?$";
|
||||
string pattern = @"^(.*?)(\d+)?$";
|
||||
string childcode = "";
|
||||
string childname = "";
|
||||
string childsourceCode = "";
|
||||
|
||||
Reference in New Issue
Block a user