diff --git a/src/WorkFlowCheck.API/Controllers/CheckListController.cs b/src/WorkFlowCheck.API/Controllers/CheckListController.cs index 3fae01c..83672b0 100644 --- a/src/WorkFlowCheck.API/Controllers/CheckListController.cs +++ b/src/WorkFlowCheck.API/Controllers/CheckListController.cs @@ -278,6 +278,28 @@ namespace WorkFlowCheck.API.Controllers } return retVal; } + [HttpGet("DeleteCheckListTemplateHeader/{id}")] + public async Task> DeleteCheckListTemplateHeader(int id) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + }; + var result = await _checkListService.DeleteCheckListTemplateHeaderAsync(id); + + if (result != null) + { + retVal.IsSuccess = true; + retVal.Data = result; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } [HttpGet("GetCheckListTemplateRow/{id}")] diff --git a/src/WorkFlowCheck.API/Controllers/SystemController.cs b/src/WorkFlowCheck.API/Controllers/SystemController.cs index 65bc9d4..91319ae 100644 --- a/src/WorkFlowCheck.API/Controllers/SystemController.cs +++ b/src/WorkFlowCheck.API/Controllers/SystemController.cs @@ -50,8 +50,10 @@ namespace WorkFlowCheck.API.Controllers }; try { + var allowedExtensions = new[] { ".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp", ".tiff" }; var imageFolder = Path.Combine(Directory.GetCurrentDirectory(), "Images"); var files = Directory.GetFiles(imageFolder) + .Where(f => allowedExtensions.Contains(Path.GetExtension(f).ToLower())) .Select(f => { var fileInfo = new FileInfo(f); @@ -102,8 +104,112 @@ namespace WorkFlowCheck.API.Controllers }; try { - var imageFolder = Path.Combine(Directory.GetCurrentDirectory(), "PDF"); - var files = Directory.GetFiles(imageFolder) + var pdfFolder = Path.Combine(Directory.GetCurrentDirectory(), "PDF"); + var files = Directory.GetFiles(pdfFolder, "*.pdf") + .Select(f => + { + var fileInfo = new FileInfo(f); + return new + { + FileName = fileInfo.Name, + FileSize = FormatFileSize(fileInfo.Length), + CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"), + }; + }); + + var checkListFileInfos = new List(); + foreach (var file in files.OrderBy(o => o.FileName).ToList()) + { + var checkListFileInfoDTO = new ImageFileDTO() + { + FileName = file.FileName, + FileSize = file.FileSize, + CreateDate = file.CreatedDate, + + }; + checkListFileInfos.Add(checkListFileInfoDTO); + } + + if (checkListFileInfos != null) + { + retVal.IsSuccess = true; + retVal.Data = checkListFileInfos; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + [HttpGet("GetAllLogAuditFiles")] + public async Task>> GetAllLogAuditiFilesAsync() + { + var retVal = new ApiResponseDTO>() + { + IsSuccess = true, + }; + try + { + var logAuditFiles = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\AuditFlow"); + var files = Directory.GetFiles(logAuditFiles, "*.log") + .Select(f => + { + var fileInfo = new FileInfo(f); + return new + { + FileName = fileInfo.Name, + FileSize = FormatFileSize(fileInfo.Length), + CreatedDate = fileInfo.CreationTime.ToString("yyyy.MM.dd HH:mm"), + }; + }); + + var checkListFileInfos = new List(); + foreach (var file in files.OrderBy(o => o.FileName).ToList()) + { + var checkListFileInfoDTO = new ImageFileDTO() + { + FileName = file.FileName, + FileSize = file.FileSize, + CreateDate = file.CreatedDate, + + }; + checkListFileInfos.Add(checkListFileInfoDTO); + } + + if (checkListFileInfos != null) + { + retVal.IsSuccess = true; + retVal.Data = checkListFileInfos; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + [HttpGet("GetAllLogBusinessFiles")] + public async Task>> GetAllLogBusinessFilesAsync() + { + var retVal = new ApiResponseDTO>() + { + IsSuccess = true, + }; + try + { + var logBusinessFiles = Path.Combine(Directory.GetCurrentDirectory(), "Logs\\BusinessFlow"); + var files = Directory.GetFiles(logBusinessFiles, "*.log") .Select(f => { var fileInfo = new FileInfo(f); diff --git a/src/WorkFlowCheck.BL/Services/CheckListService.cs b/src/WorkFlowCheck.BL/Services/CheckListService.cs index 9782d8c..83adad8 100644 --- a/src/WorkFlowCheck.BL/Services/CheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/CheckListService.cs @@ -489,7 +489,10 @@ namespace WorkFlowCheck.BL.Services return retVal; } - + public async Task DeleteCheckListTemplateHeaderAsync(int id) + { + return await DeleteEntityByIdAsync(id); + } public async Task GetCheckListTemplateRowAsync(int id) { var retVal = new CheckListTemplateRowDTO(); diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs index b5bff47..a5027cd 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs @@ -19,7 +19,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces Task GetCheckListTemplateHeaderAsync(int Id); Task> GetAllCheckListTemplateHeaderAsync(); Task UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); - + Task DeleteCheckListTemplateHeaderAsync(int id); Task GetCheckListTemplateRowAsync(int id); Task DeleteCheckListTemplateRowAsync(int id); Task UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO); diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml index ac72119..e04889c 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml @@ -1,5 +1,8 @@ @page @model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader.CheckListTemplateHeaderPageModel +@using WorkFlowCheck.Common.Helper +@using WorkFlowCheck.Common.DTO + @{ ViewData["Title"] = "Ellenőrzési sablonok"; } @@ -15,16 +18,16 @@ ID - Short Name - Description + @DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.ShortName), typeof(CheckListTemplateHeaderDTO)) + @DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.Description), typeof(CheckListTemplateHeaderDTO)) Action ID - Short Name - Description + @DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.ShortName), typeof(CheckListTemplateHeaderDTO)) + @DisplayNameHelper.GetDisplayName(nameof(CheckListTemplateHeaderDTO.Description), typeof(CheckListTemplateHeaderDTO)) Action @@ -78,17 +81,7 @@ $('#tbCheckListTemplateHeadersPage').on('click', '.delete-btn', function () { const row = table.row($(this).closest('tr')).data(); - console.log(row); - showConfirmModal({ - title: 'Törlés megerősítése', - message: 'Biztosan törölni szeretnéd ezt az elemet?', - okText: 'Törlés', - cancelText: 'Mégsem' - }).then(function(result) { - if(result === 'ok') { - console.log('Törlés végrehajtva'); - } - }); + deleteEntity(table, './CheckListTemplateHeaderPage?handler=DeleteCheckListTemplateHeader', row.id); }); } diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs index 19ef305..7942c43 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using WorkFlowCheck.Web.Services; using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader @@ -21,5 +22,10 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader var results = await _checkListService.GetAllCheckListTemplateHeaderAsync(); return new JsonResult(new { data = results }); } + public async Task OnGetDeleteCheckListTemplateHeader(int id) + { + var isSuccess = await _checkListService.DeleteCheckListTemplateHeader(id); + return new JsonResult(new { result = isSuccess }); + } } } diff --git a/src/WorkFlowCheck.Web/Services/CheckListService.cs b/src/WorkFlowCheck.Web/Services/CheckListService.cs index 893cf4a..413c5a7 100644 --- a/src/WorkFlowCheck.Web/Services/CheckListService.cs +++ b/src/WorkFlowCheck.Web/Services/CheckListService.cs @@ -243,6 +243,28 @@ namespace WorkFlowCheck.Web.Services }; } } + public async Task DeleteCheckListTemplateHeader(int id) + { + string endpoint = $"{_httpClient.BaseAddress}api/CheckList/DeleteCheckListTemplateHeader/{id}"; + var retVal = false; + try + { + var response = await _httpClient.GetFromJsonAsync>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task GetCheckListTemplateRow(int id) { diff --git a/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs index aeb038f..d3a48a8 100644 --- a/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs @@ -18,7 +18,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces Task GetCheckListTemplateHeader(int id); Task> GetAllCheckListTemplateHeaderAsync(); Task> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); - + Task DeleteCheckListTemplateHeader(int id); Task GetCheckListTemplateRow(int id); Task DeleteCheckListTemplateRow(int id);