Jó kis javítás, fejlesztés TESZT-hez

This commit is contained in:
2025-03-31 19:31:22 +02:00
parent a7e913b3ee
commit 61dd5bc9a1
18 changed files with 299 additions and 88 deletions
@@ -12,13 +12,14 @@ namespace WorkFlowCheck.API.Controllers
public class SyncController : ControllerBase public class SyncController : ControllerBase
{ {
private ISyncService _syncService; private ISyncService _syncService;
public SyncController(ISyncService syncService) private INumberGeneratorService _numberGeneratorService;
public SyncController(ISyncService syncService,INumberGeneratorService numberGeneratorService)
{ {
_syncService = syncService; _syncService = syncService;
_numberGeneratorService = numberGeneratorService;
} }
[HttpGet("GetCheckPoint/{id}")] [HttpGet("GetCheckPoint/{id}")]
public async Task<ApiResponseDTO<CheckPointDTO>> GetCheckpointAsync(int id) public async Task<ApiResponseDTO<CheckPointDTO>> GetCheckpointAsync(int id)
{ {
@@ -315,7 +316,29 @@ namespace WorkFlowCheck.API.Controllers
return retVal; return retVal;
} }
[HttpGet("GetAllNumbergenerators")]
public async Task<ApiResponseDTO<List<NumberGeneratorTemplateDTO>>> GetAllNumbergeneratorsAsync()
{
var retVal = new ApiResponseDTO<List<NumberGeneratorTemplateDTO>>()
{
IsSuccess = true,
};
var locationListDTO = await _numberGeneratorService.GetAllNumbergeneratorsAsync();
if (locationListDTO != null)
{
retVal.IsSuccess = true;
retVal.Data = locationListDTO;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
} }
@@ -265,6 +265,8 @@ namespace WorkFlowCheck.BL.Services
Description = checkListTemplateHeaderDTO.Description, Description = checkListTemplateHeaderDTO.Description,
ShortName = checkListTemplateHeaderDTO.ShortName, ShortName = checkListTemplateHeaderDTO.ShortName,
IsDeleted = false, IsDeleted = false,
NumberGenerator1Id = checkListTemplateHeaderDTO.NumberGenerator1Id,
NumberGenerator2Id = checkListTemplateHeaderDTO.NumberGenerator2Id,
}; };
_dbContext.CheckListTemplateHeaders.Add(checkListTemplateHeader); _dbContext.CheckListTemplateHeaders.Add(checkListTemplateHeader);
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.BL.Services.Interfaces namespace WorkFlowCheck.BL.Services.Interfaces
{ {
@@ -11,5 +12,6 @@ namespace WorkFlowCheck.BL.Services.Interfaces
{ {
Task<string> GenerateNextNumberAsync(int templateId, IDbContextTransaction transaction, DateTime? baseDate = null); Task<string> GenerateNextNumberAsync(int templateId, IDbContextTransaction transaction, DateTime? baseDate = null);
Task<string> GetSampleAsync(int templateId, DateTime? baseDate = null); Task<string> GetSampleAsync(int templateId, DateTime? baseDate = null);
Task<List<NumberGeneratorTemplateDTO>> GetAllNumbergeneratorsAsync();
} }
} }
@@ -1,11 +1,13 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Serilog;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WorkFlowCheck.BL.Services.Interfaces; using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.DL; using WorkFlowCheck.DL;
using WorkFlowCheck.DL.Entities; using WorkFlowCheck.DL.Entities;
@@ -13,7 +15,7 @@ namespace WorkFlowCheck.BL.Services
{ {
public class NumberGeneratorService : INumberGeneratorService public class NumberGeneratorService : INumberGeneratorService
{ {
private readonly DbContext _dbContext; private readonly AppDbContext _dbContext;
private static readonly Dictionary<int, SemaphoreSlim> _templateLocks = new(); private static readonly Dictionary<int, SemaphoreSlim> _templateLocks = new();
public NumberGeneratorService(AppDbContext dbContext) public NumberGeneratorService(AppDbContext dbContext)
@@ -71,7 +73,6 @@ namespace WorkFlowCheck.BL.Services
semaphore.Release(); semaphore.Release();
} }
} }
public async Task<string> GetSampleAsync(int templateId, DateTime? baseDate = null) public async Task<string> GetSampleAsync(int templateId, DateTime? baseDate = null)
{ {
var template = await _dbContext.Set<NumberGeneratorTemplate>() var template = await _dbContext.Set<NumberGeneratorTemplate>()
@@ -87,6 +88,28 @@ namespace WorkFlowCheck.BL.Services
return BuildFormattedNumber(template, formatted, dynamicSuffix); return BuildFormattedNumber(template, formatted, dynamicSuffix);
} }
public async Task<List<NumberGeneratorTemplateDTO>> GetAllNumbergeneratorsAsync()
{
var retVal = new List<NumberGeneratorTemplateDTO>();
try
{
var numbergenerators = await _dbContext.NumberGeneratorTemplates.ToListAsync();
foreach (var numbergenerator in numbergenerators)
{
var numbergeneratortemplateDTO = new NumberGeneratorTemplateDTO();
numbergeneratortemplateDTO.Id = numbergenerator.Id;
numbergeneratortemplateDTO.ShortName = numbergenerator.ShortName;
numbergeneratortemplateDTO.Sample = await this.GetSampleAsync(numbergenerator.Id, DateTime.Now);
retVal.Add(numbergeneratortemplateDTO);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
private SemaphoreSlim GetOrCreateSemaphore(int templateId) private SemaphoreSlim GetOrCreateSemaphore(int templateId)
{ {
@@ -98,14 +121,12 @@ namespace WorkFlowCheck.BL.Services
return _templateLocks[templateId]; return _templateLocks[templateId];
} }
} }
private static (int year, int? month) GetKeyDateParts(NumberGeneratorTemplate template, DateTime date) private static (int year, int? month) GetKeyDateParts(NumberGeneratorTemplate template, DateTime date)
{ {
int year = date.Year; int year = date.Year;
int? month = template.GenerateType == GenerateType.YearAndMonth ? date.Month : null; int? month = template.GenerateType == GenerateType.YearAndMonth ? date.Month : null;
return (year, month); return (year, month);
} }
private static string BuildDynamicSuffix(NumberGeneratorTemplate template, DateTime date) private static string BuildDynamicSuffix(NumberGeneratorTemplate template, DateTime date)
{ {
return template.GenerateType switch return template.GenerateType switch
@@ -115,7 +136,6 @@ namespace WorkFlowCheck.BL.Services
_ => template.Suffix _ => template.Suffix
}; };
} }
private static string BuildFormattedNumber(NumberGeneratorTemplate template, string formattedNumber, string dynamicSuffix) private static string BuildFormattedNumber(NumberGeneratorTemplate template, string formattedNumber, string dynamicSuffix)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
@@ -7,7 +7,10 @@ namespace WorkFlowCheck.Common.DTO
public int Id { get; set; } public int Id { get; set; }
public string ShortName { get; set; } = null!; public string ShortName { get; set; } = null!;
public string Description { get; set; } = null!; public string Description { get; set; } = null!;
public int? NumberGenerator1Id { get; set; }
public required ICollection<CheckListTemplateRowDTO>? CheckListTemplateRowDTO { get; set; } = new List<CheckListTemplateRowDTO>(); public int? NumberGenerator2Id { get; set; }
public NumberGeneratorTemplateDTO? NumberGenerator1 { get; set; }
public NumberGeneratorTemplateDTO? NumberGenerator2 { get; set; }
public ICollection<CheckListTemplateRowDTO>? CheckListTemplateRowDTO { get; set; } = new List<CheckListTemplateRowDTO>();
} }
} }
@@ -8,5 +8,8 @@ namespace WorkFlowCheck.Common.DTO
{ {
public class NumberGeneratorTemplateDTO public class NumberGeneratorTemplateDTO
{ {
public int Id { get; set; }
public string ShortName { get; set; }
public string Sample { get; set; }
} }
} }
+1 -1
View File
@@ -40,7 +40,7 @@ namespace WorkFlowCheck.DL
public DbSet<Entities.Equipment> Equipments { get; set; } = null!; public DbSet<Entities.Equipment> Equipments { get; set; } = null!;
public DbSet<Entities.Location> Locations { get; set; } = null!; public DbSet<Entities.Location> Locations { get; set; } = null!;
public DbSet<Entities.NumberGeneratorTemplate> NumberGeneratorTemplates { get; set; } = null!; public DbSet<Entities.NumberGeneratorTemplate> NumberGeneratorTemplates { get; set; } = null!;
public DbSet<Entities.NumberGeneratorTemplateDate> NumberGeneratorTemplateDatess { get; set; } = null!; public DbSet<Entities.NumberGeneratorTemplateDate> NumberGeneratorTemplateDates { get; set; } = null!;
public DbSet<Entities.Role> Roles { get; set; } = null!; public DbSet<Entities.Role> Roles { get; set; } = null!;
public DbSet<Entities.User> Users { get; set; } = null!; public DbSet<Entities.User> Users { get; set; } = null!;
public DbSet<Entities.UserRole> UserRoles { get; set; } = null!; public DbSet<Entities.UserRole> UserRoles { get; set; } = null!;
@@ -4,7 +4,7 @@
@inject IAntiforgery Antiforgery @inject IAntiforgery Antiforgery
@{ @{
ViewData["Title"] = "Ellenőrzési pont"; ViewData["Title"] = "Ellenőrzési pont";
var checkpointId = Model.CheckPoint.Id; var checkpointId = Model.CheckPointDTO.Id;
var url = Url.Page("./CheckPointEditPage", "LoadCheckListTemplateRows", new { id = checkpointId }); var url = Url.Page("./CheckPointEditPage", "LoadCheckListTemplateRows", new { id = checkpointId });
var urlPost = Url.Page("./CheckPointEditPage", "Save"); var urlPost = Url.Page("./CheckPointEditPage", "Save");
} }
@@ -16,21 +16,21 @@
<div class="card shadow p-4"> <div class="card shadow p-4">
<form method="post" id="checkPointForm"> <form method="post" id="checkPointForm">
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" /> <meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
<input type="hidden" asp-for="CheckPoint.Id" /> <input type="hidden" asp-for="CheckPointDTO.Id" />
<div class="mb-3"> <div class="mb-3">
<label asp-for="CheckPoint.ShortName"></label> <label asp-for="CheckPointDTO.ShortName"></label>
<input asp-for="CheckPoint.ShortName" class="form-control" /> <input asp-for="CheckPointDTO.ShortName" class="form-control" />
<span asp-validation-for="CheckPoint.ShortName" class="text-danger"></span> <span asp-validation-for="CheckPointDTO.ShortName" class="text-danger"></span>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label asp-for="CheckPoint.Code"></label> <label asp-for="CheckPointDTO.Code"></label>
<input asp-for="CheckPoint.Code" class="form-control" /> <input asp-for="CheckPointDTO.Code" class="form-control" />
<span asp-validation-for="CheckPoint.Code" class="text-danger"></span> <span asp-validation-for="CheckPointDTO.Code" class="text-danger"></span>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label asp-for="CheckPoint.IsEnabled"></label> <label asp-for="CheckPointDTO.IsEnabled"></label>
<input type="checkbox" asp-for="CheckPoint.IsEnabled" class="form-check-input" /> <input type="checkbox" asp-for="CheckPointDTO.IsEnabled" class="form-check-input" />
<span asp-validation-for="CheckPoint.IsEnabled" class="text-danger"></span> <span asp-validation-for="CheckPointDTO.IsEnabled" class="text-danger"></span>
</div> </div>
<div class="mb-3"> <div class="mb-3">
<button type="button" id="saveCheckPoint" class="btn btn-primary">Mentés</button> <button type="button" id="saveCheckPoint" class="btn btn-primary">Mentés</button>
@@ -66,27 +66,7 @@
</tfoot> </tfoot>
</table> </table>
</div> </div>
<style>
.box {
display: inline-block;
width: 25px;
height: 25px;
margin: 1px;
text-align: center;
line-height: 25px;
font-size: 15px;
border: 1px solid black;
border-radius: 3px;
}
.yellow-box {
background-color: yellow;
}
.red-box {
background-color: red;
}
</style>
@section Scripts { @section Scripts {
<script> <script>
@@ -101,28 +81,12 @@
{ data: "rowIndex" }, { data: "rowIndex" },
{ data: "operationDescription" }, { data: "operationDescription" },
{ {
data: "answerType", data: "answerType",
searchable: false, searchable: false,
sortable: false, sortable: false,
render: function ( data, type, row ) { render: function ( data, type, row ) {
if (data === 'SI-N') { return renderAnswerType(data);
return '<div class="text-center"><div class="box yellow-box">I</div><div class="box">N</div></div>'; }
}
if (data === 'I-SN') {
return '<div class="text-center"><div class="box">I</div><div class="box yellow-box">N</div></div>';
}
if (data === 'PI-N') {
return '<div class="text-center"><div class="box red-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-PN') {
return '<div class="text-center"><div class="box">I</div><div class="box red-box">N</div></div>';
}
if (data==='P'){
return '<div class="text-center"><i class="fas fa-camera fa-2x"></i></div>';
}
return data;
}
}, },
{ data: null, render: function (data, type, row) { { data: null, render: function (data, type, row) {
return renderActionButtons(row.id); return renderActionButtons(row.id);
@@ -169,6 +133,9 @@
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
var formData = getFormAsNestedObject('#checkPointForm'); var formData = getFormAsNestedObject('#checkPointForm');
formData.CheckPointDTO.CheckListTemplateRowDTO = [];
formData.CheckPointDTO.IsEnabled = $('#CheckPointDTO_IsEnabled').is(':checked');
$.ajax({ $.ajax({
url: $('#checkPointEditPostUrl').val(), url: $('#checkPointEditPostUrl').val(),
type: 'POST', type: 'POST',
@@ -176,13 +143,24 @@
'X-CSRF-TOKEN': csrfToken, 'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
data: JSON.stringify(formData.CheckPoint), data: JSON.stringify(formData.CheckPointDTO),
success: function (response) { success: function (response) {
showMessageModal({ if (response.success)
title: 'Figyelmem!', {
message: 'Sikeres mentés.', showMessageModal({
okText: 'Értettem' title: 'Figyelmem!',
}); message: 'Sikeres mentés.',
okText: 'Értettem'
});
}
else
{
showMessageModal({
title: 'Figyelmem, HIBA!',
message: 'Sikertelen mentés.',
okText: 'Értettem'
});
}
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
// Hiba esetén // Hiba esetén
@@ -15,7 +15,7 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
private readonly IBaseStockService _baseStockService; private readonly IBaseStockService _baseStockService;
[BindProperty] [BindProperty]
public CheckPointDTO CheckPoint { get; set; } public CheckPointDTO CheckPointDTO { get; set; }
public CheckPointEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService) public CheckPointEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
{ {
@@ -24,13 +24,13 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
} }
public async Task OnGet(int id) public async Task OnGet(int id)
{ {
CheckPoint = await _baseStockService.GetCheckPoint(id); CheckPointDTO = await _baseStockService.GetCheckPoint(id);
} }
public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id) public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id)
{ {
CheckPoint = await _baseStockService.GetCheckPoint(id); CheckPointDTO = await _baseStockService.GetCheckPoint(id);
return new JsonResult(new { data = CheckPoint.CheckListTemplateRowDTO }); return new JsonResult(new { data = CheckPointDTO.CheckListTemplateRowDTO });
} }
public async Task<IActionResult> OnPostSave([FromBody] CheckPointDTO checkPointDTO) public async Task<IActionResult> OnPostSave([FromBody] CheckPointDTO checkPointDTO)
@@ -9,7 +9,7 @@
<div class="card shadow p-4"> <div class="card shadow p-4">
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<button class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása"> <button id="newCheckPointBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása">
<i class="bi bi-plus-square"></i> <i class="bi bi-plus-square"></i>
</button> </button>
</div> </div>
@@ -76,6 +76,12 @@
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',} language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
}); });
$('#newCheckPointBtn').on('click', function ()
{
console.log('New button clicked!"');
window.location.href = `@Url.Page("./CheckPointEditPage")?id=0`;
});
$('#tbCheckPointsPage').on('click', '.edit-btn', function () $('#tbCheckPointsPage').on('click', '.edit-btn', function ()
{ {
const row = table.row($(this).closest('tr')).data(); const row = table.row($(this).closest('tr')).data();
@@ -22,6 +22,23 @@
<input asp-for="CheckListTemplateHeaderDTO.ShortName" class="form-control" /> <input asp-for="CheckListTemplateHeaderDTO.ShortName" class="form-control" />
<span asp-validation-for="CheckListTemplateHeaderDTO.ShortName" class="text-danger"></span> <span asp-validation-for="CheckListTemplateHeaderDTO.ShortName" class="text-danger"></span>
</div> </div>
<div class="mb-3">
<label asp-for="CheckListTemplateHeaderDTO.Description" class="form-label"></label>
<textarea asp-for="CheckListTemplateHeaderDTO.Description" class="form-control" rows="3"></textarea>
<span asp-validation-for="CheckListTemplateHeaderDTO.Description" class="text-danger"></span>
</div>
<div class="mb-3 row">
<div class="col-md-6">
<label asp-for="CheckListTemplateHeaderDTO.NumberGenerator1Id"></label>
<select asp-for="CheckListTemplateHeaderDTO.NumberGenerator1Id" class="form-control" asp-items="Model.Numbergenerators"></select>
<span asp-validation-for="CheckListTemplateHeaderDTO.NumberGenerator1Id" class="text-danger"></span>
</div>
<div class="col-md-6">
<label asp-for="CheckListTemplateHeaderDTO.NumberGenerator2Id"></label>
<select asp-for="CheckListTemplateHeaderDTO.NumberGenerator2Id" class="form-control" asp-items="Model.Numbergenerators"></select>
<span asp-validation-for="CheckListTemplateHeaderDTO.NumberGenerator2" class="text-danger"></span>
</div>
</div>
<div class="mb-3 d-flex justify-content-between"> <div class="mb-3 d-flex justify-content-between">
<button type="button" id="saveCheckListTemplateHeader" class="btn btn-primary">Mentés</button> <button type="button" id="saveCheckListTemplateHeader" class="btn btn-primary">Mentés</button>
<button type="button" class="btn btn-secondary" onclick="history.back()">Mégsem</button> <button type="button" class="btn btn-secondary" onclick="history.back()">Mégsem</button>
@@ -71,7 +88,14 @@
{ data: "rowIndex" }, { data: "rowIndex" },
{ data: "checkPointDTO.shortName" }, { data: "checkPointDTO.shortName" },
{ data: "operationDescription" }, { data: "operationDescription" },
{ data: "answerType" }, {
data: "answerType",
searchable: false,
sortable: false,
render: function ( data, type, row ) {
return renderAnswerType(data);
}
},
{ data: null, render: function (data, type, row) { { data: null, render: function (data, type, row) {
return renderActionButtons(row.id); return renderActionButtons(row.id);
}} }}
@@ -125,7 +149,9 @@
var formData = getFormAsNestedObject('#CheckListTemplateHeaderForm'); var formData = getFormAsNestedObject('#CheckListTemplateHeaderForm');
const $form = $('#CheckListTemplateHeaderForm'); const $form = $('#CheckListTemplateHeaderForm');
formData.CheckListTemplateHeader.RoleDTO=[]; formData.CheckListTemplateHeaderDTO.CheckListTemplateRowDTO=[];
console.log(formData.CheckListTemplateHeaderDTO);
if ($form.valid()) if ($form.valid())
{ {
@@ -136,13 +162,24 @@
'X-CSRF-TOKEN': csrfToken, 'X-CSRF-TOKEN': csrfToken,
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
data: JSON.stringify(formData.CheckListTemplateHeader), data: JSON.stringify(formData.CheckListTemplateHeaderDTO),
success: function (response) { success: function (response) {
showMessageModal({ if (response.success)
title: 'Figyelmem!', {
message: 'Sikeres mentés.', showMessageModal({
okText: 'Értettem' title: 'Figyelmem!',
}); message: 'Sikeres mentés.',
okText: 'Értettem'
});
}
else
{
showMessageModal({
title: 'Figyelmem, HIBA!',
message: 'Sikertelen mentés.',
okText: 'Értettem'
});
}
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
// Hiba esetén // Hiba esetén
@@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Serilog;
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services;
using WorkFlowCheck.Web.Services.Interfaces; using WorkFlowCheck.Web.Services.Interfaces;
namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
@@ -9,18 +12,23 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
{ {
private readonly ILogger<IndexModel> _logger; private readonly ILogger<IndexModel> _logger;
private readonly ICheckListService _checkListService; private readonly ICheckListService _checkListService;
private readonly IBaseStockService _baseStockService;
[BindProperty] [BindProperty]
public CheckListTemplateHeaderDTO CheckListTemplateHeaderDTO { get; set; } public CheckListTemplateHeaderDTO CheckListTemplateHeaderDTO { get; set; }
[BindProperty]
public List<SelectListItem> Numbergenerators { get; set; }
public CheckListTemplateHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService) public CheckListTemplateHeaderEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService, IBaseStockService baseStockService)
{ {
_logger = logger; _logger = logger;
_checkListService = checkListService; _checkListService = checkListService;
_baseStockService = baseStockService;
} }
public async Task OnGet(int id) public async Task OnGet(int id)
{ {
await InitSelectItems();
CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id); CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id);
} }
public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id) public async Task<JsonResult> OnGetLoadCheckListTemplateRows(int id)
@@ -28,5 +36,40 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader
CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id); CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id);
return new JsonResult(new { data = CheckListTemplateHeaderDTO.CheckListTemplateRowDTO }); return new JsonResult(new { data = CheckListTemplateHeaderDTO.CheckListTemplateRowDTO });
} }
public async Task<IActionResult> OnPostSave([FromBody] CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
{
try
{
var result = await _checkListService.UpdateCheckListTemplateHeader(checkListTemplateHeaderDTO);
if (result.IsSuccess)
{
return new JsonResult(new { success = true });
}
else
{
return new JsonResult(new { success = false });
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return new JsonResult(new { success = false });
}
private async Task InitSelectItems()
{
var numbergenerators = await _baseStockService.GetNumbergenerators();
this.Numbergenerators = new List<SelectListItem>();
foreach (var numbergenerator in numbergenerators)
{
this.Numbergenerators.Add(new SelectListItem()
{
Value = numbergenerator.Id.ToString(),
Text = $"{numbergenerator.ShortName} -> [{numbergenerator.Sample}]"
});
}
}
} }
} }
@@ -64,7 +64,7 @@
}, },
data: JSON.stringify(formData.RoleCheckPointDTO), data: JSON.stringify(formData.RoleCheckPointDTO),
success: function (response) { success: function (response) {
// console.log(response);
if (response.success) if (response.success)
{ {
showMessageModal({ showMessageModal({
@@ -1,4 +1,5 @@
using Newtonsoft.Json; using Microsoft.AspNetCore.Mvc.Rendering;
using Newtonsoft.Json;
using Serilog; using Serilog;
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces; using WorkFlowCheck.Web.Services.Interfaces;
@@ -229,5 +230,27 @@ namespace WorkFlowCheck.Web.Services
} }
} }
public async Task<List<NumberGeneratorTemplateDTO>> GetNumbergenerators()
{
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllNumbergenerators";
var retVal = new List<NumberGeneratorTemplateDTO>();
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<List<NumberGeneratorTemplateDTO>>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
return response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
} }
} }
@@ -103,7 +103,34 @@ namespace WorkFlowCheck.Web.Services
} }
return retVal; return retVal;
} }
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO) => throw new NotImplementedException(); public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
{
try
{
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/UpdateCheckListTemplateHeader";
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, checkListTemplateHeaderDTO))
{
httpResponseMessage.EnsureSuccessStatusCode();
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
var response = JsonConvert.DeserializeObject<ApiResponseDTO<CheckListTemplateHeaderDTO>>(jsonString);
return response ?? new ApiResponseDTO<CheckListTemplateHeaderDTO>
{
IsSuccess = false,
};
}
}
catch (Exception ex)
{
// Hiba visszaadása
return new ApiResponseDTO<CheckListTemplateHeaderDTO>
{
IsSuccess = false
};
}
}
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id) public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
{ {
@@ -1,4 +1,5 @@
using WorkFlowCheck.Common.DTO; using Microsoft.AspNetCore.Mvc.Rendering;
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.Web.Services.Interfaces namespace WorkFlowCheck.Web.Services.Interfaces
{ {
@@ -17,5 +18,7 @@ namespace WorkFlowCheck.Web.Services.Interfaces
Task<LocationDTO> GetLocation(int id); Task<LocationDTO> GetLocation(int id);
Task<List<LocationDTO>> GetAllLocations(); Task<List<LocationDTO>> GetAllLocations();
Task<ApiResponseDTO<LocationDTO>> UpdateLocation(LocationDTO LocationDTO); Task<ApiResponseDTO<LocationDTO>> UpdateLocation(LocationDTO LocationDTO);
Task<List<NumberGeneratorTemplateDTO>> GetNumbergenerators();
} }
} }
@@ -24,3 +24,23 @@ body {
.no-click { .no-click {
pointer-events: none; pointer-events: none;
} }
.box {
display: inline-block;
width: 25px;
height: 25px;
margin: 1px;
text-align: center;
line-height: 25px;
font-size: 15px;
border: 1px solid black;
border-radius: 3px;
}
.yellow-box {
background-color: yellow;
}
.red-box {
background-color: red;
}
+21
View File
@@ -171,3 +171,24 @@ function renderCheckBox(data) {
} }
return data; return data;
} }
function renderAnswerType(data) {
if (data === 'SI-N') {
return '<div class="text-center"><div class="box yellow-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-SN') {
return '<div class="text-center"><div class="box">I</div><div class="box yellow-box">N</div></div>';
}
if (data === 'PI-N') {
return '<div class="text-center"><div class="box red-box">I</div><div class="box">N</div></div>';
}
if (data === 'I-PN') {
return '<div class="text-center"><div class="box">I</div><div class="box red-box">N</div></div>';
}
if (data === 'P') {
return '<div class="text-center"><i class="fas fa-camera fa-2x"></i></div>';
}
if (data === 'V') {
return '<div class="text-center"><span class="border border-dark rounded p-1">0,00</span></div>';
}
return data;
}