Starts in:
3 DAYS
4 HRS
6 MIN
46 SEC
Starts in:
3 D
4 H
6 M
46 S

Activities of "Teknosol"

Answer

I tried that too but the error persists.

public class CreateScreenDesignConsumer : IConsumer<IScreenDesignCreateCommand>
{

//changed interface
    private readonly IScreenRootManager _screenRootManager;
    private readonly ILogger<CreateScreenDesignConsumer> _logger;

    public CreateScreenDesignConsumer(IScreenRootManager screenRootManager, ILogger<CreateScreenDesignConsumer> logger)
    {
        _screenRootManager = screenRootManager;
        _logger = logger;
    }

    public virtual async Task Consume(ConsumeContext<IScreenDesignCreateCommand> context)
    {

        try
        {
            var result = await _screenRootManager.CreateAsync(context.Message);
            await context.RespondAsync(new Result<ScreenDesignCreateResult>(data: result));
        }
        catch (Exception ex)
        {
            await context.RespondAsync<Fault<Result>>
          (new { Message = "ScreenDeisgn:CreateFail", FaultMessage = ex.Message, FaultStackTrace = ex.StackTrace });

        }
    }
}
Answer

Thank you for your answer, But the error persists. Is there another way you can suggest?

I edited what you said as follows;

public interface IScreenRootManager
{
    Task<ScreenDesignCreateResult> CreateAsync(IScreenDesignCreateCommand screenDesignDto);
}
public class ScreenRootManager : DomainService, ITransientDependency, IUnitOfWorkEnabled, IScreenRootManager
{
    private readonly IScreenDesignRepository _screenDesignRepository;
    private readonly IObjectMapper _mapper;
    private readonly ILogger<ScreenRootManager> _logger;



    public ScreenRootManager(IScreenDesignRepository screenDesignRepository, IObjectMapper mapper, IUnitOfWorkManager unitOfWorkManager, ILogger<ScreenRootManager> logger)
    {
        var screenDesignRepository1 = screenDesignRepository;
        _screenDesignRepository = screenDesignRepository;
        _mapper = mapper;
        _logger = logger;
    }
    public async Task<ScreenDesignCreateResult> CreateAsync(
      IScreenDesignCreateCommand screenDesignDto
  )
    {

            var screenDesign = new ScreenDesign(
            screenDesignDto.Type,
            screenDesignDto.ProgramName,
        Guid.NewGuid(),
           screenDesignDto.FieldId,
           screenDesignDto.FieldName,
          screenDesignDto.FieldDescription,
           screenDesignDto.GridJsonHeader,
           screenDesignDto.TabJsonHeader,
          screenDesignDto.PopupOrderAppearance,

           screenDesignDto.TabSequence,

           screenDesignDto.DontShow,
           screenDesignDto.IsMandatoryField,
           screenDesignDto.AllowMinusDataEntry,
           screenDesignDto.DontRefreshDataAfterRegistration,
           screenDesignDto.CanNotChangeFieldWithEdit,
           screenDesignDto.AllowFiltering,
           screenDesignDto.IsPrimary,
           screenDesignDto.Alignment,
           screenDesignDto.Format,
           screenDesignDto.Width,
           screenDesignDto.MessageKey,
           screenDesignDto.LookupUrl,
           screenDesignDto.IsGrid,
           screenDesignDto.HeaderUrl,
           screenDesignDto.DataSourceUrl,
           screenDesignDto.TabTitle,
           screenDesignDto.TemplateName,
           screenDesignDto.PropertyDataType,
           screenDesignDto.DisplayLocation,
           screenDesignDto.SubTab,
           screenDesignDto.SubTabSequence,
           screenDesignDto.DataLength,
           screenDesignDto.ColumnOrder,
           screenDesignDto.DefaultOrder,
           screenDesignDto.NotAllowChangesNotBlank,
          screenDesignDto.MinimumCharLength,
           screenDesignDto.MaximumCharLength,
           screenDesignDto.IsTree,
           screenDesignDto.RelationField,
           screenDesignDto.CascadeFrom,
           screenDesignDto.IsDMS,
           screenDesignDto.IsDMSEnum
        );
        try
        {
            var data = await _screenDesignRepository.InsertAsync(screenDesign);
            var returnDto = _mapper.Map<ScreenDesign, ScreenDesignCreateResult>(data);

            return returnDto ;
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "error occured");

            throw;
        }
    }


}
 public class CreateScreenDesignConsumer : IConsumer<IScreenDesignCreateCommand>
 {
     private readonly ScreenRootManager _screenRootManager;
     private readonly ILogger<CreateScreenDesignConsumer> _logger;

     public CreateScreenDesignConsumer(ScreenRootManager screenRootManager, ILogger<CreateScreenDesignConsumer> logger)
     {
         _screenRootManager = screenRootManager;
         _logger = logger;
     }
     
  //I changed to virtual here
     public virtual async Task Consume(ConsumeContext<IScreenDesignCreateCommand> context)
     {

         try
         {
             var result = await _screenRootManager.CreateAsync(context.Message);
             await context.RespondAsync(new Result<ScreenDesignCreateResult>(data: result));
         }
         catch (Exception ex)
         {
             await context.RespondAsync<Fault<Result>>
           (new { Message = "ScreenDeisgn:CreateFail", FaultMessage = ex.Message, FaultStackTrace = ex.StackTrace });

         }
     }
 }
Answer

Thank you for your answer, I added the codes you said as below but the same problem persists. Did you have a chance to review my project?

My scenario works like this: I want to capture the data with mass transit in the worker service and save it to the db, I created the worker service myself, the API where the data is created only sends the ScreenDesignCreateCommand(like dto) object.

 using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using ScreenDesign.Commands;
using ScreenDesign.Helper;
using ScreenDesign.Localization;
using ScreenDesign.Results;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;

namespace ScreenDesign
{
    public interface IScreenRootManager
    {
        Task<ScreenDesignCreateResult> CreateAsync(IScreenDesignCreateCommand screenDesignDto);
    }
    public class ScreenRootManager : DomainService, ITransientDependency, IUnitOfWorkEnabled , IScreenRootManager
    {
        private readonly IScreenDesignRepository _screenDesignRepository;
        private readonly IObjectMapper _mapper;
        private readonly ILogger<ScreenRootManager> _logger;



        public ScreenRootManager(IScreenDesignRepository screenDesignRepository, IObjectMapper mapper, IUnitOfWorkManager unitOfWorkManager, ILogger<ScreenRootManager> logger)
        {
            var screenDesignRepository1 = screenDesignRepository;
            _screenDesignRepository = screenDesignRepository;
            _mapper = mapper;
            _logger = logger;
        }

        public async Task<ScreenDesignCreateResult> CreateAsync(
          IScreenDesignCreateCommand screenDesignDto
      )
        {


                var screenDesign = new ScreenDesign(
                screenDesignDto.Type,
                screenDesignDto.ProgramName,
            Guid.NewGuid(),
               screenDesignDto.FieldId,
               screenDesignDto.FieldName,
              screenDesignDto.FieldDescription,
               screenDesignDto.GridJsonHeader,
               screenDesignDto.TabJsonHeader,
              screenDesignDto.PopupOrderAppearance,

               screenDesignDto.TabSequence,

               screenDesignDto.DontShow,
               screenDesignDto.IsMandatoryField,
               screenDesignDto.AllowMinusDataEntry,
               screenDesignDto.DontRefreshDataAfterRegistration,
               screenDesignDto.CanNotChangeFieldWithEdit,
               screenDesignDto.AllowFiltering,
               screenDesignDto.IsPrimary,
               screenDesignDto.Alignment,
               screenDesignDto.Format,
               screenDesignDto.Width,
               screenDesignDto.MessageKey,
               screenDesignDto.LookupUrl,
               screenDesignDto.IsGrid,
               screenDesignDto.HeaderUrl,
               screenDesignDto.DataSourceUrl,
               screenDesignDto.TabTitle,
               screenDesignDto.TemplateName,
               screenDesignDto.PropertyDataType,
               screenDesignDto.DisplayLocation,
               screenDesignDto.SubTab,
               screenDesignDto.SubTabSequence,
               screenDesignDto.DataLength,
               screenDesignDto.ColumnOrder,
               screenDesignDto.DefaultOrder,
               screenDesignDto.NotAllowChangesNotBlank,
              screenDesignDto.MinimumCharLength,
               screenDesignDto.MaximumCharLength,
               screenDesignDto.IsTree,
               screenDesignDto.RelationField,
               screenDesignDto.CascadeFrom,
               screenDesignDto.IsDMS,
               screenDesignDto.IsDMSEnum
            );
            try
            {
                var data = await _screenDesignRepository.InsertAsync(screenDesign);
                var returnDto = _mapper.Map<ScreenDesign, ScreenDesignCreateResult>(data);

                return returnDto ;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "error occured");

                throw;
            }
        }


    }
}

Answer

You can download my project from this link: https://we.tl/t-EWOKy9gh2H

Answer

Thanks for your feedback,

Below are the code blocks, if you share your email address I can send you the project.

This class is I call insertasync();

public class ScreenRootManager : DomainService
{
    private readonly IScreenDesignRepository _screenDesignRepository;
    private readonly IObjectMapper _mapper;
    private readonly ILogger<ScreenRootManager> _logger;



    public ScreenRootManager(IScreenDesignRepository screenDesignRepository, IObjectMapper mapper, IUnitOfWorkManager unitOfWorkManager, ILogger<ScreenRootManager> logger)
    {
        var screenDesignRepository1 = screenDesignRepository;
        _screenDesignRepository = screenDesignRepository;
        _mapper = mapper;
        _logger = logger;
    }

    public async Task<ScreenDesignCreateResult> CreateAsync(
      IScreenDesignCreateCommand screenDesignDto
  )
    {


            var screenDesign = new ScreenDesign(
            screenDesignDto.Type,
            screenDesignDto.ProgramName,
        Guid.NewGuid(),
           screenDesignDto.FieldId,
           screenDesignDto.FieldName,
          screenDesignDto.FieldDescription,
           screenDesignDto.GridJsonHeader,
           screenDesignDto.TabJsonHeader,
          screenDesignDto.PopupOrderAppearance,

           screenDesignDto.TabSequence,

           screenDesignDto.DontShow,
           screenDesignDto.IsMandatoryField,
           screenDesignDto.AllowMinusDataEntry,
           screenDesignDto.DontRefreshDataAfterRegistration,
           screenDesignDto.CanNotChangeFieldWithEdit,
           screenDesignDto.AllowFiltering,
           screenDesignDto.IsPrimary,
           screenDesignDto.Alignment,
           screenDesignDto.Format,
           screenDesignDto.Width,
           screenDesignDto.MessageKey,
           screenDesignDto.LookupUrl,
           screenDesignDto.IsGrid,
           screenDesignDto.HeaderUrl,
           screenDesignDto.DataSourceUrl,
           screenDesignDto.TabTitle,
           screenDesignDto.TemplateName,
           screenDesignDto.PropertyDataType,
           screenDesignDto.DisplayLocation,
           screenDesignDto.SubTab,
           screenDesignDto.SubTabSequence,
           screenDesignDto.DataLength,
           screenDesignDto.ColumnOrder,
           screenDesignDto.DefaultOrder,
           screenDesignDto.NotAllowChangesNotBlank,
          screenDesignDto.MinimumCharLength,
           screenDesignDto.MaximumCharLength,
           screenDesignDto.IsTree,
           screenDesignDto.RelationField,
           screenDesignDto.CascadeFrom,
           screenDesignDto.IsDMS,
           screenDesignDto.IsDMSEnum
        );
        try
        {
            var data = await _screenDesignRepository.InsertAsync(screenDesign);
            var returnDto = _mapper.Map<ScreenDesign, ScreenDesignCreateResult>(data);

            return returnDto ;
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "error occured");

            throw;
        }
    }


}

I consume this class with AMQP and direct it to the manager, that is, to the upper class, I trigger the method with this class and use mass transit.

public class CreateScreenDesignConsumer : IConsumer<IScreenDesignCreateCommand>
{
    private readonly ScreenRootManager _screenRootManager;
    private readonly ILogger<CreateScreenDesignConsumer> _logger;

    public CreateScreenDesignConsumer(ScreenRootManager screenRootManager, ILogger<CreateScreenDesignConsumer> logger)
    {
        _screenRootManager = screenRootManager;
        _logger = logger;
    }

    public async Task Consume(ConsumeContext<IScreenDesignCreateCommand> context)
    {

        try
        {
            var result = await _screenRootManager.CreateAsync(context.Message);
            await context.RespondAsync(new Result<ScreenDesignCreateResult>(data: result));
        }
        catch (Exception ex)
        {
            await context.RespondAsync<Fault<Result>>
          (new { Message = "ScreenDeisgn:CreateFail", FaultMessage = ex.Message, FaultStackTrace = ex.StackTrace });

        }
    }
}

This class is where I implemented the efcore layer in the worker service;

IHost host = Host.CreateDefaultBuilder(args)
    .ConfigureLogging(logging =>
    {
        logging.ClearProviders();
        logging.AddConsole();
        logging.AddDebug(); // Optional: Adds debug logging
    })
    .ConfigureServices(async (hostContext, services) =>
    {
        var configuration = hostContext.Configuration;
        var builder = Host.CreateDefaultBuilder(args);

        //I added the classes in quotes because generic methods were not shown.
        "await services.AddApplicationAsync"AbpAutofacModule"();"
        "await services.AddApplicationAsync"ScreenDesignEntityFrameworkCoreModule" ();"

        services.AddMassTransit(x =>
        {
            x.AddConsumer<CreateScreenDesignConsumer>();

            x.UsingRabbitMq((context, cfg) =>
            {
                cfg.Host("amqps://localhost/", h =>
                {
                    h.Username("localhost");
                    h.Password("");
                });

                cfg.ConfigureEndpoints(context);
            });
        });

        services.AddHostedService<Worker>();
    })
    .Build();

host.Run();

Error logs here; info: ScreenDesign.Domain.Worker.Worker[0] Worker running at: 11/18/2024 09:08:18 +03:00 fail: ScreenDesign.ScreenRootManager[0] error occured Volo.Abp.AbpException: A DbContext can only be created inside a unit of work! at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.GetDbContextAsync() at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.InsertAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken) at ScreenDesign.ScreenRootManager.CreateAsync(IScreenDesignCreateCommand screenDesignDto) in C:\Users\ali.ozen\Desktop\ddd\18.11-1\ScreenDesign\src\ScreenDesign.Domain\ScreenRootManager.cs:line 89 info: ScreenDesign.Domain.Worker.Worker[0] Worker running at: 11/18/2024 09:08:21 +03:00 fail: ScreenDesign.Domain.Worker.Consumers.CreateScreenDesignConsumer[0] error occured Volo.Abp.AbpException: A DbContext can only be created inside a unit of work! at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.GetDbContextAsync() at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.InsertAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken) at ScreenDesign.ScreenRootManager.CreateAsync(IScreenDesignCreateCommand screenDesignDto) in C:\Users\ali.ozen\Desktop\ddd\18.11-1\ScreenDesign\src\ScreenDesign.Domain\ScreenRootManager.cs:line 89 at ScreenDesign.Domain.Worker.Consumers.CreateScreenDesignConsumer.Consume(ConsumeContext1 context) in C:\Users\ali.ozen\Desktop\ddd\18.11-1\ScreenDesign\ScreenDesign.Domain.Worker\Consumers\CreateScreenDesignConsumer.cs:line 31 fail: MassTransit.ReceiveTransport[0] R-FAULT rabbitmqs://cow.rmq2.cloudamqp.com/gouvefqf/CreateScreenDesign a0570000-0faa-0009-898d-08dd07975edf ScreenDesign.Commands.IScreenDesignCreateCommand ScreenDesign.Domain.Worker.Consumers.CreateScreenDesignConsumer(00:00:14.3431337) Volo.Abp.AbpException: A DbContext can only be created inside a unit of work! at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.GetDbContextAsync() at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.InsertAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken) at ScreenDesign.ScreenRootManager.CreateAsync(IScreenDesignCreateCommand screenDesignDto) in C:\Users\ali.ozen\Desktop\ddd\18.11-1\ScreenDesign\src\ScreenDesign.Domain\ScreenRootManager.cs:line 89 at ScreenDesign.Domain.Worker.Consumers.CreateScreenDesignConsumer.Consume(ConsumeContext1 context) in C:\Users\ali.ozen\Desktop\ddd\18.11-1\ScreenDesign\ScreenDesign.Domain.Worker\Consumers\CreateScreenDesignConsumer.cs:line 31 at MassTransit.DependencyInjection.ScopeConsumerFactory1.Send[TMessage](ConsumeContext1 context, IPipe1 next) in //src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22 at MassTransit.DependencyInjection.ScopeConsumerFactory1.Send[TMessage](ConsumeContext1 context, IPipe1 next) in /_/src/MassTransit/DependencyInjection/DependencyInjection/ScopeConsumerFactory.cs:line 22 at MassTransit.Middleware.ConsumerMessageFilter2.MassTransit.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext1 context, IPipe1 next) in //src/MassTransit/Middleware/ConsumerMessageFilter.cs:line 48 info: ScreenDesign.Domain.Worker.Worker[0] Worker running at: 11/18/2024 09:08:22 +03:00`

Error log Screenshot;

Hi, We are currently moving containers to linux, front end is not active, we get this error when we try to log in from swagger. When I press the login button many times, I see this error on the swagger screen.

In the OpenIddictApplications table, api in redirectUris looks like this.

Hi again,

This time we loaded the mvc page, but when we press the login button on the page, it does not redirect to the redirect url, that is, to the swagger page. Can you help with this problem?

Hi again, We solved the problem, when we added the remote service url to the hosts file, the problem was solved, it was due to not being able to reach the url.

Hi, We tried your suggestion but we were not successful. Do you have a sample project where we can see this scenario? Is there a refresh token application in eshop or bookstore?

Hi, It didn't work for our project. we took a screen video for the error. For example, when filling out a form on a screen, when the access token expires, the page is refreshed and the page is redirected to the dashboard, we want the page to stay in the current form without refreshing and get a refresh token.

In addition, when the token expires and refreshes on the page, the token is received from openidict again and I share these sample token records in the screenshot. There is no record in the table as a refresh token for types, can we not generate any refresh token?

I kindly ask for your support.

Error Video : https://we.tl/t-KtB8yfhfI3

Showing 11 to 20 of 54 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06