feat(api): add sheet metal properties to DXF upload

- Add defaultBendRadius and material parameters to UploadDxfZipAsync
- Pass bend radius and material from BOM items to API
- Enables more complete sheet metal specification in CutFab

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-30 17:29:56 -04:00
parent cc34fb43b6
commit 35ac0fb3f8
2 changed files with 17 additions and 4 deletions

View File

@@ -18,7 +18,13 @@ namespace ExportDXF.Services
Task<int?> CreateDrawingAsync(int equipmentId, string drawingNumber); Task<int?> CreateDrawingAsync(int equipmentId, string drawingNumber);
Task<CutFabApiClient.ApiResponse<int?>> CreateDrawingWithInfoAsync(int equipmentId, string drawingNumber); Task<CutFabApiClient.ApiResponse<int?>> CreateDrawingWithInfoAsync(int equipmentId, string drawingNumber);
Task<bool> UploadDrawingPdfAsync(string drawingNumber, string pdfPath, string uploadedBy = null, string notes = null); Task<bool> UploadDrawingPdfAsync(string drawingNumber, string pdfPath, string uploadedBy = null, string notes = null);
Task<bool> UploadDxfZipAsync(int drawingId, string zipPath, double? thickness = null, double? kfactor = null); Task<bool> UploadDxfZipAsync(
int drawingId,
string zipPath,
double? thickness = null,
double? kfactor = null,
double? defaultBendRadius = null,
string material = null);
Task<int?> CreateBomItemAsync(object upsertBomItemDto); Task<int?> CreateBomItemAsync(object upsertBomItemDto);
Task<bool> AutoLinkTemplatesAsync(int drawingId); Task<bool> AutoLinkTemplatesAsync(int drawingId);
Task<List<ApiEquipment>> GetEquipmentAsync(); Task<List<ApiEquipment>> GetEquipmentAsync();
@@ -162,7 +168,7 @@ namespace ExportDXF.Services
} }
} }
public async Task<bool> UploadDxfZipAsync(int drawingId, string zipPath, double? thickness = null, double? kfactor = null) public async Task<bool> UploadDxfZipAsync(int drawingId, string zipPath, double? thickness = null, double? kfactor = null, double? defaultBendRadius = null, string material = null)
{ {
if (!File.Exists(zipPath)) return false; if (!File.Exists(zipPath)) return false;
using (var form = new MultipartFormDataContent()) using (var form = new MultipartFormDataContent())
@@ -177,6 +183,11 @@ namespace ExportDXF.Services
form.Add(new StringContent(thickness.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "thickness"); form.Add(new StringContent(thickness.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "thickness");
if (kfactor.HasValue) if (kfactor.HasValue)
form.Add(new StringContent(kfactor.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "kfactor"); form.Add(new StringContent(kfactor.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "kfactor");
// Add default bend radius and material if provided
if (defaultBendRadius.HasValue)
form.Add(new StringContent(defaultBendRadius.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "defaultBendRadius");
if (!string.IsNullOrWhiteSpace(material))
form.Add(new StringContent(material), "material");
var resp = await _http.PostAsync($"{_baseUrl}/api/Drawings/{drawingId}/upload-dxf-templates", form).ConfigureAwait(false); var resp = await _http.PostAsync($"{_baseUrl}/api/Drawings/{drawingId}/upload-dxf-templates", form).ConfigureAwait(false);
return resp.IsSuccessStatusCode; return resp.IsSuccessStatusCode;

View File

@@ -387,10 +387,12 @@ namespace ExportDXF.Services
string zipPath = CreateZipWithSingleFile(dxfPath); string zipPath = CreateZipWithSingleFile(dxfPath);
try try
{ {
// Pass thickness and kfactor from the item // Pass thickness, kfactor, default bend radius and material from the item
double? thickness = item.Thickness > 0 ? item.Thickness : (double?)null; double? thickness = item.Thickness > 0 ? item.Thickness : (double?)null;
double? kfactor = item.KFactor > 0 ? item.KFactor : (double?)null; double? kfactor = item.KFactor > 0 ? item.KFactor : (double?)null;
var okZip = _apiClient.UploadDxfZipAsync(drawingId.Value, zipPath, thickness, kfactor).GetAwaiter().GetResult(); double? defaultBendRadius = item.BendRadius > 0 ? item.BendRadius : (double?)null;
string material = string.IsNullOrWhiteSpace(item.Material) ? null : item.Material;
var okZip = _apiClient.UploadDxfZipAsync(drawingId.Value, zipPath, thickness, kfactor, defaultBendRadius, material).GetAwaiter().GetResult();
LogProgress(context, okZip ? $"Uploaded DXF: {Path.GetFileName(dxfPath)}" : $"Failed to upload DXF: {Path.GetFileName(dxfPath)}", okZip ? Color.Green : Color.Red); LogProgress(context, okZip ? $"Uploaded DXF: {Path.GetFileName(dxfPath)}" : $"Failed to upload DXF: {Path.GetFileName(dxfPath)}", okZip ? Color.Green : Color.Red);
} }
finally finally