Initial commit: JDE Scoping Tool migration project
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
This commit is contained in:
@@ -0,0 +1,299 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using JdeScoping.Core.Models;
|
||||
using JdeScoping.Core.Models.Inventory;
|
||||
using JdeScoping.Core.Models.Organization;
|
||||
using JdeScoping.Core.Models.WorkOrders;
|
||||
using JdeScoping.Core.ViewModels;
|
||||
using JdeScoping.DataAccess.Queries;
|
||||
|
||||
namespace JdeScoping.DataAccess.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Reference data lookup operations for LotFinder repository.
|
||||
/// </summary>
|
||||
public partial class LotFinderRepository
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<Item>> SearchItemsAsync(string filter, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(SearchItemsAsync);
|
||||
try
|
||||
{
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<Item>(
|
||||
LotFinderQueries.SqlSearchItems,
|
||||
new { filter },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_SEARCH_ITEMS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<Item>> LookupItemsAsync(List<string> itemNumbers, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(LookupItemsAsync);
|
||||
try
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("ItemNumber", typeof(string));
|
||||
foreach (var itemNumber in itemNumbers)
|
||||
{
|
||||
dataTable.Rows.Add(itemNumber);
|
||||
}
|
||||
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<Item>(
|
||||
LotFinderQueries.SqlLookupItems,
|
||||
new { itemNumbers = dataTable.AsTableValuedParameter("ItemNumberFilterParameter") },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_LOOKUP_ITEMS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<WorkOrder>> LookupWorkordersAsync(List<long> workorderNumbers, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(LookupWorkordersAsync);
|
||||
try
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("WorkOrderNumber", typeof(long));
|
||||
foreach (var workOrderNumber in workorderNumbers)
|
||||
{
|
||||
dataTable.Rows.Add(workOrderNumber);
|
||||
}
|
||||
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<WorkOrder>(
|
||||
LotFinderQueries.SqlLookupWorkorders,
|
||||
new { workOrderNumbers = dataTable.AsTableValuedParameter("WorkOrderFilterParameter") },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_LOOKUP_WORKORDERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<WorkCenter>> SearchWorkCentersAsync(string filter, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(SearchWorkCentersAsync);
|
||||
try
|
||||
{
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<WorkCenter>(
|
||||
LotFinderQueries.SqlSearchWorkCenters,
|
||||
new { filter },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_SEARCH_WORK_CENTERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<WorkCenter>> LookupWorkCentersAsync(List<string> codes, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(LookupWorkCentersAsync);
|
||||
try
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("Code", typeof(string));
|
||||
foreach (var code in codes)
|
||||
{
|
||||
dataTable.Rows.Add(code);
|
||||
}
|
||||
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<WorkCenter>(
|
||||
LotFinderQueries.SqlLookupWorkCenters,
|
||||
new { workCenterCodes = dataTable.AsTableValuedParameter("WorkCenterFilterParameter") },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_LOOKUP_WORK_CENTERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<ProfitCenter>> SearchProfitCentersAsync(string filter, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(SearchProfitCentersAsync);
|
||||
try
|
||||
{
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<ProfitCenter>(
|
||||
LotFinderQueries.SqlSearchProfitCenters,
|
||||
new { filter },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_SEARCH_PROFIT_CENTERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<ProfitCenter>> LookupProfitCentersAsync(List<string> codes, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(LookupProfitCentersAsync);
|
||||
try
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("Code", typeof(string));
|
||||
foreach (var code in codes)
|
||||
{
|
||||
dataTable.Rows.Add(code);
|
||||
}
|
||||
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<ProfitCenter>(
|
||||
LotFinderQueries.SqlLookupProfitCenters,
|
||||
new { profitCenterCodes = dataTable.AsTableValuedParameter("ProfitCenterFilterParameter") },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_LOOKUP_PROFIT_CENTERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<JdeUser>> SearchUsersAsync(string filter, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(SearchUsersAsync);
|
||||
try
|
||||
{
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<JdeUser>(
|
||||
LotFinderQueries.SqlSearchUsers,
|
||||
new { filter },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_SEARCH_USERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<JdeUser>> LookupUsersAsync(List<string> userIds, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(LookupUsersAsync);
|
||||
try
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("UserName", typeof(string));
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
dataTable.Rows.Add(userId);
|
||||
}
|
||||
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<JdeUser>(
|
||||
LotFinderQueries.SqlLookupUsers,
|
||||
new { userIDs = dataTable.AsTableValuedParameter("OperatorFilterParameter") },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_LOOKUP_USERS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<List<Lot>> LookupLotsAsync(List<LotViewModel> lots, CancellationToken ct = default)
|
||||
{
|
||||
const string operation = nameof(LookupLotsAsync);
|
||||
try
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
dataTable.Columns.Add("ComponentLotNumber", typeof(string));
|
||||
dataTable.Columns.Add("ItemNumber", typeof(string));
|
||||
foreach (var lot in lots)
|
||||
{
|
||||
dataTable.Rows.Add(lot.LotNumber, lot.ItemNumber);
|
||||
}
|
||||
|
||||
await using var connection = await _connectionFactory.CreateLotFinderConnectionAsync(ct);
|
||||
var result = await connection.QueryAsync<Lot>(
|
||||
LotFinderQueries.SqlLookupLots,
|
||||
new { lotNumbers = dataTable.AsTableValuedParameter("ComponentLotFilterParameter") },
|
||||
commandTimeout: _options.Value.DefaultTimeoutSeconds);
|
||||
return result.ToList();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogAndThrow(ex, operation, "SQL_LOOKUP_LOTS");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user