feat(parse): 支持解析 txt/dat 扩展名数据文件
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,11 @@ public class ParseService
|
|||||||
private readonly ILogger<ParseService> _logger;
|
private readonly ILogger<ParseService> _logger;
|
||||||
private readonly int _batchSize;
|
private readonly int _batchSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支持的输入数据文件扩展名(大小写不敏感)
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string[] SupportedExtensions = [".log", ".txt", ".dat"];
|
||||||
|
|
||||||
public ParseService(
|
public ParseService(
|
||||||
WctMinerDbContext context,
|
WctMinerDbContext context,
|
||||||
ScenarioService scenarioService,
|
ScenarioService scenarioService,
|
||||||
@@ -169,12 +174,16 @@ public class ParseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
var searchOption = recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||||
var logFiles = dirInfo.GetFiles("*.log", searchOption);
|
var dataFiles = dirInfo.EnumerateFiles("*", searchOption)
|
||||||
|
.Where(f => SupportedExtensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase))
|
||||||
|
.OrderBy(f => f.Name)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
_logger.LogInformation("发现 {FileCount} 个日志文件", logFiles.Length);
|
_logger.LogInformation("发现 {FileCount} 个数据文件({Extensions})",
|
||||||
|
dataFiles.Length, string.Join("/", SupportedExtensions));
|
||||||
|
|
||||||
var reports = new List<ParseReport>();
|
var reports = new List<ParseReport>();
|
||||||
foreach (var file in logFiles)
|
foreach (var file in dataFiles)
|
||||||
{
|
{
|
||||||
var report = await ParseFileAsync(file.FullName, force);
|
var report = await ParseFileAsync(file.FullName, force);
|
||||||
reports.Add(report);
|
reports.Add(report);
|
||||||
|
|||||||
Reference in New Issue
Block a user