Updated logging.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
namespace ReportingServices.Shared.HelperClasses
|
||||
@ -8,57 +9,116 @@ namespace ReportingServices.Shared.HelperClasses
|
||||
private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json";
|
||||
|
||||
public static DailyReport SetUpDailyReport(string baseUrlFabtime, string baseUrlScrapeDb)
|
||||
public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlFabtime, string baseUrlScrapeDb)
|
||||
{
|
||||
List<Task<List<EquipmentStateByDay>>> tasksEQState = new();
|
||||
List<Task<List<ToolStateCurrent>>> tasksState = new();
|
||||
DailyReport report = new()
|
||||
DailyReport report = new();
|
||||
|
||||
try
|
||||
{
|
||||
SLLTools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(_SLLFilePath),
|
||||
ManualReportEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath)
|
||||
};
|
||||
report.SLLTools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(_SLLFilePath);
|
||||
report.ManualReportEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath);
|
||||
|
||||
Task<YieldInformation> task1 = ApiCaller.GetApi<YieldInformation>(baseUrlFabtime + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString());
|
||||
Task<YieldInformation> task2 = ApiCaller.GetApi<YieldInformation>(baseUrlFabtime + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to load JsonFiles.");
|
||||
logger.LogInformation("SLL File Path: {path}", _SLLFilePath);
|
||||
logger.LogInformation("Manual Report Entries File Path: {path}", _dailyRptFilePath);
|
||||
}
|
||||
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(baseUrlFabtime + "ToolStateTrend?toolType=ASM"));
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(baseUrlFabtime + "ToolStateTrend?toolType=EPP"));
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(baseUrlFabtime + "ToolStateTrend?toolType=HTR"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=ASM"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=EPP"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=HTR"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=Metrology"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=Cleans"));
|
||||
Task<YieldInformation> task1 = null;
|
||||
Task<YieldInformation> task2 = null;
|
||||
|
||||
Task<QuarterlyTargets> targets = ApiCaller.GetApi<QuarterlyTargets>(baseUrlScrapeDb + "Targets");
|
||||
Task<List<RDS>> rds = ApiCaller.GetApi<List<RDS>>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString());
|
||||
Task<List<Reactor>> reactors = ApiCaller.GetApi<List<Reactor>>(baseUrlScrapeDb + "Reactors");
|
||||
|
||||
report.AddToolAvailibilityByType("ASM", tasksEQState[0].Result);
|
||||
report.AddToolAvailibilityByType("EPP", tasksEQState[1].Result);
|
||||
report.AddToolAvailibilityByType("HTR", tasksEQState[2].Result);
|
||||
try
|
||||
{
|
||||
task1 = ApiCaller.GetApi<YieldInformation>(baseUrlFabtime + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString());
|
||||
task2 = ApiCaller.GetApi<YieldInformation>(baseUrlFabtime + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString());
|
||||
|
||||
report.AddToolStateByType("ASM", tasksState[0].Result);
|
||||
report.AddToolStateByType("EPP", tasksState[1].Result);
|
||||
report.AddToolStateByType("HTR", tasksState[2].Result);
|
||||
report.AddToolStateByType("Metrology", tasksState[3].Result);
|
||||
report.AddToolStateByType("Cleans", tasksState[4].Result);
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(baseUrlFabtime + "ToolStateTrend?toolType=ASM"));
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(baseUrlFabtime + "ToolStateTrend?toolType=EPP"));
|
||||
tasksEQState.Add(ApiCaller.GetApi<List<EquipmentStateByDay>>(baseUrlFabtime + "ToolStateTrend?toolType=HTR"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=ASM"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=EPP"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=HTR"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=Metrology"));
|
||||
tasksState.Add(ApiCaller.GetApi<List<ToolStateCurrent>>(baseUrlFabtime + "ToolState?toolType=Cleans"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to send get requests to fabtime endpoints.");
|
||||
}
|
||||
|
||||
report.QuarterlyTargets = targets.Result;
|
||||
Task<QuarterlyTargets> targets = null;
|
||||
Task<List<RDS>> rds = null;
|
||||
Task<List<Reactor>> reactors = null;
|
||||
|
||||
report.SetRDSInfo(rds.Result);
|
||||
report.SetReactorInfo(reactors.Result, GetUnscheduledReactors(report));
|
||||
try
|
||||
{
|
||||
targets = ApiCaller.GetApi<QuarterlyTargets>(baseUrlScrapeDb + "Targets");
|
||||
rds = ApiCaller.GetApi<List<RDS>>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString());
|
||||
reactors = ApiCaller.GetApi<List<Reactor>>(baseUrlScrapeDb + "Reactors");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to send get requests to scrapedb endpoints.");
|
||||
}
|
||||
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets);
|
||||
try
|
||||
{
|
||||
report.AddToolAvailibilityByType("ASM", tasksEQState[0].Result);
|
||||
report.AddToolAvailibilityByType("EPP", tasksEQState[1].Result);
|
||||
report.AddToolAvailibilityByType("HTR", tasksEQState[2].Result);
|
||||
|
||||
report.AddToolStateByType("ASM", tasksState[0].Result);
|
||||
report.AddToolStateByType("EPP", tasksState[1].Result);
|
||||
report.AddToolStateByType("HTR", tasksState[2].Result);
|
||||
report.AddToolStateByType("Metrology", tasksState[3].Result);
|
||||
report.AddToolStateByType("Cleans", tasksState[4].Result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to retrieve data back from Tool State and Tool State Trend FabTime endpoints.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
report.QuarterlyTargets = targets.Result;
|
||||
|
||||
report.SetRDSInfo(rds.Result);
|
||||
report.SetReactorInfo(reactors.Result, GetUnscheduledReactors(report));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to retrieve data back from Scrape DB endpoints.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets);
|
||||
report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to retreive data back from ReactorOuts and Scrap endpoints.");
|
||||
}
|
||||
|
||||
report.ReverseLists();
|
||||
|
||||
ManualReportEntries entries = report.ManualReportEntries;
|
||||
List<SLLTool> sll = report.SLLTools;
|
||||
|
||||
JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
||||
JsonFileHandler.SaveJSONFile(sll, _SLLFilePath);
|
||||
try
|
||||
{
|
||||
JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
||||
JsonFileHandler.SaveJSONFile(sll, _SLLFilePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogCritical(ex, "Failed to save data back to JSON files.");
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
|
Reference in New Issue
Block a user