From 63b02a4a93e5e1b6c7aa8f85ddfc14bfc82f283a Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 18 Jul 2024 17:59:49 +0200 Subject: [PATCH 1/2] improvements, fixes, etc... --- TIAM.Database.Test/TIAM.Database.Test.csproj | 14 ++++---- TIAM.Database/TIAM.Database.csproj | 8 ++--- TIAM.Entities/TIAM.Entities.csproj | 2 +- .../TIAM.Services.Server.Tests.csproj | 6 ++-- .../TIAM.Services.Server.csproj | 2 +- .../ProductDetailGridComponent.razor | 34 +++++++++++-------- TIAMSharedUI/TIAMSharedUI.csproj | 6 ++-- TIAMWebApp/Client/TIAMWebApp.Client.csproj | 6 ++-- TIAMWebApp/Server/TIAMWebApp.Server.csproj | 8 ++--- .../TIAMWebApp.Shared.Application.csproj | 10 +++--- .../Tiam.Services.Client.Tests.csproj | 4 +-- 11 files changed, 52 insertions(+), 48 deletions(-) diff --git a/TIAM.Database.Test/TIAM.Database.Test.csproj b/TIAM.Database.Test/TIAM.Database.Test.csproj index 06d9d95e..42009a81 100644 --- a/TIAM.Database.Test/TIAM.Database.Test.csproj +++ b/TIAM.Database.Test/TIAM.Database.Test.csproj @@ -22,17 +22,17 @@ - - - - - + + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/TIAM.Database/TIAM.Database.csproj b/TIAM.Database/TIAM.Database.csproj index 86d68894..90fd0f00 100644 --- a/TIAM.Database/TIAM.Database.csproj +++ b/TIAM.Database/TIAM.Database.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/TIAM.Entities/TIAM.Entities.csproj b/TIAM.Entities/TIAM.Entities.csproj index 0d7c9be8..122ec9d2 100644 --- a/TIAM.Entities/TIAM.Entities.csproj +++ b/TIAM.Entities/TIAM.Entities.csproj @@ -32,7 +32,7 @@ - + diff --git a/TIAM.Services.Server.Tests/TIAM.Services.Server.Tests.csproj b/TIAM.Services.Server.Tests/TIAM.Services.Server.Tests.csproj index 30c93c25..53e51fc9 100644 --- a/TIAM.Services.Server.Tests/TIAM.Services.Server.Tests.csproj +++ b/TIAM.Services.Server.Tests/TIAM.Services.Server.Tests.csproj @@ -26,10 +26,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + diff --git a/TIAM.Services.Server/TIAM.Services.Server.csproj b/TIAM.Services.Server/TIAM.Services.Server.csproj index c650cf4e..f429caa5 100644 --- a/TIAM.Services.Server/TIAM.Services.Server.csproj +++ b/TIAM.Services.Server/TIAM.Services.Server.csproj @@ -7,7 +7,7 @@ - + diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor index 3232473b..5988ae07 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ProductDetailGridComponent.razor @@ -18,13 +18,14 @@ @using AyCode.Interfaces.Addresses @using AyCode.Core @using AyCode.Core.Extensions +@using AyCode.Core.Helpers @inject IStringLocalizer Localizer @inject IEnumerable LogWriters @inject AdminSignalRClient AdminSignalRClient; @code { - [Parameter] public Guid? ContextId { get; set; } + [Parameter] public Guid ContextId { get; set; } [Parameter] public IProductsRelation? ParentData { get; set; } = null!; [Parameter] public EventCallback OnGridEditModelSaving { get; set; } [Parameter] public int GetAllTag { get; set; } = SignalRTags.GetProductsByOwnerId; [Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never; - private List? destinations = null; + //private static Dictionary> _destinations = []; + private static List _destinations = []; private ProductDetailGrid _productGrid = null!; - private LoggerClient _logger = null!; + private LoggerClient _logger = null!; + + // private List GetDestinationsByContextId(Guid contextId) + // { + // if (_destinations.TryGetValue(contextId, out var transferDestinations) && transferDestinations != null) + // return transferDestinations; + + // _destinations[contextId] = []; + // return _destinations[contextId]; + // } + protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); - //DataSource = new List
(); + AdminSignalRClient.GetAllIntoAsync(_destinations, SignalRTags.GetAllTransferDestinations).Forget(); } private bool CheckDestinations(Guid addressId) { - - - if(destinations!=null) + if(_destinations!=null) { - if (destinations.Any(d => d.AddressId == addressId)) + if (_destinations.Any(d => d.AddressId == addressId)) { return true; } @@ -179,12 +189,6 @@ _productGrid.Reload(); } - protected override async Task OnInitializedAsync() - { - destinations = await AdminSignalRClient.GetAllAsync>(SignalRTags.GetAllTransferDestinations); - await base.OnInitializedAsync(); - } - protected override async Task OnParametersSetAsync() { // if (ParentData != null) diff --git a/TIAMSharedUI/TIAMSharedUI.csproj b/TIAMSharedUI/TIAMSharedUI.csproj index d87f2a8b..f8321858 100644 --- a/TIAMSharedUI/TIAMSharedUI.csproj +++ b/TIAMSharedUI/TIAMSharedUI.csproj @@ -19,9 +19,9 @@ - - - + + + diff --git a/TIAMWebApp/Client/TIAMWebApp.Client.csproj b/TIAMWebApp/Client/TIAMWebApp.Client.csproj index adff4fe3..9502f5ba 100644 --- a/TIAMWebApp/Client/TIAMWebApp.Client.csproj +++ b/TIAMWebApp/Client/TIAMWebApp.Client.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/TIAMWebApp/Server/TIAMWebApp.Server.csproj b/TIAMWebApp/Server/TIAMWebApp.Server.csproj index a18eebbd..a604fa22 100644 --- a/TIAMWebApp/Server/TIAMWebApp.Server.csproj +++ b/TIAMWebApp/Server/TIAMWebApp.Server.csproj @@ -12,10 +12,10 @@ - - - - + + + + diff --git a/TIAMWebApp/Shared/TIAMWebApp.Shared.Application.csproj b/TIAMWebApp/Shared/TIAMWebApp.Shared.Application.csproj index ca85dd73..0162055d 100644 --- a/TIAMWebApp/Shared/TIAMWebApp.Shared.Application.csproj +++ b/TIAMWebApp/Shared/TIAMWebApp.Shared.Application.csproj @@ -22,11 +22,11 @@ - - - - - + + + + + diff --git a/Tiam.Services.Client.Tests/Tiam.Services.Client.Tests.csproj b/Tiam.Services.Client.Tests/Tiam.Services.Client.Tests.csproj index 6bad5966..98b8174b 100644 --- a/Tiam.Services.Client.Tests/Tiam.Services.Client.Tests.csproj +++ b/Tiam.Services.Client.Tests/Tiam.Services.Client.Tests.csproj @@ -15,8 +15,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + From e1f9e1748d356b91b4bdf5980110e8ed115c86da Mon Sep 17 00:00:00 2001 From: Loretta Date: Thu, 18 Jul 2024 19:21:19 +0200 Subject: [PATCH 2/2] json fix --- TIAM.Entities/Products/ProductBase.cs | 5 +++++ TIAM.Entities/Users/UserProductMapping.cs | 3 +++ TIAMWebApp/Server/Services/DevAdminSignalRhub.cs | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/TIAM.Entities/Products/ProductBase.cs b/TIAM.Entities/Products/ProductBase.cs index d6d71708..b1f074d6 100644 --- a/TIAM.Entities/Products/ProductBase.cs +++ b/TIAM.Entities/Products/ProductBase.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using AyCode.Interfaces.TimeStampInfo; +using Newtonsoft.Json; using TIAM.Core.Enums; using TIAM.Entities.Profiles; @@ -23,6 +24,10 @@ public abstract class ProductBase : IProductBase, ITimeStampInfo public string Name { get; set; } public string Description { get; set; } public float Price { get; set; } + + [NotMapped] + [JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public string? JsonDetails { get; set; } public DateTime Created { get; set; } diff --git a/TIAM.Entities/Users/UserProductMapping.cs b/TIAM.Entities/Users/UserProductMapping.cs index 1184e919..968d291e 100644 --- a/TIAM.Entities/Users/UserProductMapping.cs +++ b/TIAM.Entities/Users/UserProductMapping.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations.Schema; using AyCode.Interfaces.Entities; using AyCode.Interfaces.TimeStampInfo; +using Newtonsoft.Json; using TIAM.Entities.Drivers; using TIAM.Entities.Products; @@ -27,6 +28,8 @@ public class UserProductMapping : IEntityGuid, IUserRelation, IProductRelation, //[Column("JsonDetailModel")] [NotMapped] + [JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] public UserProductJsonDetailModel? JsonDetailModel { get; set; } = null; public DateTime Created { get; set; } diff --git a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs index b24475dc..9d402896 100644 --- a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs +++ b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs @@ -215,7 +215,13 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe } else _logger.Debug($"{logText}(); {tagName}"); - await ResponseToCaller(messageTag, new SignalResponseJsonMessage(messageTag, SignalResponseStatus.Success, methodInfoModel.MethodInfo.InvokeMethod(methodsByDeclaringObject.InstanceObject, paramValues)), requestId); + var responseDataJson = new SignalResponseJsonMessage(messageTag, SignalResponseStatus.Success, methodInfoModel.MethodInfo.InvokeMethod(methodsByDeclaringObject.InstanceObject, paramValues)); + var responseDataJsonKiloBytes = System.Text.Encoding.Unicode.GetByteCount(responseDataJson.ResponseData!) / 1024; + + //File.WriteAllText(Path.Combine("h:", $"{requestId}.json"), responseDataJson.ResponseData); + + _logger.Info($"[{responseDataJsonKiloBytes}kb] responseData serialized to json"); + await ResponseToCaller(messageTag, responseDataJson, requestId); return; } @@ -309,9 +315,10 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe protected async Task SendMessageToClient(ISignalRHubItemServer sendTo, int messageTag, ISignalRMessage message, int? requestId = null) { - _logger.Info($"Server SendMessageToClient; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; {ConstHelper.NameByValue(messageTag)}"); + var responseDataMessagePack = message.ToMessagePack(ContractlessStandardResolver.Options); + _logger.Info($"[{(responseDataMessagePack.Length/1024)}kb] Server sending responseDataMessagePack to client; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; {ConstHelper.NameByValue(messageTag)}"); - await sendTo.OnReceiveMessage(messageTag, message.ToMessagePack(ContractlessStandardResolver.Options), requestId); + await sendTo.OnReceiveMessage(messageTag, responseDataMessagePack, requestId); } public async Task SendMessageToGroup(string groupId, int messageTag, string message)