Hi
I have created a separate VS Project called Integrations. In this I have created a Module:
public class GHRIntegrationModule : AbpModule
{
public override void PreInitialize()
{
var configurationAccessor = IocManager.Resolve<IAppConfigurationAccessor>();
var connectionString = configurationAccessor.Configuration["ConnectionStrings:ProjectSearch"];
if (string.IsNullOrEmpty(connectionString))
{
//Use fake project search if database connection string is empty
IocManager.Register<IProjectDataProvider, FakeProjectDataProvider>(DependencyLifeStyle.Singleton);
}
else
{
IocManager.Register<IProjectDataProvider, ProjectDataProvider>(DependencyLifeStyle.Singleton);
var projectDataProvider = Configuration.Get<ProjectDataProvider>();
projectDataProvider.DbConnectionString = connectionString;
}
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(GHRIntegrationModule).GetAssembly());
}
}
The project currently contains a single AppService:
[AbpAuthorize]
public class ProjectAppService : IProjectAppService
{
private readonly IProjectDataProvider _projectDataProvider;
public ProjectAppService(IProjectDataProvider projectDataProvider)
{
_projectDataProvider = projectDataProvider;
}
[AbpAuthorize]
public async Task<ProjectDto> GetProject(GetProjectInput input)
{
return await _projectDataProvider.GetProject(input);
}
[AbpAuthorize]
public async Task<List<ProjectDto>> SearchProjects(SearchProjectInput input)
{
return await _projectDataProvider.SearchProjects(input);
}
}
I thought that the AppService would be picked up by the auto API controller creator and included in the API but it does not show up in Swagger for example so something is missing.
I have tried to add a call to create the controller for the app service but no change. I tried to add the following to the WebCoreModule PreInitialize and my own module's PreInitialize:
Configuration.Modules.AbpAspNetCore()
.CreateControllersForAppServices(
typeof(GHRIntegrationModule).GetAssembly()
);
I think I am only missing something easy and obvious.
Any tips wpuld be very appreciated!
2 Answer(s)
-
0
Hi, can you try adding
+ [DependsOn(typeof(AbpAspNetCoreModule))] public class GHRIntegrationModule : AbpModule { // more code ... }
-
0
Ah, that got me going in the right way. It now works.
It had also to add my Module to the WebCoreModule:
[DependsOn( ... typeof(GHRIntegrationModule), .... )] public class GHRWebCoreModule
And lastly add this to WebCoreModule.PreInitialize():
Configuration.Modules.AbpAspNetCore() .CreateControllersForAppServices( typeof(GHRIntegrationModule).GetAssembly() );
Thank you @ryancyq!