Activities of "berkansasmaz"

Hi,

You are probably not running the application in the Production environment.

Please make sure ASPNETCORE_ENVIRONMENT is Production!

The offending piece of code is the following code inside MyProjectNameIdentityServerModule under MyProjectName.IdentityServer project. This piece of code is set to run only in Developmentenvironment.

If you want, you can delete this piece of code and publish it again (on Azure or local machine) to make sure this is the problem. I think you will not get error this time.

If you don't get an error, you can fix the problem permanently by setting ASPNETCORE_ENVIRONMENT to Production where you run the application.

For more information you can check here.

First of all, I will write down the actions you have done before to be on the same page:

  1. AbpOrganizationUnits has StateId
  2. You have an entity named State and you have a property called Name(or a different property).
  3. State entity has ApplicationService and when you run MyProjectName.HttpApi.Host project, api end-points appear on swagger.
  4. When you run the MyProjectName.Web project, the same api end-points appear on swagger here too. If it is not visible, you need to create a controller in MyProjectName.Web.

I assume you did these steps :)

Then you can customize the ConfigureExtraProperties method of MyProjectNameModuleExtensionConfigurator under MyProjectName.Domain.Shared as in the picture below.

I hope that you will finally see an user interface like the screenshot below:

For more information see here.

Your problem is that OrganizationUnitCreateDto also doesn't have a State property. I suspect that you have not configured State in MyProjectNameModuleExtensionConfigurator under the MyProjectName.Domain.Shared project.

Once you do this and you won't need to override the Create and Edit modal. When you run the application, you will be greeted with a picture like the one below:

PS: Make sure that the code in the picture below is in MyProjectNameEfCoreEntityExtensionMappings under the EntityFrameworkCore folder in the MyProjectName.EntityFrameworkCore project and that the property you added in the AbpOrganizationUnits table of your database is added as a column.

Hi,

I think you can do it by following this document.

I just created a test project and did what you are trying to do by following the document:

Related: https://stackoverflow.com/a/69371513/9922629

Hi,

By following the documents exactly, I was able to reach a screen like the picture below:

If you have had a problem with this, maybe it is related to your abp version, in this case, if you write your version information and which UI you are developing in, I can help more.

By the way, there is sample code for this in the setting-management module:

  • https://github.com/abpframework/abp/tree/dev/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Components/EmailSettingGroup
  • https://github.com/abpframework/abp/blob/dev/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Settings/EmailingPageContributor.cs
  • https://github.com/abpframework/abp/blob/cec636c238070fcf9212d5ad4828e5234c2c0217/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs#L36-L39
  • https://github.com/abpframework/abp/blob/cec636c238070fcf9212d5ad4828e5234c2c0217/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs#L46-L54

Happy coding 😊

This may be because the version of my application is different from the version of your application.

Could you please delete and recreate the your constructor?

PS: Don't forget to inject IEmailSender and ITemplateRenderer when you recreate constructor.

If the problem is solved, just close the question 🙂

Happy coding 💻

Hi,

Replace the CustomIdentityUserAppService I shared in my previous answer with the following code:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IIdentityUserAppService), typeof(IdentityUserAppService), typeof(CustomIdentityUserAppService))]
    public class CustomIdentityUserAppService : IdentityUserAppService
    {
        private const string ToEmail = "info@abp.io";

        private readonly IEmailSender _emailSender;
        private readonly ITemplateRenderer _templateRenderer;

        public CustomIdentityUserAppService(IdentityUserManager userManager, IIdentityUserRepository userRepository, IIdentityRoleRepository roleRepository, IOrganizationUnitRepository organizationUnitRepository, IIdentityClaimTypeRepository identityClaimTypeRepository, IdentityProTwoFactorManager identityProTwoFactorManager, IOptions<IdentityOptions> identityOptions, IDistributedEventBus distributedEventBus, ITemplateRenderer templateRenderer, IEmailSender emailSender) 
            : base(userManager, userRepository, roleRepository, organizationUnitRepository, identityClaimTypeRepository, identityProTwoFactorManager, identityOptions, distributedEventBus)
        {
            _templateRenderer = templateRenderer;
            _emailSender = emailSender;
        }

        public override async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var identityUserDto = await base.CreateAsync(input);
            
            var emailBody = await _templateRenderer.RenderAsync("Hello", new HelloModel
            {
                Name = "John"
            });
            
            await _emailSender.SendAsync(
                ToEmail,
                "ABP Commercial",
                emailBody
            );
            
            return identityUserDto;
        }
    }

Then create a folder named Emailing and create the same structure as Emailing folder in the picture below:

Hello.tpl

    <!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
    </head>
    <body>
        hi, {{model.name}}
    </body>
    </html>

HelloModel.cs

    public class HelloModel
    {
        public string Name { get; set; }
    }

MyTemplateDefinitionProvider.cs

    public class MyTemplateDefinitionProvider : TemplateDefinitionProvider
    {
        public override void Define(ITemplateDefinitionContext context)
        {
            context.Add(
                new TemplateDefinition("Hello") //template name: "Hello"
                    .WithVirtualFilePath(
                        "/Emailing/Templates/Hello.tpl", //template content path
                        isInlineLocalized: true
                    )
            );
        }
    }

Then add the following code in MyProjectName.Application.csproj:

  <ItemGroup>
    <EmbeddedResource Include="Emailing\Templates\*.tpl" />
  </ItemGroup>

Finally, add the following code inside the ConfigureServices method in MyProjectNameApplicationModule:

            Configure<AbpVirtualFileSystemOptions>(options =>
            {
                options.FileSets.AddEmbedded<MyProjectNameApplicationModule>("MyProjectName.Emailing");
            });

When you add a user, you can find the outgoing mail in the Logs/logs.txt file (at the bottom of the MyProjectName.HttpApi.Host project).

For more information, you can refer to the following documents and demo application:

  • https://community.abp.io/articles/replacing-email-templates-and-sending-emails-jkeb8zzh

  • https://docs.abp.io/en/abp/latest/Text-Templating#replacing-the-existing-templates

  • https://docs.abp.io/en/abp/latest/Emailing

  • https://commercial.abp.io/modules/Volo.TextTemplateManagement

  • https://github.com/abpframework/abp-samples/tree/master/TextTemplateDemo

Hi,

The point we are trying to test here should not be Quartz. Currently your tests depend on Quartz, ie the behavior of a library, but this is not a good method.

In my view changing your Execute method as follows provides a more testable environment:

        public override async Task Execute(IJobExecutionContext context)
        {
            Logger.LogInformation("Starting:  EventReminderWorker...");

            
            // It might be better to write tests for this service
            await ServiceProvider
                .GetRequiredService<YourOperationService>() 
                .EventReminder();
            
            
            Logger.LogInformation("Completed: EventReminderWorker...");
        }

Hi,

You can start by creating a class in the MyProjectName.Application project. Here is my file structure of the AppService I created:

Then you can customize it as follows 👇👇

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IIdentityUserAppService), typeof(IdentityUserAppService), typeof(CustomIdentityUserAppService))]
    public class CustomIdentityUserAppService : IdentityUserAppService
    {
        public CustomIdentityUserAppService(IdentityUserManager userManager, IIdentityUserRepository userRepository, IIdentityRoleRepository roleRepository, IOrganizationUnitRepository organizationUnitRepository, IIdentityClaimTypeRepository identityClaimTypeRepository, IdentityProTwoFactorManager identityProTwoFactorManager, IOptions<IdentityOptions> identityOptions, IDistributedEventBus distributedEventBus) 
            : base(userManager, userRepository, roleRepository, organizationUnitRepository, identityClaimTypeRepository, identityProTwoFactorManager, identityOptions, distributedEventBus)
        {
        }

        public override async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
        {
            var identityUserDto = await base.CreateAsync(input);

            // ...
            Console.WriteLine("Sending email...");
            
            return identityUserDto;
        }
    }

For more information you can check this document.

Showing 291 to 300 of 332 entries
Made with ❤️ on ABP v9.0.0-preview Updated on September 19, 2024, 10:13