Browse Source

regular changes

pull/65/head
cKey 5 years ago
parent
commit
e0923c0a16
  1. 39
      aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml
  2. 13
      aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs
  3. 56
      aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPExecutionFailedException.cs
  4. 9
      aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs
  5. 40
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs
  6. 40
      aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs
  7. 5
      aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs

39
aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml

@ -121,6 +121,45 @@
</summary>
<param name="context"></param>
</member>
<member name="T:LINGYUN.Abp.EventBus.CAP.AbpCAPExecutionFailedException">
<summary>
AbpECAPExecutionFailedException
</summary>
</member>
<member name="P:LINGYUN.Abp.EventBus.CAP.AbpCAPExecutionFailedException.MessageType">
<summary>
MessageType
</summary>
</member>
<member name="P:LINGYUN.Abp.EventBus.CAP.AbpCAPExecutionFailedException.Origin">
<summary>
Message
</summary>
</member>
<member name="M:LINGYUN.Abp.EventBus.CAP.AbpCAPExecutionFailedException.#ctor(DotNetCore.CAP.Messages.MessageType,DotNetCore.CAP.Messages.Message)">
<summary>
constructor
</summary>
<param name="messageType"></param>
<param name="prigin"></param>
</member>
<member name="M:LINGYUN.Abp.EventBus.CAP.AbpCAPExecutionFailedException.#ctor(DotNetCore.CAP.Messages.MessageType,DotNetCore.CAP.Messages.Message,System.String)">
<summary>
constructor
</summary>
<param name="messageType"></param>
<param name="prigin"></param>
<param name="message"></param>
</member>
<member name="M:LINGYUN.Abp.EventBus.CAP.AbpCAPExecutionFailedException.#ctor(DotNetCore.CAP.Messages.MessageType,DotNetCore.CAP.Messages.Message,System.String,System.Exception)">
<summary>
constructor
</summary>
<param name="messageType"></param>
<param name="prigin"></param>
<param name="message"></param>
<param name="innerException"></param>
</member>
<member name="T:LINGYUN.Abp.EventBus.CAP.CAPDistributedEventBus">
<summary>
CAP分布式事件总线

13
aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPEventBusModule.cs

@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.BackgroundWorkers;
using Volo.Abp.EventBus;
using Volo.Abp.ExceptionHandling;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.EventBus.CAP
@ -27,6 +28,18 @@ namespace LINGYUN.Abp.EventBus.CAP
{
configuration.GetSection("CAP:EventBus").Bind(options);
context.Services.ExecutePreConfiguredActions(options);
//if (options.FailedThresholdCallback == null)
//{
// options.FailedThresholdCallback = async (failed) =>
// {
// var exceptionNotifier = failed.ServiceProvider.GetService<IExceptionNotifier>();
// if (exceptionNotifier != null)
// {
// // TODO: 作为异常处理?
// await exceptionNotifier.NotifyAsync(new AbpCAPExecutionFailedException(failed.MessageType, failed.Message));
// }
// };
//}
});
}

56
aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/AbpCAPExecutionFailedException.cs

@ -0,0 +1,56 @@
using DotNetCore.CAP.Messages;
using System;
using Volo.Abp;
namespace LINGYUN.Abp.EventBus.CAP
{
/// <summary>
/// AbpECAPExecutionFailedException
/// </summary>
public class AbpCAPExecutionFailedException : AbpException
{
/// <summary>
/// MessageType
/// </summary>
public MessageType MessageType { get; set; }
/// <summary>
/// Message
/// </summary>
public Message Origin { get; set; }
/// <summary>
/// constructor
/// </summary>
/// <param name="messageType"></param>
/// <param name="prigin"></param>
public AbpCAPExecutionFailedException(MessageType messageType, Message prigin)
{
MessageType = messageType;
Origin = prigin;
}
/// <summary>
/// constructor
/// </summary>
/// <param name="messageType"></param>
/// <param name="prigin"></param>
/// <param name="message"></param>
public AbpCAPExecutionFailedException(MessageType messageType, Message prigin, string message) : base(message)
{
MessageType = messageType;
Origin = prigin;
}
/// <summary>
/// constructor
/// </summary>
/// <param name="messageType"></param>
/// <param name="prigin"></param>
/// <param name="message"></param>
/// <param name="innerException"></param>
public AbpCAPExecutionFailedException(MessageType messageType, Message prigin, string message, Exception innerException) : base(message, innerException)
{
MessageType = messageType;
Origin = prigin;
}
}
}

9
aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs

@ -92,10 +92,11 @@ namespace LINGYUN.Abp.SettingManagement
continue;
}
if (!setting.IsVisibleToClients)
{
continue;
}
// 既然是配置服务,那必须能管理所有配置才对
//if (!setting.IsVisibleToClients)
//{
// continue;
//}
var settingValue = await SettingManager.GetOrNullAsync(setting.Name, providerName, providerKey);
var settingInfo = new SettingDto

40
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantCreateEventHandler.cs

@ -1,4 +1,6 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@ -12,6 +14,7 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
{
public class TenantCreateEventHandler : IDistributedEventHandler<EntityCreatedEto<TenantEto>>, ITransientDependency
{
private readonly ILogger<TenantCreateEventHandler> _logger;
private readonly ICurrentTenant _currentTenant;
private readonly ITenantRepository _tenantRepository;
private readonly IDistributedCache<TenantConfigurationCacheItem> _cache;
@ -19,9 +22,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
public TenantCreateEventHandler(
ICurrentTenant currentTenant,
ITenantRepository tenantRepository,
ILogger<TenantCreateEventHandler> logger,
IDistributedCache<TenantConfigurationCacheItem> cache)
{
_cache = cache;
_logger = logger;
_currentTenant = currentTenant;
_tenantRepository = tenantRepository;
}
@ -29,22 +34,29 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
[UnitOfWork]
public virtual async Task HandleEventAsync(EntityCreatedEto<TenantEto> eventData)
{
using (_currentTenant.Change(null))
try
{
var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
if (tenant == null)
using (_currentTenant.Change(null))
{
return;
}
var connectionStrings = new ConnectionStrings();
foreach (var tenantConnectionString in tenant.ConnectionStrings)
{
connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
}
var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
if (tenant == null)
{
return;
}
var connectionStrings = new ConnectionStrings();
foreach (var tenantConnectionString in tenant.ConnectionStrings)
{
connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
}
var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
}
}
catch (Exception ex)
{
_logger.LogException(ex);
}
}
}

40
aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN/Abp/MultiTenancy/DbFinder/EventBus/Distributed/TenantUpdateEventHandler.cs

@ -1,4 +1,6 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@ -12,6 +14,7 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
{
public class TenantUpdateEventHandler : IDistributedEventHandler<EntityUpdatedEto<TenantEto>>, ITransientDependency
{
private readonly ILogger<TenantUpdateEventHandler> _logger;
private readonly ICurrentTenant _currentTenant;
private readonly ITenantRepository _tenantRepository;
private readonly IDistributedCache<TenantConfigurationCacheItem> _cache;
@ -19,9 +22,11 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
public TenantUpdateEventHandler(
ICurrentTenant currentTenant,
ITenantRepository tenantRepository,
ILogger<TenantUpdateEventHandler> logger,
IDistributedCache<TenantConfigurationCacheItem> cache)
{
_cache = cache;
_logger = logger;
_currentTenant = currentTenant;
_tenantRepository = tenantRepository;
}
@ -29,22 +34,29 @@ namespace LINGYUN.Abp.MultiTenancy.DbFinder.EventBus.Distributed
[UnitOfWork]
public virtual async Task HandleEventAsync(EntityUpdatedEto<TenantEto> eventData)
{
using (_currentTenant.Change(null))
try
{
var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
if (tenant == null)
using (_currentTenant.Change(null))
{
return;
}
var connectionStrings = new ConnectionStrings();
foreach (var tenantConnectionString in tenant.ConnectionStrings)
{
connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
}
var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
var tenant = await _tenantRepository.FindAsync(eventData.Entity.Id, true);
if (tenant == null)
{
return;
}
var connectionStrings = new ConnectionStrings();
foreach (var tenantConnectionString in tenant.ConnectionStrings)
{
connectionStrings[tenantConnectionString.Name] = tenantConnectionString.Value;
}
var cacheItem = new TenantConfigurationCacheItem(tenant.Id, tenant.Name, connectionStrings);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
var cacheKey = TenantConfigurationCacheItem.CalculateCacheKey(eventData.Entity.Id.ToString());
await _cache.SetAsync(cacheKey, cacheItem);
}
}
catch(Exception ex)
{
_logger.LogException(ex);
}
}
}

5
aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.cs

@ -1,4 +1,5 @@
using DotNetCore.CAP;
using DotNetCore.CAP.Internal;
using IdentityModel;
using LINGYUN.Abp.Domain.Entities.Events;
using LINGYUN.Abp.EventBus.CAP;
@ -121,7 +122,7 @@ namespace LINGYUN.Platform
Configure<AbpExceptionHandlingOptions>(options =>
{
// 加入需要处理的异常类型
options.Handlers.Add<AbpException>();
options.Handlers.Add<AbpCAPExecutionFailedException>();
});
// 自定义需要发送邮件通知的异常类型
Configure<AbpEmailExceptionHandlingOptions>(options =>
@ -131,7 +132,7 @@ namespace LINGYUN.Platform
// 未指定异常接收者的默认接收邮件
options.DefaultReceiveEmail = "colin.in@foxmail.com";
// 指定某种异常发送到哪个邮件
options.HandReceivedException<AbpException>("colin.in@foxmail.com");
options.HandReceivedException<AbpCAPExecutionFailedException>("colin.in@foxmail.com");
});
Configure<AbpDistributedCacheOptions>(options =>

Loading…
Cancel
Save