Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a64ab7df4e | ||
![]() |
82cd64cb50 | ||
![]() |
065bfb8694 | ||
![]() |
6db335cf87 | ||
![]() |
155f4670e9 | ||
![]() |
50522b571a | ||
![]() |
8e138863ce | ||
![]() |
7d8dfe628d | ||
![]() |
8baed5b306 | ||
![]() |
41a5ffd214 | ||
![]() |
c6aec3a1af | ||
![]() |
22e30f7a62 | ||
![]() |
57711b8ab5 | ||
![]() |
90ff1259ea | ||
![]() |
d88fc5ccd7 | ||
![]() |
5aaca2aa9c | ||
![]() |
8b9ca56e17 | ||
![]() |
e4f3772e6d | ||
![]() |
d58ec81d20 | ||
![]() |
415aae44b6 | ||
![]() |
a533286658 | ||
![]() |
e59f91cd82 | ||
![]() |
5f8b85d8a4 | ||
![]() |
47c7b88436 | ||
![]() |
90006782f2 | ||
![]() |
c3d49cbe70 | ||
![]() |
112323a360 | ||
![]() |
9d08c90fda | ||
![]() |
602d24deec | ||
![]() |
a2b9f66785 |
101
framework/ThingsGateway - Admin.sln
Normal file
101
framework/ThingsGateway - Admin.sln
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33927.249
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "admin", "admin", "{4E66C22C-0636-4949-BF6A-9E3BBE1550BA}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
admin\Directory.Build.props = admin\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Components", "admin\ThingsGateway.Components\ThingsGateway.Components.csproj", "{0A891D8E-23B3-46AD-8D30-565EE5004F93}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Core", "admin\ThingsGateway.Core\ThingsGateway.Core.csproj", "{A712EAEE-94F2-4F01-8C1C-2EC802280DD7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Admin.Core", "admin\ThingsGateway.Admin.Core\ThingsGateway.Admin.Core.csproj", "{5DA3D2BD-6768-4479-B52F-49E022EFF310}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Admin.Blazor", "admin\ThingsGateway.Admin.Blazor\ThingsGateway.Admin.Blazor.csproj", "{8DD5DF98-7FDE-4B49-8661-AEB44D923CFE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Admin.Application", "admin\ThingsGateway.Admin.Application\ThingsGateway.Admin.Application.csproj", "{D6685A42-2712-417A-92C5-5EFF90B9FA94}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Admin.ApiController", "admin\ThingsGateway.Admin.ApiController\ThingsGateway.Admin.ApiController.csproj", "{0D17D801-6DAA-4FD1-9A99-F9F07FA6BA88}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "web", "web", "{F0C9A8CB-231B-45E0-B91B-4FEF7EF47197}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
web\Directory.Build.props = web\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Web.Core", "web\ThingsGateway.Web.Core\ThingsGateway.Web.Core.csproj", "{D37EC028-EA46-4510-8261-6E780A906314}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Web.Entry", "web\ThingsGateway.Web.Entry\ThingsGateway.Web.Entry.csproj", "{C5F662EB-991F-438D-BF61-EF87E7371C04}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{97B23D8B-C6C0-4746-A21F-C7B49354B284}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\.gitignore = ..\.gitignore
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Foundation", "foundation\ThingsGateway.Foundation\ThingsGateway.Foundation.csproj", "{6961511A-8787-42AF-827D-B630B2AF4791}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "foundation", "foundation", "{268A1A81-2685-47E1-9986-5934A58A31A4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0A891D8E-23B3-46AD-8D30-565EE5004F93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0A891D8E-23B3-46AD-8D30-565EE5004F93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0A891D8E-23B3-46AD-8D30-565EE5004F93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0A891D8E-23B3-46AD-8D30-565EE5004F93}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A712EAEE-94F2-4F01-8C1C-2EC802280DD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A712EAEE-94F2-4F01-8C1C-2EC802280DD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A712EAEE-94F2-4F01-8C1C-2EC802280DD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A712EAEE-94F2-4F01-8C1C-2EC802280DD7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5DA3D2BD-6768-4479-B52F-49E022EFF310}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5DA3D2BD-6768-4479-B52F-49E022EFF310}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5DA3D2BD-6768-4479-B52F-49E022EFF310}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5DA3D2BD-6768-4479-B52F-49E022EFF310}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8DD5DF98-7FDE-4B49-8661-AEB44D923CFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8DD5DF98-7FDE-4B49-8661-AEB44D923CFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8DD5DF98-7FDE-4B49-8661-AEB44D923CFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8DD5DF98-7FDE-4B49-8661-AEB44D923CFE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D6685A42-2712-417A-92C5-5EFF90B9FA94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D6685A42-2712-417A-92C5-5EFF90B9FA94}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D6685A42-2712-417A-92C5-5EFF90B9FA94}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D6685A42-2712-417A-92C5-5EFF90B9FA94}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D17D801-6DAA-4FD1-9A99-F9F07FA6BA88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D17D801-6DAA-4FD1-9A99-F9F07FA6BA88}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D17D801-6DAA-4FD1-9A99-F9F07FA6BA88}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D17D801-6DAA-4FD1-9A99-F9F07FA6BA88}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D37EC028-EA46-4510-8261-6E780A906314}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D37EC028-EA46-4510-8261-6E780A906314}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D37EC028-EA46-4510-8261-6E780A906314}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D37EC028-EA46-4510-8261-6E780A906314}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C5F662EB-991F-438D-BF61-EF87E7371C04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C5F662EB-991F-438D-BF61-EF87E7371C04}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C5F662EB-991F-438D-BF61-EF87E7371C04}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C5F662EB-991F-438D-BF61-EF87E7371C04}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6961511A-8787-42AF-827D-B630B2AF4791}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6961511A-8787-42AF-827D-B630B2AF4791}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6961511A-8787-42AF-827D-B630B2AF4791}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6961511A-8787-42AF-827D-B630B2AF4791}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{0A891D8E-23B3-46AD-8D30-565EE5004F93} = {4E66C22C-0636-4949-BF6A-9E3BBE1550BA}
|
||||
{A712EAEE-94F2-4F01-8C1C-2EC802280DD7} = {4E66C22C-0636-4949-BF6A-9E3BBE1550BA}
|
||||
{5DA3D2BD-6768-4479-B52F-49E022EFF310} = {4E66C22C-0636-4949-BF6A-9E3BBE1550BA}
|
||||
{8DD5DF98-7FDE-4B49-8661-AEB44D923CFE} = {4E66C22C-0636-4949-BF6A-9E3BBE1550BA}
|
||||
{D6685A42-2712-417A-92C5-5EFF90B9FA94} = {4E66C22C-0636-4949-BF6A-9E3BBE1550BA}
|
||||
{0D17D801-6DAA-4FD1-9A99-F9F07FA6BA88} = {4E66C22C-0636-4949-BF6A-9E3BBE1550BA}
|
||||
{D37EC028-EA46-4510-8261-6E780A906314} = {F0C9A8CB-231B-45E0-B91B-4FEF7EF47197}
|
||||
{C5F662EB-991F-438D-BF61-EF87E7371C04} = {F0C9A8CB-231B-45E0-B91B-4FEF7EF47197}
|
||||
{6961511A-8787-42AF-827D-B630B2AF4791} = {268A1A81-2685-47E1-9986-5934A58A31A4}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C49B2D3E-6818-4E28-91B7-6E4E7E264BBB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@@ -82,6 +82,7 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决方案项", "{97B23D8B-C6C0-4746-A21F-C7B49354B284}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\.gitignore = ..\.gitignore
|
||||
..\README.md = ..\README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Plugin.Kafka", "plugin\ThingsGateway.Plugin.Kafka\ThingsGateway.Plugin.Kafka.csproj", "{E4B8B8E6-FAE7-43BA-9A51-33A3CD9FB825}"
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
<Version>4.0.0.1</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Authors>Diego</Authors>
|
||||
|
@@ -12,7 +12,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ThingsGateway.Admin.Core\ThingsGateway.Admin.Core.csproj" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.2" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.5" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@@ -1,12 +1,12 @@
|
||||
#region copyright
|
||||
#region copyright
|
||||
//------------------------------------------------------------------------------
|
||||
// <EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊȫ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>룩<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߱<EFBFBD><EFBFBD><EFBFBD>Diego<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><EFBFBD>Ŀ<EFBFBD>ԴЭ<EFBFBD>鼰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>
|
||||
// GiteeԴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ⣺https://gitee.com/diego2098/ThingsGateway
|
||||
// GithubԴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ⣺https://github.com/kimdiego2098/ThingsGateway
|
||||
// ʹ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQȺ<EFBFBD><EFBFBD>605534569
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
@@ -16,8 +16,7 @@ using Masa.Blazor.Presets;
|
||||
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.String;
|
||||
|
||||
@@ -44,7 +43,7 @@ public partial class Login
|
||||
/// <inheritdoc/>
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
if (App.WebHostEnvironment.IsDevelopment())
|
||||
{
|
||||
_loginModel.Account = "superAdmin";
|
||||
_password = "111111";
|
||||
@@ -54,7 +53,7 @@ public partial class Login
|
||||
_configTitle = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_TITLE))?.ConfigValue;
|
||||
_configRemark = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_REMARK))?.ConfigValue;
|
||||
_showCaptcha = (await _serviceScope.ServiceProvider.GetService<IConfigService>().GetByConfigKeyAsync(ConfigConst.SYS_CONFIGBASEDEFAULT, ConfigConst.CONFIG_CAPTCHA_OPEN))?.ConfigValue?.ToBool(false) == true;
|
||||
_welcome = "<EFBFBD><EFBFBD>ӭʹ<EFBFBD><EFBFBD>" + _configTitle + "!";
|
||||
_welcome = "欢迎使用" + _configTitle + "!";
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
@@ -102,11 +101,11 @@ public partial class Login
|
||||
await _captcha.RefreshCode();
|
||||
}
|
||||
|
||||
await PopupService.EnqueueSnackbarAsync(new("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + ": " + ret.Msg.ToString(), AlertTypes.Error));
|
||||
await PopupService.EnqueueSnackbarAsync(new("登录错误" + ": " + ret.Msg.ToString(), AlertTypes.Error));
|
||||
}
|
||||
else
|
||||
{
|
||||
await PopupService.EnqueueSnackbarAsync(new("<EFBFBD><EFBFBD>¼<EFBFBD>ɹ<EFBFBD>", AlertTypes.Success));
|
||||
await PopupService.EnqueueSnackbarAsync(new("登录成功", AlertTypes.Success));
|
||||
await Task.Delay(500);
|
||||
var userId = await _serviceScope.ServiceProvider.GetService<SysUserService>().GetIdByAccountAsync(_loginModel.Account);
|
||||
var data = await _serviceScope.ServiceProvider.GetService<UserCenterService>().GetLoginDefaultRazorAsync(userId);
|
||||
@@ -124,7 +123,7 @@ public partial class Login
|
||||
await _captcha.RefreshCode();
|
||||
}
|
||||
|
||||
await PopupService.EnqueueSnackbarAsync(new("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", AlertTypes.Error));
|
||||
await PopupService.EnqueueSnackbarAsync(new("登录错误", AlertTypes.Error));
|
||||
}
|
||||
}
|
||||
private async Task<string> RefreshCode()
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#region copyright
|
||||
#region copyright
|
||||
//------------------------------------------------------------------------------
|
||||
// <EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊȫ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>룩<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߱<EFBFBD><EFBFBD><EFBFBD>Diego<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><EFBFBD>Ŀ<EFBFBD>ԴЭ<EFBFBD>鼰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>
|
||||
// GiteeԴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ⣺https://gitee.com/diego2098/ThingsGateway
|
||||
// GithubԴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ⣺https://github.com/kimdiego2098/ThingsGateway
|
||||
// ʹ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQȺ<EFBFBD><EFBFBD>605534569
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
@@ -44,7 +44,7 @@ public partial class MainLayout
|
||||
[Inject]
|
||||
private UserResoures _userResoures { get; set; }
|
||||
/// <summary>
|
||||
/// ҳ<EFBFBD><EFBFBD>ˢ<EFBFBD><EFBFBD>
|
||||
/// 页面刷新
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task StateHasChangedAsync()
|
||||
|
@@ -5,8 +5,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.4" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.117" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.1.5" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.123" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.1.4" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.4" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.1.5" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.5" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
<Version>4.0.0.1</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
|
@@ -1,6 +1,10 @@
|
||||
<Project>
|
||||
<!--如果编译net45报错无支持,用一下方法添加net45包-->
|
||||
<!--VS顶部菜单栏 -> 视图 -> 其他 -> 程序包控制台
|
||||
Install-Package Microsoft.NETFramework.ReferenceAssemblies.net45
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.1</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<TargetFrameworks>net45;netstandard2.0;net6.0;net8.0;</TargetFrameworks>
|
||||
|
@@ -134,21 +134,19 @@ internal class ModbusHelper
|
||||
|
||||
if (response[1] >= 0x80)//错误码
|
||||
return new OperResult<byte[], FilterResult>(GetDescriptionByErrorCode(response[2])) { Content2 = FilterResult.Success };
|
||||
if (response[1] <= 0x05)
|
||||
if (response[1] <= 0x04)
|
||||
{
|
||||
if ((response.Length < response[2] + 5))
|
||||
return new OperResult<byte[], FilterResult>("数据长度不足" + response.ToHexString()) { Content2 = FilterResult.Cache };
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((response.Length < 8))
|
||||
return new OperResult<byte[], FilterResult>("数据长度不足" + response.ToHexString()) { Content2 = FilterResult.Cache };
|
||||
|
||||
}
|
||||
|
||||
|
||||
var data = response.SelectMiddle(0, response[2] != 0 ? response[2] + 5 : 8);
|
||||
var data = response.SelectMiddle(0, response[1] <= 0x04 ? response[2] != 0 ? response[2] + 5 : 8 : 8);
|
||||
if (crcCheck && !CRC16Utils.CheckCRC16(data))
|
||||
return new OperResult<byte[], FilterResult>("Crc校验失败" + DataTransUtil.ByteToHexString(data, ' ')) { Content2 = FilterResult.Success };
|
||||
return GetModbusData(send, data.RemoveLast(2));
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net45;netstandard2.0;net6.0;net8.0;</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
||||
|
@@ -40,6 +40,14 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
{
|
||||
this.Protocol = Protocol.Tcp;
|
||||
}
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(SocketClient)}:{IP}:{Port}";
|
||||
}
|
||||
|
||||
#region 变量
|
||||
|
||||
|
@@ -608,6 +608,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
this.OnAccepted(e);
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException) { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Logger.Exception(ex);
|
||||
|
@@ -186,10 +186,6 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.m_cancellationTokenSource = null;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.1</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
|
@@ -43,14 +43,16 @@ public abstract class CollectBase : DriverBase
|
||||
|
||||
public override async Task AfterStopAsync()
|
||||
{
|
||||
await base.AfterStopAsync();
|
||||
//去除全局设备变量
|
||||
lock (_globalDeviceData.CollectDevices)
|
||||
{
|
||||
_globalDeviceData.CollectDevices.RemoveWhere(it => it.Id == DeviceId);
|
||||
}
|
||||
await base.AfterStopAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void Init(DeviceRunTime device)
|
||||
{
|
||||
base.Init(device);
|
||||
|
@@ -109,8 +109,8 @@ public abstract class UpLoadBaseWithCacheT<DeviceT, VariableT> : UpLoadBase
|
||||
CurrentDevice.DeviceVariableRunTimes.ForEach(a => { a.VariableValueChange += VariableValueChange; });
|
||||
}
|
||||
|
||||
if (_uploadPropertyWithCache.CycleInterval <= 100) _uploadPropertyWithCache.CycleInterval = 100;
|
||||
if (_uploadPropertyWithCache.UploadInterval <= 1000) _uploadPropertyWithCache.UploadInterval = 1000;
|
||||
if (_uploadPropertyWithCache.CycleInterval <= 50) _uploadPropertyWithCache.CycleInterval = 50;
|
||||
if (_uploadPropertyWithCache.UploadInterval <= 100) _uploadPropertyWithCache.UploadInterval = 100;
|
||||
_exVariableTimerTick = new(_uploadPropertyWithCache.UploadInterval);
|
||||
_exDeviceTimerTick = new(_uploadPropertyWithCache.UploadInterval);
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class UploadPropertyWithCacheT : DriverPropertyBase
|
||||
/// <summary>
|
||||
/// 线程循环间隔
|
||||
/// </summary>
|
||||
[DeviceProperty("线程循环间隔", "最小10ms")]
|
||||
[DeviceProperty("线程循环间隔", "最小50ms")]
|
||||
public virtual int CycleInterval { get; set; } = 1000;
|
||||
/// <summary>
|
||||
/// 内存队列最大条数
|
||||
@@ -47,7 +47,7 @@ public class UploadPropertyWithCacheT : DriverPropertyBase
|
||||
/// <summary>
|
||||
/// 上传间隔时间
|
||||
/// </summary>
|
||||
[DeviceProperty("上传间隔时间", "最小1000ms")]
|
||||
[DeviceProperty("上传间隔时间", "最小100ms")]
|
||||
public virtual int UploadInterval { get; set; } = 1000;
|
||||
|
||||
[DeviceProperty("是否选择全部变量", "")] public bool IsAllVariable { get; set; } = false;
|
||||
|
@@ -44,7 +44,7 @@ public class CollectDeviceService : DeviceService<CollectDevice>, ITransient
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
[OperDesc("复制设备与变量")]
|
||||
[OperDesc("复制设备与变量", IsRecordPar = false)]
|
||||
public virtual async Task CopyDevAndVarAsync(IEnumerable<CollectDevice> input)
|
||||
{
|
||||
var variableService = _serviceScope.ServiceProvider.GetService<VariableService>();
|
||||
|
@@ -10,6 +10,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.FriendlyException;
|
||||
|
||||
using Mapster;
|
||||
@@ -30,6 +31,7 @@ using Yitter.IdGenerator;
|
||||
|
||||
namespace ThingsGateway.Gateway.Application;
|
||||
|
||||
[Injection(Proxy = typeof(OperDispatchProxy))]
|
||||
public abstract class DeviceService<T> : DbRepository<T> where T : Device, new()
|
||||
{
|
||||
protected readonly IFileService _fileService;
|
||||
@@ -233,8 +235,8 @@ public abstract class DeviceService<T> : DbRepository<T> where T : Device, new()
|
||||
}
|
||||
deviceDicts.TryGetValue(devData.RedundantDeviceId, out var redundantDevice);
|
||||
|
||||
//设备实体没有包含插件名称,手动插入
|
||||
devExport.Add(ExportHelpers.PluginName, devData.PluginName);
|
||||
////设备实体没有包含插件名称,手动插入
|
||||
//devExport.Add(ExportHelpers.PluginName, devData.PluginName);
|
||||
//设备实体没有包含冗余设备名称,手动插入
|
||||
devExport.Add(ExportHelpers.RedundantDeviceName, redundantDevice?.Name);
|
||||
|
||||
@@ -374,22 +376,22 @@ public abstract class DeviceService<T> : DbRepository<T> where T : Device, new()
|
||||
{
|
||||
var device = ((ExpandoObject)item).ConvertToEntity<T>(true);
|
||||
#region 特殊转化名称
|
||||
//转化插件名称
|
||||
var hasPlugin = item.TryGetValue(ExportHelpers.PluginName, out var pluginObj);
|
||||
////转化插件名称
|
||||
//var hasPlugin = item.TryGetValue(ExportHelpers.PluginName, out var pluginObj);
|
||||
|
||||
if (pluginObj == null || !driverPluginFullNameDict.TryGetValue(pluginObj.ToString(), out var plugin))
|
||||
{
|
||||
//找不到对应的插件
|
||||
importPreviewOutput.HasError = true;
|
||||
importPreviewOutput.Results.Add((row++, false, $"{ExportHelpers.PluginName}不存在"));
|
||||
return;
|
||||
}
|
||||
//if (pluginObj == null || !driverPluginFullNameDict.TryGetValue(pluginObj.ToString(), out var plugin))
|
||||
//{
|
||||
// //找不到对应的插件
|
||||
// importPreviewOutput.HasError = true;
|
||||
// importPreviewOutput.Results.Add((row++, false, $"{ExportHelpers.PluginName}不存在"));
|
||||
// return;
|
||||
//}
|
||||
//转化冗余设备名称
|
||||
var hasRedundant = item.TryGetValue(ExportHelpers.PluginName, out var redundantObj);
|
||||
var hasRedundant = item.TryGetValue(ExportHelpers.RedundantDeviceName, out var redundantObj);
|
||||
|
||||
#endregion
|
||||
//设备ID、冗余设备ID都需要手动补录
|
||||
if (hasRedundant && deviceDicts.TryGetValue(redundantObj.ToString(), out var rendundantDevice))
|
||||
if (hasRedundant && redundantObj != null && deviceDicts.TryGetValue(redundantObj.ToString(), out var rendundantDevice))
|
||||
{
|
||||
device.RedundantDeviceId = rendundantDevice.Id;
|
||||
}
|
||||
|
@@ -173,7 +173,7 @@ public class DriverPluginService : ISingleton
|
||||
|
||||
}
|
||||
return plugins;
|
||||
}, false);
|
||||
}, true);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class DriverPluginService : ISingleton
|
||||
var data = _serviceScope.ServiceProvider.GetService<MemoryCache>().GetOrCreate($"{nameof(GetDriverVariableProperties)}", cacheKey, c =>
|
||||
{
|
||||
var data = driver.VariablePropertys?.GetType().GetProperties()?.SelectMany(it =>
|
||||
new[] { new { memberInfo = it, attribute = GetCustomAttributeRecursive<DevicePropertyAttribute>(it) } })
|
||||
new[] { new { memberInfo = it, attribute = GetCustomAttributeRecursive<VariablePropertyAttribute>(it) } })
|
||||
?.Where(x => x.attribute != null).ToList()
|
||||
?.SelectMany(it => new[]
|
||||
{
|
@@ -15,8 +15,7 @@
|
||||
<PackageReference Include="CS-Script" Version="4.8.8" />
|
||||
<!--CS-Script与Furion冲突,直接安装覆盖版本-->
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.7.0" />
|
||||
<PackageReference Include="MQTTnet" Version="4.3.1.873" />
|
||||
<PackageReference Include="SqlSugar.TDengineCore" Version="3.2.0" />
|
||||
<PackageReference Include="SqlSugar.TDengineCore" Version="3.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -23,7 +23,7 @@ namespace ThingsGateway.Gateway.Application;
|
||||
/// </summary>
|
||||
public class CollectDeviceWorker : DeviceWorker
|
||||
{
|
||||
|
||||
private GlobalDeviceData _globalDeviceData;
|
||||
public CollectDeviceWorker(IServiceScopeFactory serviceScopeFactory, IHostApplicationLifetime appLifetime) : base(serviceScopeFactory, appLifetime)
|
||||
{
|
||||
_logger = _serviceScope.ServiceProvider.GetService<ILoggerFactory>().CreateLogger("南向设备服务");
|
||||
@@ -49,6 +49,10 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
await StopOtherHostService();
|
||||
//停止全部采集线程
|
||||
await RemoveAllDeviceThreadAsync();
|
||||
|
||||
//清空内存列表
|
||||
_globalDeviceData.CollectDevices.Clear();
|
||||
|
||||
//创建全部采集线程
|
||||
await CreatAllDeviceThreadsAsync();
|
||||
//开始其他后台服务
|
||||
@@ -197,6 +201,7 @@ public class CollectDeviceWorker : DeviceWorker
|
||||
{
|
||||
await _easyLock?.WaitAsync();
|
||||
_driverPluginService = _serviceScope.ServiceProvider.GetService<DriverPluginService>();
|
||||
_globalDeviceData = _serviceScope.ServiceProvider.GetService<GlobalDeviceData>();
|
||||
//重启采集线程,会启动其他后台服务
|
||||
await RestartDeviceThreadAsync();
|
||||
await WhileExecuteAsync(stoppingToken);
|
||||
|
@@ -49,7 +49,7 @@ public abstract class DeviceWorker : BackgroundService
|
||||
/// </summary>
|
||||
public List<DriverBase> DriverBases => _deviceThreads
|
||||
.Where(a => a.DriverBases.Any(b => b.CurrentDevice != null))
|
||||
.SelectMany(a => a.DriverBases).ToList();
|
||||
.SelectMany(a => a.DriverBases).OrderByDescending(a => a.CurrentDevice.DeviceStatus).ToList();
|
||||
|
||||
/// <summary>
|
||||
/// 设备子线程列表
|
||||
|
@@ -99,9 +99,9 @@ public class UploadDeviceWorker : DeviceWorker
|
||||
{
|
||||
if (!_stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
_logger.LogInformation("正在获取北向组态信息");
|
||||
_logger.LogInformation("正在获取北向设备组态信息");
|
||||
var deviceRunTimes = (_serviceScope.ServiceProvider.GetService<UploadDeviceService>().GetDeviceRuntime());
|
||||
_logger.LogInformation("获取北向组态信息完成");
|
||||
_logger.LogInformation("获取北向设备组态信息完成");
|
||||
foreach (var uploadDeviceRunTime in deviceRunTimes.Where(a => !deviceRunTimes.Any(b => a.Id == b.RedundantDeviceId && b.IsRedundant)))
|
||||
{
|
||||
if (!_stoppingToken.IsCancellationRequested)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#region copyright
|
||||
#region copyright
|
||||
//------------------------------------------------------------------------------
|
||||
// <EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊȫ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <EFBFBD>˴<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>룩<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߱<EFBFBD><EFBFBD><EFBFBD>Diego<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><EFBFBD>Ŀ<EFBFBD>ԴЭ<EFBFBD>鼰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>
|
||||
// GiteeԴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ⣺https://gitee.com/diego2098/ThingsGateway
|
||||
// GithubԴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ⣺https://github.com/kimdiego2098/ThingsGateway
|
||||
// ʹ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQȺ<EFBFBD><EFBFBD>605534569
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ThingsGateway.Gateway.Blazor
|
||||
try
|
||||
{
|
||||
await OnSaveAsync.InvokeAsync(Content);
|
||||
//await InvokeAsync(async () => await PopupService.EnqueueSnackbarAsync("<EFBFBD>ɹ<EFBFBD>", AlertTypes.Success));
|
||||
//await InvokeAsync(async () => await PopupService.EnqueueSnackbarAsync("成功", AlertTypes.Success));
|
||||
await ClosePopupAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
@layout MainLayout
|
||||
@using ThingsGateway.Admin.Core;
|
||||
@if (IsMobile)
|
||||
@* @if (IsMobile)
|
||||
{
|
||||
@GetAppDataTable()
|
||||
}
|
||||
@@ -67,7 +67,9 @@ else
|
||||
@GetAppDataTable()
|
||||
</MCol>
|
||||
</MRow>
|
||||
}
|
||||
} *@
|
||||
|
||||
@GetAppDataTable()
|
||||
|
||||
|
||||
<ImportExcel @ref=_importExcel Import="SaveDeviceImportAsync" Preview="DeviceImportAsync" />
|
||||
|
@@ -35,7 +35,7 @@ public partial class CollectDevicePage : BaseComponentBase
|
||||
List<CollectDevice> _devices = new();
|
||||
List<DriverPlugin> _driverPlugins;
|
||||
ImportExcel _importExcel;
|
||||
string _searchName;
|
||||
//string _searchName;
|
||||
[Inject]
|
||||
AjaxService _ajaxService { get; set; }
|
||||
[Inject]
|
||||
|
@@ -19,7 +19,7 @@
|
||||
@using Masa.Blazor.Presets;
|
||||
@using System.IO;
|
||||
@using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
@using SqlSugar;
|
||||
@using ThingsGateway.Admin.Blazor;
|
||||
@using ThingsGateway.Admin.Core;
|
||||
|
||||
@@ -48,11 +48,11 @@
|
||||
@if (_tabNumber == 1)
|
||||
{
|
||||
<MRow NoGutters>
|
||||
<MCol Md=2 Cols="12">
|
||||
@* <MCol Md=2 Cols="12">
|
||||
|
||||
<MCard Class="ma-2" Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight + 80}px );")>
|
||||
<MCardTitle>
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceGroupSearchName"
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.DeviceGroup)) />
|
||||
</MCardTitle>
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
} )
|
||||
Items="_collectDeviceGroups" ItemText="r=>r" ItemChildren="r=>null"
|
||||
Search="@_collectDeviceGroupSearchName"
|
||||
Search="@_collectDeviceSearchName"
|
||||
Activatable ItemKey=@(r=>r)>
|
||||
<LabelContent>
|
||||
<span title=@context.Item>
|
||||
@@ -73,12 +73,14 @@
|
||||
</LabelContent>
|
||||
</MTreeview>
|
||||
</MCard>
|
||||
</MCol>
|
||||
<MCol Md=3 Cols="12">
|
||||
</MCol> *@
|
||||
<MCol Md=5 Cols="12">
|
||||
<MCard Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight + 80}px; )") Style="overflow-y:auto;" Flat Class="ml-2 my-4">
|
||||
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_collectDeviceSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.Name)) />
|
||||
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+100}px)") OverscanCount=2 ItemSize="60" Items="_collectDriverBases">
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+140}px)") OverscanCount=2 ItemSize="60" Items="_collectDriverBases.WhereIF(!_collectDeviceSearchName.IsNullOrEmpty(),a=>a.CurrentDevice.Name.Contains(_collectDeviceSearchName)).ToList()">
|
||||
|
||||
<ItemContent>
|
||||
@if (item.CurrentDevice != null)
|
||||
@@ -250,10 +252,10 @@
|
||||
@if (_tabNumber == 2)
|
||||
{
|
||||
<MRow>
|
||||
<MCol Md=2 Cols="12">
|
||||
@* <MCol Md=2 Cols="12">
|
||||
<MCard Class="ma-2" Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight + 80}px); )")>
|
||||
<MCardTitle>
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceGroupSearchName"
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceSearchName"
|
||||
Outlined Label=@typeof(Device).GetDescription(nameof(Device.DeviceGroup)) />
|
||||
</MCardTitle>
|
||||
<MTreeview Style=@($"height: calc(100vh - {BlazorResourceConst.DefaultHeight+240}px);overflow-y:auto") Dense TItem="string" TKey="string" ActiveChanged=@(async a=>
|
||||
@@ -265,7 +267,7 @@
|
||||
}
|
||||
} )
|
||||
Items="_uploadDeviceGroups" ItemText="r=>r" ItemChildren="r=>null"
|
||||
Search="@_uploadDeviceGroupSearchName"
|
||||
Search="@_uploadDeviceSearchName"
|
||||
Activatable ItemKey=@(r=>r)>
|
||||
<LabelContent>
|
||||
<span title=@context.Item>
|
||||
@@ -274,11 +276,13 @@
|
||||
</LabelContent>
|
||||
</MTreeview>
|
||||
</MCard>
|
||||
</MCol>
|
||||
<MCol Md=3 Cols="12">
|
||||
</MCol> *@
|
||||
<MCol Md=5 Cols="12">
|
||||
<MCard Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+80}px)") Style="overflow-y:auto;" Flat Class="ml-2 my-4">
|
||||
<MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="mx-2 my-1" @bind-Value="_uploadDeviceSearchName"
|
||||
Outlined Label=@typeof(CollectDevice).GetDescription(nameof(CollectDevice.Name)) />
|
||||
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+100}px)") OverscanCount=2 ItemSize="60" Items="_uploadDriverBases">
|
||||
<MVirtualScroll Context="item" Height=@($"calc(100vh - {BlazorResourceConst.DefaultHeight+140}px)") OverscanCount=2 ItemSize="60" Items="_uploadDriverBases.WhereIF(!_uploadDeviceSearchName.IsNullOrEmpty(),a=>a.CurrentDevice.Name.Contains(_uploadDeviceSearchName)).ToList()">
|
||||
|
||||
<ItemContent>
|
||||
@if (item.CurrentDevice != null)
|
||||
|
@@ -12,8 +12,6 @@
|
||||
|
||||
using BlazorComponent;
|
||||
|
||||
using Mapster;
|
||||
|
||||
using Masa.Blazor;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -30,10 +28,11 @@ namespace ThingsGateway.Gateway.Blazor;
|
||||
public partial class DeviceStatusPage : IDisposable
|
||||
{
|
||||
readonly PeriodicTimer _periodicTimer = new(TimeSpan.FromSeconds(3));
|
||||
private string _collectDeviceGroup;
|
||||
private bool _isShowDetailUI;
|
||||
List<string> _collectDeviceGroups = new();
|
||||
string _collectDeviceGroupSearchName;
|
||||
//List<string> _collectDeviceGroups = new();
|
||||
//string _collectDeviceGroupSearchName;
|
||||
//private string _collectDeviceSearchName;
|
||||
string _collectDeviceSearchName;
|
||||
List<CollectBase> _collectDriverBases = new();
|
||||
CollectBase _collectDriverItem;
|
||||
BootstrapDynamicComponent _driverComponent;
|
||||
@@ -42,9 +41,10 @@ public partial class DeviceStatusPage : IDisposable
|
||||
bool _isAllRestart;
|
||||
bool _isRestart;
|
||||
StringNumber _tabNumber;
|
||||
private string _uploadDeviceGroup;
|
||||
List<string> _uploadDeviceGroups = new();
|
||||
string _uploadDeviceGroupSearchName;
|
||||
//private string _uploadDeviceSearchName;
|
||||
//List<string> _uploadDeviceGroups = new();
|
||||
//string _uploadDeviceGroupSearchName;
|
||||
string _uploadDeviceSearchName;
|
||||
List<DriverBase> _uploadDriverBases = new();
|
||||
DriverBase _uploadDriverItem;
|
||||
AlarmWorker _alarmWorker { get; set; }
|
||||
@@ -121,8 +121,8 @@ public partial class DeviceStatusPage : IDisposable
|
||||
|
||||
void CollectDeviceQuery()
|
||||
{
|
||||
_collectDeviceGroups = _globalDeviceData.CollectDevices.Adapt<List<CollectDevice>>()?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_collectDriverBases = _collectDeviceWorker?.DriverBases?.WhereIF(!_collectDeviceGroup.IsNullOrEmpty(), a => a.CurrentDevice?.DeviceGroup == _collectDeviceGroup).Select(a => (CollectBase)a).ToList() ?? new();
|
||||
//_collectDeviceGroups = _globalDeviceData.CollectDevices?.Select(a => a.DeviceGroup)?.Where(a => !a.IsNullOrEmpty()).Distinct()?.ToList() ?? new();
|
||||
_collectDriverBases = _collectDeviceWorker?.DriverBases?.WhereIF(!_collectDeviceSearchName.IsNullOrEmpty(), a => a.CurrentDevice?.Name.Contains(_collectDeviceSearchName) == true).Select(a => (CollectBase)a).ToList() ?? new();
|
||||
}
|
||||
async Task DeviceRedundantThreadAsync(long devId)
|
||||
{
|
||||
@@ -207,10 +207,6 @@ public partial class DeviceStatusPage : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
_collectDeviceGroups = _globalDeviceData.CollectDevices.Adapt<List<CollectDevice>>()?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_collectDriverBases = _collectDeviceWorker?.DriverBases?.WhereIF(!_collectDeviceGroup.IsNullOrEmpty(), a => a.CurrentDevice?.DeviceGroup == _collectDeviceGroup).Select(a => (CollectBase)a).ToList() ?? new();
|
||||
}
|
||||
if (_collectDriverBases?.FirstOrDefault()?.CurrentDevice == null || _collectDeviceWorker?.DriverBases.Count != _collectDriverBases.Count)
|
||||
{
|
||||
CollectDeviceQuery();
|
||||
@@ -248,8 +244,8 @@ public partial class DeviceStatusPage : IDisposable
|
||||
|
||||
void UploadDeviceQuery()
|
||||
{
|
||||
_uploadDeviceGroups = _uploadDeviceWorker.DriverBases.Select(a => a.CurrentDevice)?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_uploadDriverBases = _uploadDeviceWorker?.DriverBases?.WhereIF(!_uploadDeviceGroup.IsNullOrEmpty(), a => a.CurrentDevice?.DeviceGroup == _uploadDeviceGroup).ToList() ?? new();
|
||||
//_uploadDeviceGroups = _uploadDeviceWorker.DriverBases.Select(a => a.CurrentDevice)?.Select(a => a.DeviceGroup)?.Where(a => a != null).Distinct()?.ToList() ?? new();
|
||||
_uploadDriverBases = _uploadDeviceWorker?.DriverBases?.WhereIF(!_uploadDeviceSearchName.IsNullOrEmpty(), a => a.CurrentDevice?.Name.Contains(_uploadDeviceSearchName) == true).ToList() ?? new();
|
||||
}
|
||||
async Task UpRestartAsync(long devId)
|
||||
{
|
||||
|
@@ -30,7 +30,7 @@
|
||||
@inject UserResoures UserResoures
|
||||
@layout MainLayout
|
||||
|
||||
@if (IsMobile)
|
||||
@* @if (IsMobile)
|
||||
{
|
||||
@GetAppDataTable()
|
||||
|
||||
@@ -69,7 +69,8 @@ else
|
||||
|
||||
</MCol>
|
||||
</MRow>
|
||||
}
|
||||
} *@
|
||||
@GetAppDataTable()
|
||||
|
||||
<ImportExcel @ref=_importExcel Import="SaveDeviceImportAsync" Preview="DeviceImportAsync" />
|
||||
|
||||
|
@@ -32,7 +32,7 @@ public partial class DeviceVariablePage
|
||||
|
||||
ImportExcel _importExcel;
|
||||
Dictionary<long, List<string>> _otherMethods = new();
|
||||
string _searchName;
|
||||
//string _searchName;
|
||||
|
||||
List<Device> _uploadDevices = new();
|
||||
|
||||
|
@@ -30,7 +30,7 @@
|
||||
@inherits BaseComponentBase
|
||||
@inject UserResoures UserResoures
|
||||
@layout MainLayout
|
||||
@if (IsMobile)
|
||||
@* @if (IsMobile)
|
||||
{
|
||||
@GetAppDataTable()
|
||||
|
||||
@@ -69,7 +69,11 @@ else
|
||||
@GetAppDataTable()
|
||||
</MCol>
|
||||
</MRow>
|
||||
}
|
||||
} *@
|
||||
|
||||
@GetAppDataTable()
|
||||
|
||||
|
||||
@code {
|
||||
RenderFragment GetAppDataTable()
|
||||
{
|
||||
|
@@ -34,7 +34,7 @@ public partial class DeviceVariableRunTimePage
|
||||
private IAppDataTable _datatable;
|
||||
private List<DeviceTree> _deviceGroups = new();
|
||||
private EventCallback<string> _onWrite;
|
||||
private string _searchName;
|
||||
//private string _searchName;
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
@layout MainLayout
|
||||
@using ThingsGateway.Admin.Core;
|
||||
@if (IsMobile)
|
||||
@* @if (IsMobile)
|
||||
{
|
||||
@GetAppDataTable()
|
||||
}
|
||||
@@ -67,8 +67,9 @@ else
|
||||
@GetAppDataTable()
|
||||
</MCol>
|
||||
</MRow>
|
||||
}
|
||||
} *@
|
||||
|
||||
@GetAppDataTable()
|
||||
|
||||
<ImportExcel @ref=_importExcel Import="SaveDeviceImportAsync" Preview="DeviceImportAsync" />
|
||||
|
||||
|
@@ -35,7 +35,7 @@ public partial class UploadDevicePage
|
||||
List<Device> _devices = new();
|
||||
List<DriverPlugin> _driverPlugins;
|
||||
ImportExcel _importExcel;
|
||||
string _searchName;
|
||||
//string _searchName;
|
||||
[Inject]
|
||||
AjaxService _ajaxService { get; set; }
|
||||
[Inject]
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\admin\ThingsGateway.Admin.Blazor\ThingsGateway.Admin.Blazor.csproj" />
|
||||
<ProjectReference Include="..\..\admin\ThingsGateway.Components\ThingsGateway.Components.csproj" />
|
||||
<ProjectReference Include="..\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.1</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<!--<PropertyGroup>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
</PropertyGroup>-->
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj" >
|
||||
|
@@ -30,7 +30,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
@@ -16,8 +16,6 @@ using LiteDB;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
@@ -71,18 +69,19 @@ public partial class KafkaProducer : UpLoadBaseWithCacheT<DeviceData, VariableDa
|
||||
|
||||
#region Kafka 生产者
|
||||
|
||||
Enum.TryParse<SecurityProtocol>(_driverPropertys.SecurityProtocol, out var SecurityProtocol);
|
||||
Enum.TryParse<SaslMechanism>(_driverPropertys.SaslMechanism, out var SaslMechanism);
|
||||
|
||||
//1、生产者配置
|
||||
producerconfig = new ProducerConfig
|
||||
{
|
||||
BootstrapServers = _driverPropertys.BootStrapServers,
|
||||
SecurityProtocol = SecurityProtocol,
|
||||
SaslMechanism = SaslMechanism,
|
||||
SaslUsername = _driverPropertys.SaslUsername,
|
||||
SaslPassword = _driverPropertys.SaslPassword,
|
||||
SecurityProtocol = _driverPropertys.SecurityProtocol,
|
||||
SaslMechanism = _driverPropertys.SaslMechanism,
|
||||
|
||||
};
|
||||
if (!string.IsNullOrEmpty(_driverPropertys.SaslUsername))
|
||||
producerconfig.SaslUsername = _driverPropertys.SaslUsername;
|
||||
if (!string.IsNullOrEmpty(_driverPropertys.SaslPassword))
|
||||
producerconfig.SaslPassword = _driverPropertys.SaslPassword;
|
||||
|
||||
//2、创建生产者
|
||||
producerBuilder = new ProducerBuilder<Null, string>(producerconfig);
|
||||
|
@@ -10,6 +10,8 @@
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
using Confluent.Kafka;
|
||||
|
||||
namespace ThingsGateway.Plugin.Kafka;
|
||||
|
||||
/// <summary>
|
||||
@@ -53,12 +55,10 @@ public class KafkaProducerProperty : UploadPropertyWithCacheT
|
||||
/// </summary>
|
||||
[DeviceProperty("密码", "")]
|
||||
public string SaslPassword { get; set; } = "none";
|
||||
[DeviceProperty("SecurityProtocol", "")]
|
||||
public string SecurityProtocol { get; set; } = "SaslPlaintext";
|
||||
[DeviceProperty("SaslMechanism", "")]
|
||||
public string SaslMechanism { get; set; } = "Plain";
|
||||
|
||||
|
||||
[DeviceProperty("SecurityProtocol", "Plaintext, Ssl, SaslPlaintext, SaslSsl")]
|
||||
public SecurityProtocol SecurityProtocol { get; set; } = SecurityProtocol.Plaintext;
|
||||
[DeviceProperty("SaslMechanism", " Gssapi, Plain, ScramSha256, ScramSha512, OAuthBearer")]
|
||||
public SaslMechanism SaslMechanism { get; set; } = SaslMechanism.Plain;
|
||||
|
||||
/// <summary>
|
||||
/// 设备实体脚本
|
||||
|
@@ -85,7 +85,7 @@ public class ModbusSerialServer : UpLoadBase
|
||||
|
||||
var tags = CurrentDevice.DeviceVariableRunTimes
|
||||
.Where(b => !string.IsNullOrEmpty(
|
||||
b.GetPropertyValue(DeviceId, nameof(_variablePropertys.ServiceAddress)).Value))
|
||||
b.GetPropertyValue(DeviceId, nameof(_variablePropertys.ServiceAddress))?.Value))
|
||||
.ToList();
|
||||
|
||||
tags.ForEach(a =>
|
||||
|
@@ -45,7 +45,7 @@ public class ModbusTcpDtu : CollectBase
|
||||
var client1 = new TcpService();
|
||||
((TcpService)client1).Setup(FoundataionConfig);
|
||||
//载入配置
|
||||
_plc = new((TcpService)client)
|
||||
_plc = new((TcpService)client1)
|
||||
{
|
||||
DataFormat = _driverPropertys.DataFormat,
|
||||
FrameTime = _driverPropertys.FrameTime,
|
||||
|
@@ -64,6 +64,7 @@ public class ModbusTcpServer : UpLoadBase
|
||||
iPHost = new IPHost($"{_driverPropertys.IP}:{_driverPropertys.Port}");
|
||||
}
|
||||
FoundataionConfig.SetListenIPHosts(new IPHost[] { iPHost });
|
||||
FoundataionConfig.SetMaxCount(30000);
|
||||
var service = new TcpService();
|
||||
service.Setup(FoundataionConfig);
|
||||
//载入配置
|
||||
@@ -78,7 +79,7 @@ public class ModbusTcpServer : UpLoadBase
|
||||
|
||||
var tags = CurrentDevice.DeviceVariableRunTimes
|
||||
.Where(b => !string.IsNullOrEmpty(
|
||||
b.GetPropertyValue(DeviceId, nameof(_variablePropertys.ServiceAddress)).Value))
|
||||
b.GetPropertyValue(DeviceId, nameof(_variablePropertys.ServiceAddress))?.Value))
|
||||
.ToList();
|
||||
|
||||
tags.ForEach(a =>
|
||||
|
@@ -51,7 +51,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
@@ -112,7 +112,7 @@ public partial class IotSharpClient : UpLoadBaseWithCacheT<DeviceData, VariableD
|
||||
var tag = CurrentDevice.DeviceVariableRunTimes.FirstOrDefault(a => a.Name == item.Key);
|
||||
if (tag != null)
|
||||
{
|
||||
var rpcEnable = tag.GetPropertyValue(DeviceId, nameof(_variablePropertys.VariableRpcEnable)).Value.ToBool(false) && _driverPropertys.DeviceRpcEnable;
|
||||
var rpcEnable = tag.GetPropertyValue(DeviceId, nameof(_variablePropertys.VariableRpcEnable))?.Value?.ToBool() == true && _driverPropertys.DeviceRpcEnable;
|
||||
if (!rpcEnable)
|
||||
{
|
||||
results.Add(item.Key, new OperResult("权限不足,变量不支持写入"));
|
||||
|
@@ -69,14 +69,20 @@ public partial class MqttClient : UpLoadBaseWithCacheT<DeviceData, VariableData>
|
||||
{
|
||||
base.Init(client);
|
||||
var mqttFactory = new MqttFactory();
|
||||
_mqttClientOptions = mqttFactory.CreateClientOptionsBuilder()
|
||||
var mqttClientOptionsBuilder = mqttFactory.CreateClientOptionsBuilder()
|
||||
.WithClientId(_driverPropertys.ConnectId)
|
||||
.WithCredentials(_driverPropertys.UserName, _driverPropertys.Password)//账密
|
||||
.WithTcpServer(_driverPropertys.IP, _driverPropertys.Port)//服务器
|
||||
|
||||
.WithCleanSession(true)
|
||||
.WithKeepAlivePeriod(TimeSpan.FromSeconds(120.0))
|
||||
.WithoutThrowOnNonSuccessfulConnectResponse()
|
||||
.WithoutThrowOnNonSuccessfulConnectResponse();
|
||||
if (_driverPropertys.IsWebSocket)
|
||||
_mqttClientOptions = mqttClientOptionsBuilder.WithWebSocketServer(a => a.WithUri(_driverPropertys.WebSocktUrl))
|
||||
.Build();
|
||||
else
|
||||
_mqttClientOptions = mqttClientOptionsBuilder.WithTcpServer(_driverPropertys.IP, _driverPropertys.Port)//服务器
|
||||
.Build();
|
||||
|
||||
_mqttSubscribeOptions = mqttFactory.CreateSubscribeOptionsBuilder()
|
||||
.WithTopicFilter(
|
||||
f =>
|
||||
|
@@ -134,7 +134,7 @@ public partial class MqttClient : UpLoadBaseWithCacheT<DeviceData, VariableData>
|
||||
var tag = CurrentDevice.DeviceVariableRunTimes.FirstOrDefault(a => a.Name == rpcData.Key);
|
||||
if (tag != null)
|
||||
{
|
||||
var rpcEnable = tag.GetPropertyValue(DeviceId, nameof(_variablePropertys.VariableRpcEnable)).Value.ToBool();
|
||||
var rpcEnable = tag.GetPropertyValue(DeviceId, nameof(_variablePropertys.VariableRpcEnable))?.Value?.ToBool();
|
||||
if (rpcEnable == true)
|
||||
{
|
||||
|
||||
|
@@ -29,6 +29,16 @@ public class MqttClientProperty : UploadPropertyWithCacheT
|
||||
[DeviceProperty("端口", "")]
|
||||
public override int Port { get; set; } = 1883;
|
||||
/// <summary>
|
||||
/// 是否websocket连接
|
||||
/// </summary>
|
||||
[DeviceProperty("是否WebSocket连接", "true=>websocket,flase=>tcp")]
|
||||
public bool IsWebSocket { get; set; } = false;
|
||||
/// <summary>
|
||||
/// WebSocktUrl
|
||||
/// </summary>
|
||||
[DeviceProperty("WebSocktUrl", "")]
|
||||
public string WebSocktUrl { get; set; } = "ws://127.0.0.1:8083/mqtt";
|
||||
/// <summary>
|
||||
/// 账号
|
||||
/// </summary>
|
||||
[DeviceProperty("账号", "")]
|
||||
|
@@ -14,15 +14,18 @@ using Furion;
|
||||
|
||||
using Mapster;
|
||||
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet;
|
||||
using MQTTnet.AspNetCore;
|
||||
using MQTTnet.Internal;
|
||||
using MQTTnet.Protocol;
|
||||
using MQTTnet.Server;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
using ThingsGateway.Admin.Application;
|
||||
@@ -93,6 +96,7 @@ public class MqttServer : UpLoadBase
|
||||
_mqttServer.InterceptingSubscriptionAsync -= MqttServer_InterceptingSubscriptionAsync; ;
|
||||
_mqttServer?.SafeDispose();
|
||||
}
|
||||
_webHost?.Dispose();
|
||||
_globalDeviceData?.AllVariables?.ForEach(a => a.VariableValueChange -= VariableValueChange);
|
||||
_globalDeviceData?.CollectDevices?.ForEach(a =>
|
||||
{
|
||||
@@ -102,16 +106,32 @@ public class MqttServer : UpLoadBase
|
||||
_collectVariableRunTimes.Clear();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private IWebHost _webHost { get; set; }
|
||||
protected override void Init(ISenderClient client = null)
|
||||
{
|
||||
var mqttFactory = new MqttFactory();
|
||||
var mqttServerOptions = mqttFactory.CreateServerOptionsBuilder()
|
||||
.WithDefaultEndpointBoundIPAddress(string.IsNullOrEmpty(_driverPropertys.IP) ? null : IPAddress.Parse(_driverPropertys.IP))
|
||||
.WithDefaultEndpointPort(_driverPropertys.Port)
|
||||
.WithDefaultEndpoint()
|
||||
.Build();
|
||||
_mqttServer = mqttFactory.CreateMqttServer(mqttServerOptions);
|
||||
//var mqttFactory = new MqttFactory();
|
||||
//var mqttServerOptions = mqttFactory.CreateServerOptionsBuilder()
|
||||
// .WithDefaultEndpointBoundIPAddress(string.IsNullOrEmpty(_driverPropertys.IP) ? null : IPAddress.Parse(_driverPropertys.IP))
|
||||
// .WithDefaultEndpointPort(_driverPropertys.Port)
|
||||
// .WithDefaultEndpoint()
|
||||
// .Build();
|
||||
//_mqttServer = mqttFactory.CreateMqttServer(mqttServerOptions);
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory)
|
||||
.Build();
|
||||
var webBuilder = new WebHostBuilder()
|
||||
.UseKestrel(
|
||||
o =>
|
||||
{
|
||||
o.ListenAnyIP(_driverPropertys.Port, l => l.UseMqtt());
|
||||
o.ListenAnyIP(_driverPropertys.WebSocketPort);
|
||||
});
|
||||
webBuilder.UseStartup<MqttServerStartup>();
|
||||
_webHost = webBuilder.UseConfiguration(configuration)
|
||||
.Build();
|
||||
|
||||
|
||||
_mqttServer = _webHost.Services.GetService<MqttHostedServer>();
|
||||
|
||||
CollectDevices.Where(a => CurrentDevice.DeviceVariableRunTimes.Select(b => b.DeviceId).Contains(a.Id)).ForEach(a =>
|
||||
{
|
||||
@@ -121,11 +141,11 @@ public class MqttServer : UpLoadBase
|
||||
{
|
||||
a.VariableValueChange += VariableValueChange;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected override async Task ProtectedBeforStartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_ = _webHost.StartAsync(cancellationToken);
|
||||
if (_mqttServer != null)
|
||||
{
|
||||
_mqttServer.ValidatingConnectionAsync += MqttServer_ValidatingConnectionAsync;
|
||||
@@ -288,7 +308,7 @@ public class MqttServer : UpLoadBase
|
||||
var tag = CurrentDevice.DeviceVariableRunTimes.FirstOrDefault(a => a.Name == rpcData.Key);
|
||||
if (tag != null)
|
||||
{
|
||||
var rpcEnable = tag.GetPropertyValue(DeviceId, nameof(_variablePropertys.VariableRpcEnable)).Value.ToBool(false);
|
||||
var rpcEnable = tag.GetPropertyValue(DeviceId, nameof(_variablePropertys.VariableRpcEnable))?.Value?.ToBool() == true;
|
||||
if (!rpcEnable)
|
||||
{
|
||||
mqttRpcResult.Success = false;
|
||||
|
@@ -17,17 +17,18 @@ namespace ThingsGateway.Plugin.Mqtt;
|
||||
public class MqttServerProperty : DriverPropertyBase
|
||||
{
|
||||
[DeviceProperty("是否选择全部变量", "")] public bool IsAllVariable { get; set; } = false;
|
||||
/// <summary>
|
||||
/// IP
|
||||
/// </summary>
|
||||
[DeviceProperty("IP", "留空则全部监听")]
|
||||
public override string IP { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
[DeviceProperty("端口", "")]
|
||||
public override int Port { get; set; } = 1883;
|
||||
/// <summary>
|
||||
/// WebSocket端口
|
||||
/// </summary>
|
||||
[DeviceProperty("WebSocket端口", "")]
|
||||
public int WebSocketPort { get; set; } = 8083;
|
||||
/// <summary>
|
||||
/// 允许连接的ID(前缀)
|
||||
/// </summary>
|
||||
[DeviceProperty("允许连接的ID(前缀)", "")]
|
||||
|
@@ -0,0 +1,63 @@
|
||||
#region copyright
|
||||
//------------------------------------------------------------------------------
|
||||
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
|
||||
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
|
||||
// 源代码使用协议遵循本仓库的开源协议及附加协议
|
||||
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
|
||||
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
|
||||
// 使用文档:https://diego2098.gitee.io/thingsgateway-docs/
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
#endregion
|
||||
|
||||
using Mapster;
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using MQTTnet.AspNetCore;
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
namespace MQTTnet.Server;
|
||||
/// <summary>
|
||||
/// MqttServerStartup
|
||||
/// </summary>
|
||||
public class MqttServerStartup
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton(s =>
|
||||
{
|
||||
var serverOptionsBuilder = new MqttServerOptionsBuilder();
|
||||
|
||||
serverOptionsBuilder.WithDefaultEndpoint();
|
||||
|
||||
return serverOptionsBuilder.Build();
|
||||
});
|
||||
|
||||
var logger = new MqttNetEventLogger();
|
||||
services.AddSingleton<IMqttNetLogger>(logger);
|
||||
services.AddSingleton<MqttHostedServer>();
|
||||
//services.AddSingleton<IHostedService>(s => s.GetService<MqttHostedServer>());
|
||||
////不再注册HostService,MqttServer的生命周期由插件完成
|
||||
services.AddSingleton<MqttServer>(s => s.GetService<MqttHostedServer>());
|
||||
services.AddMqttConnectionHandler();
|
||||
services.AddConnections();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapConnectionHandler<MqttConnectionHandler>(
|
||||
"/mqtt",
|
||||
httpConnectionDispatcherOptions => httpConnectionDispatcherOptions.WebSockets.SubProtocolSelector =
|
||||
protocolList => protocolList.FirstOrDefault() ?? string.Empty);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -3,10 +3,15 @@
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
|
||||
<Exec Command=" set dir="$(SolutionDir)web\ThingsGateway.Web.Entry\bin\$(Configuration)\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Mqtt*.dll" %25dir%25


" />
|
||||
<Exec Command=" set dir="$(SolutionDir)web\ThingsGateway.Web.Entry\bin\$(Configuration)\$(TargetFramework)\Plugins\$(AssemblyName)"
 if not exist %25dir%25 md %25dir%25 
copy "$(TargetDir)*Mqtt*.dll" %25dir%25

copy "$(TargetDir)*MQTTnet.AspNetCore*.dll" %25dir%25
" />
|
||||
|
||||
</Target>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MQTTnet.AspNetCore" Version="4.3.1.873" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -45,7 +45,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
@@ -48,7 +48,7 @@ public class OPCUAClient : CollectBase
|
||||
public override Task AfterStopAsync()
|
||||
{
|
||||
_plc?.Disconnect();
|
||||
return Task.CompletedTask;
|
||||
return base.AfterStopAsync();
|
||||
}
|
||||
protected override string GetAddressDescription()
|
||||
{
|
||||
|
@@ -54,7 +54,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
@@ -16,8 +16,6 @@ using Mapster;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
using SqlSugar;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
|
@@ -14,8 +14,6 @@ using LiteDB;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
using RabbitMQ.Client;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
|
@@ -16,8 +16,6 @@ using Mapster;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
using ThingsGateway.Foundation.Sockets;
|
||||
|
||||
|
@@ -16,8 +16,6 @@ using Mapster;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
using ThingsGateway.Foundation.Sockets;
|
||||
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj" >
|
||||
<ProjectReference Include="..\..\gateway\ThingsGateway.Gateway.Blazor\ThingsGateway.Gateway.Blazor.csproj">
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ExcludeAssets>runtime</ExcludeAssets>
|
||||
|
@@ -16,8 +16,6 @@ using Mapster;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using MQTTnet.Diagnostics;
|
||||
|
||||
using SqlSugar;
|
||||
|
||||
using ThingsGateway.Foundation.Extension.ConcurrentQueue;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>4.0.0.1</Version>
|
||||
<Version>4.0.0.5</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
@@ -13,6 +13,4 @@
|
||||
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
</Project>
|
@@ -54,20 +54,6 @@ public class Program
|
||||
builder.Host.UseWindowsService();
|
||||
builder.Host.UseSystemd();
|
||||
|
||||
#if AF2021
|
||||
|
||||
builder.WebHost.UseKestrel(
|
||||
o =>
|
||||
{
|
||||
var config = Furion.App.GetConfig<ThingsGateway.Gateway.LK.MqttConfig>("MqttConfig", true);
|
||||
if (config.Enable)
|
||||
{
|
||||
o.ListenAnyIP(config.Port, a => MQTTnet.AspNetCore.ConnectionBuilderExtensions.UseMqtt(a));
|
||||
o.ListenAnyIP(config.WebSocketPort);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
|
||||
//Furion便利方法
|
||||
builder.Inject();
|
||||
var app = builder.Build();
|
||||
|
@@ -7,12 +7,6 @@
|
||||
<!--<PlatformTarget>x86</PlatformTarget>-->
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<_WebToolingArtifacts Remove="Properties\PublishProfiles\linux64_net6.pubxml" />
|
||||
<_WebToolingArtifacts Remove="Properties\PublishProfiles\linux64_net8.pubxml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="pm2-linux.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -50,17 +44,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--pro内容-->
|
||||
<PropertyGroup Condition="'$(SolutionName)'=='ThingsGateway - Pro - AF2021'">
|
||||
<DefineConstants>AF2021</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(SolutionName)'=='ThingsGateway - Pro - AF2021'">
|
||||
<ProjectReference Include="..\..\PluginProAF2021\ThingsGateway.Gateway.LK\ThingsGateway.Gateway.LK.csproj" />
|
||||
<PackageReference Include="MQTTnet.AspNetCore" Version="4.3.1.873" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user