Compare commits
3 Commits
d29d9a0e06
...
5cf7e1f1e5
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cf7e1f1e5 | |||
| 35ac0fb3f8 | |||
| cc34fb43b6 |
23
.claude/commands/organize-commits.md
Normal file
23
.claude/commands/organize-commits.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Organize Changes into Logical Commits
|
||||
|
||||
Analyze all current git changes and organize them into logical, atomic commits. Follow these steps:
|
||||
|
||||
1. **Analyze Changes**: Run git status and git diff to see all modified and untracked files
|
||||
2. **Review Content**: Examine the actual changes in each file to understand what was modified
|
||||
3. **Group Logically**: Group changes by:
|
||||
- Feature or bug fix
|
||||
- Service or component
|
||||
- Related functionality
|
||||
- UI changes vs business logic vs API changes
|
||||
4. **Create Commits**: For each logical group:
|
||||
- Stage only the relevant files
|
||||
- Create a descriptive commit message following conventional commit format
|
||||
- Use prefixes like feat:, fix:, refactor:, chore:, docs:, etc.
|
||||
5. **Verify**: After all commits, show git log to confirm all changes were committed
|
||||
|
||||
Important guidelines:
|
||||
- Keep commits atomic (one logical change per commit)
|
||||
- Write clear, descriptive commit messages
|
||||
- Don't mix unrelated changes in the same commit
|
||||
- Follow the existing commit message style in the repository
|
||||
- Include the Claude Code attribution at the end of each commit message
|
||||
10
.claude/settings.local.json
Normal file
10
.claude/settings.local.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
70
AGENTS.md
Normal file
70
AGENTS.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
- Root solution: `ExportDXF.sln`.
|
||||
- WinForms app: `ExportDXF/ExportDXF/` (.NET Framework 4.8; SolidWorks automation). Key folders: `Forms/`, `Services/`, `Models/`, `Utilities/`, `Templates/`, `Resources/`, `ItemExtractors/`, `ViewFlipDeciders/`, `Extensions/`, `Properties/`.
|
||||
- Companion utilities: `EtchBendLines/` (standalone solution for DXF processing; includes vendored `netDxf`).
|
||||
- Sample docs: `TestDocs/` contains drawings/fixtures useful for local validation.
|
||||
- Tests: none yet; add new test projects under `tests/` (e.g., `tests/ExportDXF.Tests/`).
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
- Restore: `msbuild ExportDXF.sln /t:Restore` (or `nuget restore ExportDXF.sln`).
|
||||
- Build (Release): `msbuild ExportDXF.sln /p:Configuration=Release`.
|
||||
- Build single project: `msbuild ExportDXF/ExportDXF/ExportDXF.csproj /p:Configuration=Release`.
|
||||
- Run app: `ExportDXF/ExportDXF/bin/Release/ExportDXF.exe` (or `bin/Debug/ExportDXF.exe` after a Debug build).
|
||||
- Prereqs: Visual Studio 2019/2022 or Build Tools with .NET Framework 4.8 targeting pack; SolidWorks installed for automation features (app starts without SW but SW-dependent actions require it).
|
||||
- Format: `dotnet format` from repo root if .NET SDK is installed; otherwise use VS “Format Document”.
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
- C#: 4-space indent, braces on new lines, nullable where supported.
|
||||
- Naming: PascalCase for types/methods; camelCase for locals/fields; `Async` suffix for async methods.
|
||||
- Structure: Keep UI in `Forms/` thin; delegate work to `Services/` and `Utilities/`. One class per file; filename matches type (e.g., `DxfExportService.cs`).
|
||||
- Interop: Isolate SolidWorks COM/interop behind interfaces for testability; prefer dependency injection where practical.
|
||||
|
||||
## Testing Guidelines
|
||||
- Framework: xUnit recommended. Name files `*Tests.cs` and methods `MethodName_Should_DoThing`.
|
||||
- Location: `tests/ExportDXF.Tests/` with reference to the app or extracted class libraries.
|
||||
- Scope: Favor service- and utility-level tests; avoid UI surface. Mock/abstract SolidWorks interop.
|
||||
- Run: `dotnet test` (add when tests exist).
|
||||
|
||||
## Commit & Pull Request Guidelines
|
||||
- Messages: imperative, present tense with optional scope (e.g., `ExportDXF: improve DXF export options`). Provide rationale in body and any breaking changes.
|
||||
- PRs include: clear description, linked issues (`Closes #123`), screenshots/GIFs for UI, migration notes, and local run steps.
|
||||
|
||||
## Security & Configuration Tips
|
||||
- Do not commit secrets or license keys.
|
||||
- App configuration resides in `app.config`; user/machine-specific settings should stay in user config and not be committed.
|
||||
- Keep SolidWorks version/paths configurable where possible.
|
||||
|
||||
## Agent Tools: Roslyn Bridge (C# Analysis)
|
||||
- Purpose: Use for C# code analysis, symbol queries, diagnostics, and semantic navigation via a local WebAPI bridge to Roslyn.
|
||||
- Golden rules:
|
||||
- Always use this tool first for any C#/Roslyn analysis; do not guess.
|
||||
- Always check service health/instances before querying.
|
||||
- Default to `solutionName=ExportDXF` for this repo. If you intentionally open and analyze `EtchBendLines.sln`, use `solutionName=EtchBendLines`.
|
||||
- Service assumptions:
|
||||
- WebAPI listens on `http://localhost:5001` when installed and running.
|
||||
- Visual Studio must have the target solution open for the instance to appear.
|
||||
- Quick workflow (ExportDXF):
|
||||
- List VS instances: `curl http://localhost:5001/api/instances`
|
||||
- Health check: `curl http://localhost:5001/api/health`
|
||||
- Diagnostics summary: `curl "http://localhost:5001/api/roslyn/diagnostics/summary?solutionName=ExportDXF"`
|
||||
- Errors only: `curl "http://localhost:5001/api/roslyn/diagnostics?solutionName=ExportDXF&severity=error"`
|
||||
- Warnings only: `curl "http://localhost:5001/api/roslyn/diagnostics?solutionName=ExportDXF&severity=warning"`
|
||||
- All diagnostics: `curl "http://localhost:5001/api/roslyn/diagnostics?solutionName=ExportDXF"`
|
||||
- List projects: `curl "http://localhost:5001/api/roslyn/projects?solutionName=ExportDXF"`
|
||||
- Solution overview: `curl "http://localhost:5001/api/roslyn/solution/overview?solutionName=ExportDXF"`
|
||||
- Find symbol by name: `curl "http://localhost:5001/api/roslyn/symbol/search?solutionName=ExportDXF&symbolName=TypeOrMember"`
|
||||
- Symbol at file/position: `curl "http://localhost:5001/api/roslyn/symbol?solutionName=ExportDXF&filePath=C:/full/path/File.cs&line=10&column=5"`
|
||||
- Find references: `curl "http://localhost:5001/api/roslyn/references?solutionName=ExportDXF&filePath=C:/full/path/File.cs&line=10&column=5"`
|
||||
- Notes:
|
||||
- Lines are 1-based; columns are 0-based. Use absolute file paths.
|
||||
- Get canonical file paths from the `projects` endpoint responses.
|
||||
- Prefer this tool over manual grepping for symbols/references/diagnostics.
|
||||
- Troubleshooting:
|
||||
- No instances listed: ensure Visual Studio is running with the solution open; wait up to 60s for discovery.
|
||||
- Service not reachable: verify the Roslyn Bridge WebAPI service is installed and running on port 5001.
|
||||
|
||||
- Helper script:
|
||||
- `scripts/rb.ps1` provides short commands with defaults for this repo (defaults to `-SolutionName ExportDXF`).
|
||||
- Examples: `./scripts/rb.ps1 summary`, `./scripts/rb.ps1 projects`, `./scripts/rb.ps1 symbol -SymbolName Program`.
|
||||
88
ExportDXF/Forms/MainForm.Designer.cs
generated
88
ExportDXF/Forms/MainForm.Designer.cs
generated
@@ -29,15 +29,15 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.activeDocTitleBox = new System.Windows.Forms.TextBox();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.logTextBox = new System.Windows.Forms.RichTextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.runButton = new System.Windows.Forms.Button();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.viewFlipDeciderBox = new System.Windows.Forms.ComboBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.equipmentNoBox = new System.Windows.Forms.ComboBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.comboBox2 = new System.Windows.Forms.ComboBox();
|
||||
this.drawingNoBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// activeDocTitleBox
|
||||
@@ -52,18 +52,18 @@
|
||||
this.activeDocTitleBox.TabIndex = 1;
|
||||
this.activeDocTitleBox.TextChanged += new System.EventHandler(this.activeDocTitleBox_TextChanged);
|
||||
//
|
||||
// richTextBox1
|
||||
// logTextBox
|
||||
//
|
||||
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.logTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.richTextBox1.BackColor = System.Drawing.Color.White;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(12, 106);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.ReadOnly = true;
|
||||
this.richTextBox1.Size = new System.Drawing.Size(866, 556);
|
||||
this.richTextBox1.TabIndex = 10;
|
||||
this.richTextBox1.Text = "";
|
||||
this.logTextBox.BackColor = System.Drawing.Color.White;
|
||||
this.logTextBox.Location = new System.Drawing.Point(12, 106);
|
||||
this.logTextBox.Name = "logTextBox";
|
||||
this.logTextBox.ReadOnly = true;
|
||||
this.logTextBox.Size = new System.Drawing.Size(866, 556);
|
||||
this.logTextBox.TabIndex = 10;
|
||||
this.logTextBox.Text = "";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@@ -74,17 +74,17 @@
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Active document :";
|
||||
//
|
||||
// button1
|
||||
// runButton
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.Image = global::ExportDXF.Properties.Resources.play;
|
||||
this.button1.Location = new System.Drawing.Point(884, 13);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(46, 56);
|
||||
this.button1.TabIndex = 11;
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
this.runButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.runButton.Image = global::ExportDXF.Properties.Resources.play;
|
||||
this.runButton.Location = new System.Drawing.Point(884, 13);
|
||||
this.runButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.runButton.Name = "runButton";
|
||||
this.runButton.Size = new System.Drawing.Size(46, 56);
|
||||
this.runButton.TabIndex = 11;
|
||||
this.runButton.UseVisualStyleBackColor = true;
|
||||
this.runButton.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
@@ -95,14 +95,14 @@
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "View flip decider :";
|
||||
//
|
||||
// comboBox1
|
||||
// viewFlipDeciderBox
|
||||
//
|
||||
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
this.comboBox1.Location = new System.Drawing.Point(130, 44);
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
this.comboBox1.Size = new System.Drawing.Size(432, 25);
|
||||
this.comboBox1.TabIndex = 3;
|
||||
this.viewFlipDeciderBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.viewFlipDeciderBox.FormattingEnabled = true;
|
||||
this.viewFlipDeciderBox.Location = new System.Drawing.Point(130, 44);
|
||||
this.viewFlipDeciderBox.Name = "viewFlipDeciderBox";
|
||||
this.viewFlipDeciderBox.Size = new System.Drawing.Size(432, 25);
|
||||
this.viewFlipDeciderBox.TabIndex = 3;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
@@ -131,28 +131,28 @@
|
||||
this.label5.TabIndex = 6;
|
||||
this.label5.Text = "Drawing #";
|
||||
//
|
||||
// comboBox2
|
||||
// drawingNoBox
|
||||
//
|
||||
this.comboBox2.FormattingEnabled = true;
|
||||
this.comboBox2.Location = new System.Drawing.Point(388, 75);
|
||||
this.comboBox2.Name = "comboBox2";
|
||||
this.comboBox2.Size = new System.Drawing.Size(174, 25);
|
||||
this.comboBox2.TabIndex = 7;
|
||||
this.drawingNoBox.FormattingEnabled = true;
|
||||
this.drawingNoBox.Location = new System.Drawing.Point(388, 75);
|
||||
this.drawingNoBox.Name = "drawingNoBox";
|
||||
this.drawingNoBox.Size = new System.Drawing.Size(174, 25);
|
||||
this.drawingNoBox.TabIndex = 7;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(942, 674);
|
||||
this.Controls.Add(this.comboBox2);
|
||||
this.Controls.Add(this.drawingNoBox);
|
||||
this.Controls.Add(this.equipmentNoBox);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.comboBox1);
|
||||
this.Controls.Add(this.viewFlipDeciderBox);
|
||||
this.Controls.Add(this.label4);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.logTextBox);
|
||||
this.Controls.Add(this.activeDocTitleBox);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.runButton);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MaximizeBox = false;
|
||||
@@ -167,16 +167,16 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button runButton;
|
||||
private System.Windows.Forms.TextBox activeDocTitleBox;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.RichTextBox logTextBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.ComboBox comboBox1;
|
||||
private System.Windows.Forms.ComboBox viewFlipDeciderBox;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.ComboBox equipmentNoBox;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.ComboBox comboBox2;
|
||||
private System.Windows.Forms.ComboBox drawingNoBox;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace ExportDXF.Forms
|
||||
protected override async void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
button1.Enabled = false;
|
||||
runButton.Enabled = false;
|
||||
await InitializeAsync();
|
||||
}
|
||||
private async Task InitializeAsync()
|
||||
@@ -50,7 +50,7 @@ namespace ExportDXF.Forms
|
||||
_solidWorksService.ActiveDocumentChanged += OnActiveDocumentChanged;
|
||||
LogMessage("Ready", Color.Green);
|
||||
UpdateActiveDocumentDisplay();
|
||||
button1.Enabled = true;
|
||||
runButton.Enabled = true;
|
||||
// Populate equipment and (initial) drawings
|
||||
await PopulateEquipmentAsync();
|
||||
}
|
||||
@@ -99,13 +99,29 @@ namespace ExportDXF.Forms
|
||||
var selected = equipmentNoBox.SelectedItem as CutFabApiClient.ApiEquipment;
|
||||
if (selected == null)
|
||||
{
|
||||
comboBox2.DataSource = null;
|
||||
drawingNoBox.DataSource = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the currently selected drawing number
|
||||
var currentSelectedDrawing = drawingNoBox.SelectedItem as CutFabApiClient.ApiDrawingSummary;
|
||||
var previousDrawingNumber = currentSelectedDrawing?.DrawingNumber;
|
||||
|
||||
var drawings = await _apiClient.GetDrawingsForEquipmentAsync(selected.ID);
|
||||
comboBox2.DisplayMember = nameof(CutFabApiClient.ApiDrawingSummary.DrawingNumber);
|
||||
comboBox2.ValueMember = nameof(CutFabApiClient.ApiDrawingSummary.ID);
|
||||
comboBox2.DataSource = drawings;
|
||||
drawingNoBox.DisplayMember = nameof(CutFabApiClient.ApiDrawingSummary.DrawingNumber);
|
||||
drawingNoBox.ValueMember = nameof(CutFabApiClient.ApiDrawingSummary.ID);
|
||||
drawingNoBox.DataSource = drawings;
|
||||
|
||||
// Try to restore the previous selection if it exists in the new list
|
||||
if (!string.IsNullOrEmpty(previousDrawingNumber) && drawings.Count > 0)
|
||||
{
|
||||
var matchingDrawing = drawings.FirstOrDefault(d => d.DrawingNumber == previousDrawingNumber);
|
||||
if (matchingDrawing != null)
|
||||
{
|
||||
drawingNoBox.SelectedItem = matchingDrawing;
|
||||
}
|
||||
}
|
||||
|
||||
LogMessage($"Loaded {drawings.Count} drawing(s) for equipment {selected.EquipmentNumber}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -129,8 +145,8 @@ namespace ExportDXF.Forms
|
||||
items.Remove(automatic);
|
||||
items.Insert(0, automatic);
|
||||
}
|
||||
comboBox1.DataSource = items;
|
||||
comboBox1.DisplayMember = "Name";
|
||||
viewFlipDeciderBox.DataSource = items;
|
||||
viewFlipDeciderBox.DisplayMember = "Name";
|
||||
}
|
||||
private async void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -157,7 +173,7 @@ namespace ExportDXF.Forms
|
||||
return;
|
||||
}
|
||||
var viewFlipDecider = GetSelectedViewFlipDecider();
|
||||
var drawingNumberText = comboBox2.Text?.Trim();
|
||||
var drawingNumberText = drawingNoBox.Text?.Trim();
|
||||
var selectedEquipment = equipmentNoBox.SelectedItem as CutFabApiClient.ApiEquipment;
|
||||
var exportContext = new ExportContext
|
||||
{
|
||||
@@ -190,30 +206,30 @@ namespace ExportDXF.Forms
|
||||
}
|
||||
private void CancelExport()
|
||||
{
|
||||
button1.Enabled = false;
|
||||
runButton.Enabled = false;
|
||||
_cancellationTokenSource?.Cancel();
|
||||
}
|
||||
private IViewFlipDecider GetSelectedViewFlipDecider()
|
||||
{
|
||||
var item = comboBox1.SelectedItem as ViewFlipDeciderComboboxItem;
|
||||
var item = viewFlipDeciderBox.SelectedItem as ViewFlipDeciderComboboxItem;
|
||||
return item?.ViewFlipDecider;
|
||||
}
|
||||
private void UpdateUIForExportStart()
|
||||
{
|
||||
activeDocTitleBox.Enabled = false;
|
||||
comboBox1.Enabled = false;
|
||||
button1.Image = Properties.Resources.stop_alt;
|
||||
if (richTextBox1.TextLength != 0)
|
||||
viewFlipDeciderBox.Enabled = false;
|
||||
runButton.Image = Properties.Resources.stop_alt;
|
||||
if (logTextBox.TextLength != 0)
|
||||
{
|
||||
richTextBox1.AppendText("\n\n");
|
||||
logTextBox.AppendText("\n\n");
|
||||
}
|
||||
}
|
||||
private void UpdateUIForExportComplete()
|
||||
{
|
||||
activeDocTitleBox.Enabled = true;
|
||||
comboBox1.Enabled = true;
|
||||
button1.Image = Properties.Resources.play;
|
||||
button1.Enabled = true;
|
||||
viewFlipDeciderBox.Enabled = true;
|
||||
runButton.Image = Properties.Resources.play;
|
||||
runButton.Enabled = true;
|
||||
}
|
||||
private void OnActiveDocumentChanged(object sender, EventArgs e)
|
||||
{
|
||||
@@ -233,20 +249,19 @@ namespace ExportDXF.Forms
|
||||
private void UpdatePrefixFromActiveDocument()
|
||||
{
|
||||
var activeDoc = _solidWorksService.GetActiveDocument();
|
||||
|
||||
if (activeDoc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeDoc.DocumentType == DocumentType.Drawing)
|
||||
{
|
||||
var drawingInfo = DrawingInfo.Parse(activeDoc.Title);
|
||||
|
||||
if (drawingInfo != null)
|
||||
{
|
||||
drawingNoBox.Text = drawingInfo.ToString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
private void activeDocTitleBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
@@ -261,13 +276,13 @@ namespace ExportDXF.Forms
|
||||
}
|
||||
if (color.HasValue)
|
||||
{
|
||||
richTextBox1.AppendText(message + System.Environment.NewLine, color.Value);
|
||||
logTextBox.AppendText(message + System.Environment.NewLine, color.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
richTextBox1.AppendText(message + System.Environment.NewLine);
|
||||
logTextBox.AppendText(message + System.Environment.NewLine);
|
||||
}
|
||||
richTextBox1.ScrollToCaret();
|
||||
logTextBox.ScrollToCaret();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,13 @@ namespace ExportDXF.Services
|
||||
Task<int?> CreateDrawingAsync(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> 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<bool> AutoLinkTemplatesAsync(int drawingId);
|
||||
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;
|
||||
using (var form = new MultipartFormDataContent())
|
||||
@@ -177,6 +183,11 @@ namespace ExportDXF.Services
|
||||
form.Add(new StringContent(thickness.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)), "thickness");
|
||||
if (kfactor.HasValue)
|
||||
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);
|
||||
return resp.IsSuccessStatusCode;
|
||||
|
||||
@@ -387,10 +387,12 @@ namespace ExportDXF.Services
|
||||
string zipPath = CreateZipWithSingleFile(dxfPath);
|
||||
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? 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);
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user