mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-28 06:07:10 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac3525a953 | ||
|
|
c8c3f5b134 | ||
|
|
51319c0718 | ||
|
|
43399b8b47 | ||
|
|
a6596042b7 | ||
|
|
23ae85fc9c | ||
|
|
2da54862f1 | ||
|
|
f272fb0559 | ||
|
|
bd04e33586 | ||
|
|
b09b9752ca | ||
|
|
a810a48158 | ||
|
|
b4f5792aa8 | ||
|
|
fdf0330b4f | ||
|
|
ca73743082 | ||
|
|
df0cde2cfd |
@@ -6,7 +6,7 @@
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>5.0.0.9</Version>
|
||||
<Version>5.0.0.12</Version>
|
||||
<Authors>Diego</Authors>
|
||||
<Company>Diego</Company>
|
||||
<Product>Diego</Product>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -43,7 +43,7 @@ public static class LiteDBCacheUtil
|
||||
var dir = GetFilePath(id);
|
||||
var fileStart = GetFileStartName(typeName);
|
||||
var maxNum = GetMaxNumFileName(id, typeName);
|
||||
var fullName = dir.CombinePath($"{fileStart}{maxNum}{ex}");
|
||||
var fullName = dir.CombinePath($"{fileStart}_{maxNum}{ex}");
|
||||
if (isDeleteRule)
|
||||
{
|
||||
//磁盘使用率限制
|
||||
@@ -59,9 +59,14 @@ public static class LiteDBCacheUtil
|
||||
foreach (var d in dirs)
|
||||
{
|
||||
string[] files = Directory.GetFiles(d);
|
||||
//如果文件数量小于4的,退出循环
|
||||
if (files.Length < 4)
|
||||
{
|
||||
break;
|
||||
}
|
||||
//数量超限就删除旧文件
|
||||
//按文件更改时间降序排序
|
||||
var sortedFiles = files.OrderByDescending(file => File.GetLastWriteTime(file));
|
||||
//按文件更改时间排序
|
||||
var sortedFiles = files.OrderBy(file => File.GetLastWriteTime(file)).ToArray();
|
||||
|
||||
// 需要删除的文件数量
|
||||
int filesToDeleteCount = files.Length - Math.Max(2, (int)(files.Length * 0.1));
|
||||
@@ -69,14 +74,14 @@ public static class LiteDBCacheUtil
|
||||
// 删除较旧的文件
|
||||
for (int i = 0; i < filesToDeleteCount; i++)
|
||||
{
|
||||
var fileName = sortedFiles.ElementAt(i);
|
||||
var fileName = sortedFiles[i];
|
||||
if (_dict.TryGetValue(fileName, out object cache1))
|
||||
{
|
||||
DisposeAndDeleteFile(fileName, cache1);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteFile(fullName);
|
||||
DeleteFile(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +95,7 @@ public static class LiteDBCacheUtil
|
||||
{
|
||||
//数量超限就删除旧文件
|
||||
//按文件更改时间降序排序
|
||||
var sortedFiles = files.OrderByDescending(file => File.GetLastWriteTime(file));
|
||||
var sortedFiles = files.OrderBy(file => File.GetLastWriteTime(file)).ToArray();
|
||||
|
||||
// 需要删除的文件数量
|
||||
int filesToDeleteCount = files.Length - LiteDBCacheUtil.config.MaxFileCount;
|
||||
@@ -98,14 +103,14 @@ public static class LiteDBCacheUtil
|
||||
// 删除较旧的文件
|
||||
for (int i = 0; i < filesToDeleteCount; i++)
|
||||
{
|
||||
var fileName = sortedFiles.ElementAt(i);
|
||||
var fileName = sortedFiles[i];
|
||||
if (_dict.TryGetValue(fileName, out object cache1))
|
||||
{
|
||||
DisposeAndDeleteFile(fileName, cache1);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteFile(fullName);
|
||||
DeleteFile(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +131,7 @@ public static class LiteDBCacheUtil
|
||||
if (mb1 > LiteDBCacheUtil.config.MaxFileLength)
|
||||
{
|
||||
//大小超限就返回新的文件
|
||||
var newFullName = dir.CombinePath($"{fileStart}{maxNum + 1}{ex}");
|
||||
var newFullName = dir.CombinePath($"{fileStart}_{maxNum + 1}{ex}");
|
||||
{
|
||||
if (_dict.TryGetValue(fullName, out object cache1))
|
||||
{
|
||||
@@ -239,14 +244,14 @@ public static class LiteDBCacheUtil
|
||||
var fileStart = GetFileStartName(typeName);
|
||||
|
||||
//搜索全部符合条件的文件
|
||||
if (!File.Exists(dir.CombinePath($"{fileStart}{ex}")))
|
||||
if (!File.Exists(dir.CombinePath($"{fileStart}_{ex}")))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var index = 1;
|
||||
while (true)
|
||||
{
|
||||
var newFileName = dir.CombinePath($"{fileStart}{index}{ex}");
|
||||
var newFileName = dir.CombinePath($"{fileStart}_{index}{ex}");
|
||||
if (System.IO.File.Exists(newFileName))
|
||||
{
|
||||
index++;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<Import Project="$(SolutionDir)PackNuget.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.1.27" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.27" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.27" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.1.28" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.28" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.28" />
|
||||
<PackageReference Include="NewLife.Redis" Version="5.6.2024.105" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
<PackageReference Include="LiteDB" Version="5.0.17" />
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
|
||||
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class FileLogCleanJob : IJob
|
||||
{
|
||||
if (!data.Contains(item))
|
||||
{
|
||||
Directory.Delete(item, true);
|
||||
Directory.Delete(dir.CombinePath(item), true);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
@@ -68,7 +68,7 @@ public class FileLogCleanJob : IJob
|
||||
{
|
||||
if (!channelConfig.ChannelDatas.Select(a => a.Id.ToString()).Contains(item))
|
||||
{
|
||||
Directory.Delete(item, true);
|
||||
Directory.Delete(debugDir.CombinePath(item), true);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
@@ -448,13 +448,22 @@ public class AlarmWorker : BackgroundService
|
||||
|
||||
#region worker服务
|
||||
|
||||
private EasyLock _easyLock = new();
|
||||
private EasyLock _easyLock = new(false);
|
||||
|
||||
private async Task CollectDeviceWorker_Starting()
|
||||
{
|
||||
await StartAsync();
|
||||
}
|
||||
|
||||
private async Task CollectDeviceWorker_Stoping()
|
||||
{
|
||||
await StopAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_logger?.LogInformation("报警服务启动");
|
||||
await _easyLock.WaitAsync();
|
||||
_appLifetime.ApplicationStarted.Register(() => { _easyLock.Release(); _easyLock = null; });
|
||||
await base.StartAsync(cancellationToken);
|
||||
}
|
||||
@@ -470,7 +479,8 @@ public class AlarmWorker : BackgroundService
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await _easyLock?.WaitAsync();
|
||||
|
||||
WorkerUtil.GetWoker<CollectDeviceWorker>().Starting += CollectDeviceWorker_Starting;
|
||||
WorkerUtil.GetWoker<CollectDeviceWorker>().Stoping += CollectDeviceWorker_Stoping;
|
||||
GlobalData = _serviceScope.ServiceProvider.GetService<GlobalData>();
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
|
||||
@@ -51,10 +51,36 @@ public class BusinessDeviceWorker : DeviceWorker
|
||||
if (ChannelThreads.Count == 0)
|
||||
{
|
||||
await CreatAllChannelThreadsAsync();
|
||||
await StartAllChannelThreadsAsync();
|
||||
await ProtectedStarting();
|
||||
}
|
||||
await StartAllChannelThreadsAsync();
|
||||
await ProtectedStarted();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "启动发生错误");
|
||||
}
|
||||
finally
|
||||
{
|
||||
singleRestartLock.Release();
|
||||
restartLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始
|
||||
/// </summary>
|
||||
public async Task CreatThreadsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await restartLock.WaitAsync();
|
||||
await singleRestartLock.WaitAsync();
|
||||
if (ChannelThreads.Count == 0)
|
||||
{
|
||||
await CreatAllChannelThreadsAsync();
|
||||
await ProtectedStarting();
|
||||
}
|
||||
if (Start != null)
|
||||
await Start.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -76,14 +102,14 @@ public class BusinessDeviceWorker : DeviceWorker
|
||||
{
|
||||
await restartLock.WaitAsync();
|
||||
await singleRestartLock.WaitAsync();
|
||||
await BeforeRemoveAllChannelThreadAsync();
|
||||
await ProtectedStoping();
|
||||
|
||||
await RemoveAllChannelThreadAsync();
|
||||
await ProtectedStoped();
|
||||
|
||||
//清空内存列表
|
||||
GlobalData.BusinessDevices.Clear();
|
||||
|
||||
if (Stop != null)
|
||||
await Stop.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -160,6 +186,27 @@ public class BusinessDeviceWorker : DeviceWorker
|
||||
|
||||
#region worker服务
|
||||
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await base.StartAsync(cancellationToken);
|
||||
}
|
||||
|
||||
private async Task CollectDeviceWorker_Starting()
|
||||
{
|
||||
await CreatThreadsAsync();
|
||||
}
|
||||
|
||||
private async Task CollectDeviceWorker_Started()
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
await StartAsync();
|
||||
}
|
||||
|
||||
private async Task CollectDeviceWorker_Stoping()
|
||||
{
|
||||
await StopAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -169,14 +216,15 @@ public class BusinessDeviceWorker : DeviceWorker
|
||||
await base.StopAsync(cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task StartOtherHostService()
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override Task StopOtherHostService()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
await _easyLock?.WaitAsync();
|
||||
WorkerUtil.GetWoker<CollectDeviceWorker>().Starting += CollectDeviceWorker_Starting;
|
||||
WorkerUtil.GetWoker<CollectDeviceWorker>().Started += CollectDeviceWorker_Started;
|
||||
WorkerUtil.GetWoker<CollectDeviceWorker>().Stoping += CollectDeviceWorker_Stoping;
|
||||
PluginService = _serviceScope.ServiceProvider.GetService<IPluginService>();
|
||||
GlobalData = _serviceScope.ServiceProvider.GetService<GlobalData>();
|
||||
await WhileExecuteAsync(stoppingToken);
|
||||
}
|
||||
|
||||
protected override async Task<IEnumerable<DeviceRunTime>> GetDeviceRunTimeAsync(long deviceId)
|
||||
@@ -185,8 +233,4 @@ public class BusinessDeviceWorker : DeviceWorker
|
||||
}
|
||||
|
||||
#endregion worker服务
|
||||
|
||||
public event RestartEventHandler Stop;
|
||||
|
||||
public event RestartEventHandler Start;
|
||||
}
|
||||
@@ -43,20 +43,21 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
|
||||
//停止采集服务
|
||||
await BeforeRemoveAllChannelThreadAsync();
|
||||
//停止其他后台服务
|
||||
await StopOtherHostService();
|
||||
await ProtectedStoping();
|
||||
//完全停止全部采集线程
|
||||
await RemoveAllChannelThreadAsync();
|
||||
await ProtectedStoped();
|
||||
|
||||
//清空内存列表
|
||||
GlobalData.CollectDevices.Clear();
|
||||
|
||||
//创建全部采集线程
|
||||
await CreatAllChannelThreadsAsync();
|
||||
//开始其他后台服务
|
||||
await StartOtherHostService();
|
||||
await ProtectedStarting();
|
||||
|
||||
//开始全部采集线程
|
||||
await StartAllChannelThreadsAsync();
|
||||
await ProtectedStarted();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -69,32 +70,6 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动其他后台服务
|
||||
/// </summary>
|
||||
protected override async Task StartOtherHostService()
|
||||
{
|
||||
var alarmHostService = WorkerUtil.GetWoker<AlarmWorker>();
|
||||
var businessDeviceHostService = WorkerUtil.GetWoker<BusinessDeviceWorker>();
|
||||
await businessDeviceHostService.StartAsync();
|
||||
await alarmHostService.StartAsync();
|
||||
if (Start != null)
|
||||
await Start.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止其他后台服务
|
||||
/// </summary>
|
||||
protected override async Task StopOtherHostService()
|
||||
{
|
||||
var alarmHostService = WorkerUtil.GetWoker<AlarmWorker>();
|
||||
var businessDeviceHostService = WorkerUtil.GetWoker<BusinessDeviceWorker>();
|
||||
await alarmHostService.StopAsync();
|
||||
await businessDeviceHostService.StopAsync();
|
||||
if (Stop != null)
|
||||
await Stop.Invoke();
|
||||
}
|
||||
|
||||
#endregion public 设备创建更新结束
|
||||
|
||||
#region Private
|
||||
@@ -147,9 +122,11 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
stoppingToken.Cancel();
|
||||
await BeforeRemoveAllChannelThreadAsync();
|
||||
//停止其他后台服务
|
||||
await StopOtherHostService();
|
||||
await ProtectedStoping();
|
||||
//停止全部采集线程
|
||||
await RemoveAllChannelThreadAsync();
|
||||
//停止其他后台服务
|
||||
await ProtectedStoped();
|
||||
await base.StopAsync(cancellationToken);
|
||||
}
|
||||
|
||||
@@ -165,8 +142,4 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
}
|
||||
|
||||
#endregion worker服务
|
||||
|
||||
public event RestartEventHandler Stop;
|
||||
|
||||
public event RestartEventHandler Start;
|
||||
}
|
||||
@@ -202,13 +202,15 @@ public abstract class DeviceWorker : BackgroundService
|
||||
if (!_stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
if (isChanged)
|
||||
await StopOtherHostService();
|
||||
await ProtectedStoping();
|
||||
var channelThread = ChannelThreads.FirstOrDefault(it => it.Has(deviceId)) ?? throw new($"更新设备线程失败,不存在{deviceId}为id的设备");
|
||||
|
||||
var dev = isChanged ? (await GetDeviceRunTimeAsync(deviceId)).FirstOrDefault() : channelThread.GetDriver(deviceId).CurrentDevice;
|
||||
|
||||
//这里先停止采集,操作会使线程取消,需要重新恢复线程
|
||||
await channelThread.RemoveDriverAsync(deviceId);
|
||||
if (isChanged)
|
||||
await ProtectedStoped();
|
||||
if (dev != null)
|
||||
{
|
||||
//初始化
|
||||
@@ -216,16 +218,39 @@ public abstract class DeviceWorker : BackgroundService
|
||||
var newChannelThread = GetChannelThread(newDriverBase);
|
||||
if (newChannelThread != null)
|
||||
{
|
||||
await newChannelThread.StartThreadAsync();
|
||||
if (isChanged)
|
||||
await ProtectedStarting();
|
||||
try
|
||||
{
|
||||
await newChannelThread.StartThreadAsync();
|
||||
if (isChanged)
|
||||
await ProtectedStarted();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (isChanged)
|
||||
await ProtectedStarted();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isChanged)
|
||||
await ProtectedStarting();
|
||||
if (isChanged)
|
||||
await ProtectedStarted();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isChanged)
|
||||
await ProtectedStarting();
|
||||
if (isChanged)
|
||||
await ProtectedStarted();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!_stoppingToken.IsCancellationRequested)
|
||||
if (isChanged)
|
||||
await StartOtherHostService();
|
||||
singleRestartLock.Release();
|
||||
}
|
||||
}
|
||||
@@ -391,7 +416,7 @@ public abstract class DeviceWorker : BackgroundService
|
||||
|
||||
#region worker服务
|
||||
|
||||
protected EasyLock _easyLock = new();
|
||||
protected EasyLock _easyLock = new(false);
|
||||
|
||||
/// <summary>
|
||||
/// 在软件关闭时取消
|
||||
@@ -401,7 +426,6 @@ public abstract class DeviceWorker : BackgroundService
|
||||
/// <inheritdoc/>
|
||||
public override async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await _easyLock.WaitAsync(cancellationToken);
|
||||
_appLifetime.ApplicationStarted.Register(() => { _easyLock.Release(); _easyLock = null; });
|
||||
await base.StartAsync(cancellationToken);
|
||||
}
|
||||
@@ -411,16 +435,44 @@ public abstract class DeviceWorker : BackgroundService
|
||||
/// </summary>
|
||||
public const int CheckIntervalTime = 600;
|
||||
|
||||
protected abstract Task StartOtherHostService();
|
||||
public event RestartEventHandler Stoping;
|
||||
|
||||
protected abstract Task StopOtherHostService();
|
||||
public event RestartEventHandler Stoped;
|
||||
|
||||
public event RestartEventHandler Started;
|
||||
|
||||
public event RestartEventHandler Starting;
|
||||
|
||||
protected async Task ProtectedStarted()
|
||||
{
|
||||
if (Started != null)
|
||||
await Started.Invoke();
|
||||
}
|
||||
|
||||
protected async Task ProtectedStarting()
|
||||
{
|
||||
if (Starting != null)
|
||||
await Starting.Invoke();
|
||||
}
|
||||
|
||||
protected async Task ProtectedStoped()
|
||||
{
|
||||
if (Stoped != null)
|
||||
await Stoped.Invoke();
|
||||
}
|
||||
|
||||
protected async Task ProtectedStoping()
|
||||
{
|
||||
if (Stoping != null)
|
||||
await Stoping.Invoke();
|
||||
}
|
||||
|
||||
protected abstract Task<IEnumerable<DeviceRunTime>> GetDeviceRunTimeAsync(long deviceId);
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await _easyLock?.WaitAsync(stoppingToken);
|
||||
await _easyLock?.WaitAsync();
|
||||
PluginService = _serviceScope.ServiceProvider.GetService<IPluginService>();
|
||||
GlobalData = _serviceScope.ServiceProvider.GetService<GlobalData>();
|
||||
await WhileExecuteAsync(stoppingToken);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
#aspnetcore6.0环境
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
#linux安装
|
||||
EXPOSE 7200
|
||||
#图像库
|
||||
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ sid main contrib non-free" > /etc/apt/sources.list
|
||||
RUN apt-get update && apt-get -y install libfontconfig1
|
||||
ENTRYPOINT ["dotnet", "ThingsGateway.Web.Server.dll","--urls","http://*:7200"]
|
||||
|
||||
#7200端口
|
||||
ENTRYPOINT ["dotnet", "ThingsGateway.Web.Entry.dll","--urls","http://*:7200"]
|
||||
@@ -22,7 +22,7 @@ public interface IChannel : IConnectObject, ICloseObject, ISetupConfigObject, ID
|
||||
/// <summary>
|
||||
/// 该通道下的所有设备
|
||||
/// </summary>
|
||||
public List<IProtocol> Collects { get; }
|
||||
public ConcurrentList<IProtocol> Collects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// CanSend
|
||||
|
||||
@@ -139,14 +139,14 @@ namespace ThingsGateway.Foundation
|
||||
var byteBlock = new ByteBlock(this.ReceiveBufferSize);
|
||||
try
|
||||
{
|
||||
var r = await Task<int>.Factory.FromAsync(this.m_serialPort.BaseStream.BeginRead, this.m_serialPort.BaseStream.EndRead, byteBlock.Buffer, 0, byteBlock.Capacity, default).ConfigureFalseAwait();
|
||||
var r = await this.m_serialPort.BaseStream.ReadAsync(byteBlock.Buffer, 0, byteBlock.Capacity, default).ConfigureFalseAwait();
|
||||
if (r == 0)
|
||||
{
|
||||
this.PrivateBreakOut(false, FoundationConst.RemoteClose);
|
||||
return;
|
||||
}
|
||||
if (m_serialPort.BytesToRead > 0)
|
||||
r += await Task<int>.Factory.FromAsync(this.m_serialPort.BaseStream.BeginRead, this.m_serialPort.BaseStream.EndRead, byteBlock.Buffer, r, byteBlock.Capacity - r, default);
|
||||
r += await this.m_serialPort.BaseStream.ReadAsync(byteBlock.Buffer, r, byteBlock.Capacity - r, default).ConfigureFalseAwait();
|
||||
|
||||
byteBlock.SetLength(r);
|
||||
this.HandleBuffer(byteBlock);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace ThingsGateway.Foundation
|
||||
public EasyLock WaitLock { get; } = new EasyLock();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public List<IProtocol> Collects { get; } = new();
|
||||
public ConcurrentList<IProtocol> Collects { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 接收到数据
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace ThingsGateway.Foundation
|
||||
public EasyLock WaitLock { get; } = new EasyLock();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public List<IProtocol> Collects { get; } = new();
|
||||
public ConcurrentList<IProtocol> Collects { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ThingsGateway.Foundation
|
||||
public class TgTcpClient : TgTcpClientBase, IClientChannel
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public List<IProtocol> Collects { get; } = new();
|
||||
public ConcurrentList<IProtocol> Collects { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public EasyLock WaitLock { get; } = new EasyLock();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ThingsGateway.Foundation
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public List<IProtocol> Collects { get; } = new();
|
||||
public ConcurrentList<IProtocol> Collects { get; } = new();
|
||||
|
||||
#region 事件
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace ThingsGateway.Foundation
|
||||
DataHandlingAdapter IClientChannel.DataHandlingAdapter => DataHandlingAdapter;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public List<IProtocol> Collects { get; } = new();
|
||||
public ConcurrentList<IProtocol> Collects { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetDataHandlingAdapter(DataHandlingAdapter adapter)
|
||||
|
||||
@@ -799,7 +799,8 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
|
||||
public virtual Task<OperResult> WriteAsync(string address, string value, CancellationToken cancellationToken = default)
|
||||
{
|
||||
IThingsGatewayBitConverter transformParameter = ByteTransUtil.GetTransByAddress(ref address, ThingsGatewayBitConverter);
|
||||
return WriteAsync(address, transformParameter.GetBytes(value), cancellationToken);
|
||||
var data = transformParameter.GetBytes(value);
|
||||
return WriteAsync(address, data.ArrayExpandToLength(transformParameter.StringLength ?? data.Length), cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -881,7 +882,8 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
|
||||
public virtual OperResult Write(string address, string value, CancellationToken cancellationToken = default)
|
||||
{
|
||||
IThingsGatewayBitConverter transformParameter = ByteTransUtil.GetTransByAddress(ref address, ThingsGatewayBitConverter);
|
||||
return Write(address, transformParameter.GetBytes(value), cancellationToken);
|
||||
var data = transformParameter.GetBytes(value);
|
||||
return Write(address, data.ArrayExpandToLength(transformParameter.StringLength ?? data.Length), cancellationToken);
|
||||
}
|
||||
|
||||
#endregion 写入
|
||||
@@ -953,9 +955,7 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
|
||||
value.ForEach((Action<string>)(a =>
|
||||
{
|
||||
var data = transformParameter.GetBytes(a);
|
||||
if (a.Length > transformParameter.StringLength)
|
||||
data = data.RemoveLast((int)(a.Length - transformParameter.StringLength.Value));
|
||||
bytes.AddRange(data);
|
||||
bytes.AddRange(data.ArrayExpandToLength(transformParameter.StringLength ?? data.Length));
|
||||
}));
|
||||
return await WriteAsync(address, bytes.ToArray(), cancellationToken);
|
||||
}
|
||||
@@ -1025,9 +1025,7 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
|
||||
value.ForEach((Action<string>)(a =>
|
||||
{
|
||||
var data = transformParameter.GetBytes(a);
|
||||
if (a.Length > transformParameter.StringLength)
|
||||
data = data.RemoveLast((int)(a.Length - transformParameter.StringLength.Value));
|
||||
bytes.AddRange(data);
|
||||
bytes.AddRange(data.ArrayExpandToLength(transformParameter.StringLength ?? data.Length));
|
||||
}));
|
||||
return Write(address, bytes.ToArray(), cancellationToken);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="10.6.2024.101" />
|
||||
<PackageReference Include="NewLife.Core" Version="10.7.2024.202" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="TouchSocket" Version="2.0.0-beta.270" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Dlt645*.dll" %25dir%25






cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*Dlt645*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Kafka*.dll" %25dir%25


cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*Kafka*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Modbus*.dll" %25dir%25





cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*Modbus*.dll" "!dir!"
)

endlocal

" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -110,7 +110,7 @@ public partial class MqttClient : BusinessBaseWithCacheIntervalScript<VariableDa
|
||||
success = clientResult.IsSuccess;
|
||||
}
|
||||
await Delay(cancellationToken);
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
|
||||
await Update(cancellationToken);
|
||||
|
||||
@@ -295,7 +295,7 @@ public partial class MqttClient : BusinessBaseWithCacheIntervalScript<VariableDa
|
||||
if (isConnect.IsSuccess)
|
||||
{
|
||||
var variableMessage = new MqttApplicationMessageBuilder()
|
||||
.WithTopic(topic)
|
||||
.WithTopic(topic).WithRetainFlag(true)
|
||||
.WithPayload(payLoad).Build();
|
||||
var result = await _mqttClient.PublishAsync(variableMessage, cancellationToken);
|
||||
if (result.IsSuccess)
|
||||
|
||||
@@ -207,13 +207,19 @@ public partial class MqttServer : BusinessBaseWithCacheIntervalScript<VariableDa
|
||||
arg.ReasonCode = MqttConnectReasonCode.BadUserNameOrPassword;
|
||||
return;
|
||||
}
|
||||
|
||||
List<MqttApplicationMessage> data = GetRetainedMessages();
|
||||
foreach (var item in data)
|
||||
{
|
||||
await _mqttServer.UpdateRetainedMessageAsync(item);
|
||||
}
|
||||
LogMessage?.LogInformation($"{ToString()}-{arg.ClientId}-客户端已连接成功");
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
//延时发送
|
||||
await Task.Delay(1000);
|
||||
List<MqttApplicationMessage> data = GetRetainedMessages();
|
||||
foreach (var item in data)
|
||||
{
|
||||
await _mqttServer.InjectApplicationMessage(
|
||||
new InjectedMqttApplicationMessage(item));
|
||||
//await _mqttServer.UpdateRetainedMessageAsync(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Mqtt*.dll" %25dir%25


cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)
for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)
" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*Mqtt*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*OpcDa*.dll" %25dir%25






cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*OpcDa*.dll" "!dir!"
)

endlocal


" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*OpcUa*.dll" %25dir%25
copy "$(TargetDir)*Opc.Ua*.dll" %25dir%25
copy "$(TargetDir)*System.Formats.Asn1*.dll" %25dir%25

cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)
for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*OpcUa*.dll" "!dir!"
 copy "$(TargetDir)*Opc.Ua*.dll" "!dir!"
 copy "$(TargetDir)*System.Formats.Asn1*.dll" "!dir!"
)

endlocal


" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*QuestDB*.dll" %25dir%25





cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*QuestDB*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*RabbitMQ*.dll" %25dir%25


cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)
" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*RabbitMQ*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Siemens*.dll" %25dir%25





cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*Siemens*.dll" "!dir!"

)

endlocal


" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*SqlDB*.dll" %25dir%25




cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*SqlDB*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*SqlHisAlarm*.dll" %25dir%25




cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*SqlHisAlarm*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*TDengineDB*.dll" %25dir%25






cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*TDengineDB*.dll" "!dir!"
)

endlocal
" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*VariableExpression*.dll" %25dir%25







cd /d "$(TargetDir)"
::设置要排除的文件格式,多个格式之间使用英文逗号隔开
set Ext=dll
::删除文件
for /f "delims=" %25%25a in ('dir /a-d/s/b') do (
 if /i not "%25%25~a"=="%25~f0" (
 set "Skip="
 for %25%25i in (%25Ext%25) do (
 if /i ".%25%25~i"=="%25%25~xa" (
 set Skip=OK
 )
 )
 if not defined Skip (
 del /f /q "%25%25~a"
 )
 )
)

for /d %25%25i in (*) do (
 rd /s /q "%25%25i"
)

" />
|
||||
<Exec Command="@echo off
setlocal enabledelayedexpansion

set "targetFWS=net6.0 net7.0 net8.0"
for %25%25f in (%25targetFWS%25) do (
 set "dir=$(SolutionDir)bin\$(Configuration)\ThingsGateway.Web.Entry\%25%25f\Plugins\$(AssemblyName)"
 if not exist "!dir!" md "!dir!"
 copy "$(TargetDir)*VariableExpression*.dll" "!dir!"

)

endlocal


" />
|
||||
</Target>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user