Add wizard UI, general-assembly resolution, and test suite
Restructure Form1 into a sequential wizard (database -> import -> raw -> recursive component resolution -> completeness/STEP report), fix case-sensitivity bugs in codice/tipo_file lookups and a word-boundary gap in the assembly scanner that missed _D100-style sub-assembly references, and treat the distinta's general assembly as an ordinary CSV row (derived from the DBP_<codice>_<timestamp> filename) instead of special-casing it throughout. Also adds CadSearchGui.Tests (xUnit) covering the scanner, filename parsing, and the case-insensitive DB lookup behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
146ce78eae
commit
52483177f0
16 files changed
+1144
-249
No files matched your search
@@ -11,19 +11,25 @@ namespace CadSearchGui;
|
||||
/// vedi Indexer.FilenameRegex) e si lascia poi al chiamante il compito di verificarli
|
||||
/// contro l'indice DB, che scarta automaticamente i falsi positivi (numeri che non
|
||||
/// corrispondono a nessun codice reale).
|
||||
///
|
||||
/// Verificato su un caso reale confrontando con un report BOM generato da Creo: i
|
||||
/// riferimenti veri compaiono più volte nel file (una volta per feature/placement),
|
||||
/// mentre il rumore binario casuale che assomiglia a un codice compare quasi sempre
|
||||
/// una sola volta. Si scartano quindi i candidati con una sola occorrenza.
|
||||
/// </summary>
|
||||
static class AssemblyComponentScanner
|
||||
{
|
||||
private static readonly Regex CodiceRegex = new(@"\b\d{8,12}[A-Za-z]{0,2}\b", RegexOptions.Compiled);
|
||||
private static readonly Regex CodiceRegex = new(@"\b\d{8,12}(?:_[A-Za-z]\d{2,4}|[A-Za-z]{0,2})\b", RegexOptions.Compiled);
|
||||
private const int OccorrenzeMinime = 2;
|
||||
|
||||
public static HashSet<string> EstraiCodiciReferenziati(string percorsoAsm)
|
||||
{
|
||||
var testo = Encoding.Latin1.GetString(File.ReadAllBytes(percorsoAsm));
|
||||
var codici = new HashSet<string>();
|
||||
var occorrenze = new Dictionary<string, int>();
|
||||
foreach (Match m in CodiceRegex.Matches(testo))
|
||||
{
|
||||
codici.Add(m.Value);
|
||||
occorrenze[m.Value] = occorrenze.GetValueOrDefault(m.Value) + 1;
|
||||
}
|
||||
return codici;
|
||||
return occorrenze.Where(kv => kv.Value >= OccorrenzeMinime).Select(kv => kv.Key).ToHashSet();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user