Business és Audit log hozzáadva, WEB-en letölthető

This commit is contained in:
2025-04-28 11:35:30 +02:00
parent 2fae17fed4
commit 9ffbcd87f2
9 changed files with 441 additions and 8 deletions
@@ -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";
}
<h1>@ViewData["Title"]</h1>
<div class="card shadow p-4">
<table id="tbAuditFilesPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
@section Scripts {
<script>
const table = new DataTable('#tbAuditFilesPage', {
ajax: {
url: "@Url.Page("./AuditFilesPage", "LoadAuditFiles")",
type: "GET",
dataSrc : "data"
},
columns: [
{ data: "id" },
{ data: "fileName" },
{ data: "createDate" },
{ data: "fileSize" },
{ data: null, render: function (data, type, row) {
return renderActionButtonsDownloadImages(row.id);
}}
],
columnDefs: [
{
"targets": 0,
"visible": false
},
{
"targets": 2,
"className": "text-start"
},
{
"targets": 3,
"className": "text-end"
},
{
"targets": 4,
"className": "text-center",
"width": "10%"
}
],
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#tbAuditFilesPage').on('click', '.download-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("/BaseStock/Log/Audit/AuditFilesPage")?handler=DownloadFile&filename=${row.fileName}`;
});
</script>
}
@@ -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<IndexModel> _logger;
private readonly ISystemService _systemService;
public AuditFilesPageModel(ILogger<IndexModel> logger, ISystemService systemService)
{
_logger = logger;
_systemService = systemService;
}
public async Task OnGet()
{
}
public async Task<JsonResult> OnGetLoadAuditFiles()
{
var results = await _systemService.GetAllLogAuditFilesAsync();
return new JsonResult(new { data = results });
}
public async Task<IActionResult> 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 });
}
}
}
}
@@ -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";
}
<h1>@ViewData["Title"]</h1>
<div class="card shadow p-4">
<table id="tbBusinessFilesPage" class="table table-bordered table-hover table-sm" style="width:100%">
<thead class="table-primary">
<tr>
<th>ID</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tfoot class="table-light">
<tr>
<th>ID</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileName), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.FileSize), typeof(ImageFileDTO))</th>
<th>@DisplayNameHelper.GetDisplayName(nameof(ImageFileDTO.CreateDate), typeof(ImageFileDTO))</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
@section Scripts {
<script>
const table = new DataTable('#tbBusinessFilesPage', {
ajax: {
url: "@Url.Page("./BusinessFilesPage", "LoadBusinessFiles")",
type: "GET",
dataSrc : "data"
},
columns: [
{ data: "id" },
{ data: "fileName" },
{ data: "createDate" },
{ data: "fileSize" },
{ data: null, render: function (data, type, row) {
return renderActionButtonsDownloadImages(row.id);
}}
],
columnDefs: [
{
"targets": 0,
"visible": false
},
{
"targets": 2,
"className": "text-start"
},
{
"targets": 3,
"className": "text-end"
},
{
"targets": 4,
"className": "text-center",
"width": "10%"
}
],
processing:true,
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
});
$('#tbBusinessFilesPage').on('click', '.download-btn', function ()
{
const row = table.row($(this).closest('tr')).data();
window.location.href = `@Url.Page("/BaseStock/BusinessFiles/BusinessFilesPage")?handler=DownloadFile&filename=${row.fileName}`;
});
</script>
}
@@ -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<IndexModel> _logger;
private readonly ISystemService _systemService;
public BusinessFilesPageModel(ILogger<IndexModel> logger, ISystemService systemService)
{
_logger = logger;
_systemService = systemService;
}
public async Task OnGet()
{
}
public async Task<JsonResult> OnGetLoadBusinessFiles()
{
var results = await _systemService.GetAllLogBusinessFilesAsync();
return new JsonResult(new { data = results });
}
public async Task<IActionResult> 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 });
}
}
}
}
@@ -39,6 +39,9 @@
<li><hr class="dropdown-divider"></li> <!-- EZ AZ ELVÁLASZTÓ VONAL -->
<li><a class="dropdown-item" asp-area="" asp-page="/BaseStock/ImageFiles/ImageFilesPage">Fényképek</a></li>
<li><a class="dropdown-item" asp-area="" asp-page="/BaseStock/PDFFiles/PDFFilesPage">PDF állomány</a></li>
<li><hr class="dropdown-divider"></li> <!-- EZ AZ ELVÁLASZTÓ VONAL -->
<li><a class="dropdown-item" asp-area="" asp-page="/BaseStock/Logs/Audit/AuditFilesPage">Audit események</a></li>
<li><a class="dropdown-item" asp-area="" asp-page="/BaseStock/Logs/Business/BusinessFilesPage">Folyamat események</a></li>
</ul>
</li>
<li class="nav-item dropdown">
@@ -6,7 +6,15 @@ namespace WorkFlowCheck.Web.Services.Interfaces
{
Task<List<ImageFileDTO>> GetAllImageFilesAsync();
Task<ApiResponseDTO<byte[]>> DownloadFile(string filename);
Task<List<PDFFileDTO>> GetAllPDFFilesAsync();
Task<ApiResponseDTO<byte[]>> DownloadPDFFile(string filename);
Task<List<LogFileDTO>> GetAllLogAuditFilesAsync();
Task<ApiResponseDTO<byte[]>> DownloadAuditLogFile(string filename);
Task<List<LogFileDTO>> GetAllLogBusinessFilesAsync();
Task<ApiResponseDTO<byte[]>> DownloadBusinessLogFile(string filename);
}
}
@@ -93,5 +93,91 @@ namespace WorkFlowCheck.Web.Services
}
return retVal;
}
public async Task<List<LogFileDTO>> GetAllLogAuditFilesAsync()
{
var endpoint = $"{_httpClient.BaseAddress}api/System/GetAllLogAuditFiles";
var retVal = new List<LogFileDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<LogFileDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<ApiResponseDTO<byte[]>> DownloadAuditLogFile(string filename)
{
var retVal = new ApiResponseDTO<byte[]>();
var endpoint = $"{_httpClient.BaseAddress}api/System/DownloadAuditLogFile/{filename}";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<byte[]>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<List<LogFileDTO>> GetAllLogBusinessFilesAsync()
{
var endpoint = $"{_httpClient.BaseAddress}api/System/GetAllLogBusinessFiles";
var retVal = new List<LogFileDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<LogFileDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<ApiResponseDTO<byte[]>> DownloadBusinessLogFile(string filename)
{
var retVal = new ApiResponseDTO<byte[]>();
var endpoint = $"{_httpClient.BaseAddress}api/System/DownloadBusinessLogFile/{filename}";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<byte[]>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}