26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
59 lines
2.1 KiB
C#
Executable File
59 lines
2.1 KiB
C#
Executable File
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>
|
|
/// Workorder tracking functions for LotFinderDB interface
|
|
/// </summary>
|
|
public partial class LotFinderDB
|
|
{
|
|
/// <summary>
|
|
/// Query to find work orders with matching work order numbers
|
|
/// </summary>
|
|
private const string SQL_LOOKUP_WORKORDERS = @"
|
|
SELECT *
|
|
FROM dbo.WorkOrder AS wo INNER JOIN
|
|
@workOrderNumbers wo2 ON (wo.WorkOrderNumber = wo2.WorkOrderNumber)";
|
|
|
|
/// <summary>
|
|
/// Finds work orders with matching work order numbers
|
|
/// </summary>
|
|
/// <param name="workorderNumbers">Workorder numbers to match</param>
|
|
/// <returns>List of matching workorders</returns>
|
|
public static List<WorkOrder> LookupWorkorders(List<long> workorderNumbers)
|
|
{
|
|
List<WorkOrder> results = new List<WorkOrder>();
|
|
|
|
try
|
|
{
|
|
//Create search filter parameter
|
|
DataTable dataTable = new DataTable();
|
|
dataTable.Columns.Add("WorkOrderNumber", typeof(long));
|
|
foreach (long workOrderNumber in workorderNumbers)
|
|
{
|
|
dataTable.Rows.Add(workOrderNumber);
|
|
}
|
|
|
|
using (SqlConnection connection = GetConnection())
|
|
{
|
|
results = connection.Query<WorkOrder>(SQL_LOOKUP_WORKORDERS, new { workOrderNumbers = dataTable.AsTableValuedParameter("WorkOrderFilterParameter") }).ToList();
|
|
}
|
|
}
|
|
catch (Exception error)
|
|
{
|
|
//Log and forward exception
|
|
logger.Error("LookupWorkorders: failed to find matching workorders: {0}.", error.Message);
|
|
throw new Exception("LookupWorkorders: failed to find matching workorders in LotFinderDB.", error);
|
|
}
|
|
|
|
return results;
|
|
}
|
|
}
|
|
}
|