Ran formatting through code

This commit is contained in:
Daniel Wathen
2023-01-12 13:19:05 -07:00
parent ba6d7b19e7
commit 8d65b82af6
37 changed files with 2006 additions and 1823 deletions

View File

@ -2,27 +2,20 @@
using ReportingServices.UI.Models;
using System.Diagnostics;
namespace ReportingServices.UI.Controllers
namespace ReportingServices.UI.Controllers;
public class HomeController : Controller
{
public class HomeController : Controller
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger) => _logger = logger;
public IActionResult Index()
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
_logger.LogInformation("Starting Index Page");
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
_logger.LogInformation("Starting Index Page");
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() => View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}

View File

@ -1,55 +1,50 @@
using Microsoft.AspNetCore.Mvc;
using ReportingServices.Shared.Models.PlanningReport;
using ReportingServices.Shared.HelperClasses;
using ReportingServices.Shared.Models.PlanningReport;
namespace ReportingServices.UI.Controllers
namespace ReportingServices.UI.Controllers;
public class PlanningReportController : Controller
{
public class PlanningReportController : Controller
private readonly ILogger<PlanningReportController> _logger;
private readonly string _baseUrl;
public PlanningReportController(ILogger<PlanningReportController> logger)
{
private readonly ILogger<PlanningReportController> _logger;
private readonly string _baseUrl;
_logger = logger;
_baseUrl = "http://localhost:50201/api/" + "ScrapeDB/";
public PlanningReportController(ILogger<PlanningReportController> logger)
{
_logger = logger;
_baseUrl = "http://localhost:50201/api/" + "ScrapeDB/";
_logger.LogInformation("Base API Address: {baseUrl}", _baseUrl);
}
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> WeeklyPartChangesReport(DateTime startDate, DateTime endDate)
{
string partChangeUrl = _baseUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
string psnwoRunsUrl = _baseUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
_logger.LogInformation("Part Change URL: {url}", partChangeUrl);
_logger.LogInformation("PSN WO Runs URL: {url}", psnwoRunsUrl);
WeeklyPartChanges weeklyPartChanges = new();
try
{
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);
}
_logger.LogInformation("Base API Address: {baseUrl}", _baseUrl);
}
}
public IActionResult Index() => View();
public async Task<IActionResult> WeeklyPartChangesReport(DateTime startDate, DateTime endDate)
{
string partChangeUrl = _baseUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
string psnwoRunsUrl = _baseUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString();
_logger.LogInformation("Part Change URL: {url}", partChangeUrl);
_logger.LogInformation("PSN WO Runs URL: {url}", psnwoRunsUrl);
WeeklyPartChanges weeklyPartChanges = new();
try
{
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);
}
}

View File

@ -3,62 +3,57 @@ using ReportingServices.Shared.HelperClasses;
using ReportingServices.Shared.Models.ProductionReport;
using ReportingServices.Shared.ViewModels.ProductionReport;
namespace ReportingServices.UI.Controllers
namespace ReportingServices.UI.Controllers;
public class ProductionReportController : Controller
{
public class ProductionReportController : Controller
private readonly ILogger<ProductionReportController> _logger;
private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json";
private readonly string _baseDBUrl;
public ProductionReportController(ILogger<ProductionReportController> logger)
{
private readonly ILogger<ProductionReportController> _logger;
private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json";
private readonly string _baseDBUrl;
_logger = logger;
_baseDBUrl = "http://localhost:50201/api/";
public ProductionReportController(ILogger<ProductionReportController> logger)
_logger.LogInformation("Base Database Address: {baseUrl}", _baseDBUrl);
}
public IActionResult Index() => View();
public IActionResult DailyReport()
{
string baseScrapeDbUrl = _baseDBUrl + "ScrapeDB/";
try
{
_logger = logger;
_baseDBUrl = "http://localhost:50201/api/";
DailyReport dailyReport = DailyReportHelper.SetUpDailyReport(_logger, baseScrapeDbUrl);
Dictionary<string, List<string>> toolStateOwners = JsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(_toolStateOwnerFilePath);
_logger.LogInformation("Base Database Address: {baseUrl}", _baseDBUrl);
dailyReport.ToolStatesByOwner = toolStateOwners;
return View(dailyReport);
}
public IActionResult Index()
catch (Exception ex)
{
_logger.LogCritical(ex, "Failed to load report");
return View();
}
public IActionResult DailyReport()
{
string baseScrapeDbUrl = _baseDBUrl + "ScrapeDB/";
try
{
DailyReport dailyReport = DailyReportHelper.SetUpDailyReport(_logger, baseScrapeDbUrl);
Dictionary<string, List<string>> toolStateOwners = JsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(_toolStateOwnerFilePath);
dailyReport.ToolStatesByOwner = toolStateOwners;
return View(dailyReport);
}
catch (Exception ex)
{
_logger.LogCritical(ex, "Failed to load report");
return View();
}
}
public IActionResult EditDailyReport()
{
ManualReportEntries entries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath);
return View(entries);
}
[HttpPost]
public IActionResult EditDailyReport(ManualReportEntries rpt)
{
JsonFileHandler.SaveJSONFile(rpt, _dailyRptFilePath);
return RedirectToAction("DailyReport");
}
}
}
public IActionResult EditDailyReport()
{
ManualReportEntries entries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath);
return View(entries);
}
[HttpPost]
public IActionResult EditDailyReport(ManualReportEntries rpt)
{
JsonFileHandler.SaveJSONFile(rpt, _dailyRptFilePath);
return RedirectToAction("DailyReport");
}
}