|
|
|
@ -20,6 +20,7 @@ using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Vibrant.InfluxDB.Client;
|
|
|
|
|
using Vibrant.InfluxDB.Client.Rows;
|
|
|
|
|
using IoT.Shared.Services;
|
|
|
|
|
|
|
|
|
|
namespace Platform.Services
|
|
|
|
|
{
|
|
|
|
@ -34,8 +35,8 @@ namespace Platform.Services
|
|
|
|
|
IEventHander<EntityUpdatedEvent<IoTGateway>>,
|
|
|
|
|
IEventHander<EntityDeletedEvent<IoTGateway>>,
|
|
|
|
|
IEventHander<EntityInsertedEvent<IoTProduct>>,
|
|
|
|
|
IEventHander<EntityUpdatedEvent<IoTProduct>>,
|
|
|
|
|
IEventHander<EntityDeletedEvent<IoTProduct>>,
|
|
|
|
|
//IEventHander<EntityUpdatedEvent<IoTProduct>>,
|
|
|
|
|
//IEventHander<EntityDeletedEvent<IoTProduct>>,
|
|
|
|
|
IEventHander<EntityInsertedEvent<IoTDevice>>,
|
|
|
|
|
IEventHander<EntityUpdatedEvent<IoTDevice>>,
|
|
|
|
|
IEventHander<EntityDeletedEvent<IoTDevice>>,
|
|
|
|
@ -49,6 +50,7 @@ namespace Platform.Services
|
|
|
|
|
private readonly IConfiguration _cfg;
|
|
|
|
|
private readonly ISettingService _settingService;
|
|
|
|
|
private readonly ILogger<IoTCenterEventHandler> _logger;
|
|
|
|
|
private readonly IRepository<IoTProduct> _productrepo;
|
|
|
|
|
private readonly IRepository<IoTGateway> _nodeRepo;
|
|
|
|
|
private readonly IRepository<Organ> _organRepo;
|
|
|
|
|
private readonly IRepository<BuildingIoTGateway> _buildingIoTGatewayRepo;
|
|
|
|
@ -62,6 +64,7 @@ namespace Platform.Services
|
|
|
|
|
public IoTCenterEventHandler(IConfiguration cfg,
|
|
|
|
|
ISettingService settingService,
|
|
|
|
|
ILogger<IoTCenterEventHandler> logger,
|
|
|
|
|
IRepository<IoTProduct> productRepo,
|
|
|
|
|
IRepository<IoTGateway> nodeRepo,
|
|
|
|
|
IRepository<Organ> organRepo,
|
|
|
|
|
IRepository<BuildingIoTGateway> buildingIoTGatewayRepo,
|
|
|
|
@ -75,6 +78,7 @@ namespace Platform.Services
|
|
|
|
|
this._cfg = cfg;
|
|
|
|
|
this._settingService = settingService;
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._productrepo = productRepo;
|
|
|
|
|
this._nodeRepo = nodeRepo;
|
|
|
|
|
this._organRepo = organRepo;
|
|
|
|
|
this._buildingIoTGatewayRepo = buildingIoTGatewayRepo;
|
|
|
|
@ -135,18 +139,26 @@ namespace Platform.Services
|
|
|
|
|
|
|
|
|
|
public void Handle(EntityInsertedEvent<IoTProduct> message)
|
|
|
|
|
{
|
|
|
|
|
var product = this._productrepo.Table()
|
|
|
|
|
.Include(o=>o.IoTApis)
|
|
|
|
|
.ThenInclude(o=>o.IoTParameters)
|
|
|
|
|
.FirstOrDefault(o => o.Number == message.Data.Number);
|
|
|
|
|
if(product!=null)
|
|
|
|
|
{
|
|
|
|
|
OpenApiService.UpdateApi(product);
|
|
|
|
|
}
|
|
|
|
|
this.Notify(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Handle(EntityUpdatedEvent<IoTProduct> message)
|
|
|
|
|
{
|
|
|
|
|
this.Notify(message);
|
|
|
|
|
}
|
|
|
|
|
//public void Handle(EntityUpdatedEvent<IoTProduct> message)
|
|
|
|
|
//{
|
|
|
|
|
// this.Notify(message);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
public void Handle(EntityDeletedEvent<IoTProduct> message)
|
|
|
|
|
{
|
|
|
|
|
this.Notify(message);
|
|
|
|
|
}
|
|
|
|
|
//public void Handle(EntityDeletedEvent<IoTProduct> message)
|
|
|
|
|
//{
|
|
|
|
|
// this.Notify(message);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
#endregion Product
|
|
|
|
|
|
|
|
|
|