diff --git a/docs/screenshot/2023-10-26_172812.png b/docs/screenshot/2023-10-26_172812.png deleted file mode 100644 index 9faab2e0..00000000 Binary files a/docs/screenshot/2023-10-26_172812.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_172955.png b/docs/screenshot/2023-10-26_172955.png deleted file mode 100644 index cc5eafc8..00000000 Binary files a/docs/screenshot/2023-10-26_172955.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_174707.png b/docs/screenshot/2023-10-26_174707.png deleted file mode 100644 index 52977aef..00000000 Binary files a/docs/screenshot/2023-10-26_174707.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_174949.png b/docs/screenshot/2023-10-26_174949.png deleted file mode 100644 index 5c0fad31..00000000 Binary files a/docs/screenshot/2023-10-26_174949.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175308.png b/docs/screenshot/2023-10-26_175308.png deleted file mode 100644 index 7a40d25f..00000000 Binary files a/docs/screenshot/2023-10-26_175308.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175352.png b/docs/screenshot/2023-10-26_175352.png deleted file mode 100644 index 41bb82b8..00000000 Binary files a/docs/screenshot/2023-10-26_175352.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175407.png b/docs/screenshot/2023-10-26_175407.png deleted file mode 100644 index b9749d2c..00000000 Binary files a/docs/screenshot/2023-10-26_175407.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175419.png b/docs/screenshot/2023-10-26_175419.png deleted file mode 100644 index c9d0bd17..00000000 Binary files a/docs/screenshot/2023-10-26_175419.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175430.png b/docs/screenshot/2023-10-26_175430.png deleted file mode 100644 index 96189189..00000000 Binary files a/docs/screenshot/2023-10-26_175430.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175441.png b/docs/screenshot/2023-10-26_175441.png deleted file mode 100644 index 1a24a31e..00000000 Binary files a/docs/screenshot/2023-10-26_175441.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175447.png b/docs/screenshot/2023-10-26_175447.png deleted file mode 100644 index c44feb0b..00000000 Binary files a/docs/screenshot/2023-10-26_175447.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175501.png b/docs/screenshot/2023-10-26_175501.png deleted file mode 100644 index cdd83f9c..00000000 Binary files a/docs/screenshot/2023-10-26_175501.png and /dev/null differ diff --git a/docs/screenshot/2023-10-26_175922.png b/docs/screenshot/2023-10-26_175922.png deleted file mode 100644 index bd4e7604..00000000 Binary files a/docs/screenshot/2023-10-26_175922.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_172812.png b/docs/screenshot/thumb/2023-10-26_172812.png deleted file mode 100644 index 05fcace6..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_172812.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_172955.png b/docs/screenshot/thumb/2023-10-26_172955.png deleted file mode 100644 index 3a345a77..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_172955.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_174707.png b/docs/screenshot/thumb/2023-10-26_174707.png deleted file mode 100644 index b96c238e..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_174707.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_174949.png b/docs/screenshot/thumb/2023-10-26_174949.png deleted file mode 100644 index 6d5684df..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_174949.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175308.png b/docs/screenshot/thumb/2023-10-26_175308.png deleted file mode 100644 index f5720229..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175308.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175352.png b/docs/screenshot/thumb/2023-10-26_175352.png deleted file mode 100644 index 6f8af702..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175352.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175407.png b/docs/screenshot/thumb/2023-10-26_175407.png deleted file mode 100644 index 8e6d62c3..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175407.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175419.png b/docs/screenshot/thumb/2023-10-26_175419.png deleted file mode 100644 index d626f980..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175419.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175430.png b/docs/screenshot/thumb/2023-10-26_175430.png deleted file mode 100644 index e7f63105..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175430.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175441.png b/docs/screenshot/thumb/2023-10-26_175441.png deleted file mode 100644 index b775c8a5..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175441.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175447.png b/docs/screenshot/thumb/2023-10-26_175447.png deleted file mode 100644 index 1a7eadbe..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175447.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175501.png b/docs/screenshot/thumb/2023-10-26_175501.png deleted file mode 100644 index e1acc7d7..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175501.png and /dev/null differ diff --git a/docs/screenshot/thumb/2023-10-26_175922.png b/docs/screenshot/thumb/2023-10-26_175922.png deleted file mode 100644 index 2efb2601..00000000 Binary files a/docs/screenshot/thumb/2023-10-26_175922.png and /dev/null differ diff --git a/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs b/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs index cea6ea9c..686fccdc 100644 --- a/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs +++ b/src/backend/NetAdmin/NetAdmin.Application/Services/RepositoryService.cs @@ -50,11 +50,7 @@ public abstract class RepositoryService(BasicReposit Func, ISelect> selector, QueryReq query, string fileName, Expression> listExp = null) where TQuery : DataAbstraction, new() { - var select = selector(query) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(Numbers.MAX_LIMIT_EXPORT); + var select = selector(query).WithNoLockNoWait().Take(Numbers.MAX_LIMIT_EXPORT); object list = listExp == null ? await select.ToListAsync().ConfigureAwait(false) : await select.ToListAsync(listExp).ConfigureAwait(false); @@ -100,8 +96,8 @@ public abstract class RepositoryService(BasicReposit TEntity newValue // , IEnumerable includeFields // , string[] excludeFields = null // - , Expression> whereExp = null // - , string whereSql = null // + , Expression> whereExp = null // + , string whereSql = null // , bool ignoreVersion = false) { // 默认匹配主键 diff --git a/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs b/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs index bf23ecea..40f7cd78 100644 --- a/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs +++ b/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs @@ -28,11 +28,7 @@ public sealed class ExampleService(BasicRepository rpo) // public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -54,11 +50,7 @@ public sealed class ExampleService(BasicRepository rpo) // public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -80,14 +72,7 @@ public sealed class ExampleService(BasicRepository rpo) // public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -96,13 +81,7 @@ public sealed class ExampleService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_LoginLog.cs b/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_LoginLog.cs index 13b824cb..29b2b499 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_LoginLog.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_LoginLog.cs @@ -28,11 +28,7 @@ public record Sys_LoginLog : SimpleEntity, IFieldCreatedTime, IFieldOwner, IFiel /// /// 创建者客户端用户代理 /// - #if DBTYPE_SQLSERVER [Column(Position = -1, DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_1022)] - #else - [Column(Position = -1, DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)] - #endif [CsvIgnore] [JsonIgnore] public virtual string CreatedUserAgent { get; init; } diff --git a/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_RequestLogDetail.cs b/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_RequestLogDetail.cs index 2a155f71..0c7ef809 100644 --- a/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_RequestLogDetail.cs +++ b/src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_RequestLogDetail.cs @@ -18,11 +18,7 @@ public record Sys_RequestLogDetail : SimpleEntity, IFieldCreatedTime, IFieldCrea /// /// 创建者客户端用户代理 /// - #if DBTYPE_SQLSERVER [Column(Position = -1, DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_1022)] - #else - [Column(Position = -1, DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)] - #endif [CsvIgnore] [JsonIgnore] public virtual string CreatedUserAgent { get; init; } diff --git a/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/ISelectExtensions.cs b/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/ISelectExtensions.cs new file mode 100644 index 00000000..e648a120 --- /dev/null +++ b/src/backend/NetAdmin/NetAdmin.Infrastructure/Extensions/ISelectExtensions.cs @@ -0,0 +1,94 @@ +namespace NetAdmin.Infrastructure.Extensions; + +/// +/// ISelect 扩展方法 +/// +public static class ISelectExtensions +{ + /// + /// 无锁无等待 + /// + public static ISelect WithNoLockNoWait(this ISelect me) + { + return me + #if DBTYPE_SQLSERVER + .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) + #endif + ; + } + + /// + /// 无锁无等待 + /// + public static ISelect WithNoLockNoWait(this ISelect me) + where T2 : class + { + return me + #if DBTYPE_SQLSERVER + .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) + #endif + ; + } + + /// + /// 无锁无等待 + /// + public static ISelect WithNoLockNoWait(this ISelect me) + where T2 : class // + where T3 : class + { + return me + #if DBTYPE_SQLSERVER + .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) + #endif + ; + } + + /// + /// 无锁无等待 + /// + public static ISelect WithNoLockNoWait(this ISelect me) + where T2 : class // + where T3 : class // + where T4 : class + { + return me + #if DBTYPE_SQLSERVER + .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) + #endif + ; + } + + /// + /// 无锁无等待 + /// + public static ISelect WithNoLockNoWait(this ISelect me) + where T2 : class // + where T3 : class // + where T4 : class // + where T5 : class + { + return me + #if DBTYPE_SQLSERVER + .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) + #endif + ; + } + + /// + /// 无锁无等待 + /// + public static ISelect WithNoLockNoWait(this ISelect me) + where T2 : class // + where T3 : class // + where T4 : class // + where T5 : class // + where T6 : class + { + return me + #if DBTYPE_SQLSERVER + .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) + #endif + ; + } +} \ No newline at end of file diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs index 25155827..b957c6f1 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ApiService.cs @@ -21,11 +21,7 @@ public sealed class ApiService( public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -46,11 +42,7 @@ public sealed class ApiService( public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs index 32042cb4..1732260b 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/ConfigService.cs @@ -25,11 +25,7 @@ public sealed class ConfigService(BasicRepository rpo) // public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -64,11 +60,7 @@ public sealed class ConfigService(BasicRepository rpo) // public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -97,14 +89,7 @@ public sealed class ConfigService(BasicRepository rpo) // public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -113,13 +98,7 @@ public sealed class ConfigService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DeptService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DeptService.cs index a385056e..d1300533 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DeptService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DeptService.cs @@ -25,11 +25,7 @@ public sealed class DeptService(BasicRepository rpo) // public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -80,11 +76,7 @@ public sealed class DeptService(BasicRepository rpo) // public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -113,12 +105,7 @@ public sealed class DeptService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - return (await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .ToTreeListAsync() - .ConfigureAwait(false)).Adapt>(); + return (await QueryInternal(req).WithNoLockNoWait().ToTreeListAsync().ConfigureAwait(false)).Adapt>(); } /// diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs index 61312e0e..41214dea 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicCatalogService.cs @@ -25,11 +25,7 @@ public sealed class DicCatalogService(BasicRepository rpo) public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -37,12 +33,7 @@ public sealed class DicCatalogService(BasicRepository rpo) public async Task CreateAsync(CreateDicCatalogReq req) { req.ThrowIfInvalid(); - if (req.ParentId != 0 && !await Rpo.Where(a => a.Id == req.ParentId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false)) { + if (req.ParentId != 0 && !await Rpo.Where(a => a.Id == req.ParentId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false)) { throw new NetAdminInvalidOperationException(Ln.父节点不存在); } @@ -63,12 +54,7 @@ public sealed class DicCatalogService(BasicRepository rpo) public async Task EditAsync(EditDicCatalogReq req) { req.ThrowIfInvalid(); - return req.ParentId == 0 || await Rpo.Where(a => a.Id == req.ParentId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false) + return req.ParentId == 0 || await Rpo.Where(a => a.Id == req.ParentId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false) ? await UpdateAsync(req, null).ConfigureAwait(false) : throw new NetAdminInvalidOperationException(Ln.父节点不存在); } @@ -77,11 +63,7 @@ public sealed class DicCatalogService(BasicRepository rpo) public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -103,14 +85,7 @@ public sealed class DicCatalogService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -119,12 +94,7 @@ public sealed class DicCatalogService(BasicRepository rpo) public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .ToTreeListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().ToTreeListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs index 8a89710e..07ea33e8 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DicContentService.cs @@ -25,11 +25,7 @@ public sealed class DicContentService(BasicRepository rpo) public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -37,13 +33,7 @@ public sealed class DicContentService(BasicRepository rpo) public async Task CreateAsync(CreateDicContentReq req) { req.ThrowIfInvalid(); - if (!await Rpo.Orm.Select() - .Where(a => a.Id == req.CatalogId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false)) { + if (!await Rpo.Orm.Select().Where(a => a.Id == req.CatalogId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false)) { throw new NetAdminInvalidOperationException(Ln.字典目录不存在); } @@ -63,13 +53,7 @@ public sealed class DicContentService(BasicRepository rpo) public async Task EditAsync(EditDicContentReq req) { req.ThrowIfInvalid(); - if (!await Rpo.Orm.Select() - .Where(a => a.Id == req.CatalogId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false)) { + if (!await Rpo.Orm.Select().Where(a => a.Id == req.CatalogId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false)) { throw new NetAdminInvalidOperationException(Ln.字典目录不存在); } @@ -86,11 +70,7 @@ public sealed class DicContentService(BasicRepository rpo) public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -112,14 +92,7 @@ public sealed class DicContentService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -128,13 +101,7 @@ public sealed class DicContentService(BasicRepository rpo) public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } @@ -142,9 +109,7 @@ public sealed class DicContentService(BasicRepository rpo) public async Task> QueryByCatalogCodeAsync(string catalogCode) { var ret = await Rpo.Orm.Select() - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Include(a => a.Catalog) .Where(a => a.Catalog.Code == catalogCode) .Where(a => a.Enabled) diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs index 7384a44e..c1699252 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocCatalogService.cs @@ -25,11 +25,7 @@ public sealed class DocCatalogService(BasicRepository rpo) public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -37,12 +33,7 @@ public sealed class DocCatalogService(BasicRepository rpo) public async Task CreateAsync(CreateDocCatalogReq req) { req.ThrowIfInvalid(); - if (req.ParentId != 0 && !await Rpo.Where(a => a.Id == req.ParentId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false)) { + if (req.ParentId != 0 && !await Rpo.Where(a => a.Id == req.ParentId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false)) { throw new NetAdminInvalidOperationException(Ln.父节点不存在); } @@ -63,12 +54,7 @@ public sealed class DocCatalogService(BasicRepository rpo) public async Task EditAsync(EditDocCatalogReq req) { req.ThrowIfInvalid(); - return req.ParentId == 0 || await Rpo.Where(a => a.Id == req.ParentId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false) + return req.ParentId == 0 || await Rpo.Where(a => a.Id == req.ParentId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false) ? await UpdateAsync(req, null).ConfigureAwait(false) : throw new NetAdminInvalidOperationException(Ln.父节点不存在); } @@ -77,11 +63,7 @@ public sealed class DocCatalogService(BasicRepository rpo) public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -103,14 +85,7 @@ public sealed class DocCatalogService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -119,12 +94,7 @@ public sealed class DocCatalogService(BasicRepository rpo) public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .ToTreeListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().ToTreeListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs index c5a37c9c..44043b94 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/DocContentService.cs @@ -1,7 +1,9 @@ -using NetAdmin.Domain.DbMaps.Dependency.Fields; using NetAdmin.Domain.DbMaps.Sys; using NetAdmin.Domain.Dto.Sys.Doc.Content; using NetAdmin.Domain.Enums.Sys; +#if !DBTYPE_SQLSERVER +using NetAdmin.Domain.DbMaps.Dependency.Fields; +#endif namespace NetAdmin.SysComponent.Application.Services.Sys; @@ -27,11 +29,7 @@ public sealed class DocContentService(BasicRepository rpo) public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -39,13 +37,7 @@ public sealed class DocContentService(BasicRepository rpo) public async Task CreateAsync(CreateDocContentReq req) { req.ThrowIfInvalid(); - if (!await Rpo.Orm.Select() - .Where(a => a.Id == req.CatalogId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false)) { + if (!await Rpo.Orm.Select().Where(a => a.Id == req.CatalogId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false)) { throw new NetAdminInvalidOperationException(Ln.文档分类不存在); } @@ -65,13 +57,7 @@ public sealed class DocContentService(BasicRepository rpo) public async Task EditAsync(EditDocContentReq req) { req.ThrowIfInvalid(); - if (!await Rpo.Orm.Select() - .Where(a => a.Id == req.CatalogId) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync() - .ConfigureAwait(false)) { + if (!await Rpo.Orm.Select().Where(a => a.Id == req.CatalogId).WithNoLockNoWait().AnyAsync().ConfigureAwait(false)) { throw new NetAdminInvalidOperationException(Ln.文档分类不存在); } @@ -88,11 +74,7 @@ public sealed class DocContentService(BasicRepository rpo) public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -114,14 +96,7 @@ public sealed class DocContentService(BasicRepository rpo) public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -130,13 +105,7 @@ public sealed class DocContentService(BasicRepository rpo) public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs index e6c91f0d..e1f0b0ee 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobRecordService.cs @@ -26,11 +26,7 @@ public sealed class JobRecordService(BasicRepository rpo) / public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -52,11 +48,7 @@ public sealed class JobRecordService(BasicRepository rpo) / public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -80,9 +72,7 @@ public sealed class JobRecordService(BasicRepository rpo) / req.ThrowIfInvalid(); var ret = await QueryInternal(req with { Order = Orders.None }) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .GroupBy(a => new { a.CreatedTime.Year, a.CreatedTime.Month, a.CreatedTime.Day, a.CreatedTime.Hour }) .ToListAsync(a => new GetBarChartRsp { Timestamp = new DateTime(a.Key.Year, a.Key.Month, a.Key.Day, a.Key.Hour, 0, 0 @@ -98,9 +88,7 @@ public sealed class JobRecordService(BasicRepository rpo) / { req.ThrowIfInvalid(); var ret = await QueryInternal(req with { Order = Orders.None }) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Include(a => a.Job) .GroupBy(a => a.HttpStatusCode) #pragma warning disable CA1305 @@ -115,9 +103,7 @@ public sealed class JobRecordService(BasicRepository rpo) / { req.ThrowIfInvalid(); var ret = await QueryInternal(req with { Order = Orders.None }) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Include(a => a.Job) .GroupBy(a => a.Job.JobName) .ToListAsync(a => new GetPieChartRsp { Value = a.Count(), Key = a.Key }) @@ -129,14 +115,7 @@ public sealed class JobRecordService(BasicRepository rpo) / public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -145,13 +124,7 @@ public sealed class JobRecordService(BasicRepository rpo) / public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs index b1f8b4ad..0e1a8d5c 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/JobService.cs @@ -30,11 +30,7 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -129,11 +125,7 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -192,9 +184,7 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer ] }; var job = await QueryInternal(new QueryReq { DynamicFilter = df, Order = Orders.Random }, false) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Where(a => !Rpo.Orm.Select().As("b").Where(b => b.JobId == a.Id && b.TimeId == a.NextTimeId).Any()) .ToOneAsync(a => new { a.RequestUrl @@ -262,14 +252,7 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -285,13 +268,7 @@ public sealed class JobService(BasicRepository rpo, IJobRecordSer public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs index 7f0b9da5..2cd000b4 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/LoginLogService.cs @@ -25,11 +25,7 @@ public sealed class LoginLogService(BasicRepository rpo) // public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -51,11 +47,7 @@ public sealed class LoginLogService(BasicRepository rpo) // public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -80,9 +72,7 @@ public sealed class LoginLogService(BasicRepository rpo) // var list = await QueryInternal(req) .Include(a => a.Owner) .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Count(out var total) .ToListAsync(a => new { a.CreatedClientIp @@ -106,13 +96,7 @@ public sealed class LoginLogService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/MenuService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/MenuService.cs index 60d727c9..4388cd50 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/MenuService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/MenuService.cs @@ -25,11 +25,7 @@ public sealed class MenuService(BasicRepository rpo, IUserServic public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -64,11 +60,7 @@ public sealed class MenuService(BasicRepository rpo, IUserServic public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -97,12 +89,7 @@ public sealed class MenuService(BasicRepository rpo, IUserServic public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .ToTreeListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().ToTreeListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs index ccb36212..14b5b490 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogDetailService.cs @@ -25,11 +25,7 @@ public sealed class RequestLogDetailService(BasicRepository CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -51,11 +47,7 @@ public sealed class RequestLogDetailService(BasicRepository ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -79,14 +71,7 @@ public sealed class RequestLogDetailService(BasicRepository> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -95,13 +80,7 @@ public sealed class RequestLogDetailService(BasicRepository> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs index ca049f91..2680f14a 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RequestLogService.cs @@ -27,11 +27,7 @@ public sealed class RequestLogService(BasicRepository rpo, public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -59,11 +55,7 @@ public sealed class RequestLogService(BasicRepository rpo, public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -109,9 +101,7 @@ public sealed class RequestLogService(BasicRepository rpo, req.ThrowIfInvalid(); var ret = await QueryInternal(req with { Order = Orders.None }, false) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .GroupBy(a => new { a.CreatedTime.Year, a.CreatedTime.Month, a.CreatedTime.Day, a.CreatedTime.Hour }) .ToListAsync(a => new GetBarChartRsp { Timestamp = new DateTime(a.Key.Year, a.Key.Month, a.Key.Day, a.Key.Hour, 0, 0 @@ -127,9 +117,7 @@ public sealed class RequestLogService(BasicRepository rpo, { req.ThrowIfInvalid(); var ret = await QueryInternal(req with { Order = Orders.None }) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .GroupBy(a => a.Api.Summary) .ToListAsync(a => new GetPieChartRsp { Value = a.Count(), Key = a.Key }) .ConfigureAwait(false); @@ -141,9 +129,7 @@ public sealed class RequestLogService(BasicRepository rpo, { req.ThrowIfInvalid(); var ret = await QueryInternal(req with { Order = Orders.None }, false) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .GroupBy(a => a.HttpStatusCode) #pragma warning disable CA1305 .ToListAsync(a => new GetPieChartRsp { Value = a.Count(), Key = a.Key.ToString() }) @@ -171,9 +157,7 @@ public sealed class RequestLogService(BasicRepository rpo, } var ret = await selectTemp.Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Count(out var total) .ToListAsync(a => a.temp) .ConfigureAwait(false); @@ -185,13 +169,7 @@ public sealed class RequestLogService(BasicRepository rpo, public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs index c2fd630e..aca4bbde 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/RoleService.cs @@ -25,11 +25,7 @@ public sealed class RoleService(BasicRepository rpo) // public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -52,12 +48,7 @@ public sealed class RoleService(BasicRepository rpo) // public async Task DeleteAsync(DelReq req) { req.ThrowIfInvalid(); - return await Rpo.Orm.Select() - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(a => a.RoleId == req.Id) - .ConfigureAwait(false) + return await Rpo.Orm.Select().WithNoLockNoWait().AnyAsync(a => a.RoleId == req.Id).ConfigureAwait(false) ? throw new NetAdminInvalidOperationException(Ln.该角色下存在用户) : await Rpo.DeleteAsync(a => a.Id == req.Id).ConfigureAwait(false); } @@ -79,11 +70,7 @@ public sealed class RoleService(BasicRepository rpo) // public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -105,14 +92,7 @@ public sealed class RoleService(BasicRepository rpo) // public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -121,12 +101,7 @@ public sealed class RoleService(BasicRepository rpo) // public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs index 6fb3f6c6..23e0a96f 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgDeptService.cs @@ -25,11 +25,7 @@ public sealed class SiteMsgDeptService(BasicRepository rp public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -51,11 +47,7 @@ public sealed class SiteMsgDeptService(BasicRepository rp public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -77,14 +69,7 @@ public sealed class SiteMsgDeptService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,13 +78,7 @@ public sealed class SiteMsgDeptService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs index db02ece4..da8eb4bb 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgFlagService.cs @@ -25,11 +25,7 @@ public sealed class SiteMsgFlagService(BasicRepository rp public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -51,11 +47,7 @@ public sealed class SiteMsgFlagService(BasicRepository rp public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -77,14 +69,7 @@ public sealed class SiteMsgFlagService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,13 +78,7 @@ public sealed class SiteMsgFlagService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs index 0ad07d14..38e6a579 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgRoleService.cs @@ -25,11 +25,7 @@ public sealed class SiteMsgRoleService(BasicRepository rp public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -51,11 +47,7 @@ public sealed class SiteMsgRoleService(BasicRepository rp public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -77,14 +69,7 @@ public sealed class SiteMsgRoleService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,13 +78,7 @@ public sealed class SiteMsgRoleService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs index a6e6e67f..e90ef1c9 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgService.cs @@ -29,11 +29,7 @@ public sealed class SiteMsgService(BasicRepository rpo, Conte public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -94,11 +90,7 @@ public sealed class SiteMsgService(BasicRepository rpo, Conte public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -143,9 +135,7 @@ public sealed class SiteMsgService(BasicRepository rpo, Conte req.ThrowIfInvalid(); var list = await QueryInternal(req) .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Count(out var total) .ToListAsync(a => new { a.CreatedTime @@ -172,13 +162,7 @@ public sealed class SiteMsgService(BasicRepository rpo, Conte public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } @@ -295,9 +279,7 @@ public sealed class SiteMsgService(BasicRepository rpo, Conte var roleIds = contextUserInfo.Roles.Select(x => x.Id).ToList(); return Rpo.Orm.Select() - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .LeftJoin((a, b, _, _, _, _) => a.CreatedUserId == b.Id) .LeftJoin((a, _, c, _, _, _) => a.Id == c.SiteMsgId) .LeftJoin((a, _, _, d, _, _) => a.Id == d.SiteMsgId) diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs index d9eafa3f..94ada7dc 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/SiteMsgUserService.cs @@ -25,11 +25,7 @@ public sealed class SiteMsgUserService(BasicRepository rp public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -51,11 +47,7 @@ public sealed class SiteMsgUserService(BasicRepository rp public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -77,14 +69,7 @@ public sealed class SiteMsgUserService(BasicRepository rp public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -93,13 +78,7 @@ public sealed class SiteMsgUserService(BasicRepository rp public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserProfileService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserProfileService.cs index 30ef5ad7..d9ab21cb 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserProfileService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserProfileService.cs @@ -44,11 +44,7 @@ public sealed class UserProfileService(BasicRepository rp public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -78,11 +74,7 @@ public sealed class UserProfileService(BasicRepository rp public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -113,9 +105,7 @@ public sealed class UserProfileService(BasicRepository rp req.ThrowIfInvalid(); var list = await QueryInternal(req) .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Count(out var total) .ToListAsync((a, b, c, d, e) => new { a @@ -141,9 +131,7 @@ public sealed class UserProfileService(BasicRepository rp { req.ThrowIfInvalid(); var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Take(req.Count) .ToListAsync((a, b, c, d, e) => new { a diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserService.cs index 6f4f3cb3..cb04053e 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserService.cs @@ -68,11 +68,7 @@ public sealed class UserService( { req.ThrowIfInvalid(); #pragma warning disable VSTHRD103 - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); #pragma warning restore VSTHRD103 } @@ -235,9 +231,7 @@ public sealed class UserService( var includeRoles = listUserExp == _listUserExp; var select = await QueryInternalAsync(req, includeRoles).ConfigureAwait(false); IEnumerable list = await select.Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Count(out var total) .ToListAsync(listUserExp) .ConfigureAwait(false); @@ -252,13 +246,12 @@ public sealed class UserService( public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var list = await (await QueryInternalAsync(req, false).ConfigureAwait(false)) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync(a => new Sys_User { Id = a.Id, UserName = a.UserName }) - .ConfigureAwait(false); + var list = await (await QueryInternalAsync(req, false).ConfigureAwait(false)).WithNoLockNoWait() + .Take(req.Count) + .ToListAsync(a => new Sys_User { + Id = a.Id, UserName = a.UserName + }) + .ConfigureAwait(false); return list.Adapt>(); } @@ -418,63 +411,29 @@ public sealed class UserService( /// public async Task UserInfoAsync() { - static void OtherIncludes(ISelect select) - { - select.Where(a => a.Enabled) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .IncludeMany( // - a => a.Menus - #if DBTYPE_SQLSERVER - #pragma warning disable SA1115 - , then => then.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #pragma warning restore SA1115 - #endif - #pragma warning disable SA1009, SA1111 - ) - #pragma warning restore SA1111, SA1009 - .IncludeMany( // - a => a.Depts - #if DBTYPE_SQLSERVER - #pragma warning disable SA1115 - , then => then.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #pragma warning restore SA1115 - #endif - #pragma warning disable SA1009, SA1111 - ) - #pragma warning restore SA1111, SA1009 - .IncludeMany( // - a => a.Apis - #if DBTYPE_SQLSERVER - #pragma warning disable SA1115 - , then => then.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #pragma warning restore SA1115 - #endif - #pragma warning disable SA1009, SA1111 - ) - #pragma warning restore SA1111, SA1009 - ; - } - var dbUser = await Rpo.Where(a => a.Token == UserToken.Token && a.Enabled) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Include(a => a.Dept) .IncludeMany(a => a.Roles, OtherIncludes) .ToOneAsync() .ConfigureAwait(false); return dbUser.Adapt(); + + static void OtherIncludes(ISelect select) + { + _ = select.Where(a => a.Enabled) + .WithNoLockNoWait() + .IncludeMany(a => a.Menus, then => then.WithNoLockNoWait()) + .IncludeMany(a => a.Depts, then => then.WithNoLockNoWait()) + .IncludeMany(a => a.Apis, then => then.WithNoLockNoWait()); + } } private async Task> CreateEditCheckAsync(CreateEditUserReq req) { // 检查角色是否存在 var roles = await Rpo.Orm.Select() - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .Where(a => req.RoleIds.Contains(a.Id)) .ToDictionaryAsync(a => a.Id, a => a.DashboardLayout) .ConfigureAwait(false); @@ -483,13 +442,7 @@ public sealed class UserService( } // 检查部门是否存在 - var dept = await Rpo.Orm.Select() - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Where(a => req.DeptId == a.Id) - .ToListAsync(a => a.Id) - .ConfigureAwait(false); + var dept = await Rpo.Orm.Select().WithNoLockNoWait().Where(a => req.DeptId == a.Id).ToListAsync(a => a.Id).ConfigureAwait(false); return dept.Count != 1 ? throw new NetAdminInvalidOperationException(Ln.部门不存在) : roles; } diff --git a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs index 30a2463a..a2a1c9e7 100644 --- a/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs +++ b/src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/VerifyCodeService.cs @@ -29,11 +29,7 @@ public sealed class VerifyCodeService(BasicRepository rpo, public Task CountAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .CountAsync(); + return QueryInternal(req).WithNoLockNoWait().CountAsync(); } /// @@ -61,11 +57,7 @@ public sealed class VerifyCodeService(BasicRepository rpo, public Task ExistAsync(QueryReq req) { req.ThrowIfInvalid(); - return QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .AnyAsync(); + return QueryInternal(req).WithNoLockNoWait().AnyAsync(); } /// @@ -87,14 +79,7 @@ public sealed class VerifyCodeService(BasicRepository rpo, public async Task> PagedQueryAsync(PagedQueryReq req) { req.ThrowIfInvalid(); - var list = await QueryInternal(req) - .Page(req.Page, req.PageSize) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Count(out var total) - .ToListAsync() - .ConfigureAwait(false); + var list = await QueryInternal(req).Page(req.Page, req.PageSize).WithNoLockNoWait().Count(out var total).ToListAsync().ConfigureAwait(false); return new PagedQueryRsp(req.Page, req.PageSize, total, list.Adapt>()); } @@ -103,13 +88,7 @@ public sealed class VerifyCodeService(BasicRepository rpo, public async Task> QueryAsync(QueryReq req) { req.ThrowIfInvalid(); - var ret = await QueryInternal(req) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif - .Take(req.Count) - .ToListAsync() - .ConfigureAwait(false); + var ret = await QueryInternal(req).WithNoLockNoWait().Take(req.Count).ToListAsync().ConfigureAwait(false); return ret.Adapt>(); } @@ -180,9 +159,7 @@ public sealed class VerifyCodeService(BasicRepository rpo, , Value = destDevice } }) - #if DBTYPE_SQLSERVER - .WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait) - #endif + .WithNoLockNoWait() .ToOneAsync(); }