diff --git a/src/WorkFlowCheck.API/Controllers/SystemController.cs b/src/WorkFlowCheck.API/Controllers/SystemController.cs index 91319ae..d0ca942 100644 --- a/src/WorkFlowCheck.API/Controllers/SystemController.cs +++ b/src/WorkFlowCheck.API/Controllers/SystemController.cs @@ -148,9 +148,9 @@ namespace WorkFlowCheck.API.Controllers return retVal; } [HttpGet("GetAllLogAuditFiles")] - public async Task>> GetAllLogAuditiFilesAsync() + public async Task>> GetAllLogAuditFilesAsync() { - var retVal = new ApiResponseDTO>() + var retVal = new ApiResponseDTO>() { IsSuccess = true, }; @@ -169,10 +169,10 @@ namespace WorkFlowCheck.API.Controllers }; }); - var checkListFileInfos = new List(); + var checkListFileInfos = new List(); foreach (var file in files.OrderBy(o => o.FileName).ToList()) { - var checkListFileInfoDTO = new ImageFileDTO() + var checkListFileInfoDTO = new LogFileDTO() { FileName = file.FileName, FileSize = file.FileSize, @@ -200,9 +200,9 @@ namespace WorkFlowCheck.API.Controllers return retVal; } [HttpGet("GetAllLogBusinessFiles")] - public async Task>> GetAllLogBusinessFilesAsync() + public async Task>> GetAllLogBusinessFilesAsync() { - var retVal = new ApiResponseDTO>() + var retVal = new ApiResponseDTO>() { IsSuccess = true, }; @@ -221,10 +221,10 @@ namespace WorkFlowCheck.API.Controllers }; }); - var checkListFileInfos = new List(); + var checkListFileInfos = new List(); foreach (var file in files.OrderBy(o => o.FileName).ToList()) { - var checkListFileInfoDTO = new ImageFileDTO() + var checkListFileInfoDTO = new LogFileDTO() { FileName = file.FileName, FileSize = file.FileSize, @@ -317,6 +317,72 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + + [HttpGet("DownloadAuditLogFile/{filename}")] + public async Task> DownloadAuditLogFile(string filename) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = false, + }; + var imageFile = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\AuditFlow", filename); + + if (!System.IO.File.Exists(imageFile)) + { + retVal.Errors.Add($"{filename} does not exist"); + return retVal; + } + + byte[] response = System.IO.File.ReadAllBytes(imageFile); + + + if (response != null) + { + + retVal.IsSuccess = true; + retVal.Data = response; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } + [HttpGet("DownloadBusinessLogFile/{filename}")] + public async Task> DownloadBusinessLogFile(string filename) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = false, + }; + var imageFile = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\BusinessFlow", filename); + + if (!System.IO.File.Exists(imageFile)) + { + retVal.Errors.Add($"{filename} does not exist"); + return retVal; + } + + byte[] response = System.IO.File.ReadAllBytes(imageFile); + + + if (response != null) + { + + retVal.IsSuccess = true; + retVal.Data = response; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } + private string FormatFileSize(long bytes) { string[] sizes = { "B", "KB", "MB", "GB", "TB" }; diff --git a/src/WorkFlowCheck.Common/DTO/LogFileDTO.cs b/src/WorkFlowCheck.Common/DTO/LogFileDTO.cs new file mode 100644 index 0000000..8f5a958 --- /dev/null +++ b/src/WorkFlowCheck.Common/DTO/LogFileDTO.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.Common.DTO +{ + public class LogFileDTO + { + public string Id { get; set; } + public string FileName { get; set; } + public string FileSize { get; set; } + public string CreateDate { get; set; } + } +} diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Audit/AuditFilesPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Audit/AuditFilesPage.cshtml new file mode 100644 index 0000000..2e08d64 --- /dev/null +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Audit/AuditFilesPage.cshtml @@ -0,0 +1,80 @@ +@page +@model WorkFlowCheck.Web.Pages.BaseStock.AuditFiles.AuditFilesPageModel +@using WorkFlowCheck.Common.Helper +@using WorkFlowCheck.Common.DTO +@{ + ViewData["Title"] = "Audit események"; +} +

@ViewData["Title"]

+ +
+ + + + + + + + + + + + + + + + + + + +
ID@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))Action
ID@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))Action
+
+ +@section Scripts { + +} diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Audit/AuditFilesPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Audit/AuditFilesPage.cshtml.cs new file mode 100644 index 0000000..302cbc7 --- /dev/null +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Audit/AuditFilesPage.cshtml.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using WorkFlowCheck.Web.Services.Interfaces; + +namespace WorkFlowCheck.Web.Pages.BaseStock.AuditFiles +{ + [Authorize] + public class AuditFilesPageModel : PageModel + { + private readonly ILogger _logger; + private readonly ISystemService _systemService; + public AuditFilesPageModel(ILogger logger, ISystemService systemService) + { + _logger = logger; + _systemService = systemService; + } + public async Task OnGet() + { + } + public async Task OnGetLoadAuditFiles() + { + var results = await _systemService.GetAllLogAuditFilesAsync(); + return new JsonResult(new { data = results }); + } + public async Task OnGetDownloadFile(string filename) + { + var response = await _systemService.DownloadAuditLogFile(filename); + + + if (response.IsSuccess) + { + + var result = new FileContentResult(response.Data, "application/octet-stream") + { + FileDownloadName = filename, + FileContents = response.Data + }; + return result; + } + else + { + return new JsonResult(new { success = false }); + } + } + } +} diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Business/BusinessFilesPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Business/BusinessFilesPage.cshtml new file mode 100644 index 0000000..acb6b2c --- /dev/null +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Business/BusinessFilesPage.cshtml @@ -0,0 +1,80 @@ +@page +@model WorkFlowCheck.Web.Pages.BaseStock.BusinessFiles.BusinessFilesPageModel +@using WorkFlowCheck.Common.Helper +@using WorkFlowCheck.Common.DTO +@{ + ViewData["Title"] = "Folyamat események"; +} +

@ViewData["Title"]

+ +
+ + + + + + + + + + + + + + + + + + + +
ID@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))Action
ID@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))Action
+
+ +@section Scripts { + +} diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Business/BusinessFilesPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Business/BusinessFilesPage.cshtml.cs new file mode 100644 index 0000000..a5244c6 --- /dev/null +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Logs/Business/BusinessFilesPage.cshtml.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using WorkFlowCheck.Web.Services.Interfaces; + +namespace WorkFlowCheck.Web.Pages.BaseStock.BusinessFiles +{ + [Authorize] + public class BusinessFilesPageModel : PageModel + { + private readonly ILogger _logger; + private readonly ISystemService _systemService; + public BusinessFilesPageModel(ILogger logger, ISystemService systemService) + { + _logger = logger; + _systemService = systemService; + } + public async Task OnGet() + { + } + public async Task OnGetLoadBusinessFiles() + { + var results = await _systemService.GetAllLogBusinessFilesAsync(); + return new JsonResult(new { data = results }); + } + public async Task OnGetDownloadFile(string filename) + { + var response = await _systemService.DownloadBusinessLogFile(filename); + + + if (response.IsSuccess) + { + + var result = new FileContentResult(response.Data, "application/octet-stream") + { + FileDownloadName = filename, + FileContents = response.Data + }; + return result; + } + else + { + return new JsonResult(new { success = false }); + } + } + } +} diff --git a/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml b/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml index fe08bb3..46881ed 100644 --- a/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml +++ b/src/WorkFlowCheck.Web/Pages/Shared/_Layout.cshtml @@ -39,6 +39,9 @@
  • Fényképek
  • PDF állomány
  • +
  • +
  • Audit események
  • +
  • Folyamat események