Commit f85a0b3d 刘韬

1

1 个父辈 59dbae0f
...@@ -261,22 +261,29 @@ namespace SmartScan ...@@ -261,22 +261,29 @@ namespace SmartScan
// 读取文件内容 // 读取文件内容
string fileContent = File.ReadAllText(FilePath.CONFIG_Code_Value); string fileContent = File.ReadAllText(FilePath.CONFIG_Code_Value);
List<string> lines = fileContent.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(s=>s.Trim()).ToList();
LogNet.log.Info("扫描到条码:"+string.Join(",", codeTexts)); LogNet.log.Info("扫描到条码:"+string.Join(",", codeTexts));
LogNet.log.Info("在以下条码中匹配:"+fileContent); LogNet.log.Info("在以下条码中匹配:"+fileContent);
// 检查文件内容是否包含任一条码文本 // 检查文件内容是否包含任一条码文本
foreach (string ln in lines.ToArray())
{
foreach (string codeText in codeTexts) foreach (string codeText in codeTexts)
{ {
if (fileContent.Contains(codeText)) if (ln.Trim() == codeText.Trim())
{ {
LogNet.log.Info($"条码 {codeText} 在文件中找到匹配"); LogNet.log.Info($"条码 {codeText} 在文件中找到匹配");
return true; lines.Remove(ln);
} }
} }
}
LogNet.log.Info("所有条码在文件中均未找到匹配"); if (lines.Count > 0)
{
LogNet.log.Info("以下条码文件中均未找到匹配:" + string.Join(",", lines.ToArray()));
return false; return false;
} }
else
return true;
}
catch (Exception ex) catch (Exception ex)
{ {
LogNet.log.Error($"检查文件内容时出错: {ex.Message}"); LogNet.log.Error($"检查文件内容时出错: {ex.Message}");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!