@page "/projects/{Id:int}/results"
@inject ProjectService ProjectService
@inject CutListPackingService PackingService
@inject ReportService ReportService
@inject NavigationManager Navigation
@inject IJSRuntime JS
@using CutList.Core.Nesting
@using CutList.Core.Formatting
Results - @(project?.Name ?? "Project")
@if (loading)
{
Loading...
}
else if (project == null)
{
Project not found.
}
else
{
@project.Name
Optimization Results
@if (!CanOptimize)
{
}
else if (packResult != null)
{
@if (packResult.ItemsNotUsed.Count > 0)
{
Items Not Placed
The following @packResult.ItemsNotUsed.Count item(s) could not be placed (probably too long for available stock):
@foreach (var item in packResult.ItemsNotUsed.GroupBy(i => new { i.Name, i.Length }))
{
- @item.Count() x @item.Key.Name (@ArchUnits.FormatFromInches(item.Key.Length))
}
}
@summary!.TotalBins
Stock Bars
@summary.TotalPieces
Total Pieces
@ArchUnits.FormatFromInches(summary.TotalWaste)
Total Waste
@summary.Efficiency.ToString("F1")%
Efficiency
}
}
@code {
[Parameter]
public int Id { get; set; }
private Project? project;
private PackResult? packResult;
private PackingSummary? summary;
private bool loading = true;
private bool CanOptimize => project != null &&
project.Parts.Count > 0 &&
project.StockBins.Count > 0 &&
project.CuttingToolId != null;
protected override async Task OnInitializedAsync()
{
project = await ProjectService.GetByIdAsync(Id);
if (project != null && CanOptimize)
{
var kerf = project.CuttingTool?.KerfInches ?? 0.125m;
packResult = PackingService.Pack(project.Parts, project.StockBins, kerf);
summary = PackingService.GetSummary(packResult);
}
loading = false;
}
private async Task PrintReport()
{
await JS.InvokeVoidAsync("window.print");
}
}