mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-22 11:33:07 +08:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
58f8b23b7c | ||
![]() |
9e7c348b15 | ||
![]() |
5f5ff8b43b | ||
![]() |
f626b4e5fc | ||
![]() |
bc23200e66 | ||
![]() |
95ab59fd5a | ||
![]() |
0bbee003b0 |
@@ -20,11 +20,14 @@ A cross-platform, high-performance edge data collection gateway based on net9.
|
||||
## Demo
|
||||
|
||||
|
||||
[Demo](http://47.119.161.158:5000/)
|
||||
[Demo](https://demo.thingsgateway.cn/)
|
||||
|
||||
|
||||
Account: **SuperAdmin**
|
||||
|
||||
|
||||
Password: **111111**
|
||||
|
||||
|
||||
**In the upper-right corner, switch to the IoT Gateway module in the personal popup box**
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
## 演示
|
||||
|
||||
[ThingsGateway演示地址](http://47.119.161.158:5000/)
|
||||
[ThingsGateway演示地址](https://demo.thingsgateway.cn/)
|
||||
|
||||
账户 : **SuperAdmin**
|
||||
|
||||
|
@@ -137,7 +137,7 @@ public sealed class OperDescAttribute : MoAttribute
|
||||
Name = (localizerType == null ? App.CreateLocalizerByType(typeof(OperDescAttribute)) : App.CreateLocalizerByType(localizerType))![Description],
|
||||
Category = LogCateGoryEnum.Operate,
|
||||
ExeStatus = true,
|
||||
OpIp = AppService?.RemoteIpAddress?.MapToIPv4()?.ToString() ?? string.Empty,
|
||||
OpIp = AppService?.RemoteIpAddress ?? string.Empty,
|
||||
OpBrowser = clientInfo?.UA?.Family + clientInfo?.UA?.Major,
|
||||
OpOs = clientInfo?.OS?.Family + clientInfo?.OS?.Major,
|
||||
OpTime = DateTime.Now,
|
||||
|
@@ -23,7 +23,7 @@ public class SysDict : BaseEntity
|
||||
/// <summary>
|
||||
/// 类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "类型", Length = 200)]
|
||||
[SugarColumn(ColumnDescription = "类型")]
|
||||
[AutoGenerateColumn(Ignore = true, Filterable = true, Sortable = true)]
|
||||
public virtual DictTypeEnum DictType { get; set; }
|
||||
|
||||
|
@@ -24,7 +24,7 @@ public class SysOperateLog
|
||||
/// <summary>
|
||||
/// 日志分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "日志分类", Length = 200)]
|
||||
[SugarColumn(ColumnDescription = "日志分类")]
|
||||
[AutoGenerateColumn(Order = 1, Filterable = true, Sortable = true)]
|
||||
public LogCateGoryEnum Category { get; set; }
|
||||
|
||||
|
@@ -54,7 +54,7 @@ public class SysPosition : BaseEntity
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Category", ColumnDescription = "分类", Length = 200)]
|
||||
[SugarColumn(ColumnName = "Category", ColumnDescription = "分类")]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual PositionCategoryEnum Category { get; set; }
|
||||
|
||||
|
@@ -22,7 +22,7 @@ public class SysRelation : PrimaryKeyEntity
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "分类", Length = 200)]
|
||||
[SugarColumn(ColumnDescription = "分类")]
|
||||
public RelationCategoryEnum Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@@ -41,7 +41,7 @@ public class SysRole : BaseEntity
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnDescription = "分类", Length = 200, IsNullable = false)]
|
||||
[SugarColumn(ColumnDescription = "分类", IsNullable = false)]
|
||||
[AutoGenerateColumn(Visible = true, Sortable = true, Filterable = true)]
|
||||
public virtual RoleCategoryEnum Category { get; set; }
|
||||
|
||||
|
@@ -72,7 +72,7 @@ public class AppService : IAppService
|
||||
}
|
||||
public ClaimsPrincipal? User => App.User;
|
||||
|
||||
public IPAddress? RemoteIpAddress => App.HttpContext?.Connection?.RemoteIpAddress;
|
||||
public string? RemoteIpAddress => App.HttpContext?.GetRemoteIpAddressToIPv4();
|
||||
|
||||
public int LocalPort => App.HttpContext.Connection.LocalPort;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class HybridAppService : IAppService
|
||||
{
|
||||
var str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0";
|
||||
ClientInfo = Parser.GetDefault().Parse(str);
|
||||
RemoteIpAddress = IPAddress.Parse("127.0.0.1");
|
||||
RemoteIpAddress = "127.0.0.1";
|
||||
}
|
||||
public ClientInfo? ClientInfo { get; }
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HybridAppService : IAppService
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress? RemoteIpAddress { get; }
|
||||
public string? RemoteIpAddress { get; }
|
||||
|
||||
public string GetReturnUrl(string returnUrl)
|
||||
{
|
||||
|
@@ -31,7 +31,7 @@ public interface IAppService
|
||||
/// <summary>
|
||||
/// RemoteIpAddress
|
||||
/// </summary>
|
||||
public IPAddress? RemoteIpAddress { get; }
|
||||
public string? RemoteIpAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// GetReturnUrl
|
||||
|
@@ -105,7 +105,7 @@ public class AuthService : IAuthService
|
||||
{
|
||||
var loginEvent = new LoginEvent
|
||||
{
|
||||
Ip = _appService.RemoteIpAddress?.MapToIPv4()?.ToString(),
|
||||
Ip = _appService.RemoteIpAddress,
|
||||
SysUser = userinfo,
|
||||
VerificatId = verificatId
|
||||
};
|
||||
@@ -236,7 +236,7 @@ public class AuthService : IAuthService
|
||||
//登录事件参数
|
||||
var logingEvent = new LoginEvent
|
||||
{
|
||||
Ip = _appService.RemoteIpAddress?.MapToIPv4()?.ToString(),
|
||||
Ip = _appService.RemoteIpAddress,
|
||||
Device = App.GetService<IAppService>().ClientInfo?.OS?.ToString(),
|
||||
Expire = expire,
|
||||
SysUser = sysUser,
|
||||
|
@@ -47,12 +47,10 @@ public class BaseService<T> : IDataService<T>, IDisposable where T : class, new(
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<bool> DeleteAsync(IEnumerable<T> models)
|
||||
public async Task<bool> DeleteAsync(IEnumerable<T> models)
|
||||
{
|
||||
if (models.FirstOrDefault() is IPrimaryIdEntity)
|
||||
return DeleteAsync(models.Select(a => ((IPrimaryIdEntity)a).Id));
|
||||
else
|
||||
return Task.FromResult(false);
|
||||
using var db = GetDB();
|
||||
return await db.Deleteable<T>().In(models.ToList()).ExecuteCommandHasChangeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -165,4 +163,6 @@ public class BaseService<T> : IDataService<T>, IDisposable where T : class, new(
|
||||
{
|
||||
return DbContext.Db.GetConnectionScopeWithAttr<T>().CopyNew();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -103,4 +103,46 @@ public static class DbContext
|
||||
Console.WriteLine("【Sql执行时间】:" + DateTime.Now.ToDefaultDateTimeFormat());
|
||||
Console.WriteLine("【Sql语句】:" + msg + Environment.NewLine);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static async Task BulkCopyAsync<TITEM>(this SqlSugarClient db, List<TITEM> datas, int size) where TITEM : class, new()
|
||||
{
|
||||
switch (db.CurrentConnectionConfig.DbType)
|
||||
{
|
||||
case DbType.MySql:
|
||||
case DbType.SqlServer:
|
||||
case DbType.Sqlite:
|
||||
case DbType.Oracle:
|
||||
case DbType.PostgreSQL:
|
||||
case DbType.Dm:
|
||||
case DbType.MySqlConnector:
|
||||
case DbType.Kdbndp:
|
||||
await db.Fastest<TITEM>().PageSize(size).BulkCopyAsync(datas).ConfigureAwait(false);
|
||||
break;
|
||||
default:
|
||||
await db.Insertable(datas).PageSize(size).ExecuteCommandAsync().ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
public static async Task BulkUpdateAsync<TITEM>(this SqlSugarClient db, List<TITEM> datas, int size) where TITEM : class, new()
|
||||
{
|
||||
switch (db.CurrentConnectionConfig.DbType)
|
||||
{
|
||||
case DbType.MySql:
|
||||
case DbType.SqlServer:
|
||||
case DbType.Sqlite:
|
||||
case DbType.Oracle:
|
||||
case DbType.PostgreSQL:
|
||||
case DbType.Dm:
|
||||
case DbType.MySqlConnector:
|
||||
case DbType.Kdbndp:
|
||||
await db.Fastest<TITEM>().PageSize(size).BulkUpdateAsync(datas).ConfigureAwait(false);
|
||||
break;
|
||||
default:
|
||||
await db.Updateable(datas).PageSize(size).ExecuteCommandAsync().ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.2" />
|
||||
<PackageReference Include="BootstrapBlazor.TableExport" Version="9.2.3" />
|
||||
<!--<PackageReference Include="MiniExcel" Version="1.39.0" />-->
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.188" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.189" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
|
||||
|
@@ -298,9 +298,9 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -106,7 +106,7 @@ public static class HttpContextExtensions
|
||||
/// <param name="context"></param>
|
||||
/// <param name="xff">是否优先取 X-Forwarded-For</param>
|
||||
/// <returns></returns>
|
||||
public static string GetRemoteIpAddressToIPv4(this HttpContext context, bool xff = false)
|
||||
public static string GetRemoteIpAddressToIPv4(this HttpContext context, bool xff = true)
|
||||
{
|
||||
var ipv4 = context.Connection.RemoteIpAddress?.MapToIPv4()?.ToString();
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="9.0.2" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.5.7" />
|
||||
<PackageReference Include="BootstrapBlazor" Version="9.5.8" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.4.20</PluginVersion>
|
||||
<ProPluginVersion>10.4.20</ProPluginVersion>
|
||||
<PluginVersion>10.5.1</PluginVersion>
|
||||
<ProPluginVersion>10.5.1</ProPluginVersion>
|
||||
<AuthenticationVersion>2.1.7</AuthenticationVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CS-Script" Version="4.8.27" />
|
||||
<PackageReference Include="CS-Script" Version="4.9.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -10,8 +10,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.4" />
|
||||
<PackageReference Include="TouchSocket" Version="3.0.25" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="3.0.25" />
|
||||
<PackageReference Include="TouchSocket" Version="3.0.26" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="3.0.26" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -13,6 +13,7 @@ using BootstrapBlazor.Components;
|
||||
using Mapster;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using SqlSugar;
|
||||
@@ -139,7 +140,7 @@ public class ControlController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
return await GlobalData.RpcService.InvokeDeviceMethodAsync($"WebApi-{UserManager.UserAccount}-{App.HttpContext.Connection.RemoteIpAddress.MapToIPv4()}", deviceDatas).ConfigureAwait(false);
|
||||
return await GlobalData.RpcService.InvokeDeviceMethodAsync($"WebApi-{UserManager.UserAccount}-{App.HttpContext?.GetRemoteIpAddressToIPv4()}", deviceDatas).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -56,7 +56,7 @@ public class Device : BaseDataEntity, IValidatableObject
|
||||
/// <summary>
|
||||
/// 通道
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "通道", Length = 200)]
|
||||
[SugarColumn(ColumnDescription = "通道")]
|
||||
[AutoGenerateColumn(Ignore = true)]
|
||||
[IgnoreExcel]
|
||||
[MinValue(1)]
|
||||
|
@@ -329,8 +329,8 @@ internal sealed class ChannelService : BaseService<Channel>, IChannelService
|
||||
ManageHelper.CheckChannelCount(insertData.Count);
|
||||
|
||||
using var db = GetDB();
|
||||
await db.Fastest<Channel>().PageSize(100000).BulkCopyAsync(insertData).ConfigureAwait(false);
|
||||
await db.Fastest<Channel>().PageSize(100000).BulkUpdateAsync(upData).ConfigureAwait(false);
|
||||
await db.BulkCopyAsync(insertData, 100000).ConfigureAwait(false);
|
||||
await db.BulkUpdateAsync(upData, 100000).ConfigureAwait(false);
|
||||
DeleteChannelFromCache();
|
||||
return channels.Select(a => a.Id).ToHashSet();
|
||||
}
|
||||
|
@@ -351,8 +351,8 @@ internal sealed class DeviceService : BaseService<Device>, IDeviceService
|
||||
ManageHelper.CheckDeviceCount(insertData.Count);
|
||||
|
||||
using var db = GetDB();
|
||||
await db.Fastest<Device>().PageSize(100000).BulkCopyAsync(insertData).ConfigureAwait(false);
|
||||
await db.Fastest<Device>().PageSize(100000).BulkUpdateAsync(upData).ConfigureAwait(false);
|
||||
await db.BulkCopyAsync(insertData, 100000).ConfigureAwait(false);
|
||||
await db.BulkUpdateAsync(upData, 100000).ConfigureAwait(false);
|
||||
DeleteDeviceFromCache();
|
||||
return devices.Select(a => a.Id).ToHashSet();
|
||||
}
|
||||
|
@@ -310,7 +310,6 @@ internal static class RuntimeServiceHelper
|
||||
}
|
||||
}
|
||||
|
||||
item.Value.Dispose();
|
||||
}
|
||||
if (group.Key != null)
|
||||
{
|
||||
@@ -321,6 +320,19 @@ internal static class RuntimeServiceHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void VariableRuntimesDispose(IEnumerable<long> variableIds)
|
||||
{
|
||||
|
||||
foreach (var variableId in variableIds)
|
||||
{
|
||||
|
||||
if (GlobalData.IdVariables.TryGetValue(variableId, out var variableRuntime))
|
||||
{
|
||||
variableRuntime.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void AddCollectChangedDriver(IEnumerable<VariableRuntime> newVariableRuntimes, ConcurrentHashSet<IDriver> changedDriver)
|
||||
|
@@ -43,10 +43,10 @@ public class VariableRuntimeService : IVariableRuntimeService
|
||||
//获取变量,先找到原插件线程,然后修改插件线程内的字典,再改动全局字典,最后刷新插件
|
||||
|
||||
ConcurrentHashSet<IDriver> changedDriver = new();
|
||||
|
||||
RuntimeServiceHelper.VariableRuntimesDispose(variableIds);
|
||||
RuntimeServiceHelper.AddCollectChangedDriver(newVariableRuntimes, changedDriver);
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
RuntimeServiceHelper.AddCollectChangedDriver(newVariableRuntimes, changedDriver);
|
||||
|
||||
if (restart)
|
||||
{
|
||||
@@ -79,9 +79,9 @@ public class VariableRuntimeService : IVariableRuntimeService
|
||||
|
||||
ConcurrentHashSet<IDriver> changedDriver = new();
|
||||
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
RuntimeServiceHelper.VariableRuntimesDispose(variableIds);
|
||||
RuntimeServiceHelper.AddCollectChangedDriver(newVariableRuntimes, changedDriver);
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
if (restart)
|
||||
{
|
||||
@@ -111,6 +111,7 @@ public class VariableRuntimeService : IVariableRuntimeService
|
||||
ConcurrentHashSet<IDriver> changedDriver = new();
|
||||
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
RuntimeServiceHelper.VariableRuntimesDispose(variableIds);
|
||||
|
||||
if (restart)
|
||||
{
|
||||
@@ -144,10 +145,9 @@ public class VariableRuntimeService : IVariableRuntimeService
|
||||
var variableIds = newVariableRuntimes.Select(a => a.Id).ToHashSet();
|
||||
|
||||
ConcurrentHashSet<IDriver> changedDriver = new();
|
||||
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
RuntimeServiceHelper.VariableRuntimesDispose(variableIds);
|
||||
RuntimeServiceHelper.AddCollectChangedDriver(newVariableRuntimes, changedDriver);
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
if (restart)
|
||||
{
|
||||
@@ -237,10 +237,9 @@ public class VariableRuntimeService : IVariableRuntimeService
|
||||
|
||||
ConcurrentHashSet<IDriver> changedDriver = new();
|
||||
|
||||
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
RuntimeServiceHelper.VariableRuntimesDispose(variableIds);
|
||||
RuntimeServiceHelper.AddCollectChangedDriver(newVariableRuntimes, changedDriver);
|
||||
RuntimeServiceHelper.AddBusinessChangedDriver(variableIds, changedDriver);
|
||||
|
||||
if (restart)
|
||||
{
|
||||
|
@@ -217,9 +217,9 @@ internal sealed class VariableService : BaseService<Variable>, IVariableService
|
||||
|
||||
var result = await db.UseTranAsync(async () =>
|
||||
{
|
||||
await db.Fastest<Channel>().PageSize(100000).BulkCopyAsync(newChannels).ConfigureAwait(false);
|
||||
await db.Fastest<Device>().PageSize(100000).BulkCopyAsync(newDevices).ConfigureAwait(false);
|
||||
await db.Fastest<Variable>().PageSize(100000).BulkCopyAsync(newVariables).ConfigureAwait(false);
|
||||
await db.BulkCopyAsync(newChannels, 100000).ConfigureAwait(false);
|
||||
await db.BulkCopyAsync(newDevices, 100000).ConfigureAwait(false);
|
||||
await db.BulkCopyAsync(newVariables, 100000).ConfigureAwait(false);
|
||||
}).ConfigureAwait(false);
|
||||
if (result.IsSuccess)//如果成功了
|
||||
{
|
||||
@@ -486,8 +486,8 @@ internal sealed class VariableService : BaseService<Variable>, IVariableService
|
||||
var insertData = variables.Where(a => !a.IsUp).ToList();
|
||||
ManageHelper.CheckVariableCount(insertData.Count);
|
||||
using var db = GetDB();
|
||||
await db.Fastest<Variable>().PageSize(100000).BulkCopyAsync(insertData).ConfigureAwait(false);
|
||||
await db.Fastest<Variable>().PageSize(100000).BulkUpdateAsync(upData).ConfigureAwait(false);
|
||||
await db.BulkCopyAsync(insertData, 100000).ConfigureAwait(false);
|
||||
await db.BulkUpdateAsync(upData, 100000).ConfigureAwait(false);
|
||||
_dispatchService.Dispatch(new());
|
||||
DeleteVariableCache();
|
||||
return variables.Select(a => a.Id).ToHashSet();
|
||||
|
@@ -9,8 +9,8 @@
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||
<PackageReference Include="SqlSugar.TDengineCore" Version="4.18.6" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.0" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.25" />
|
||||
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.0.25" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.26" />
|
||||
<PackageReference Include="TouchSocket.WebApi.Swagger" Version="3.0.26" />
|
||||
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
|
||||
|
||||
</ItemGroup>
|
||||
|
@@ -20,7 +20,7 @@
|
||||
<h4>
|
||||
<a id="user-content-演示" class="anchor" href="#%E6%BC%94%E7%A4%BA"></a>演示
|
||||
</h4>
|
||||
<p><a href="http://47.119.161.158:5000/">ThingsGateway演示地址</a></p>
|
||||
<p><a href="https://demo.thingsgateway.cn/">ThingsGateway演示地址</a></p>
|
||||
<p>账户 : <strong>SuperAdmin</strong></p>
|
||||
<p>密码 : <strong>111111</strong></p>
|
||||
<p><strong>右上角个人弹出框中,切换到物联网关模块</strong></p>
|
||||
|
@@ -35,6 +35,7 @@
|
||||
"BigTextScriptHistoryTable": "DynamicScriptHistoryTable",
|
||||
"BigTextScriptRealTable": "DynamicScriptRealTable",
|
||||
"RealTableBusinessInterval": "RealTableBusinessInterval",
|
||||
"SqlDBSplitType": "SplitType",
|
||||
|
||||
"BusinessUpdateEnum": "BusinessUpdateEnum",
|
||||
"BusinessInterval": "BusinessInterval",
|
||||
|
@@ -35,7 +35,7 @@
|
||||
"BigTextScriptHistoryTable": "历史表动态脚本",
|
||||
"BigTextScriptRealTable": "实时表动态脚本",
|
||||
"RealTableBusinessInterval": "实时表定时上传间隔",
|
||||
|
||||
"SqlDBSplitType": "分表模式",
|
||||
"BusinessUpdateEnum": "上传模式",
|
||||
"BusinessInterval": "定时上传间隔",
|
||||
"IsAllVariable": "选择全部变量",
|
||||
|
@@ -1,12 +0,0 @@
|
||||
|
||||
|
||||
namespace ThingsGateway.Plugin.SqlDB;
|
||||
|
||||
public enum DbType
|
||||
{
|
||||
MySql = 0,
|
||||
SqlServer = 1,
|
||||
Sqlite = 2,
|
||||
Oracle = 3,
|
||||
PostgreSQL = 4,
|
||||
}
|
@@ -14,7 +14,7 @@ using SqlSugar;
|
||||
|
||||
namespace ThingsGateway.Plugin.SqlDB;
|
||||
|
||||
[SplitTable(SplitType.Week)]//按周分表 (自带分表支持 年、季、月、周、日)
|
||||
[SplitTable(SplitType._Custom01)]//按周分表 (自带分表支持 年、季、月、周、日)
|
||||
[SugarTable("{name}_{year}{month}{day}", TableDescription = "设备采集历史表")]//3个变量必须要有
|
||||
[SugarIndex("index_Id", nameof(SQLHistoryValue.Id), OrderByType.Desc)]
|
||||
[SugarIndex("index_Name", nameof(SQLHistoryValue.Name), OrderByType.Desc)]
|
||||
|
@@ -8,6 +8,10 @@
|
||||
// QQ群:605534569
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using Mapster;
|
||||
|
||||
using Microsoft.Data.Sqlite;
|
||||
|
||||
using SqlSugar;
|
||||
|
||||
using System.Reflection;
|
||||
@@ -17,11 +21,11 @@ namespace ThingsGateway.Plugin.SqlDB;
|
||||
|
||||
public class SqlDBDateSplitTableService : DateSplitTableService
|
||||
{
|
||||
private SqlDBProducerProperty sqlDBProducerProperty;
|
||||
private SqlDBProducerProperty _sqlDBProducerProperty;
|
||||
|
||||
public SqlDBDateSplitTableService(SqlDBProducerProperty sqlDBProducerProperty)
|
||||
{
|
||||
this.sqlDBProducerProperty = sqlDBProducerProperty;
|
||||
this._sqlDBProducerProperty = sqlDBProducerProperty;
|
||||
}
|
||||
|
||||
#region Core
|
||||
@@ -29,7 +33,7 @@ public class SqlDBDateSplitTableService : DateSplitTableService
|
||||
public override List<SplitTableInfo> GetAllTables(ISqlSugarClient db, EntityInfo EntityInfo, List<DbTableInfo> tableInfos)
|
||||
{
|
||||
CheckTableName(EntityInfo.DbTableName);
|
||||
string regex = "^" + EntityInfo.DbTableName.Replace("{year}", "([0-9]{2,4})").Replace("{day}", "([0-9]{1,2})").Replace("{month}", "([0-9]{1,2})").Replace("{name}", sqlDBProducerProperty.HistoryDBTableName);
|
||||
string regex = "^" + EntityInfo.DbTableName.Replace("{year}", "([0-9]{2,4})").Replace("{day}", "([0-9]{1,2})").Replace("{month}", "([0-9]{1,2})").Replace("{name}", _sqlDBProducerProperty.HistoryDBTableName);
|
||||
List<string> list = (from it in tableInfos
|
||||
where Regex.IsMatch(it.Name, regex, RegexOptions.IgnoreCase)
|
||||
select it.Name).Reverse().ToList();
|
||||
@@ -51,16 +55,9 @@ public class SqlDBDateSplitTableService : DateSplitTableService
|
||||
|
||||
public override string GetTableName(ISqlSugarClient db, EntityInfo EntityInfo)
|
||||
{
|
||||
var splitTableAttribute = EntityInfo.Type.GetCustomAttribute<SplitTableAttribute>();
|
||||
if (splitTableAttribute != null)
|
||||
{
|
||||
var type = splitTableAttribute.SplitType;
|
||||
return GetTableName(db, EntityInfo, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetTableName(db, EntityInfo, SplitType.Day);
|
||||
}
|
||||
var type = (SplitType)_sqlDBProducerProperty.SqlDBSplitType;
|
||||
return GetTableName(db, EntityInfo, type);
|
||||
|
||||
}
|
||||
|
||||
public override string GetTableName(ISqlSugarClient db, EntityInfo EntityInfo, SplitType splitType)
|
||||
@@ -154,8 +151,9 @@ public class SqlDBDateSplitTableService : DateSplitTableService
|
||||
|
||||
private string GetTableNameByDate(EntityInfo EntityInfo, SplitType splitType, DateTime date)
|
||||
{
|
||||
date = ConvertDateBySplitType(date, splitType);
|
||||
return EntityInfo.DbTableName.Replace("{year}", date.Year + "").Replace("{day}", SqlDBDateSplitTableService.PadLeft2(date.Day + "")).Replace("{month}", SqlDBDateSplitTableService.PadLeft2(date.Month + "")).Replace("{name}", sqlDBProducerProperty.HistoryDBTableName);
|
||||
var type = (SplitType)_sqlDBProducerProperty.SqlDBSplitType;
|
||||
date = ConvertDateBySplitType(date, type);
|
||||
return EntityInfo.DbTableName.Replace("{year}", date.Year + "").Replace("{day}", SqlDBDateSplitTableService.PadLeft2(date.Day + "")).Replace("{month}", SqlDBDateSplitTableService.PadLeft2(date.Month + "")).Replace("{name}", _sqlDBProducerProperty.HistoryDBTableName);
|
||||
}
|
||||
|
||||
private static string PadLeft2(string str)
|
||||
|
@@ -13,7 +13,23 @@ using BootstrapBlazor.Components;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ThingsGateway.Plugin.SqlDB;
|
||||
|
||||
public enum DbType
|
||||
{
|
||||
MySql = 0,
|
||||
SqlServer = 1,
|
||||
Sqlite = 2,
|
||||
Oracle = 3,
|
||||
PostgreSQL = 4,
|
||||
}
|
||||
public enum SqlDBSplitType
|
||||
{
|
||||
Day = 0,
|
||||
Week = 1,
|
||||
Month = 2,
|
||||
Month_6 = 1000,
|
||||
Season = 3,
|
||||
Year = 4,
|
||||
}
|
||||
/// <summary>
|
||||
/// SqlDBProducerProperty
|
||||
/// </summary>
|
||||
@@ -34,6 +50,9 @@ public class SqlDBProducerProperty : BusinessPropertyWithCacheInterval
|
||||
[DynamicProperty]
|
||||
public DbType DbType { get; set; } = DbType.SqlServer;
|
||||
|
||||
[DynamicProperty]
|
||||
public SqlDBSplitType SqlDBSplitType { get; set; } = SqlDBSplitType.Week;
|
||||
|
||||
[DynamicProperty]
|
||||
[Required]
|
||||
[AutoGenerateColumn(ComponentType = typeof(Textarea), Rows = 1)]
|
||||
|
@@ -9,7 +9,7 @@
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Razor\ThingsGateway.Gateway.Razor.csproj">
|
||||
</ProjectReference>
|
||||
<PackageReference Include="Confluent.Kafka" Version="2.9.0" GeneratePathProperty="true">
|
||||
<PackageReference Include="Confluent.Kafka" Version="2.10.0" GeneratePathProperty="true">
|
||||
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
@@ -280,9 +280,9 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -6,7 +6,7 @@
|
||||
"Startway": "", // 启动方式:DOTNET: (直接启动) ;WindowsService:(windows服务) PM2, Systemctl等不需要配置。对应文件夹下的命令文件
|
||||
|
||||
"AppSettings": {
|
||||
"InjectSpecificationDocument": false, // 生产环境是否开启Swagger
|
||||
"InjectSpecificationDocument": true, // 生产环境是否开启Swagger
|
||||
"ExternalAssemblies": [ "Plugins" ], // 插件目录
|
||||
|
||||
// nuget动态加载的程序集
|
||||
|
@@ -298,9 +298,10 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -7,7 +7,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
"applicationUrl": "http://*:5000"
|
||||
},
|
||||
"demo": {
|
||||
"commandName": "Project",
|
||||
@@ -16,7 +16,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Demo"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
"applicationUrl": "http://*:5000"
|
||||
},
|
||||
|
||||
"IIS Express": {
|
||||
@@ -32,7 +32,7 @@
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:59494/",
|
||||
"applicationUrl": "http://*:59494/",
|
||||
"sslPort": 44372
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"urls": "http://*:5000",
|
||||
|
||||
"ConfigurationScanDirectories": [ "Configuration", "" ], // 扫描配置文件json文件夹(自动合并该文件夹里面所有json文件)
|
||||
"IgnoreConfigurationFiles": [ "" ],
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.25" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.26" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
@@ -304,9 +304,9 @@ public class Startup : AppStartup
|
||||
public void Use(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||
{
|
||||
var app = (WebApplication)applicationBuilder;
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All, KnownNetworks = { }, KnownProxies = { } });
|
||||
app.UseBootstrapBlazor();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });
|
||||
|
||||
// 启用本地化
|
||||
var option = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>10.4.20</Version>
|
||||
<Version>10.5.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user