From 60702480e73f9627d3ca5ccb49d1764aac9c835a Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Mon, 3 Jun 2019 22:48:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=BE=E5=A4=87=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E4=BD=BF=E7=94=A8DevicePostDto=E6=9D=A5?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=8D=95=E7=8B=AC=E5=88=9B=E5=BB=BA=EF=BC=8C?= =?UTF-8?q?=20=E8=80=8C=E4=B8=8D=E6=98=AFDevice=E7=B1=BB=EF=BC=8C=E5=8F=A6?= =?UTF-8?q?=E5=A4=96=EF=BC=8C=20=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IoTSharp.Test/IoTSharp.Test.csproj | 2 +- IoTSharp/Controllers/DevicesController.cs | 18 +++++++++--------- IoTSharp/Dtos/DevicePostDto.cs | 14 ++++++++++++++ IoTSharp/IoTSharp.csproj | 4 ++-- README.md | 12 ++++++++++++ 5 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 IoTSharp/Dtos/DevicePostDto.cs diff --git a/IoTSharp.Test/IoTSharp.Test.csproj b/IoTSharp.Test/IoTSharp.Test.csproj index 523cf1bb..e1752d8d 100644 --- a/IoTSharp.Test/IoTSharp.Test.csproj +++ b/IoTSharp.Test/IoTSharp.Test.csproj @@ -9,7 +9,7 @@ - + diff --git a/IoTSharp/Controllers/DevicesController.cs b/IoTSharp/Controllers/DevicesController.cs index 697e761b..b93e77f2 100644 --- a/IoTSharp/Controllers/DevicesController.cs +++ b/IoTSharp/Controllers/DevicesController.cs @@ -185,21 +185,21 @@ namespace IoTSharp.Controllers // POST: api/Devices [Authorize(Roles = nameof(UserRole.CustomerAdmin))] [HttpPost] - public async Task> PostDevice(Device device) + public async Task> PostDevice(DevicePostDto device) { var cid = User.Claims.First(c => c.Type == IoTSharpClaimTypes.Customer); var tid = User.Claims.First(c => c.Type == IoTSharpClaimTypes.Tenant); - - device.Tenant = _context.Tenant.Find(new Guid(tid.Value)); - device.Customer = _context.Customer.Find(new Guid(cid.Value)); - if (device.Tenant == null || device.Customer == null) + var devvalue = new Device() { Name = device.Name, DeviceType = device.DeviceType }; + 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 NotFound(new ApiResult(ApiCode.NotFoundTenantOrCustomer, $"Not found Tenant or Customer ", device)); + return NotFound(new ApiResult(ApiCode.NotFoundTenantOrCustomer, $"Not found Tenant or Customer ", device)); } - _context.Device.Add(device); - _context.AfterCreateDevice(device); + _context.Device.Add(devvalue); + _context.AfterCreateDevice(devvalue); await _context.SaveChangesAsync(); - return await GetDevice(device.Id); + return await GetDevice(devvalue.Id); } // DELETE: api/Devices/5 diff --git a/IoTSharp/Dtos/DevicePostDto.cs b/IoTSharp/Dtos/DevicePostDto.cs new file mode 100644 index 00000000..6b26a6fe --- /dev/null +++ b/IoTSharp/Dtos/DevicePostDto.cs @@ -0,0 +1,14 @@ +using IoTSharp.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace IoTSharp.Dtos +{ + public class DevicePostDto + { + public string Name { get; set; } + public DeviceType DeviceType { get; set; } + } +} diff --git a/IoTSharp/IoTSharp.csproj b/IoTSharp/IoTSharp.csproj index 0089f130..a1a2d479 100644 --- a/IoTSharp/IoTSharp.csproj +++ b/IoTSharp/IoTSharp.csproj @@ -2,7 +2,7 @@ netcoreapp2.2 - win7-x64;rhel.7-x64;ubuntu.16.04-x64 + win7-x64;rhel.7-x64;ubuntu.18.04-x64 true true true @@ -79,7 +79,7 @@ - + diff --git a/README.md b/README.md index 2c760431..9fb2c16d 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,15 @@ IoTSharp is an open-source IoT platform for data collection, processing, visuali ![IotSharp Logo](docs/images/iot_sharp_logo.png) + +## How to install ? + - mkdir /var/lib/iotsharp/ + - cp ./* /var/lib/iotsharp/ + - chmod 777 /var/lib/iotsharp/IoTSharp + - cp iotsharp.service /etc/systemd/system/iotsharp.service + - sudo systemctl enable /etc/systemd/system/iotsharp.service + - sudo systemctl start iotsharp.service + - sudo journalctl -fu iotsharp.service + - http://127.0.0.1:80/ + - + -- GitLab