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.
This commit is contained in:
43
ReportingServices.Blazor/Services/ScrapeDBService.cs
Normal file
43
ReportingServices.Blazor/Services/ScrapeDBService.cs
Normal file
@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user