Moved all of the file paths to appsettings file.
This commit is contained in:
@ -6,18 +6,15 @@ namespace ReportingServices.Shared.HelperClasses;
|
||||
|
||||
public static class DailyReportHelper
|
||||
{
|
||||
private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
|
||||
private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json";
|
||||
|
||||
public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlScrapeDb)
|
||||
public static DailyReport SetUpDailyReport(ILogger logger, Dictionary<string, string> filePaths, string baseUrlScrapeDb)
|
||||
{
|
||||
DailyReport report = new();
|
||||
DateTime currentDateTime = DateTime.Now;
|
||||
|
||||
try
|
||||
{
|
||||
List<SLLTool> tools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(_SLLFilePath);
|
||||
ManualReportEntries manualEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(_dailyRptFilePath);
|
||||
List<SLLTool> tools = JsonFileHandler.LoadJSONFile<List<SLLTool>>(filePaths["SLL"]);
|
||||
ManualReportEntries manualEntries = JsonFileHandler.LoadJSONFile<ManualReportEntries>(filePaths["DailyReport"]);
|
||||
|
||||
if (currentDateTime.DayOfWeek == DayOfWeek.Monday && tools[^1].Date == currentDateTime.Date.AddDays(-1))
|
||||
report.SLLTools = new List<SLLTool>();
|
||||
@ -26,12 +23,14 @@ public static class DailyReportHelper
|
||||
|
||||
report.ManualReportEntries = manualEntries;
|
||||
|
||||
report.ToolStatesByOwner = JsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(filePaths["ToolStateOwners"]);
|
||||
|
||||
}
|
||||
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);
|
||||
logger.LogInformation("SLL File Path: {path}", filePaths["SLL"]);
|
||||
logger.LogInformation("Manual Report Entries File Path: {path}", filePaths["DailyReport"]);
|
||||
}
|
||||
|
||||
List<string> cleanTools = new()
|
||||
@ -169,8 +168,8 @@ public static class DailyReportHelper
|
||||
|
||||
try
|
||||
{
|
||||
JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath);
|
||||
JsonFileHandler.SaveJSONFile(sll, _SLLFilePath);
|
||||
JsonFileHandler.SaveJSONFile(entries, filePaths["DailyReport"]);
|
||||
JsonFileHandler.SaveJSONFile(sll, filePaths["SLL"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user