Browse Source

Fix unreasonable tenant storage interface implementation

pull/75/head
cKey 5 years ago
parent
commit
e9a088a2ae
  1. 26
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/TenantStore.cs

26
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/TenantStore.cs

@ -39,6 +39,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder
var tenantCacheItem = AsyncHelper.RunSync(async () => await var tenantCacheItem = AsyncHelper.RunSync(async () => await
GetCacheItemByNameAsync(name)); GetCacheItemByNameAsync(name));
if (tenantCacheItem == null)
{
return null;
}
return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name) return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name)
{ {
ConnectionStrings = tenantCacheItem.ConnectionStrings ConnectionStrings = tenantCacheItem.ConnectionStrings
@ -50,6 +55,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder
var tenantCacheItem = AsyncHelper.RunSync(async () => await var tenantCacheItem = AsyncHelper.RunSync(async () => await
GetCacheItemByIdAsync(id)); GetCacheItemByIdAsync(id));
if (tenantCacheItem == null)
{
return null;
}
return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name) return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name)
{ {
ConnectionStrings = tenantCacheItem.ConnectionStrings ConnectionStrings = tenantCacheItem.ConnectionStrings
@ -60,6 +70,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder
{ {
var tenantCacheItem = await GetCacheItemByNameAsync(name); var tenantCacheItem = await GetCacheItemByNameAsync(name);
if (tenantCacheItem == null)
{
return null;
}
return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name) return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name)
{ {
ConnectionStrings = tenantCacheItem.ConnectionStrings ConnectionStrings = tenantCacheItem.ConnectionStrings
@ -70,6 +85,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder
{ {
var tenantCacheItem = await GetCacheItemByIdAsync(id); var tenantCacheItem = await GetCacheItemByIdAsync(id);
if (tenantCacheItem == null)
{
return null;
}
return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name) return new TenantConfiguration(tenantCacheItem.Id, tenantCacheItem.Name)
{ {
ConnectionStrings = tenantCacheItem.ConnectionStrings ConnectionStrings = tenantCacheItem.ConnectionStrings
@ -97,7 +117,8 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder
if (tenant == null) if (tenant == null)
{ {
Logger.LogWarning($"Can not found tenant by id: {id}"); Logger.LogWarning($"Can not found tenant by id: {id}");
throw new AbpException($"Can not found tenant by id: {id}"); // throw new AbpException($"Can not found tenant by id: {id}");
return null;
} }
var connectionStrings = new ConnectionStrings(); var connectionStrings = new ConnectionStrings();
foreach (var tenantConnectionString in tenant.ConnectionStrings) foreach (var tenantConnectionString in tenant.ConnectionStrings)
@ -134,7 +155,8 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder
if (tenant == null) if (tenant == null)
{ {
Logger.LogWarning($"Can not found tenant by name: {name}"); Logger.LogWarning($"Can not found tenant by name: {name}");
throw new AbpException($"Can not found tenant by name: {name}"); // throw new AbpException($"Can not found tenant by name: {name}");
return null;
} }
var connectionStrings = new ConnectionStrings(); var connectionStrings = new ConnectionStrings();
foreach (var tenantConnectionString in tenant.ConnectionStrings) foreach (var tenantConnectionString in tenant.ConnectionStrings)

Loading…
Cancel
Save