Hello, Our project structure is mentioned in this ticket : https://support.abp.io/QA/Questions/4663#answer-3a09d256-58d0-4c55-dc67-7e989f693fb3
We tried to add Hangfire in Admin part of the project (ConfigurateurClient.Admin.HttpApi.Host\AdminHttpApiHostModule.cs).
we called app.UseHangFireDashboard on the last line of OnApplicationInitialization method.
The Admin.HangFire pemrission is well defined in the application.contract layer
But when we want acces to https://localhost:44340/hangfire, we have this message.
Avez-vous des informations sur ce que nous aurions pu manquer pour générer ce type d'erreur ?
ABP Framework version: v7.0.0
UI type: Angular and Blazor (not relevant here)
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): no
Hello, Our project is an application that is composed of two back. (see screenshot)
we want that when launching a database migration, 3 roles are created and that the permissions (already defined) are set for the created roles. Permissions are defined in the folders:
ConfigurateurClient.Admin.Application.Contracts/Permissions and
ConfigurateurClient.Application.Contracts/Permissions
We have created a DataSeeding in the application layer
namespace ConfigurateurClient.Admin.DataSeeding
{
public class DataSeedingRoleAppService : AdminAppService, IDataSeedingRoleAppService
{
private readonly IRepository _userRepository;
private readonly IRepository _roleRepository;
private readonly IIdentityRoleAppService _identityAppService;
private readonly IPermissionAppService _permissionAppService;
private readonly IPermissionManager _permissionManager;
public DataSeedingRoleAppService(IRepository userRepository, IRepository roleRepository, IIdentityRoleAppService identityAppService, IPermissionAppService permissionAppService, IPermissionManager permissionManager)
{
_userRepository = userRepository;
_roleRepository = roleRepository;
_identityAppService = identityAppService;
_permissionAppService = permissionAppService;
_permissionManager = permissionManager;
}
public async Task PostCreateDefaultRoles()
{
var roles = await _roleRepository.GetListAsync();
await CreateRoleAdmin(roles);
await CreateRoleClient(roles);
await CreateRoleManuloc(roles);
}
private async Task CreateRoleAdmin(List listRoles)
{
var isRoleAdminExist = listRoles.Where(r => r.Name == "admin").ToList();
IdentityRoleDto roleAdmin = new();
if(isRoleAdminExist.Count == 0)
{
roleAdmin = await _identityAppService.CreateAsync(new IdentityRoleCreateDto
{
Name = "admin",
IsDefault = false,
IsPublic = true
});
}
}
private async Task CreateRoleClient(List listRoles)
{
var isRoleClientExist = listRoles.Where(r => r.Name == "client").ToList();
if (isRoleClientExist.Count == 0)
{
await _identityAppService.CreateAsync(new IdentityRoleCreateDto
{
Name = "client",
IsDefault = false,
IsPublic = true
});
}
}
private async Task CreateRoleManuloc(List listRoles)
{
var isRoleManuloxExist = listRoles.Where(r => r.Name == "manuloc").ToList();
IdentityRoleDto roleManuloc = new();
if (isRoleManuloxExist.Count == 0)
{
roleManuloc = await _identityAppService.CreateAsync(new IdentityRoleCreateDto
{
Name = "manuloc",
IsDefault = false,
IsPublic = true
});
}
await SetPermissionToRoleManuloc(roleManuloc);
}
private async Task SetPermissionToRoleManuloc(IdentityRoleDto roleManuloc)
{
UpdatePermissionsDto Permissions = new();
List permission = new List();
permission.Add(new UpdatePermissionDto { Name = "Admin.Client",IsGranted = true});
permission.Add(new UpdatePermissionDto { Name = "Admin.Configuration", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.Contact", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.Option", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.GroupeOption", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.Modeles", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.Ulisateur", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.Caracteristique", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.TauxLocation", IsGranted = true });
permission.Add(new UpdatePermissionDto { Name = "Admin.Ulisateur", IsGranted = true });
Permissions.Permissions = permission.ToArray();
await _permissionAppService.UpdateAsync("R", "manuloc", Permissions);
}
}
}
But, we want that when launching a database migration.
We tried to use the IDataSeedContributor, but some Repositories are not accessible.
public class DataSeedingRoleAppService : IDataSeedContributor, ITransientDependency
{
private readonly IIdentityRoleAppService _identityAppService;
private readonly IPermissionAppService _permissionAppService;
public DataSeedingRoleAppService(IIdentityRoleAppService identityAppService, IPermissionAppService permissionAppService)
{
_identityAppService = identityAppService;
_permissionAppService = permissionAppService;
}
}
then I launched a database migration and got this error :
Exception message and stack trace: [16:00:51 INF] Executing host database seed... Unhandled exception. Autofac.Core.DependencyResolutionException: An exception was thrown while activating ConfigurateurClient.Admin.DataSeeding.DataSeedingRoleAppService. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'ConfigurateurClient.Admin.DataSeeding.DataSeedingRoleAppService' can be invoked with the available services and parameters: Cannot resolve parameter 'Volo.Abp.Identity.IIdentityRoleAppService identityAppService' of constructor 'Void .ctor(Volo.Abp.Identity.IIdentityRoleAppService, Volo.Abp.PermissionManagement.IPermissionAppService)'. at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass12_0.b__0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.
(String[] args)
ABP Framework version: v7.0.0 UI type: Angular and Blazor (not relevant here)
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): no