refactor: replace CutFab API with local file export and database

Remove CutFabApiClient and DrawingSelectionForm - exports no longer
depend on an external API server. DXF/PDF files are saved directly
to a configurable output folder, and export records are persisted
to a local SQL Server database via EF Core.

Replace Color-based progress logging with LogLevel enum across all
services. Redesign MainForm with equipment/drawing filter dropdowns
populated from export history, log row coloring by severity, and
simplified startup flow in Program.cs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 11:27:04 -05:00
parent 384fceb047
commit 49051b5e64
15 changed files with 524 additions and 1785 deletions
+20 -5
View File
@@ -14,14 +14,29 @@ namespace ExportDXF.Models
public string PartName { get; set; } = "";
public string ConfigurationName { get; set; } = "";
public string Material { get; set; } = "";
public int DrawingID { get; set; }
public int? CutTemplateID { get; set; }
public string CutTemplateName { get; set; } = "";
public string DxfFilePath { get; set; } = "";
// Sheet metal properties
private double? _thickness;
public double? Thickness
{
get => _thickness;
set => _thickness = value.HasValue ? Math.Round(value.Value, 8) : null;
}
// Sheet metal properties from CutTemplate
public double? Thickness { get; set; }
public double? KFactor { get; set; }
public double? DefaultBendRadius { get; set; }
private double? _defaultBendRadius;
public double? DefaultBendRadius
{
get => _defaultBendRadius;
set => _defaultBendRadius = value.HasValue ? Math.Round(value.Value, 8) : null;
}
// EF Core relationship to ExportRecord
public int ExportRecordId { get; set; }
public virtual ExportRecord ExportRecord { get; set; }
}
public struct Size
+14 -8
View File
@@ -1,8 +1,8 @@
using ExportDXF.ViewFlipDeciders;
using ExportDXF.Models;
using ExportDXF.ViewFlipDeciders;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;
@@ -44,12 +44,18 @@ namespace ExportDXF.Services
/// <summary>
/// Callback for reporting progress and status messages.
/// Parameters: message, level, file (optional)
/// </summary>
public Action<string, Color?> ProgressCallback { get; set; }
public Action<string, LogLevel, string> ProgressCallback { get; set; }
public void LogProgress(string message, Color? color = null)
/// <summary>
/// Callback for adding BOM items to the UI.
/// </summary>
public Action<BomItem> BomItemCallback { get; set; }
public void LogProgress(string message, LogLevel level = LogLevel.Info, string file = null)
{
ProgressCallback?.Invoke(message, color);
ProgressCallback?.Invoke(message, level, file);
}
public SldWorks SolidWorksApp { get; set; }
@@ -90,7 +96,7 @@ namespace ExportDXF.Services
if (SolidWorksApp == null)
{
ProgressCallback?.Invoke("Warning: Cannot cleanup template drawing - SolidWorks app not available", Color.DarkBlue);
ProgressCallback?.Invoke("Warning: Cannot cleanup template drawing - SolidWorks app not available", LogLevel.Warning, null);
TemplateDrawing = null;
return;
}
@@ -104,7 +110,7 @@ namespace ExportDXF.Services
{
// Close the document without saving
SolidWorksApp.CloseDoc(title);
ProgressCallback?.Invoke("Closed template drawing", null);
ProgressCallback?.Invoke("Closed template drawing", LogLevel.Info, null);
}
}
@@ -113,7 +119,7 @@ namespace ExportDXF.Services
}
catch (Exception ex)
{
ProgressCallback?.Invoke($"Failed to close template drawing: {ex.Message}", Color.Red);
ProgressCallback?.Invoke($"Failed to close template drawing: {ex.Message}", LogLevel.Error, null);
// Still clear the reference to prevent further issues
TemplateDrawing = null;