Added logging to application.
This commit is contained in:
@ -6,13 +6,17 @@ namespace ReportingServices.UI.Controllers
|
||||
{
|
||||
public class PlanningReportController : Controller
|
||||
{
|
||||
private readonly ILogger<PlanningReportController> _logger;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string _baseUrl;
|
||||
|
||||
public PlanningReportController(IConfiguration configuration)
|
||||
public PlanningReportController(ILogger<PlanningReportController> logger, IConfiguration configuration)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_baseUrl = _configuration.GetValue<string>("BaseAPIAddress") + "ScrapeDB/";
|
||||
|
||||
_logger.LogInformation("Base API Address: {baseUrl}", _baseUrl);
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -25,16 +29,27 @@ namespace ReportingServices.UI.Controllers
|
||||
string partChangeUrl = _baseUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
|
||||
string psnwoRunsUrl = _baseUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
|
||||
|
||||
int numberOfPartChanges = await ApiCaller.GetApi<int>(partChangeUrl);
|
||||
List<ReactorPSNWORuns> reactorPSNWORuns = await ApiCaller.GetApi<List<ReactorPSNWORuns>>(psnwoRunsUrl);
|
||||
_logger.LogInformation("Part Change URL: {url}", partChangeUrl);
|
||||
_logger.LogInformation("PSN WO Runs URL: {url}", psnwoRunsUrl);
|
||||
|
||||
WeeklyPartChanges weeklyPartChanges = new()
|
||||
WeeklyPartChanges weeklyPartChanges = new();
|
||||
|
||||
try
|
||||
{
|
||||
TotalPartChanges = numberOfPartChanges,
|
||||
StartDate = startDate.ToShortDateString(),
|
||||
EndDate = endDate.ToShortDateString(),
|
||||
ReactorPSNWORuns = reactorPSNWORuns
|
||||
};
|
||||
int numberOfPartChanges = await ApiCaller.GetApi<int>(partChangeUrl);
|
||||
List<ReactorPSNWORuns> reactorPSNWORuns = await ApiCaller.GetApi<List<ReactorPSNWORuns>>(psnwoRunsUrl);
|
||||
|
||||
weeklyPartChanges.TotalPartChanges = numberOfPartChanges;
|
||||
weeklyPartChanges.StartDate = startDate.ToShortDateString();
|
||||
weeklyPartChanges.EndDate = endDate.ToShortDateString();
|
||||
weeklyPartChanges.ReactorPSNWORuns = reactorPSNWORuns;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical(ex, "Failed to get a response from API calls.");
|
||||
RedirectToAction("Error");
|
||||
}
|
||||
|
||||
|
||||
return View(weeklyPartChanges);
|
||||
}
|
||||
|
Reference in New Issue
Block a user