Is it possible to override an AppService and modify its logic without rewriting the entire module?
Yes, of course you can, for example:
[ExposeServices(typeof(ITenantAppService))]
[Dependency(ReplaceServices = true)]
public class MyTenantAppService : TenantAppService
{
public MyTenantAppService(ITenantRepository tenantRepository, IEditionRepository editionRepository, ITenantManager tenantManager, IDataSeeder dataSeeder, IDistributedEventBus distributedEventBus, IOptions<AbpDbConnectionOptions> dbConnectionOptions, IConnectionStringChecker connectionStringChecker) : base(tenantRepository, editionRepository, tenantManager, dataSeeder, distributedEventBus, dbConnectionOptions, connectionStringChecker)
{
}
public override Task<SaasTenantDto> CreateAsync(SaasTenantCreateDto input)
{
input.ConnectionStrings = new SaasTenantConnectionStringsDto
{
Databases = new List<SaasTenantDatabaseConnectionStringsDto>
{
new SaasTenantDatabaseConnectionStringsDto {
ConnectionString = "...",
DatabaseName = "Default"
}
}
};
return base.CreateAsync(input);
}
}
Hi,
Because you have the source code, you can modify the source code directly.
For exmaple, add a method to IFileDescriptorRepository
to get all items by filter:
public virtual async Task<List<FileDescriptor>> GetAllListAsync(
string filter = null,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Name.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? FileDescriptorConsts.DefaultSorting : sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
And use it in the appservice.
Hi,
Could you share the full app logs? thanks
Hi,
I can reproduce the problem, I will check it.
We isolated the problem to a small change we recently made. We changed the APB setting value of the mail send from address (Abp.Mailing.DefaultFromAddress) to a new value. This single change caused the exception. When we revert the send from mail address to its original value, everything works as expected.
You mean that after reverting the change, the PasswordResetLinkSet
page will not be automatically redirected, right?
I checked the source code, page does not contain automatic redirection code, have you customized the page?
BTW, could you provide a test email to me? I want to test it. thanks
Hi,
Could you share a project that can reproduce the problem with me? I will check it out. shiwei.liang@volosoft.com
You can replace the IGuidGenerator
service.
For example:
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IGuidGenerator))]
public class MyGuidGenerator : IGuidGenerator, ITransientDependency
{
public virtual Guid Create()
{
return Guid.NewGuid();
}
}
You need to use the DisableIdGenerationAttribute
3.
For example:
public class MyEntity : AggregateRoot<Guid>
{
[DisableIdGeneration]
public override Guid Id { get; protected set; }
}