SVN r664
SVN-Revision: r664
This commit is contained in:
@@ -270,12 +270,14 @@ namespace Lskj.PubBomImport
|
||||
int execOrder = 1;
|
||||
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||
string bomOtherAddMode = selectRows[0]["qms_laddf_mode"] + "";
|
||||
string speciesno = selectRows[0]["qms_laddf_speciesno"] + "";
|
||||
if (string.IsNullOrEmpty(bomOtherAddMode))
|
||||
{
|
||||
throw new Exception("未选择上传模式");
|
||||
}
|
||||
if (bomOtherAddMode.Equals("9040"))//有规则
|
||||
{
|
||||
Dictionary<string, DataRow> maxfileRowDic = new Dictionary<string, DataRow>();
|
||||
string pattern = @"^(\S+)\s+(\S+)\s+(.+)$";
|
||||
foreach (DataRow selectRow in selectRows)
|
||||
{
|
||||
@@ -285,19 +287,10 @@ namespace Lskj.PubBomImport
|
||||
if (fileInfo != null)
|
||||
{
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||
var match = Regex.Match(fileNameWithoutExtension, pattern);
|
||||
string code = "";
|
||||
string spec = "";
|
||||
string name = "";
|
||||
if (match.Success)
|
||||
bool isMatch = GetOtherFileCodeInfo(fileInfo.Name, out string code, out string spec, out string name, out string extension, out string bb, out int bc);
|
||||
if (!isMatch)
|
||||
{
|
||||
code = match.Groups[1].Value.Trim();
|
||||
spec = match.Groups[2].Value.Trim();
|
||||
name = match.Groups[3].Value.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}不满足规则");
|
||||
throw new Exception($"{fileInfo.Name}\r\n文件名不符合规则");
|
||||
}
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
@@ -325,10 +318,20 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
else
|
||||
{
|
||||
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{code}' and dllcoid = '1000202') and speciesno = '010105' and sname = '{ fileInfo.Name}'");
|
||||
if (filetable.Rows.Count > 0)
|
||||
if (bc > 0)
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}的附件已存在");
|
||||
throw new Exception($"{fileInfo.Name}\r\n不为0的版次不允许新增,请进行修改");
|
||||
}
|
||||
DataRow maxRow = BaseImpl.GetDataRowResult($"exec dbo.p_CheckLxFileRevision N'{fileInfo.Name}','{speciesno}';");
|
||||
maxfileRowDic[fileInfo.Name] = maxRow;
|
||||
if (maxRow != null)//如果存在则不允许上传
|
||||
{
|
||||
int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
||||
int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
||||
if (newbb > oldbb)
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n版本号大于最大版本号,请进行修改");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,26 +360,37 @@ namespace Lskj.PubBomImport
|
||||
FileInfo fileInfo = new FileInfo(dirPath);
|
||||
if (fileInfo != null)
|
||||
{
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||
var match = Regex.Match(fileNameWithoutExtension, pattern);
|
||||
string code = "";
|
||||
string spec = "";
|
||||
string name = "";
|
||||
if (match.Success)
|
||||
DataRow maxRow = maxfileRowDic.ContainsKey(fileInfo.Name) ? maxfileRowDic[fileInfo.Name] : null;
|
||||
string uploadFileId = "";
|
||||
if (maxRow != null)//如果存在则不允许上传
|
||||
{
|
||||
code = match.Groups[1].Value.Trim();
|
||||
spec = match.Groups[2].Value.Trim();
|
||||
name = match.Groups[3].Value.Trim();
|
||||
uploadFileId = maxRow["fileid"] + "";
|
||||
int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
||||
int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
||||
if (newbb > oldbb)
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n版本号大于最大版本号,请进行修改");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}不满足规则");
|
||||
}
|
||||
SetProcessBar(0, allCount);
|
||||
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, "010105", out string msg, out string uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||
GetOtherFileCodeInfo(fileInfo.Name, out string code, out string spec, out string name, out string extension, out string bb, out int bc);
|
||||
SetProcessBar(0, allCount);
|
||||
bool isUpload = UploadFileToAudit(fileInfo.FullName, code, speciesno, out string msg, out uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (selectRow.Table.Columns.Contains("qms_laddf_uploadtag"))
|
||||
{
|
||||
selectRow["qms_laddf_uploadtag"] = 1;
|
||||
}
|
||||
}));
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
@@ -386,8 +400,6 @@ namespace Lskj.PubBomImport
|
||||
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -444,7 +456,7 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
else
|
||||
{
|
||||
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '010105' and sname = '{fileInfo.Name}'");
|
||||
DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{productId}' and dllcoid = '1000202') and speciesno = '{speciesno}' and sname = '{fileInfo.Name}'");
|
||||
if (filetable.Rows.Count > 0)
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}的附件已存在");
|
||||
@@ -478,7 +490,7 @@ namespace Lskj.PubBomImport
|
||||
{
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||
SetProcessBar(0, allCount);
|
||||
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, "010105", out string msg, out string uploadFileId);
|
||||
bool isUpload = UploadFileToAudit(fileInfo.FullName, productId, speciesno, out string msg, out string uploadFileId);
|
||||
if (!isUpload)
|
||||
{
|
||||
throw new Exception($"{fileNameWithoutExtension}附件上传失败\r\n{msg}");
|
||||
@@ -3144,4 +3156,42 @@ namespace Lskj.PubBomImport
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解析code信息
|
||||
/// </summary>
|
||||
/// <param name="sourceCode"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="bb"></param>
|
||||
/// <param name="bc"></param>
|
||||
private bool GetOtherFileCodeInfo(string fileName, out string code, out string spec, out string name, out string extension, out string bb, out int bc)
|
||||
{
|
||||
string namepattern = @"^(\S+)\s+(\S*-S[A-Z][0-9]*)\s+(.+)(\.[^.]+)$";
|
||||
string pattern = @"^(.*?)(\d+)?$";
|
||||
var match = Regex.Match(fileName, namepattern);
|
||||
code = "";
|
||||
spec = "";
|
||||
Reference in New Issue
Block a user