루트 파일 정리: - DXF/P&ID 관련 → dxf-graph/ - fastTable 관련 → fastTable/ - plan/ → plans/ 통합 (최신 버전 유지) - 테스트 출력 파일, 구버전 프로젝트 삭제 - 불필요한 루트 문서 삭제
121 lines
4.8 KiB
C#
121 lines
4.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using netDxf;
|
|
|
|
class TestDxfFull
|
|
{
|
|
static void Main()
|
|
{
|
|
string filePath = "/home/windpacer/projects/ExperionCrawler/src/Web/uploads/pid/p-9100.dxf";
|
|
|
|
Console.WriteLine("=== PidExtractorService.ExtractDxfText() 전체 흐름 검증 ===\n");
|
|
|
|
// 1. Stream 복사
|
|
Console.WriteLine("1. Stream 복사 테스트");
|
|
var tmp = Path.GetTempFileName() + ".dxf";
|
|
try
|
|
{
|
|
using (var stream = File.OpenRead(filePath))
|
|
using (var fs = File.Create(tmp))
|
|
{
|
|
stream.CopyTo(fs);
|
|
Console.WriteLine($" ✓ Stream 복사 완료: {fs.Length:N0} bytes");
|
|
}
|
|
|
|
// 2. DxfDocument.Load
|
|
Console.WriteLine("\n2. DxfDocument.Load() 테스트");
|
|
var doc = DxfDocument.Load(tmp);
|
|
Console.WriteLine($" ✓ DXF 로드 성공");
|
|
Console.WriteLine($" - Texts: {doc.Entities.Texts.Count}");
|
|
Console.WriteLine($" - MTexts: {doc.Entities.MTexts.Count}");
|
|
Console.WriteLine($" - Blocks: {doc.Blocks.Count}");
|
|
|
|
// 3. TEXT 추출
|
|
Console.WriteLine("\n3. TEXT 추출 테스트");
|
|
var sb = new StringBuilder();
|
|
int textCount = 0;
|
|
foreach (var txt in doc.Entities.Texts)
|
|
{
|
|
sb.AppendLine(txt.Value);
|
|
textCount++;
|
|
}
|
|
Console.WriteLine($" ✓ TEXT 추출: {textCount}개");
|
|
|
|
// 4. MTEXT 추출
|
|
Console.WriteLine("\n4. MTEXT 추출 테스트");
|
|
int mtextCount = 0;
|
|
foreach (var mtxt in doc.Entities.MTexts)
|
|
{
|
|
sb.AppendLine(mtxt.PlainText());
|
|
mtextCount++;
|
|
}
|
|
Console.WriteLine($" ✓ MTEXT 추출: {mtextCount}개");
|
|
|
|
// 5. AttributeDefinition 추출
|
|
Console.WriteLine("\n5. AttributeDefinition 추출 테스트");
|
|
int attrCount = 0;
|
|
foreach (var blk in doc.Blocks)
|
|
{
|
|
foreach (var attr in blk.AttributeDefinitions.Values)
|
|
{
|
|
sb.AppendLine(attr.Value);
|
|
attrCount++;
|
|
}
|
|
}
|
|
Console.WriteLine($" ✓ AttributeDefinition 추출: {attrCount}개");
|
|
|
|
string result = sb.ToString();
|
|
Console.WriteLine($"\n=== 최종 추출 결과 ===");
|
|
Console.WriteLine($"총 추출 길이: {result.Length} bytes");
|
|
Console.WriteLine($"총 줄 수: {result.Split('\n').Length}");
|
|
|
|
// 6. 태그 패턴 검색
|
|
var lines = result.Split('\n');
|
|
int tagCount = 0;
|
|
var foundTags = new System.Collections.Generic.List<string>();
|
|
foreach (var line in lines)
|
|
{
|
|
if (System.Text.RegularExpressions.Regex.IsMatch(line, @"[A-Z]{2,4}-\d{3,4}(\.\w+)?", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
|
|
{
|
|
if (foundTags.Count < 10)
|
|
{
|
|
foundTags.Add(line.Trim());
|
|
}
|
|
tagCount++;
|
|
}
|
|
}
|
|
Console.WriteLine($"\n태그 패턴 검색: {tagCount}개 발견");
|
|
Console.WriteLine("샘플 태그:");
|
|
foreach (var tag in foundTags)
|
|
{
|
|
Console.WriteLine($" - {tag}");
|
|
}
|
|
|
|
// 7. MCP 서버로 전달할 텍스트 길이 확인
|
|
Console.WriteLine($"\n=== MCP 서버 전달 테스트 ===");
|
|
string truncated = result.Length > 12000 ? result.Substring(0, 12000) : result;
|
|
Console.WriteLine($"원본 길이: {result.Length} bytes");
|
|
Console.WriteLine($"MCP 전달 길이: {truncated.Length} bytes (12000자 제한)");
|
|
|
|
// 8. 샘플 텍스트 출력
|
|
Console.WriteLine($"\n=== 샘플 텍스트 (상위 5줄) ===");
|
|
foreach (var line in lines.Take(5))
|
|
{
|
|
Console.WriteLine($" {line}");
|
|
}
|
|
|
|
Console.WriteLine($"\n=== 검증 완료 ===");
|
|
Console.WriteLine($"PidExtractorService.ExtractDxfText() 메서드는 정상적으로 작동합니다.");
|
|
Console.WriteLine($"추출된 텍스트 길이: {result.Length} bytes");
|
|
Console.WriteLine($"태그 패턴 발견: {tagCount}개");
|
|
Console.WriteLine($"\nMCP 서버로 전달할 텍스트는 {truncated.Length} bytes입니다.");
|
|
|
|
}
|
|
finally
|
|
{
|
|
if (File.Exists(tmp)) File.Delete(tmp);
|
|
}
|
|
}
|
|
}
|