diff --git a/src/WorkFlowCheck.API/Controllers/SyncController.cs b/src/WorkFlowCheck.API/Controllers/SyncController.cs index f9cef30..0f4debb 100644 --- a/src/WorkFlowCheck.API/Controllers/SyncController.cs +++ b/src/WorkFlowCheck.API/Controllers/SyncController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Serilog; +using System.Text; using WorkFlowCheck.BL.Services; using WorkFlowCheck.BL.Services.Interfaces; using WorkFlowCheck.Common.DTO; @@ -410,6 +411,56 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + + [HttpPost("DeviceMessageSend")] + public async Task> DeviceMessageSend([FromBody] DeviceMessageDTO deviceMessageDTO) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true + }; + try + { + var result = await _syncService.DeviceMessageSend(deviceMessageDTO); + retVal.Data = true; + } + catch (Exception ex) + { + retVal.IsSuccess = false; + retVal.Errors.Add(ex.Message); + Log.Error(ex.Message); + } + return retVal; + } + + [HttpGet("DeviceMessageReadUnreaded/{deviceIdBase64}")] + public async Task>> DeviceMessageReadUnreaded(string deviceIdBase64) + { + var retVal = new ApiResponseDTO>() + { + IsSuccess = true, + }; + + byte[] byteArray = Convert.FromBase64String(deviceIdBase64); + string deviceId = Encoding.UTF8.GetString(byteArray); + + + var response = await _syncService.DeviceMessageReadUnreaded(deviceId); + + if (response != null) + { + + retVal.IsSuccess = true; + retVal.Data = response; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } } } diff --git a/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs b/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs index 97f354c..cc8d6fe 100644 --- a/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs +++ b/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs @@ -43,6 +43,9 @@ namespace WorkFlowCheck.BL.Mappings CreateMap(); CreateMap(); + CreateMap(); + CreateMap(); + CreateMap() .ForMember(dest => dest.UserDTO, opt => opt.MapFrom(src => src.User)) .ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows)); diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs index 892899e..ae7c25f 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs @@ -24,5 +24,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces Task CreatePDF(int checkListHeaderId); + + } } diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs index 4560d7d..be16adb 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs @@ -28,5 +28,8 @@ namespace WorkFlowCheck.BL.Services.Interfaces Task> GetAllCheckListAsync(int userId); Task UpdateCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO); + + Task DeviceMessageSend(DeviceMessageDTO deviceMessageDTO); + Task> DeviceMessageReadUnreaded(string deviceId); } } diff --git a/src/WorkFlowCheck.BL/Services/SyncService.cs b/src/WorkFlowCheck.BL/Services/SyncService.cs index 9fa724c..d78b9c3 100644 --- a/src/WorkFlowCheck.BL/Services/SyncService.cs +++ b/src/WorkFlowCheck.BL/Services/SyncService.cs @@ -1,6 +1,7 @@  using AutoMapper; using DocumentFormat.OpenXml.InkML; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.EntityFrameworkCore; using Serilog; using System.Collections.Generic; @@ -172,7 +173,7 @@ namespace WorkFlowCheck.BL.Services } public async Task DeleteLocationAsync(int id) { - return await DeleteEntityByIdAsync(id); + return await DeleteEntityByIdAsync(id); } public async Task UpdateLocationAsync(LocationDTO LocationDTO) { @@ -182,7 +183,7 @@ namespace WorkFlowCheck.BL.Services { if (LocationDTO.Id == 0) //Hozzáadás, ha Id == 0 { - var Location = _mapper.Map(LocationDTO); + var Location = _mapper.Map(LocationDTO); _dbContext.Locations.Add(Location); await _dbContext.SaveChangesAsync(); @@ -193,7 +194,7 @@ namespace WorkFlowCheck.BL.Services var res = await _dbContext.Locations.Where(w => w.Id == LocationDTO.Id).FirstOrDefaultAsync(); if (res != null) { - res = _mapper.Map(LocationDTO); + res = _mapper.Map(LocationDTO); await _dbContext.SaveChangesAsync(); @@ -408,5 +409,51 @@ namespace WorkFlowCheck.BL.Services return retVal; } + + + public async Task DeviceMessageSend(DeviceMessageDTO deviceMessageDTO) + { + var retVal = false; + try + { + var deviceMessage = _mapper.Map(deviceMessageDTO); + deviceMessage.SendDate = DateTime.UtcNow; + deviceMessage.IsReaded = false; + _dbContext.DeviceMessages.Add(deviceMessage); + await _dbContext.SaveChangesAsync(true); + retVal = true; + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task> DeviceMessageReadUnreaded(string deviceId) + { + var retVal = new List(); + try + { + var res = await _dbContext.DeviceMessages + .Where(w => w.DeviceIdTo == deviceId && w.IsReaded != true) + .ToListAsync(); + + if (res != null) + { + retVal = _mapper.Map>(res); + foreach (var deviceMessage in res) + { + deviceMessage.IsReaded = true; + deviceMessage.ReceiveDate = DateTime.UtcNow; + } + await _dbContext.SaveChangesAsync(); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } } } diff --git a/src/WorkFlowCheck.Common/DTO/DeviceMessageDTO.cs b/src/WorkFlowCheck.Common/DTO/DeviceMessageDTO.cs new file mode 100644 index 0000000..ffb9f46 --- /dev/null +++ b/src/WorkFlowCheck.Common/DTO/DeviceMessageDTO.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.Common.DTO +{ + public class DeviceMessageDTO + { + public int Id { get; set; } + public DateTime? SendDate { get; set; } + public DateTime? ReceiveDate { get; set; } + public string DeviceIdFrom { get; set; } = null!; + public string DeviceIdTo { get; set; } = null!; + public string Message { get; set; } = null!; + public string ExtraDataJSON { get; set; } = null!; + public bool IsReaded { get; set; } + } +} diff --git a/src/WorkFlowCheck.Common/DTO/RoleDTO.cs b/src/WorkFlowCheck.Common/DTO/RoleDTO.cs index 06d88b5..57689c3 100644 --- a/src/WorkFlowCheck.Common/DTO/RoleDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/RoleDTO.cs @@ -1,8 +1,14 @@ -namespace WorkFlowCheck.Common.DTO +using System.ComponentModel.DataAnnotations; +using System.ComponentModel; + +namespace WorkFlowCheck.Common.DTO { public class RoleDTO { - public int Id { get; set; } + public int Id { get; set; } + + [Required(ErrorMessage = "A szabály megnevezésének megadása kötelező.")] + [DisplayName("Megnevezés")] public string RoleName { get; set; } = null!; } } diff --git a/src/WorkFlowCheck.DL/AppDbContext.cs b/src/WorkFlowCheck.DL/AppDbContext.cs index 4b5e4d1..cd8ef44 100644 --- a/src/WorkFlowCheck.DL/AppDbContext.cs +++ b/src/WorkFlowCheck.DL/AppDbContext.cs @@ -25,6 +25,7 @@ namespace WorkFlowCheck.DL public DbSet CheckListTemplateHeaders { get; set; } = null!; public DbSet CheckListTemplateRows { get; set; } = null!; public DbSet CheckPoints { get; set; } = null!; + public DbSet DeviceMessages { get; set; } = null!; public DbSet Equipments { get; set; } = null!; public DbSet Locations { get; set; } = null!; public DbSet NumberGeneratorTemplates { get; set; } = null!; @@ -45,6 +46,7 @@ namespace WorkFlowCheck.DL modelBuilder.ApplyConfiguration(new CheckListTemplateHeaderTypeConfiguration()); modelBuilder.ApplyConfiguration(new CheckListTemplateRowTypeConfiguration()); modelBuilder.ApplyConfiguration(new CheckPointTypeConfiguration()); + modelBuilder.ApplyConfiguration(new DeviceMessageTypeConfiguration()); modelBuilder.ApplyConfiguration(new EquipmentTypeConfiguration()); modelBuilder.ApplyConfiguration(new LocationTypeConfiguration()); modelBuilder.ApplyConfiguration(new NumberGeneratorTypeConfiguration()); diff --git a/src/WorkFlowCheck.DL/Configurations/DeviceMessageTypeConfiguration.cs b/src/WorkFlowCheck.DL/Configurations/DeviceMessageTypeConfiguration.cs new file mode 100644 index 0000000..9bad651 --- /dev/null +++ b/src/WorkFlowCheck.DL/Configurations/DeviceMessageTypeConfiguration.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.DL.Configurations +{ + public class DeviceMessageTypeConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("DeviceMessage"); + builder.HasKey(e => e.Id); + builder.Property(e => e.Id).ValueGeneratedOnAdd(); + + builder.HasIndex(e => e.DeviceIdTo) + .HasDatabaseName("IX_DeviceMessage_DeviceIdTo"); + } + + } +} diff --git a/src/WorkFlowCheck.DL/Entities/DeviceMessage.cs b/src/WorkFlowCheck.DL/Entities/DeviceMessage.cs new file mode 100644 index 0000000..8316e7e --- /dev/null +++ b/src/WorkFlowCheck.DL/Entities/DeviceMessage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.DL.Entities +{ + public class DeviceMessage + { + public int Id { get; set; } + public DateTime SendDate { get; set; } + public DateTime? ReceiveDate { get; set; } + public string DeviceIdFrom { get; set; } = null!; + public string DeviceIdTo { get; set; } = null!; + public string Message { get; set; } = null!; + public string ExtraDataJSON { get; set; } = null!; + public bool IsReaded { get; set; } + + } +} diff --git a/src/WorkFlowCheck.DL/Migrations/20250405121855_Extend014.Designer.cs b/src/WorkFlowCheck.DL/Migrations/20250405121855_Extend014.Designer.cs new file mode 100644 index 0000000..7065d35 --- /dev/null +++ b/src/WorkFlowCheck.DL/Migrations/20250405121855_Extend014.Designer.cs @@ -0,0 +1,902 @@ +// +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("20250405121855_Extend014")] + partial class Extend014 + { + /// + 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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("CheckStatus") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateExecution") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GuidNumber") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsEditable") + .HasColumnType("bit"); + + b.Property("IsStorno") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Answer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CheckListHeaderId") + .HasColumnType("int"); + + b.Property("CheckListTemplateRowId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GuidNumber") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NumberGenerator1Id") + .HasColumnType("int"); + + b.Property("NumberGenerator2Id") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnswerType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("CheckPointId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EquipmentId") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OperationDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsEnabled") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("CheckPoint", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.DeviceMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeviceIdFrom") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DeviceIdTo") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ExtraDataJSON") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsReaded") + .HasColumnType("bit"); + + b.Property("Message") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ReceiveDate") + .HasColumnType("datetime2"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EquipmentNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Equipment", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Location", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.NumberGeneratorTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CurrentNumber") + .HasColumnType("int"); + + b.Property("DigitFormat") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GenerateType") + .HasColumnType("int"); + + b.Property("LastGeneratedNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Prefix") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PrefixSeparator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Suffix") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CurrentNumber") + .HasColumnType("int"); + + b.Property("LastGeneratedNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Month") + .HasColumnType("int"); + + b.Property("NumberGeneratorTemplateId") + .HasColumnType("int"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.RoleCheckListTemplateHeader", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckListTemplateHeaderId") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckPointId") + .HasColumnType("int"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("bit"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("JwtToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastModAt") + .HasColumnType("datetime2"); + + b.Property("LastModBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NFCActive") + .HasColumnType("bit"); + + b.Property("NFCCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("Token2FA") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("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, 5, 12, 18, 54, 939, DateTimeKind.Utc).AddTicks(1707), + CreatedBy = "System", + Email = "admin@nuvolar.hu", + FirstName = "Administrator", + IsDeleted = false, + JwtToken = "", + LastModAt = new DateTime(2025, 4, 5, 12, 18, 54, 939, DateTimeKind.Utc).AddTicks(1709), + LastModBy = "System", + LastName = "System", + NFCActive = true, + NFCCode = "00000000", + PasswordHash = "eGM0NUREZnJ0ISFFRDIxMKE5TYwthDBuUsTUEO1fBnCR3VdSCmdz47ue0RoVvnkY", + Token2FA = "", + UserName = "admin" + }, + new + { + Id = 2, + Active = true, + CreatedAt = new DateTime(2025, 4, 5, 12, 18, 54, 949, DateTimeKind.Utc).AddTicks(6682), + CreatedBy = "System", + Email = "user@nuvolar.hu", + FirstName = "User", + IsDeleted = false, + JwtToken = "", + LastModAt = new DateTime(2025, 4, 5, 12, 18, 54, 949, DateTimeKind.Utc).AddTicks(6683), + LastModBy = "System", + LastName = "System", + NFCActive = true, + NFCCode = "00000000", + PasswordHash = "eGM0NUREZnJ0ISFFRDIxMPwM2D9sQSj7zmaSBIsOGe0I9hBFwCGPVbyrYMA5EnKG", + Token2FA = "", + UserName = "user" + }); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("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.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("UserRoles"); + }); + + modelBuilder.Entity("WorkFlowCheck.DL.Entities.User", b => + { + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/WorkFlowCheck.DL/Migrations/20250405121855_Extend014.cs b/src/WorkFlowCheck.DL/Migrations/20250405121855_Extend014.cs new file mode 100644 index 0000000..3d3ca62 --- /dev/null +++ b/src/WorkFlowCheck.DL/Migrations/20250405121855_Extend014.cs @@ -0,0 +1,74 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WorkFlowCheck.DL.Migrations +{ + /// + public partial class Extend014 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DeviceMessage", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SendDate = table.Column(type: "datetime2", nullable: false), + ReceiveDate = table.Column(type: "datetime2", nullable: true), + DeviceIdFrom = table.Column(type: "nvarchar(max)", nullable: false), + DeviceIdTo = table.Column(type: "nvarchar(450)", nullable: false), + Message = table.Column(type: "nvarchar(max)", nullable: false), + ExtraDataJSON = table.Column(type: "nvarchar(max)", nullable: false), + IsReaded = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DeviceMessage", x => x.Id); + }); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "Id", + keyValue: 1, + columns: new[] { "CreatedAt", "LastModAt" }, + values: new object[] { new DateTime(2025, 4, 5, 12, 18, 54, 939, DateTimeKind.Utc).AddTicks(1707), new DateTime(2025, 4, 5, 12, 18, 54, 939, DateTimeKind.Utc).AddTicks(1709) }); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "Id", + keyValue: 2, + columns: new[] { "CreatedAt", "LastModAt" }, + values: new object[] { new DateTime(2025, 4, 5, 12, 18, 54, 949, DateTimeKind.Utc).AddTicks(6682), new DateTime(2025, 4, 5, 12, 18, 54, 949, DateTimeKind.Utc).AddTicks(6683) }); + + migrationBuilder.CreateIndex( + name: "IX_DeviceMessage_DeviceIdTo", + table: "DeviceMessage", + column: "DeviceIdTo"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DeviceMessage"); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "Id", + keyValue: 1, + columns: new[] { "CreatedAt", "LastModAt" }, + values: new object[] { new DateTime(2025, 4, 4, 10, 41, 46, 227, DateTimeKind.Utc).AddTicks(5578), new DateTime(2025, 4, 4, 10, 41, 46, 227, DateTimeKind.Utc).AddTicks(5580) }); + + migrationBuilder.UpdateData( + table: "Users", + keyColumn: "Id", + keyValue: 2, + columns: new[] { "CreatedAt", "LastModAt" }, + values: new object[] { new DateTime(2025, 4, 4, 10, 41, 46, 239, DateTimeKind.Utc).AddTicks(1896), new DateTime(2025, 4, 4, 10, 41, 46, 239, DateTimeKind.Utc).AddTicks(1897) }); + } + } +} diff --git a/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs b/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs index 1b308df..a7a9910 100644 --- a/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs +++ b/src/WorkFlowCheck.DL/Migrations/AppDbContextModelSnapshot.cs @@ -285,6 +285,47 @@ namespace WorkFlowCheck.DL.Migrations b.ToTable("CheckPoint", (string)null); }); + modelBuilder.Entity("WorkFlowCheck.DL.Entities.DeviceMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeviceIdFrom") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DeviceIdTo") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ExtraDataJSON") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsReaded") + .HasColumnType("bit"); + + b.Property("Message") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ReceiveDate") + .HasColumnType("datetime2"); + + b.Property("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("Id") @@ -618,13 +659,13 @@ namespace WorkFlowCheck.DL.Migrations { Id = 1, Active = true, - CreatedAt = new DateTime(2025, 4, 4, 10, 41, 46, 227, DateTimeKind.Utc).AddTicks(5578), + CreatedAt = new DateTime(2025, 4, 5, 12, 18, 54, 939, DateTimeKind.Utc).AddTicks(1707), CreatedBy = "System", Email = "admin@nuvolar.hu", FirstName = "Administrator", IsDeleted = false, JwtToken = "", - LastModAt = new DateTime(2025, 4, 4, 10, 41, 46, 227, DateTimeKind.Utc).AddTicks(5580), + LastModAt = new DateTime(2025, 4, 5, 12, 18, 54, 939, DateTimeKind.Utc).AddTicks(1709), LastModBy = "System", LastName = "System", NFCActive = true, @@ -637,13 +678,13 @@ namespace WorkFlowCheck.DL.Migrations { Id = 2, Active = true, - CreatedAt = new DateTime(2025, 4, 4, 10, 41, 46, 239, DateTimeKind.Utc).AddTicks(1896), + CreatedAt = new DateTime(2025, 4, 5, 12, 18, 54, 949, DateTimeKind.Utc).AddTicks(6682), CreatedBy = "System", Email = "user@nuvolar.hu", FirstName = "User", IsDeleted = false, JwtToken = "", - LastModAt = new DateTime(2025, 4, 4, 10, 41, 46, 239, DateTimeKind.Utc).AddTicks(1897), + LastModAt = new DateTime(2025, 4, 5, 12, 18, 54, 949, DateTimeKind.Utc).AddTicks(6683), LastModBy = "System", LastName = "System", NFCActive = true, diff --git a/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml b/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml index a92c7bc..65ba13e 100644 --- a/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml +++ b/src/WorkFlowCheck.Web/Pages/Account/Login.cshtml @@ -1,5 +1,7 @@ @page @model WorkFlowCheck.Web.Pages.Account.LoginModel +@using WorkFlowCheck.Common.Helper +@using WorkFlowCheck.Common.DTO @{ Layout = null; ViewData["Title"] = "Bejelentkezés"; diff --git a/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml b/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml index 190fc93..d01de11 100644 --- a/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/UserAndRole/RolePage.cshtml @@ -1,5 +1,8 @@ @page @model WorkFlowCheck.Web.Pages.UserAndRole.RolePageModel +@using WorkFlowCheck.Common.Helper +@using WorkFlowCheck.Common.DTO + @{ ViewData["Title"] = "Szabályok"; } @@ -15,14 +18,14 @@ ID - Role Name + @DisplayNameHelper.GetDisplayName("RoleName", typeof(RoleDTO)) Action ID - Role Name + @DisplayNameHelper.GetDisplayName("RoleName", typeof(RoleDTO)) Action