From 7cd08f934ac5a7f155d50b2dd6f8b63ea807742b Mon Sep 17 00:00:00 2001 From: Scottxjw <13374147+scottxjw@user.noreply.gitee.com> Date: Fri, 14 Aug 2026 09:25:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(parse):=20=E6=94=AF=E6=8C=81=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=20txt/dat=20=E6=89=A9=E5=B1=95=E5=90=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Application/LocalIngestion/ParseService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Gpulse.WCT.DataAnalyzer.Core/Application/LocalIngestion/ParseService.cs b/src/Gpulse.WCT.DataAnalyzer.Core/Application/LocalIngestion/ParseService.cs index dc7a128..6b2e1e7 100644 --- a/src/Gpulse.WCT.DataAnalyzer.Core/Application/LocalIngestion/ParseService.cs +++ b/src/Gpulse.WCT.DataAnalyzer.Core/Application/LocalIngestion/ParseService.cs @@ -20,6 +20,11 @@ public class ParseService private readonly ILogger _logger; private readonly int _batchSize; + /// + /// 支持的输入数据文件扩展名(大小写不敏感) + /// + private static readonly string[] SupportedExtensions = [".log", ".txt", ".dat"]; + public ParseService( WctMinerDbContext context, ScenarioService scenarioService, @@ -169,12 +174,16 @@ public class ParseService } 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(); - foreach (var file in logFiles) + foreach (var file in dataFiles) { var report = await ParseFileAsync(file.FullName, force); reports.Add(report);