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

Activities of "adamphones"

This is an issue we encounter when parent component is a modal and child component is table that it needs to send request to get its data.

Full error AbpValidationException: Method arguments are not valid! See ValidationErrors for details.\r\nThe following errors were detected during validation.\r\n - The field MaxResultCount must be between 1 and 2147483647

This issue easily can be replicated:

<div appBsModal #editModal="bs-modal" (onShown)="onShown()" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true" [config]="{ backdrop: 'static', keyboard: !saving }" > <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-body"> <tabset class="nav-line-tabs nav-line-tabs-2x border-transparent fs-5 flex-nowrap"> <tab heading="Grid Data" class="p-5"> <grid-data #gridData [Id]= "Id" </grid-data> </tab> </tabset> </div> <div class="modal-footer"> ... </div> </form> </div> </div> </div>

GridDataComponent.ts

`import { Component, Injector, ViewChild, Input } from '@angular/core'; import { Table } from 'primeng/table'; import { Paginator } from 'primeng/paginator'; import { LazyLoadEvent } from 'primeng/api/lazyloadevent'; import { map as _map, filter as _filter, find as _find } from 'lodash-es';

import { AppComponentBase } from '@shared/common/app-component-base'; import { FileDownloadService } from '@shared/utils/file-download.service'; import { GridDataServiceProxy } from '@shared/service-proxies/service-proxies'; import { DateTime } from 'luxon';

@Component({ selector: 'grid-data', templateUrl: './grid-data.component.html', }) export class GridDataComponent extends AppComponentBase { @ViewChild('dataTable', { static: true }) dataTable: Table; @ViewChild('paginator', { static: true }) paginator: Paginator;

advancedFiltersAreShown = false; filterText = ''; maxEffectiveFromFilter: DateTime; minEffectiveFromFilter: DateTime; constructor( injector: Injector, private _gridDataProxy: GridDataServiceProxy ) { super(injector); } get Id(): number { return this._id; }

@Input() set Id(value: number) { this._id = value; this.getGridData(); }

getGridData(event?: LazyLoadEvent) { if (!this._id) { return; }

if (this.primengTableHelper.shouldResetPaging(event)) {
        this.paginator.changePage(0);

        if (this.primengTableHelper.records && this.primengTableHelper.records.length > 0) {
            return;
        }
    }

    this.primengTableHelper.showLoadingIndicator();

this._gridDataProxy
  .getData(
    this.filterText,
    this.maxEffectiveFromFilter === undefined
      ? this.maxEffectiveFromFilter
      : this.dateTimeService.getEndOfDayForDate(this.maxEffectiveFromFilter),
    this.minEffectiveFromFilter === undefined
      ? this.minEffectiveFromFilter
      : this.dateTimeService.getEndOfDayForDate(this.minEffectiveFromFilter),   
    this._id,
    this.contractActivityDescriptionFilter,
    this.primengTableHelper.getSorting(this.dataTable),
    this.primengTableHelper.getSkipCount(this.paginator, event),
    this.primengTableHelper.getMaxResultCount(this.paginator, event)
  )
  .subscribe((result) => {
    this.primengTableHelper.totalRecordsCount = result.totalCount;
    this.primengTableHelper.records = result.items;
    this.primengTableHelper.hideLoadingIndicator();
  });

}

reloadPage(): void { this.paginator.changePage(this.paginator.getPage()); } }`

Important part is when Id is set then this goes and calls the getGridData method to load data. And this throws exception as this.primengTableHelper.getMaxResultCount(this.paginator, event) returns 0.

I am sure you have faced this issue before. What is the solution? What is the best way to load child component data?

Regards,

Hi,

As the background jobs are running in Application pool and this might cause issues if the tasks are taking too long and some reason application pool decides to shut itself. We want to run those backgroun jobs in a window service. This part can be achieved by introducing Configuration.BackgroundJobs.IsJobExecutionEnabled = true; in Windows service module.

The article about jobs has the following sections:

  • You can enable job execution for only one instance of the application.
  • You can disable job execution for all instances of the web application and create a separated, standalone application (example: a Windows Service) that executes background jobs.

We are planning to go ahead the second option ( move background jobs running into Windows service). However, would that be a way to still manage those jobs through web application? For instance we would sometimes want to force to run the background jobs or rescedule the jobs. I have done a demo and that didn't work as web application sets Configuration.BackgroundJobs.IsJobExecutionEnabled = false;.

The question is: Can we manage background jobs through web application but jobs run in windows service? If yes how would we achieve that?

Update

In your documantation you separated Background Jobs and Background Workers. Backgorund jobs are persisted in the table AbpBackgroundJobs automatically. This is great to use in web application. However both Background jobs and Background workers are enabled with the same key Configuration.BackgroundJobs.IsJobExecutionEnabled = false;. Is this correct?

Background jobs should run in application pool as those are short tasks like sending emails etc.There should be a way to separate between Background Jobs from Background workers. For instance this would allow to move Background workers to be moved out of Application pool into Windows Service.

Q2: Does AbpBackgroundJobs table is also used to persist Backround Workers? What if we want to use advanced scheduling with Quartz? How can we persist the jobs in the database? Would they also be stored in the same table? Or we would need to configure Quartz somewhere to make sure new table is created for it automatically to persist the jobs? If yes then how could we do that? Having [DependsOn(typeof (AbpQuartzModule))] does bring all in place? How can we configure the persistent store?

This might feel like too many questions( Apologies :)). But we really need to move long tasks outside of Application pool and also be able to manage those tasks from web application( manually run them from web application, paused them etc).

Regards

I have created a console application which depends on CoreModule.

I have annotated console application module as below:

[DependsOn(typeof(MyCoreModule))] public class MyConsoleAppModule : AbpModule{ }

When the console application is run I get dependency injection error in this line in CoreModule PostInitiliaze method: IocManager.Resolve<ChatUserStateWatcher>().Initialize();

Error message:

``Can't create component 'MyApp.Friendships.Cache.UserFriendsCache' as it has dependencies to be satisfied.

'MyApp.Friendships.Cache.UserFriendsCache' is waiting for the following dependencies:

  • Service 'Abp.Domain.Repositories.IRepository`2[[MyApp.Friendships.Friendship, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[MyApp.Chat.ChatMessage, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.MultiTenancy.TenantCache2[[MyApp.MultiTenancy.Tenant, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null],[MyApp.Authorization.Users.User, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null]]' which was registered but is also waiting for dependencies. 'Abp.MultiTenancy.TenantCache2[[MyApp.MultiTenancy.Tenant, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null],[MyApp.Authorization.Users.User, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null]]' is waiting for the following dependencies:
  • Service 'Abp.Domain.Repositories.IRepository`1[[MyApp.MultiTenancy.Tenant, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
  • Service 'MyApp.Authorization.Users.UserStore_07b5c24a-14b4-4126-8563-99bd25a1bc6e' which was registered but is also waiting for dependencies. 'MyApp.Authorization.Users.UserStore_07b5c24a-14b4-4126-8563-99bd25a1bc6e' is waiting for the following dependencies:
  • Service 'Abp.Domain.Repositories.IRepository`2[[MyApp.Authorization.Users.User, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.UserLogin, Abp.Zero.Common, Version=7.3.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.UserRole, Abp.Zero.Common, Version=7.3.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`1[[MyApp.Authorization.Roles.Role, MyApp.Core, Version=11.4.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.UserClaim, Abp.Zero.Common, Version=7.3.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.UserPermissionSetting, Abp.Zero.Common, Version=7.3.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.UserOrganizationUnit, Abp.Zero.Common, Version=7.3.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
  • Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Organizations.OrganizationUnitRole, Abp.Zero.Common, Version=7.3.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.``

Any idea how to resolve this issue?

Thanks

in .net 6 there is a new template as Worker Service that can be used to create Windows Services.

I followed the https://docs.microsoft.com/en-us/dotnet/core/extensions/windows-service to convert the Worker Service to Window Service.

Now I would like to migrate some of ASP ZERO background jobs( which runs in Application Pool) into Windows Service. In order to do that as ASP Boiler plate is moduler I have created a similar Module class in the project.

My question is how to combine those existing configurations with existing template so it would work best.

Where using (var bootstrapper = AbpBootstrapper.Create&lt;MyModule&gt;()) should go in the process?

Program.cs

    IHost host = Host.CreateDefaultBuilder(args)
         .UseWindowsService(options =>
      {
             options.ServiceName = ".NET Joke Service";
        })
        .ConfigureServices(services =>
     {
       services.AddHostedService&lt;WindowsBackgroundService&gt;();
     })
 .Build();

    await host.RunAsync(); 

.net core version: .net 5 asp zero: 10.20

I have the simplest query with select statement for efficiency so instead of selecting all columns I want to limit the selection:

var productDto = await _productRepository.GetAll().Select(d=>new ProductDto{Name = d.Name}).SingleAsync(x=>x.Id ==input.Id);

This simple query throws

The LINQ expression 'DbSet()
.Where(c => new ProductDo{ Name= d.Name}
.Id == __input_Id_0)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. 

I have written a simple ef core application with ef core 5 with simple context and above query perfectly works fine in that.

Any idea why this selection is not allowed?

VERSION: .net core 3.1 and latest v9.3.0-rc.1

We are in the process of upgrading to latest and first thing we noticed is that all localized texts show names instead of values. See the screenshot attached.

Any idea why this could be happening and how can we get it back working again?

When I change the language it does not do anything but changes the flag only.

//Use database for language management Configuration.Modules.Zero().LanguageManagement.EnableDbLocalization(); //Configuration.Localization.Languages.Add(new LanguageInfo("en", "English", "famfamfam-flag-gb", true));

Tried to disabled EnableDbLocalization() but no luck.

In startup :

//Initializes ABP framework. app.UseAbp(options => { options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization });

Tried to change it to true and no luck

Clear all cahces and removed all cookies still the same issue.

Deleted all Abp.Localization.DefaultLanguageName settings from AppSettings and try again and no luck.

Version: asp zero 8.6 angular.

On dev we get exception with modal( sweetalert) 'Invalid username or password'. On production user does not get any modal on the wrong credantials. When I view F12 network I can see the error message comes back on authenticate call is 500 instead of 401 on production. I believe as a result the modal does not appear on production.

Any idea how to fix this? Is this an appsetting issue? or any setting we need to change on IIS to get the error modal working?

Note that when I change launchSettings.json to Production the issue occurs. On Development it shows the modal fine.

Both dev and production appsettings are indentical and the issue still persists.

Thanks,

We would like to create a module or use app service) to import large data into the system. We noticed is that when current services are used or domains are used to import the data, the process takes ages or sometimes never to finish. The issue due to the fact that EF tracks changes to all entities. As the loop continues to increase, memory gets smashed with all tracking an as a result process gets very slow.

You can read the issue here: https://weblog.west-wind.com/posts/2014/dec/21/gotcha-entity-framework-gets-slow-in-long-iteration-loops#:~:text=There%20are%20a%20few%20simple,tracking%20for%20the%20dbContext%20instance

The suggestion is to get a new instance of the db context or stop tracking to speed up the process.

I read through your documation and disabling UnitOfWork speeds up the process a bit (basically using a single unit of work for each loop and commiting changes at the end of the loop). However we believe that creating nearly 10 000 records ( in various tables) should not take around 15 minutes.

Somehow we need to access the DB context and disable the following to gain more speed while importing data as it suggested in this link : https://stackoverflow.com/questions/6107206/improving-bulk-insert-performance-in-entity-framework

yourContext.Configuration.AutoDetectChangesEnabled = false; yourContext.Configuration.ValidateOnSaveEnabled = false;

My questions are:

1- What is your suggestion about importing large data(not just into single table but multiple tables) with best performance? 2- How can we access the DB context to disable those options while we import the data? 3- Would we be able to still use Repository injections? For example : IRepository<Product>

When we change the language to en-GB we cannot see the required permisisons in the error message.

<text name="AtLeastOneOfThesePermissionsMustBeGranted">Required permissions are not granted. At least one of these permissions must be granted: {0}</text> exists in en-GB.xml file.

Any idea why we do not see the required permissions in the error message?

Thanks,

Hi,

We would like to import data into system from CSV file. We created a process read cv file each row one by one and create necessary Entities and sub entities by using repository pattern and save changes by calling await CurrentUnitOfWork.SaveChangesAsync(); or await _productRepository.InsertAndGetIdAsync(product);

However, the process run very fast in the first 10-20 iterations then gets slower and slower and It takes over 10 minutes to complete around 150 rows!

I looked up on the internet and found this link where @Rick explained the problem: https://weblog.west-wind.com/posts/2014/dec/21/gotcha-entity-framework-gets-slow-in-long-iteration-loops.

What I tried: 1- call AsNoTracking() in all repository access but I still see that process very slow.

2- Used using (var unitOfWork = _unitOfWorkManager.Begin()) {...} in the iteration thinking that this would refresh the context in each iteration as the link suggests but no luck with this either.

Do you have any idea how to overcome this issue? How do you import large users into the system?

Regards,

Showing 1 to 10 of 17 entries