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:
Executable
+103
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Dapper;
|
||||
using DataModel.Models;
|
||||
|
||||
namespace DataModel.Process
|
||||
{
|
||||
/// <summary>
|
||||
/// User tracking functions for LotFinderDB interface
|
||||
/// </summary>
|
||||
public partial class LotFinderDB
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds users with matching user ID or full name
|
||||
/// </summary>
|
||||
private const string SQL_SEARCH_USERS = @"
|
||||
SELECT TOP 25
|
||||
u.AddressNumber,
|
||||
COALESCE(u.UserID,' ') AS UserID,
|
||||
u.FullName,
|
||||
u.LastUpdateDT
|
||||
FROM dbo.JdeUser AS u
|
||||
WHERE u.UserID LIKE '%' + @filter + '%' OR
|
||||
u.FullName LIKE '%' + @filter + '%' OR
|
||||
CAST(u.AddressNumber AS VARCHAR(10)) LIKE '%' + @filter + '%'
|
||||
ORDER BY u.UserID, u.FullName";
|
||||
|
||||
/// <summary>
|
||||
/// Finds users with matching user ID or full name
|
||||
/// </summary>
|
||||
/// <param name="filter">Search filter</param>
|
||||
/// <returns>Users with matching matching user ID or full name</returns>
|
||||
public static List<JdeUser> SearchUsers(string filter)
|
||||
{
|
||||
List<JdeUser> results = new List<JdeUser>();
|
||||
|
||||
try
|
||||
{
|
||||
using (SqlConnection connection = GetConnection())
|
||||
{
|
||||
results.AddRange(connection.Query<JdeUser>(SQL_SEARCH_USERS, new{filter}));
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
//Log and forward exception
|
||||
logger.Error("SearchUsers: failed to search for user '{0}': {1}.", filter, error.Message);
|
||||
throw new Exception($"Failed to get serach for user '{filter}' from LotFinderDB.", error);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query to find users with matching user IDs
|
||||
/// </summary>
|
||||
private const string SQL_LOOKUP_USERS = @"
|
||||
SELECT u.AddressNumber,
|
||||
u.UserID,
|
||||
u.FullName,
|
||||
u.LastUpdateDT
|
||||
FROM dbo.JdeUser AS u INNER JOIN
|
||||
@userIDs u2 ON (u.UserID = u2.UserName OR CAST(u.AddressNumber AS VARCHAR(20)) = u2.UserName)
|
||||
ORDER BY u.UserID";
|
||||
|
||||
/// <summary>
|
||||
/// Finds users with matching user IDs
|
||||
/// </summary>
|
||||
/// <param name="userIDs">User IDs to match</param>
|
||||
/// <returns>Users with matching user IDs</returns>
|
||||
public static List<JdeUser> LookupUsers(List<string> userIDs)
|
||||
{
|
||||
List<JdeUser> results = new List<JdeUser>();
|
||||
|
||||
try
|
||||
{
|
||||
//Create search filter parameter
|
||||
DataTable dataTable = new DataTable();
|
||||
dataTable.Columns.Add("UserName", typeof(string));
|
||||
foreach (string userID in userIDs)
|
||||
{
|
||||
dataTable.Rows.Add(userID);
|
||||
}
|
||||
|
||||
using (SqlConnection connection = GetConnection())
|
||||
{
|
||||
results = connection.Query<JdeUser>(SQL_LOOKUP_USERS, new { userIDs = dataTable.AsTableValuedParameter("OperatorFilterParameter") }).ToList();
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
//Log and forward exception
|
||||
logger.Error("LookupUsers: failed to find matching users: {0}.", error.Message);
|
||||
throw new Exception("LookupUsers: failed to find matching users in LotFinderDB.", error);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user