using System.Net.Http.Json; using Microsoft.AspNetCore.Components; using ReportingServices.Shared.HelperClasses; using ReportingServices.Shared.Models.ProductionReport; using ReportingServices.Shared.ViewModels.ProductionReport; namespace ReportingServices.Client.Pages; public partial class DailyReport { [Inject] protected HttpClient? HttpClient { get; set; } [Inject] protected ILogger? Logger { get; set; } protected ReportingServices.Shared.ViewModels.ProductionReport.DailyReport? _dailyReport; protected double _ASMAvailablePct = 0; protected double _EPPAvailablePct = 0; protected double _HTRAvailablePct = 0; protected int _ASMSLL = 0; protected int _HTRSLL = 0; protected int _ASMUnloadTemps = 0; protected int _HTRUnloadTemps = 0; protected int _reportIndex = (int)DateTime.Now.DayOfWeek; protected int _numberOfDaysInWeek; // = Model.CurrentWeek.OutsByDay.Count; protected ManualReportEntries? _rpt; // = Model.ManualReportEntries; protected string? _myClass; protected override async Task OnInitializedAsync() { if (Logger is null) throw new NullReferenceException(nameof(Logger)); if (HttpClient is null) throw new NullReferenceException(nameof(HttpClient)); string baseScrapeDbUrl = "https://localhost:7196/api/" + "ScrapeDB/"; List? sllTools = null; ManualReportEntries? manualReportEntries = null; Dictionary>? toolStateOwners = null; try { sllTools = await HttpClient.GetFromJsonAsync>("http://localhost:5054/SLLTools.json"); manualReportEntries = await HttpClient.GetFromJsonAsync("http://localhost:5054/DailyReportInfo.json"); toolStateOwners = await HttpClient.GetFromJsonAsync>>("http://localhost:5054/ToolStates.json"); } catch (Exception ex) { Logger.LogError(ex, "Failed to load JsonFiles."); } try { _dailyReport = DailyReportHelper.SetUpDailyReport(Logger, baseScrapeDbUrl, sllTools, manualReportEntries); _dailyReport.ToolStatesByOwner = toolStateOwners; _numberOfDaysInWeek = _dailyReport.CurrentWeek.OutsByDay.Count; _rpt = _dailyReport.ManualReportEntries; } catch (Exception ex) { Logger.LogCritical(ex, "Failed to load report"); } } }