Most működik az üzenetküldés Backenden

This commit is contained in:
2025-04-07 17:05:27 +02:00
parent a3be387ee1
commit 85976547f6
13 changed files with 1056 additions and 70 deletions
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using Serilog; using Serilog;
using System.Text; using System.Text;
using WorkFlowCheck.BL.Services; using WorkFlowCheck.BL.Services;
@@ -442,7 +443,7 @@ namespace WorkFlowCheck.API.Controllers
IsSuccess = true, IsSuccess = true,
}; };
byte[] byteArray = Convert.FromBase64String(deviceIdBase64); byte[] byteArray = Base64UrlEncoder.DecodeBytes(deviceIdBase64);
string deviceId = Encoding.UTF8.GetString(byteArray); string deviceId = Encoding.UTF8.GetString(byteArray);
@@ -154,10 +154,10 @@ namespace WorkFlowCheck.API.Controllers
} }
try try
{ {
var userDTO_Response = await _userService.Authenticate(userSimpleDTO.UserName, userSimpleDTO.Password); var userDTO_Response = await _userService.AuthenticateNFC(userSimpleDTO.UserName);
if (userDTO_Response != null) if (userDTO_Response != null)
{ {
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false && userDTO_Response.UserName == userSimpleDTO.UserName) if (string.IsNullOrEmpty(userDTO_Response.UserName) == false && userDTO_Response.NFCActive)
{ {
retVal.IsSuccess = true; retVal.IsSuccess = true;
retVal.Data = userDTO_Response; retVal.Data = userDTO_Response;
+10 -2
View File
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using AutoMapper.Configuration.Conventions; using AutoMapper.Configuration.Conventions;
using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.DL.Entities; using WorkFlowCheck.DL.Entities;
@@ -35,7 +36,14 @@ namespace WorkFlowCheck.BL.Mappings
.ForMember(dest => dest.EquipmentDTO, opt => opt.MapFrom(src => src.Equipment)) .ForMember(dest => dest.EquipmentDTO, opt => opt.MapFrom(src => src.Equipment))
.ForMember(dest => dest.CheckPointDTO, opt => opt.MapFrom(src => src.CheckPoint)); .ForMember(dest => dest.CheckPointDTO, opt => opt.MapFrom(src => src.CheckPoint));
CreateMap<CheckPoint, CheckPointDTO>().ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows)); CreateMap<CheckPoint, CheckPointDTO>()
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
CreateMap<CheckPoint, CheckPointDTO>()
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
CreateMap<CheckPointDTO, CheckPoint>(); CreateMap<CheckPointDTO, CheckPoint>();
@@ -45,7 +53,7 @@ namespace WorkFlowCheck.BL.Mappings
CreateMap<Equipment, EquipmentDTO>(); CreateMap<Equipment, EquipmentDTO>();
CreateMap<EquipmentDTO, Equipment>(); CreateMap<EquipmentDTO, Equipment>();
CreateMap<DeviceMessage, DeviceMessageDTO>(); CreateMap<DeviceMessage, DeviceMessageDTO>();
CreateMap<DeviceMessageDTO, DeviceMessage>(); CreateMap<DeviceMessageDTO, DeviceMessage>();
CreateMap<CheckListHeader, CheckListHeaderDTO>() CreateMap<CheckListHeader, CheckListHeaderDTO>()
+8 -7
View File
@@ -45,14 +45,17 @@ namespace WorkFlowCheck.BL.Services
try try
{ {
var res = await _dbContext.CheckPoints var checkpoint = await _dbContext.CheckPoints
.Include(i => i.CheckListTemplateRows) .Include(i => i.CheckListTemplateRows)
.Where(w => w.Id == id) .Where(w => w.Id == id)
.AsNoTracking() .AsNoTracking()
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
if (res != null) if (checkpoint != null)
{ {
retVal = _mapper.Map<CheckPointDTO>(res); retVal = _mapper.Map<CheckPointDTO>(checkpoint);
var role = await _dbContext.Roles.Where(w => w.Id == retVal.RoleId).FirstOrDefaultAsync();
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -332,10 +335,8 @@ namespace WorkFlowCheck.BL.Services
{ {
var res = await _dbContext.CheckListHeaders var res = await _dbContext.CheckListHeaders
.Where(w => w.IsEditable && .Where(w => w.IsEditable &&
w.UserId == userId && w.IsDeleted != true
w.IsDeleted != true && )
(w.CheckStatus == CheckStatus.InProgress ||
w.CheckStatus == CheckStatus.Open))
.Include(i => i.CheckListRows) .Include(i => i.CheckListRows)
//.ThenInclude(i => i.CheckListTemplateRow) //.ThenInclude(i => i.CheckListTemplateRow)
.AsNoTracking() .AsNoTracking()
@@ -7,6 +7,8 @@ namespace WorkFlowCheck.Common.DTO
public string ShortName { get; set; } public string ShortName { get; set; }
public string Code { get; set; } public string Code { get; set; }
public bool IsEnabled { get; set; } public bool IsEnabled { get; set; }
public int? RoleId { get; set; }
public string? RoleName { get; set; }
public List<CheckListTemplateRowDTO>? CheckListTemplateRowDTO { get; set; } = new List<CheckListTemplateRowDTO>(); public List<CheckListTemplateRowDTO>? CheckListTemplateRowDTO { get; set; } = new List<CheckListTemplateRowDTO>();
} }
} }
@@ -18,6 +18,8 @@ namespace WorkFlowCheck.DL.Entities
public string LastModBy { get; set; } = null!; public string LastModBy { get; set; } = null!;
public DateTime CreatedAt { get; set; } public DateTime CreatedAt { get; set; }
public string CreatedBy { get; set; } = null!; public string CreatedBy { get; set; } = null!;
public int RoleId { get; set; }
public virtual ICollection<CheckListTemplateRow> CheckListTemplateRows { get; set; } = new List<CheckListTemplateRow>(); public virtual ICollection<CheckListTemplateRow> CheckListTemplateRows { get; set; } = new List<CheckListTemplateRow>();
@@ -0,0 +1,931 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WorkFlowCheck.DL;
#nullable disable
namespace WorkFlowCheck.DL.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20250406192452_Extend016")]
partial class Extend016
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CheckListTemplateHeaderId")
.HasColumnType("int");
b.Property<int>("CheckStatus")
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateExecution")
.HasColumnType("datetime2");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("DocumentNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<Guid>("GuidNumber")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsEditable")
.HasColumnType("bit");
b.Property<bool>("IsStorno")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CheckListTemplateHeaderId");
b.HasIndex("UserId");
b.ToTable("CheckListHeader", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListRow", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Answer")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("CheckListHeaderId")
.HasColumnType("int");
b.Property<int>("CheckListTemplateRowId")
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<Guid>("GuidNumber")
.HasColumnType("uniqueidentifier");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhotoFileName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("CheckListHeaderId");
b.HasIndex("CheckListTemplateRowId");
b.ToTable("CheckListRow", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("NumberGenerator1Id")
.HasColumnType("int");
b.Property<int?>("NumberGenerator2Id")
.HasColumnType("int");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("NumberGenerator1Id");
b.HasIndex("NumberGenerator2Id");
b.ToTable("CheckListTemplateHeader", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateRow", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AnswerType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("CheckListTemplateHeaderId")
.HasColumnType("int");
b.Property<int>("CheckPointId")
.HasColumnType("int");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("EquipmentId")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OperationDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("RowIndex")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CheckListTemplateHeaderId");
b.HasIndex("CheckPointId");
b.HasIndex("EquipmentId");
b.ToTable("CheckListTemplateRow", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckPoint", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Code")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsEnabled")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("RoleId")
.HasColumnType("int");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("CheckPoint", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.DeviceMessage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DeviceIdFrom")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("DeviceIdTo")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("ExtraDataJSON")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsReaded")
.HasColumnType("bit");
b.Property<string>("Message")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("ReceiveDate")
.HasColumnType("datetime2");
b.Property<DateTime>("SendDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DeviceIdTo")
.HasDatabaseName("IX_DeviceMessage_DeviceIdTo");
b.ToTable("DeviceMessage", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.Equipment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("EquipmentNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Equipment", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.Location", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FullName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Location", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.NumberGeneratorTemplate", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrentNumber")
.HasColumnType("int");
b.Property<string>("DigitFormat")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("GenerateType")
.HasColumnType("int");
b.Property<string>("LastGeneratedNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Prefix")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PrefixSeparator")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ShortName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Suffix")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("SuffixSeparator")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("NumberGeneratorTemplate", (string)null);
b.HasData(
new
{
Id = 1,
CurrentNumber = 0,
DigitFormat = "D4",
GenerateType = 0,
LastGeneratedNumber = "",
Prefix = "CHK",
PrefixSeparator = "-",
ShortName = "Ellenőrzési dokumentum sorszámozása",
Suffix = "",
SuffixSeparator = "-"
});
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.NumberGeneratorTemplateDate", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrentNumber")
.HasColumnType("int");
b.Property<string>("LastGeneratedNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("Month")
.HasColumnType("int");
b.Property<int>("NumberGeneratorTemplateId")
.HasColumnType("int");
b.Property<int>("Year")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("NumberGeneratorTemplateId");
b.ToTable("NumberGeneratorTemplateDate", (string)null);
b.HasData(
new
{
Id = 1,
CurrentNumber = 0,
LastGeneratedNumber = "",
Month = 0,
NumberGeneratorTemplateId = 1,
Year = 1
});
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("CanDownloadAPK")
.HasColumnType("bit");
b.Property<bool>("CanEnableBlocked")
.HasColumnType("bit");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsAdmin")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ParentId")
.HasColumnType("int");
b.Property<string>("RoleName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ParentId");
b.ToTable("Roles", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.RoleCheckListTemplateHeader", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CheckListTemplateHeaderId")
.HasColumnType("int");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CheckListTemplateHeaderId");
b.HasIndex("RoleId");
b.ToTable("RoleCheckListTemplateHeader", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.RoleCheckPoint", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CheckPointId")
.HasColumnType("int");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CheckPointId");
b.HasIndex("RoleId");
b.ToTable("RoleCheckPoint", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<bool>("Active")
.HasColumnType("bit");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("JwtToken")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("LastModAt")
.HasColumnType("datetime2");
b.Property<string>("LastModBy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("NFCActive")
.HasColumnType("bit");
b.Property<string>("NFCCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("Token2FA")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users", (string)null);
b.HasData(
new
{
Id = 1,
Active = true,
CreatedAt = new DateTime(2025, 4, 6, 19, 24, 51, 944, DateTimeKind.Utc).AddTicks(2145),
CreatedBy = "System",
Email = "admin@nuvolar.hu",
FirstName = "Administrator",
IsDeleted = false,
JwtToken = "",
LastModAt = new DateTime(2025, 4, 6, 19, 24, 51, 944, DateTimeKind.Utc).AddTicks(2148),
LastModBy = "System",
LastName = "System",
NFCActive = true,
NFCCode = "00000000",
PasswordHash = "eGM0NUREZnJ0ISFFRDIxMKE5TYwthDBuUsTUEO1fBnCR3VdSCmdz47ue0RoVvnkY",
Token2FA = "",
UserName = "admin"
},
new
{
Id = 2,
Active = true,
CreatedAt = new DateTime(2025, 4, 6, 19, 24, 51, 956, DateTimeKind.Utc).AddTicks(5191),
CreatedBy = "System",
Email = "user@nuvolar.hu",
FirstName = "User",
IsDeleted = false,
JwtToken = "",
LastModAt = new DateTime(2025, 4, 6, 19, 24, 51, 956, DateTimeKind.Utc).AddTicks(5194),
LastModBy = "System",
LastName = "System",
NFCActive = true,
NFCCode = "00000000",
PasswordHash = "eGM0NUREZnJ0ISFFRDIxMPwM2D9sQSj7zmaSBIsOGe0I9hBFwCGPVbyrYMA5EnKG",
Token2FA = "",
UserName = "user"
});
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.UserRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("RoleId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.HasIndex("UserId");
b.ToTable("UserRoles", (string)null);
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader")
.WithMany()
.HasForeignKey("CheckListTemplateHeaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WorkFlowCheck.DL.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CheckListTemplateHeader");
b.Navigation("User");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListRow", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.CheckListHeader", "CheckListHeader")
.WithMany("CheckListRows")
.HasForeignKey("CheckListHeaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateRow", "CheckListTemplateRow")
.WithMany()
.HasForeignKey("CheckListTemplateRowId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CheckListHeader");
b.Navigation("CheckListTemplateRow");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.NumberGeneratorTemplate", "NumberGenerator1")
.WithMany()
.HasForeignKey("NumberGenerator1Id");
b.HasOne("WorkFlowCheck.DL.Entities.NumberGeneratorTemplate", "NumberGenerator2")
.WithMany()
.HasForeignKey("NumberGenerator2Id");
b.Navigation("NumberGenerator1");
b.Navigation("NumberGenerator2");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateRow", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader")
.WithMany("CheckListTemplateRows")
.HasForeignKey("CheckListTemplateHeaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WorkFlowCheck.DL.Entities.CheckPoint", "CheckPoint")
.WithMany("CheckListTemplateRows")
.HasForeignKey("CheckPointId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WorkFlowCheck.DL.Entities.Equipment", "Equipment")
.WithMany()
.HasForeignKey("EquipmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CheckListTemplateHeader");
b.Navigation("CheckPoint");
b.Navigation("Equipment");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.NumberGeneratorTemplateDate", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.NumberGeneratorTemplate", "NumberGeneratorTemplate")
.WithMany("NumberGeneratorTemplateDates")
.HasForeignKey("NumberGeneratorTemplateId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("NumberGeneratorTemplate");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.Role", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.Role", "Parent")
.WithMany("Children")
.HasForeignKey("ParentId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Parent");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.RoleCheckListTemplateHeader", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", "CheckListTemplateHeader")
.WithMany()
.HasForeignKey("CheckListTemplateHeaderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WorkFlowCheck.DL.Entities.Role", "Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CheckListTemplateHeader");
b.Navigation("Role");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.RoleCheckPoint", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.CheckPoint", "CheckPoint")
.WithMany()
.HasForeignKey("CheckPointId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("WorkFlowCheck.DL.Entities.Role", "Role")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CheckPoint");
b.Navigation("Role");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.UserRole", b =>
{
b.HasOne("WorkFlowCheck.DL.Entities.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId");
b.HasOne("WorkFlowCheck.DL.Entities.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListHeader", b =>
{
b.Navigation("CheckListRows");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckListTemplateHeader", b =>
{
b.Navigation("CheckListTemplateRows");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.CheckPoint", b =>
{
b.Navigation("CheckListTemplateRows");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.NumberGeneratorTemplate", b =>
{
b.Navigation("NumberGeneratorTemplateDates");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.Role", b =>
{
b.Navigation("Children");
b.Navigation("UserRoles");
});
modelBuilder.Entity("WorkFlowCheck.DL.Entities.User", b =>
{
b.Navigation("UserRoles");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WorkFlowCheck.DL.Migrations
{
/// <inheritdoc />
public partial class Extend016 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "RoleId",
table: "CheckPoint",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "Users",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "CreatedAt", "LastModAt" },
values: new object[] { new DateTime(2025, 4, 6, 19, 24, 51, 944, DateTimeKind.Utc).AddTicks(2145), new DateTime(2025, 4, 6, 19, 24, 51, 944, DateTimeKind.Utc).AddTicks(2148) });
migrationBuilder.UpdateData(
table: "Users",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "CreatedAt", "LastModAt" },
values: new object[] { new DateTime(2025, 4, 6, 19, 24, 51, 956, DateTimeKind.Utc).AddTicks(5191), new DateTime(2025, 4, 6, 19, 24, 51, 956, DateTimeKind.Utc).AddTicks(5194) });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RoleId",
table: "CheckPoint");
migrationBuilder.UpdateData(
table: "Users",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "CreatedAt", "LastModAt" },
values: new object[] { new DateTime(2025, 4, 6, 11, 24, 45, 650, DateTimeKind.Utc).AddTicks(7691), new DateTime(2025, 4, 6, 11, 24, 45, 650, DateTimeKind.Utc).AddTicks(7694) });
migrationBuilder.UpdateData(
table: "Users",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "CreatedAt", "LastModAt" },
values: new object[] { new DateTime(2025, 4, 6, 11, 24, 45, 661, DateTimeKind.Utc).AddTicks(5371), new DateTime(2025, 4, 6, 11, 24, 45, 661, DateTimeKind.Utc).AddTicks(5373) });
}
}
}
@@ -276,6 +276,9 @@ namespace WorkFlowCheck.DL.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("RoleId")
.HasColumnType("int");
b.Property<string>("ShortName") b.Property<string>("ShortName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@@ -673,13 +676,13 @@ namespace WorkFlowCheck.DL.Migrations
{ {
Id = 1, Id = 1,
Active = true, Active = true,
CreatedAt = new DateTime(2025, 4, 6, 11, 24, 45, 650, DateTimeKind.Utc).AddTicks(7691), CreatedAt = new DateTime(2025, 4, 6, 19, 24, 51, 944, DateTimeKind.Utc).AddTicks(2145),
CreatedBy = "System", CreatedBy = "System",
Email = "admin@nuvolar.hu", Email = "admin@nuvolar.hu",
FirstName = "Administrator", FirstName = "Administrator",
IsDeleted = false, IsDeleted = false,
JwtToken = "", JwtToken = "",
LastModAt = new DateTime(2025, 4, 6, 11, 24, 45, 650, DateTimeKind.Utc).AddTicks(7694), LastModAt = new DateTime(2025, 4, 6, 19, 24, 51, 944, DateTimeKind.Utc).AddTicks(2148),
LastModBy = "System", LastModBy = "System",
LastName = "System", LastName = "System",
NFCActive = true, NFCActive = true,
@@ -692,13 +695,13 @@ namespace WorkFlowCheck.DL.Migrations
{ {
Id = 2, Id = 2,
Active = true, Active = true,
CreatedAt = new DateTime(2025, 4, 6, 11, 24, 45, 661, DateTimeKind.Utc).AddTicks(5371), CreatedAt = new DateTime(2025, 4, 6, 19, 24, 51, 956, DateTimeKind.Utc).AddTicks(5191),
CreatedBy = "System", CreatedBy = "System",
Email = "user@nuvolar.hu", Email = "user@nuvolar.hu",
FirstName = "User", FirstName = "User",
IsDeleted = false, IsDeleted = false,
JwtToken = "", JwtToken = "",
LastModAt = new DateTime(2025, 4, 6, 11, 24, 45, 661, DateTimeKind.Utc).AddTicks(5373), LastModAt = new DateTime(2025, 4, 6, 19, 24, 51, 956, DateTimeKind.Utc).AddTicks(5194),
LastModBy = "System", LastModBy = "System",
LastName = "System", LastName = "System",
NFCActive = true, NFCActive = true,
@@ -27,6 +27,11 @@
<input asp-for="CheckPointDTO.Code" class="form-control" /> <input asp-for="CheckPointDTO.Code" class="form-control" />
<span asp-validation-for="CheckPointDTO.Code" class="text-danger"></span> <span asp-validation-for="CheckPointDTO.Code" class="text-danger"></span>
</div> </div>
<div class="col-md-3">
<label asp-for="CheckPointDTO.RoleId"></label>
<select asp-for="CheckPointDTO.RoleId" class="form-control" asp-items="Model.Roles"></select>
<span asp-validation-for="CheckPointDTO.RoleId" class="text-danger"></span>
</div>
<div class="col-md-3"> <div class="col-md-3">
<label asp-for="CheckPointDTO.IsEnabled"></label> <label asp-for="CheckPointDTO.IsEnabled"></label>
<input type="checkbox" asp-for="CheckPointDTO.IsEnabled" class="form-check-input" /> <input type="checkbox" asp-for="CheckPointDTO.IsEnabled" class="form-check-input" />
@@ -117,16 +122,7 @@
$('#tbCheckPointsEditPage').on('click', '.delete-btn', function () $('#tbCheckPointsEditPage').on('click', '.delete-btn', function ()
{ {
const row = table.row($(this).closest('tr')).data(); const row = table.row($(this).closest('tr')).data();
showConfirmModal({ deleteEntity(table, '/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage?handler=DeleteCheckPoint', row.id);
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');
}
});
}); });
$("#saveCheckPoint").click(function () { $("#saveCheckPoint").click(function () {
@@ -138,42 +134,6 @@
saveEntity(csrfToken, formData.CheckPointDTO, $('#checkPointEditPostUrl').val()); saveEntity(csrfToken, formData.CheckPointDTO, $('#checkPointEditPostUrl').val());
// $.ajax({
// url: $('#checkPointEditPostUrl').val(),
// type: 'POST',
// headers: {
// 'X-CSRF-TOKEN': csrfToken,
// 'Content-Type': 'application/json'
// },
// data: JSON.stringify(formData.CheckPointDTO),
// success: function (response) {
// if (response.success)
// {
// showMessageModal({
// title: 'Figyelmem!',
// message: 'Sikeres mentés.',
// okText: 'Értettem'
// });
// }
// else
// {
// showMessageModal({
// title: 'Figyelmem, HIBA!',
// message: 'Sikertelen mentés.',
// okText: 'Értettem'
// });
// }
// },
// error: function (xhr, status, error) {
// console.error("Hiba: ", error);
// showMessageModal({
// title: 'Hiba!',
// message: 'A mentés NEM sikerült!',
// okText: 'Értettem'
// });
// }
// });
}); });
</script> </script>
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
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 Serilog;
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces; using WorkFlowCheck.Web.Services.Interfaces;
@@ -13,17 +14,24 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
{ {
private readonly ILogger<IndexModel> _logger; private readonly ILogger<IndexModel> _logger;
private readonly IBaseStockService _baseStockService; private readonly IBaseStockService _baseStockService;
private readonly IUserService _userService;
[BindProperty] [BindProperty]
public CheckPointDTO CheckPointDTO { get; set; } public CheckPointDTO CheckPointDTO { get; set; }
[BindProperty]
public List<SelectListItem> Roles { get; set; }
public CheckPointEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService) public CheckPointEditPageModel(ILogger<IndexModel> logger,
IBaseStockService baseStockService,
IUserService userService)
{ {
_baseStockService = baseStockService; _baseStockService = baseStockService;
_userService = userService;
_logger = logger; _logger = logger;
} }
public async Task OnGet(int id) public async Task OnGet(int id)
{ {
await InitSelectItems();
CheckPointDTO = await _baseStockService.GetCheckPoint(id); CheckPointDTO = await _baseStockService.GetCheckPoint(id);
} }
@@ -54,5 +62,15 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
return new JsonResult(new { success = false }); return new JsonResult(new { success = false });
} }
private async Task InitSelectItems()
{
var roles = await _userService.GetAllRoles();
Roles = new List<SelectListItem>();
Roles.Add(new SelectListItem() { Value = "-1", Text = "NINCS" });
foreach (var role in roles)
{
Roles.Add(new SelectListItem() { Value = role.Id.ToString(), Text = role.RoleName });
}
}
} }
} }
@@ -77,7 +77,7 @@
$('#tbEquipmentsPage').on('click', '.delete-btn', function () $('#tbEquipmentsPage').on('click', '.delete-btn', function ()
{ {
const row = table.row($(this).closest('tr')).data(); const row = table.row($(this).closest('tr')).data();
deleteEntity(table, '/BaseStock/Equipments/EquipmentPage?handler=DeleteLocation', row.id); deleteEntity(table, '/BaseStock/Equipments/EquipmentPage?handler=DeleteEquipment', row.id);
}); });
</script> </script>
} }
@@ -1,5 +1,7 @@
@page @page
@model WorkFlowCheck.Web.Pages.UserAndRole.RoleCheckPointsPageModel @model WorkFlowCheck.Web.Pages.UserAndRole.RoleCheckPointsPageModel
@using WorkFlowCheck.Common.Helper
@using WorkFlowCheck.Common.DTO
@{ @{
ViewData["Title"] = "Szabályok - Ellenőrzési sablonok"; ViewData["Title"] = "Szabályok - Ellenőrzési sablonok";
} }
@@ -15,18 +17,18 @@
<thead class="table-primary"> <thead class="table-primary">
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Role name</th> <th>>@DisplayNameHelper.GetDisplayName(nameof(RoleCheckPointDTO.RoleDTO.RoleName), typeof(RoleCheckPointDTO))</th>
<th>Checkpoint name</th> <th>@DisplayNameHelper.GetDisplayName(nameof(RoleCheckPointDTO.CheckPointDTO.ShortName), typeof(RoleCheckPointDTO))</th>
<th>Enabled</th> <th>@DisplayNameHelper.GetDisplayName(nameof(RoleCheckPointDTO.Enabled), typeof(RoleCheckPointDTO))</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
<tfoot class="table-light"> <tfoot class="table-light">
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Role name</th> <th>>@DisplayNameHelper.GetDisplayName(nameof(RoleCheckPointDTO.RoleDTO.RoleName), typeof(RoleCheckPointDTO))</th>
<th>Checkpoint name</th> <th>@DisplayNameHelper.GetDisplayName(nameof(RoleCheckPointDTO.CheckPointDTO.ShortName), typeof(RoleCheckPointDTO))</th>
<th>Enabled</th> <th>@DisplayNameHelper.GetDisplayName(nameof(RoleCheckPointDTO.Enabled), typeof(RoleCheckPointDTO))</th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
</tr> </tr>
</tfoot> </tfoot>