From 767a5b20fc7425fab083b80fab4e831e036d7a18 Mon Sep 17 00:00:00 2001 From: "jozsef.b@aycode.com" <9Rj@D}fVwBaN> Date: Thu, 30 May 2024 12:49:29 +0200 Subject: [PATCH] AddResponseCompression... --- .../SysAdmins/ManageServiceProviders.razor | 5 ++- TIAMWebApp/Server/Program.cs | 34 ++++++++----------- .../Shared/Services/AcSignalRClientBase.cs | 16 +++++++-- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor index 03b4af78..1081b90a 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor @@ -308,13 +308,12 @@ Company resultCompany = null; if (e.IsNew) { - //add new orderData to orderData array - _logger.Info("New orderData added"); + _logger.Info("New company adding"); resultCompany = await serviceProviderDataService.CreateServiceProviderAsync((Company)e.EditModel); } else { - _logger.Info("orderData updated at id " + ((Company)e.EditModel).Id); + _logger.Info("company updating at id " + ((Company)e.EditModel).Id); resultCompany = await serviceProviderDataService.UpdateServiceProviderAsync((Company)e.EditModel); diff --git a/TIAMWebApp/Server/Program.cs b/TIAMWebApp/Server/Program.cs index 0ebd8edb..490a9dd9 100644 --- a/TIAMWebApp/Server/Program.cs +++ b/TIAMWebApp/Server/Program.cs @@ -148,22 +148,16 @@ builder.WebHost.ConfigureKestrel((context, options) => }); }); -//builder.Services.AddResponseCompression(options => -//{ -// options.EnableForHttps = true; -// options.Providers.Add(); -// options.Providers.Add(); -//}); +builder.Services.AddResponseCompression(options => +{ + options.EnableForHttps = true; + options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "application/octet-stream" }); + options.Providers.Add(); + options.Providers.Add(); +}); -//builder.Services.Configure(options => -//{ -// options.Level = CompressionLevel.Optimal; -//}); - -//builder.Services.Configure(options => -//{ -// options.Level = CompressionLevel.Optimal; -//}); +builder.Services.Configure(options => options.Level = CompressionLevel.Optimal); +builder.Services.Configure(options => options.Level = CompressionLevel.Optimal); var app = builder.Build(); @@ -178,6 +172,11 @@ else app.UseHsts(); } +//if (!app.Environment.IsDevelopment()) +{ + app.UseResponseCompression(); +} + app.UseSwagger(); app.UseSwaggerUI(c => { @@ -197,11 +196,6 @@ app.MapRazorPages(); app.MapControllers(); app.MapBlazorHub(); -//if (!app.Environment.IsDevelopment()) -{ - //app.UseResponseCompression(); -} - app.MapHub("/TiamChatHub"); app.MapHub("/TiamLoggerHub"); app.MapHub("/DevAdminHub"); diff --git a/TIAMWebApp/Shared/Services/AcSignalRClientBase.cs b/TIAMWebApp/Shared/Services/AcSignalRClientBase.cs index e9e19336..4620251b 100644 --- a/TIAMWebApp/Shared/Services/AcSignalRClientBase.cs +++ b/TIAMWebApp/Shared/Services/AcSignalRClientBase.cs @@ -41,7 +41,12 @@ namespace TIAMWebApp.Shared.Application.Services HubConnection = new HubConnectionBuilder() .WithUrl($"{Setting.BaseUrl}/{hubName}") - //.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData)) + //.AddMessagePackProtocol(options => { + // options.SerializerOptions = MessagePackSerializerOptions.Standard + // .WithResolver(MessagePack.Resolvers.StandardResolver.Instance) + // .WithSecurity(MessagePackSecurity.UntrustedData) + // .WithCompression(MessagePackCompression.Lz4Block) + // .WithCompressionMinLength(256);}) .Build(); HubConnection.Closed += HubConnection_Closed; @@ -131,8 +136,13 @@ namespace TIAMWebApp.Shared.Application.Services { if (responseMessage.Status == SignalResponseStatus.Error || responseMessage.ResponseData == null) { - Logger.Error($"Client SendMessageToServerAsync response error; await; tag: {messageTag}; Status: {responseMessage.Status}; requestId: {requestId};"); - return default; + var errorText = $"Client SendMessageToServerAsync response error; await; tag: {messageTag}; Status: {responseMessage.Status}; requestId: {requestId};"; + + Logger.Error(errorText); + + //TODO: Ideiglenes, majd a ResponseMessage-et kell visszaadni a Status miatt! - J. + throw new Exception(errorText); + //return default; } return responseMessage.ResponseData.JsonTo();