A component with no .stp could mean two different things: the CAD source was never found in the index at all, or it's indexed but nobody exported the STEP yet. Cross-references the missing codes against cad_index.db (reusing the phase-2 verification cache when available) and reports each as EsitoStep.StepMancante vs ComponenteNonTrovato, colored differently. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
86 lines
3.4 KiB
C#
86 lines
3.4 KiB
C#
using System.Diagnostics;
|
|
|
|
namespace CadSearchGui;
|
|
|
|
public enum EsitoStep
|
|
{
|
|
/// <summary>File .stp trovato in "step" e copiato in "step_finali".</summary>
|
|
Creato,
|
|
/// <summary>Il componente è nell'indice CAD (asm/prt trovato), ma nessuno STEP esportato.</summary>
|
|
StepMancante,
|
|
/// <summary>Il componente non è nemmeno nell'indice CAD.</summary>
|
|
ComponenteNonTrovato,
|
|
}
|
|
|
|
/// <summary>Mostra, per ogni componente della distinta base, se lo STEP corrispondente è stato
|
|
/// trovato in "step" e copiato in "step_finali", se manca solo lo STEP (il CAD sorgente c'è,
|
|
/// ma non è ancora stato esportato) o se manca anche il CAD sorgente nell'indice.</summary>
|
|
public class ReportStepForm : Form
|
|
{
|
|
public ReportStepForm(List<(string Componente, string Descrizione, EsitoStep Esito)> righe, string cartellaStepFinali)
|
|
{
|
|
int creati = righe.Count(r => r.Esito == EsitoStep.Creato);
|
|
int stepMancanti = righe.Count(r => r.Esito == EsitoStep.StepMancante);
|
|
int nonTrovati = righe.Count(r => r.Esito == EsitoStep.ComponenteNonTrovato);
|
|
|
|
Text = "Report STEP finali";
|
|
ClientSize = new Size(720, 440);
|
|
StartPosition = FormStartPosition.CenterParent;
|
|
Font = new Font("Segoe UI", 9.5f);
|
|
|
|
var lblInfo = new Label
|
|
{
|
|
Dock = DockStyle.Top,
|
|
AutoSize = false,
|
|
Height = 32,
|
|
Padding = new Padding(12, 8, 12, 8),
|
|
Text = $"{creati} copiati, {stepMancanti} da esportare (CAD presente), "
|
|
+ $"{nonTrovati} non nell'indice, su {righe.Count} totali. In \"{cartellaStepFinali}\".",
|
|
};
|
|
|
|
var grid = new DataGridView
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
ReadOnly = true,
|
|
AllowUserToAddRows = false,
|
|
AllowUserToDeleteRows = false,
|
|
RowHeadersVisible = false,
|
|
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
|
|
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
|
|
};
|
|
grid.Columns.Add("componente", "Componente");
|
|
grid.Columns.Add("descrizione", "Descrizione");
|
|
grid.Columns.Add("step", "STEP");
|
|
grid.Columns["componente"]!.FillWeight = 20;
|
|
grid.Columns["descrizione"]!.FillWeight = 55;
|
|
grid.Columns["step"]!.FillWeight = 25;
|
|
|
|
foreach (var (componente, descrizione, esito) in righe.OrderBy(r => r.Esito).ThenBy(r => r.Componente))
|
|
{
|
|
var (testo, colore) = esito switch
|
|
{
|
|
EsitoStep.Creato => ("Creato", Color.DarkGreen),
|
|
EsitoStep.StepMancante => ("Da esportare (CAD presente)", Color.DarkOrange),
|
|
_ => ("Componente non trovato nel server", Color.DarkRed),
|
|
};
|
|
int i = grid.Rows.Add(componente, descrizione, testo);
|
|
grid.Rows[i].DefaultCellStyle.ForeColor = colore;
|
|
}
|
|
|
|
var btnApriCartella = new Button { Text = "Apri cartella step_finali", Dock = DockStyle.Bottom, Height = 34 };
|
|
btnApriCartella.Click += (_, _) =>
|
|
{
|
|
try { Process.Start("explorer.exe", cartellaStepFinali); }
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(this, $"Impossibile aprire Esplora risorse:\n{ex.Message}", "Errore",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
};
|
|
|
|
Controls.Add(grid);
|
|
Controls.Add(lblInfo);
|
|
Controls.Add(btnApriCartella);
|
|
}
|
|
}
|