From 49ec9009e8248b7931e0c4c9c2f29427932a4bc2 Mon Sep 17 00:00:00 2001 From: WangJunZzz <510423039@qq.com> Date: Sun, 17 Jul 2022 19:00:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=95=20=E8=B0=83=E6=95=B4SignalR?= =?UTF-8?q?=EF=BC=8CRedis=E8=BF=9E=E6=8E=A5=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=80=82#50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...NotificationManagementApplicationModule.cs | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/NotificationManagementApplicationModule.cs b/aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/NotificationManagementApplicationModule.cs index 915ed919..75a9766b 100644 --- a/aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/NotificationManagementApplicationModule.cs +++ b/aspnet-core/modules/NotificationManagement/src/Lion.AbpPro.NotificationManagement.Application/NotificationManagementApplicationModule.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; using Volo.Abp.Application; -using Microsoft.Extensions.Configuration; using Volo.Abp; using Volo.Abp.AspNetCore.SignalR; @@ -22,39 +21,19 @@ namespace Lion.AbpPro.NotificationManagement { context.Services.AddAutoMapperObjectMapper(); Configure(options => { options.AddMaps(validate: true); }); - ConfigurationSignalR(context); } private void ConfigurationSignalR(ServiceConfigurationContext context) { var redisConnection = context.Services.GetConfiguration()["Redis:Configuration"]; - var redisConnectionStringList = redisConnection.Split(',', StringSplitOptions.RemoveEmptyEntries); - if (redisConnectionStringList == null || redisConnectionStringList.Length == 0) - { - throw new UserFriendlyException(message: "Redis连接字符串配置异常"); - } - - var password = string.Empty; - if (redisConnection.Contains("password")) - { - password = redisConnectionStringList[1].Split('=')[1]; - } - var redisDatabaseId = 0; - if (redisConnection.Contains("defaultdatabase")) + if (redisConnection.IsNullOrWhiteSpace()) { - redisDatabaseId = Convert.ToInt32(redisConnectionStringList[2].Split('=')[1]); + throw new UserFriendlyException(message: "Redis连接字符串未配置."); } - - context.Services.AddSignalR().AddStackExchangeRedis(options => - { - options.Configuration.ChannelPrefix = "Lion.AbpPro"; - options.Configuration.DefaultDatabase = redisDatabaseId; - options.Configuration.Password = password; - options.Configuration.EndPoints.Add(redisConnectionStringList[0]); - }); + context.Services.AddSignalR().AddStackExchangeRedis(redisConnection, options => { options.Configuration.ChannelPrefix = "Lion.AbpPro"; }); } } } \ No newline at end of file