更新6.0版本

This commit is contained in:
Diego2098
2024-04-14 22:51:56 +08:00
parent e5dd7cc2fa
commit e87428ef33
833 changed files with 53299 additions and 7857 deletions

View File

@@ -87,7 +87,7 @@
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
4. Cachetribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

View File

@@ -19,7 +19,7 @@
#### 采集插件
| 插件名称 | 备注 |
|-------|-------|
| ModbusMaster | Rtu/Tcp报文格式支持串口/Tcp/Udp链路 |
| SiemensS7Master | Rtu/Tcp报文格式支持串口/Tcp/Udp链路 |
| S7 | 西门子PLC S7系列 |
| Dlt6452007 | Master支持串口/Tcp/Udp链路 |
| OpcDaClient | 64位编译 |
@@ -28,7 +28,7 @@
#### 业务插件
| 插件名称 | 备注 |
|-------|-------|
| ModbusSlave | Rtu/Tcp报文格式支持串口/Tcp/Udp链路支持Rpc反写 |
| SiemensS7Slave | Rtu/Tcp报文格式支持串口/Tcp/Udp链路支持Rpc反写 |
| OpcUaServer | OpcUa服务端支持Rpc反写 |
| Mqtt Client | Mqtt客户端支持Rpc反写脚本自定义上传内容 |
| Mqtt Server | Mqtt服务端支持WebSocket支持Rpc反写脚本自定义上传内容 |

10
src/Delete nupkgs.bat Normal file
View File

@@ -0,0 +1,10 @@
@echo off
chcp 65001
setlocal enabledelayedexpansion
set "folder=%~dp0/nupkgs"
rd /s /q "%folder%"
echo 删除了名称为"nupkgs"的文件夹
echo 删除完成!
pause

View File

@@ -5,7 +5,7 @@
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>5.0.3.8</Version>
<Version>6.0.0.0</Version>
<Authors>Diego</Authors>
<Company>Diego</Company>
<Product>Diego</Product>

9
src/Foundation.props Normal file
View File

@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0;</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir)Foundation.props" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

24
src/PackNuget.props Normal file
View File

@@ -0,0 +1,24 @@
<Project>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!--<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>-->
<PackageOutputPath>$(SolutionDir)nupkgs</PackageOutputPath>
<PackageVersion>$(Version)</PackageVersion>
<PackageTags>ThingsGateway;Diego;Blazor;设备采集;边缘网关;物联网</PackageTags>
<PackageProjectUrl>https://gitee.com/diego2098/ThingsGateway</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<DebugSymbols>True</DebugSymbols>
<DebugType>Embedded</DebugType>
<EmbedAllSources>True</EmbedAllSources>
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir)PackNuget.props" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

17
src/Plugin.props Normal file
View File

@@ -0,0 +1,17 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net8.0;</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir)Plugin.props" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,74 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Server", "ThingsGateway.Server\ThingsGateway.Server.csproj", "{BDC88C7C-D37B-44FB-9E84-2619F8B8B007}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Razor", "ThingsGateway.Razor\ThingsGateway.Razor.csproj", "{D3E8D660-AD12-4C46-871F-144D9C83ED2B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Core", "ThingsGateway.Core\ThingsGateway.Core.csproj", "{2904D604-40E9-459C-81E4-2B55FFB27706}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "others", "others", "{2C6B6E2F-76B9-47E1-B3BB-A76595275F2A}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Delete .vs .bat = Delete .vs .bat
Delete Bin And Obj.bat = Delete Bin And Obj.bat
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Admin.Razor", "ThingsGateway.Admin.Razor\ThingsGateway.Admin.Razor.csproj", "{81C3B3AF-9DA6-404B-A20A-31F2FC1CE832}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.Admin.Application", "ThingsGateway.Admin.Application\ThingsGateway.Admin.Application.csproj", "{5EE2DAEF-05DF-4590-B1FA-42917D859F73}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThingsGateway.NewLife.X", "ThingsGateway.NewLife.X\ThingsGateway.NewLife.X.csproj", "{1A04C297-BA57-45F1-8D74-D1DD8FCE83B9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "admin", "admin", "{1A13C5CC-69C9-42D9-8046-96DDECA0467A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{3D3C6EB5-8E66-4B4F-A2F6-8C66673F3116}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BDC88C7C-D37B-44FB-9E84-2619F8B8B007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDC88C7C-D37B-44FB-9E84-2619F8B8B007}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDC88C7C-D37B-44FB-9E84-2619F8B8B007}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDC88C7C-D37B-44FB-9E84-2619F8B8B007}.Release|Any CPU.Build.0 = Release|Any CPU
{D3E8D660-AD12-4C46-871F-144D9C83ED2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3E8D660-AD12-4C46-871F-144D9C83ED2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3E8D660-AD12-4C46-871F-144D9C83ED2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3E8D660-AD12-4C46-871F-144D9C83ED2B}.Release|Any CPU.Build.0 = Release|Any CPU
{2904D604-40E9-459C-81E4-2B55FFB27706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2904D604-40E9-459C-81E4-2B55FFB27706}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2904D604-40E9-459C-81E4-2B55FFB27706}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2904D604-40E9-459C-81E4-2B55FFB27706}.Release|Any CPU.Build.0 = Release|Any CPU
{81C3B3AF-9DA6-404B-A20A-31F2FC1CE832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81C3B3AF-9DA6-404B-A20A-31F2FC1CE832}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81C3B3AF-9DA6-404B-A20A-31F2FC1CE832}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81C3B3AF-9DA6-404B-A20A-31F2FC1CE832}.Release|Any CPU.Build.0 = Release|Any CPU
{5EE2DAEF-05DF-4590-B1FA-42917D859F73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5EE2DAEF-05DF-4590-B1FA-42917D859F73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5EE2DAEF-05DF-4590-B1FA-42917D859F73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5EE2DAEF-05DF-4590-B1FA-42917D859F73}.Release|Any CPU.Build.0 = Release|Any CPU
{1A04C297-BA57-45F1-8D74-D1DD8FCE83B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A04C297-BA57-45F1-8D74-D1DD8FCE83B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A04C297-BA57-45F1-8D74-D1DD8FCE83B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A04C297-BA57-45F1-8D74-D1DD8FCE83B9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D3E8D660-AD12-4C46-871F-144D9C83ED2B} = {3D3C6EB5-8E66-4B4F-A2F6-8C66673F3116}
{2904D604-40E9-459C-81E4-2B55FFB27706} = {3D3C6EB5-8E66-4B4F-A2F6-8C66673F3116}
{81C3B3AF-9DA6-404B-A20A-31F2FC1CE832} = {1A13C5CC-69C9-42D9-8046-96DDECA0467A}
{5EE2DAEF-05DF-4590-B1FA-42917D859F73} = {1A13C5CC-69C9-42D9-8046-96DDECA0467A}
{1A04C297-BA57-45F1-8D74-D1DD8FCE83B9} = {3D3C6EB5-8E66-4B4F-A2F6-8C66673F3116}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {199B1B96-4F56-4828-9531-813BA02DB282}
EndGlobalSection
EndGlobal

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -39,10 +43,11 @@ public class OperDescAttribute : MoAttribute
Task.Factory.StartNew(ProcessQueue, TaskCreationOptions.LongRunning);
}
public OperDescAttribute(string description, bool isRecordPar = true)
public OperDescAttribute(string description, bool isRecordPar = true, object localizerType = null)
{
Description = description;
IsRecordPar = isRecordPar;
LocalizerType = (Type)localizerType;
}
public override AccessFlags Flags => AccessFlags.Public | AccessFlags.Method;
@@ -53,6 +58,8 @@ public class OperDescAttribute : MoAttribute
/// </summary>
public string Description { get; }
public Type? LocalizerType { get; }
/// <summary>
/// 是否记录进出参数
/// </summary>
@@ -61,14 +68,14 @@ public class OperDescAttribute : MoAttribute
public override void OnSuccess(MethodContext context)
{
//插入操作日志
SysOperateLog log = GetOperLog(context);
SysOperateLog log = GetOperLog(LocalizerType, context);
WriteToQueue(log);
}
public override void OnException(MethodContext context)
{
//插入异常日志
SysOperateLog log = GetOperLog(context);
SysOperateLog log = GetOperLog(LocalizerType, context);
log.Category = LogCateGoryEnum.Exception;//操作类型为异常
log.ExeStatus = false;//操作状态为失败
@@ -85,7 +92,7 @@ public class OperDescAttribute : MoAttribute
/// </summary>
private static async Task ProcessQueue()
{
var db = DbContext.Db.CopyNew();
var db = DbContext.Db.GetConnectionScopeWithAttr<SysOperateLog>().CopyNew();
var appLifetime = App.RootServices!.GetService<IHostApplicationLifetime>()!;
while (!(appLifetime.ApplicationStopping.IsCancellationRequested || appLifetime.ApplicationStopped.IsCancellationRequested))
{
@@ -104,7 +111,7 @@ public class OperDescAttribute : MoAttribute
}
}
private SysOperateLog GetOperLog(MethodContext context)
private SysOperateLog GetOperLog(Type? localizerType, MethodContext context)
{
var str = App.HttpContext?.Request?.Headers?.UserAgent;
var methodBase = context.Method;
@@ -131,7 +138,7 @@ public class OperDescAttribute : MoAttribute
//操作日志表实体
var log = new SysOperateLog
{
Name = App.CreateLocalizerByType(typeof(OperDescAttribute))![Description],
Name = (localizerType == null ? App.CreateLocalizerByType(typeof(OperDescAttribute)) : App.CreateLocalizerByType(localizerType))![Description],
Category = LogCateGoryEnum.Operate,
ExeStatus = true,
OpIp = App.HttpContext?.Connection?.RemoteIpAddress?.MapToIPv4()?.ToString(),

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
namespace ThingsGateway.Admin.Application;
@@ -21,12 +25,12 @@ public class MinValueAttribute : ValidationAttribute
/// 最小值
/// </summary>
/// <param name="value"></param>
public MinValueAttribute(int value)
public MinValueAttribute(UInt64 value)
{
MinValue = value;
}
private int MinValue { get; set; }
private UInt64 MinValue { get; set; }
/// <summary>
/// 最小值校验
@@ -40,7 +44,7 @@ public class MinValueAttribute : ValidationAttribute
return false;
}
var input = Convert.ToInt32(value);
var input = Convert.ToUInt64(value);
return input >= MinValue;
}
}

View File

@@ -0,0 +1,676 @@

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
using System.Collections;
namespace ThingsGateway.Admin.Application.ConcurrentList;
/// <summary>
/// 线程安全的List其基本操作和List一致。
/// </summary>
/// <typeparam name="T"></typeparam>
public class ConcurrentList<T> : IList<T>, IReadOnlyList<T>
{
private readonly List<T> m_list;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="collection"></param>
public ConcurrentList(IEnumerable<T> collection)
{
this.m_list = new List<T>(collection);
}
/// <summary>
/// 构造函数
/// </summary>
public ConcurrentList()
{
this.m_list = new List<T>();
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="capacity"></param>
public ConcurrentList(int capacity)
{
this.m_list = new List<T>(capacity);
}
/// <summary>
/// 元素数量
/// </summary>
public int Count
{
get
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.Count;
}
}
}
/// <summary>
/// 是否为只读
/// </summary>
public bool IsReadOnly => false;
/// <summary>
/// 获取索引元素
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public T this[int index]
{
get
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list[index];
}
}
set
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list[index] = value;
}
}
}
/// <summary>
/// 添加元素
/// </summary>
/// <param name="item"></param>
public void Add(T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Add(item);
}
}
/// <summary>
/// 清空所有元素
/// </summary>
public void Clear()
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Clear();
}
}
/// <summary>
/// 是否包含某个元素
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Contains(T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.Contains(item);
}
}
/// <summary>
/// 复制到
/// </summary>
/// <param name="array"></param>
/// <param name="arrayIndex"></param>
public void CopyTo(T[] array, int arrayIndex)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.CopyTo(array, arrayIndex);
}
}
/// <summary>
/// 返回迭代器
/// </summary>
/// <returns></returns>
public IEnumerator<T> GetEnumerator()
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.ToList().GetEnumerator();
}
}
/// <summary>
/// 返回迭代器组合
/// </summary>
/// <returns></returns>
IEnumerator IEnumerable.GetEnumerator()
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.GetEnumerator();
}
}
/// <summary>
/// 索引
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public int IndexOf(T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.IndexOf(item);
}
}
/// <summary>
/// 插入
/// </summary>
/// <param name="index"></param>
/// <param name="item"></param>
public void Insert(int index, T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Insert(index, item);
}
}
/// <summary>
/// 移除元素
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Remove(T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.Remove(item);
}
}
/// <summary>
/// 按索引移除
/// </summary>
/// <param name="index"></param>
public void RemoveAt(int index)
{
lock (((ICollection)this.m_list).SyncRoot)
{
if (index < this.m_list.Count)
{
this.m_list.RemoveAt(index);
}
}
}
/// <summary>
/// 获取或设置容量
/// </summary>
public int Capacity
{
get
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.Capacity;
}
}
set
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Capacity = value;
}
}
}
/// <summary>
/// <inheritdoc cref="List{T}.AddRange(IEnumerable{T})"/>
/// </summary>
/// <param name="collection"></param>
public void AddRange(IEnumerable<T> collection)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.AddRange(collection);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.BinarySearch(T)"/>
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public int BinarySearch(T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.BinarySearch(item);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.BinarySearch(T, IComparer{T})"/>
/// </summary>
/// <param name="item"></param>
/// <param name="comparer"></param>
/// <returns></returns>
public int BinarySearch(T item, IComparer<T> comparer)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.BinarySearch(item, comparer);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.BinarySearch(int, int, T, IComparer{T})"/>
/// </summary>
/// <param name="index"></param>
/// <param name="count"></param>
/// <param name="item"></param>
/// <param name="comparer"></param>
/// <returns></returns>
public int BinarySearch(int index, int count, T item, IComparer<T> comparer)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.BinarySearch(index, count, item, comparer);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.ConvertAll{TOutput}(Converter{T, TOutput})"/>
/// </summary>
/// <typeparam name="TOutput"></typeparam>
/// <param name="converter"></param>
/// <returns></returns>
public List<TOutput> ConvertAll<TOutput>(Converter<T, TOutput> converter)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.ConvertAll(converter);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Find(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public T Find(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.Find(match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindAll(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public List<T> FindAll(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindAll(match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindIndex(int, int, Predicate{T})"/>
/// </summary>
/// <param name="startIndex"></param>
/// <param name="count"></param>
/// <param name="match"></param>
/// <returns></returns>
public int FindIndex(int startIndex, int count, Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindIndex(startIndex, count, match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindIndex(int, Predicate{T})"/>
/// </summary>
/// <param name="startIndex"></param>
/// <param name="match"></param>
/// <returns></returns>
public int FindIndex(int startIndex, Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindIndex(startIndex, match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindIndex(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public int FindIndex(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindIndex(match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindLast(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public T FindLast(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindLast(match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindLastIndex(int, int, Predicate{T})"/>
/// </summary>
/// <param name="startIndex"></param>
/// <param name="count"></param>
/// <param name="match"></param>
/// <returns></returns>
public int FindLastIndex(int startIndex, int count, Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindLastIndex(startIndex, count, match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindLastIndex(int, Predicate{T})"/>
/// </summary>
/// <param name="startIndex"></param>
/// <param name="match"></param>
/// <returns></returns>
public int FindLastIndex(int startIndex, Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindLastIndex(startIndex, match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.FindLastIndex(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public int FindLastIndex(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.FindLastIndex(match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.ForEach(Action{T})"/>
/// </summary>
/// <param name="action"></param>
public void ForEach(Action<T> action)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.ForEach(action);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.GetRange(int, int)"/>
/// </summary>
/// <param name="index"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<T> GetRange(int index, int count)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.GetRange(index, count);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.IndexOf(T, int)"/>
/// </summary>
/// <param name="item"></param>
/// <param name="index"></param>
/// <returns></returns>
public int IndexOf(T item, int index)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.IndexOf(item, index);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.IndexOf(T, int, int)"/>
/// </summary>
/// <param name="item"></param>
/// <param name="index"></param>
/// <param name="count"></param>
/// <returns></returns>
public int IndexOf(T item, int index, int count)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.IndexOf(item, index, count);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.InsertRange(int, IEnumerable{T})"/>
/// </summary>
/// <param name="index"></param>
/// <param name="collection"></param>
public void InsertRange(int index, IEnumerable<T> collection)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.InsertRange(index, collection);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.LastIndexOf(T)"/>
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public int LastIndexOf(T item)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.IndexOf(item);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.LastIndexOf(T, int)"/>
/// </summary>
/// <param name="item"></param>
/// <param name="index"></param>
/// <returns></returns>
public int LastIndexOf(T item, int index)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.LastIndexOf(item, index);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.LastIndexOf(T, int, int)"/>
/// </summary>
/// <param name="item"></param>
/// <param name="index"></param>
/// <param name="count"></param>
/// <returns></returns>
public int LastIndexOf(T item, int index, int count)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.LastIndexOf(item, index, count);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.RemoveAll(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
public void RemoveAll(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.RemoveAll(match);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.RemoveRange(int, int)"/>
/// </summary>
/// <param name="index"></param>
/// <param name="count"></param>
public void RemoveRange(int index, int count)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.RemoveRange(index, count);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Reverse()"/>
/// </summary>
public void Reverse()
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Reverse();
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Reverse(int, int)"/>
/// </summary>
/// <param name="index"></param>
/// <param name="count"></param>
public void Reverse(int index, int count)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Reverse(index, count);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Sort()"/>
/// </summary>
public void Sort()
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Sort();
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Sort(Comparison{T})"/>
/// </summary>
/// <param name="comparison"></param>
public void Sort(Comparison<T> comparison)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Sort(comparison);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Sort(IComparer{T})"/>
/// </summary>
/// <param name="comparer"></param>
public void Sort(IComparer<T> comparer)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Sort(comparer);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.Sort(int, int, IComparer{T})"/>
/// </summary>
/// <param name="index"></param>
/// <param name="count"></param>
/// <param name="comparer"></param>
public void Sort(int index, int count, IComparer<T> comparer)
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.Sort(index, count, comparer);
}
}
/// <summary>
/// <inheritdoc cref="List{T}.ToArray"/>
/// </summary>
/// <returns></returns>
public T[] ToArray()
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.ToArray();
}
}
/// <summary>
/// <inheritdoc cref="List{T}.TrimExcess"/>
/// </summary>
public void TrimExcess()
{
lock (((ICollection)this.m_list).SyncRoot)
{
this.m_list.TrimExcess();
}
}
/// <summary>
/// <inheritdoc cref="List{T}.TrueForAll(Predicate{T})"/>
/// </summary>
/// <param name="match"></param>
/// <returns></returns>
public bool TrueForAll(Predicate<T> match)
{
lock (((ICollection)this.m_list).SyncRoot)
{
return this.m_list.TrueForAll(match);
}
}
}

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application
{
public class CacheConst
@@ -44,6 +48,16 @@ namespace ThingsGateway.Admin.Application
/// </summary>
public const string Cache_SysRole = $"{CacheConst.Cache_Prefix_Admin}SysRole:";
/// <summary>
/// Token表缓存Key
/// </summary>
public const string Cache_Token = $"{CacheConst.Cache_Prefix_Admin}Token:";
/// <summary>
/// Token表缓存Key
/// </summary>
public const string Cache_HardwareInfo = $"{CacheConst.Cache_Prefix_Admin}Cache_HardwareInfo:";
#region
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>
@@ -25,6 +29,16 @@ public class SqlSugarConst
/// </summary>
public const string DB_Log = "DB_Log";
/// <summary>
/// DB_TokenCache
/// </summary>
public const string DB_TokenCache = "DB_TokenCache";
/// <summary>
/// DB_HardwareInfo
/// </summary>
public const string DB_HardwareInfo = "DB_HardwareInfo";
/// <summary>
/// DB_Custom
/// </summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -15,7 +19,7 @@ using Microsoft.AspNetCore.WebUtilities;
namespace ThingsGateway.Admin.Application;
[Route("auth")]
[Route("api/auth")]
[LoggingMonitor]
public class AuthController : ControllerBase
{

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
@@ -43,6 +47,14 @@ public class CultureController : Controller
{
Expires = DateTimeOffset.Now.AddYears(1)
});
//更改全局文化,采集后台也会变化
//var cultureInfo = new CultureInfo(culture);
//CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
//CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
//CultureInfo.CurrentCulture = cultureInfo;
//CultureInfo.CurrentUICulture = cultureInfo;
}
return LocalRedirect(redirectUri);

View File

@@ -1,36 +0,0 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ThingsGateway.Admin.Application;
[Route("export")]
public class ExportController : ControllerBase
{
private readonly ISysOperateLogService _operateLogService;
public ExportController(ISysOperateLogService operateLogService)
{
_operateLogService = operateLogService;
}
[HttpGet("operateLog")]
[Authorize]
[IgnoreRolePermission]
public async Task<IActionResult> DownloadOperateLogAsync([FromQuery] QueryPageOptions input)
{
var fileStreamResult = await _operateLogService.ExportFileAsync(input);
return fileStreamResult;
}
}

View File

@@ -0,0 +1,48 @@

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace ThingsGateway.Admin.Application
{
/// <summary>
/// 文件下载
/// </summary>
[Route("api/file")]
public class FileController : ControllerBase
{
/// <summary>
/// 下载wwwroot文件夹下的文件
/// </summary>
/// <param name="fileName">相对路径</param>
/// <returns></returns>
[HttpGet("download")]
public IActionResult Download(string fileName)
{
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", fileName);
if (!System.IO.File.Exists(filePath))
{
return NotFound();
}
var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Response.Headers.Append("Access-Control-Expose-Headers", "Content-Disposition");
return File(fileStream, "application/octet-stream", (fileName.Replace('/', '_')));
}
}
}

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components.Forms;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Http;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Http;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
@@ -91,7 +95,7 @@ public class UnifyResultProvider : IUnifyResultProvider
return new UnifyResult<object>
{
Code = statusCode,
Msg = statusCode == StatusCodes.Status200OK ? "请求成功" : errors,
Msg = statusCode == StatusCodes.Status200OK ? "Success" : errors,
Data = data,
Time = DateTime.Now,
};

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,18 +9,23 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ThingsGateway.Admin.Application;
[Route("testController")]
[Route("api/[controller]/[action]")]
[RolePermission]
[Authorize(AuthenticationSchemes = "Bearer")]
public class TestController : ControllerBase
{
[HttpGet("test")]
public async Task Test()
[HttpGet]
public async Task Test(QueryPageOptions queryPageOptions)
{
await Task.CompletedTask;
}

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using SqlSugar;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using SqlSugar;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using SqlSugar;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using SqlSugar;
namespace ThingsGateway.Admin.Application;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components.Routing;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using SqlSugar;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Mapster;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
public enum LogCateGoryEnum

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
public enum RelationCategoryEnum

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
public enum ResourceCategoryEnum

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
public enum RoleCategoryEnum

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
public enum TargetEnum

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <inheritdoc/>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,9 +9,6 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
//
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证。
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Http;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Mvc.Controllers;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,12 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.Extensions.Localization;
using System.ComponentModel;
@@ -26,6 +33,103 @@ public static class LocalizerExtensions
public static FieldInfo? GetFieldByName(this Type type, string fieldName) => type.GetRuntimeFields().FirstOrDefault(p => p.Name == fieldName);
private static bool IsPublic(PropertyInfo p) => p.GetMethod != null && p.SetMethod != null && p.GetMethod.IsPublic && p.SetMethod.IsPublic;
/// <summary>
/// 验证整个模型时验证属性方法
/// </summary>
/// <param name="context"></param>
/// <param name="results"></param>
public static void ValidateProperty(this ValidationContext context, List<ValidationResult> results)
{
// 获得所有可写属性
var properties = context.ObjectType.GetRuntimeProperties().Where(p => IsPublic(p) && p.CanWrite && p.GetIndexParameters().Length == 0);
foreach (var pi in properties)
{
var fieldIdentifier = new FieldIdentifier(context.ObjectInstance, pi.Name);
context.DisplayName = fieldIdentifier.GetDisplayName();
context.MemberName = fieldIdentifier.FieldName;
var propertyValue = BootstrapBlazor.Components.Utility.GetPropertyValue(context.ObjectInstance, context.MemberName);
// 验证 DataAnnotations
var messages = new List<ValidationResult>();
// 组件进行验证
ValidateDataAnnotations(propertyValue, context, messages, pi);
if (messages.Count > 0)
results.AddRange(messages);
}
}
/// <summary>
/// 通过属性设置的 DataAnnotation 进行数据验证
/// </summary>
/// <param name="value"></param>
/// <param name="context"></param>
/// <param name="results"></param>
/// <param name="propertyInfo"></param>
/// <param name="memberName"></param>
private static void ValidateDataAnnotations(object? value, ValidationContext context, List<ValidationResult> results, PropertyInfo propertyInfo, string? memberName = null)
{
var rules = propertyInfo.GetCustomAttributes(true).OfType<ValidationAttribute>();
var metadataType = context.ObjectType.GetCustomAttribute<MetadataTypeAttribute>(false);
if (metadataType != null)
{
var p = metadataType.MetadataClassType.GetPropertyByName(propertyInfo.Name);
if (p != null)
{
rules = rules.Concat(p.GetCustomAttributes(true).OfType<ValidationAttribute>());
}
}
var displayName = context.DisplayName;
memberName ??= propertyInfo.Name;
var attributeSpan = nameof(Attribute).AsSpan();
foreach (var rule in rules)
{
var result = rule.GetValidationResult(value, context);
if (result != null && result != ValidationResult.Success)
{
var find = false;
var ruleNameSpan = rule.GetType().Name.AsSpan();
var index = ruleNameSpan.IndexOf(attributeSpan, StringComparison.OrdinalIgnoreCase);
var ruleName = ruleNameSpan[..index];
//// 通过设置 ErrorMessage 检索
//if (!context.ObjectType.Assembly.IsDynamic && !find
// && !string.IsNullOrEmpty(rule.ErrorMessage)
// && App.CreateLocalizerByType(context.ObjectType).TryGetLocalizerString(rule.ErrorMessage, out var msg))
//{
// rule.ErrorMessage = msg;
// find = true;
//}
//// 通过 Attribute 检索
//if (!rule.GetType().Assembly.IsDynamic && !find
// && App.CreateLocalizerByType(rule.GetType()).TryGetLocalizerString(nameof(rule.ErrorMessage), out msg))
//{
// rule.ErrorMessage = msg;
// find = true;
//}
// 通过 字段.规则名称 检索
if (!context.ObjectType.Assembly.IsDynamic && !find
&& App.CreateLocalizerByType(context.ObjectType).TryGetLocalizerString($"{memberName}.{ruleName.ToString()}", out var msg))
{
rule.ErrorMessage = msg;
find = true;
}
if (!find)
{
rule.ErrorMessage = result.ErrorMessage;
}
var errorMessage = !string.IsNullOrEmpty(rule.ErrorMessage) && rule.ErrorMessage.Contains("{0}")
? rule.FormatErrorMessage(displayName)
: rule.ErrorMessage;
results.Add(new ValidationResult(errorMessage, new string[] { memberName }));
}
}
}
/// <summary>
/// 获取指定 Type 的资源文件
/// </summary>

View File

@@ -1,3 +1,4 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Http;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,9 +9,12 @@
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
using NewLife;
using NewLife.Extension;
using SqlSugar;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,9 +9,13 @@
// QQ群605534569
//------------------------------------------------------------------------------
using SqlSugar;
using System.Linq.Expressions;
using System.Reflection;
using ThingsGateway.Core;
@@ -167,4 +172,71 @@ public static class SqlSugarExtensions
HasPrevPages = pageIndex - 1 > 0
};
}
/// <summary>
/// 分页查询
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list">数据列表</param>
/// <param name="basePageInput">参数</param>
/// <param name="isAll">不分页</param>
/// <returns>分页集合</returns>
public static SqlSugarPagedList<T> ToPagedList<T>(this IEnumerable<T> list, BasePageInput basePageInput = null, bool isAll = false)
{
if (isAll)
{
list = Sort(list, basePageInput);
var data = new SqlSugarPagedList<T>
{
Current = 1,
Size = list?.Count() ?? 0,
Records = list,
Total = list?.Count() ?? 0,
Pages = 1,
HasNextPages = false,
HasPrevPages = false
};
return data;
}
int _PageIndex = basePageInput.Current;
int _PageSize = basePageInput.Size;
var num = list.Count();
var pageConut = (double)num / _PageSize;
int PageConut = (int)Math.Ceiling(pageConut);
list = Sort(list, basePageInput);
if (PageConut >= _PageIndex)
{
list = list.Skip((_PageIndex - 1) * _PageSize).Take(_PageSize);
}
return new SqlSugarPagedList<T>
{
Current = _PageIndex,
Size = _PageSize,
Records = list,
Total = num,
Pages = PageConut,
HasNextPages = _PageIndex < PageConut,
HasPrevPages = _PageIndex - 1 > 0
};
}
public static IEnumerable<T> Sort<T>(this IEnumerable<T> list, BasePageInput basePageInput)
{
if (basePageInput != null && basePageInput.SortField != null)
{
for (int i = 0; i < basePageInput.SortField.Count; i++)
{
var pro = typeof(T).GetRuntimeProperty(basePageInput.SortField[i]);
if (pro != null)
{
if (!basePageInput.SortDesc[i])
list = list.OrderBy(a => pro.GetValue(a));
else
list = list.OrderByDescending(a => pro.GetValue(a));
}
}
}
return list;
}
}

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Builder;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
namespace ThingsGateway.Admin.Application;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
#if !NET5_0

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Newtonsoft.Json;

View File

@@ -1,3 +1,4 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Newtonsoft.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Newtonsoft.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
#if !NET5_0

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using System.Text.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using System.Text.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using System.Text.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using System.Text.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
#if !NET5_0

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using ThingsGateway.JsonSerialization;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,12 +9,15 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using ThingsGateway.JsonSerialization;
using System.Text.Json.Serialization;
using ThingsGateway.JsonSerialization;
namespace System.Text.Json;
/// <summary>

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Newtonsoft.Json;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.DependencyInjection;

View File

@@ -1,3 +1,4 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.JsonSerialization;

View File

@@ -1,3 +1,4 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.AspNetCore.Mvc;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.DependencyInjection;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using System.Text;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Configuration;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,9 +9,13 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Collections.Concurrent;
@@ -114,7 +119,7 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
// 设置 1.5秒的缓冲时间,避免还有日志消息没有完成写入数据库中
_processQueueTask?.Wait(1500);
}
catch (TaskCanceledException) { }
catch (OperationCanceledException) { }
catch (AggregateException ex) when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is TaskCanceledException) { }
catch { }
@@ -171,25 +176,34 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
/// <remarks></remarks>
private async Task ProcessQueueAsync()
{
foreach (var logMsg in _logMessageQueue.GetConsumingEnumerable())
var lifetime = _serviceScope.ServiceProvider.GetService<IHostApplicationLifetime>();
try
{
try
foreach (var logMsg in _logMessageQueue.GetConsumingEnumerable(lifetime.ApplicationStopping))
{
// 调用数据库写入器写入数据库方法
await _databaseLoggingWriter.WriteAsync(logMsg, _logMessageQueue.Count == 0);
}
catch (Exception ex)
{
// 处理数据库写入错误
if (LoggerOptions.HandleWriteError != null)
try
{
var databaseWriteError = new DatabaseWriteError(ex);
LoggerOptions.HandleWriteError(databaseWriteError);
// 调用数据库写入器写入数据库方法
await _databaseLoggingWriter.WriteAsync(logMsg, _logMessageQueue.Count == 0);
}
// 这里不抛出异常,避免中断日志写入
else { }
catch (Exception ex)
{
// 处理数据库写入错误
if (LoggerOptions.HandleWriteError != null)
{
var databaseWriteError = new DatabaseWriteError(ex);
LoggerOptions.HandleWriteError(databaseWriteError);
}
// 这里不抛出异常,避免中断日志写入
else { }
}
finally { }
}
finally { }
}
catch (OperationCanceledException)
{
}
}
}

View File

@@ -1,3 +1,4 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,3 +1,4 @@
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
namespace ThingsGateway.Logging;

View File

@@ -1,4 +1,5 @@
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
@@ -8,6 +9,9 @@
// QQ群605534569
//------------------------------------------------------------------------------
// 版权归百小僧及百签科技(广东)有限公司所有。
using Microsoft.Extensions.Logging;

Some files were not shown because too many files have changed in this diff Show More