Daniel Wathen 72e7a55ab4 Updated daily report to show correct information when two work weeks split quarters.
Also current changes to project with Blazor implementation is implemented here as well.
2023-04-03 09:58:28 -07:00

44 lines
1.9 KiB
C#

using ReportingServices.Shared.Blazor.Models.PlanningReport;
using ReportingServices.Shared.Blazor.Models.ProductionReport;
using System.Text.Json;
namespace ReportingServices.Blazor.Services;
public class ScrapeDBService
{
private readonly string APIUrl = "https://localhost:7196/api/ScrapeDB/";
public async Task<List<NCR>> GetNCRsAsync() => await GetApi<List<NCR>>(APIUrl + "GetCurrentNCRs");
public async Task<List<HoldLot>> GetHoldLotsAsync() => await GetApi<List<HoldLot>>(APIUrl + "GetCurrentHoldLots");
public async Task<int> GetPartChangesAsync(DateTime startDate, DateTime endDate) =>
await GetApi<int>(APIUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString());
public async Task<List<ReactorPSNWORuns>> GetReactorRunsAsync(DateTime startDate, DateTime endDate) =>
await GetApi<List<ReactorPSNWORuns>>(APIUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString());
public async Task<YieldInformation> GetReactorAndScrapOutsAsync(DateTime startDate, DateTime endDate) =>
await GetApi<YieldInformation>(APIUrl + "ReactorOuts?startDate=" + startDate + "&endDate=" + endDate);
public async Task<QuarterlyTargets> GetTargetsAsync() => await GetApi<QuarterlyTargets>(APIUrl + "Targets");
public async Task<DateTime> GetQuarterStartDate() => await GetApi<DateTime>(APIUrl + "GetQuarterStartDate");
public async Task<OutsAndScrapTotal> GetOutsAndScrapAsync(DateTime startDate, DateTime endDate) =>
await GetApi<OutsAndScrapTotal>(APIUrl + "GetOutsAndScrapTotals?startDate=" + startDate + "&endDate=" + endDate);
private async Task<T> GetApi<T>(string url)
{
T deserializedJson = default;
using (HttpClient client = new())
{
string apiResponse = await client.GetStringAsync(url);
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
}
return deserializedJson;
}
}