Compare commits

..

2 Commits

Author SHA1 Message Date
Diego
0e3898218b 10.11.44 2025-09-16 19:13:19 +08:00
Diego
61f13cef3c 10.11.43 2025-09-15 17:35:49 +08:00
21 changed files with 72 additions and 24 deletions

View File

@@ -106,6 +106,17 @@ public static class Runtime
#if NET6_0_OR_GREATER
public static Boolean IsSystemd
{
get
{
var id = Environment.GetEnvironmentVariable("INVOCATION_ID");
return !string.IsNullOrEmpty(id);
}
}
public static Boolean? isLegacyWindows;
/// <summary>

View File

@@ -21,6 +21,7 @@ public class Setting : Config<Setting>
#region
/// <summary>是否启用全局调试。默认启用</summary>
[Description("全局调试。XTrace.Debug")]
[XmlIgnore, IgnoreDataMember]
public Boolean Debug { get; set; } = true;
/// <summary>日志等级只输出大于等于该级别的日志All/Debug/Info/Warn/Error/Fatal默认Info</summary>
@@ -30,6 +31,7 @@ public class Setting : Config<Setting>
/// <summary>文件日志目录。默认Log子目录</summary>
[Description("文件日志目录。默认Log子目录")]
[XmlIgnore, IgnoreDataMember]
public String LogPath { get; set; } = "Logs/XLog";
/// <summary>日志文件上限。超过上限后拆分新日志文件默认5MB0表示不限制大小</summary>
@@ -42,6 +44,7 @@ public class Setting : Config<Setting>
/// <summary>日志文件格式。默认{0:yyyy_MM_dd}.log支持日志等级如 {1}_{0:yyyy_MM_dd}.log</summary>
[Description("日志文件格式。默认{0:yyyy_MM_dd}.log支持日志等级如 {1}_{0:yyyy_MM_dd}.log")]
[XmlIgnore, IgnoreDataMember]
public String LogFileFormat { get; set; } = "{0:yyyy_MM_dd}.log";
/// <summary>日志行格式。默认Time|ThreadId|Kind|Name|Message还支持Level</summary>

View File

@@ -52,7 +52,7 @@
<ItemGroup>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

View File

@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<PluginVersion>10.11.42</PluginVersion>
<ProPluginVersion>10.11.42</ProPluginVersion>
<DefaultVersion>10.11.42</DefaultVersion>
<PluginVersion>10.11.44</PluginVersion>
<ProPluginVersion>10.11.44</ProPluginVersion>
<DefaultVersion>10.11.44</DefaultVersion>
<AuthenticationVersion>10.11.5</AuthenticationVersion>
<SourceGeneratorVersion>10.11.4</SourceGeneratorVersion>
<NET8Version>8.0.20</NET8Version>

View File

@@ -105,6 +105,5 @@ public class BusinessPropertyWithCacheIntervalScript : BusinessPropertyWithCache
/// 报警实体脚本
/// </summary>
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptPluginEventDataModel { get; set; }
public virtual string? BigTextScriptPluginEventDataModel { get; set; }
}

View File

@@ -48,6 +48,14 @@
@Localizer["Check"]
</Button>
</div>
</div>
<div class="col-12 col-md-12 min-height-500">
<BootstrapLabel Value=@PropertyComponentLocalizer["BigTextScriptPluginEventDataModel"] ShowLabelTooltip="true" />
<CodeEditor IsReadonly=@(!CanWrite) ShowLineNo @bind-Value=@businessProperty.BigTextScriptPluginEventDataModel Language="csharp" Theme="vs-dark" />
</div>
</EditTemplate>

View File

@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes" Version="1.5.376.244" />
</ItemGroup>

View File

@@ -39,7 +39,7 @@ public class RealDBProducerProperty : BusinessPropertyWithCacheInterval
/// <summary>
/// 历史表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptHistoryTable { get; set; }
}

View File

@@ -85,7 +85,6 @@ public partial class QuestDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
DynamicSQLBase? hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -112,7 +112,6 @@ public partial class SqlDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
var hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -69,13 +69,13 @@ public class SqlDBProducerProperty : BusinessPropertyWithCacheInterval
/// <summary>
/// 实时表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRealTable { get; set; }
/// <summary>
/// 历史表脚本
/// </summary>
[DynamicProperty(Remark = "必须为间隔上传,才生效")]
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptHistoryTable { get; set; }
}

View File

@@ -102,7 +102,6 @@ public partial class TDengineDBProducer : BusinessBaseWithCacheIntervalVariable
{
_db.DbMaintenance.CreateDatabase();
//必须为间隔上传
if (!_driverPropertys.BigTextScriptHistoryTable.IsNullOrEmpty())
{
var hisModel = CSharpScriptEngineExtension.Do<DynamicSQLBase>(_driverPropertys.BigTextScriptHistoryTable);

View File

@@ -1,5 +1,6 @@
{
"ThingsGateway.Plugin.Mqtt.MqttClientProperty": {
"BigTextScriptPluginEventDataModel": "BigTextScriptPluginEventDataModel",
"CAFile_BrowserFile": "CAFile",
"ClientCertificateFile_BrowserFile": "ClientCertificateFile",
"ClientKeyFile_BrowserFile": "ClientKeyFile",
@@ -40,6 +41,7 @@
"WebSocketUrl": "WebSocketUrl"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"BigTextScriptPluginEventDataModel": "BigTextScriptPluginEventDataModel",
"AnonymousEnable": "AnonymousEnable",
"DeviceRpcEnable": "DeviceRpcEnable",
"IP": "IP",

View File

@@ -1,5 +1,6 @@
{
"ThingsGateway.Plugin.Mqtt.MqttClientProperty": {
"BigTextScriptPluginEventDataModel": "插件事件上传脚本",
"CAFile_BrowserFile": "CA文件",
"ClientCertificateFile_BrowserFile": "客户端证书",
"ClientKeyFile_BrowserFile": "客户端key文件",
@@ -40,6 +41,7 @@
"WebSocketUrl": "WebSocketUrl"
},
"ThingsGateway.Plugin.Mqtt.MqttServerProperty": {
"BigTextScriptPluginEventDataModel": "插件事件上传脚本",
"AnonymousEnable": "允许匿名登录",
"DeviceRpcEnable": "允许Rpc写入",
"IP": "IP",

View File

@@ -124,4 +124,8 @@ public class MqttClientProperty : BusinessPropertyWithCacheIntervalScript
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRpc { get; set; }
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public override string? BigTextScriptPluginEventDataModel { get; set; }
}

View File

@@ -76,4 +76,8 @@ public class MqttServerProperty : BusinessPropertyWithCacheIntervalScript
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public string? BigTextScriptRpc { get; set; }
[DynamicProperty]
[AutoGenerateColumn(Visible = true, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false)]
public override string? BigTextScriptPluginEventDataModel { get; set; }
}

View File

@@ -1,7 +1,4 @@
{
"Debug": "true",
"LogPath": "Logs/XLog",
"LogFileMaxBytes": "5", //5mb最大日志文件
"LogFileBackups": "50", //50个日志文件
"LogFileFormat": "{0:yyyy_MM_dd}.log"
"LogFileBackups": "50" //50个日志文件
}

View File

@@ -36,6 +36,7 @@ public class Program
ClaimConst.Scheme = $"{typeof(Program).Assembly.GetName().Name}{SchemeHelper.GetOrCreate()}";
Runtime.CreateConfigOnMissing = true;
#region Logo
Console.Write(Environment.NewLine);
@@ -72,8 +73,17 @@ public class Program
if (Runtime.IsLegacyWindows)
builder.Logging.ClearProviders(); //去除默认的事件日志提供者,某些情况下会日志输出异常,导致程序崩溃
}).ConfigureBuilder(builder =>
{
if (Runtime.IsSystemd)
{
builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning);
}
if (!builder.Environment.IsDevelopment())
{
builder.Services.AddResponseCompression(
@@ -108,6 +118,8 @@ public class Program
#endif
ReflectionInoHelper.RemoveAllCache();
InstanceFactory.RemoveCache();
})
@@ -136,6 +148,12 @@ public class Program
}).ConfigureBuilder(builder =>
{
if (Runtime.IsSystemd)
{
builder.ConfigureLogging(a => a.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Warning));
}
// 设置接口超时时间和上传大小-Kestrel
builder.ConfigureKestrel(u =>
{
@@ -144,11 +162,7 @@ public class Program
u.Limits.MaxRequestBodySize = null;
}).UseKestrel().Configure(app =>
{
// ✅ 最小中间件
app.Run(context =>
{
return context.Response.WriteAsync("web is disable");
});
app.Run(context => context.Response.WriteAsync("web is disable"));
});
})
.Configure(app =>

View File

@@ -73,7 +73,6 @@ public class Startup : AppStartup
services.AddRazorPages();
services.AddMvcFilter<RequestAuditFilter>();
services.AddControllers()

View File

@@ -1,5 +1,5 @@
#docker run -d --name tg --restart always -p 127.0.0.1:5000:5000 -e ASPNETCORE_ENVIRONMENT=Demo -v /thingsgateway/Keys:/app/Keys -v /thingsgateway/DB:/app/DB --memory="512m" registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest
#docker run -d --log-driver json-file --log-opt max-size=50m --log-opt max-file=5 --name tg --restart always -p 127.0.0.1:5000:5000 -p 502:502 -e ASPNETCORE_ENVIRONMENT=Demo -v /thingsgateway/Keys:/app/Keys -v /thingsgateway/DB:/app/DB --memory="512m" registry.cn-shenzhen.aliyuncs.com/thingsgateway/thingsgateway:latest
version: "latest" # Docker Compose 配置版本

View File

@@ -25,6 +25,14 @@ Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
# 文件配置
# [Journal]
# SystemMaxUse=200M # 日志最大占用200MB磁盘空间
# SystemMaxFileSize=50M # 单个日志文件最大50MB
# MaxRetentionSec=1month # 日志只保留1个月
# RuntimeMaxUse=100M # 内存中最多缓存100MB日志
# 加载服务配置文件
# systemctl daemon-reload