Activities of "alkaabi"

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

I want to set a 30 minutes timeout when the user is idle. The user has to renter his credentials after 30 minutes if he isn't using the application.

Answer

Hi,

I am activating through someting called ObjectDataSourceProvider. I dont really know about the implemenation details of that class and how the service get registered. That class comes part of Devexpress Reporting suite. To get an idea od how this is done, I will share their example of how they are doing it with standard ASP .Net Core App and EF Core:

https://github.com/DevExpress-Examples/Reporting-Entity-Framework-Core-In-AspNet-Core

I would appreciate if you could guide me how to inetgrate this with Abp using Abp infrastructure.

Thanks

Answer

I have created another another db context provider which inherits from Abp db context provider :

 public interface IScopedDbContextProvider<TDbContext> : 
        IDbContextProvider<TDbContext> where TDbContext: IEfCoreDbContext
 {
 }

    public class ScopedDbContextProvider<TDbContext> : 
        UnitOfWorkDbContextProvider<TDbContext>, IScopedDbContextProvider<TDbContext> where TDbContext : IEfCoreDbContext
  {
        public ScopedDbContextProvider(IUnitOfWorkManager unitOfWorkManager,
            IConnectionStringResolver connectionStringResolver,
            ICancellationTokenProvider cancellationTokenProvider,
            ICurrentTenant currentTenant,
            IOptions<AbpDbContextOptions> options) :base(
                unitOfWorkManager,
                connectionStringResolver,
                cancellationTokenProvider,
                currentTenant,
                options)
  {

  }

Then I registered the provider as a siglton

context.Services.TryAddSingleton(typeof(IScopedDbContextProvider<>), typeof(ScopedDbContextProvider<>));

Then I created custom repository and I used that new IScopedDbContextProvider in the repository

 public class RepPersonRepository : EfCoreRepository<JundDbContext, Person, Guid>, IRepPersonRepository
    {
        public RepPersonRepository(IScopedDbContextProvider<JundDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }
    }

Then I used the repository inside a regular Abp Application Service

 public class ReportingDataSourceService: ApplicationService, IReportingDataSourceService
    {
        private readonly IRepPersonRepository _personRepository;
        public ReportingDataSourceService()
        {
            // We use this parameterless constructor in the Data Source Wizard only, and not for the actual instantiation of the repository object.
            throw new NotSupportedException();
        }
        public ReportingDataSourceService(IRepPersonRepository perosnRepository)
        {
            _personRepository = perosnRepository;
        }

        public  IList<PersonDetailsDto> GetAllPeople()
        {

            return ObjectMapper.Map<IList<Person>, IList<PersonDetailsDto>>(
                _personRepository.WithDetailsAsync(
                    p => p.Rank,
                    p => p.ServiceNumberPrefix,
                    p => p.BirthLocation,
                    p => p.ContactAddresses
                ).Result.ToList());

        }
}

Whenever I call the endpoint using swagger UI, everything works fine and I get the result but when I set the service as datasource for the report I get this error:

All Objects have been disposed from repository as shown below

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

I am using a third-party reporting tool in our Abp application which uses a repository as its datsource. The repository's lifetime exceeds the lifetime of the HTTP request that creates the repository. Whenever I use the dafualt Abp repositories, an exception occures saying that services has been already disposed. This is because (I think) I am trying to use dbcontext beyond request liftime. As far as as I know, Abp registers dbcontext as transient lifetime dependency by default using IDbContextProvider provider.

Any idea how to create another db context provider similar to Abp but with a scoped liftime dependency so I can use the repository outisde the http request context ?

yes, I did..

It was a silly mistake. In Host project App Setting file, there is an entry for AuthServer which had the wrong IP address (localhost). I entered the correct ip address and everything worked fine.

Hi @GregB

Check baseUrl in envronemnt.prod.ts in Angular Client

Hi @gvnuysal,

Thanks for your response. I did what you did without luck. In fact, I prevoisly modified IdentityServerClientRedirectUris table to include the angular client url but did not work. I have also modified ClientUri just like you said without luck. I have wasted too many hours trying to figure out what is wrong.

Hi,

I hosted the following on a sepearte IIS website (diffrent machines)

1- Api.Host project using publish menu in VS (running under https) 2- IdentityServer project using publish menu in VS (running under https) 3- angular client (runnning under http)

I have also changed Cors Oirgin urls in app settings to match Angular Client IIS addresses

Hi,

Our production server are not connected to the internet. However, I made a smilar environemnt and hosted the apps on IIS and I still get the same problem.

How can you you help remotely ?? Via which app ?? Remote Desktop ?

Here is a screenshot of identity logs. NO error is shown

Showing 1 to 10 of 19 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09