Where is the
override
keyword?
This is the code from Saas Module
[Authorize(SaasHostPermissions.Tenants.ManageConnectionStrings)]
public async Task ApplyDatabaseMigrationsAsync(Guid id)
{
await DistributedEventBus.PublishAsync(
new ApplyDatabaseMigrationsEto
{
TenantId = id,
DatabaseName = ConnectionStrings.DefaultConnectionStringName
}
);
foreach (var databaseInfo in DbConnectionOptions.Databases.Values)
{
if (!databaseInfo.IsUsedByTenants)
{
continue;
}
await DistributedEventBus.PublishAsync(
new ApplyDatabaseMigrationsEto
{
TenantId = id,
DatabaseName = databaseInfo.DatabaseName
}
);
}
}
ApplyDatabaseMigrationsAsync
method is not virtual so we cannot override it
Hi,
I tired overriding TenantAppService , code as below :
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
using Volo.Saas.Editions;
using Volo.Saas.Host;
using Volo.Saas.Host.Dtos;
using Volo.Saas.Tenants;
namespace SCV.Litmus.LitmusTenants
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(ITenantAppService), typeof(TenantAppService))]
public class CustomTenantAppService : TenantAppService, ITenantAppService
{
protected IEditionRepository EditionRepository { get; }
protected IDataSeeder DataSeeder { get; }
protected IDistributedEventBus DistributedEventBus { get; }
protected ITenantRepository TenantRepository { get; }
protected ITenantManager TenantManager { get; }
protected AbpDbConnectionOptions DbConnectionOptions { get; }
public CustomTenantAppService(
ITenantRepository tenantRepository,
IEditionRepository editionRepository,
ITenantManager tenantManager,
IDataSeeder dataSeeder,
IDistributedEventBus distributedEventBus,
IOptions<AbpDbConnectionOptions> dbConnectionOptions)
: base(tenantRepository,
editionRepository,
tenantManager,
dataSeeder,
distributedEventBus,
dbConnectionOptions)
{
EditionRepository = editionRepository;
DataSeeder = dataSeeder;
DistributedEventBus = distributedEventBus;
DbConnectionOptions = dbConnectionOptions.Value;
TenantRepository = tenantRepository;
TenantManager = tenantManager;
}
public async Task ApplyDatabaseMigrationsAsync(Guid id)
{
await DistributedEventBus.PublishAsync(
new ApplyDatabaseMigrationsEto
{
TenantId = id,
DatabaseName = ConnectionStrings.DefaultConnectionStringName
}
);
foreach (var databaseInfo in DbConnectionOptions.Databases.Values)
{
if (!databaseInfo.IsUsedByTenants)
{
continue;
}
await DistributedEventBus.PublishAsync(
new ApplyDatabaseMigrationsEto
{
TenantId = id,
DatabaseName = databaseInfo.DatabaseName
}
);
}
}
}
}
My swagger is showing error now as below :
Log:
2022-05-19 18:22:36.176 +05:30 [ERR] An unhandled exception has occurred while executing the request.
Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Conflicting method/path combination "POST api/app/custom-tenant/{id}/apply-database-migrations" for actions - SCV.Litmus.LitmusTenants.CustomTenantAppService.ApplyDatabaseMigrationsAsync (SCV.Litmus.Application),SCV.Litmus.LitmusTenants.CustomTenantAppService.ApplyDatabaseMigrationsAsync (SCV.Litmus.Application). Actions require a unique method/path combination for Swagger/OpenAPI 3.0. Use ConflictingActionsResolver as a workaround
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at SCV.Litmus.LitmusHttpApiHostModule.<>c.<<OnApplicationInitialization>b__9_0>d.MoveNext() in D:\Litmus\Projects\multi-tenancy\SCV.Litmus\aspnet-core\gateways\SCV.Litmus.HttpApi.Host\LitmusHttpApiHostModule.cs:line 217
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Also If you can give advice me on adding 3 new string properties in SaasTenantCreateDto
which I want to Insert into SaasTenantConnectionStrings
table.
Please answer both of my queries. Thanks !!!
Hi mailming
This is TenantAppService source code https://github.com/abpframework/abp/blob/4.3.1/modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/TenantAppService.cs
There are no events published here Also there is no method called ApplyDatabaseMigrations in this AppService.
Please can you guide us with sample code or something as this activity is on priority for us.
Hi still not working with ITransientDependency
Hi **@maliming **
How do I Custom the app service and Angular UI I need few details : Angular
Service level
Hi @enisn,
Can't we use TenantSettingValueProvider
?
This is also a kind of setting manager right ?
Is there any answer for this question ?
@albert Please reply.
I was able to validate user credentitals using await _signInManager.CheckPasswordSignInAsync()
Now I just want to know below things, This is angular login component code
login(params: LoginParams): Observable<any>; Which backend method is called when the above method is called from angular component ?
May be I can make a wrapper method and call this backend login method in my method once I done with my requirement.
import { Injector } from '@angular/core';
import { Params } from '@angular/router';
import { Observable } from 'rxjs';
import { LoginParams } from '../strategies/auth-flow.strategy';
import * as ɵngcc0 from '@angular/core';
export declare class AuthService {
protected injector: Injector;
private strategy;
get isInternalAuth(): boolean;
constructor(injector: Injector);
init(): Promise<any>;
logout(queryParams?: Params): Observable<any>;
/**
* @deprecated Use navigateToLogin method instead. To be deleted in v5.0
*/
initLogin(): void;
navigateToLogin(queryParams?: Params): void;
login(params: LoginParams): Observable<any>;
static ɵfac: ɵngcc0.ɵɵFactoryDef<AuthService, never>;
}
Can you share a simple project?
No I can't.Sorry May be we can have a section and you can have a look into my project.