Compare commits

...

7 Commits

Author SHA1 Message Date
Diego
58f8b23b7c build:10.5.1
fix: 反向代理正确获取客户端IP

refactor: 添加demo站点域名
2025-04-22 11:45:14 +08:00
Diego
9e7c348b15 添加大数据写入方法 2025-04-21 23:05:10 +08:00
Diego
5f5ff8b43b 删除实体部分特性 2025-04-21 17:53:33 +08:00
Diego
f626b4e5fc sql插件增加分表模式 属性 2025-04-21 11:00:05 +08:00
2248356998 qq.com
bc23200e66 更新依赖 2025-04-20 20:32:41 +08:00
Diego
95ab59fd5a build: 10.4.21 2025-04-18 11:27:48 +08:00
Diego
0bbee003b0 app.json 2025-04-18 09:21:31 +08:00
45 changed files with 158 additions and 95 deletions

View File

@@ -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**

View File

@@ -13,7 +13,7 @@
## 演示
[ThingsGateway演示地址](http://47.119.161.158:5000/)
[ThingsGateway演示地址](https://demo.thingsgateway.cn/)
账户 : **SuperAdmin**

View File

@@ -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,

View File

@@ -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; }

View File

@@ -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; }

View File

@@ -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; }

View File

@@ -22,7 +22,7 @@ public class SysRelation : PrimaryKeyEntity
/// <summary>
/// 分类
///</summary>
[SugarColumn(ColumnDescription = "分类", Length = 200)]
[SugarColumn(ColumnDescription = "分类")]
public RelationCategoryEnum Category { get; set; }
/// <summary>

View File

@@ -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; }

View File

@@ -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;
}

View File

@@ -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)
{

View File

@@ -31,7 +31,7 @@ public interface IAppService
/// <summary>
/// RemoteIpAddress
/// </summary>
public IPAddress? RemoteIpAddress { get; }
public string? RemoteIpAddress { get; }
/// <summary>
/// GetReturnUrl

View File

@@ -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,

View File

@@ -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();
}
}

View File

@@ -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;
}
}
}

View File

@@ -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" />

View File

@@ -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>>();

View File

@@ -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();

View File

@@ -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>

View File

@@ -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>

View File

@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CS-Script" Version="4.8.27" />
<PackageReference Include="CS-Script" Version="4.9.5" />
</ItemGroup>
<ItemGroup>

View File

@@ -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>

View File

@@ -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);
}

View File

@@ -56,7 +56,7 @@ public class Device : BaseDataEntity, IValidatableObject
/// <summary>
/// 通道
/// </summary>
[SugarColumn(ColumnDescription = "通道", Length = 200)]
[SugarColumn(ColumnDescription = "通道")]
[AutoGenerateColumn(Ignore = true)]
[IgnoreExcel]
[MinValue(1)]

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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>

View File

@@ -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>

View File

@@ -35,6 +35,7 @@
"BigTextScriptHistoryTable": "DynamicScriptHistoryTable",
"BigTextScriptRealTable": "DynamicScriptRealTable",
"RealTableBusinessInterval": "RealTableBusinessInterval",
"SqlDBSplitType": "SplitType",
"BusinessUpdateEnum": "BusinessUpdateEnum",
"BusinessInterval": "BusinessInterval",

View File

@@ -35,7 +35,7 @@
"BigTextScriptHistoryTable": "历史表动态脚本",
"BigTextScriptRealTable": "实时表动态脚本",
"RealTableBusinessInterval": "实时表定时上传间隔",
"SqlDBSplitType": "分表模式",
"BusinessUpdateEnum": "上传模式",
"BusinessInterval": "定时上传间隔",
"IsAllVariable": "选择全部变量",

View File

@@ -1,12 +0,0 @@

namespace ThingsGateway.Plugin.SqlDB;
public enum DbType
{
MySql = 0,
SqlServer = 1,
Sqlite = 2,
Oracle = 3,
PostgreSQL = 4,
}

View File

@@ -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)]

View File

@@ -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)

View File

@@ -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)]

View File

@@ -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>

View File

@@ -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>>();

View File

@@ -6,7 +6,7 @@
"Startway": "", // 启动方式DOTNET (直接启动) WindowsServicewindows服务 PM2, Systemctl等不需要配置。对应文件夹下的命令文件
"AppSettings": {
"InjectSpecificationDocument": false, // 生产环境是否开启Swagger
"InjectSpecificationDocument": true, // 生产环境是否开启Swagger
"ExternalAssemblies": [ "Plugins" ], // 插件目录
// nuget动态加载的程序集

View File

@@ -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>>();

View File

@@ -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
}
}

View File

@@ -1,5 +1,4 @@
{
"urls": "http://*:5000",
"ConfigurationScanDirectories": [ "Configuration", "" ], // 扫描配置文件json文件夹自动合并该文件夹里面所有json文件
"IgnoreConfigurationFiles": [ "" ],

View File

@@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.25" />
<PackageReference Include="TouchSocket.Dmtp" Version="3.0.26" />
</ItemGroup>

View File

@@ -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>>();

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>10.4.20</Version>
<Version>10.5.1</Version>
</PropertyGroup>
<ItemGroup>