From e216ccba5a1cfb60ad24987e496ff126e19f3f20 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Mon, 8 Aug 2022 22:15:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=81=E5=89=AA=E5=BC=95=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IoTSharp.Data.Cassandra.csproj | 7 --- .../IoTSharpDataBuilderExtensions.cs | 1 - .../IoTSharp.Data.InMemory.csproj | 8 --- .../IoTSharpDataBuilderExtensions.cs | 1 - .../IoTSharp.Data.MySQL.csproj | 6 -- .../IoTSharp.Data.Oracle.csproj | 6 -- .../IoTSharp.Data.PostgreSQL.csproj | 12 ---- .../IoTSharp.Data.SqlServer.csproj | 1 - .../IoTSharp.Data.Sqlite.csproj | 6 -- IoTSharp.Data/IoTSharp.Data.csproj | 3 - .../IoTSharp.Interpreter.csproj | 6 -- .../ScriptEnginesExtensions.cs | 3 +- .../IoTSharp.Sdk.MQTT.csproj | 2 +- IoTSharp.Test/IoTSharp.Test.csproj | 4 -- IoTSharp/Handlers/MQTTServerHandler.cs | 24 +++---- IoTSharp/IoTSharp.csproj | 62 +++---------------- IoTSharp/Startup.cs | 1 + IoTSharp/Storage/PinusDBStorage.cs | 1 - 18 files changed, 23 insertions(+), 131 deletions(-) diff --git a/IoTSharp.Data.Cassandra/IoTSharp.Data.Cassandra.csproj b/IoTSharp.Data.Cassandra/IoTSharp.Data.Cassandra.csproj index 21e72305..f17df472 100644 --- a/IoTSharp.Data.Cassandra/IoTSharp.Data.Cassandra.csproj +++ b/IoTSharp.Data.Cassandra/IoTSharp.Data.Cassandra.csproj @@ -9,13 +9,6 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/IoTSharp.Data.Cassandra/IoTSharpDataBuilderExtensions.cs b/IoTSharp.Data.Cassandra/IoTSharpDataBuilderExtensions.cs index 5da71ab9..29387df2 100644 --- a/IoTSharp.Data.Cassandra/IoTSharpDataBuilderExtensions.cs +++ b/IoTSharp.Data.Cassandra/IoTSharpDataBuilderExtensions.cs @@ -1,5 +1,4 @@  -using EFCore.Sharding; using IoTSharp.Data; using Microsoft.EntityFrameworkCore; diff --git a/IoTSharp.Data.InMemory/IoTSharp.Data.InMemory.csproj b/IoTSharp.Data.InMemory/IoTSharp.Data.InMemory.csproj index fe8d087e..d31128e5 100644 --- a/IoTSharp.Data.InMemory/IoTSharp.Data.InMemory.csproj +++ b/IoTSharp.Data.InMemory/IoTSharp.Data.InMemory.csproj @@ -11,14 +11,6 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/IoTSharp.Data.InMemory/IoTSharpDataBuilderExtensions.cs b/IoTSharp.Data.InMemory/IoTSharpDataBuilderExtensions.cs index bca44115..3e68cce8 100644 --- a/IoTSharp.Data.InMemory/IoTSharpDataBuilderExtensions.cs +++ b/IoTSharp.Data.InMemory/IoTSharpDataBuilderExtensions.cs @@ -1,5 +1,4 @@  -using EFCore.Sharding; using IoTSharp.Data; using IoTSharp.Data.InMemory; using Microsoft.EntityFrameworkCore; diff --git a/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj b/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj index 4ab1d26a..66bd5b58 100644 --- a/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj +++ b/IoTSharp.Data.MySQL/IoTSharp.Data.MySQL.csproj @@ -8,15 +8,9 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj b/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj index a419c041..2e0edb13 100644 --- a/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj +++ b/IoTSharp.Data.Oracle/IoTSharp.Data.Oracle.csproj @@ -6,15 +6,9 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj b/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj index 83f88d99..5454c01e 100644 --- a/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj +++ b/IoTSharp.Data.PostgreSQL/IoTSharp.Data.PostgreSQL.csproj @@ -7,19 +7,7 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - diff --git a/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj b/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj index 8977fca9..8babe14c 100644 --- a/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj +++ b/IoTSharp.Data.SqlServer/IoTSharp.Data.SqlServer.csproj @@ -6,7 +6,6 @@ - diff --git a/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj b/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj index 0120227c..aca8053a 100644 --- a/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj +++ b/IoTSharp.Data.Sqlite/IoTSharp.Data.Sqlite.csproj @@ -7,12 +7,6 @@ - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/IoTSharp.Data/IoTSharp.Data.csproj b/IoTSharp.Data/IoTSharp.Data.csproj index 64f805fb..4f5b7feb 100644 --- a/IoTSharp.Data/IoTSharp.Data.csproj +++ b/IoTSharp.Data/IoTSharp.Data.csproj @@ -5,11 +5,8 @@ - - - diff --git a/IoTSharp.Interpreter/IoTSharp.Interpreter.csproj b/IoTSharp.Interpreter/IoTSharp.Interpreter.csproj index 6acefa37..f34474fd 100644 --- a/IoTSharp.Interpreter/IoTSharp.Interpreter.csproj +++ b/IoTSharp.Interpreter/IoTSharp.Interpreter.csproj @@ -7,15 +7,9 @@ - - - - - - diff --git a/IoTSharp.Interpreter/ScriptEnginesExtensions.cs b/IoTSharp.Interpreter/ScriptEnginesExtensions.cs index eb2c7833..ad961d22 100644 --- a/IoTSharp.Interpreter/ScriptEnginesExtensions.cs +++ b/IoTSharp.Interpreter/ScriptEnginesExtensions.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; diff --git a/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj b/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj index 31b97ca8..e70bdc14 100644 --- a/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj +++ b/IoTSharp.SDKs/IoTSharp.Sdk.MQTT/IoTSharp.Sdk.MQTT.csproj @@ -19,7 +19,7 @@ - + diff --git a/IoTSharp.Test/IoTSharp.Test.csproj b/IoTSharp.Test/IoTSharp.Test.csproj index 626f926d..158553d9 100644 --- a/IoTSharp.Test/IoTSharp.Test.csproj +++ b/IoTSharp.Test/IoTSharp.Test.csproj @@ -12,11 +12,7 @@ - - - - diff --git a/IoTSharp/Handlers/MQTTServerHandler.cs b/IoTSharp/Handlers/MQTTServerHandler.cs index 73c97909..8c0a0ab4 100644 --- a/IoTSharp/Handlers/MQTTServerHandler.cs +++ b/IoTSharp/Handlers/MQTTServerHandler.cs @@ -545,16 +545,16 @@ namespace IoTSharp.Handlers Uri uri = new Uri("mqtt://" + obj.Endpoint); isLoopback = uri.IsLoopback; } - if (isLoopback && !string.IsNullOrEmpty(e.ClientId) && e.ClientId == _mcsetting.MqttBroker && !string.IsNullOrEmpty(e.Username) ) + if (isLoopback && !string.IsNullOrEmpty(e.ClientId) && e.ClientId == _mcsetting.MqttBroker && !string.IsNullOrEmpty(e.UserName) ) { e.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.Success; } else { - _logger.LogInformation($"ClientId={obj.ClientId},Endpoint={obj.Endpoint},Username={obj.Username},Password={obj.Password}"); + _logger.LogInformation($"ClientId={obj.ClientId},Endpoint={obj.Endpoint},Username={obj.UserName},Password={obj.Password}"); var mcr = _dbContextcv.DeviceIdentities.Include(d => d.Device).FirstOrDefault(mc => - (mc.IdentityType == IdentityType.AccessToken && mc.IdentityId == obj.Username) || - (mc.IdentityType == IdentityType.DevicePassword && mc.IdentityId == obj.Username && mc.IdentityValue == obj.Password)); + (mc.IdentityType == IdentityType.AccessToken && mc.IdentityId == obj.UserName) || + (mc.IdentityType == IdentityType.DevicePassword && mc.IdentityId == obj.UserName && mc.IdentityValue == obj.Password)); if (mcr != null) { try @@ -563,7 +563,7 @@ namespace IoTSharp.Handlers e.SessionItems.Add(nameof(Device), device); e.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.Success; - _logger.LogInformation($"Device {device.Name}({device.Id}) is online !username is {obj.Username} and is endpoint{obj.Endpoint}"); + _logger.LogInformation($"Device {device.Name}({device.Id}) is online !username is {obj.UserName} and is endpoint{obj.Endpoint}"); } catch (Exception ex) { @@ -574,35 +574,35 @@ namespace IoTSharp.Handlers else if (_dbContextcv.AuthorizedKeys.Any(ak => ak.AuthToken == obj.Password)) { var ak = _dbContextcv.AuthorizedKeys.Include(ak => ak.Customer).Include(ak => ak.Tenant).Include(ak => ak.Devices).FirstOrDefault(ak => ak.AuthToken == obj.Password); - if (ak != null && !ak.Devices.Any(dev => dev.Name == obj.Username)) + if (ak != null && !ak.Devices.Any(dev => dev.Name == obj.UserName)) { - var devvalue = new Device() { Name = obj.Username, DeviceType = DeviceType.Device, Timeout = 300, LastActive = DateTime.Now }; + var devvalue = new Device() { Name = obj.UserName, DeviceType = DeviceType.Device, Timeout = 300, LastActive = DateTime.Now }; devvalue.Tenant = ak.Tenant; devvalue.Customer = ak.Customer; _dbContextcv.Device.Add(devvalue); ak.Devices.Add(devvalue); - _dbContextcv.AfterCreateDevice(devvalue, obj.Username, obj.Password); + _dbContextcv.AfterCreateDevice(devvalue, obj.UserName, obj.Password); _dbContextcv.SaveChanges(); } - var mcp = _dbContextcv.DeviceIdentities.Include(d => d.Device).FirstOrDefault(mc => mc.IdentityType == IdentityType.DevicePassword && mc.IdentityId == obj.Username && mc.IdentityValue == obj.Password); + var mcp = _dbContextcv.DeviceIdentities.Include(d => d.Device).FirstOrDefault(mc => mc.IdentityType == IdentityType.DevicePassword && mc.IdentityId == obj.UserName && mc.IdentityValue == obj.Password); if (mcp != null) { e.SessionItems.Add(nameof(Device), mcp.Device); e.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.Success; - _logger.LogInformation($"Device {mcp.Device.Name}({mcp.Device.Id}) is online !username is {obj.Username} and is endpoint{obj.Endpoint}"); + _logger.LogInformation($"Device {mcp.Device.Name}({mcp.Device.Id}) is online !username is {obj.UserName} and is endpoint{obj.Endpoint}"); } else { e.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.BadUserNameOrPassword; - _logger.LogInformation($"Bad username or password/AuthToken {obj.Username},connection {obj.Endpoint} refused"); + _logger.LogInformation($"Bad username or password/AuthToken {obj.UserName},connection {obj.Endpoint} refused"); } } else { e.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.BadUserNameOrPassword; - _logger.LogInformation($"Bad username or password {obj.Username},connection {obj.Endpoint} refused"); + _logger.LogInformation($"Bad username or password {obj.UserName},connection {obj.Endpoint} refused"); } } diff --git a/IoTSharp/IoTSharp.csproj b/IoTSharp/IoTSharp.csproj index 964787a8..e19c20c4 100644 --- a/IoTSharp/IoTSharp.csproj +++ b/IoTSharp/IoTSharp.csproj @@ -53,30 +53,21 @@ - - - - - - - - - @@ -84,19 +75,16 @@ - - - @@ -104,62 +92,28 @@ - - - - - - - - - - - + + - - - - - - - - - + + + - - - - - - - + + true + - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - diff --git a/IoTSharp/Startup.cs b/IoTSharp/Startup.cs index 924cd7e7..476312ce 100644 --- a/IoTSharp/Startup.cs +++ b/IoTSharp/Startup.cs @@ -60,6 +60,7 @@ namespace IoTSharp // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + System.Text.Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var settings = Configuration.Get(); services.Configure((Action)(setting => { diff --git a/IoTSharp/Storage/PinusDBStorage.cs b/IoTSharp/Storage/PinusDBStorage.cs index 221cf41b..fbfd20a0 100644 --- a/IoTSharp/Storage/PinusDBStorage.cs +++ b/IoTSharp/Storage/PinusDBStorage.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.Options; using Org.BouncyCastle.Utilities.Encoders; using PinusDB.Data; -using Silkier; using Silkier.EFCore; using System; using System.Collections.Generic; -- GitLab