From d63c3aaa802e1696c13ea45a78c67d2b7bfe0045 Mon Sep 17 00:00:00 2001
From: Kimdiego2098 <2248356998@qq.com>
Date: Sun, 19 Nov 2023 14:15:58 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8F=92=E4=BB=B6=E7=BB=A7?=
=?UTF-8?q?=E6=89=BF=E5=B1=9E=E6=80=A7=E6=97=B6=EF=BC=8C=E5=8E=BB=E9=99=A4?=
=?UTF-8?q?=E4=B8=8D=E9=87=8D=E5=86=99=E7=89=B9=E6=80=A7=E7=9A=84=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Foundation/Extensions/StringExtensions.cs | 2 +-
.../DriverPlugin/DriverPluginService.cs | 20 +++++++++++++++----
.../Util/EncodingMapper.cs | 2 +-
.../Entity/AlarmVariable.cs | 4 +---
.../QuestDB/QuestDB.cs | 2 +-
.../QuestDB/QuestDBHistoryValue.cs | 2 +-
.../QuestDB/QuestDBMed.cs | 13 ------------
.../TDengineDB/TDHistoryValue.cs | 2 +-
.../TDengineDB/TDengineDB.cs | 2 +-
.../TDengineDB/TDengineDBMed.cs | 14 -------------
.../ThingsGateway.Web.Entry.csproj | 7 ++-----
11 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/framework/foundation/ThingsGateway.Foundation/Foundation/Extensions/StringExtensions.cs b/framework/foundation/ThingsGateway.Foundation/Foundation/Extensions/StringExtensions.cs
index 68b96aab1..10ec2f99a 100644
--- a/framework/foundation/ThingsGateway.Foundation/Foundation/Extensions/StringExtensions.cs
+++ b/framework/foundation/ThingsGateway.Foundation/Foundation/Extensions/StringExtensions.cs
@@ -21,7 +21,7 @@ namespace ThingsGateway.Foundation.Extension.String;
public static class StringExtensions
{
///
- /// 转换布尔值
+ /// 转换布尔值,注意 1,0,on,off ,true,false 都会对应转换
///
///
///
diff --git a/framework/gateway/ThingsGateway.Gateway.Application/Plugin/DriverPlugin/DriverPluginService.cs b/framework/gateway/ThingsGateway.Gateway.Application/Plugin/DriverPlugin/DriverPluginService.cs
index c0ef2b7be..25ed2f62e 100644
--- a/framework/gateway/ThingsGateway.Gateway.Application/Plugin/DriverPlugin/DriverPluginService.cs
+++ b/framework/gateway/ThingsGateway.Gateway.Application/Plugin/DriverPlugin/DriverPluginService.cs
@@ -267,7 +267,19 @@ public class DriverPluginService : ISingleton
}, true);
return data;
}
-
+ static T GetCustomAttributeRecursive(PropertyInfo property) where T : Attribute
+ {
+ var attribute = property.GetCustomAttribute(false);
+ if (attribute == null && property.DeclaringType.BaseType != null)
+ {
+ var baseProperty = property.DeclaringType.BaseType.GetProperties().FirstOrDefault(p => p.Name == property.Name);
+ if (baseProperty != null)
+ {
+ attribute = GetCustomAttributeRecursive(baseProperty);
+ }
+ }
+ return attribute;
+ }
///
/// 获取插件的属性值
///
@@ -278,7 +290,7 @@ public class DriverPluginService : ISingleton
var data = _serviceScope.ServiceProvider.GetService().GetOrCreate($"{nameof(GetDriverProperties)}", cacheKey, c =>
{
var data = driver.DriverPropertys?.GetType().GetProperties().SelectMany(it =>
- new[] { new { memberInfo = it, attribute = it.GetCustomAttribute() } })
+ new[] { new { memberInfo = it, attribute = GetCustomAttributeRecursive(it) } })
.Where(x => x.attribute != null).ToList()
.SelectMany(it => new[]
{
@@ -305,7 +317,7 @@ public class DriverPluginService : ISingleton
var data = _serviceScope.ServiceProvider.GetService().GetOrCreate($"{nameof(GetDriverVariableProperties)}", cacheKey, c =>
{
var data = driver.VariablePropertys?.GetType().GetProperties()?.SelectMany(it =>
- new[] { new { memberInfo = it, attribute = it.GetCustomAttribute() } })
+ new[] { new { memberInfo = it, attribute = GetCustomAttributeRecursive(it) } })
?.Where(x => x.attribute != null).ToList()
?.SelectMany(it => new[]
{
@@ -380,7 +392,7 @@ public class DriverPluginService : ISingleton
/// 插件属性,检索相同名称的属性后写入
public void SetDriverProperties(DriverBase driver, List deviceProperties)
{
- var pluginPropertys = driver.DriverPropertys?.GetType().GetProperties().Where(a => a.GetCustomAttribute(typeof(DevicePropertyAttribute)) != null)?.ToList();
+ var pluginPropertys = driver.DriverPropertys?.GetType().GetProperties().Where(a => GetCustomAttributeRecursive(a) != null)?.ToList();
foreach (var propertyInfo in pluginPropertys ?? new())
{
var deviceProperty = deviceProperties.FirstOrDefault(x => x.PropertyName == propertyInfo.Name);
diff --git a/framework/gateway/ThingsGateway.Gateway.Application/Util/EncodingMapper.cs b/framework/gateway/ThingsGateway.Gateway.Application/Util/EncodingMapper.cs
index 949b7b30d..4b51cc1ba 100644
--- a/framework/gateway/ThingsGateway.Gateway.Application/Util/EncodingMapper.cs
+++ b/framework/gateway/ThingsGateway.Gateway.Application/Util/EncodingMapper.cs
@@ -17,7 +17,7 @@ using System.Text;
namespace ThingsGateway.Gateway.Application;
///
-/// Master规则
+/// Master规则
///
public class EncodingMapper : IRegister
{
diff --git a/framework/gateway/ThingsGateway.Gateway.Core/Entity/AlarmVariable.cs b/framework/gateway/ThingsGateway.Gateway.Core/Entity/AlarmVariable.cs
index 66d995a5d..e1107b866 100644
--- a/framework/gateway/ThingsGateway.Gateway.Core/Entity/AlarmVariable.cs
+++ b/framework/gateway/ThingsGateway.Gateway.Core/Entity/AlarmVariable.cs
@@ -12,10 +12,8 @@
namespace ThingsGateway.Gateway.Core;
///
-/// 历史报警表
+/// 报警变量
///
-[IgnoreSqlTable]
-[SugarTable("historyAlarm", TableDescription = "历史报警表")]
public class AlarmVariable : PrimaryIdEntity
{
///
diff --git a/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDB.cs b/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDB.cs
index dd830fe17..44e8e1578 100644
--- a/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDB.cs
+++ b/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDB.cs
@@ -59,7 +59,7 @@ public partial class QuestDB : UpLoadBaseWithCache()
- .Map(dest => dest.Value, (src) => ValueReturn(src))
+ .Map(dest => dest.Value, src => src.Value == null ? string.Empty : src.Value.ToString() ?? string.Empty)
.Map(dest => dest.CollectTime, (src) => src.CollectTime < DateTime.MinValue ? DateTime.MinValue.ToUniversalTime() : src.CollectTime.ToUniversalTime())//注意sqlsugar插入时无时区,直接utc时间
.Map(dest => dest.CreateTime, (src) => DateTime.UtcNow)
;//注意sqlsugar插入时无时区,直接utc时间
diff --git a/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBHistoryValue.cs b/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBHistoryValue.cs
index 9bb08c124..26d54d2fe 100644
--- a/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBHistoryValue.cs
+++ b/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBHistoryValue.cs
@@ -57,5 +57,5 @@ public class QuestDBHistoryValue
/// 变量值
///
[Description("变量值")]
- public double Value { get; set; }
+ public string Value { get; set; }
}
diff --git a/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBMed.cs b/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBMed.cs
index a4f63b99b..1dd9e8ccd 100644
--- a/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBMed.cs
+++ b/framework/plugin/ThingsGateway.Plugin.QuestDB/QuestDB/QuestDBMed.cs
@@ -22,7 +22,6 @@ using System.ComponentModel.DataAnnotations;
using System.Reflection;
using ThingsGateway.Foundation.Extension.Generic;
-using ThingsGateway.Foundation.Extension.String;
using Yitter.IdGenerator;
@@ -39,18 +38,6 @@ public partial class QuestDB : UpLoadBaseWithCache cacheItems, IEnumerable dev)
{
diff --git a/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDHistoryValue.cs b/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDHistoryValue.cs
index f33b833c7..1e9038851 100644
--- a/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDHistoryValue.cs
+++ b/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDHistoryValue.cs
@@ -58,5 +58,5 @@ public class TDHistoryValue : STable
///
[Description("变量值")]
[SugarColumn(Length = 18, DecimalDigits = 2)]
- public double Value { get; set; }
+ public string Value { get; set; }
}
diff --git a/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDB.cs b/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDB.cs
index 3cec9399d..cbb2a6de5 100644
--- a/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDB.cs
+++ b/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDB.cs
@@ -59,7 +59,7 @@ public partial class TDengineDB : UpLoadBaseWithCache()
- .Map(dest => dest.Value, (src) => ValueReturn(src));
+ .Map(dest => dest.Value, src => src.Value == null ? string.Empty : src.Value.ToString() ?? string.Empty);
base.Init(client);
}
diff --git a/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDBMed.cs b/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDBMed.cs
index 8e95a95f5..da5637d0e 100644
--- a/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDBMed.cs
+++ b/framework/plugin/ThingsGateway.Plugin.TDengineDB/TDengineDB/TDengineDBMed.cs
@@ -22,7 +22,6 @@ using System.ComponentModel.DataAnnotations;
using System.Reflection;
using ThingsGateway.Foundation.Extension.Generic;
-using ThingsGateway.Foundation.Extension.String;
using Yitter.IdGenerator;
@@ -39,19 +38,6 @@ public partial class TDengineDB : UpLoadBaseWithCache cacheItems, IEnumerable dev)
{
var data = dev.ChunkBetter(_driverPropertys.CacheItemCount);
diff --git a/framework/web/ThingsGateway.Web.Entry/ThingsGateway.Web.Entry.csproj b/framework/web/ThingsGateway.Web.Entry/ThingsGateway.Web.Entry.csproj
index 6e082e890..3ce3c1632 100644
--- a/framework/web/ThingsGateway.Web.Entry/ThingsGateway.Web.Entry.csproj
+++ b/framework/web/ThingsGateway.Web.Entry/ThingsGateway.Web.Entry.csproj
@@ -8,12 +8,9 @@
-
- <_WebToolingArtifacts Remove="Properties\PublishProfiles\linux64_net6.pubxml" />
- <_WebToolingArtifacts Remove="Properties\PublishProfiles\linux64_net7.pubxml" />
- <_WebToolingArtifacts Remove="Properties\PublishProfiles\win64_net6.pubxml" />
- <_WebToolingArtifacts Remove="Properties\PublishProfiles\win64_net7.pubxml" />
+ <_WebToolingArtifacts Remove="Properties\PublishProfiles\linux64_net6.pubxml" />
+ <_WebToolingArtifacts Remove="Properties\PublishProfiles\linux64_net8.pubxml" />