Commit Graph

90 Commits

Author SHA1 Message Date
Joseph Doherty 645ef46f35 refactor(data-access): replace TVP lookups with STRING_SPLIT and OPENJSON
Remove dependency on deleted SQL Server Table-Valued Parameter types
by refactoring lookup methods to use built-in SQL Server functions:

- Simple single-value lookups (Items, WorkOrders, WorkCenters,
  ProfitCenters, Users) now use STRING_SPLIT with comma-separated
  strings from C#
- Complex multi-column lookup (Lots with LotNumber + ItemNumber)
  now uses OPENJSON with JSON string from C#

This eliminates the need for TVP type definitions (scripts 033-039)
while maintaining equivalent functionality.
2026-01-06 15:34:39 -05:00
Joseph Doherty 691a6d1ffd refactor(data-access): remove TVP code and simplify SearchModel
- Remove all List<*FilterEntry> properties and *FilterEnabled computed properties from SearchModel
- Delete TableValuedParameterExtensions.cs
- Delete entire FilterEntries folder and all filter entry model classes
- Delete FilterHandlers folder and all filter handler classes
- Delete IFilterHandler interface and FilterResult model
- Update MisQueryBuilder to use SQL extraction functions instead of model properties
- Update SearchProcessor to get ExtractMisData from database using fn_GetSearchExtractMisData
- Update DependencyInjection to remove filter handler registrations
- Delete obsolete tests for TVP extensions and filter handlers

Filter criteria are now stored as JSON in Search.Criteria column and extracted using SQL functions (fn_GetSearch*) during query execution.
2026-01-06 14:32:03 -05:00
Joseph Doherty a2a8bb3e9f refactor(datasync): remove obsolete DataSourceConfig properties 2026-01-06 14:25:46 -05:00
Joseph Doherty edd07858a1 refactor(datasync): remove obsolete appsettings properties
Remove legacy ETL properties from DataSources configuration:
- FetcherTypeName (9 entries)
- PostProcessorTypeName (1 entry - MisData)
- PrepurgeData from MassConfig (9 entries)
- ReIndexData from MassConfig (9 entries)

These properties were used by the old fetcher-based ETL system
and are no longer needed with the new EtlPipeline architecture.
2026-01-06 14:24:19 -05:00
Joseph Doherty 3c728dd575 refactor(datasync): update tests to remove FetcherTypeName
- Remove FetcherTypeName assignments from test fixtures in ScheduleCheckerTests
  and SyncOrchestratorTests
- Remove PrepurgeData and ReIndexData assignments from MassConfig in tests
- Mark FetcherTypeName, PostProcessorTypeName, PrepurgeData, and ReIndexData
  as obsolete with deprecation warnings pointing to pipelines.json
- Change FetcherTypeName from required to optional to allow tests to compile
  without providing the deprecated property
2026-01-06 14:22:26 -05:00
Joseph Doherty 8ce9a7dae1 docs: switch cache conversion design from MessagePack to protobuf-net-data
protobuf-net-data is purpose-built for IDataReader serialization and
returns IDataReader directly from Deserialize(), eliminating the need
for custom streaming reader implementations.
2026-01-06 14:15:19 -05:00
Joseph Doherty d4135e8ad3 fix(data-access): correct self-referential SQL in WorkCenter filter
The WHERE clause was comparing Code to itself instead of the aliased
table reference, which would always be true.
2026-01-06 14:12:07 -05:00
Joseph Doherty 34daf6a83b refactor(datasync): delete old ETL source files 2026-01-06 14:11:13 -05:00
Joseph Doherty 6074424524 refactor(data-access): update ISearchQueryBuilder to use SearchId only
- Change interface methods to accept int searchId instead of SearchModel
- Update SqlKataSearchQueryBuilder to generate SQL using extraction functions
- SQL now calls dbo.fn_GetSearchWorkOrders(@SearchId) etc instead of TVPs
- Update SearchProcessor to pass model.Id to query builder
- Update tests for new method signatures
2026-01-06 14:08:47 -05:00
Joseph Doherty 7508001be1 refactor(datasync): remove old ETL DI registrations 2026-01-06 14:07:28 -05:00
Joseph Doherty 981c410cb3 feat(datasync): wire TableSyncOperation to use EtlPipelineFactory
Replace the old sync logic (fetchers, merge configurations, bulk merge
helper, post processors) with the new ETL pipeline factory.

Changes:
- Inject IEtlPipelineFactory instead of old dependencies
- Remove IServiceProvider, IDbConnectionFactory, IBulkMergeHelper,
  IMergeConfigurationRegistry dependencies
- Simplify ExecuteSyncCoreAsync to build and execute pipeline
- Keep DataUpdateRepository calls for tracking sync timestamps
- Determine SyncMode from UpdateType (Mass vs Incremental)
2026-01-06 14:05:56 -05:00
Joseph Doherty 7b3592df96 feat(datasync): register EtlPipelineFactory in DI 2026-01-06 14:03:31 -05:00
Joseph Doherty e75cd70d94 fix(datasync): correct MisData postScript and query filtering
- Replace placeholder postScript with actual MIS data post-processing:
  1. Sets ObsoleteDate based on BackLevel records
  2. Sets ObsoleteDate for remaining NULL cases
  3. Rebuilds PK_MisData index

- Add massQuery support to SourceConfig for mode-specific queries
- MisData mass sync now uses query without date filter (like legacy)
- EtlPipelineFactory selects massQuery when in mass mode if available
- Remove unnecessary minDtOffset from MisData mass mode config
2026-01-06 14:01:26 -05:00
Joseph Doherty 4298fb8147 feat(datasync): add pipelines.json config for all sync tables
Configure ETL pipelines for all 9 sync tables:
- WorkOrder_Curr, Lot, LotUsage_Curr (JDE)
- Item, WorkCenter, ProfitCenter (JDE)
- JdeUser, Branch (JDE)
- MisData (CMS) with postScript for ProcessedFlag update

Each pipeline includes:
- Source query with JDE Julian date/time parameters
- Sync modes for mass (365 day lookback, prePurge, reIndex)
  and incremental (7 day lookback) operations
- Destination table with match columns and updateWhen conditions
2026-01-06 13:53:30 -05:00
Joseph Doherty 795c15df56 feat(datasync): add EtlPipelineFactory with JSON config support
- Implement IEtlPipelineFactory with ForTable() method returning a builder
- Load pipeline config from JSON file path (from PipelineOptions)
- Parse config using System.Text.Json with PropertyNameCaseInsensitive
- Builder supports WithMode() and WithMinimumDate() fluent methods
- Create DbQuerySource for source with ParameterFormatConverter for JDE dates
- Create DbBulkMergeDestination or DbBulkImportDestination based on sync mode
- Mass mode defaults to bulkImport, incremental defaults to bulkMerge
- Support destination override in sync mode config
- Execute pre/post scripts from config (prePurge, reIndex, custom scripts)
- Validate config: require mass and incremental modes, reject runtime params
- Add comprehensive tests for factory, builder, and config validation
2026-01-06 13:45:36 -05:00
Joseph Doherty 0d9e6db7f2 feat(datasync): add IEtlPipelineFactory and SyncMode contracts 2026-01-06 13:38:51 -05:00
Joseph Doherty 8af4f9915f feat(datasync): extend DbBulkMergeDestination with excludeFromUpdate and updateCondition 2026-01-06 13:35:25 -05:00
Joseph Doherty eb85ab6f34 feat(datasync): add generic DbQuerySource for JDE/CMS/LotFinder
Extend DbQuerySource to support multiple connection types:
- Add connectionType parameter ("jde", "cms", "lotfinder")
- Use appropriate IDbConnectionFactory method for each type
- Support Dictionary<string, object> parameters
- Use DbConnection/DbCommand for cross-database compatibility
2026-01-06 13:30:00 -05:00
Joseph Doherty 1f7fd9f0f2 feat(datasync): add ParameterFormatConverter with JDE date/time support 2026-01-06 13:25:15 -05:00
Joseph Doherty 5f8b4422b3 chore: remove obsolete Table Type scripts (033-039) 2026-01-06 13:24:38 -05:00
Joseph Doherty 2fd1cb1fe7 feat(db): add validation stored procedure with THROW errors 2026-01-06 13:20:42 -05:00
Joseph Doherty e875244c8f feat(datasync): add pipeline configuration models 2026-01-06 13:20:35 -05:00
Joseph Doherty 28d2fd30c9 feat(db): add inline TVFs for complex object extraction from SearchCriteria 2026-01-06 13:17:23 -05:00
Joseph Doherty 250323f8b0 feat(db): add inline TVFs for simple array extraction from SearchCriteria 2026-01-06 13:14:18 -05:00
Joseph Doherty 5ee348dc98 feat(db): add scalar extraction functions for SearchCriteria JSON 2026-01-06 13:11:11 -05:00
Joseph Doherty c626ffbd69 test: add edge case tests to ApiClientBaseTests
Add 7 edge case tests for ApiClientBase:
- GetAsync_Returns200_EmptyBody_MapsToApiError
- GetAsync_Returns200_InvalidJson_MapsToApiError
- GetAsync_Returns204_ForUnitType_MapsToSuccess
- GetAsync_Returns204_ForNonUnitType_MapsToApiError
- GetAsync_NetworkException_MapsToApiError
- GetAsync_Timeout_MapsToApiError
- GetAsync_Returns400_WithoutValidationFormat_MapsToApiError

Also fix bug in ApiClientBase where 204 NoContent for Unit type
failed due to incorrect type casting. The implicit conversion from
Unit to ApiResult<Unit> must be applied before the runtime cast.
2026-01-06 11:23:54 -05:00
Joseph Doherty 6bd6138b2a chore(client): add Extensions namespace to global imports
Add @using JdeScoping.Client.Extensions to _Imports.razor so that
extension methods (like ViewModelMappingExtensions) are available
globally in Razor components without explicit using statements.
2026-01-06 10:39:44 -05:00
Joseph Doherty 4e1cd2c221 chore(client): delete old service files replaced by API clients
Delete old service interfaces and implementations that have been
replaced by the new typed API clients:
- ISearchService/SearchService -> ISearchApiClient/SearchApiClient
- ILookupService/LookupService -> ILookupApiClient/LookupApiClient
- IFileService/FileService -> IFileApiClient/FileApiClient

Also remove unused IFileService injection from SearchEdit.razor
(download functionality now uses SearchApi.GetResultsAsync).
2026-01-06 10:38:41 -05:00
Joseph Doherty 6701da137d chore(client): remove old service registrations
Remove ISearchService, ILookupService, and IFileService registrations
from Program.cs as these are now replaced by the typed API clients
(ISearchApiClient, ILookupApiClient, IFileApiClient).
2026-01-06 10:37:15 -05:00
Joseph Doherty 828034d0e2 feat(client): migrate PartOperationFilterPanel to API clients 2026-01-06 10:35:33 -05:00
Joseph Doherty 251e2f910f feat(client): migrate ComponentLotFilterPanel to API clients 2026-01-06 10:34:33 -05:00
Joseph Doherty ead947bf57 feat(client): migrate WorkOrderFilterPanel to API clients 2026-01-06 10:33:36 -05:00
Joseph Doherty 8e05afb34f feat(client): migrate OperatorFilterPanel to API clients 2026-01-06 10:32:54 -05:00
Joseph Doherty ee6afc9e4e feat(client): migrate ProfitCenterFilterPanel to API clients 2026-01-06 10:32:25 -05:00
Joseph Doherty f49390ad01 feat(client): migrate WorkCenterFilterPanel to API clients 2026-01-06 10:31:58 -05:00
Joseph Doherty a6348c4268 feat(client): migrate ItemNumberFilterPanel to API clients
Update ItemNumberFilterPanel.razor to use ILookupApiClient and IFileApiClient
instead of legacy ILookupService and IFileService interfaces. All methods now
use the result.Switch() pattern for proper ApiResult error handling.
2026-01-06 10:30:20 -05:00
Joseph Doherty 20f9a1c683 feat(client): migrate MainLayout.razor to IAuthApiClient
- Replace IAuthService with IAuthApiClient for logout functionality
- Add @using JdeScoping.Core.ApiContracts
- LogoutAsync now calls AuthApi.LogoutAsync() and navigates to login
  regardless of API result
2026-01-06 10:27:24 -05:00
Joseph Doherty b555f57b72 feat(client): migrate Login.razor to IAuthApiClient
- Replace IAuthService injection with IAuthApiClient
- Keep ICryptoService for credential encryption
- Add AuthStateProvider injection to notify authentication state
- Use result.Switch() pattern for ApiResult<LoginResultModel> handling
- Properly handle ValidationError with FieldErrors dictionary
2026-01-06 10:25:54 -05:00
Joseph Doherty 6054412a77 refactor: move JSON ETL classes to DataSync.Dev
Move dev-only JSON reading infrastructure from DataSync to DataSync.Dev:
- JsonColumnSchema (Models/)
- JsonZstdFileSource (Sources/)
- JsonStreamingDataReader (Sources/)
- Utf8JsonStreamingDataReader (Sources/)

Update namespaces and using statements in all DevEtl files.
2026-01-06 10:25:45 -05:00
Joseph Doherty a77b71e53d feat(client): migrate SearchEdit.razor to ISearchApiClient
- Replace ISearchService with ISearchApiClient
- Add @using for JdeScoping.Core.ApiContracts and JdeScoping.Client.Extensions
- Update LoadSearchAsync to use result.Switch() pattern with ApiResult<T>
- Handle CopySearchId, Id, and new search cases with proper error handling
- Use ToClient() extension method to convert Core to Client SearchViewModel
- Add _errorMessage field and display error alert in UI
- Update SubmitSearchInternalAsync and DownloadResultsAsync for consistency
- Add FormatValidationErrors helper for ValidationError.FieldErrors
2026-01-06 10:23:36 -05:00
Joseph Doherty b86d48657e feat(client): migrate SearchQueue.razor to ISearchApiClient
- Replace ISearchService injection with ISearchApiClient
- Add @using for JdeScoping.Core.ApiContracts and JdeScoping.Client.Extensions
- Update LoadQueueAsync to use result.Switch() pattern with ApiResult<T>
- Add _errorMessage field for error display
- Add RadzenAlert for error message display in UI
2026-01-06 10:19:53 -05:00
Joseph Doherty b08f5418ec feat(client): migrate Searches.razor to ISearchApiClient
- Replace ISearchService injection with ISearchApiClient
- Add @using for JdeScoping.Core.ApiContracts and JdeScoping.Client.Extensions
- Update LoadSearchesAsync to use ApiResult<T>.Switch() pattern
- Add _errorMessage field for error state
- Display RadzenAlert for error conditions
- Use ToClientList() extension method to convert Core->Client view models
2026-01-06 10:18:11 -05:00
Joseph Doherty 81b07ce027 feat: extract DevEtl to JdeScoping.DataSync.Dev project
- Create JdeScoping.DataSync.Dev for sandbox testing ETL code
- Create JdeScoping.DataSync.Dev.Tests for associated tests
- Move 22 source files and 8 test files
- Update namespaces from DevEtl to Dev
- Add both projects to solution
2026-01-06 10:18:09 -05:00
Joseph Doherty 7ad4e3ec1c feat(client): configure HttpClient with AuthRedirectHandler
- Add using statement for JdeScoping.Client.Http namespace
- Register AuthRedirectHandler as a scoped service
- Replace simple HttpClient registration with handler pipeline
- AuthRedirectHandler intercepts 401 responses and redirects to login
- Keep all existing service registrations for backward compatibility
2026-01-06 10:15:48 -05:00
Joseph Doherty ba88450feb feat(client): add ViewModelMappingExtensions for Core<->Client mapping
Add extension methods to convert between Core and Client view models:
- SearchViewModel: Core (enum Status) <-> Client (string Status)
- SearchCriteria: Core (primitive lists) <-> Client (full ViewModels)
- JdeUserViewModel -> OperatorViewModel

Handles structural differences in criteria where Core uses primitive
lists (List<long>, List<string>) and Client uses full objects.
2026-01-06 10:14:09 -05:00
Joseph Doherty 0b50c03e44 feat(client): add AuthRedirectHandler for global 401 redirect
Add HTTP message handler that intercepts 401 Unauthorized responses
and redirects to the login page with return URL preserved.
2026-01-06 10:11:43 -05:00
Joseph Doherty badc6a43f3 fix(datasync): throw on cancellation in DevEtlRegistry.RunAllAsync 2026-01-03 16:32:29 -05:00
Joseph Doherty 6bd2b3c285 feat(datasync): add DevEtlRegistry for managing development ETL pipelines 2026-01-03 16:28:35 -05:00
Joseph Doherty fd1e5454da feat(datasync): add BranchDevEtl pipeline for Branch table dev loading 2026-01-03 16:24:34 -05:00
Joseph Doherty 2629cb26e0 fix(datasync): add guards and exception safety to JsonZstdFileSource 2026-01-03 16:21:59 -05:00