From 08b373f0c7ed69a2a3c41d1f6f01685a6587f1ed Mon Sep 17 00:00:00 2001 From: Loretta Date: Mon, 1 Jul 2024 18:16:44 +0200 Subject: [PATCH] improvements, fixes, etc... --- TIAM.Entities/Transfers/Transfer.cs | 1 + TIAM.Services/SignalRTags.cs | 21 +++++++++++-------- .../Server/Services/DevAdminSignalRhub.cs | 13 ++++++------ .../Shared/Services/AdminSignalRClient.cs | 9 +++++++- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/TIAM.Entities/Transfers/Transfer.cs b/TIAM.Entities/Transfers/Transfer.cs index a171c2f7..f11a2b59 100644 --- a/TIAM.Entities/Transfers/Transfer.cs +++ b/TIAM.Entities/Transfers/Transfer.cs @@ -31,6 +31,7 @@ public class Transfer: IEntityGuid, IAcFullName, ITimeStampInfo, IProductForeign public string? PaymentId { get; set; } //public virtual UserProductMapping? UserProductMapping { get; set; } + [JsonIgnore] [Newtonsoft.Json.JsonIgnore] public virtual List TransferToDrivers { get; set; } = []; diff --git a/TIAM.Services/SignalRTags.cs b/TIAM.Services/SignalRTags.cs index 4b18f87c..88ecbbf1 100644 --- a/TIAM.Services/SignalRTags.cs +++ b/TIAM.Services/SignalRTags.cs @@ -1,4 +1,5 @@ using AyCode.Services.SignalRs; +using System.Reflection; namespace TIAM.Services; @@ -10,9 +11,9 @@ public class SignalRTags : AcSignalRTags public const int GetTransfersByDriverId = 4; public const int GetTransfersByProductId = 5; public const int GetTransfersByCompanyId = 6; - + public const int GetTransfersByFilterText = 301; - + public const int UpdateTransfer = 7; public const int AddTransfer = 8; public const int RemoveTransfer = 9; @@ -36,13 +37,16 @@ public class SignalRTags : AcSignalRTags public const int RemoveTransferToDriver = 28; public const int GetAddress = 29; + //public const int GetAddresses = 30; public const int GetAddressesByContextId = 31; + public const int UpdateAddress = 32; //public const int AddAddress = 33; //public const int RemoveAddress = 34; public const int GetProfileById = 35; + //public const int GetProfiles = 36; //public const int GetProfileByContextId = 37; public const int UpdateProfile = 38; @@ -53,11 +57,11 @@ public class SignalRTags : AcSignalRTags public const int CreateUserProductMapping = 40; public const int UpdateUserProductMapping = 41; public const int DeleteUserProductMapping = 42; //set permissions to 0 - public const int GetAllUserProductMappings = 43; - public const int GetUserProductMappingsByProductId = 44; - public const int GetUserProductMappingsByUserId = 45; - public const int GetUserProductMappingById = 46; - public const int GetUserProductMappingsById = 47; + public const int GetAllUserProductMappings = 43; + public const int GetUserProductMappingsByProductId = 44; + public const int GetUserProductMappingsByUserId = 45; + public const int GetUserProductMappingById = 46; + public const int GetUserProductMappingsById = 47; public const int GetCarsForUserProductMapping = 50; public const int CreateCar = 51; @@ -86,7 +90,7 @@ public class SignalRTags : AcSignalRTags public const int CreateTransferDestination = 82; public const int UpdateTransferDestination = 83; public const int RemoveTransferDestination = 84; //set permissions to 0 - + public const int CreateTransferDestinationToProduct = 90; public const int UpdateTransferDestinationToProduct = 91; public const int RemoveTransferDestinationToProduct = 92; //set permissions to 0 @@ -96,5 +100,4 @@ public class SignalRTags : AcSignalRTags public const int GetTransferDestinationToProductsByTransferDestinationId = 96; public const int GetAllLogItemsByFilterText = 100; - } diff --git a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs index 0e8cfd6b..32fa75b1 100644 --- a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs +++ b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq.Expressions; using AutoMapper; +using AyCode.Core.Helpers; using DevExpress.Pdf.Native.BouncyCastle.Security; using TIAM.Entities.Emails; using TIAM.Services.Server; @@ -138,7 +139,7 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe public async Task OnReceiveMessage(int messageTag, byte[]? message, int? requestId) { - var logText = $"Server OnReceiveMessage; {nameof(messageTag)}: {messageTag}; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; UserIdentifier: {Context.UserIdentifier}"; + var logText = $"{ConstHelper.NameByValue(messageTag)} Server OnReceiveMessage; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; UserIdentifier: {Context.UserIdentifier}"; if (message is { Length: 0 }) _logger.Warning($"message.Length == 0! {logText}"); else _logger.Info(logText); @@ -151,7 +152,7 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe object[]? paramValues = null; - logText = $"Found dynamic method for the tag! tag: {messageTag}; method: {methodsByDeclaringObject.InstanceObject.GetType().Name}.{methodInfoModel.MethodInfo.Name}"; + logText = $"{ConstHelper.NameByValue(messageTag)} Found dynamic method for the tag! method: {methodsByDeclaringObject.InstanceObject.GetType().Name}.{methodInfoModel.MethodInfo.Name}"; if (methodInfoModel.ParamInfos is { Length: > 0 }) { @@ -214,7 +215,7 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe return; } - _logger.Debug($"Not found dynamic method for the tag! tag: {messageTag};"); + _logger.Debug($"{ConstHelper.NameByValue(messageTag)} Not found dynamic method for the tag! tag: {messageTag};"); switch (messageTag) { @@ -286,13 +287,13 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe // return; default: - _logger.Error($"Server OnReceiveMessage; messageTag not found! messageTag: {messageTag}"); + _logger.Error($"{ConstHelper.NameByValue(messageTag)} Server OnReceiveMessage; messageTag not found!"); break; } } catch (Exception ex) { - _logger.Error($"Server OnReceiveMessage; {ex.Message}", ex); + _logger.Error($"{ConstHelper.NameByValue(messageTag)} Server OnReceiveMessage; {ex.Message}", ex); } await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Error), requestId); @@ -303,7 +304,7 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe protected async Task SendMessageToClient(ISignalRHubItemServer sendTo, int messageTag, ISignalRMessage message, int? requestId = null) { - _logger.Info($"Server SendMessageToClient; {nameof(messageTag)}: {messageTag}; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; UserIdentifier: {Context.UserIdentifier}"); + _logger.Info($"{ConstHelper.NameByValue(messageTag)} Server SendMessageToClient; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; UserIdentifier: {Context.UserIdentifier}"); await sendTo.OnReceiveMessage(messageTag, message.ToMessagePack(ContractlessStandardResolver.Options), requestId); } diff --git a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs index 3873924e..91ed73b4 100644 --- a/TIAMWebApp/Shared/Services/AdminSignalRClient.cs +++ b/TIAMWebApp/Shared/Services/AdminSignalRClient.cs @@ -8,10 +8,17 @@ using AyCode.Services.Loggers; using AyCode.Services.SignalRs; using MessagePack.Resolvers; using Microsoft.AspNetCore.SignalR.Client; +using TIAM.Services; using TIAMWebApp.Shared.Application.Models.ClientSide; using TIAMWebApp.Shared.Application.Utility; namespace TIAMWebApp.Shared.Application.Services { - public class AdminSignalRClient(IEnumerable logWriters) : AcSignalRClientBase($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray())); + public class AdminSignalRClient : AcSignalRClientBase + { + public AdminSignalRClient(IEnumerable logWriters) : base($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray())) + { + ConstHelper.NameByValue(0); + } + } }