Integration
In order to interact with Components Service
you'll need to depend on the
service's contracts project:
XML |
---|
| <ProjectReference Include="$(ServicesPath)Components\ITsynch.Suite.Components.Application.Contracts\ITsynch.Suite.Components.Application.Contracts.csproj" />
|
Components can be created or updated by publishing a CreateOrUpdateComponent
message that Components Service will attend.
C# |
---|
| public record CreateOrUpdateComponent
{
public Guid CorrelationId { get; set; }
public Guid LocationId { get; set; }
public string DisplayName { get; set; }
public string Maker { get; set; }
public string Code { get; set; }
public string? SerialNumber { get; set; }
public string? FunctionDisplayName { get; set; }
}
|
In both cases, the service will publish a response with a ComponentUpdated
message if the process completed successfully.
C# |
---|
| public record ComponentUpdated
{
public Guid CorrelationId { get; set; }
public Guid LocationId { get; set; }
public string DisplayName { get; set; }
public string Maker { get; set; }
public string Code { get; set; }
public string? SerialNumber { get; set; }
public string? FunctionDisplayName { get; set; }
}
|
Messages
From your module, you are able to request two different Component's actions,
wait for their response and then continue:
Create or update Components:
C# |
---|
| var componentCorrelationId = NewId.NextGuid();
var componentLocationId = NewId.NextGuid();
var componentDisplayName = "Spa Pool System 1";
var componentCode = "POO003008001";
var componentMaker = "Abramov C&Y";
var serialNumber = "1-0002114-654789";
var FunctionDisplayName = "SPA POOL HYDRO HEALTH CENTER";
var client = this.ServiceProvider.GetRequiredService<IRequestClient<CreateOrUpdateComponent>>();
var componentCreated = (await client.GetResponse<ComponentUpdated>(new
{
CorrelationId: componentCorrelationId,
DisplayName: componentDisplayName,
Code: componentCode,
Maker: componentMaker,
SerialNumber: default(string),
FunctionDisplayName: default(string),
LocationId: componentLocationId
})).Message;
|
Events
On the other hand, you can consume the different Component's events and perform
the actions you need to do in your project.
Component Updated:
C# |
---|
| using ITsynch.Suite.Components.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class ComponentUpdatedConsumer : IConsumer<ComponentUpdated>
{
public ComponentUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<LocationUpdated> context)
{
// do some stuff
}
}
}
|
Note
ComponentUpdated
event is published when a Component is updated but
also when a Component is created.