This commit is contained in:
Adam 2024-07-01 20:01:39 +02:00
commit 8517864be4
4 changed files with 31 additions and 18 deletions

View File

@ -31,6 +31,7 @@ public class Transfer: IEntityGuid, IAcFullName, ITimeStampInfo, IProductForeign
public string? PaymentId { get; set; } public string? PaymentId { get; set; }
//public virtual UserProductMapping? UserProductMapping { get; set; } //public virtual UserProductMapping? UserProductMapping { get; set; }
[JsonIgnore] [JsonIgnore]
[Newtonsoft.Json.JsonIgnore] [Newtonsoft.Json.JsonIgnore]
public virtual List<TransferToDriver> TransferToDrivers { get; set; } = []; public virtual List<TransferToDriver> TransferToDrivers { get; set; } = [];

View File

@ -1,4 +1,5 @@
using AyCode.Services.SignalRs; using AyCode.Services.SignalRs;
using System.Reflection;
namespace TIAM.Services; namespace TIAM.Services;
@ -10,9 +11,9 @@ public class SignalRTags : AcSignalRTags
public const int GetTransfersByDriverId = 4; public const int GetTransfersByDriverId = 4;
public const int GetTransfersByProductId = 5; public const int GetTransfersByProductId = 5;
public const int GetTransfersByCompanyId = 6; public const int GetTransfersByCompanyId = 6;
public const int GetTransfersByFilterText = 301; public const int GetTransfersByFilterText = 301;
public const int UpdateTransfer = 7; public const int UpdateTransfer = 7;
public const int AddTransfer = 8; public const int AddTransfer = 8;
public const int RemoveTransfer = 9; public const int RemoveTransfer = 9;
@ -36,13 +37,16 @@ public class SignalRTags : AcSignalRTags
public const int RemoveTransferToDriver = 28; public const int RemoveTransferToDriver = 28;
public const int GetAddress = 29; public const int GetAddress = 29;
//public const int GetAddresses = 30; //public const int GetAddresses = 30;
public const int GetAddressesByContextId = 31; public const int GetAddressesByContextId = 31;
public const int UpdateAddress = 32; public const int UpdateAddress = 32;
//public const int AddAddress = 33; //public const int AddAddress = 33;
//public const int RemoveAddress = 34; //public const int RemoveAddress = 34;
public const int GetProfileById = 35; public const int GetProfileById = 35;
//public const int GetProfiles = 36; //public const int GetProfiles = 36;
//public const int GetProfileByContextId = 37; //public const int GetProfileByContextId = 37;
public const int UpdateProfile = 38; public const int UpdateProfile = 38;
@ -53,11 +57,11 @@ public class SignalRTags : AcSignalRTags
public const int CreateUserProductMapping = 40; public const int CreateUserProductMapping = 40;
public const int UpdateUserProductMapping = 41; public const int UpdateUserProductMapping = 41;
public const int DeleteUserProductMapping = 42; //set permissions to 0 public const int DeleteUserProductMapping = 42; //set permissions to 0
public const int GetAllUserProductMappings = 43; public const int GetAllUserProductMappings = 43;
public const int GetUserProductMappingsByProductId = 44; public const int GetUserProductMappingsByProductId = 44;
public const int GetUserProductMappingsByUserId = 45; public const int GetUserProductMappingsByUserId = 45;
public const int GetUserProductMappingById = 46; public const int GetUserProductMappingById = 46;
public const int GetUserProductMappingsById = 47; public const int GetUserProductMappingsById = 47;
public const int GetCarsForUserProductMapping = 50; public const int GetCarsForUserProductMapping = 50;
public const int CreateCar = 51; public const int CreateCar = 51;
@ -86,7 +90,7 @@ public class SignalRTags : AcSignalRTags
public const int CreateTransferDestination = 82; public const int CreateTransferDestination = 82;
public const int UpdateTransferDestination = 83; public const int UpdateTransferDestination = 83;
public const int RemoveTransferDestination = 84; //set permissions to 0 public const int RemoveTransferDestination = 84; //set permissions to 0
public const int CreateTransferDestinationToProduct = 90; public const int CreateTransferDestinationToProduct = 90;
public const int UpdateTransferDestinationToProduct = 91; public const int UpdateTransferDestinationToProduct = 91;
public const int RemoveTransferDestinationToProduct = 92; //set permissions to 0 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 GetTransferDestinationToProductsByTransferDestinationId = 96;
public const int GetAllLogItemsByFilterText = 100; public const int GetAllLogItemsByFilterText = 100;
} }

View File

@ -18,6 +18,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq.Expressions; using System.Linq.Expressions;
using AutoMapper; using AutoMapper;
using AyCode.Core.Helpers;
using DevExpress.Pdf.Native.BouncyCastle.Security; using DevExpress.Pdf.Native.BouncyCastle.Security;
using TIAM.Entities.Emails; using TIAM.Entities.Emails;
using TIAM.Services.Server; using TIAM.Services.Server;
@ -138,7 +139,8 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
public async Task OnReceiveMessage(int messageTag, byte[]? message, int? requestId) 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 tagName = ConstHelper.NameByValue<SignalRTags>(messageTag);
var logText = $"Server OnReceiveMessage; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; {tagName}";
if (message is { Length: 0 }) _logger.Warning($"message.Length == 0! {logText}"); if (message is { Length: 0 }) _logger.Warning($"message.Length == 0! {logText}");
else _logger.Info(logText); else _logger.Info(logText);
@ -151,11 +153,11 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
object[]? paramValues = null; object[]? paramValues = null;
logText = $"Found dynamic method for the tag! tag: {messageTag}; method: {methodsByDeclaringObject.InstanceObject.GetType().Name}.{methodInfoModel.MethodInfo.Name}"; logText = $"Found dynamic method for the tag! method: {methodsByDeclaringObject.InstanceObject.GetType().Name}.{methodInfoModel.MethodInfo.Name}";
if (methodInfoModel.ParamInfos is { Length: > 0 }) if (methodInfoModel.ParamInfos is { Length: > 0 })
{ {
_logger.Debug($"{logText}({string.Join(", ", methodInfoModel.ParamInfos.Select(x => x.Name))})"); _logger.Debug($"{logText}({string.Join(", ", methodInfoModel.ParamInfos.Select(x => x.Name))}); {tagName}");
paramValues = new object[methodInfoModel.ParamInfos.Length]; paramValues = new object[methodInfoModel.ParamInfos.Length];
@ -207,14 +209,14 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
} }
else paramValues[0] = message!.MessagePackTo<SignalPostJsonDataMessage<object>>(MessagePackSerializerOptions.Standard).PostDataJson.JsonTo(firstParamType)!; else paramValues[0] = message!.MessagePackTo<SignalPostJsonDataMessage<object>>(MessagePackSerializerOptions.Standard).PostDataJson.JsonTo(firstParamType)!;
} }
else _logger.Debug($"{logText}()"); else _logger.Debug($"{logText}(); {tagName}");
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, methodInfoModel.MethodInfo.InvokeMethod(methodsByDeclaringObject.InstanceObject, paramValues)), requestId); await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, methodInfoModel.MethodInfo.InvokeMethod(methodsByDeclaringObject.InstanceObject, paramValues)), requestId);
return; return;
} }
_logger.Debug($"Not found dynamic method for the tag! tag: {messageTag};"); _logger.Debug($"Not found dynamic method for the tag! {tagName}");
switch (messageTag) switch (messageTag)
{ {
@ -286,13 +288,13 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
// return; // return;
default: default:
_logger.Error($"Server OnReceiveMessage; messageTag not found! messageTag: {messageTag}"); _logger.Error($"Server OnReceiveMessage; messageTag not found! {tagName}");
break; break;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error($"Server OnReceiveMessage; {ex.Message}", ex); _logger.Error($"Server OnReceiveMessage; {ex.Message}; {tagName}", ex);
} }
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Error), requestId); await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Error), requestId);
@ -303,7 +305,7 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
protected async Task SendMessageToClient(ISignalRHubItemServer sendTo, int messageTag, ISignalRMessage message, int? requestId = null) 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($"Server SendMessageToClient; {nameof(requestId)}: {requestId}; ConnectionId: {Context.ConnectionId}; {ConstHelper.NameByValue<SignalRTags>(messageTag)}");
await sendTo.OnReceiveMessage(messageTag, message.ToMessagePack(ContractlessStandardResolver.Options), requestId); await sendTo.OnReceiveMessage(messageTag, message.ToMessagePack(ContractlessStandardResolver.Options), requestId);
} }

View File

@ -8,10 +8,17 @@ using AyCode.Services.Loggers;
using AyCode.Services.SignalRs; using AyCode.Services.SignalRs;
using MessagePack.Resolvers; using MessagePack.Resolvers;
using Microsoft.AspNetCore.SignalR.Client; using Microsoft.AspNetCore.SignalR.Client;
using TIAM.Services;
using TIAMWebApp.Shared.Application.Models.ClientSide; using TIAMWebApp.Shared.Application.Models.ClientSide;
using TIAMWebApp.Shared.Application.Utility; using TIAMWebApp.Shared.Application.Utility;
namespace TIAMWebApp.Shared.Application.Services namespace TIAMWebApp.Shared.Application.Services
{ {
public class AdminSignalRClient(IEnumerable<IAcLogWriterClientBase> logWriters) : AcSignalRClientBase($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray())); public class AdminSignalRClient : AcSignalRClientBase
{
public AdminSignalRClient(IEnumerable<IAcLogWriterClientBase> logWriters) : base($"{Setting.BaseUrl}/DevAdminHub", new LoggerClient(nameof(AdminSignalRClient), logWriters.ToArray()))
{
ConstHelper.NameByValue<SignalRTags>(0);
}
}
} }