From 6bca7d45bfc02c487c0737da6de447ba87424430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 21 Mar 2021 18:16:23 +0300 Subject: [PATCH] Fix module deps. --- .../EventHub.BackgroundServices.csproj | 12 ++++++--- .../EventHubBackgroundServicesModule.cs | 19 +++++++++++++- .../appsettings.json | 21 ++++++++++++++- .../EventHubHttpApiHostModule.cs | 26 ++++++++++++------- .../EventHubIdentityServerModule.cs | 11 +++----- src/EventHub.Web/EventHubWebModule.cs | 16 +++++------- 6 files changed, 72 insertions(+), 33 deletions(-) diff --git a/src/EventHub.BackgroundServices/EventHub.BackgroundServices.csproj b/src/EventHub.BackgroundServices/EventHub.BackgroundServices.csproj index 5793ab8..833fdd5 100644 --- a/src/EventHub.BackgroundServices/EventHub.BackgroundServices.csproj +++ b/src/EventHub.BackgroundServices/EventHub.BackgroundServices.csproj @@ -6,11 +6,17 @@ Exe net5.0 EventHub + EventHub-4681b4fd-151f-4221-84a4-929d86723e4c - + + + + + + @@ -19,6 +25,7 @@ + @@ -28,7 +35,4 @@ - - - diff --git a/src/EventHub.BackgroundServices/EventHubBackgroundServicesModule.cs b/src/EventHub.BackgroundServices/EventHubBackgroundServicesModule.cs index 923993c..d3d9ff2 100644 --- a/src/EventHub.BackgroundServices/EventHubBackgroundServicesModule.cs +++ b/src/EventHub.BackgroundServices/EventHubBackgroundServicesModule.cs @@ -1,16 +1,23 @@ using EventHub.Events; +using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using StackExchange.Redis; using Volo.Abp; using Volo.Abp.Autofac; using Volo.Abp.BackgroundWorkers; +using Volo.Abp.Caching; +using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.Modularity; namespace EventHub { [DependsOn( - typeof(AbpAutofacModule) + typeof(AbpAutofacModule), + typeof(AbpBackgroundWorkersModule), + typeof(EventHubDomainModule), + typeof(AbpCachingStackExchangeRedisModule) )] public class EventHubBackgroundServicesModule : AbpModule { @@ -20,6 +27,16 @@ namespace EventHub var hostEnvironment = context.Services.GetSingletonInstance(); context.Services.AddHostedService(); + + Configure(options => + { + options.KeyPrefix = "EventHub:"; + }); + + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/src/EventHub.BackgroundServices/appsettings.json b/src/EventHub.BackgroundServices/appsettings.json index d177980..cebcafb 100644 --- a/src/EventHub.BackgroundServices/appsettings.json +++ b/src/EventHub.BackgroundServices/appsettings.json @@ -1,3 +1,22 @@ { - + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=EventHub;Trusted_Connection=True" + }, + "Redis": { + "Configuration": "127.0.0.1" + }, + "StringEncryption": { + "DefaultPassPhrase": "TxVIZFPxK33czbbv" + }, + "Settings": { + "Abp.Mailing.Smtp.Host": "127.0.0.1", + "Abp.Mailing.Smtp.Port": "25", + "Abp.Mailing.Smtp.UserName": "", + "Abp.Mailing.Smtp.Password": "", + "Abp.Mailing.Smtp.Domain": "", + "Abp.Mailing.Smtp.EnableSsl": "false", + "Abp.Mailing.Smtp.UseDefaultCredentials": "true", + "Abp.Mailing.DefaultFromAddress": "noreply@abp.io", + "Abp.Mailing.DefaultFromDisplayName": "ABP application" + } } diff --git a/src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs b/src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs index b6f9e30..6548222 100644 --- a/src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs +++ b/src/EventHub.HttpApi.Host/EventHubHttpApiHostModule.cs @@ -19,6 +19,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; +using Volo.Abp.BackgroundJobs; using Volo.Abp.Caching; using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.Localization; @@ -52,9 +53,18 @@ namespace EventHub ConfigureLocalization(); ConfigureCache(configuration); ConfigureVirtualFileSystem(context); - ConfigureRedis(context, configuration, hostingEnvironment); + ConfigureRedis(context, configuration); ConfigureCors(context, configuration); ConfigureSwaggerServices(context, configuration); + ConfigureBackgroundJobs(); + } + + private void ConfigureBackgroundJobs() + { + Configure(options => + { + options.IsJobExecutionEnabled = false; + }); } private void ConfigureCache(IConfiguration configuration) @@ -142,16 +152,12 @@ namespace EventHub private void ConfigureRedis( ServiceConfigurationContext context, - IConfiguration configuration, - IWebHostEnvironment hostingEnvironment) + IConfiguration configuration) { - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); - } + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); } private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) diff --git a/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs b/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs index 5f4c9e1..65f1825 100644 --- a/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs +++ b/src/EventHub.IdentityServer/EventHubIdentityServerModule.cs @@ -113,13 +113,10 @@ namespace EventHub options.KeyPrefix = "EventHub:"; }); - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); - } + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); context.Services.AddCors(options => { diff --git a/src/EventHub.Web/EventHubWebModule.cs b/src/EventHub.Web/EventHubWebModule.cs index 6bb8dbc..08b8b65 100644 --- a/src/EventHub.Web/EventHubWebModule.cs +++ b/src/EventHub.Web/EventHubWebModule.cs @@ -69,7 +69,7 @@ namespace EventHub.Web ConfigureBundles(); ConfigureCache(configuration); - ConfigureRedis(context, configuration, hostingEnvironment); + ConfigureRedis(context, configuration); ConfigureUrls(configuration); ConfigureAuthentication(context, configuration); ConfigureAutoMapper(); @@ -186,16 +186,12 @@ namespace EventHub.Web private void ConfigureRedis( ServiceConfigurationContext context, - IConfiguration configuration, - IWebHostEnvironment hostingEnvironment) + IConfiguration configuration) { - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - context.Services - .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); - } + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + context.Services + .AddDataProtection() + .PersistKeysToStackExchangeRedis(redis, "EventHub-Protection-Keys"); } public override void OnApplicationInitialization(ApplicationInitializationContext context)