Browse Source

Merge branch 'main' into 11427-Order-Managment

pull/92/head
malik masis 5 years ago
parent
commit
30267768a9
  1. 8
      README.md
  2. 12
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs
  3. 32
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/DbMigrations/AdministrationServiceDatabaseMigrationEventHandler.cs
  4. 9
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs
  5. 26
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationEventHandler.cs
  6. 2
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs
  7. 30
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationEventHandler.cs
  8. 9
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs
  9. 29
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs
  10. 4
      services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs
  11. 21
      services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs
  12. 3
      services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs
  13. 12
      shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/EfCore/DatabaseEfCoreMigrationEventHandler.cs
  14. 19
      shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/DatabaseMongoDbMigrationEventHandler.cs
  15. 1
      shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj
  16. 10
      shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs

8
README.md

@ -30,7 +30,13 @@ You can either run in Visual Studio, or using [Microsoft Tye](https://github.com
- Wait until all applications are up!
- You can check running application from tye dashboard ([localhost:8000](http://127.0.0.1:8000/))
- You can check running application from tye dashboard ([localhost:8000](http://127.0.0.1:8000/))
- **Note**: If you see all of your applications keep restarting on tye dashboard or tye console, you may be facing ssl certificate issues. To diagnose the problems better, check any application logs. If it is related with SSL, developer certificate creation may have failed because of powershell issues regarding authorization. Check the powershell script running configuration and set policy for your local machine as:
```bash
Get-ExecutionPolicy list
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
```
See [Microsoft Powershell documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy?view=powershell-7.2) for more information.
- After all your backend services are up, start the angular application:

12
services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/AdministrationServiceHttpApiHostModule.cs

@ -1,22 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.AdministrationService.DbMigrations;
using EShopOnAbp.AdministrationService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices;
using Medallion.Threading;
using Medallion.Threading.Redis;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy;
using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.AdministrationService;

32
services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/DbMigrations/AdministrationServiceDatabaseMigrationEventHandler.cs

@ -1,10 +1,13 @@
using EShopOnAbp.AdministrationService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Serilog;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
@ -13,7 +16,7 @@ using Volo.Abp.Uow;
namespace EShopOnAbp.AdministrationService.DbMigrations
{
public class AdministrationServiceDatabaseMigrationEventHandler
: DatabaseEfCoreMigrationEventHandler<AdministrationServiceDbContext>,
: DatabaseEfCoreMigrationEventHandler<AdministrationServiceDbContext>,
IDistributedEventHandler<TenantCreatedEto>,
IDistributedEventHandler<ApplyDatabaseMigrationsEto>
{
@ -26,13 +29,16 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
ITenantStore tenantStore,
IPermissionDefinitionManager permissionDefinitionManager,
IPermissionDataSeeder permissionDataSeeder,
IDistributedEventBus distributedEventBus
IDistributedEventBus distributedEventBus,
IAbpDistributedLock distributedLockProvider
) : base(
currentTenant,
unitOfWorkManager,
tenantStore,
distributedEventBus,
AdministrationServiceDbProperties.ConnectionStringName)
AdministrationServiceDbProperties.ConnectionStringName,
distributedLockProvider
)
{
_permissionDefinitionManager = permissionDefinitionManager;
_permissionDataSeeder = permissionDataSeeder;
@ -47,8 +53,16 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
try
{
var schemaMigrated = await MigrateDatabaseSchemaAsync(eventData.TenantId);
await SeedDataAsync(eventData.TenantId);
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
Log.Information("AdministrationService acquired lock for db migration and seeding...");
if (handle != null)
{
await MigrateDatabaseSchemaAsync(eventData.TenantId);
await SeedDataAsync(eventData.TenantId);
}
}
}
catch (Exception ex)
{
@ -61,6 +75,7 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
try
{
await MigrateDatabaseSchemaAsync(eventData.Id);
Logger.LogInformation("Starting AdministrationService DataSeeder...");
await SeedDataAsync(eventData.Id);
}
catch (Exception ex)
@ -82,7 +97,8 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
var permissionNames = _permissionDefinitionManager
.GetPermissions()
.Where(p => p.MultiTenancySide.HasFlag(multiTenancySide))
.Where(p => !p.Providers.Any() || p.Providers.Contains(RolePermissionValueProvider.ProviderName))
.Where(p => !p.Providers.Any() ||
p.Providers.Contains(RolePermissionValueProvider.ProviderName))
.Select(p => p.Name)
.ToArray();
@ -98,4 +114,4 @@ namespace EShopOnAbp.AdministrationService.DbMigrations
}
}
}
}
}

9
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs

@ -1,24 +1,21 @@
using EShopOnAbp.CatalogService.DbMigrations;
using EShopOnAbp.CatalogService.Grpc;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.Grpc;
using EShopOnAbp.CatalogService.MongoDB;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
namespace EShopOnAbp.CatalogService;

26
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationEventHandler.cs

@ -1,8 +1,10 @@
using System;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.MongoDb;
using System;
using System.Threading.Tasks;
using Serilog;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
@ -18,13 +20,16 @@ namespace EShopOnAbp.CatalogService.DbMigrations
IUnitOfWorkManager unitOfWorkManager,
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
IServiceProvider serviceProvider
IServiceProvider serviceProvider,
IAbpDistributedLock distributedLockProvider
) : base(
currentTenant,
unitOfWorkManager,
tenantStore,
distributedEventBus,
CatalogServiceDbProperties.ConnectionStringName,serviceProvider)
CatalogServiceDbProperties.ConnectionStringName,
serviceProvider,
distributedLockProvider)
{
}
@ -42,7 +47,16 @@ namespace EShopOnAbp.CatalogService.DbMigrations
try
{
await MigrateDatabaseSchemaAsync(null);
Log.Information("CatalogService has acquired lock for db migration...");
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if (handle != null)
{
Log.Information("CatalogService is migrating database...");
await MigrateDatabaseSchemaAsync(null);
}
}
}
catch (Exception ex)
{

2
services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs

@ -8,7 +8,7 @@ namespace EShopOnAbp.CatalogService.MongoDB
[ConnectionStringName(CatalogServiceDbProperties.ConnectionStringName)]
public class CatalogServiceMongoDbContext : AbpMongoDbContext, ICatalogServiceMongoDbContext
{
public IMongoCollection<Product> Questions => Collection<Product>();
public IMongoCollection<Product> Products => Collection<Product>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{

30
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDatabaseMigrationEventHandler.cs

@ -10,6 +10,7 @@ using Volo.Abp.EventBus.Local;
using Volo.Abp.Identity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
using Volo.Abp.DistributedLocking;
namespace EShopOnAbp.IdentityService.DbMigrations
{
@ -29,13 +30,15 @@ namespace EShopOnAbp.IdentityService.DbMigrations
IIdentityDataSeeder identityDataSeeder,
IdentityServerDataSeeder identityServerDataSeeder,
IDistributedEventBus distributedEventBus,
ILocalEventBus localEventBus
ILocalEventBus localEventBus,
IAbpDistributedLock distributedLockProvider
) : base(
currentTenant,
unitOfWorkManager,
tenantStore,
distributedEventBus,
IdentityServiceDbProperties.ConnectionStringName)
IdentityServiceDbProperties.ConnectionStringName,
distributedLockProvider)
{
_identityDataSeeder = identityDataSeeder;
_identityServerDataSeeder = identityServerDataSeeder;
@ -51,12 +54,22 @@ namespace EShopOnAbp.IdentityService.DbMigrations
try
{
var schemaMigrated = await MigrateDatabaseSchemaAsync(eventData.TenantId);
await SeedDataAsync(
tenantId: eventData.TenantId,
adminEmail: IdentityServiceDbProperties.DefaultAdminEmailAddress,
adminPassword: IdentityServiceDbProperties.DefaultAdminPassword
);
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
Log.Information("IdentityService has acquired lock for db migration...");
if (handle != null)
{
Log.Information("IdentityService is migrating database...");
await MigrateDatabaseSchemaAsync(eventData.TenantId);
Log.Information("IdentityService is seeding data...");
await SeedDataAsync(
tenantId: eventData.TenantId,
adminEmail: IdentityServiceDbProperties.DefaultAdminEmailAddress,
adminPassword: IdentityServiceDbProperties.DefaultAdminPassword
);
}
}
await _localEventBus.PublishAsync(new ApplyDatabaseSeedsEto());
}
@ -64,7 +77,6 @@ namespace EShopOnAbp.IdentityService.DbMigrations
{
await HandleErrorOnApplyDatabaseMigrationAsync(eventData, ex);
}
}
public async Task HandleEventAsync(TenantCreatedEto eventData)

9
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/IdentityServiceHttpApiHostModule.cs

@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.IdentityService.DbMigrations;
using EShopOnAbp.IdentityService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.AspNetCore;
@ -12,9 +8,12 @@ using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.IdentityService;

29
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs

@ -1,9 +1,10 @@
using EShopOnAbp.OrderingService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using System;
using System.Threading.Tasks;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Microsoft.Extensions.Logging;
using Serilog;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
@ -15,18 +16,21 @@ namespace EShopOnAbp.OrderingService.DbMigrations
IDistributedEventHandler<ApplyDatabaseMigrationsEto>
{
private readonly IDataSeeder _dataSeeder;
public OrderingServiceDatabaseMigrationEventHandler(
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
IDataSeeder dataSeeder)
IDistributedEventBus distributedEventBus,
IDataSeeder dataSeeder,
IAbpDistributedLock distributedLockProvider)
: base(
currentTenant,
unitOfWorkManager,
tenantStore,
distributedEventBus,
OrderingServiceDbProperties.ConnectionStringName)
OrderingServiceDbProperties.ConnectionStringName,
distributedLockProvider)
{
_dataSeeder = dataSeeder;
}
@ -45,9 +49,18 @@ namespace EShopOnAbp.OrderingService.DbMigrations
try
{
await MigrateDatabaseSchemaAsync(null);
Logger.LogInformation("Starting OrderingService DataSeeder...");
await _dataSeeder.SeedAsync();
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
Log.Information("OrderingService has acquired lock for db migration...");
if (handle != null)
{
Log.Information("OrderingService is migrating database...");
await MigrateDatabaseSchemaAsync(null);
Log.Information("OrderingService is seeding data...");
await _dataSeeder.SeedAsync();
}
}
}
catch (Exception ex)
{

4
services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs

@ -4,17 +4,16 @@ using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.OrderingService;
@ -22,6 +21,7 @@ namespace EShopOnAbp.OrderingService;
typeof(OrderingServiceHttpApiModule),
typeof(OrderingServiceApplicationModule),
typeof(OrderingServiceEntityFrameworkCoreModule),
//typeof(MedallionAbpDistributedLock),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
public class OrderingServiceHttpApiHostModule : AbpModule

21
services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs

@ -1,8 +1,10 @@
using EShopOnAbp.PaymentService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using System;
using System.Threading.Tasks;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore;
using Serilog;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
@ -17,13 +19,15 @@ namespace EShopOnAbp.PaymentService.DbMigrations
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus)
IDistributedEventBus distributedEventBus,
IAbpDistributedLock distributedLockProvider)
: base(
currentTenant,
unitOfWorkManager,
tenantStore,
distributedEventBus,
PaymentServiceDbProperties.ConnectionStringName)
PaymentServiceDbProperties.ConnectionStringName,
distributedLockProvider)
{
}
@ -41,7 +45,16 @@ namespace EShopOnAbp.PaymentService.DbMigrations
try
{
await MigrateDatabaseSchemaAsync(null);
Log.Information("PaymentService has acquired lock for db migration...");
await using (var handle = await DistributedLockProvider.TryAcquireAsync(DatabaseName))
{
if (handle != null)
{
Log.Information("PaymentService is migrating database...");
await MigrateDatabaseSchemaAsync(null);
}
}
}
catch (Exception ex)
{

3
services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs

@ -4,16 +4,15 @@ using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Volo.Abp;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
namespace EShopOnAbp.PaymentService;

12
shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/EfCore/DatabaseEfCoreMigrationEventHandler.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Medallion.Threading;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@ -9,6 +10,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using Serilog;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EventBus.Distributed;
@ -29,19 +31,23 @@ public abstract class DatabaseEfCoreMigrationEventHandler<TDbContext> : Database
protected IDistributedEventBus DistributedEventBus { get; }
protected ILogger<DatabaseEfCoreMigrationEventHandler<TDbContext>> Logger { get; set; }
protected string DatabaseName { get; }
protected IAbpDistributedLock DistributedLockProvider { get; }
protected DatabaseEfCoreMigrationEventHandler(
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
string databaseName)
string databaseName,
IAbpDistributedLock distributedLockProvider
)
{
CurrentTenant = currentTenant;
UnitOfWorkManager = unitOfWorkManager;
TenantStore = tenantStore;
DatabaseName = databaseName;
DistributedEventBus = distributedEventBus;
DistributedLockProvider = distributedLockProvider;
Logger = NullLogger<DatabaseEfCoreMigrationEventHandler<TDbContext>>.Instance;
}
@ -76,6 +82,7 @@ public abstract class DatabaseEfCoreMigrationEventHandler<TDbContext> : Database
if (tenantId == null)
{
//Migrating the host database
Log.Information($"There is no tenant. Migrating {DatabaseName}...");
result = await MigrateDatabaseSchemaWithDbContextAsync();
}
else
@ -85,6 +92,7 @@ public abstract class DatabaseEfCoreMigrationEventHandler<TDbContext> : Database
!tenantConfiguration.ConnectionStrings.GetOrDefault(DatabaseName).IsNullOrWhiteSpace())
{
//Migrating the tenant database (only if tenant has a separate database)
Log.Information($"Migrating tenant database:{DatabaseName} with tenantId:{tenantId}...");
result = await MigrateDatabaseSchemaWithDbContextAsync();
}
}
@ -126,7 +134,7 @@ public abstract class DatabaseEfCoreMigrationEventHandler<TDbContext> : Database
var tryCount = IncrementEventTryCount(eventData);
if (tryCount <= MaxEventTryCount)
{
Logger.LogWarning(
Log.Warning(
$"Could not perform tenant created event. Re-queueing the operation. TenantId = {eventData.Id}, TenantName = {eventData.Name}.");
Logger.LogException(exception, LogLevel.Warning);

19
shared/EShopOnAbp.Shared.Hosting.Microservices/DbMigrations/MongoDb/DatabaseMongoDbMigrationEventHandler.cs

@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MongoDB;
@ -27,16 +27,20 @@ public abstract class DatabaseMongoDbMigrationEventHandler<TDbContext> : Databas
protected ITenantStore TenantStore { get; }
protected IDistributedEventBus DistributedEventBus { get; }
protected ILogger<DatabaseMongoDbMigrationEventHandler<TDbContext>> Logger { get; set; }
protected IServiceProvider ServiceProvider { get; }
protected string DatabaseName { get; }
protected IAbpDistributedLock DistributedLockProvider { get; }
protected DatabaseMongoDbMigrationEventHandler(
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
ITenantStore tenantStore,
IDistributedEventBus distributedEventBus,
string databaseName, IServiceProvider serviceProvider)
string databaseName,
IServiceProvider serviceProvider,
IAbpDistributedLock distributedLockProvider
)
{
CurrentTenant = currentTenant;
UnitOfWorkManager = unitOfWorkManager;
@ -44,6 +48,7 @@ public abstract class DatabaseMongoDbMigrationEventHandler<TDbContext> : Databas
DatabaseName = databaseName;
ServiceProvider = serviceProvider;
DistributedEventBus = distributedEventBus;
DistributedLockProvider = distributedLockProvider;
Logger = NullLogger<DatabaseMongoDbMigrationEventHandler<TDbContext>>.Instance;
}

1
shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbp.Shared.Hosting.Microservices.csproj

@ -9,6 +9,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DistributedLock.Redis" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />

10
shared/EShopOnAbp.Shared.Hosting.Microservices/EShopOnAbpSharedHostingMicroservicesModule.cs

@ -1,5 +1,7 @@
using EShopOnAbp.AdministrationService.EntityFrameworkCore;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using Medallion.Threading;
using Medallion.Threading.Redis;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
@ -26,7 +28,6 @@ namespace EShopOnAbp.Shared.Hosting.Microservices
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
Configure<AbpMultiTenancyOptions>(options =>
{
@ -42,6 +43,13 @@ namespace EShopOnAbp.Shared.Hosting.Microservices
context.Services
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "EShopOnAbp-Protection-Keys");
context.Services.AddSingleton<IDistributedLockProvider>(sp =>
{
var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
return new RedisDistributedSynchronizationProvider(connection.GetDatabase());
});
}
}
}
Loading…
Cancel
Save