Starts in:
2 DAYS
11 HRS
10 MIN
37 SEC
Starts in:
2 D
11 H
10 M
37 S

Activities of "lalitChougule"

Hi @maliming

Now I am able to debug the code, now the issue is I am not able to get Database name here I am able to get connection string but not able to get database name. I have 4 connection string for each tenant

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

  • Component I need to override
  • How do I add field or list of connection string to DTO

Service level

  • Which method in TenantAppService I need to override as none of the method in TenantAppService is with name ApplyDatabaseMigrations
  • How do I add extra properties for modules connection strings in abp's DTO
  • ABP Framework version: v4.3.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no / yes
  • Exception message and stack trace: N.A
  • Steps to reproduce the issue:" N.A

Hi,

When I click on the Apply database migration in image 1, I only get message as per image 2 and image 3 shows the network tab

Now, I have created an Event Handler like below, but none of the below methods executes. Debugger also hit on these methods.

public class XYZServiceDatabaseMigrationEventHandler : IDistributedEventHandler<TenantCreatedEto>,
        IDistributedEventHandler<TenantConnectionStringUpdatedEto>,
        IDistributedEventHandler<ApplyDatabaseMigrationsEto>
    {
        public async Task HandleEventAsync(TenantCreatedEto eventData)
        {
            //Some code
        }

        public async Task HandleEventAsync(TenantConnectionStringUpdatedEto eventData)
        {
            //Some code
        }

        public async Task HandleEventAsync(ApplyDatabaseMigrationsEto eventData)
        {
            //Some code
        }
    }

Hi @enisn,

Can't we use TenantSettingValueProvider ? This is also a kind of setting manager right ?

  • ABP Framework version: v4.3.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no / yes
  • Exception message and stack trace: N.A
  • Steps to reproduce the issue:" N.A

Hi,

I have multitenant microservice application. appsettings details are different for each tenant. I wish not to maintain a appsettings file or if I have to then I have to maintain only common settings there. But my other tenant related settings should come from database.

How do I achieve this , any suggestions ?

  • ABP Framework version: v4.3.1
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no / yes
  • Exception message and stack trace: N.A
  • Steps to reproduce the issue:" N.A

Hi,

My requirement is similar to this ticket : https://support.abp.io/QA/Questions/1087/DbMigrator-for-multi-tenant--multi-db

But I can't see any resolution on this ticket. Please can you help me with it.

Also If you can answer below question it will be helpful

  1. This is the end point api/saas/tenants/3a03440a-5d0e-e4e2-4fa5-c40c2671b8fe/apply-database-migrations. I was not able to find the actual app service method it belongs to on git hub, please give me the name of this app service.
  2. Will I be able to override the above service ?
  3. How do I add multiple connection string ( i,e, per module ) from UI i.e. Saas Tenant screen where we create a Tenant and give the connection string. My project have 3 custom module, So I have 1 database for Admin/Abp/IdentityServer and other 3 for 3 different modules
Showing 21 to 30 of 132 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06