namespace LogViewer.Data { public class ReportFileService { private static IConfiguration _configuration; private static ILogger _logger; //private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); /// /// Init classe /// /// /// public ReportFileService(IConfiguration configuration, ILogger logger) { _logger = logger; _configuration = configuration; } public async Task> getDayReport() { string basec = _configuration["basePath"]; string targetDir = basec+$"/day"; return await getFileList(targetDir); } public async Task> getWeekReport() { string basec = _configuration["basePath"]; string targetDir = basec + $"/week"; return await getFileList(targetDir); //return await getFileList($"{Directory.GetCurrentDirectory()}/wwwroot/reports/week/"); } public async Task> getMonthReport() { string basec = _configuration["basePath"]; string targetDir = basec + $"/month"; return await getFileList(targetDir); //return await getFileList($"{Directory.GetCurrentDirectory()}/wwwroot/reports/month/"); } private static async Task> getFileList(string baseDir) { Dictionary keyValuePairs = new Dictionary(); Console.WriteLine($"GetfileList for {baseDir}"); var results = Directory.GetFiles(baseDir, "*.html"); Console.WriteLine($"Found {results.Length}"); foreach (var result in results) { keyValuePairs.Add(Path.GetFileName(result), result); } return await Task.FromResult(keyValuePairs); } } }