blazor组件初始化并行执行,导致sugar单例DB出现线程偶发错误,暂增加copyNew()解决
This commit is contained in:
@@ -15,7 +15,7 @@ using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace ThingsGateway.Application.Services.Auth
|
||||
namespace ThingsGateway.Application.Services
|
||||
{
|
||||
/// <inheritdoc cref="IAuthService"/>
|
||||
public class AuthService : IAuthService
|
||||
|
@@ -89,7 +89,7 @@ namespace ThingsGateway.Application
|
||||
if (sysResources == null)
|
||||
{
|
||||
//cache没有就去数据库拿
|
||||
sysResources = await CopyNew().GetListAsync(it => it.Category == category);
|
||||
sysResources = await base.GetListAsync(it => it.Category == category);
|
||||
if (sysResources.Count > 0)
|
||||
{
|
||||
//插入Cache
|
||||
|
@@ -22,7 +22,7 @@ namespace ThingsGateway.Core
|
||||
|
||||
public DbRepository(ISqlSugarClient context = null) : base(context)//注意这里要有默认值等于null
|
||||
{
|
||||
Context = DbContext.Db.GetConnectionScopeWithAttr<T>();//ioc注入的对象
|
||||
Context = DbContext.Db.GetConnectionScopeWithAttr<T>().CopyNew();//ioc注入的对象
|
||||
itenant = DbContext.Db;
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
//"Sqlsugar": [
|
||||
// {
|
||||
// "ConfigId": "Default", //租户ID
|
||||
// "ConnectionString": "server=localhost;Database=test;Uid=root;Pwd=111111;", //连接字符串
|
||||
// "ConnectionString": "server=localhost;Database=test1;Uid=root;Pwd=111111;", //连接字符串
|
||||
// "DbType": "MySql", //数据库类型
|
||||
// "IsAutoCloseConnection": true, //是否自动释放
|
||||
// "IsInitDb": true, //是否初始化数据库,适用于codefirst
|
||||
@@ -15,7 +15,7 @@
|
||||
// },
|
||||
// {
|
||||
// "ConfigId": "ThingsGateway", //租户ID
|
||||
// "ConnectionString": "server=localhost;Database=test123;Uid=root;Pwd=111111;", //连接字符串
|
||||
// "ConnectionString": "server=localhost;Database=test122223;Uid=root;Pwd=111111;", //连接字符串
|
||||
// "DbType": "MySql", //数据库类型
|
||||
// "IsAutoCloseConnection": true, //是否自动释放
|
||||
// "IsInitDb": true, //是否初始化数据库,适用于codefirst
|
||||
|
@@ -38,12 +38,36 @@ public enum ShareChannelEnum
|
||||
/// </summary>
|
||||
TGUdpSession
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 共享通道
|
||||
/// </summary>
|
||||
public enum RedundantEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 不支持冗余
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 主站
|
||||
/// </summary>
|
||||
Primary,
|
||||
/// <summary>
|
||||
/// 备用
|
||||
/// </summary>
|
||||
Standby,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="DriverPropertyBase"/><br></br>
|
||||
/// 1.5.0版本适配共享通道,支持自定义TCP/UDP/Serial共享<see cref="TGTcpClient"/>,<see cref="TGUdpSession"/>,<see cref="SerialClient"/>
|
||||
/// </summary>
|
||||
public abstract class CollectDriverPropertyBase : DriverPropertyBase
|
||||
{
|
||||
|
||||
|
||||
#region 共享通道配置
|
||||
/// <summary>
|
||||
/// 是否支持共享通道
|
||||
/// </summary>
|
||||
@@ -54,6 +78,10 @@ public abstract class CollectDriverPropertyBase : DriverPropertyBase
|
||||
/// </summary>
|
||||
public abstract ShareChannelEnum ShareChannel { get; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region Socket
|
||||
/// <summary>
|
||||
/// IP地址
|
||||
@@ -89,6 +117,8 @@ public abstract class CollectDriverPropertyBase : DriverPropertyBase
|
||||
public virtual StopBits StopBits { get; set; } = StopBits.One;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
@@ -26,10 +26,6 @@ namespace ThingsGateway.Web.Page
|
||||
[Inject]
|
||||
ResourceService ResourceService { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
DriverPlugins = DriverPluginService.GetDriverPluginChildrenList(DriverEnum.Collect);
|
||||
|
@@ -26,10 +26,6 @@ namespace ThingsGateway.Web.Page
|
||||
[Inject]
|
||||
ResourceService ResourceService { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
[Inject]
|
||||
IUploadDeviceService UploadDeviceService { get; set; }
|
||||
protected override async Task OnParametersSetAsync()
|
||||
|
@@ -22,16 +22,8 @@ namespace ThingsGateway.Web.Page
|
||||
[Inject]
|
||||
ResourceService ResourceService { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
[Inject]
|
||||
IUploadDeviceService UploadDeviceService { get; set; }
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -192,6 +192,7 @@
|
||||
List<ThingsGateway.Web.Foundation.RuntimeLog> RuntimeLogs;
|
||||
[Inject]
|
||||
private IOperateLogService OperateLogService { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (UserManager.SuperAdmin)
|
||||
@@ -202,6 +203,7 @@
|
||||
|
||||
DevLogVisits = (await VisitLogService.Page(new() { Size = 5, Account = UserResoures.CurrentUser?.Account })).Records.ToList();
|
||||
DevLogOps = (await OperateLogService.Page(new() { Size = 5, Account = UserResoures.CurrentUser?.Account })).Records.ToList();
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
@@ -25,10 +25,6 @@ namespace ThingsGateway.Web.Page
|
||||
[Inject]
|
||||
ResourceService ResourceService { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
DriverPlugins = DriverPluginService.GetDriverPluginChildrenList(DriverEnum.Upload);
|
||||
|
@@ -26,7 +26,6 @@ namespace ThingsGateway.Web.Rcl
|
||||
[Inject]
|
||||
private UserResoures UserResoures { get; set; }
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await UserResoures.InitAllAsync();
|
||||
|
Reference in New Issue
Block a user