[Table("venclass")]
public class Venclass : AggregateRoot<int>, IMultiTenant
{
public Venclass()
{
}
public Venclass(string classcode, string description, string user_entered)
{
this.class_code = classcode;
this.description = description;
this.date_entered = DateTime.Now;
this.time_entered = DateTime.Now;
this.user_entered = user_entered;
}
[Column("oid")]
public override int Id { get; protected set; }
[Column(TypeName = "varchar(4)" + CollationConst.collation)]
[StringLength(VenclassConsts.Maxclass_codeLength, MinimumLength = VenclassConsts.Minclass_codeLength)]
public virtual string class_code { get; set; }
[Column(TypeName = "varchar(30)" + CollationConst.collation)]
[StringLength(VenclassConsts.MaxdescriptionLength, MinimumLength = VenclassConsts.MindescriptionLength)]
public virtual string description { get; set; }
[DataType(DataType.Date)]
[Column(TypeName = "Date")]
public virtual DateTime? date_entered { get; set; }
[Column(TypeName = "datetime")]
public virtual DateTime? time_entered { get; set; }
[Column(TypeName = "varchar(32)" + CollationConst.collation)]
[StringLength(VenclassConsts.Maxuser_enteredLength, MinimumLength = VenclassConsts.Minuser_enteredLength)]
public virtual string user_entered { get; set; }
[Column("tenant_id")]
public virtual Guid? TenantId { get; }
}
[Authorize(VendorManagementPermissions.VendorClass.Default)]
public class VenClassAppService : VendorManagementAppService, IVenClassAppService
{
private readonly VenClassManager _vendorClassManager;
private readonly IRepository<Venclass, int> _vendorClassRepository;
public VenClassAppService(VenClassManager vendorClassManager, IRepository<Venclass, int> vendorClassRepository)
{
_vendorClassManager = vendorClassManager;
_vendorClassRepository = vendorClassRepository;
}
[Authorize(VendorManagementPermissions.VendorClass.Create)]
public async Task<VenclassDto> CreateAsync(VenclassDto input)
{
var venclass = await _vendorClassManager.CreateAsync(
input.class_code,
input.description,
input.user_entered
);
return ObjectMapper.Map<Venclass, VenclassDto>(venclass,input);
}
[Authorize(VendorManagementPermissions.VendorClass.Delete)]
public async Task DeleteAsync(int id)
{
await _vendorClassRepository.DeleteAsync(id);
}
[Authorize(VendorManagementPermissions.VendorClass.Default)]
public async Task<ListResultDto<VenclassDto>> GetAllAsync()
{
var venclass = await _vendorClassRepository.GetListAsync();
return new ListResultDto<VenclassDto>(
ObjectMapper.Map<List<Venclass>, List<VenclassDto>>(venclass)
);
}
[Authorize(VendorManagementPermissions.VendorClass.Default)]
public async Task<VenclassDto> GetAsync(int id)
{
return ObjectMapper.Map<Venclass, VenclassDto>(await _vendorClassRepository.GetAsync(id));
}
[Authorize(VendorManagementPermissions.VendorClass.Update)]
public async Task<VenclassDto> UpdateAsync(VenclassDto input)
{
var venclass = await _vendorClassRepository.GetAsync(input.Id);
ObjectMapper.Map(input, venclass);
await _vendorClassRepository.UpdateAsync(venclass);
return ObjectMapper.Map<Venclass, VenclassDto>(venclass);
}
}
Module configuration
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<VendorManagementApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<VendorManagementApplicationModule>(validate: true);
});
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = true;
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseMultiTenancy();
}
After runnig my app service create function TenantId is stored as null. Am I missing anything?
This is resolved. Thanks.
1 next) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest& request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest& request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable
1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.Entity
public class Vendors : Entity<int>, ICreationAuditedObject
{
[MaxLength(128)]
public string Name { get; set; }
public DateTime CreationTime { get; set; }
public Guid? CreatorId { get; set; }
internal Vendors(string name)
{
Name= name;
CreationTime = DateTime.Now;
CreatorId = Guid.NewGuid();
}
}
App Service
public class VendorAppService : VendorManagementAppService, IVendorManagementAppService
{
private readonly VendorManager _vendorManager;
private readonly IRepository<Vendors, int> _vendorRepository;
public VendorAppService(VendorManager vendorManager, IRepository<Vendors, int> vendorRepository)
{
_vendorManager = vendorManager;
_vendorRepository = vendorRepository;
ObjectMapperContext = typeof(VendorManagementApplicationModule);
}
[Authorize(VendorManagementPermissions.Vendors.Create)]
public async Task<VendorDto> CreateAsync(VendorDto vendor)
{
var vendor1 = await _vendorManager.CreateAsync(
vendor.Name
);
return ObjectMapper.Map<Vendors, VendorDto>(vendor1);
}
[Authorize(VendorManagementPermissions.Vendors.Delete)]
public async Task DeleteAsync(int id)
{
await _vendorRepository.DeleteAsync(id);
}
public async Task<ListResultDto<VendorDto>> GetAllAsync()
{
var vendors = await _vendorRepository.GetListAsync();
return new ListResultDto<VendorDto>(
ObjectMapper.Map<List<Vendors>, List<VendorDto>>(vendors)
);
}
public async Task<VendorDto> GetAsync(int id)
{
return ObjectMapper.Map<Vendors, VendorDto>(await _vendorRepository.GetAsync(id));
}
[Authorize(VendorManagementPermissions.Vendors.Create)]
public async Task<VendorDto> UpdateAsync(VendorDto input)
{
var vendor = await _vendorRepository.GetAsync(input.Id);
vendor.Name = input.Name;
await _vendorRepository.UpdateAsync(vendor);
return ObjectMapper.Map<Vendors, VendorDto>(vendor);
}
}
Controller
[Area(VendorManagementRemoteServiceConsts.ModuleName)]
[RemoteService(Name = VendorManagementRemoteServiceConsts.RemoteServiceName)]
public class VendorController : IVendorManagementAppService
{
private readonly IVendorManagementAppService _vendorManagementAppService;
public VendorController(IVendorManagementAppService vendorManagementAppService)
{
_vendorManagementAppService = vendorManagementAppService;
}
[Authorize]
public Task<VendorDto> CreateAsync(VendorDto vendor)
{
return _vendorManagementAppService.CreateAsync(vendor);
}
[Authorize]
public Task DeleteAsync(int id)
{
return _vendorManagementAppService.DeleteAsync(id);
}
public Task<VendorDto> GetAsync(int id)
{
return _vendorManagementAppService.GetAsync(id);
}
[Authorize]
public Task<ListResultDto<VendorDto>> GetAllAsync()
{
return _vendorManagementAppService.GetAllAsync();
}
[Authorize]
public Task<VendorDto> UpdateAsync(VendorDto vendor)
{
return _vendorManagementAppService.UpdateAsync(vendor);
}
}
Module configuration to include the repositories
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<VendorManagementDbContext>(options =>
{
options.AddDefaultRepositories(includeAllEntities: true);
});
}
Above all code is written in DDD module and reference through the micro-service. Is there anything that I'm missing?
Hi,
can you share the full error logs
8/22/2024 1:47:16 AM [Information] Request starting "HTTP/1.1" "GET" "http"://"localhost:44323""""/api/vendor-management/vendor""" - null null
8/22/2024 1:47:16 AM [Information] Executing endpoint '"CastandCrew.PSL.VendorManagement.VendorController.VendorController.GetAllAsync (CastandCrew.PSL.VendorManagement.HttpApi)"'
8/22/2024 1:47:16 AM [Information] Route matched with "{area = "vendorManagement", action = "GetAll", controller = "Vendor", page = ""}". Executing controller action with signature "System.Threading.Tasks.Task1[Volo.Abp.Application.Dtos.ListResultDto
1[CastandCrew.PSL.VendorManagement.Vendor.VendorDto]] GetAllAsync()" on controller "CastandCrew.PSL.VendorManagement.VendorController.VendorController" ("CastandCrew.PSL.VendorManagement.HttpApi").
8/22/2024 1:47:16 AM [Error] ---------- RemoteServiceErrorInfo ----------
{
"code": null,
"message": "An internal error occurred during your request!",
"details": null,
"data": {
"ActivatorChain": "CastandCrew.PSL.VendorManagement.VendorController.VendorController"
},
"validationErrors": null
}
8/22/2024 1:47:16 AM [Error] Autofac.Core.DependencyResolutionException: An exception was thrown while activating CastandCrew.PSL.VendorManagement.VendorController.VendorController. ---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'CastandCrew.PSL.VendorManagement.VendorController.VendorController' can be invoked with the available services and parameters: Cannot resolve parameter 'CastandCrew.PSL.VendorManagement.Vendor.IVendorManagementAppService vendorManagementAppService' of constructor 'Void .ctor(CastandCrew.PSL.VendorManagement.Vendor.IVendorManagementAppService)'.
See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext context, Action
1 next)
at Autofac.Builder.RegistrationBuilder3.<>c__DisplayClass39_0.<OnActivated>b__0(ResolveRequestContext context, Action
1 next)
at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) --- End of inner exception stack trace --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action
1 next)
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest& request)
at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest& request)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable
1 parameters)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
8/22/2024 1:47:16 AM [Error] ---------- Exception Data ---------- ActivatorChain = CastandCrew.PSL.VendorManagement.VendorController.VendorController
8/22/2024 1:47:16 AM [Information] Executing "ObjectResult", writing value of type '"Volo.Abp.Http.RemoteServiceErrorResponse"'. 8/22/2024 1:47:16 AM [Information] Executed action "CastandCrew.PSL.VendorManagement.VendorController.VendorController.GetAllAsync (CastandCrew.PSL.VendorManagement.HttpApi)" in 6.6256ms 8/22/2024 1:47:16 AM [Information] Executed endpoint '"CastandCrew.PSL.VendorManagement.VendorController.VendorController.GetAllAsync (CastandCrew.PSL.VendorManagement.HttpApi)"' 8/22/2024 1:47:16 AM [Information] Request finished "HTTP/1.1" "GET" "http"://"localhost:44323""""/api/vendor-management/vendor""" - 500 null "application/json; charset=utf-8" 20.7208ms
Resolved thanks.
Hi,
I've created an microservices application using ABP Studio and started all services/gateway/authserver and Angular application. I see the databases for each service is created when I browse and login to Angular application I do not see the multiple menu items like Auditing/OpenIddict/Saas on the menu list. After digging some more I see that in my Administration service database does not contains any permissions groups and permissions.
Even my own microservices permissions groups and permissions are not added.
Thanks Krishna
hi
Have you gotten any error logs in your microservices?
Hi,
This is the new database so initially I got Database does not exists exceptions but once the migrations are applied I started getting below error where I do not have any tenants created yet.
9/3/2024 5:00:30 PM [Information] Found 1 events in the outbox.
9/3/2024 5:00:31 PM [Error] Could not perform tenant created event. Canceling the operation. TenantId = 3a148325-10a8-1caa-e17d-3b436fa27506, TenantName = Tenancy_Test.
9/3/2024 5:00:31 PM [Error] System.NullReferenceException: Object reference not set to an instance of an object.
at Volo.Abp.EntityFrameworkCore.Migrations.EfCoreDatabaseMigrationEventHandlerBase1.MigrateDatabaseSchemaAsync(Nullable
1 tenantId)
at Volo.Abp.EntityFrameworkCore.Migrations.EfCoreDatabaseMigrationEventHandlerBase`1.HandleEventAsync(TenantCreatedEto eventData)
Hi @sgarad
Does the problem persist after you give the missing permissions to
admin
onIdentity Management
>Roles
page? or are not they present inpermissions
window?
Hi,
Those permissions are not available in permissions window. Those permissions groups are not created. I've attached the screenshot above in original post.
Thanks Krishna
An error occurred using the connection to database 'PSLWeb_dev3_SaasService' on server 'cm1giqldc35kxj7.caxfhp14t2hx.us-west-2.rds.amazonaws.com'. fail: Volo.Abp.RabbitMQ.RabbitMqMessageConsumer[0]
Hi,
We see all the databases have been migrated properly but still AbpPermissionGroups and AbpPermissions table are empty.. Is there any order in which services needs to starts?