SVN r469
SVN-Revision: r469
This commit is contained in:
@@ -186,33 +186,65 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
else if (Model.ShowType.Equals("3"))
|
||||
{
|
||||
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
|
||||
if (StaticControl.RightMenuGridView.Tag is Dictionary<string, string> filesDic)
|
||||
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||
{
|
||||
FrmProgress frmProgress = new FrmProgress();
|
||||
frmProgress.frmMain = this;
|
||||
frmProgress.Model = Model;
|
||||
frmProgress.ImportTimer.Tick += (ts, te) =>
|
||||
ShowType = Model.ShowType,
|
||||
AfterBomFieldName = Model.AfterBomFieldName,
|
||||
CanSave = true
|
||||
};
|
||||
FormDialogModel dialogModel = new FormDialogModel()
|
||||
{
|
||||
DialogDllName = "Lskj.PubBomImport.dll",
|
||||
PubDialogType = DialogType.PubAddRecord,
|
||||
ReturnTag = bomImpRtnModel
|
||||
};
|
||||
this.Tag = dialogModel;
|
||||
if (StaticControl.RightMenuGridView.Tag is Dictionary<DataRow, string> filesDic)
|
||||
{
|
||||
DataTable sourceTable = StaticControl.RightMenuGridView.GridControl.DataSourceTable();
|
||||
List<DataRow> selectRows = new List<DataRow>();
|
||||
foreach (DataRow sourceRow in sourceTable.Rows)
|
||||
{
|
||||
frmProgress.ImportTimer.Enabled = false;
|
||||
frmProgress.StartImportInQDFile(sourceTable, filesDic);
|
||||
};
|
||||
frmProgress.ImportTimer.Enabled = true;
|
||||
DialogResult dialogResult = frmProgress.ShowDialog();
|
||||
BomImpRtnModel bomImpRtnModel = new BomImpRtnModel()
|
||||
if (sourceRow.RowState == DataRowState.Deleted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fileName = sourceRow[Model.AfterBomFieldName] + "";
|
||||
string dirPath = filesDic.ContainsKey(sourceRow) ? filesDic[sourceRow] : "";
|
||||
FileInfo parentInfo = null;
|
||||
if (string.IsNullOrEmpty(dirPath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
parentInfo = new FileInfo(dirPath);
|
||||
if (parentInfo != null && (parentInfo.Name.Trim().StartsWith("QD") || parentInfo.Name.Trim().StartsWith("ZZQD")))
|
||||
{
|
||||
selectRows.Add(sourceRow);
|
||||
}
|
||||
}
|
||||
if (selectRows.Count > 0)
|
||||
{
|
||||
ShowType = Model.ShowType,
|
||||
AfterBomFieldName = Model.AfterBomFieldName,
|
||||
CanSave = dialogResult == DialogResult.OK
|
||||
};
|
||||
FormDialogModel dialogModel = new FormDialogModel()
|
||||
FrmProgress frmProgress = new FrmProgress();
|
||||
frmProgress.frmMain = this;
|
||||
frmProgress.Model = Model;
|
||||
frmProgress.ImportTimer.Tick += (ts, te) =>
|
||||
{
|
||||
frmProgress.ImportTimer.Enabled = false;
|
||||
frmProgress.StartImportInQDFile(selectRows, filesDic);
|
||||
};
|
||||
frmProgress.ImportTimer.Enabled = true;
|
||||
DialogResult dialogResult = frmProgress.ShowDialog();
|
||||
bomImpRtnModel.CanSave = dialogResult == DialogResult.OK;
|
||||
frmProgress.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogDllName = "Lskj.PubBomImport.dll",
|
||||
PubDialogType = DialogType.PubAddRecord,
|
||||
ReturnTag = bomImpRtnModel
|
||||
};
|
||||
this.Tag = dialogModel;
|
||||
frmProgress.Dispose();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,18 +505,18 @@ namespace Lskj.PubBomImport
|
||||
/// 开始导入3
|
||||
/// </summary>
|
||||
/// <param name="dirPaths"></param>
|
||||
public void StartImportInQDFile(DataTable sourceTable, Dictionary<string, string> filesDic)
|
||||
public void StartImportInQDFile(List<DataRow> selectRows, Dictionary<DataRow, string> filesDic)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DataRow sourceRow in sourceTable.Rows)
|
||||
foreach (DataRow sourceRow in selectRows)
|
||||
{
|
||||
if (sourceRow.RowState == DataRowState.Deleted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string fileName = sourceRow[Model.AfterBomFieldName] + "";
|
||||
string dirPath = filesDic.ContainsKey(fileName) ? filesDic[fileName] : "";
|
||||
string dirPath = filesDic.ContainsKey(sourceRow) ? filesDic[sourceRow] : "";
|
||||
FileInfo parentInfo = null;
|
||||
if (string.IsNullOrEmpty(dirPath))
|
||||
{
|
||||
@@ -553,17 +553,17 @@ namespace Lskj.PubBomImport
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DataRow sourceRow in sourceTable.Rows)
|
||||
foreach (DataRow sourceRow in selectRows)
|
||||
{
|
||||
if (sourceRow.RowState == DataRowState.Deleted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int childIndex = sourceTable.Rows.IndexOf(sourceRow);
|
||||
int allCount = (int)((decimal)(childIndex) / (sourceTable.Rows.Count) * 100);
|
||||
int finishCount = (int)((decimal)(1 + childIndex) / (sourceTable.Rows.Count) * 100);
|
||||
int childIndex = selectRows.IndexOf(sourceRow);
|
||||
int allCount = (int)((decimal)(childIndex) / (selectRows.Count) * 100);
|
||||
int finishCount = (int)((decimal)(1 + childIndex) / (selectRows.Count) * 100);
|
||||
string fileName = sourceRow[Model.AfterBomFieldName] + "";
|
||||
string dirPath = filesDic.ContainsKey(fileName) ? filesDic[fileName] : "";
|
||||
string dirPath = filesDic.ContainsKey(sourceRow) ? filesDic[sourceRow] : "";
|
||||
FileInfo parentInfo = null;
|
||||
if (string.IsNullOrEmpty(dirPath))
|
||||
{
|
||||
@@ -652,7 +652,7 @@ namespace Lskj.PubBomImport
|
||||
//上传文件
|
||||
bool isUpload = UploadFile(childInfo.FullName, billNo, out string msg);
|
||||
SetProcessBar(100, finishCount);
|
||||
SetProcessLabelAllMsg($"总进度:{childIndex + 1}/{sourceTable.Rows.Count }");
|
||||
SetProcessLabelAllMsg($"总进度:{childIndex + 1}/{selectRows.Count }");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -667,10 +667,7 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show("不是QD或ZZQD文件");
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
ImportTimer?.Dispose();
|
||||
throw new Exception($"{parentInfo.Name}不是QD或ZZQD文件");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1193,5 +1190,6 @@ namespace Lskj.PubBomImport
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnMsg = ex.Message;
|
||||
throw new Exception($"文件{Path.GetFileName(filePath)}上传失败\r\n{ex.Message}");
|
||||
isUpload = false;
|
||||
|
||||
Reference in New Issue
Block a user