提交 abcf73c2 编写于 作者: W wq1234wq

更新Mysql迁移,增加异常捕获

上级 495ffad9
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Data.MySql.Migrations
{
public partial class addmodelcommand : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventEventId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleRuleId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_BaseEventEventId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_FlowRuleRuleId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "BaseEventEventId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "FlowRuleRuleId",
table: "FlowOperations");
migrationBuilder.AlterColumn<Guid>(
name: "FlowId",
table: "FlowOperations",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "BaseEventId",
table: "FlowOperations",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "FlowRuleId",
table: "FlowOperations",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "DeviceModelId",
table: "Device",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateTable(
name: "DeviceModels",
columns: table => new
{
DeviceModelId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ModelName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ModelDesc = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ModelStatus = table.Column<int>(type: "int", nullable: false),
CreateDateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Creator = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceModels", x => x.DeviceModelId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "DeviceModelCommands",
columns: table => new
{
CommandId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CommandTitle = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CommandI18N = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CommandType = table.Column<int>(type: "int", nullable: false),
CommandParams = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CommandName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
CommandTemplate = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
DeviceModelId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CreateDateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Creator = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
CommandStatus = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceModelCommands", x => x.CommandId);
table.ForeignKey(
name: "FK_DeviceModelCommands_DeviceModels_DeviceModelId",
column: x => x.DeviceModelId,
principalTable: "DeviceModels",
principalColumn: "DeviceModelId",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_BaseEventId",
table: "FlowOperations",
column: "BaseEventId");
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_FlowRuleId",
table: "FlowOperations",
column: "FlowRuleId");
migrationBuilder.CreateIndex(
name: "IX_Device_DeviceModelId",
table: "Device",
column: "DeviceModelId");
migrationBuilder.CreateIndex(
name: "IX_DeviceModelCommands_DeviceModelId",
table: "DeviceModelCommands",
column: "DeviceModelId");
migrationBuilder.AddForeignKey(
name: "FK_Device_DeviceModels_DeviceModelId",
table: "Device",
column: "DeviceModelId",
principalTable: "DeviceModels",
principalColumn: "DeviceModelId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventId",
table: "FlowOperations",
column: "BaseEventId",
principalTable: "BaseEvents",
principalColumn: "EventId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleId",
table: "FlowOperations",
column: "FlowRuleId",
principalTable: "FlowRules",
principalColumn: "RuleId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations",
column: "FlowId",
principalTable: "Flows",
principalColumn: "FlowId",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Device_DeviceModels_DeviceModelId",
table: "Device");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations");
migrationBuilder.DropTable(
name: "DeviceModelCommands");
migrationBuilder.DropTable(
name: "DeviceModels");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_BaseEventId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_FlowRuleId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_Device_DeviceModelId",
table: "Device");
migrationBuilder.DropColumn(
name: "BaseEventId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "FlowRuleId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "DeviceModelId",
table: "Device");
migrationBuilder.AlterColumn<Guid>(
name: "FlowId",
table: "FlowOperations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "BaseEventEventId",
table: "FlowOperations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "FlowRuleRuleId",
table: "FlowOperations",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_BaseEventEventId",
table: "FlowOperations",
column: "BaseEventEventId");
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_FlowRuleRuleId",
table: "FlowOperations",
column: "FlowRuleRuleId");
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventEventId",
table: "FlowOperations",
column: "BaseEventEventId",
principalTable: "BaseEvents",
principalColumn: "EventId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleRuleId",
table: "FlowOperations",
column: "FlowRuleRuleId",
principalTable: "FlowRules",
principalColumn: "RuleId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations",
column: "FlowId",
principalTable: "Flows",
principalColumn: "FlowId",
onDelete: ReferentialAction.Restrict);
}
}
}
......@@ -446,6 +446,9 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<Guid?>("CustomerId")
.HasColumnType("char(36)");
b.Property<Guid?>("DeviceModelId")
.HasColumnType("char(36)");
b.Property<int>("DeviceType")
.HasColumnType("int");
......@@ -476,6 +479,8 @@ namespace IoTSharp.Data.MySql.Migrations
b.HasIndex("CustomerId");
b.HasIndex("DeviceModelId");
b.HasIndex("OwnerId");
b.HasIndex("TenantId");
......@@ -669,6 +674,75 @@ namespace IoTSharp.Data.MySql.Migrations
b.ToTable("DeviceIdentities");
});
modelBuilder.Entity("IoTSharp.Data.DeviceModel", b =>
{
b.Property<Guid>("DeviceModelId")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<DateTime>("CreateDateTime")
.HasColumnType("datetime(6)");
b.Property<Guid>("Creator")
.HasColumnType("char(36)");
b.Property<string>("ModelDesc")
.HasColumnType("longtext");
b.Property<string>("ModelName")
.HasColumnType("longtext");
b.Property<int>("ModelStatus")
.HasColumnType("int");
b.HasKey("DeviceModelId");
b.ToTable("DeviceModels");
});
modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b =>
{
b.Property<Guid>("CommandId")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("CommandI18N")
.HasColumnType("longtext");
b.Property<string>("CommandName")
.HasColumnType("longtext");
b.Property<string>("CommandParams")
.HasColumnType("longtext");
b.Property<int>("CommandStatus")
.HasColumnType("int");
b.Property<string>("CommandTemplate")
.HasColumnType("longtext");
b.Property<string>("CommandTitle")
.HasColumnType("longtext");
b.Property<int>("CommandType")
.HasColumnType("int");
b.Property<DateTime>("CreateDateTime")
.HasColumnType("datetime(6)");
b.Property<Guid>("Creator")
.HasColumnType("char(36)");
b.Property<Guid>("DeviceModelId")
.HasColumnType("char(36)");
b.HasKey("CommandId");
b.HasIndex("DeviceModelId");
b.ToTable("DeviceModelCommands");
});
modelBuilder.Entity("IoTSharp.Data.DevicePort", b =>
{
b.Property<Guid>("PortId")
......@@ -1042,7 +1116,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<DateTime?>("AddDate")
.HasColumnType("datetime(6)");
b.Property<Guid?>("BaseEventEventId")
b.Property<Guid>("BaseEventId")
.HasColumnType("char(36)");
b.Property<string>("BizId")
......@@ -1051,10 +1125,10 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<string>("Data")
.HasColumnType("longtext");
b.Property<Guid?>("FlowId")
b.Property<Guid>("FlowId")
.HasColumnType("char(36)");
b.Property<Guid?>("FlowRuleRuleId")
b.Property<Guid>("FlowRuleId")
.HasColumnType("char(36)");
b.Property<int?>("NodeStatus")
......@@ -1074,11 +1148,11 @@ namespace IoTSharp.Data.MySql.Migrations
b.HasKey("OperationId");
b.HasIndex("BaseEventEventId");
b.HasIndex("BaseEventId");
b.HasIndex("FlowId");
b.HasIndex("FlowRuleRuleId");
b.HasIndex("FlowRuleId");
b.ToTable("FlowOperations");
});
......@@ -1647,6 +1721,10 @@ namespace IoTSharp.Data.MySql.Migrations
.WithMany("Devices")
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel")
.WithMany()
.HasForeignKey("DeviceModelId");
b.HasOne("IoTSharp.Data.Gateway", "Owner")
.WithMany("Children")
.HasForeignKey("OwnerId");
......@@ -1657,6 +1735,8 @@ namespace IoTSharp.Data.MySql.Migrations
b.Navigation("Customer");
b.Navigation("DeviceModel");
b.Navigation("Owner");
b.Navigation("Tenant");
......@@ -1680,6 +1760,17 @@ namespace IoTSharp.Data.MySql.Migrations
b.Navigation("Device");
});
modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b =>
{
b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel")
.WithMany("DeviceModelCommands")
.HasForeignKey("DeviceModelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("DeviceModel");
});
modelBuilder.Entity("IoTSharp.Data.DeviceRule", b =>
{
b.HasOne("IoTSharp.Data.Device", "Device")
......@@ -1714,15 +1805,21 @@ namespace IoTSharp.Data.MySql.Migrations
{
b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent")
.WithMany()
.HasForeignKey("BaseEventEventId");
.HasForeignKey("BaseEventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IoTSharp.Data.Flow", "Flow")
.WithMany()
.HasForeignKey("FlowId");
.HasForeignKey("FlowId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
.WithMany()
.HasForeignKey("FlowRuleRuleId");
.HasForeignKey("FlowRuleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BaseEvent");
......@@ -1836,6 +1933,11 @@ namespace IoTSharp.Data.MySql.Migrations
b.Navigation("Devices");
});
modelBuilder.Entity("IoTSharp.Data.DeviceModel", b =>
{
b.Navigation("DeviceModelCommands");
});
modelBuilder.Entity("IoTSharp.Data.Tenant", b =>
{
b.Navigation("Customers");
......
......@@ -98,7 +98,8 @@ export class I18NService extends AlainI18nBaseService {
}
loadLangData(lang: string): Observable<NzSafeAny> {
return this.http.get(`assets/tmp/i18n/${lang}.json`);
return this.http.get(`api/i18n/current?_allow_anonymous=true&lang=${lang}`);
}
use(lang: string, data: Record<string, unknown>): void {
......
......@@ -29,12 +29,23 @@ namespace IoTSharp.Controllers
[HttpPost("[action]")]
public ApiResult<PagedData<DeviceModel>> Index([FromQuery] DeviceModelParam m)
{
Expression<Func<DeviceModel, bool>> condition = x => x.ModelStatus > -1;
if (!string.IsNullOrEmpty(m.Name))
try
{
Expression<Func<DeviceModel, bool>> condition = x => x.ModelStatus > -1;
if (!string.IsNullOrEmpty(m.Name))
{
condition.And(x => x.ModelName == m.Name);
}
return new ApiResult<PagedData<DeviceModel>>(ApiCode.Success, "OK", new PagedData<DeviceModel>() { rows = _context.DeviceModels.Where(condition).Skip((m.offset) * m.limit).Take(m.limit).ToList(), total = _context.DeviceModels.Count(condition) });
}
catch (Exception e)
{
condition.And(x => x.ModelName == m.Name);
return new ApiResult<PagedData<DeviceModel>>(ApiCode.Exception, e.Message, null);
}
return new ApiResult<PagedData<DeviceModel>>(ApiCode.Success, "OK", new PagedData<DeviceModel>() { rows = _context.DeviceModels.Where(condition).Skip((m.offset) * m.limit).Take(m.limit).ToList(), total = _context.DeviceModels.Count(condition) });
}
[HttpGet("[action]")]
public ApiResult<DeviceModel> Get(Guid id)
......@@ -81,8 +92,6 @@ namespace IoTSharp.Controllers
_context.DeviceModels.Update(dm);
_context.SaveChanges();
return new ApiResult<bool>(ApiCode.CantFindObject, "Ok", true);
}
catch (Exception ex)
{
......@@ -115,9 +124,9 @@ namespace IoTSharp.Controllers
{
var dev = _context.Device.SingleOrDefault(c => c.Id == id);
if (dev!=null&&dev.DeviceModelId != null && dev.DeviceModelId != Guid.Empty)
if (dev != null && dev.DeviceModelId != null && dev.DeviceModelId != Guid.Empty)
{
return new ApiResult<List<DeviceModelCommand>>(ApiCode.Success, "Ok", _context.DeviceModelCommands.Where(c=>c.DeviceModelId==dev.DeviceModelId&&c.CommandStatus>-1).ToList());
return new ApiResult<List<DeviceModelCommand>>(ApiCode.Success, "Ok", _context.DeviceModelCommands.Where(c => c.DeviceModelId == dev.DeviceModelId && c.CommandStatus > -1).ToList());
}
......@@ -127,7 +136,7 @@ namespace IoTSharp.Controllers
[HttpGet("[action]")]
public ApiResult<List<DeviceModelCommand>> GetCommands(Guid id)
{
return new ApiResult<List<DeviceModelCommand>>(ApiCode.Success, "Ok", _context.DeviceModelCommands.Where(c => c.DeviceModelId == id&&c.CommandStatus>-1).ToList());
return new ApiResult<List<DeviceModelCommand>>(ApiCode.Success, "Ok", _context.DeviceModelCommands.Where(c => c.DeviceModelId == id && c.CommandStatus > -1).ToList());
}
[HttpGet("[action]")]
......@@ -157,8 +166,8 @@ namespace IoTSharp.Controllers
CommandParams = m.CommandParams,
CommandName = m.CommandName,
DeviceModelId = m.DeviceModelId,
CommandTemplate = m.CommandTemplate,
CreateDateTime = DateTime.Now
CommandTemplate = m.CommandTemplate,
CreateDateTime = DateTime.Now
};
_context.DeviceModelCommands.Add(dmc);
......
......@@ -104,53 +104,66 @@ namespace IoTSharp.Controllers
public async Task<ApiResult<PagedData<DeviceDetailDto>>> GetDevices([FromQuery] DeviceParam m)
{
if (m.limit > 0)
{
Expression<Func<Device, bool>> condition = x => x.Customer.Id == m.customerId && x.Status > -1;
return new ApiResult<PagedData<DeviceDetailDto>>(ApiCode.Success, "OK", new PagedData<DeviceDetailDto>
try
{
total = await _context.Device.CountAsync(condition),
rows = await _context.Device.OrderByDescending(c => c.LastActive).Where(condition).Skip((m.offset) * m.limit).Take(m.limit).Join(_context.DeviceIdentities, x => x.Id, y => y.Device.Id, (x, y) => new DeviceDetailDto()
Expression<Func<Device, bool>> condition = x => x.Customer.Id == m.customerId && x.Status > -1;
return new ApiResult<PagedData<DeviceDetailDto>>(ApiCode.Success, "OK", new PagedData<DeviceDetailDto>
{
Id = x.Id,
Name = x.Name,
LastActive = x.LastActive,
IdentityId = y.IdentityId,
IdentityValue = y.IdentityType == IdentityType.X509Certificate ? "" : y.IdentityValue,
Tenant = x.Tenant,
Customer = x.Customer,
DeviceType = x.DeviceType,
Online = x.Online,
Owner = x.Owner,
Timeout = x.Timeout,
IdentityType = y.IdentityType
}).ToListAsync()
});
total = await _context.Device.CountAsync(condition),
rows = await _context.Device.OrderByDescending(c => c.LastActive).Where(condition).Skip((m.offset) * m.limit).Take(m.limit).Join(_context.DeviceIdentities, x => x.Id, y => y.Device.Id, (x, y) => new DeviceDetailDto()
{
Id = x.Id,
Name = x.Name,
LastActive = x.LastActive,
IdentityId = y.IdentityId,
IdentityValue = y.IdentityType == IdentityType.X509Certificate ? "" : y.IdentityValue,
Tenant = x.Tenant,
Customer = x.Customer,
DeviceType = x.DeviceType,
Online = x.Online,
Owner = x.Owner,
Timeout = x.Timeout,
IdentityType = y.IdentityType
}).ToListAsync()
});
}
catch (Exception e)
{
return new ApiResult<PagedData<DeviceDetailDto>>(ApiCode.Exception, e.Message, null);
}
}
else
{
Expression<Func<Device, bool>> condition = x => x.Customer.Id == m.customerId && x.Status > -1;
return new ApiResult<PagedData<DeviceDetailDto>>(ApiCode.Success, "OK", new PagedData<DeviceDetailDto>
try
{
total = await _context.Device.CountAsync(condition),
rows = await _context.Device.OrderByDescending(c => c.LastActive).Where(condition).Select(x=> new DeviceDetailDto()
Expression<Func<Device, bool>> condition = x => x.Customer.Id == m.customerId && x.Status > -1;
return new ApiResult<PagedData<DeviceDetailDto>>(ApiCode.Success, "OK", new PagedData<DeviceDetailDto>
{
Id = x.Id,
Name = x.Name,
LastActive = x.LastActive,
Tenant = x.Tenant,
Customer = x.Customer,
DeviceType = x.DeviceType,
Online = x.Online,
Owner = x.Owner,
Timeout = x.Timeout,
}).ToListAsync()
});
total = await _context.Device.CountAsync(condition),
rows = await _context.Device.OrderByDescending(c => c.LastActive).Where(condition).Select(x => new DeviceDetailDto()
{
Id = x.Id,
Name = x.Name,
LastActive = x.LastActive,
Tenant = x.Tenant,
Customer = x.Customer,
DeviceType = x.DeviceType,
Online = x.Online,
Owner = x.Owner,
Timeout = x.Timeout,
}).ToListAsync()
});
}
catch (Exception e)
{
return new ApiResult<PagedData<DeviceDetailDto>>(ApiCode.Exception, e.Message, null);
}
}
......@@ -622,15 +635,21 @@ namespace IoTSharp.Controllers
{
var cid = User.Claims.First(c => c.Type == IoTSharpClaimTypes.Customer);
var tid = User.Claims.First(c => c.Type == IoTSharpClaimTypes.Tenant);
var devvalue = new Device() { Name = device.Name, DeviceType = device.DeviceType, Timeout = device.Timeout, LastActive = DateTime.Now, Status = 1,
DeviceModel = _context.DeviceModels.FirstOrDefault(c => c.DeviceModelId == device.DeviceModelId),
//CreateDate = DateTime.Today,
//CreateMonth =DateTime.Now.ToString("yyyy-MM"),
//CreateDateTime = DateTime.Now
};
var devvalue = new Device()
{
Name = device.Name,
DeviceType = device.DeviceType,
Timeout = device.Timeout,
LastActive = DateTime.Now,
Status = 1,
DeviceModel = _context.DeviceModels.FirstOrDefault(c => c.DeviceModelId == device.DeviceModelId),
//CreateDate = DateTime.Today,
//CreateMonth =DateTime.Now.ToString("yyyy-MM"),
//CreateDateTime = DateTime.Now
};
devvalue.Tenant = _context.Tenant.Find(new Guid(tid.Value));
devvalue.Customer = _context.Customer.Find(new Guid(cid.Value));
if (devvalue.Tenant == null || devvalue.Customer == null)
......@@ -646,7 +665,7 @@ namespace IoTSharp.Controllers
{
identity.IdentityType = device.IdentityType;
_context.DeviceIdentities.Update(identity);
_context.DeviceIdentities.Update(identity);
await _context.SaveChangesAsync();
}
......@@ -711,7 +730,7 @@ namespace IoTSharp.Controllers
try
{
_logger.LogInformation($"RPC 通过 access_token:{access_token} 找到设备{dev.Name} ");
var rpcClient = new RpcClient(_mqtt,_logger);
var rpcClient = new RpcClient(_mqtt, _logger);
var _timeout = TimeSpan.FromSeconds(timeout);
var qos = MqttQualityOfServiceLevel.AtMostOnce;
var payload = Newtonsoft.Json.JsonConvert.SerializeObject(args);
......@@ -865,7 +884,7 @@ namespace IoTSharp.Controllers
});
await _context.SaveChangesAsync();
return new ApiResult<bool>(ApiCode.Success, "Ok", true);
}
......@@ -939,7 +958,7 @@ namespace IoTSharp.Controllers
[ProducesDefaultResponseType]
public async Task<ApiResult<int>> GetSessionsCount()
{
return new ApiResult<int>(ApiCode.Success, "OK",( await _serverEx.GetClientStatusAsync()).Count);
return new ApiResult<int>(ApiCode.Success, "OK", (await _serverEx.GetClientStatusAsync()).Count);
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册