Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "ivanosw1"

Hi, I've just update to 5.3.0 Core/Angular. Previously, to obtain User Roles I did:

var userProfile = await _userManager.GetUserByIdAsync(id); await _userManager.AbpStore.UserRepository.EnsureCollectionLoadedAsync(userProfile, u => u.Roles); var roleId = userProfile.Roles.FirstOrDefault()?.RoleId;

Now AbpStore isn't accessibile due to protection level. How Can I get the RoleId, starting from a User ?

Thanks

Hi I have a custom base DbContext, to make it works i am using DefaultDbContextAttribute as suggested here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1119">https://github.com/aspnetboilerplate/as ... ssues/1119</a>. If I use DefaultDbContextAttribute for only one implemented context i got the error: Found more than one concrete type for given DbContext Type. If I use DefaultDbContextAttribute for all implemented context except of only one it works, but i think it's not the expected behavior.

This doesn't work

public abstract class BaseDbContext : AbpDbContext
{
        protected BaseDbContext (DbContextOptions options) : base(options)
        {
        }
}
[DefaultDbContextAttribute]
public class SecurityContext : BaseDbContext 
{
    public SecurityContext(DbContextOptions<SecurityContext> options) : base(options)
     {
     }
}
public class TestContext : BaseDbContext 
{
    public NuovoContext(DbContextOptions<TestContext > options) : base(options)
    {
    }
}
public class AdtContext : BaseDbContext 
{
    public AdtContext(DbContextOptions options) : base(options)
    {
    }
}

This works and use SecurityContext when BaseDbContext is needed

public abstract class BaseDbContext : AbpDbContext
{
        protected BaseDbContext (DbContextOptions options) : base(options)
        {
        }
}
public class SecurityContext : BaseDbContext 
{
    public SecurityContext(DbContextOptions<SecurityContext> options) : base(options)
     {
     }
}
[DefaultDbContextAttribute]
public class TestContext : BaseDbContext 
{
    public NuovoContext(DbContextOptions<TestContext > options) : base(options)
    {
    }
}
[DefaultDbContextAttribute]
public class AdtContext : BaseDbContext 
{
    public AdtContext(DbContextOptions options) : base(options)
    {
    }
}

Is It right to add DefaultDbContextAttribute to all new DbContext thats inherits from BaseDbContext ?

Hi, I've create the code to implement an External Authentication module. What I don't realize is how to call from a client this different authentication system. I need to use both ways: the default abpTables and this new one. I've tried to call by "api/TokenAuth/ExternalAuthenticate/" but I receive the error: Unknown external auth provider: MyAuth

public class MyAuthExternalAuthenticationSource: DefaultExternalAuthenticationSource<Tenant,User>, ITransientDependency
   {
       public override Task<bool> TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword, Tenant tenant)
       {
           return Task.FromResult(true);
       }

       public override string Name => "MyAuth";
   }
}
public override void PreInitialize()
        {
                     Configuration.Modules.Zero().UserManagement.ExternalAuthenticationSources.Add<MyAuthExternalAuthenticationSource>();
         
        }

What I'm missing? Thanks

Hi, I need to use two different dbcontext at same request to fill out a dto. One dbcontext use the default Abp database where I have Host and all Tenants. The other dbcontext needs read and write a second database in order to collect additional data but in the same client request. In addition, every tenant has his own second database and so the connection string changes at runtime. None of the solutions I've tried works.

When the second context is created, the ExistingConnection is not null but I can't change it and I can't open a new one one the same transaction.

How can I achieve my requirement ?

public override void PreInitialize()
        {
           // Default Context on Abp Database
            Configuration.Modules.AbpEfCore().AddDbContext<AdtContext>(options =>
            {

                if (options.ExistingConnection != null)
                {
                    AdtConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                }
                else
                {
                    AdtConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                }
            });

             // Second Db Context on different database that change for every Tenant
            Configuration.Modules.AbpEfCore().AddDbContext<AdtLegacyContext>(options =>
             {

                 if (options.ExistingConnection != null)
                 {
                     AdtLegacyConfigurer.Configure(options.DbContextOptions, options.ExistingConnection);
                 }
                 else
                 {
                     AdtLegacyConfigurer.Configure(options.DbContextOptions, options.ConnectionString);
                 }
             });

        }

The configurers:

public class AdtConfigurer
    {
        private const string MigrationTableName = "__AdtMigrationsHistory";
        private const string MigrationTableSchema = "adt";

        //https://github.com/aspnet/EntityFrameworkCore/issues/2180
        public static void Configure(DbContextOptionsBuilder<AdtContext> builder, string connectionString)
        {
            builder.UseSqlServer(connectionString, o =>
                o.MigrationsHistoryTable(MigrationTableName, MigrationTableSchema)
                    .UseRowNumberForPaging());

        }

        public static void Configure(DbContextOptionsBuilder<AdtContext> builder, DbConnection connection)
        {
            builder.UseSqlServer(connection, o =>
                o.MigrationsHistoryTable(MigrationTableName, MigrationTableSchema)
                    .UseRowNumberForPaging());
        }

    }


public class AdtLegacyConfigurer
    {
        private const string MigrationTableName = "__AdtMigrationsHistory";
        private const string MigrationTableSchema = "adt";

        //https://github.com/aspnet/EntityFrameworkCore/issues/2180
        //Quando l'issue viene risolta si può togliere UseRowNumberForPaging

        public static void Configure(DbContextOptionsBuilder<AdtLegacyContext> builder, string connectionString)
        {
            builder.UseSqlServer(connectionString, o =>
                o.MigrationsHistoryTable(MigrationTableName, MigrationTableSchema)
                .UseRowNumberForPaging());
            
        }

        public static void Configure(DbContextOptionsBuilder<AdtLegacyContext> builder, DbConnection connection)
        {
            builder.UseSqlServer(connection, o => 
                o.MigrationsHistoryTable(MigrationTableName, MigrationTableSchema)
                .UseRowNumberForPaging());
        }
    }

The Default Context (All dataset omitted for brevity)

public class AdtContext: AbpDbContext
    {
        public DbSet<AuditData> Audits { get; set; }

        public AdtContext(DbContextOptions options) : base(options)
        {
            
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ApplyConfiguration(new AuditConfiguration());
        }
    }

The second context (All dataset omitted for brevity):

public class AdtLegacyContext : AbpDbContext
    {
       
        private readonly ILegacyConnectionStringService _legacyConnectionStrings;

        public AdtLegacyContext(DbContextOptions options, ILegacyConnectionStringService legacyConnectionStrings) : base(options)
        {
          
            _legacyConnectionStrings = legacyConnectionStrings;
        }

        public DbSet<TrcAnagraficaData> TrcAnagrafiche { get; set; }
        .......

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var tenantId = AbpSession.GetTenantId();
            var connectionString = _legacyConnectionStrings.GetConnectionString(tenantId);  // <-- This resolve the connection string for tenant
            optionsBuilder.UseSqlServer(connectionString);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ApplyConfiguration(new TrcAnagraficaConfiguration());
           ......
        
        }
    }

Thank you.

Hi, the [DisableAuditing] attribute doesn't work if when my AppService implements AsyncCrudAppService. How can I disable the auditing?

Thanks

Hi, I suspect that the "scope" meaning of Feature is ignored. If I set a new feature with scope FeatureScopes.Edition, it is assignable to Tenant as well (Default Angular UI)

From docs:

Scope: A value in the FeatureScopes enum. It can be Edition (if this feature can be set only for edition level), Tenant (if this feature can be set only for tenant level) or All (if this feature can be set for editions and tenants, where a tenant setting overrides its edition's setting). Default value is All.

Is an obsolete settings? I've noted that in downloaded code you don't use scope nowhere (AppFeatures.MaxUserCount, AppFeatures.TestCheckFeature, and so on)

Hi, I've the same requirement as this topic [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10262]) but with default repository.

I've a context but I don't need a custom repository and so "override int SaveChanges()" is not raised on my context. How can I catch DbUpdateConcurrencyException on default repository to show a UserFriendlyException?

Thank you.

Hi, I'm using DDD and in my class that inherits AggregateRoot I use DomaniEvents:

DomainEvents.Add(new CambioCredenzialiEventData(){Email = email});

and the relative handler:

public class CambioCredenzialiEventHandler : IEventHandler<CambioCredenzialiEventData>, ITransientDependency
    {
        public void HandleEvent(CambioCredenzialiEventData eventData){
          ...........
           }
}

In Module Initizialize assembly is registered with

IocManager.RegisterAssemblyByConvention(typeof(MyDomainModule).Assembly);

When the ApplicationService ends his work and repository save the data, nothing happens and the EventHandler is not called. But if I use the EventBus in the ApplicationService, the handler is called.

EventBus.Trigger(new CambioCredenzialiEventData() { Email = input.Email });

Note that if I check MyClass.DomainEvents.Count the result is 1 as expected; What I'm missing to work with DomainEvents ?

Thank you

Hi, I've created a generic interface with implementation:

public interface IAggregateRepository<T, in TPrimaryKey> : ITransientDependency where T : IAggregateRoot
...

public class ConfigurazioneRepository : IAggregateRepository<Configurazione,long>
....

When I try to inject IAggragateRoot<Configurazione, long>, Castle says that it has dependencies to be satisfied and is waiting for the following dependencies.

But if I register it manually it works.

IocManager.Register<IAggregateRepository<Configurazione, long>, ConfigurazioneRepository>(DependencyLifeStyle.Transient);

The question is: how can I register a generic interface like IRepository<T> ?

Thanks

Question

Hi, I'm trying to migrate my module tests to 5.0.4 Core 2 & Angular. Module porting was sucessfull and works, but I've some problems to migrate test. Can you give me some clarifications about testing new plugin module? The error is :

Castle.MicroKernel.Handlers.HandlerException : Can't create component 'Uno.DossierSanitario.Application.DossierSanitarioAppService' as it has dependencies to be satisfied.

'Uno.DossierSanitario.Application.DossierSanitarioAppService' is waiting for the following dependencies:
- Service 'Uno.DossierSanitario.EntityFramework.Repositories.DossierRepository' which was registered but is also waiting for dependencies.
'Uno.DossierSanitario.EntityFramework.Repositories.DossierRepository' is waiting for the following dependencies:
- Service 'Abp.EntityFrameworkCore.IDbContextProvider`1[[Uno.DossierSanitario.EntityFramework.EntityFramework.DossierSanitarioContext, Uno.DossierSanitario.EntityFramework, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
- Service 'Abp.Domain.Repositories.IRepository`1[[Uno.DossierSanitario.Core.WriteModel.StateTypeData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
- Service 'Abp.Domain.Repositories.IRepository`2[[Uno.DossierSanitario.Core.ReferenceModel.ProfileData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
- Service 'Abp.Domain.Repositories.IRepository`2[[Uno.DossierSanitario.Core.ReferenceModel.OrganizationUnitData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
- Service 'Abp.Domain.Repositories.IRepository`1[[Uno.DossierSanitario.Core.WriteModel.StateData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
- Service 'Abp.Domain.Repositories.IRepository`1[[Uno.DossierSanitario.Core.WriteModel.WorkspaceData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
- Service 'Abp.Domain.Repositories.IRepository`1[[Uno.DossierSanitario.Core.WriteModel.StateTypeData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
- Service 'Uno.DossierSanitario.Core.DossierDossierIdGenerator' which was registered but is also waiting for dependencies.
'Uno.DossierSanitario.Core.DossierDossierIdGenerator' is waiting for the following dependencies:
- Service 'Abp.Domain.Repositories.IRepository`1[[Uno.DossierSanitario.Core.WriteModel.DossierData, Uno.DossierSanitario.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.

   at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
   at Castle.Windsor.WindsorContainer.Resolve[T]()
   at Uno.DossierSanitario.Tests.DossierSanitarioTests..ctor() in c:\Uno\Production\Development\Development\Uno.2017\Products\Uno.DossierSanitario.Abp\test\Uno.DossierSanitario.Tests\DossierSanitarioTests.cs:line 23

Thanks

Showing 31 to 40 of 59 entries