diff --git a/ExportDXF/Data/ExportDxfDbContext.cs b/ExportDXF/Data/ExportDxfDbContext.cs deleted file mode 100644 index b0024ac..0000000 --- a/ExportDXF/Data/ExportDxfDbContext.cs +++ /dev/null @@ -1,74 +0,0 @@ -using ExportDXF.Models; -using Microsoft.EntityFrameworkCore; -using System.Configuration; - -namespace ExportDXF.Data -{ - public class ExportDxfDbContext : DbContext - { - public DbSet ExportRecords { get; set; } - public DbSet BomItems { get; set; } - public DbSet CutTemplates { get; set; } - - public ExportDxfDbContext() : base() - { - } - - public ExportDxfDbContext(DbContextOptions options) : base(options) - { - } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if (!optionsBuilder.IsConfigured) - { - var connectionString = ConfigurationManager.ConnectionStrings["ExportDxfDb"]?.ConnectionString - ?? "Server=localhost;Database=ExportDxfDb;Trusted_Connection=True;TrustServerCertificate=True;"; - optionsBuilder.UseSqlServer(connectionString); - } - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity(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(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(ct => ct.BomItemId) - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id); - entity.Property(e => e.CutTemplateName).HasMaxLength(100); - entity.Property(e => e.ContentHash).HasMaxLength(64); - }); - } - } -} diff --git a/ExportDXF/ExportDXF.csproj b/ExportDXF/ExportDXF.csproj index 4a45d38..fd1c36f 100644 --- a/ExportDXF/ExportDXF.csproj +++ b/ExportDXF/ExportDXF.csproj @@ -14,11 +14,6 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/ExportDXF/Migrations/20260214044511_InitialCreate.Designer.cs b/ExportDXF/Migrations/20260214044511_InitialCreate.Designer.cs deleted file mode 100644 index 4c4858b..0000000 --- a/ExportDXF/Migrations/20260214044511_InitialCreate.Designer.cs +++ /dev/null @@ -1,153 +0,0 @@ -// -using System; -using ExportDXF.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ExportDXF.Migrations -{ - [DbContext(typeof(ExportDxfDbContext))] - [Migration("20260214044511_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ConfigurationName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ContentHash") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("CutTemplateName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DefaultBendRadius") - .HasColumnType("float"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("DxfFilePath") - .HasColumnType("nvarchar(max)"); - - b.Property("ExportRecordId") - .HasColumnType("int"); - - b.Property("ItemNo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("KFactor") - .HasColumnType("float"); - - b.Property("Material") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PartName") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PartNo") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Qty") - .HasColumnType("int"); - - b.Property("SortOrder") - .HasColumnType("int"); - - b.Property("Thickness") - .HasColumnType("float"); - - b.Property("TotalQty") - .HasColumnType("int"); - - b.HasKey("ID"); - - b.HasIndex("ExportRecordId"); - - b.ToTable("BomItems"); - }); - - modelBuilder.Entity("ExportDXF.Models.ExportRecord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DrawingNumber") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ExportedAt") - .HasColumnType("datetime2"); - - b.Property("ExportedBy") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("OutputFolder") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("PdfContentHash") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("SourceFilePath") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("ExportRecords"); - }); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.HasOne("ExportDXF.Models.ExportRecord", "ExportRecord") - .WithMany("BomItems") - .HasForeignKey("ExportRecordId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExportRecord"); - }); - - modelBuilder.Entity("ExportDXF.Models.ExportRecord", b => - { - b.Navigation("BomItems"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ExportDXF/Migrations/20260214044511_InitialCreate.cs b/ExportDXF/Migrations/20260214044511_InitialCreate.cs deleted file mode 100644 index e88cc78..0000000 --- a/ExportDXF/Migrations/20260214044511_InitialCreate.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ExportDXF.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ExportRecords", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DrawingNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - SourceFilePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - OutputFolder = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - ExportedAt = table.Column(type: "datetime2", nullable: false), - ExportedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - PdfContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ExportRecords", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BomItems", - columns: table => new - { - ID = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ItemNo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - PartNo = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - SortOrder = table.Column(type: "int", nullable: false), - Qty = table.Column(type: "int", nullable: true), - TotalQty = table.Column(type: "int", nullable: true), - Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - PartName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - ConfigurationName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - Material = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - CutTemplateName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - DxfFilePath = table.Column(type: "nvarchar(max)", nullable: true), - ContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Thickness = table.Column(type: "float", nullable: true), - KFactor = table.Column(type: "float", nullable: true), - DefaultBendRadius = table.Column(type: "float", nullable: true), - ExportRecordId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BomItems", x => x.ID); - table.ForeignKey( - name: "FK_BomItems_ExportRecords_ExportRecordId", - column: x => x.ExportRecordId, - principalTable: "ExportRecords", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_BomItems_ExportRecordId", - table: "BomItems", - column: "ExportRecordId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "BomItems"); - - migrationBuilder.DropTable( - name: "ExportRecords"); - } - } -} diff --git a/ExportDXF/Migrations/20260214195856_ExtractCutTemplate.Designer.cs b/ExportDXF/Migrations/20260214195856_ExtractCutTemplate.Designer.cs deleted file mode 100644 index 6c06ec6..0000000 --- a/ExportDXF/Migrations/20260214195856_ExtractCutTemplate.Designer.cs +++ /dev/null @@ -1,188 +0,0 @@ -// -using System; -using ExportDXF.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ExportDXF.Migrations -{ - [DbContext(typeof(ExportDxfDbContext))] - [Migration("20260214195856_ExtractCutTemplate")] - partial class ExtractCutTemplate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ConfigurationName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("ExportRecordId") - .HasColumnType("int"); - - b.Property("ItemNo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Material") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PartName") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PartNo") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Qty") - .HasColumnType("int"); - - b.Property("SortOrder") - .HasColumnType("int"); - - b.Property("TotalQty") - .HasColumnType("int"); - - b.HasKey("ID"); - - b.HasIndex("ExportRecordId"); - - b.ToTable("BomItems"); - }); - - modelBuilder.Entity("ExportDXF.Models.CutTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BomItemId") - .HasColumnType("int"); - - b.Property("ContentHash") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("CutTemplateName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DefaultBendRadius") - .HasColumnType("float"); - - b.Property("DxfFilePath") - .HasColumnType("nvarchar(max)"); - - b.Property("KFactor") - .HasColumnType("float"); - - b.Property("Thickness") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("BomItemId") - .IsUnique(); - - b.ToTable("CutTemplates"); - }); - - modelBuilder.Entity("ExportDXF.Models.ExportRecord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DrawingNumber") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ExportedAt") - .HasColumnType("datetime2"); - - b.Property("ExportedBy") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("OutputFolder") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("PdfContentHash") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("SourceFilePath") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("ExportRecords"); - }); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.HasOne("ExportDXF.Models.ExportRecord", "ExportRecord") - .WithMany("BomItems") - .HasForeignKey("ExportRecordId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExportRecord"); - }); - - modelBuilder.Entity("ExportDXF.Models.CutTemplate", b => - { - b.HasOne("ExportDXF.Models.BomItem", "BomItem") - .WithOne("CutTemplate") - .HasForeignKey("ExportDXF.Models.CutTemplate", "BomItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BomItem"); - }); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.Navigation("CutTemplate"); - }); - - modelBuilder.Entity("ExportDXF.Models.ExportRecord", b => - { - b.Navigation("BomItems"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ExportDXF/Migrations/20260214195856_ExtractCutTemplate.cs b/ExportDXF/Migrations/20260214195856_ExtractCutTemplate.cs deleted file mode 100644 index bdb1d95..0000000 --- a/ExportDXF/Migrations/20260214195856_ExtractCutTemplate.cs +++ /dev/null @@ -1,114 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ExportDXF.Migrations -{ - /// - public partial class ExtractCutTemplate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ContentHash", - table: "BomItems"); - - migrationBuilder.DropColumn( - name: "CutTemplateName", - table: "BomItems"); - - migrationBuilder.DropColumn( - name: "DefaultBendRadius", - table: "BomItems"); - - migrationBuilder.DropColumn( - name: "DxfFilePath", - table: "BomItems"); - - migrationBuilder.DropColumn( - name: "KFactor", - table: "BomItems"); - - migrationBuilder.DropColumn( - name: "Thickness", - table: "BomItems"); - - migrationBuilder.CreateTable( - name: "CutTemplates", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DxfFilePath = table.Column(type: "nvarchar(max)", nullable: true), - ContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CutTemplateName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - Thickness = table.Column(type: "float", nullable: true), - KFactor = table.Column(type: "float", nullable: true), - DefaultBendRadius = table.Column(type: "float", nullable: true), - BomItemId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_CutTemplates", x => x.Id); - table.ForeignKey( - name: "FK_CutTemplates_BomItems_BomItemId", - column: x => x.BomItemId, - principalTable: "BomItems", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_CutTemplates_BomItemId", - table: "CutTemplates", - column: "BomItemId", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CutTemplates"); - - migrationBuilder.AddColumn( - name: "ContentHash", - table: "BomItems", - type: "nvarchar(64)", - maxLength: 64, - nullable: true); - - migrationBuilder.AddColumn( - name: "CutTemplateName", - table: "BomItems", - type: "nvarchar(100)", - maxLength: 100, - nullable: true); - - migrationBuilder.AddColumn( - name: "DefaultBendRadius", - table: "BomItems", - type: "float", - nullable: true); - - migrationBuilder.AddColumn( - name: "DxfFilePath", - table: "BomItems", - type: "nvarchar(max)", - nullable: true); - - migrationBuilder.AddColumn( - name: "KFactor", - table: "BomItems", - type: "float", - nullable: true); - - migrationBuilder.AddColumn( - name: "Thickness", - table: "BomItems", - type: "float", - nullable: true); - } - } -} diff --git a/ExportDXF/Migrations/ExportDxfDbContextModelSnapshot.cs b/ExportDXF/Migrations/ExportDxfDbContextModelSnapshot.cs deleted file mode 100644 index 130ebad..0000000 --- a/ExportDXF/Migrations/ExportDxfDbContextModelSnapshot.cs +++ /dev/null @@ -1,185 +0,0 @@ -// -using System; -using ExportDXF.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ExportDXF.Migrations -{ - [DbContext(typeof(ExportDxfDbContext))] - partial class ExportDxfDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ID")); - - b.Property("ConfigurationName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("ExportRecordId") - .HasColumnType("int"); - - b.Property("ItemNo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Material") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("PartName") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PartNo") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Qty") - .HasColumnType("int"); - - b.Property("SortOrder") - .HasColumnType("int"); - - b.Property("TotalQty") - .HasColumnType("int"); - - b.HasKey("ID"); - - b.HasIndex("ExportRecordId"); - - b.ToTable("BomItems"); - }); - - modelBuilder.Entity("ExportDXF.Models.CutTemplate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("BomItemId") - .HasColumnType("int"); - - b.Property("ContentHash") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("CutTemplateName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("DefaultBendRadius") - .HasColumnType("float"); - - b.Property("DxfFilePath") - .HasColumnType("nvarchar(max)"); - - b.Property("KFactor") - .HasColumnType("float"); - - b.Property("Thickness") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("BomItemId") - .IsUnique(); - - b.ToTable("CutTemplates"); - }); - - modelBuilder.Entity("ExportDXF.Models.ExportRecord", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DrawingNumber") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("ExportedAt") - .HasColumnType("datetime2"); - - b.Property("ExportedBy") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("OutputFolder") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("PdfContentHash") - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b.Property("SourceFilePath") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("ExportRecords"); - }); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.HasOne("ExportDXF.Models.ExportRecord", "ExportRecord") - .WithMany("BomItems") - .HasForeignKey("ExportRecordId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExportRecord"); - }); - - modelBuilder.Entity("ExportDXF.Models.CutTemplate", b => - { - b.HasOne("ExportDXF.Models.BomItem", "BomItem") - .WithOne("CutTemplate") - .HasForeignKey("ExportDXF.Models.CutTemplate", "BomItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("BomItem"); - }); - - modelBuilder.Entity("ExportDXF.Models.BomItem", b => - { - b.Navigation("CutTemplate"); - }); - - modelBuilder.Entity("ExportDXF.Models.ExportRecord", b => - { - b.Navigation("BomItems"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ExportDXF/Services/FileExportService.cs b/ExportDXF/Services/FileExportService.cs deleted file mode 100644 index 80482ee..0000000 --- a/ExportDXF/Services/FileExportService.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.IO; - -namespace ExportDXF.Services -{ - public interface IFileExportService - { - string OutputFolder { get; } - string GetDrawingOutputFolder(string equipment, string drawingNo); - string SaveDxfFile(string sourcePath, string drawingNumber, string itemNo); - string SavePdfFile(string sourcePath, string drawingNumber, string outputFolder = null); - void EnsureOutputFolderExists(); - string StashFile(string filePath); - void ArchiveFile(string stashPath, string originalPath); - void DiscardStash(string stashPath); - } - - public class FileExportService : IFileExportService - { - public string OutputFolder { get; } - - public FileExportService(string outputFolder) - { - OutputFolder = outputFolder ?? throw new ArgumentNullException(nameof(outputFolder)); - EnsureOutputFolderExists(); - } - - public void EnsureOutputFolderExists() - { - if (!Directory.Exists(OutputFolder)) - { - Directory.CreateDirectory(OutputFolder); - } - } - - public string GetDrawingOutputFolder(string equipment, string drawingNo) - { - if (string.IsNullOrEmpty(equipment) || string.IsNullOrEmpty(drawingNo)) - return OutputFolder; - - var folder = Path.Combine(OutputFolder, equipment, drawingNo); - if (!Directory.Exists(folder)) - Directory.CreateDirectory(folder); - - return folder; - } - - public string SaveDxfFile(string sourcePath, string drawingNumber, string itemNo) - { - if (string.IsNullOrEmpty(sourcePath)) - throw new ArgumentNullException(nameof(sourcePath)); - - var fileName = !string.IsNullOrEmpty(drawingNumber) && !string.IsNullOrEmpty(itemNo) - ? $"{drawingNumber} PT{itemNo}.dxf" - : Path.GetFileName(sourcePath); - - var destPath = Path.Combine(OutputFolder, fileName); - - // If source and dest are the same, skip copy - if (!string.Equals(sourcePath, destPath, StringComparison.OrdinalIgnoreCase)) - { - File.Copy(sourcePath, destPath, overwrite: true); - } - - return destPath; - } - - public string SavePdfFile(string sourcePath, string drawingNumber, string outputFolder = null) - { - if (string.IsNullOrEmpty(sourcePath)) - throw new ArgumentNullException(nameof(sourcePath)); - - var folder = outputFolder ?? OutputFolder; - var fileName = !string.IsNullOrEmpty(drawingNumber) - ? $"{drawingNumber}.pdf" - : Path.GetFileName(sourcePath); - - var destPath = Path.Combine(folder, fileName); - - // If source and dest are the same, skip copy - if (!string.Equals(sourcePath, destPath, StringComparison.OrdinalIgnoreCase)) - { - File.Copy(sourcePath, destPath, overwrite: true); - } - - return destPath; - } - - public string StashFile(string filePath) - { - if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) - return null; - - var stashPath = filePath + ".bak"; - File.Move(filePath, stashPath, overwrite: true); - return stashPath; - } - - public void ArchiveFile(string stashPath, string originalPath) - { - if (string.IsNullOrEmpty(stashPath) || !File.Exists(stashPath)) - return; - - var fileDir = Path.GetDirectoryName(originalPath) ?? OutputFolder; - var archiveDir = Path.Combine(fileDir, "_archive"); - if (!Directory.Exists(archiveDir)) - Directory.CreateDirectory(archiveDir); - - var originalName = Path.GetFileNameWithoutExtension(originalPath); - var ext = Path.GetExtension(originalPath); - var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss"); - var archiveName = $"{originalName} [{timestamp}]{ext}"; - var archivePath = Path.Combine(archiveDir, archiveName); - - File.Move(stashPath, archivePath, overwrite: true); - } - - public void DiscardStash(string stashPath) - { - if (!string.IsNullOrEmpty(stashPath) && File.Exists(stashPath)) - File.Delete(stashPath); - } - } -} diff --git a/ExportDXF/app.config b/ExportDXF/app.config index f67a830..169406a 100644 --- a/ExportDXF/app.config +++ b/ExportDXF/app.config @@ -5,11 +5,6 @@ - + - - -