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:
@@ -2,7 +2,6 @@ namespace ExportDXF.Models
|
||||
{
|
||||
public class BomItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string ItemNo { get; set; } = "";
|
||||
public string PartNo { get; set; } = "";
|
||||
public int SortOrder { get; set; }
|
||||
@@ -12,13 +11,7 @@ namespace ExportDXF.Models
|
||||
public string PartName { get; set; } = "";
|
||||
public string ConfigurationName { get; set; } = "";
|
||||
public string Material { 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 CutTemplate CutTemplate { get; set; }
|
||||
}
|
||||
|
||||
public struct Size
|
||||
|
||||
@@ -4,12 +4,11 @@ namespace ExportDXF.Models
|
||||
{
|
||||
public class CutTemplate
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DxfFilePath { get; set; } = "";
|
||||
public string ContentHash { get; set; }
|
||||
public string CutTemplateName { get; set; } = "";
|
||||
public int Revision { get; set; } = 1;
|
||||
|
||||
// Sheet metal properties (moved from BomItem)
|
||||
private double? _thickness;
|
||||
public double? Thickness
|
||||
{
|
||||
@@ -25,9 +24,5 @@ namespace ExportDXF.Models
|
||||
get => _defaultBendRadius;
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using ExportDXF.Models;
|
||||
using ExportDXF.Models;
|
||||
using ExportDXF.ViewFlipDeciders;
|
||||
using SolidWorks.Interop.sldworks;
|
||||
using SolidWorks.Interop.swconst;
|
||||
@@ -28,29 +28,14 @@ namespace ExportDXF.Services
|
||||
public IViewFlipDecider ViewFlipDecider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prefix to prepend to exported filenames.
|
||||
/// Filename template with placeholders (e.g., "4321 A01 PT{item_no:2}").
|
||||
/// </summary>
|
||||
public string FilePrefix { get; set; }
|
||||
public string FilenameTemplate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Equipment number from the UI (e.g., "5028").
|
||||
/// Output folder for DXF files and Excel workbook.
|
||||
/// </summary>
|
||||
public string Equipment { 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; }
|
||||
public string OutputFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancellation token for canceling the export operation.
|
||||
@@ -82,8 +67,8 @@ namespace ExportDXF.Services
|
||||
get
|
||||
{
|
||||
return Path.Combine(
|
||||
Application.StartupPath,
|
||||
DRAWING_TEMPLATE_FOLDER,
|
||||
Application.StartupPath,
|
||||
DRAWING_TEMPLATE_FOLDER,
|
||||
DRAWING_TEMPLATE_FILE);
|
||||
}
|
||||
}
|
||||
@@ -123,23 +108,17 @@ namespace ExportDXF.Services
|
||||
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
// Close the document without saving
|
||||
SolidWorksApp.CloseDoc(title);
|
||||
ProgressCallback?.Invoke("Closed template drawing", LogLevel.Info, null);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the reference regardless of success/failure
|
||||
TemplateDrawing = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ProgressCallback?.Invoke($"Failed to close template drawing: {ex.Message}", LogLevel.Error, null);
|
||||
|
||||
// Still clear the reference to prevent further issues
|
||||
TemplateDrawing = null;
|
||||
|
||||
// Don't throw here as this is cleanup code - log the error but continue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user