Compare commits

...

2 Commits

Author SHA1 Message Date
Diego
8e938f18be 去除不必要的控制台日志输出 2025-05-28 16:52:51 +08:00
Diego
ab1b364c54 fix: 同步插件反写空错误 2025-05-28 12:30:16 +08:00
9 changed files with 34 additions and 21 deletions

View File

@@ -29,7 +29,6 @@ using ThingsGateway.Admin.Application;
using ThingsGateway.Admin.Razor;
using ThingsGateway.Extension;
using ThingsGateway.NewLife.Caching;
using ThingsGateway.NewLife.Extension;
namespace ThingsGateway.AdminServer;
@@ -161,7 +160,8 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (logMsg.Message.IsNullOrEmpty()) return false;
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -71,13 +71,25 @@ public static class App
/// </summary>
public static IServiceProvider RootServices => InternalApp.RootServices;
private static IHostApplicationLifetime hostApplicationLifetime;
public static IHostApplicationLifetime HostApplicationLifetime
{
get
{
if ((hostApplicationLifetime == null))
{
hostApplicationLifetime = RootServices?.GetService<IHostApplicationLifetime>();
}
return hostApplicationLifetime;
}
}
private static IStringLocalizerFactory? stringLocalizerFactory;
/// <summary>
/// 本地化服务工厂
/// </summary>
public static IStringLocalizerFactory? StringLocalizerFactory
{
get
{

View File

@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<PluginVersion>10.6.29</PluginVersion>
<ProPluginVersion>10.6.29</ProPluginVersion>
<PluginVersion>10.6.31</PluginVersion>
<ProPluginVersion>10.6.31</ProPluginVersion>
<AuthenticationVersion>2.1.8</AuthenticationVersion>
</PropertyGroup>

View File

@@ -63,11 +63,8 @@ public partial class Synchronization : BusinessBase, IRpcDriver
protected override async ValueTask ProtectedExecuteAsync(CancellationToken cancellationToken)
{
try
{
if (_driverPropertys.IsServer)
{
if (_tcpDmtpService.ServerState != ServerState.Running)
@@ -132,6 +129,7 @@ public partial class Synchronization : BusinessBase, IRpcDriver
// 如果 online 为 true表示设备在线
if (online)
{
var deviceRunTimes = CollectDevices.Where(a => a.Value.IsCollect == true).Select(a => a.Value).Adapt<List<DeviceDataWithValue>>();
@@ -308,9 +306,11 @@ public partial class Synchronization : BusinessBase, IRpcDriver
a.Channel.Id = CommonUtils.GetSingleId();
a.DeviceVariables.ForEach(b =>
{
b.Device.Id = 0;
b.Device.ChannelId = a.Channel.Id;
b.Device.Id = CommonUtils.GetSingleId();
b.Variables.ForEach(c =>
{
c.DeviceId = b.Device.Id;
c.Id = 0;
});
});
@@ -340,12 +340,12 @@ public partial class Synchronization : BusinessBase, IRpcDriver
{
if (deviceDatas.TryGetValue(item.Key.DeviceName ?? string.Empty, out var variableDatas))
{
variableDatas.Add(item.Key.Name, item.Value?.ToString() ?? string.Empty);
variableDatas.TryAdd(item.Key.Name, item.Value?.ToString() ?? string.Empty);
}
else
{
deviceDatas.Add(item.Key.DeviceName ?? string.Empty, new());
deviceDatas[item.Key.DeviceName ?? string.Empty].Add(item.Key.Name, item.Value?.ToString() ?? string.Empty);
deviceDatas.TryAdd(item.Key.DeviceName ?? string.Empty, new());
deviceDatas[item.Key.DeviceName ?? string.Empty].TryAdd(item.Key.Name, item.Value?.ToString() ?? string.Empty);
}
}
@@ -402,7 +402,7 @@ public partial class Synchronization : BusinessBase, IRpcDriver
try
{
var data = await _tcpDmtpClient.GetDmtpRpcActor().InvokeTAsync<Dictionary<string, Dictionary<string, OperResult<object>>>>(
var data = await client.GetDmtpRpcActor().InvokeTAsync<Dictionary<string, Dictionary<string, OperResult<object>>>>(
nameof(ReverseCallbackServer.Rpc), waitInvoke, new Dictionary<string, Dictionary<string, string>>() { { item.Key, item.Value } }).ConfigureAwait(false);
dataResult.AddRange(data);
@@ -415,7 +415,7 @@ public partial class Synchronization : BusinessBase, IRpcDriver
foreach (var vItem in item.Value)
{
dataResult[item.Key].Add(vItem.Key, new OperResult<object>(ex));
dataResult[item.Key].TryAdd(vItem.Key, new OperResult<object>(ex));
}
}
}
@@ -426,7 +426,7 @@ public partial class Synchronization : BusinessBase, IRpcDriver
foreach (var vItem in item.Value)
{
dataResult[item.Key].Add(vItem.Key, new OperResult<object>("No online"));
dataResult[item.Key].TryAdd(vItem.Key, new OperResult<object>("No online"));
}
}

View File

@@ -15,7 +15,7 @@ namespace ThingsGateway.Plugin.Synchronization;
/// <summary>
/// <inheritdoc/>
/// </summary>
public class SynchronizationProperty : BusinessPropertyBase
public class SynchronizationProperty : BusinessPropertyBase, IBusinessPropertyAllVariableBase
{
[DynamicProperty]
public bool IsServer { get; set; } = true;

View File

@@ -37,7 +37,6 @@ using ThingsGateway.Debug;
using ThingsGateway.Extension;
using ThingsGateway.Gateway.Application;
using ThingsGateway.NewLife.Caching;
using ThingsGateway.NewLife.Extension;
namespace ThingsGateway.Server;
@@ -138,7 +137,8 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (logMsg.Message.IsNullOrEmpty()) return false;
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -29,7 +29,6 @@ using ThingsGateway.Admin.Application;
using ThingsGateway.Admin.Razor;
using ThingsGateway.Extension;
using ThingsGateway.NewLife.Caching;
using ThingsGateway.NewLife.Extension;
namespace ThingsGateway.Server;
@@ -162,7 +161,8 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (logMsg.Message.IsNullOrEmpty()) return false;
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -157,6 +157,7 @@ public class Startup : AppStartup
{
options.WriteFilter = (logMsg) =>
{
if (App.HostApplicationLifetime.ApplicationStopping.IsCancellationRequested && logMsg.LogLevel >= LogLevel.Warning) return false;
if (string.IsNullOrEmpty(logMsg.Message)) return false;
else return true;
};

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>10.6.29</Version>
<Version>10.6.31</Version>
</PropertyGroup>
<ItemGroup>