Compare commits

...

8 Commits

Author SHA1 Message Date
27d731a5b0 Bump version to 2.0.0-beta in ReC.API.csproj
Updated <Version>, <AssemblyVersion>, <FileVersion>, and <InformationalVersion> fields from 1.0.3-beta to 2.0.0-beta to reflect a major version change, indicating significant updates or breaking changes in the project.
2026-01-22 10:41:26 +01:00
b8f797f14d Make EndpointAuthType non-nullable with default NoAuth
Changed EndpointAuthType in RecActionViewDto from nullable to non-nullable and set its default value to EndpointAuthType.NoAuth to ensure it always has a valid value.
2026-01-22 10:37:37 +01:00
6feef53733 Update namespaces and usings for Insert procedures
Refactored InsertActionProcedure to the RecActions.Commands namespace and updated its usings to import InsertObjectProcedure. Added missing using for RecActions.Commands in InsertObjectProcedure.cs. These changes improve code organization and clarify command responsibilities.
2026-01-22 10:17:08 +01:00
878e096c57 Refactor TypeId to use RestType enum in InsertActionProcedure
Changed TypeId from byte? to RestType? in InsertActionProcedure for stronger typing. Updated InsertObjectProcedureHandler to cast RestType to byte? when creating SQL parameters. Added using directive for ReC.Domain.Constants to support the new enum type.
2026-01-22 09:55:35 +01:00
2ded140ad5 Rename SqlExceptionNumber to BadRequestSqlExceptionNumber
Clarify intent by renaming SqlExceptionNumber to BadRequestSqlExceptionNumber in both configuration and code. This makes it explicit that these SQL exception numbers are mapped to HTTP 400 Bad Request errors. All relevant usages and settings have been updated accordingly.
2026-01-22 09:33:54 +01:00
e2ca249d13 Add SQL exception 50000 to handled exception numbers
Updated appsettings.json to include 50000 in the SqlExceptionNumber array, allowing the application to recognize and handle SQL exceptions with this number in addition to existing ones. This change can be applied at runtime without requiring a restart.
2026-01-22 09:31:41 +01:00
e782eab62a Refactor handlers to use IOptionsMonitor for SQL options
Refactored Delete, Insert, and Update procedure handlers to inject IOptionsMonitor<SqlExceptionOptions> instead of SqlExceptionOptions, enabling dynamic configuration updates. Updated all references to use CurrentValue. Added necessary using directives and cleaned up redundant usings in InsertObjectProcedure.cs.
2026-01-22 09:21:39 +01:00
d8e08b237d Simplify SqlException config structure in appsettings.json
Removed the "ErrorMessages" wrapper from the SqlException section,
placing "SqlExceptionNumber" directly under "SqlException".
No changes to the exception numbers themselves. Improved
readability and clarity of the configuration.
2026-01-22 02:04:52 +01:00
8 changed files with 27 additions and 21 deletions

View File

@@ -10,10 +10,10 @@
<Product>ReC.API</Product>
<PackageIcon>Assets\icon.ico</PackageIcon>
<PackageTags>digital data rest-caller rec api</PackageTags>
<Version>1.0.3-beta</Version>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<FileVersion>1.0.3.0</FileVersion>
<InformationalVersion>1.0.3-beta</InformationalVersion>
<Version>2.0.0-beta</Version>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<InformationalVersion>2.0.0-beta</InformationalVersion>
<Copyright>Copyright © 2025 Digital Data GmbH. All rights reserved.</Copyright>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>

View File

@@ -8,11 +8,10 @@
"RecAction": {
"MaxConcurrentInvocations": 5
},
// Bad request SqlException numbers numbers can be updated at runtime; no restart required.
"SqlException": {
"ErrorMessages": {
// https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlexception.number
"SqlExceptionNumber": [ 515 , 547, 2601, 2627]
}
// https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlexception.number
"BadRequestSqlExceptionNumbers": [ 515, 547, 2601, 2627, 50000 ]
},
"AddedWho": "ReC.API",
"FakeProfileId": 2

View File

@@ -20,7 +20,7 @@ public record RecActionViewDto
public long? EndpointAuthId { get; init; }
public EndpointAuthType? EndpointAuthType { get; init; }
public EndpointAuthType EndpointAuthType { get; init; } = EndpointAuthType.NoAuth;
public string? EndpointAuthTypeName { get; init; }

View File

@@ -2,5 +2,5 @@ namespace ReC.Application.Common.Options;
public class SqlExceptionOptions
{
public HashSet<int> SqlExceptionNumber { get; set; } = [];
public HashSet<int> BadRequestSqlExceptionNumbers { get; set; } = [];
}

View File

@@ -2,6 +2,7 @@ using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using MediatR;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
using ReC.Application.Common.Exceptions;
using ReC.Application.Common.Options;
@@ -49,7 +50,7 @@ public static class DeleteObjectProcedureExtensions
}
}
public class DeleteObjectProcedureHandler(IRepository repo, SqlExceptionOptions sqlExceptionOptions) : IRequestHandler<DeleteObjectProcedure, int>
public class DeleteObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<DeleteObjectProcedure, int>
{
public async Task<int> Handle(DeleteObjectProcedure request, CancellationToken cancel)
{
@@ -81,7 +82,7 @@ public class DeleteObjectProcedureHandler(IRepository repo, SqlExceptionOptions
}
catch (SqlException ex)
{
if (sqlExceptionOptions.SqlExceptionNumber.Contains(ex.Number))
if (sqlExOpt.CurrentValue.BadRequestSqlExceptionNumbers.Contains(ex.Number))
throw new BadRequestException(ex.Message, ex);
else
throw;

View File

@@ -2,13 +2,15 @@
using DigitalData.Core.Exceptions;
using MediatR;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
using ReC.Application.Common.Exceptions;
using ReC.Application.Common.Options;
using ReC.Application.EndpointAuth.Commands;
using ReC.Application.EndpointParams.Commands;
using ReC.Application.Endpoints.Commands;
using ReC.Application.Results.Commands;
using ReC.Application.Profile.Commands;
using ReC.Application.Common.Options;
using ReC.Application.RecActions.Commands;
using ReC.Application.Results.Commands;
namespace ReC.Application.Common.Procedures.InsertProcedure;
@@ -43,7 +45,7 @@ public static class InsertObjectProcedureExtensions
}
}
public class InsertObjectProcedureHandler(IRepository repo, SqlExceptionOptions sqlExceptionOptions) : IRequestHandler<InsertObjectProcedure, long>
public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<InsertObjectProcedure, long>
{
public async Task<long> Handle(InsertObjectProcedure request, CancellationToken cancel)
{
@@ -61,7 +63,7 @@ public class InsertObjectProcedureHandler(IRepository repo, SqlExceptionOptions
new SqlParameter("@pACTION_ENDPOINT_AUTH_ID", (object?)request.Action.EndpointAuthId ?? DBNull.Value),
new SqlParameter("@pACTION_ENDPOINT_PARAMS_ID", (object?)request.Action.EndpointParamsId ?? DBNull.Value),
new SqlParameter("@pACTION_SQL_CONNECTION_ID", (object?)request.Action.SqlConnectionId ?? DBNull.Value),
new SqlParameter("@pACTION_TYPE_ID", (object?)request.Action.TypeId ?? DBNull.Value),
new SqlParameter("@pACTION_TYPE_ID", (object?)(byte?)request.Action.TypeId ?? DBNull.Value),
new SqlParameter("@pACTION_PRE_SQL", (object?)request.Action.PreSql ?? DBNull.Value),
new SqlParameter("@pACTION_HEADER_SQL", (object?)request.Action.HeaderSql ?? DBNull.Value),
new SqlParameter("@pACTION_BODY_SQL", (object?)request.Action.BodySql ?? DBNull.Value),
@@ -129,7 +131,7 @@ public class InsertObjectProcedureHandler(IRepository repo, SqlExceptionOptions
}
catch (SqlException ex)
{
if (sqlExceptionOptions.SqlExceptionNumber.Contains(ex.Number))
if (sqlExOpt.CurrentValue.BadRequestSqlExceptionNumbers.Contains(ex.Number))
throw new BadRequestException(ex.Message, ex);
else
throw;

View File

@@ -2,6 +2,7 @@ using DigitalData.Core.Abstraction.Application.Repository;
using DigitalData.Core.Exceptions;
using MediatR;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
using ReC.Application.Common.Exceptions;
using ReC.Application.Common.Options;
using ReC.Application.EndpointAuth.Commands;
@@ -49,7 +50,7 @@ public static class UpdateObjectProcedureExtensions
}
}
public class UpdateObjectProcedureHandler(IRepository repo, SqlExceptionOptions sqlExceptionOptions) : IRequestHandler<UpdateObjectProcedure, int>
public class UpdateObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<UpdateObjectProcedure, int>
{
public async Task<int> Handle(UpdateObjectProcedure request, CancellationToken cancel)
{
@@ -141,7 +142,7 @@ public class UpdateObjectProcedureHandler(IRepository repo, SqlExceptionOptions
}
catch (SqlException ex)
{
if (sqlExceptionOptions.SqlExceptionNumber.Contains(ex.Number))
if (sqlExOpt.CurrentValue.BadRequestSqlExceptionNumbers.Contains(ex.Number))
throw new BadRequestException(ex.Message, ex);
else
throw;

View File

@@ -1,4 +1,7 @@
namespace ReC.Application.Common.Procedures.InsertProcedure;
using ReC.Application.Common.Procedures.InsertProcedure;
using ReC.Domain.Constants;
namespace ReC.Application.RecActions.Commands;
public record InsertActionProcedure : IInsertProcedure
{
@@ -9,7 +12,7 @@ public record InsertActionProcedure : IInsertProcedure
public long? EndpointAuthId { get; set; }
public short? EndpointParamsId { get; set; }
public short? SqlConnectionId { get; set; }
public byte? TypeId { get; set; }
public RestType? TypeId { get; set; }
public string? PreSql { get; set; }
public string? HeaderSql { get; set; }
public string? BodySql { get; set; }