1.0.0-rc.101

Former-commit-id: 5bac6609b26fe26fa617200303eb4ad2328849b3
TangShanKaiPing
wanggang 6 years ago
parent 06600c9cce
commit fea02b9974

@ -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<string, string> list = new System.Collections.Generic.Dictionary<string, string>();
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;
}
}
}

@ -220,7 +220,11 @@ namespace IoT.Shared.Services
var dataService = scope.ServiceProvider.GetService<DataService>();
var eventPublisher = scope.ServiceProvider.GetService<IEventPublisher>();
if (method == $"Edit{nameof(Node)}")//服务端编辑节点
if (method == "UpdateNode")
{
this.OnConnected();
}
else if (method == $"Edit{nameof(Node)}")//服务端编辑节点
{
var model = message.FromJson<EditNodeModel>();
dataService.Edit<Node, EditNodeModel>(model);

@ -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,

@ -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<object>();
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<DynamicInfluxRow>(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<string>();
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<object>()
});
}
}
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<Device, bool> func)
{

@ -1,5 +1,5 @@
{
"version": "1.0.0-rc.100",
"version": "1.0.0-rc.101",
"Logging": {
"LogLevel": {
"Default": "Warning",

@ -1,5 +1,5 @@
{
"version": "1.0.0-rc.100",
"version": "1.0.0-rc.101",
"Logging": {
"LogLevel": {
"Default": "Warning",

@ -1,5 +1,5 @@
{
"version": "1.0.0-rc.100",
"version": "1.0.0-rc.101",
"Logging": {
"LogLevel": {
"Default": "Warning"

Loading…
Cancel
Save