refactor: update models — add CutTemplate.Revision, remove ExportRecord, simplify ExportContext

- CutTemplate: add Revision property, remove EF Core navigation properties
- BomItem: remove EF Core navigation properties and ExportRecordId
- ExportContext: replace Equipment/DrawingNo/Title/FilePrefix with
  FilenameTemplate and OutputFolder
- Delete ExportRecord.cs (replaced by log file)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 22:13:40 -04:00
parent 742d86ab8a
commit cf17e71b80
4 changed files with 9 additions and 62 deletions
+1 -8
View File
@@ -2,7 +2,6 @@ namespace ExportDXF.Models
{ {
public class BomItem public class BomItem
{ {
public int ID { get; set; }
public string ItemNo { get; set; } = ""; public string ItemNo { get; set; } = "";
public string PartNo { get; set; } = ""; public string PartNo { get; set; } = "";
public int SortOrder { get; set; } public int SortOrder { get; set; }
@@ -12,13 +11,7 @@ namespace ExportDXF.Models
public string PartName { get; set; } = ""; public string PartName { get; set; } = "";
public string ConfigurationName { get; set; } = ""; public string ConfigurationName { get; set; } = "";
public string Material { get; set; } = ""; public string Material { get; set; } = "";
public CutTemplate CutTemplate { get; set; }
// EF Core relationship to ExportRecord
public int ExportRecordId { get; set; }
public virtual ExportRecord ExportRecord { get; set; }
// Optional 1:1 relationship to CutTemplate (only for sheet metal parts)
public virtual CutTemplate CutTemplate { get; set; }
} }
public struct Size public struct Size
+1 -6
View File
@@ -4,12 +4,11 @@ namespace ExportDXF.Models
{ {
public class CutTemplate public class CutTemplate
{ {
public int Id { get; set; }
public string DxfFilePath { get; set; } = ""; public string DxfFilePath { get; set; } = "";
public string ContentHash { get; set; } public string ContentHash { get; set; }
public string CutTemplateName { get; set; } = ""; public string CutTemplateName { get; set; } = "";
public int Revision { get; set; } = 1;
// Sheet metal properties (moved from BomItem)
private double? _thickness; private double? _thickness;
public double? Thickness public double? Thickness
{ {
@@ -25,9 +24,5 @@ namespace ExportDXF.Models
get => _defaultBendRadius; get => _defaultBendRadius;
set => _defaultBendRadius = value.HasValue ? Math.Round(value.Value, 8) : null; set => _defaultBendRadius = value.HasValue ? Math.Round(value.Value, 8) : null;
} }
// FK back to BomItem
public int BomItemId { get; set; }
public virtual BomItem BomItem { get; set; }
} }
} }
+5 -26
View File
@@ -1,4 +1,4 @@
using ExportDXF.Models; using ExportDXF.Models;
using ExportDXF.ViewFlipDeciders; using ExportDXF.ViewFlipDeciders;
using SolidWorks.Interop.sldworks; using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst; using SolidWorks.Interop.swconst;
@@ -28,29 +28,14 @@ namespace ExportDXF.Services
public IViewFlipDecider ViewFlipDecider { get; set; } public IViewFlipDecider ViewFlipDecider { get; set; }
/// <summary> /// <summary>
/// Prefix to prepend to exported filenames. /// Filename template with placeholders (e.g., "4321 A01 PT{item_no:2}").
/// </summary> /// </summary>
public string FilePrefix { get; set; } public string FilenameTemplate { get; set; }
/// <summary> /// <summary>
/// Equipment number from the UI (e.g., "5028"). /// Output folder for DXF files and Excel workbook.
/// </summary> /// </summary>
public string Equipment { get; set; } public string OutputFolder { get; set; }
/// <summary>
/// Drawing number from the UI (e.g., "A02", "Misc").
/// </summary>
public string DrawingNo { get; set; }
/// <summary>
/// Optional title/label for the export.
/// </summary>
public string Title { get; set; }
/// <summary>
/// Selected Equipment ID for API operations (optional).
/// </summary>
public int? EquipmentId { get; set; }
/// <summary> /// <summary>
/// Cancellation token for canceling the export operation. /// Cancellation token for canceling the export operation.
@@ -123,23 +108,17 @@ namespace ExportDXF.Services
if (!string.IsNullOrEmpty(title)) if (!string.IsNullOrEmpty(title))
{ {
// Close the document without saving
SolidWorksApp.CloseDoc(title); SolidWorksApp.CloseDoc(title);
ProgressCallback?.Invoke("Closed template drawing", LogLevel.Info, null); ProgressCallback?.Invoke("Closed template drawing", LogLevel.Info, null);
} }
} }
// Clear the reference regardless of success/failure
TemplateDrawing = null; TemplateDrawing = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
ProgressCallback?.Invoke($"Failed to close template drawing: {ex.Message}", LogLevel.Error, null); ProgressCallback?.Invoke($"Failed to close template drawing: {ex.Message}", LogLevel.Error, null);
// Still clear the reference to prevent further issues
TemplateDrawing = null; TemplateDrawing = null;
// Don't throw here as this is cleanup code - log the error but continue
} }
} }
-20
View File
@@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
namespace ExportDXF.Models
{
public class ExportRecord
{
public int Id { get; set; }
public string DrawingNumber { get; set; }
public string EquipmentNo { get; set; }
public string DrawingNo { get; set; }
public string SourceFilePath { get; set; }
public string OutputFolder { get; set; }
public DateTime ExportedAt { get; set; }
public string ExportedBy { get; set; }
public string PdfContentHash { get; set; }
public virtual ICollection<BomItem> BomItems { get; set; } = new List<BomItem>();
}
}