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:
davideandClaude Sonnet 5 committed 2026-09-16 16:25:52 +02:00
1 parent 146ce78eae
commit 52483177f0
16 files changed
+1144 -249

No files matched your search

+8 -6
View File
@@ -18,12 +18,10 @@ public sealed record ScanProgress(
public static class Indexer
{
public static readonly string[] CartelleRadice = { "__Accessori", "__B.end", "__Corpi", "__Fondi", "Unificati", "Commerciali" };
private static readonly Regex FilenameRegex =
new(@"^(?<codice>.+)\.(?<tipo>[A-Za-z0-9]+)\.(?<versione>\d+)$", RegexOptions.Compiled);
private const string Schema = """
internal const string Schema = """
CREATE TABLE IF NOT EXISTS files (
id INTEGER PRIMARY KEY,
percorso_completo TEXT UNIQUE NOT NULL,
@@ -67,8 +65,12 @@ public static class Indexer
schemaCmd.ExecuteNonQuery();
}
// Indicizza tutte le cartelle di primo livello sotto la radice (non un elenco fisso),
// così una nuova cartella creata sulla share entra nell'indice senza modificare il codice.
var cartelleRadice = Directory.GetDirectories(root).Select(p => Path.GetFileName(p)!).ToArray();
var previsti = new Dictionary<string, long>();
foreach (var cartella in CartelleRadice)
foreach (var cartella in cartelleRadice)
{
using var cmd = connection.CreateCommand();
cmd.CommandText = "SELECT COUNT(*) FROM files WHERE cartella_radice = @c";
@@ -80,7 +82,7 @@ public static class Indexer
var sw = Stopwatch.StartNew();
long fattiTotali = 0;
foreach (var cartella in CartelleRadice)
foreach (var cartella in cartelleRadice)
{
ct.ThrowIfCancellationRequested();
@@ -233,7 +235,7 @@ public static class Indexer
cmd.Parameters["@modifica"].Value = modifica;
}
private static (string codice, string tipo, int? versione) ParseFilename(string nomeFile)
internal static (string codice, string tipo, int? versione) ParseFilename(string nomeFile)
{
var match = FilenameRegex.Match(nomeFile);
if (match.Success)