From 495ffad901eae386dfcc26324d4263a7498cd864 Mon Sep 17 00:00:00 2001 From: wq1234wq Date: Tue, 21 Dec 2021 11:40:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B6=85=E6=97=B6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/routes/device/deviceform/deviceform.component.html | 4 +++- .../app/routes/device/deviceform/deviceform.component.ts | 1 + IoTSharp/Controllers/DevicesController.cs | 6 ++++-- IoTSharp/Dtos/DevicePostDto.cs | 4 +++- IoTSharp/Dtos/DevicePutDto.cs | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.html b/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.html index 62ec72e3..3c0c7bbd 100644 --- a/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.html +++ b/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.html @@ -12,7 +12,9 @@ - + + + diff --git a/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.ts b/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.ts index 7f54ab49..850f9b77 100644 --- a/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.ts +++ b/IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.ts @@ -55,6 +55,7 @@ export class DeviceformComponent implements OnInit { deviceType: [null, [Validators.required]], customerId: [null, []], deviceModelId: [null, []], + timeout: [300, []], id: [Guid.EMPTY, []], identityType: [Guid.EMPTY, []], }); diff --git a/IoTSharp/Controllers/DevicesController.cs b/IoTSharp/Controllers/DevicesController.cs index ce253791..6da86939 100644 --- a/IoTSharp/Controllers/DevicesController.cs +++ b/IoTSharp/Controllers/DevicesController.cs @@ -577,6 +577,7 @@ namespace IoTSharp.Controllers dev.DeviceModel = _context.DeviceModels.FirstOrDefault(c => c.DeviceModelId == device.DeviceModelId); dev.Name = device.Name; + dev.Timeout = device.Timeout; try { await _context.SaveChangesAsync(); @@ -621,7 +622,7 @@ 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 = 300, LastActive = DateTime.Now, Status = 1, + 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"), @@ -629,8 +630,9 @@ namespace IoTSharp.Controllers }; 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) { return new ApiResult(ApiCode.NotFoundTenantOrCustomer, "Not found Tenant or Customer", null); diff --git a/IoTSharp/Dtos/DevicePostDto.cs b/IoTSharp/Dtos/DevicePostDto.cs index e9699687..c0352ff0 100644 --- a/IoTSharp/Dtos/DevicePostDto.cs +++ b/IoTSharp/Dtos/DevicePostDto.cs @@ -10,7 +10,9 @@ namespace IoTSharp.Dtos { public string Name { get; set; } public DeviceType DeviceType { get; set; } - public Guid DeviceModelId { get; set; } + public Guid? DeviceModelId { get; set; } + + public int Timeout { get; set; } public IdentityType IdentityType { get; set; } } } diff --git a/IoTSharp/Dtos/DevicePutDto.cs b/IoTSharp/Dtos/DevicePutDto.cs index 4c9c54d7..96b5d618 100644 --- a/IoTSharp/Dtos/DevicePutDto.cs +++ b/IoTSharp/Dtos/DevicePutDto.cs @@ -11,7 +11,8 @@ namespace IoTSharp.Dtos public Guid Id { get; set; } public string Name { get; set; } - public Guid DeviceModelId { get; set; } + public int Timeout { get; set; } + public Guid? DeviceModelId { get; set; } public IdentityType IdentityType { get; set; } } } -- GitLab