From 4fbd2641815d0a73d448e4645c9b1444499489f6 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 6 Jan 2026 23:42:42 -0500 Subject: [PATCH] refactor(DataAccess): remove duplicate Models and Attributes (now in Core/ExcelIO) --- .../Attributes/OutputColumnAttribute.cs | 58 ------ .../Attributes/OutputTableAttribute.cs | 23 --- .../Models/Results/MisNonMatchSearchResult.cs | 82 -------- .../Models/Results/MisSearchResult.cs | 124 ------------ .../Models/Results/SearchResult.cs | 179 ------------------ .../Models/SearchModel.cs | 56 ------ .../Services/SearchProcessor.cs | 1 - 7 files changed, 523 deletions(-) delete mode 100644 NEW/src/JdeScoping.DataAccess/Attributes/OutputColumnAttribute.cs delete mode 100644 NEW/src/JdeScoping.DataAccess/Attributes/OutputTableAttribute.cs delete mode 100644 NEW/src/JdeScoping.DataAccess/Models/Results/MisNonMatchSearchResult.cs delete mode 100644 NEW/src/JdeScoping.DataAccess/Models/Results/MisSearchResult.cs delete mode 100644 NEW/src/JdeScoping.DataAccess/Models/Results/SearchResult.cs delete mode 100644 NEW/src/JdeScoping.DataAccess/Models/SearchModel.cs diff --git a/NEW/src/JdeScoping.DataAccess/Attributes/OutputColumnAttribute.cs b/NEW/src/JdeScoping.DataAccess/Attributes/OutputColumnAttribute.cs deleted file mode 100644 index f0b810b..0000000 --- a/NEW/src/JdeScoping.DataAccess/Attributes/OutputColumnAttribute.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace JdeScoping.DataAccess.Attributes; - -/// -/// Excel output column specification attribute. -/// -[AttributeUsage(AttributeTargets.Property)] -public class OutputColumnAttribute : Attribute -{ - /// - /// Standard format. - /// - public const string StdFormat = "@"; - - /// - /// Standard date format. - /// - public const string DateFormat = "[$-409]MM/dd/yyyy;@"; - - /// - /// Standard timestamp format. - /// - public const string TimestampFormat = "[$-409]m/d/yy h:mm AM/PM;@"; - - /// - /// Wrapped text column default width. - /// - public const double WrappedColumnWidth = 65; - - /// - /// Order to display column. - /// - public int Order { get; set; } - - /// - /// Override text to display for column header. - /// - public string HeaderText { get; set; } = string.Empty; - - /// - /// Column format (Excel formatting string). - /// - public string Format { get; set; } = StdFormat; - - /// - /// Whether or not width should be set automatically. - /// - public bool AutoWidth { get; set; } = true; - - /// - /// Manually set width (only used if AutoWidth = FALSE). - /// - public double Width { get; set; } - - /// - /// Whether or not text should be wrapped. - /// - public bool WrapText { get; set; } -} diff --git a/NEW/src/JdeScoping.DataAccess/Attributes/OutputTableAttribute.cs b/NEW/src/JdeScoping.DataAccess/Attributes/OutputTableAttribute.cs deleted file mode 100644 index 0165888..0000000 --- a/NEW/src/JdeScoping.DataAccess/Attributes/OutputTableAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace JdeScoping.DataAccess.Attributes; - -/// -/// Excel output table specification attribute. -/// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] -public class OutputTableAttribute : Attribute -{ - /// - /// Output tab name in Excel. - /// - public string TabName { get; set; } = string.Empty; - - /// - /// Table name for the Excel table. - /// - public string TableName { get; set; } = string.Empty; - - /// - /// Whether or not merged header should be shown. - /// - public bool ShowHeader { get; set; } -} diff --git a/NEW/src/JdeScoping.DataAccess/Models/Results/MisNonMatchSearchResult.cs b/NEW/src/JdeScoping.DataAccess/Models/Results/MisNonMatchSearchResult.cs deleted file mode 100644 index 21b8e7f..0000000 --- a/NEW/src/JdeScoping.DataAccess/Models/Results/MisNonMatchSearchResult.cs +++ /dev/null @@ -1,82 +0,0 @@ -using JdeScoping.DataAccess.Attributes; - -namespace JdeScoping.DataAccess.Models.Results; - -/// -/// MIS non-match reporting model. -/// -[OutputTable(TabName = "Investigation", TableName = "Investigation")] -public sealed record MisNonMatchSearchResult -{ - /// - /// Work order job step work center code. - /// - [OutputColumn(Order = 10, HeaderText = "Work Center Code")] - public string WorkCenterCode { get; init; } = string.Empty; - - /// - /// Work order unique number. - /// - [OutputColumn(Order = 20, HeaderText = "Work Order Number")] - public long WorkOrderNumber { get; init; } - - /// - /// Work order start date. - /// - [OutputColumn(Order = 30, HeaderText = "Work Order Start Date", Format = OutputColumnAttribute.DateFormat)] - public DateTime WorkOrderStartDate { get; init; } - - /// - /// Work order job step number. - /// - [OutputColumn(Order = 40, HeaderText = "Job Step Number")] - public decimal JobStepNumber { get; init; } - - /// - /// Work order job step description. - /// - [OutputColumn(Order = 50, HeaderText = "Function Operation Description")] - public string JobStepDescription { get; init; } = string.Empty; - - /// - /// Work order job step completion date. - /// - [OutputColumn(Order = 60, HeaderText = "Job Step End Date", Format = OutputColumnAttribute.DateFormat)] - public DateTime? JobStepEndDate { get; init; } - - /// - /// Work order job step function code. - /// - [OutputColumn(Order = 70, HeaderText = "Function Code")] - public string FunctionCode { get; init; } = string.Empty; - - /// - /// Whether the job step was added (not in original router). - /// - [OutputColumn(Order = 75, HeaderText = "Was Job Step Added?")] - public bool WasJobStepAdded { get; init; } - - /// - /// Matched work order job step number (match to original router by work order number, work center code, and function code). - /// - [OutputColumn(Order = 76, HeaderText = "Matched Job Step Number")] - public decimal? MatchedJobStepNumber { get; init; } - - /// - /// Work order item number. - /// - [OutputColumn(Order = 80, HeaderText = "Item Number")] - public string ItemNumber { get; init; } = string.Empty; - - /// - /// Work order item description. - /// - [OutputColumn(Order = 90, HeaderText = "Item Description")] - public string ItemDescription { get; init; } = string.Empty; - - /// - /// Work order router type. - /// - [OutputColumn(Order = 100, HeaderText = "Routing Type")] - public string RoutingType { get; init; } = string.Empty; -} diff --git a/NEW/src/JdeScoping.DataAccess/Models/Results/MisSearchResult.cs b/NEW/src/JdeScoping.DataAccess/Models/Results/MisSearchResult.cs deleted file mode 100644 index 5fa7930..0000000 --- a/NEW/src/JdeScoping.DataAccess/Models/Results/MisSearchResult.cs +++ /dev/null @@ -1,124 +0,0 @@ -using JdeScoping.DataAccess.Attributes; - -namespace JdeScoping.DataAccess.Models.Results; - -/// -/// MIS data reporting model. -/// -[OutputTable(TabName = "MIS Info", TableName = "MIS_Info")] -public sealed record MisSearchResult -{ - /// - /// Item unique number. - /// - [OutputColumn(Order = 10, HeaderText = "Item Number")] - public string ItemNumber { get; init; } = string.Empty; - - /// - /// Item description. - /// - [OutputColumn(Order = 50, HeaderText = "Item Description")] - public string ItemDescription { get; init; } = string.Empty; - - /// - /// Operation job step number. - /// - [OutputColumn(Order = 20, HeaderText = "MIS Job Step Sequence Number")] - public string SequenceNumber { get; init; } = string.Empty; - - /// - /// MIS unique number. - /// - [OutputColumn(Order = 30, HeaderText = "MIS Number")] - public string MisNumber { get; init; } = string.Empty; - - /// - /// MIS revision ID. - /// - [OutputColumn(Order = 40, HeaderText = "MIS Revision")] - public string RevId { get; init; } = string.Empty; - - /// - /// MIS release status. - /// - [OutputColumn(Order = 60, HeaderText = "MIS Release Status")] - public string Status { get; init; } = string.Empty; - - /// - /// MIS release date. - /// - [OutputColumn(Order = 70, HeaderText = "MIS Release Date", Format = OutputColumnAttribute.TimestampFormat)] - public DateTime? ReleaseDate { get; init; } - - /// - /// Branch unique code. - /// - [OutputColumn(Order = 80, HeaderText = "Branch Code")] - public string BranchCode { get; init; } = string.Empty; - - /// - /// Job step number. - /// - [OutputColumn(Order = 90, HeaderText = "Job Step Sequence Number")] - public decimal JobStepSequenceNumber { get; init; } - - /// - /// Job step number for matched F3112Z1 / F3111 record. - /// - [OutputColumn(Order = 100, HeaderText = "Matched Sequence Number")] - public decimal? MatchedSequenceNumber { get; init; } - - /// - /// Whether or not the job step was matched to F3112Z1 record. - /// - [OutputColumn(Order = 110, HeaderText = "Matched to F3112Z1?")] - public bool RoutingMatch { get; init; } - - /// - /// Whether or not the job step was matched to F3111 record. - /// - [OutputColumn(Order = 120, HeaderText = "Matched to F3003?")] - public bool MasterMatch { get; init; } - - /// - /// Job step function description. - /// - [OutputColumn(Order = 130, HeaderText = "Function Operation Description")] - public string FunctionOperationDescription { get; init; } = string.Empty; - - /// - /// Characteristic number. - /// - [OutputColumn(Order = 140, HeaderText = "Char Number")] - public string CharNumber { get; init; } = string.Empty; - - /// - /// Test description. - /// - [OutputColumn(Order = 150, HeaderText = "Test Description", AutoWidth = false, Width = OutputColumnAttribute.WrappedColumnWidth, WrapText = true)] - public string TestDescription { get; init; } = string.Empty; - - /// - /// Type of sampling. - /// - [OutputColumn(Order = 160, HeaderText = "Sampling Type")] - public string SamplingType { get; init; } = string.Empty; - - /// - /// Sampling selection value. - /// - [OutputColumn(Order = 170, HeaderText = "Sampling Value")] - public string SamplingValue { get; init; } = string.Empty; - - /// - /// Tools and gauges for MIS. - /// - [OutputColumn(Order = 180, HeaderText = "Tools & Gauges", AutoWidth = false, Width = OutputColumnAttribute.WrappedColumnWidth, WrapText = true)] - public string ToolsGauges { get; init; } = string.Empty; - - /// - /// Instructions for MIS. - /// - [OutputColumn(Order = 190, HeaderText = "Work Instructions", AutoWidth = false, Width = OutputColumnAttribute.WrappedColumnWidth, WrapText = true)] - public string WorkInstructions { get; init; } = string.Empty; -} diff --git a/NEW/src/JdeScoping.DataAccess/Models/Results/SearchResult.cs b/NEW/src/JdeScoping.DataAccess/Models/Results/SearchResult.cs deleted file mode 100644 index 09e511c..0000000 --- a/NEW/src/JdeScoping.DataAccess/Models/Results/SearchResult.cs +++ /dev/null @@ -1,179 +0,0 @@ -using JdeScoping.DataAccess.Attributes; - -namespace JdeScoping.DataAccess.Models.Results; - -/// -/// JDE search result reporting model. -/// -[OutputTable(TabName = "Search Results", TableName = "Search_Results")] -public sealed record SearchResult -{ - /// - /// Order unique number. - /// - [OutputColumn(Order = 10, HeaderText = "Work Order Number")] - public long WorkOrderNumber { get; init; } - - /// - /// Order branch code. - /// - [OutputColumn(Order = 20, HeaderText = "Work Order Branch Code")] - public string WorkOrderBranchCode { get; init; } = string.Empty; - - /// - /// Order lot number. - /// - [OutputColumn(Order = 30, HeaderText = "Lot Number")] - public string LotNumber { get; init; } = string.Empty; - - /// - /// Order item number. - /// - [OutputColumn(Order = 40, HeaderText = "Item Number")] - public string ItemNumber { get; init; } = string.Empty; - - /// - /// Item master planning family. - /// - [OutputColumn(Order = 50, HeaderText = "Planning Family")] - public string PlanningFamily { get; init; } = string.Empty; - - /// - /// Item master stocking type. - /// - [OutputColumn(Order = 55, HeaderText = "Stocking Type")] - public string StockingType { get; init; } = string.Empty; - - /// - /// Order quantity. - /// - [OutputColumn(Order = 60, HeaderText = "Order Quantity")] - public decimal OrderQuantity { get; init; } - - /// - /// Quantity on hold. - /// - [OutputColumn(Order = 70, HeaderText = "Held Quantity")] - public decimal HeldQuantity { get; init; } - - /// - /// Quantity scrapped/cancelled. - /// - [OutputColumn(Order = 80, HeaderText = "Scrapped Quantity")] - public decimal ScrappedQuantity { get; init; } - - /// - /// Quantity shipped. - /// - [OutputColumn(Order = 90, HeaderText = "Shipped Quantity")] - public decimal ShippedQuantity { get; init; } - - /// - /// Operation branch code. - /// - [OutputColumn(Order = 100, HeaderText = "Operation Step Branch Code")] - public string StepBranchCode { get; init; } = string.Empty; - - /// - /// Operation step number. - /// - [OutputColumn(Order = 110, HeaderText = "Operation Step")] - public decimal StepNumber { get; init; } - - /// - /// Operation step description. - /// - [OutputColumn(Order = 120, HeaderText = "Operation Step Description")] - public string StepDescription { get; init; } = string.Empty; - - /// - /// Function operation description (long text). - /// - [OutputColumn(Order = 130, HeaderText = "Function Operation Description")] - public string FunctionOperationDescription { get; init; } = string.Empty; - - /// - /// Timestamp of last update to operation step number. - /// - [OutputColumn(Order = 140, HeaderText = "Operation Step Update Timestamp", Format = OutputColumnAttribute.TimestampFormat)] - public DateTime StepUpdateDt { get; init; } - - /// - /// Order status code. - /// - [OutputColumn(Order = 150, HeaderText = "Status Code")] - public string StatusCode { get; init; } = string.Empty; - - /// - /// Order status description. - /// - [OutputColumn(Order = 160, HeaderText = "Status Description")] - public string StatusDescription { get; init; } = string.Empty; - - /// - /// Timestamp of last update to order status. - /// - [OutputColumn(Order = 170, HeaderText = "Status Update Timestamp", Format = OutputColumnAttribute.DateFormat)] - public DateTime? StatusUpdateDt { get; init; } - - /// - /// Work order was included because it was manually specified. - /// - public bool ManuallySpecified { get; init; } - - /// - /// Work order was included because it was split from a flagged work order. - /// - public bool SplitOrder { get; init; } - - /// - /// Work order was included because it received parts from a flagged work order (CARDEX / F4111). - /// - public bool Cardex { get; init; } - - /// - /// Work order was included because it received parts from a flagged work order (parts list / F3111). - /// - public bool PartsList { get; init; } - - /// - /// Work order was included because it met the filter criteria. - /// - public bool Flagged { get; init; } - - /// - /// Reason work order was included in results. - /// - [OutputColumn(Order = 180, HeaderText = "Inclusion Reason")] - public string InclusionReason - { - get - { - if (ManuallySpecified) - { - return "ManuallySpecified"; - } - if (Flagged) - { - return "Flagged"; - } - if (Cardex && PartsList) - { - return "ComponentUsage (CARDEX + Parts List)"; - } - if (Cardex && !PartsList) - { - return "ComponentUsage (CARDEX)"; - } - if (!Cardex && PartsList) - { - return "ComponentUsage (Parts List)"; - } - if (SplitOrder) - { - return "Split order"; - } - return "UNKNOWN"; - } - } -} diff --git a/NEW/src/JdeScoping.DataAccess/Models/SearchModel.cs b/NEW/src/JdeScoping.DataAccess/Models/SearchModel.cs deleted file mode 100644 index dd5892d..0000000 --- a/NEW/src/JdeScoping.DataAccess/Models/SearchModel.cs +++ /dev/null @@ -1,56 +0,0 @@ -using JdeScoping.DataAccess.Models.Results; - -namespace JdeScoping.DataAccess.Models; - -/// -/// Reporting search data model. -/// Filter criteria are stored as JSON in the Search.Criteria column -/// and are extracted using SQL functions (fn_GetSearch*) during query execution. -/// -public class SearchModel -{ - /// - /// PK ID of search. - /// - public int Id { get; set; } - - /// - /// User name of user that created search. - /// - public string UserName { get; set; } = string.Empty; - - /// - /// User-friendly name for search. - /// - public string Name { get; set; } = string.Empty; - - /// - /// Timestamp search was submitted. - /// - public DateTime? SubmitDt { get; set; } - - /// - /// Timestamp search was started. - /// - public DateTime? StartDt { get; set; } - - /// - /// Timestamp search was completed. - /// - public DateTime? EndDt { get; set; } - - /// - /// Work order search results. - /// - public List Results { get; set; } = []; - - /// - /// MIS results. - /// - public List MisResults { get; set; } = []; - - /// - /// MIS no match found results. - /// - public List MisNonMatchResults { get; set; } = []; -} diff --git a/NEW/src/JdeScoping.DataAccess/Services/SearchProcessor.cs b/NEW/src/JdeScoping.DataAccess/Services/SearchProcessor.cs index 63874eb..a4d930b 100644 --- a/NEW/src/JdeScoping.DataAccess/Services/SearchProcessor.cs +++ b/NEW/src/JdeScoping.DataAccess/Services/SearchProcessor.cs @@ -4,7 +4,6 @@ using JdeScoping.DataAccess.Options; using JdeScoping.DataAccess.Interfaces; using JdeScoping.Core.Models.SearchResults; using JdeScoping.DataAccess.Models; -using SearchModel = JdeScoping.Core.Models.SearchResults.SearchModel; using JdeScoping.DataAccess.QueryBuilders; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging;