修复错误的试运行模式
This commit is contained in:
@@ -65,7 +65,10 @@ public class FileInputService : IInputService
|
||||
var file = Path.GetFileName(info.FileName);
|
||||
_logger.LogInformation("正在读取文件:{FileName}, 对应的数据表:{TableName}", file, info.TableName);
|
||||
using var source = _dataReaderFactory.CreateReader(info.FileName, info.TableName, info.Headers);
|
||||
var count = 0;
|
||||
var countBuffer = 0;
|
||||
|
||||
if (_dryRun && _context.TableProgress.GetValueOrDefault(info.TableName, (input: 0, output: 0)).input >= _dryRunCount)
|
||||
continue;
|
||||
|
||||
while (await source.ReadAsync())
|
||||
{
|
||||
@@ -78,13 +81,23 @@ public class FileInputService : IInputService
|
||||
}
|
||||
var record = source.Current;
|
||||
await _producerQueue.EnqueueAsync(record);
|
||||
count++;
|
||||
countBuffer++;
|
||||
_context.AddInput();
|
||||
if (_dryRun && count >= _dryRunCount)
|
||||
break;
|
||||
|
||||
// 避免影响性能,每1000条更新一次表输入进度
|
||||
if (countBuffer >= 1000)
|
||||
{
|
||||
_context.AddTableInput(info.TableName, countBuffer);
|
||||
countBuffer = 0;
|
||||
// 试运行模式下,超出了指定行数则停止输入
|
||||
if (_dryRun && _context.TableProgress[info.TableName].input >= _dryRunCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_context.AddTableInput(info.TableName, count);
|
||||
_context.AddTableInput(info.TableName, countBuffer);
|
||||
_logger.LogInformation("文件 {File} 输入完成", file);
|
||||
_dataInputOptions.Value.OnTableInputCompleted?.Invoke(info.TableName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user