26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
172 lines
6.5 KiB
C#
Executable File
172 lines
6.5 KiB
C#
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using DataModel.Helpers;
|
|
using DataModel.Models;
|
|
using DataModel.Process;
|
|
|
|
namespace DataModel.ViewModels
|
|
{
|
|
/// <summary>
|
|
/// View model for search criteria
|
|
/// </summary>
|
|
public class SearchCriteriaViewModel
|
|
{
|
|
/// <summary>
|
|
/// Minimum timestamp to include in filter
|
|
/// </summary>
|
|
public DateTime? MinimumDT { get; set; }
|
|
|
|
/// <summary>
|
|
/// Maxmimum timestamp to include in filter
|
|
/// </summary>
|
|
public DateTime? MaximumDT { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection of workorders to include in filter
|
|
/// </summary>
|
|
public List<WorkOrderViewModel> WorkOrders { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection of items to include in filter
|
|
/// </summary>
|
|
public List<ItemViewModel> Items { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection of profit centers to include in filter
|
|
/// </summary>
|
|
public List<ProfitCenterViewModel> ProfitCenters { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection of work centers to include in filter
|
|
/// </summary>
|
|
public List<WorkCenterViewModel> WorkCenters { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection component lots to include in filter
|
|
/// </summary>
|
|
public List<LotViewModel> ComponentLots { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection of operators to include in filter
|
|
/// </summary>
|
|
public List<JdeUserViewModel> Operators { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether or not to extract MIS data
|
|
/// </summary>
|
|
public bool ExtractMisData { get; set; }
|
|
|
|
/// <summary>
|
|
/// Collection of part/operation combinations to get MIS data for
|
|
/// </summary>
|
|
public List<PartOperationViewModel> PartOperations { get; set; }
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
public SearchCriteriaViewModel()
|
|
{
|
|
WorkOrders = new List<WorkOrderViewModel>();
|
|
Items = new List<ItemViewModel>();
|
|
ProfitCenters = new List<ProfitCenterViewModel>();
|
|
WorkCenters = new List<WorkCenterViewModel>();
|
|
ComponentLots = new List<LotViewModel>();
|
|
Operators = new List<JdeUserViewModel>();
|
|
PartOperations=new List<PartOperationViewModel>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="criteria">Search criteria to explode</param>
|
|
public SearchCriteriaViewModel(SearchCriteria criteria) : this()
|
|
{
|
|
if (criteria == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
MinimumDT = criteria.MinimumDT;
|
|
MaximumDT = criteria.MaximumDT;
|
|
ExtractMisData = criteria.ExtractMisData;
|
|
|
|
//Load work orders
|
|
if (criteria.WorkOrderNumbers != null && criteria.WorkOrderNumbers.Any())
|
|
{
|
|
WorkOrders.AddRange(LotFinderDB.LookupWorkorders(criteria.WorkOrderNumbers)
|
|
.OrderBy(wo => wo.WorkOrderNumber)
|
|
.Select(wo => wo.ToViewModel()));
|
|
}
|
|
|
|
//Load items
|
|
if (criteria.ItemNumbers != null && criteria.ItemNumbers.Any())
|
|
{
|
|
Items.AddRange(LotFinderDB.LookupItems(criteria.ItemNumbers)
|
|
.OrderBy(wo => wo.ItemNumber)
|
|
.Select(wo => wo.ToViewModel()));
|
|
}
|
|
|
|
//Load profit centers
|
|
if (criteria.ProfitCenters != null && criteria.ProfitCenters.Any())
|
|
{
|
|
ProfitCenters.AddRange(LotFinderDB.LookupProfitCenters(criteria.ProfitCenters)
|
|
.OrderBy(wo => wo.Code)
|
|
.Select(wo => wo.ToViewModel()));
|
|
}
|
|
|
|
//Load work centers
|
|
if (criteria.WorkCenters != null && criteria.WorkCenters.Any())
|
|
{
|
|
WorkCenters.AddRange(LotFinderDB.LookupWorkCenters(criteria.WorkCenters)
|
|
.OrderBy(wo => wo.Code)
|
|
.Select(wo => wo.ToViewModel()));
|
|
}
|
|
|
|
//Load component lots
|
|
if (criteria.ComponentLotNumbers != null && criteria.ComponentLotNumbers.Any())
|
|
{
|
|
ComponentLots.AddRange(LotFinderDB.LookupLots(criteria.ComponentLotNumbers)
|
|
.Select(l => l.ToViewModel())
|
|
.DistinctBy(l => new { l.LotNumber, l.ItemNumber })
|
|
.OrderBy(wo => wo.LotNumber));
|
|
}
|
|
|
|
//Load operators
|
|
if (criteria.OperatorIDs != null && criteria.OperatorIDs.Any())
|
|
{
|
|
Operators.AddRange(LotFinderDB.LookupUsers(criteria.OperatorIDs)
|
|
.OrderBy(wo => wo.UserID)
|
|
.Select(wo => wo.ToViewModel()));
|
|
}
|
|
|
|
//Load part operations
|
|
if (criteria.PartOperations != null && criteria.PartOperations.Any())
|
|
{
|
|
PartOperations.AddRange(criteria.PartOperations);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts the view model into standard model
|
|
/// </summary>
|
|
/// <returns>Compressed search criteria model</returns>
|
|
public SearchCriteria ToModel()
|
|
{
|
|
return new SearchCriteria()
|
|
{
|
|
MinimumDT = MinimumDT,
|
|
MaximumDT = MaximumDT,
|
|
ExtractMisData = ExtractMisData,
|
|
WorkOrderNumbers = WorkOrders.Select(wo => wo.WorkOrderNumber).ToList(),
|
|
ItemNumbers = Items.Select(i => i.ItemNumber).ToList(),
|
|
ProfitCenters = ProfitCenters.Select(pc => pc.Code).ToList(),
|
|
WorkCenters = WorkCenters.Select(wc => wc.Code).ToList(),
|
|
ComponentLotNumbers = ComponentLots,
|
|
OperatorIDs = Operators.Select(o => o.AddressNumber.ToString()).ToList(),
|
|
PartOperations = PartOperations
|
|
};
|
|
}
|
|
}
|
|
}
|