From fea02b9974ebb22989a74d71e7449b65cecd8c58 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Sat, 23 Nov 2019 13:42:22 +0800 Subject: [PATCH] 1.0.0-rc.101 Former-commit-id: 5bac6609b26fe26fa617200303eb4ad2328849b3 --- .../Extensions/StringExtensions.cs | 7 +- .../Services/IoTNode/IoTNodeClient.cs | 6 +- .../IoT.Shared/Services/OpenApiService.cs | 4 +- .../IoTCenter/Controllers/AppController.cs | 102 +----------------- projects/IoTCenter/appsettings.json | 2 +- projects/IoTNode/appsettings.json | 2 +- projects/UserCenter/appsettings.json | 2 +- 7 files changed, 17 insertions(+), 108 deletions(-) diff --git a/projects/Infrastructure/Extensions/StringExtensions.cs b/projects/Infrastructure/Extensions/StringExtensions.cs index f54407af..b86223d4 100644 --- a/projects/Infrastructure/Extensions/StringExtensions.cs +++ b/projects/Infrastructure/Extensions/StringExtensions.cs @@ -1,5 +1,6 @@ using HtmlAgilityPack; using System; +using System.Diagnostics; using System.Linq; using System.Security.Cryptography; using System.Text; @@ -100,11 +101,15 @@ namespace Infrastructure.Extensions return Encoding.Default.GetString(ms.ToArray()); } + public static System.Collections.Generic.Dictionary list = new System.Collections.Generic.Dictionary(); + public static Guid ToGuid(this string input) { using MD5 md5 = MD5.Create(); var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(input)); - return new Guid(hash); + var guid = new Guid(hash); + //list.Add(input, guid.ToString()); + return guid; } } } \ No newline at end of file diff --git a/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs b/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs index b24a1fe4..c87ed68d 100644 --- a/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs +++ b/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs @@ -220,7 +220,11 @@ namespace IoT.Shared.Services var dataService = scope.ServiceProvider.GetService(); var eventPublisher = scope.ServiceProvider.GetService(); - if (method == $"Edit{nameof(Node)}")//服务端编辑节点 + if (method == "UpdateNode") + { + this.OnConnected(); + } + else if (method == $"Edit{nameof(Node)}")//服务端编辑节点 { var model = message.FromJson(); dataService.Edit(model); diff --git a/projects/IoT.Shared/Services/OpenApiService.cs b/projects/IoT.Shared/Services/OpenApiService.cs index 42b6dac1..853f39a2 100644 --- a/projects/IoT.Shared/Services/OpenApiService.cs +++ b/projects/IoT.Shared/Services/OpenApiService.cs @@ -27,7 +27,7 @@ namespace IoT.Shared.Services var postion = path.Key.LastIndexOf('/') + 1; var api = new Api { - Id=$"{product.Number}{path}".ToGuid(), + Id = $"{product.Number}{path}".ToGuid(), Path = path.Key.Substring(0, postion), Command = path.Key.Substring(postion), Name = operation.Value.Summary, @@ -40,7 +40,7 @@ namespace IoT.Shared.Services { api.Parameters.Add(new Parameter { - Id=$"{product.Number}{api.Path}{parameter.Name}".ToGuid(), + Id = $"{product.Number}{path}{parameter.Name}".ToGuid(), Name = parameter.Name, Description = parameter.Description, Required = parameter.Required, diff --git a/projects/IoTCenter/Controllers/AppController.cs b/projects/IoTCenter/Controllers/AppController.cs index ef7acc21..e0762fdd 100644 --- a/projects/IoTCenter/Controllers/AppController.cs +++ b/projects/IoTCenter/Controllers/AppController.cs @@ -417,40 +417,6 @@ namespace IoTCenter.Controllers /************************************************************/ - public IActionResult Data(Guid id, string time = "10m") - { - var device = this._deviceRepo.ReadOnlyTable().Include(o => o.Node).Include(o => o.Data).FirstOrDefault(o => o.Id == id); - var url = this._configuration["influxdb:url"]; - var usr = this._configuration["influxdb:usr"]; - var pwd = this._configuration["influxdb:pwd"]; - var dbName = "iot"; - var measurementName = "data"; - var list = new List(); - using (var client = new InfluxClient(new Uri(url), usr, pwd)) - { - var fileds = String.Join(',', device.Data - .Where(o => o.Type == DeviceDataType.Int || o.Type == DeviceDataType.Float) - .Select(o => o.Key)); - var query = $"select {fileds} from {measurementName} where time>now()-{time} and DeviceNumber = '{device.Number}' limit 10000"; - var result = client.ReadAsync(dbName, query).Result; - var rows = result.Results.FirstOrDefault()? - .Series.FirstOrDefault()? - .Rows; - var labels = rows?.Select(o => o.Timestamp.Value).Select(o => o.ToString("MM-dd HH:mm:ss")).ToList() ?? new List(); - foreach (var data in device.Data.Where(o => o.Type == DeviceDataType.Int || o.Type == DeviceDataType.Float)) - { - list.Add(new - { - id = data.Key, - label = data.Name, - labels, - data = rows?.Select(o => o.GetField(data.Key)).ToList() ?? new List() - }); - } - } - return Json(list); - } - public IActionResult AllPowerOn(string connectionId, string[] nodes) { this.Power(connectionId, nodes, "On", o => o.Name.Contains("开关") || o.Name.Contains("插座")); @@ -465,25 +431,7 @@ namespace IoTCenter.Controllers public IActionResult AllSwitchOn(string connectionId, string[] nodes) { - this.Power(connectionId, nodes, "On", o => o.Name.Contains("一路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult AllSwitchOff(string connectionId, string[] nodes) - { - this.Power(connectionId, nodes, "Off", o => o.Name.Contains("一路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult AllSwitch3On(string connectionId, string[] nodes) - { - this.Power(connectionId, nodes, "On", o => o.Name.Contains("三路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult AllSwitch3Off(string connectionId, string[] nodes) - { - this.Power(connectionId, nodes, "Off", o => o.Name.Contains("三路开关")); + this.Power(connectionId, nodes, "On", o => o.Name.Contains("开关")); return Json(ApiResponse.AsyncSuccess()); } @@ -499,54 +447,6 @@ namespace IoTCenter.Controllers return Json(ApiResponse.AsyncSuccess()); } - public IActionResult NodePowerOn(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "On", o => o.Name.Contains("开关") || o.Name.Contains("插座")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodePowerOff(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "Off", o => o.Name.Contains("开关") || o.Name.Contains("插座")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodeSwitchOn(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "On", o => o.Name.Contains("一路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodeSwitchOff(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "Off", o => o.Name.Contains("一路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodeSwitch3On(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "On", o => o.Name.Contains("三路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodeSwitch3Off(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "Off", o => o.Name.Contains("三路开关")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodeSocketOn(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "On", o => o.Name.Contains("插座")); - return Json(ApiResponse.AsyncSuccess()); - } - - public IActionResult NodeSocketOff(string connectionId, string node) - { - this.Power(connectionId, new string[] { node }, "Off", o => o.Name.Contains("插座")); - return Json(ApiResponse.AsyncSuccess()); - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:不捕获常规异常类型", Justification = "<挂起>")] private void Power(string connectionId, string[] nodes, string command, Func func) { diff --git a/projects/IoTCenter/appsettings.json b/projects/IoTCenter/appsettings.json index 9f6095bf..d6bf9202 100644 --- a/projects/IoTCenter/appsettings.json +++ b/projects/IoTCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-rc.100", + "version": "1.0.0-rc.101", "Logging": { "LogLevel": { "Default": "Warning", diff --git a/projects/IoTNode/appsettings.json b/projects/IoTNode/appsettings.json index 26848f5f..b03e85a9 100644 --- a/projects/IoTNode/appsettings.json +++ b/projects/IoTNode/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-rc.100", + "version": "1.0.0-rc.101", "Logging": { "LogLevel": { "Default": "Warning", diff --git a/projects/UserCenter/appsettings.json b/projects/UserCenter/appsettings.json index 45269cc2..a08f2e46 100644 --- a/projects/UserCenter/appsettings.json +++ b/projects/UserCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-rc.100", + "version": "1.0.0-rc.101", "Logging": { "LogLevel": { "Default": "Warning"