Business és Audit log hozzáadva, WEB-en letölthető
This commit is contained in:
@@ -148,9 +148,9 @@ namespace WorkFlowCheck.API.Controllers
|
||||
return retVal;
|
||||
}
|
||||
[HttpGet("GetAllLogAuditFiles")]
|
||||
public async Task<ApiResponseDTO<List<ImageFileDTO>>> GetAllLogAuditiFilesAsync()
|
||||
public async Task<ApiResponseDTO<List<LogFileDTO>>> GetAllLogAuditFilesAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<ImageFileDTO>>()
|
||||
var retVal = new ApiResponseDTO<List<LogFileDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
@@ -169,10 +169,10 @@ namespace WorkFlowCheck.API.Controllers
|
||||
};
|
||||
});
|
||||
|
||||
var checkListFileInfos = new List<ImageFileDTO>();
|
||||
var checkListFileInfos = new List<LogFileDTO>();
|
||||
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<ApiResponseDTO<List<ImageFileDTO>>> GetAllLogBusinessFilesAsync()
|
||||
public async Task<ApiResponseDTO<List<LogFileDTO>>> GetAllLogBusinessFilesAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<ImageFileDTO>>()
|
||||
var retVal = new ApiResponseDTO<List<LogFileDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
@@ -221,10 +221,10 @@ namespace WorkFlowCheck.API.Controllers
|
||||
};
|
||||
});
|
||||
|
||||
var checkListFileInfos = new List<ImageFileDTO>();
|
||||
var checkListFileInfos = new List<LogFileDTO>();
|
||||
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<ApiResponseDTO<byte[]>> DownloadAuditLogFile(string filename)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
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<ApiResponseDTO<byte[]>> DownloadBusinessLogFile(string filename)
|
||||
{
|
||||
var retVal = new ApiResponseDTO<byte[]>()
|
||||
{
|
||||
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" };
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user