You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
using Microsoft.Extensions.Logging;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.DistributedLocking;
|
|
using Volo.Abp.EntityFrameworkCore.Migrations;
|
|
using Volo.Abp.EventBus.Distributed;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.Uow;
|
|
|
|
namespace LINGYUN.Abp.MicroService.AdminService;
|
|
public class AdminServiceDbMigrationEventHandler : EfCoreDatabaseMigrationEventHandlerBase<AdminServiceMigrationsDbContext>
|
|
{
|
|
protected AdminServiceDataSeeder DataSeeder { get; }
|
|
|
|
public AdminServiceDbMigrationEventHandler(
|
|
ICurrentTenant currentTenant,
|
|
IUnitOfWorkManager unitOfWorkManager,
|
|
ITenantStore tenantStore,
|
|
IAbpDistributedLock abpDistributedLock,
|
|
IDistributedEventBus distributedEventBus,
|
|
ILoggerFactory loggerFactory,
|
|
AdminServiceDataSeeder dataSeeder)
|
|
: base(
|
|
ConnectionStringNameAttribute.GetConnStringName<AdminServiceMigrationsDbContext>(),
|
|
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory)
|
|
{
|
|
DataSeeder = dataSeeder;
|
|
}
|
|
|
|
protected async override Task AfterTenantCreated(TenantCreatedEto eventData, bool schemaMigrated)
|
|
{
|
|
// 新租户数据种子
|
|
var context = new DataSeedContext(eventData.Id);
|
|
if (eventData.Properties != null)
|
|
{
|
|
foreach (var property in eventData.Properties)
|
|
{
|
|
context.WithProperty(property.Key, property.Value);
|
|
}
|
|
}
|
|
|
|
await DataSeeder.SeedAsync(context);
|
|
}
|
|
}
|
|
|