Reorganized project structure to separate backend process from frontend process.
This commit is contained in:
28
ReportingServices.UI/Controllers/HomeController.cs
Normal file
28
ReportingServices.UI/Controllers/HomeController.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReportingServices.UI.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ReportingServices.UI.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
37
ReportingServices.UI/Controllers/PlanningReportController.cs
Normal file
37
ReportingServices.UI/Controllers/PlanningReportController.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReportingServices.Shared.Repositories;
|
||||
using ReportingServices.Shared.Models.PlanningReport;
|
||||
|
||||
namespace ReportingServices.UI.Controllers
|
||||
{
|
||||
public class PlanningReportController : Controller
|
||||
{
|
||||
private readonly IScrapeDatabaseRepository _scrapeDatabaseRepository;
|
||||
|
||||
public PlanningReportController(IScrapeDatabaseRepository scrapeDatabaseRepository)
|
||||
{
|
||||
_scrapeDatabaseRepository = scrapeDatabaseRepository;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult WeeklyPartChangesReport(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
int numberOfPartChanges = _scrapeDatabaseRepository.GetNumberOfPartChanges(startDate.ToString(), endDate.ToString());
|
||||
List<ReactorPSNWORuns> reactorPSNWORuns = _scrapeDatabaseRepository.GetReactorPSNWORuns(startDate.ToString(), endDate.ToString());
|
||||
|
||||
WeeklyPartChanges weeklyPartChanges = new()
|
||||
{
|
||||
TotalPartChanges = numberOfPartChanges,
|
||||
StartDate = startDate.ToShortDateString(),
|
||||
EndDate = endDate.ToShortDateString(),
|
||||
ReactorPSNWORuns = reactorPSNWORuns
|
||||
};
|
||||
|
||||
return View(weeklyPartChanges);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReportingServices.Shared.Repositories;
|
||||
using ReportingServices.Shared.HelperClasses;
|
||||
using ReportingServices.Shared.Models.ProductionReport;
|
||||
using ReportingServices.Shared.ViewModels.ProductionReport;
|
||||
|
||||
namespace ReportingServices.UI.Controllers
|
||||
{
|
||||
public class ProductionReportController : Controller
|
||||
{
|
||||
private readonly IScrapeDatabaseRepository _scrapeDatabaseRepository;
|
||||
private readonly IFabTimeReportingRepository _fabTimeReportingRepository;
|
||||
private readonly ILogger<ProductionReportController> _logger;
|
||||
private readonly int _reportIndex = (int)DateTime.Now.DayOfWeek;
|
||||
private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json";
|
||||
|
||||
public ProductionReportController(IScrapeDatabaseRepository scrapeDatabaseRepository,
|
||||
IFabTimeReportingRepository fabTimeReportingRepository, ILogger<ProductionReportController> logger)
|
||||
{
|
||||
_scrapeDatabaseRepository = scrapeDatabaseRepository;
|
||||
_fabTimeReportingRepository = fabTimeReportingRepository;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult DailyReport()
|
||||
{
|
||||
try
|
||||
{
|
||||
DailyReportHelper.SetRepositories(_fabTimeReportingRepository, _scrapeDatabaseRepository);
|
||||
DailyReport dailyReport = DailyReportHelper.SetUpDailyReport();
|
||||
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()
|
||||
{
|
||||
Dictionary<string, List<ManualReportEntries>> entries = JsonFileHandler.LoadJSONFile<Dictionary<string, List<ManualReportEntries>>>(_dailyRptFilePath);
|
||||
|
||||
ManualReportEntries rpt = entries["Current Week"][_reportIndex];
|
||||
|
||||
return View(rpt);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult EditDailyReport(ManualReportEntries rpt)
|
||||
{
|
||||
Dictionary<string, List<ManualReportEntries>> report = JsonFileHandler.LoadJSONFile<Dictionary<string, List<ManualReportEntries>>>(_dailyRptFilePath);
|
||||
|
||||
rpt.Date = DateTime.Parse(DateTime.Now.ToShortDateString());
|
||||
rpt.Day = DateTime.Now.DayOfWeek;
|
||||
|
||||
report["Current Week"][_reportIndex] = rpt;
|
||||
|
||||
JsonFileHandler.SaveJSONFile(report, _dailyRptFilePath);
|
||||
|
||||
return RedirectToAction("DailyReport");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user