SVN r675
SVN-Revision: r675
This commit is contained in:
@@ -553,7 +553,7 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Bom结构补充,新增其它文件,无版本控制
|
||||
/// 批量修改多个其它文件{版次变化直接上传}
|
||||
/// </summary>
|
||||
/// <param name="dirPaths"></param>
|
||||
public void StartUpdateInOtherFiles(List<DataRow> selectRows)
|
||||
@@ -736,6 +736,193 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 单个修改其它文件,有可能存在无规则的文件,直接按照版本变化上传
|
||||
/// </summary>
|
||||
/// <param name="dirPaths"></param>
|
||||
public void StartUpdateInOtherFile(List<DataRow> selectRows)
|
||||
{
|
||||
try
|
||||
{
|
||||
int execOrder = 1;
|
||||
FrmBillInfo frmBillInfo = new FrmBillInfo();
|
||||
string speciesno = selectRows[0]["BomAddSpeciesNo"] + "";
|
||||
if (string.IsNullOrEmpty(speciesno))
|
||||
{
|
||||
throw new Exception("未选择文件分类");
|
||||
}
|
||||
if (selectRows.Count > 1)
|
||||
{
|
||||
throw new Exception("仅支持单个附件变更");
|
||||
}
|
||||
Dictionary<string, DataRow> maxfileRowDic = new Dictionary<string, DataRow>();
|
||||
foreach (DataRow selectRow in selectRows)
|
||||
{
|
||||
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||
FileInfo fileInfo = new FileInfo(dirPath);
|
||||
if (fileInfo != null)
|
||||
{
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name).Trim();
|
||||
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)
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n文件名不符合规则");
|
||||
}
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
throw new Exception($"编码解析为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(spec))
|
||||
{
|
||||
throw new Exception($"规格解析为空");
|
||||
}
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception($"名称解析为空");
|
||||
}
|
||||
if (!fileNameWithoutExtension.StartsWith("LX"))
|
||||
{
|
||||
throw new Exception($"文件{fileNameWithoutExtension}名称不符合规则\r\n不以LX开头");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bc <= 0)
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n为0的版次不允许进行版次修改");
|
||||
}
|
||||
DataRow productRow = BaseImpl.GetDataRowResult($"select ProductId from p_productTab where ProductId = '{code}'");
|
||||
if (productRow == null)
|
||||
{
|
||||
throw new Exception($"物料编码{code}不存在,无法修改");
|
||||
}
|
||||
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版本号小于等于最大版本号{oldbb},无法修改");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n不存在可以修改的附件");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{fileName}的文件不存在");
|
||||
}
|
||||
}
|
||||
frmBillInfo.OnControlSourceBind += (s, args) =>
|
||||
{
|
||||
Task task = new Task(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int.TryParse(Model.FirstRowIndex, out int index);
|
||||
frmMain.FirstRowIndex = index;
|
||||
foreach (DataRow selectRow in selectRows)
|
||||
{
|
||||
string productId = selectRow["BomMxMainProduct"] + "";
|
||||
int childIndex = selectRows.IndexOf(selectRow);
|
||||
int nowCount = 1 + childIndex;
|
||||
int allCount = (int)((decimal)(1 + childIndex) / (selectRows.Count + 1) * 100);
|
||||
int finishCount = (int)((decimal)(1 + nowCount) / (selectRows.Count + 1) * 100);
|
||||
string fileName = selectRow[Model.AfterBomFieldName] + "";
|
||||
string dirPath = selectRow["BomFieldNameDir"] + "";
|
||||
FileInfo fileInfo = new FileInfo(dirPath);
|
||||
if (fileInfo != null)
|
||||
{
|
||||
DataRow maxRow = maxfileRowDic.ContainsKey(fileInfo.Name) ? maxfileRowDic[fileInfo.Name] : null;
|
||||
string uploadFileId = "";
|
||||
if (maxRow != null)//如果存在则修改
|
||||
{
|
||||
int.TryParse(maxRow["fileid"] + "", out int fileId);
|
||||
int.TryParse(maxRow["版本号"] + "", out int oldbb);
|
||||
int.TryParse(maxRow["新文件版本号"] + "", out int newbb);
|
||||
if (newbb <= oldbb)
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n版本号小于等于最大版本号{oldbb},无法修改");
|
||||
}
|
||||
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_uniofileid"))
|
||||
{
|
||||
selectRow["qms_laddf_uniofileid"] = fileId;
|
||||
}
|
||||
if (selectRow.Table.Columns.Contains("qms_laddf_uploadtag"))
|
||||
{
|
||||
selectRow["qms_laddf_uploadtag"] = 1;
|
||||
}
|
||||
}));
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{nowCount + 1}/{selectRows.Count + 1}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{fileInfo.Name}\r\n不存在可以修改的附件");
|
||||
}
|
||||
StaticControl.RightMenuGridView.GridControl.Invoke(new Action(() =>
|
||||
{
|
||||
if (selectRow.Table.Columns.Contains("qms_laddf_FileId"))
|
||||
{
|
||||
int.TryParse(uploadFileId, out int qms_laddf_FileId);
|
||||
selectRow["qms_laddf_FileId"] = qms_laddf_FileId;
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{fileName}的文件不存在");
|
||||
}
|
||||
}
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
ImportTimer?.Dispose();
|
||||
}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
ImportTimer?.Dispose();
|
||||
}));
|
||||
}
|
||||
});
|
||||
task.Start();
|
||||
};
|
||||
frmBillInfo.OnLoad(Model);
|
||||
frmMain.ParentView = frmBillInfo.GcMainView;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
ImportTimer?.Dispose();
|
||||
}));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改单个文件
|
||||
/// </summary>
|
||||
/// <param name="dirPaths"></param>
|
||||
|
||||
Reference in New Issue
Block a user