Skip to content

Commit

Permalink
产品中创建属性后,再创建设备会报错
Browse files Browse the repository at this point in the history
  • Loading branch information
SiasZhang committed Mar 22, 2023
1 parent 937a1c3 commit 203da63
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion IoTSharp/Controllers/DevicesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using DicKV = System.Collections.Generic.KeyValuePair<string, string>;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
using IoTSharp.Extensions.X509;
using AutoMapper;

namespace IoTSharp.Controllers
{
Expand Down Expand Up @@ -741,9 +742,12 @@ public async Task<ApiResult<Device>> PostDevice(Guid id, DevicePostProduceDto de
var dev = await PostDevice(dto);
if (dev.Code == (int)ApiCode.Success)
{
MapperConfiguration mapperConfiguration = new MapperConfiguration(options => { options.CreateMap<ProduceData, AttributeLatest>(); });
IMapper mapper = mapperConfiguration.CreateMapper();

var atts = produce.DefaultAttributes.Select(c =>
{
var atx = (AttributeLatest)(DataStorage)c;
AttributeLatest atx = mapper.Map<ProduceData, AttributeLatest>(c);
atx.Catalog = DataCatalog.AttributeLatest;
atx.DeviceId = dev.Data.Id;
atx.DataSide = DataSide.ServerSide;
Expand Down

0 comments on commit 203da63

Please sign in to comment.