feat: add FabWorks.Core shared library with entity models and FormProgram

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 06:20:13 -05:00
parent 719dca1ca5
commit 78a8a2197d
7 changed files with 226 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
using FabWorks.Core.Models;
using Microsoft.EntityFrameworkCore;
namespace FabWorks.Core.Data
{
public class FabWorksDbContext : DbContext
{
public DbSet<ExportRecord> ExportRecords { get; set; }
public DbSet<BomItem> BomItems { get; set; }
public DbSet<CutTemplate> CutTemplates { get; set; }
public DbSet<FormProgram> FormPrograms { get; set; }
public FabWorksDbContext(DbContextOptions<FabWorksDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ExportRecord>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.DrawingNumber).HasMaxLength(100);
entity.Property(e => e.SourceFilePath).HasMaxLength(500);
entity.Property(e => e.OutputFolder).HasMaxLength(500);
entity.Property(e => e.ExportedBy).HasMaxLength(100);
entity.Property(e => e.PdfContentHash).HasMaxLength(64);
entity.HasMany(e => e.BomItems)
.WithOne(b => b.ExportRecord)
.HasForeignKey(b => b.ExportRecordId)
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<BomItem>(entity =>
{
entity.HasKey(e => e.ID);
entity.Property(e => e.ItemNo).HasMaxLength(50);
entity.Property(e => e.PartNo).HasMaxLength(100);
entity.Property(e => e.Description).HasMaxLength(500);
entity.Property(e => e.PartName).HasMaxLength(200);
entity.Property(e => e.ConfigurationName).HasMaxLength(100);
entity.Property(e => e.Material).HasMaxLength(100);
entity.HasOne(e => e.CutTemplate)
.WithOne(ct => ct.BomItem)
.HasForeignKey<CutTemplate>(ct => ct.BomItemId)
.OnDelete(DeleteBehavior.Cascade);
entity.HasOne(e => e.FormProgram)
.WithOne(fp => fp.BomItem)
.HasForeignKey<FormProgram>(fp => fp.BomItemId)
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<CutTemplate>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.DxfFilePath).HasMaxLength(500);
entity.Property(e => e.CutTemplateName).HasMaxLength(100);
entity.Property(e => e.ContentHash).HasMaxLength(64);
});
modelBuilder.Entity<FormProgram>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.ProgramFilePath).HasMaxLength(500);
entity.Property(e => e.ContentHash).HasMaxLength(64);
entity.Property(e => e.ProgramName).HasMaxLength(200);
entity.Property(e => e.MaterialType).HasMaxLength(50);
entity.Property(e => e.UpperToolNames).HasMaxLength(500);
entity.Property(e => e.LowerToolNames).HasMaxLength(500);
entity.Property(e => e.SetupNotes).HasMaxLength(2000);
});
}
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.11">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,22 @@
namespace FabWorks.Core.Models
{
public class BomItem
{
public int ID { get; set; }
public string ItemNo { get; set; } = "";
public string PartNo { get; set; } = "";
public int SortOrder { get; set; }
public int? Qty { get; set; }
public int? TotalQty { get; set; }
public string Description { get; set; } = "";
public string PartName { get; set; } = "";
public string ConfigurationName { get; set; } = "";
public string Material { get; set; } = "";
public int ExportRecordId { get; set; }
public virtual ExportRecord ExportRecord { get; set; }
public virtual CutTemplate CutTemplate { get; set; }
public virtual FormProgram FormProgram { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using System;
namespace FabWorks.Core.Models
{
public class CutTemplate
{
public int Id { get; set; }
public string DxfFilePath { get; set; } = "";
public string ContentHash { get; set; }
public string CutTemplateName { get; set; } = "";
private double? _thickness;
public double? Thickness
{
get => _thickness;
set => _thickness = value.HasValue ? Math.Round(value.Value, 8) : null;
}
public double? KFactor { get; set; }
private double? _defaultBendRadius;
public double? DefaultBendRadius
{
get => _defaultBendRadius;
set => _defaultBendRadius = value.HasValue ? Math.Round(value.Value, 8) : null;
}
public int BomItemId { get; set; }
public virtual BomItem BomItem { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
namespace FabWorks.Core.Models
{
public class ExportRecord
{
public int Id { get; set; }
public string DrawingNumber { 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>();
}
}

View File

@@ -0,0 +1,20 @@
namespace FabWorks.Core.Models
{
public class FormProgram
{
public int Id { get; set; }
public string ProgramFilePath { get; set; } = "";
public string ContentHash { get; set; }
public string ProgramName { get; set; } = "";
public double? Thickness { get; set; }
public string MaterialType { get; set; } = "";
public double? KFactor { get; set; }
public int BendCount { get; set; }
public string UpperToolNames { get; set; } = "";
public string LowerToolNames { get; set; } = "";
public string SetupNotes { get; set; } = "";
public int BomItemId { get; set; }
public virtual BomItem BomItem { get; set; }
}
}