fix: resolve drawing dropdown race condition and save PDF hash to export record

Detach EquipmentBox event before programmatically setting equipment to
prevent async UpdateDrawingDropdownAsync from clearing the drawing
selection and duplicating entries. Also update ExportRecord.PdfContentHash
in StorePdfAsync so the web frontend can serve PDF downloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 22:40:22 -05:00
parent c06d834e05
commit 463916c75c
2 changed files with 19 additions and 0 deletions

View File

@@ -477,6 +477,9 @@ namespace ExportDXF.Forms
if (drawingInfo != null)
{
// Detach event to prevent async race when setting equipment
equipmentBox.SelectedIndexChanged -= EquipmentBox_SelectedIndexChanged;
if (!string.IsNullOrEmpty(drawingInfo.EquipmentNo))
{
if (!equipmentBox.Items.Contains(drawingInfo.EquipmentNo))
@@ -484,6 +487,11 @@ namespace ExportDXF.Forms
equipmentBox.Text = drawingInfo.EquipmentNo;
}
// Load drawings for the selected equipment, then set drawing number
await UpdateDrawingDropdownAsync();
equipmentBox.SelectedIndexChanged += EquipmentBox_SelectedIndexChanged;
if (!string.IsNullOrEmpty(drawingInfo.DrawingNo))
{
if (!drawingNoBox.Items.Contains(drawingInfo.DrawingNo))

View File

@@ -82,6 +82,17 @@ namespace FabWorks.Api.Services
var wasUnchanged = previousHash != null && previousHash == contentHash;
var isNewFile = await StoreBlobAsync(stream, contentHash, "pdf");
// Update the export record with the PDF content hash
if (exportRecordId.HasValue)
{
var record = await _db.ExportRecords.FindAsync(exportRecordId.Value);
if (record != null)
{
record.PdfContentHash = contentHash;
await _db.SaveChangesAsync();
}
}
return new FileUploadResult
{
ContentHash = contentHash,