mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-29 22:53:59 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96711ba022 | ||
|
|
cbfc0fdbdc | ||
|
|
6e81886c0e | ||
|
|
2d976bc132 | ||
|
|
57f6a476af | ||
|
|
8491ed296e | ||
|
|
cd1288afdc |
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Version>2.1.0.4</Version>
|
||||
<Version>2.1.0.5</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
<Copyright>© 2023-present Diego</Copyright>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<MSheet>
|
||||
<MCard Flat Href=@CONFIG_COPYRIGHT_URL Target="_blank">
|
||||
<MLabel Style="background-color:inherit;" Class="text-subtltie-2">@CONFIG_COPYRIGHT</MLabel>
|
||||
<MLabel Style="background-color:inherit;" Class="text-subtltie-2 ml-4">@Version</MLabel>
|
||||
<MLabel Style="background-color:inherit;white-space: pre;" Class="text-subtltie-2 ml-4">@Version</MLabel>
|
||||
</MCard>
|
||||
</MSheet>
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Components;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
using ThingsGateway.Admin.Core;
|
||||
|
||||
namespace ThingsGateway.Admin.Blazor.Core;
|
||||
/// <summary>
|
||||
/// Foter
|
||||
@@ -40,7 +42,12 @@ public partial class Foter
|
||||
/// <inheritdoc/>
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Version = "v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
var assembly = Assembly.GetEntryAssembly();
|
||||
if (assembly != null)
|
||||
{
|
||||
Version = $"v{assembly.GetName().Version} {new System.IO.FileInfo(assembly.Location).LastWriteTime.ToDefaultDateTimeFormat()}";
|
||||
}
|
||||
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
using Furion;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -157,7 +159,7 @@ public abstract class CollectBase : DriverBase
|
||||
{
|
||||
deviceVariableSourceRead.DeviceVariables.ForEach(it =>
|
||||
{
|
||||
var operResult = it.SetValue(null,isOnline:false);
|
||||
var operResult = it.SetValue(null, isOnline: false);
|
||||
if (!operResult.IsSuccess)
|
||||
{
|
||||
_logger.LogWarning("变量值更新失败:" + operResult.Message);
|
||||
@@ -220,6 +222,31 @@ public abstract class CollectBase : DriverBase
|
||||
}
|
||||
}
|
||||
|
||||
internal override void NewMessage(TouchSocket.Core.LogLevel arg1, object arg2, string arg3, Exception arg4)
|
||||
{
|
||||
if (IsSaveLog)
|
||||
{
|
||||
if (arg3.StartsWith(FoundationConst.LogMessageHeader))
|
||||
{
|
||||
var customLevel = App.GetConfig<Microsoft.Extensions.Logging.LogLevel?>("Logging:LogLevel:BackendLog") ?? Microsoft.Extensions.Logging.LogLevel.Trace;
|
||||
if ((byte)arg1 < (byte)customLevel)
|
||||
{
|
||||
var logRuntime = new BackendLog
|
||||
{
|
||||
LogLevel = (Microsoft.Extensions.Logging.LogLevel)arg1,
|
||||
LogMessage = arg3,
|
||||
LogSource = "采集设备:" + CurDevice.Name,
|
||||
LogTime = SysDateTimeExtensions.CurrentDateTime,
|
||||
Exception = null,
|
||||
};
|
||||
_logQueues.Enqueue(logRuntime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
base.NewMessage(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回全部内容字节数组
|
||||
/// <br></br>
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.Foundation;
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
|
||||
using TouchSocket.Core;
|
||||
|
||||
@@ -40,6 +43,7 @@ public abstract class DriverBase : DisposableObject
|
||||
LogMessage = new LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace };
|
||||
LogMessage.AddLogger(new EasyLogger(Log_Out) { LogLevel = TouchSocket.Core.LogLevel.Trace });
|
||||
FoundataionConfig.ConfigureContainer(a => a.RegisterSingleton<ILog>(LogMessage));
|
||||
Task.Factory.StartNew(LogInsertAsync);
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
@@ -67,6 +71,12 @@ public abstract class DriverBase : DisposableObject
|
||||
/// </summary>
|
||||
public bool IsLogOut { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否存储报文
|
||||
/// </summary>
|
||||
public bool IsSaveLog { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报文信息
|
||||
/// </summary>
|
||||
@@ -82,11 +92,14 @@ public abstract class DriverBase : DisposableObject
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract bool IsConnected();
|
||||
|
||||
/// <summary>
|
||||
/// 存储日志队列
|
||||
/// </summary>
|
||||
protected ConcurrentQueue<BackendLog> _logQueues = new();
|
||||
/// <summary>
|
||||
/// 设备报文
|
||||
/// </summary>
|
||||
internal void NewMessage(TouchSocket.Core.LogLevel arg1, object arg2, string arg3, Exception arg4)
|
||||
internal virtual void NewMessage(TouchSocket.Core.LogLevel arg1, object arg2, string arg3, Exception arg4)
|
||||
{
|
||||
if (IsLogOut)
|
||||
{
|
||||
@@ -102,6 +115,27 @@ public abstract class DriverBase : DisposableObject
|
||||
}
|
||||
|
||||
}
|
||||
private async Task LogInsertAsync()
|
||||
{
|
||||
var db = DbContext.Db.CopyNew();
|
||||
while (!DisposedValue)
|
||||
{
|
||||
if (_logQueues.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _logQueues.ToListWithDequeue();
|
||||
await db.InsertableWithAttr(data).ExecuteCommandAsync();//入库
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 底层日志输出
|
||||
|
||||
@@ -14,6 +14,8 @@ using Furion;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using ThingsGateway.Foundation;
|
||||
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace ThingsGateway.Application;
|
||||
@@ -153,6 +155,32 @@ public abstract class UpLoadBase : DriverBase
|
||||
_logger.Log_Out(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void NewMessage(TouchSocket.Core.LogLevel arg1, object arg2, string arg3, Exception arg4)
|
||||
{
|
||||
if (IsSaveLog)
|
||||
{
|
||||
if (arg3.StartsWith(FoundationConst.LogMessageHeader))
|
||||
{
|
||||
var customLevel = App.GetConfig<Microsoft.Extensions.Logging.LogLevel?>("Logging:LogLevel:BackendLog") ?? Microsoft.Extensions.Logging.LogLevel.Trace;
|
||||
if ((byte)arg1 < (byte)customLevel)
|
||||
{
|
||||
var logRuntime = new BackendLog
|
||||
{
|
||||
LogLevel = (Microsoft.Extensions.Logging.LogLevel)arg1,
|
||||
LogMessage = arg3,
|
||||
LogSource = "上传设备:" + CurDevice.Name,
|
||||
LogTime = SysDateTimeExtensions.CurrentDateTime,
|
||||
Exception = null,
|
||||
};
|
||||
_logQueues.Enqueue(logRuntime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
base.NewMessage(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ public class DriverPluginSeedData : ISqlSugarEntitySeedData<DriverPlugin>
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<DriverPlugin> SeedData()
|
||||
{
|
||||
return SeedDataUtil.GetSeedData<DriverPlugin>("driver_plugin.json");
|
||||
return SeedDataUtil.GetSeedData<DriverPlugin>("driver_plugin.json")
|
||||
.Concat(SeedDataUtil.GetSeedData<DriverPlugin>("pro_driver_plugin.json"))
|
||||
.Concat(SeedDataUtil.GetSeedData<DriverPlugin>("custom_driver_plugin.json"))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,6 @@ public class OpenApiUserSeedData : ISqlSugarEntitySeedData<OpenApiUser>
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<OpenApiUser> SeedData()
|
||||
{
|
||||
return SeedDataUtil.GetSeedData<OpenApiUser>("gatewayopenapi_user.json");
|
||||
return SeedDataUtil.GetSeedData<OpenApiUser>("gateway_openapi_user.json");
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="SeedData\Json\driver_plugin.json" />
|
||||
<None Remove="SeedData\Json\gatewayopenapi_user.json" />
|
||||
<None Remove="SeedData\Json\gateway_openapi_user.json" />
|
||||
<None Remove="SeedData\Json\gateway_relation.json" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<Content Include="SeedData\Json\gateway_resource.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SeedData\Json\gatewayopenapi_user.json">
|
||||
<Content Include="SeedData\Json\gateway_openapi_user.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SeedData\Json\gateway_relation.json">
|
||||
|
||||
@@ -1978,6 +1978,11 @@
|
||||
是否输出日志
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.DriverBase.IsSaveLog">
|
||||
<summary>
|
||||
是否存储报文
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:ThingsGateway.Application.DriverBase.Messages">
|
||||
<summary>
|
||||
报文信息
|
||||
@@ -1994,6 +1999,11 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:ThingsGateway.Application.DriverBase._logQueues">
|
||||
<summary>
|
||||
存储日志队列
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:ThingsGateway.Application.DriverBase.NewMessage(TouchSocket.Core.LogLevel,System.Object,System.String,System.Exception)">
|
||||
<summary>
|
||||
设备报文
|
||||
|
||||
@@ -75,30 +75,33 @@
|
||||
(item.Value.HasError ? "出现错误" : "验证成功")
|
||||
)
|
||||
</MSubheader>
|
||||
|
||||
<MVirtualScroll Context="item1" Height=300 OverscanCount=2 ItemSize="60" Items="item.Value.Results">
|
||||
<ItemContent>
|
||||
<MListItem>
|
||||
<MListItemAction>
|
||||
<MChip Class="ma-2">
|
||||
@(
|
||||
if (item.Value.HasError)
|
||||
{
|
||||
<MVirtualScroll Context="item1" Height=300 OverscanCount=2 ItemSize="60" Items="item.Value.Results.Where(a=>!a.isSuccess).ToList()">
|
||||
<ItemContent>
|
||||
<MListItem>
|
||||
<MListItemAction>
|
||||
<MChip Class="ma-2">
|
||||
@(
|
||||
$"第{item1.row}行"
|
||||
)
|
||||
</MChip>
|
||||
</MListItemAction>
|
||||
</MChip>
|
||||
</MListItemAction>
|
||||
|
||||
<MListItemContent>
|
||||
<MListItemTitle Class=@((item1.isSuccess?"green--text":"red--text"))>
|
||||
<strong>@item1.resultString</strong>
|
||||
</MListItemTitle>
|
||||
</MListItemContent>
|
||||
<MListItemContent>
|
||||
<MListItemTitle Class=@((item1.isSuccess?"green--text":"red--text"))>
|
||||
<strong>@item1.resultString</strong>
|
||||
</MListItemTitle>
|
||||
</MListItemContent>
|
||||
|
||||
</MListItem>
|
||||
</MListItem>
|
||||
|
||||
<MDivider></MDivider>
|
||||
<MDivider></MDivider>
|
||||
|
||||
</ItemContent>
|
||||
</MVirtualScroll>
|
||||
</ItemContent>
|
||||
</MVirtualScroll>
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -253,6 +253,23 @@
|
||||
</ChildContent>
|
||||
</MTooltip>
|
||||
|
||||
<MTooltip Bottom Context="tip">
|
||||
<ActivatorContent>
|
||||
<MButton Disabled=@(!UserResoures.IsHasButtonWithRole("gatewaydevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small
|
||||
OnClick=@(()=>
|
||||
{
|
||||
if(collectDeviceInfoItem.Driver!=null)
|
||||
collectDeviceInfoItem.Driver.IsSaveLog=! collectDeviceInfoItem.Driver.IsSaveLog;
|
||||
}
|
||||
)>
|
||||
<MIcon>@((collectDeviceInfoItem.Driver?.IsSaveLog==true) ? "mdi-pause" : "mdi-play")</MIcon>
|
||||
</MButton>
|
||||
</ActivatorContent>
|
||||
<ChildContent>
|
||||
<span>@((collectDeviceInfoItem.Driver?.IsSaveLog != true) ? "存入数据库,注意若交互频繁,可能导致数据库太大" : "不存入数据库")</span>
|
||||
</ChildContent>
|
||||
</MTooltip>
|
||||
|
||||
<MTooltip Bottom Context="tip">
|
||||
<ActivatorContent>
|
||||
<MButton Loading=isDownExport Disabled=@(!UserResoures.IsHasButtonWithRole("gatewaydevicepause")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small
|
||||
|
||||
@@ -24,6 +24,8 @@ public static class ReadWriteDevicesExHelpers
|
||||
/// <returns></returns>
|
||||
public static bool GetBoolValue(this string value)
|
||||
{
|
||||
if (value == null)
|
||||
return false;
|
||||
if (value == "1")
|
||||
return true;
|
||||
if (value == "0")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<Version>2.1.0.4</Version>
|
||||
<Version>2.1.0.5</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
<Copyright>© 2023-present Diego</Copyright>
|
||||
|
||||
@@ -519,8 +519,12 @@ public class OPCDAClient : DisposableObject
|
||||
{
|
||||
if (IsConnected)
|
||||
_logger?.Trace($"{m_server.Host + " - " + m_server.Name} - 断开连接");
|
||||
checkTimer.Enabled = false;
|
||||
checkTimer.Stop();
|
||||
if (checkTimer != null)
|
||||
{
|
||||
checkTimer.Enabled = false;
|
||||
checkTimer.Stop();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_server?.SafeDispose();
|
||||
|
||||
Reference in New Issue
Block a user