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

Activities of "adamphones"

Hi Ismail,

They are not similar. I have checked that one. In my example you have a a child component(Modal) You pass parent data to child component with Input (Id) Then child component (Modal) is the parent for other child components with tables. This Id gets passed to those child components and they should fire getAll methods to get data is loaded. This is not the case. grant-parent.html <div> <parent [ItemId]="ItemId"> </parent> </div>

parent.html (Modal)

<tabset> <tab> <child [itemId]="Id"> </child> </tab> <tab> <child2 [itemId]="Id"> </child2> </tab> <tab> <child3 [itemId]="Id"> </child3> </tab> </tabset>

All child components have <p-Table> in them. Basically standard grid table with getAll() methods.

The idea is simple: When parent(Modal) is viewed (show) it should automatically fire all child components to load those tables. Where should we place getAll() methods for those child components to load the data? And this needs to happen regardless of Input changes( Id) every time the parent Modal loaded it must fire all child components to pull the data by calling their getAll() methods.

Hi Ismail,

Do both Bakground Jobs and Bakground Workers are enabled with the same key Configuration.BackgroundJobs.IsJobExecutionEnabled = false;?

Is there any example that Background Jobs can be controlled in web app but can be executed in a Windows Service? How could this be achieved really?

If we want to use Quartz along side Background Jobs then can we enable disable them independently? Or we need to choose either use Background Jobs or Background Workers?

Thanks,

HI @ismail,

When I use your suggestion here in another ticket the issues really disappeared.

However, I still want to clarify something: My understanding is that if Module A depends on Module B and Module B depends on Module C then Module A should not add Module C as depency in the module class? Is this right? As Because Module B should take care the dependency. For some reason this doesn't seem to work. Even though my new Module shoud only depend on CoreModule and when I use dependency to only CoreModule I get exceptions that Domain and repositories are not registered. Those dependency issues disappear if I make my new module to depend on EntityFrameWork module. Somehow some registeries in Core like :IocManager.Resolve<ChatUserStateWatcher>().Initialize(); in PostInitialize in core module fails.

Migrator project also depends on EntityFramework and I guess it is required?

Thanks @ismail. This worked.

The main issue was caused by appsettings.json file. I had to AbpZeroLicenseCode key in the settings.

But this still throwing a new dependency injection issue as :

Castle.MicroKernel.ComponentActivator.ComponentActivatorException: ComponentActivator: could not instantiate MyApp.Authorization.Users.UserManager ---> System.Exception: Could not instantiate AdamPhones.Spectrum.Authorization.Users.UserManager. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Castle.MicroKernel.ComponentRegistrationException: Type Microsoft.Extensions.Hosting.IHostEnvironment is abstract. As such, it is not possible to instansiate it as implementation of service 'Microsoft.Extensions.Hosting.IHostEnvironment'. Did you forget to proxy it?

In .net 6 IHostEnvironment is automatically registered

Can you please tell us how this service will be registered in Castle dependency injection?

Hi Musa,

That's what I did actually. followed the example. I raised another question here how to set up Window Service. What I am trying to do is to move background tasks(jobs) into Windows Service from Application pool. I obvioulsy don't know the order to set this up correctly. The only difference I can see in those two is that Migrator project depends on EntityFramework project where mine is Core project.

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();

WindowsBackgroundService.cs: This is where I placed the bootstrapper code.

    ``public class WindowsBackgroundService : BackgroundService
     {
    private readonly ILogger&lt;WindowsBackgroundService&gt; _logger;

    public WindowsBackgroundService(ILogger&lt;WindowsBackgroundService&gt; logger)
    {
        _logger = logger;
    }

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        try
        {
            using (var bootstrapper = AbpBootstrapper.Create&lt;PricingEngineServiceModule&gt;())
            {
                bootstrapper.IocManager.IocContainer
                    .AddFacility&lt;LoggingFacility&gt;(f => f.UseAbpLog4Net()
                        .WithConfig("log4net.config")
                    );

                bootstrapper.Initialize();

                
                while (!stoppingToken.IsCancellationRequested)
                {
                    _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);

                    using (var migrateExecuter = bootstrapper.IocManager.ResolveAsDisposable&lt;DataImportJob&gt;())
                    {
                        await migrateExecuter.Object.Execute(null);
                    }

                    await Task.Delay(1000, stoppingToken);
                }

                Console.WriteLine("Press ENTER to exit...");
                Console.ReadLine();
            }
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "{Message}", ex.Message);
            Environment.Exit(1);
        }
        
    }``

MyModule.cs:

` [DependsOn(typeof(CoreModule))] public class EngineServiceModule : AbpModule { private readonly IConfigurationRoot _appConfiguration;

public EngineServiceModuleCoreModule coreModule)
{
    _appConfiguration = AppConfigurations.Get(
        typeof(CoreModule).GetAssembly().GetDirectoryPathOrNull(),
        addUserSecrets: true
    );
}

public override void PreInitialize()
{
    Configuration.DefaultNameOrConnectionString = _appConfiguration.GetConnectionString(
        MyAppConsts.ConnectionStringName
    );
    Configuration.Modules.AspNetZero().LicenseCode = _appConfiguration["AbpZeroLicenseCode"];

    Configuration.BackgroundJobs.IsJobExecutionEnabled = false;
    Configuration.ReplaceService(typeof(IEventBus), () =>
    {
        IocManager.IocContainer.Register(
            Component.For<IEventBus>().Instance(NullEventBus.Instance)
        );
    });
}

public override void Initialize()
{
    IocManager.RegisterAssemblyByConvention(typeof(EngineServiceModule).GetAssembly());
    ServiceCollectionRegistrar.Register(IocManager);
}

}`

ServiceCollectionRegistrar.cs is the same as Migrator project.

`public static class ServiceCollectionRegistrar { public static void Register(IIocManager iocManager) { var services = new ServiceCollection();

    IdentityRegistrar.Register(services);

    WindsorRegistrationHelper.CreateServiceProvider(iocManager.IocContainer, services);
}

}`

Hi @musa,

I have tried all and none works as expected. All queries retrieve all columns from database. And it would be wrong actually to think that one way of writing the query would change the output where those should be translated into sql with the same script. This is the case in ef core.

Can you please do the test at your end to see what you get? My question still stands. How should I write queries that would only select the columns that I specify in the select dto? In ef core world any of those queries result in the same correct expected query.

I have created a ticket as wellhttps://github.com/aspnetzero/aspnet-zero-core/issues/4274

Hi @musa.demir,

When Id is used in select the translation error is NOT getting thrown. However, when I checked profiler what query gets sent to database i can see it goes and grabs all columns. So it is not expected behaviour at all. So basically select statment is useless.

Hi Ismail,

I find this weird too. It is just like all other Repository pattern.

private readonly IRepository<Product> _productRepository;

DI injection injects the product repository as above.

Then in the method I just call var product = await _productRepository.GetAll().Select(v=> new ProductDto(){}).SingleAsync(x => x.Id == input.Id);

public class ProductDto: EntityDto{
public string Name {get;set;}
}`

This one fails.

But if I write the query as below it is fine:

        var product = await _productRepository.GetAll().SingleAsync(x=>x.Id ==input>id);

        var productDto = ObjectMapper.Map<ProductDto>(product);`

The problem with this is that this returns all columns from database for the product. I am trying to avoid this with select but it fails.

Anything you can think of would cause this problem?

Thanks,

Found the issue

<ItemGroup> <EmbeddedResource Include="Localization\ProjectName\*.xml;Net\Emailing\EmailTemplates\default.html" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" /> </ItemGroup>

was missing from Core.csproj

Showing 1 to 10 of 37 entries