Compare commits
107 Commits
5d316e43b9
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| e96773f3c4 | |||
| 06e92b588f | |||
| b922cbbb30 | |||
| 6c56375e3e | |||
| fa9aa23f32 | |||
| b86d0c0f99 | |||
| b0d89ceba4 | |||
| 11ebfdd21e | |||
| 1467acc4a1 | |||
| e761fbd1ca | |||
| 2e83d4a24a | |||
| 37ba85d681 | |||
| a46cd08122 | |||
| 3d46901af5 | |||
| 90e8adbd36 | |||
| aef59def7f | |||
| d7783b6e81 | |||
| 4126f984e4 | |||
| 0e2328c287 | |||
| e04e054151 | |||
| 6082a637fe | |||
| 93669a6358 | |||
| fecd9219b4 | |||
| bd07b4482c | |||
| 520aec427b | |||
| 26b7a82451 | |||
| 08c0d29d84 | |||
| 405b5f3ab1 | |||
| 32af65d30c | |||
| 30ccf05c57 | |||
| a14d5ff112 | |||
| fec125b0d5 | |||
| 82ae4c5957 | |||
| 894b7bb070 | |||
| a707cce6e4 | |||
| 2ca85a2372 | |||
| dbe09cd07b | |||
| 690dcea7a8 | |||
| fdae4d26be | |||
| 2883cf9be4 | |||
| 9410c5dc0d | |||
| 35e99d9f2a | |||
| 5fd65e52a3 | |||
| 2508a8b986 | |||
| daff1477be | |||
| dcfa47c68d | |||
| e691faf620 | |||
| cac33c46df | |||
| de503cac5b | |||
| 4999beda3b | |||
| 5df36d94e0 | |||
| d3d24a0fb6 | |||
| a6b0cbaf9d | |||
| 0162d059da | |||
| 302fee4908 | |||
| 3e10176d98 | |||
| 4f0f99e0f8 | |||
| 8fb4b4005c | |||
| b3bb7144ef | |||
| eff6350d77 | |||
| 114b5de71d | |||
| f786192786 | |||
| 50741bfdd3 | |||
| 561eafe48c | |||
| 84358ced96 | |||
| d2e97a2fef | |||
| d505c8415e | |||
| a590ffd2dc | |||
| 94da75ce37 | |||
| 9c1ffd7df8 | |||
| e31d034266 | |||
| 649d7eff8c | |||
| 401d67de4c | |||
| ed94415a33 | |||
| 04513a3d08 | |||
| d390c3f7b6 | |||
| a40f20f6d9 | |||
| ee1f6a8753 | |||
| 1e35b6e263 | |||
| e152e9a37a | |||
| 554aaa8b6c | |||
| 329d156d08 | |||
| 246362812a | |||
| 71430918ac | |||
| 7a1705365b | |||
| acf136e689 | |||
| 6b4897702a | |||
| 7d4e082958 | |||
| d1dd021952 | |||
| 5afc1791b0 | |||
| 2ec07d7e96 | |||
| cbe4f1ba3c | |||
| 16155da033 | |||
| 0aa1414ea6 | |||
| 181a9a83fd | |||
| 5e3e12bad8 | |||
| 6dcc128ad5 | |||
| 754ef88644 | |||
| 95ece6fdcf | |||
| 87194df697 | |||
| b38d53248c | |||
| 56b604bd35 | |||
| f67579dba9 | |||
| 636397efb8 | |||
| ef4d0767e9 | |||
| f15725ade2 | |||
| 382eef0089 |
@@ -25,7 +25,7 @@ public class CommonController(IMediator mediator) : ControllerBase
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public async Task<IActionResult> DeleteObject([FromBody] DeleteObjectProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> DeleteObject([FromQuery] DeleteObjectProcedure procedure, CancellationToken cancel)
|
||||
{
|
||||
var result = await mediator.Send(procedure, cancel);
|
||||
return Ok(result);
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class EndpointAuthController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
public class EndpointAuthController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Inserts an endpoint authentication record via the ENDPOINT_AUTH insert procedure.
|
||||
@@ -19,38 +17,38 @@ public class EndpointAuthController(IMediator mediator, IConfiguration config) :
|
||||
/// <returns>The created ENDPOINT_AUTH identifier.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> Post([FromBody] InsertEndpointAuthProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Post([FromBody] InsertEndpointAuthCommand procedure, CancellationToken cancel)
|
||||
{
|
||||
var id = await mediator.ExecuteInsertProcedure(procedure, config["AddedWho"], cancel);
|
||||
var id = await mediator.Send(procedure, cancel);
|
||||
return StatusCode(StatusCodes.Status201Created, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an endpoint authentication record via the ENDPOINT_AUTH update procedure.
|
||||
/// </summary>
|
||||
/// <param name="id">ENDPOINT_AUTH identifier to update.</param>
|
||||
/// <param name="procedure">UpdateEndpointAuthProcedure payload.</param>
|
||||
/// <param name="id">The identifier of the ENDPOINT_AUTH record to update.</param>
|
||||
/// <param name="data">UpdateEndpointAuthProcedure payload.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpPut("{id:long}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointAuthProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointAuthDto data, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel);
|
||||
await mediator.Send(new UpdateEndpointAuthCommand() { Id = id, Data = data}, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes endpoint authentication records via the ENDPOINT_AUTH delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="procedure">DeleteEndpointAuthProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="command">DeleteEndpointAuthProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteEndpointAuthProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointAuthCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.EndpointParams.Commands;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class EndpointParamsController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
public class EndpointParamsController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Inserts endpoint parameter records via the ENDPOINT_PARAMS insert procedure.
|
||||
@@ -19,38 +17,38 @@ public class EndpointParamsController(IMediator mediator, IConfiguration config)
|
||||
/// <returns>The created ENDPOINT_PARAMS identifier.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> Post([FromBody] InsertEndpointParamsProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Post([FromBody] InsertEndpointParamsCommand procedure, CancellationToken cancel)
|
||||
{
|
||||
var id = await mediator.ExecuteInsertProcedure(procedure, config["AddedWho"], cancel);
|
||||
var id = await mediator.Send(procedure, cancel);
|
||||
return StatusCode(StatusCodes.Status201Created, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates endpoint parameter records via the ENDPOINT_PARAMS update procedure.
|
||||
/// </summary>
|
||||
/// <param name="id">ENDPOINT_PARAMS identifier to update.</param>
|
||||
/// <param name="procedure">UpdateEndpointParamsProcedure payload.</param>
|
||||
/// <param name="id">The identifier of the ENDPOINT_PARAMS record to update.</param>
|
||||
/// <param name="data">UpdateEndpointParamsProcedure payload.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpPut("{id:long}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointParamsProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointParamsDto data, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel);
|
||||
await mediator.Send(new UpdateEndpointParamsCommand() { Id = id, Data = data }, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes endpoint parameter records via the ENDPOINT_PARAMS delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="procedure">DeleteEndpointParamsProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="command">DeleteEndpointParamsProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteEndpointParamsProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointParamsCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class EndpointsController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
public class EndpointsController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Inserts an endpoint via the ENDPOINT insert procedure.
|
||||
@@ -19,38 +17,38 @@ public class EndpointsController(IMediator mediator, IConfiguration config) : Co
|
||||
/// <returns>The created ENDPOINT identifier.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> Post([FromBody] InsertEndpointProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Post([FromBody] InsertEndpointCommand procedure, CancellationToken cancel)
|
||||
{
|
||||
var id = await mediator.ExecuteInsertProcedure(procedure, config["AddedWho"], cancel);
|
||||
var id = await mediator.Send(procedure, cancel);
|
||||
return StatusCode(StatusCodes.Status201Created, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an endpoint via the ENDPOINT update procedure.
|
||||
/// </summary>
|
||||
/// <param name="id">ENDPOINT identifier to update.</param>
|
||||
/// <param name="procedure">UpdateEndpointProcedure payload.</param>
|
||||
/// <param name="id">The identifier of the ENDPOINT record to update.</param>
|
||||
/// <param name="data">UpdateEndpointProcedure payload.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpPut("{id:long}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateEndpointDto data, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel);
|
||||
await mediator.Send(new UpdateEndpointCommand() { Id = id, Data = data }, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes endpoints via the ENDPOINT delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="procedure">DeleteEndpointProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="command">DeleteEndpointProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteEndpointProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteEndpointCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.Profile.Commands;
|
||||
using ReC.Application.Profile.Queries;
|
||||
|
||||
@@ -26,38 +24,38 @@ public class ProfileController(IMediator mediator) : ControllerBase
|
||||
/// <returns>The created profile identifier.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> Post([FromBody] InsertProfileProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Post([FromBody] InsertProfileCommand procedure, CancellationToken cancel)
|
||||
{
|
||||
var id = await mediator.ExecuteInsertProcedure(procedure, cancel: cancel);
|
||||
var id = await mediator.Send(procedure, cancel);
|
||||
return CreatedAtAction(nameof(Get), new { id }, id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a profile via the PROFILE update procedure.
|
||||
/// </summary>
|
||||
/// <param name="id">Profile identifier to update.</param>
|
||||
/// <param name="procedure">UpdateProfileProcedure payload.</param>
|
||||
/// <param name="id">The identifier of the PROFILE record to update.</param>
|
||||
/// <param name="data">UpdateProfileProcedure payload.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpPut("{id:long}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateProfileProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateProfileDto data, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel);
|
||||
await mediator.Send(new UpdateProfileCommand() { Id = id, Data = data }, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes profile records via the PROFILE delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="procedure">DeleteProfileProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="command">DeleteProfileProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteProfileProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteProfileCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using ReC.Application.RecActions.Queries;
|
||||
|
||||
@@ -10,19 +8,19 @@ namespace ReC.API.Controllers;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class RecActionController(IMediator mediator, IConfiguration config) : ControllerBase
|
||||
public class RecActionController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Invokes a batch of RecActions for a given profile.
|
||||
/// </summary>
|
||||
/// <param name="profileId">The ID of the profile.</param>
|
||||
/// <param name="command">The command containing the profile ID.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 202 Accepted response indicating the process has been started.</returns>
|
||||
[HttpPost("invoke/{profileId}")]
|
||||
[HttpPost("invoke/{command}")]
|
||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId, CancellationToken cancel)
|
||||
public async Task<IActionResult> Invoke([FromRoute] InvokeBatchRecActionViewsCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.InvokeBatchRecActionView(profileId, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return Accepted();
|
||||
}
|
||||
|
||||
@@ -45,9 +43,9 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
||||
/// <returns>An HTTP 201 Created response.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> Create([FromBody] InsertActionProcedure command, CancellationToken cancel)
|
||||
public async Task<IActionResult> Create([FromBody] InsertActionCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteInsertProcedure(command, config["AddedWho"], cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
|
||||
return StatusCode(StatusCodes.Status201Created);
|
||||
}
|
||||
@@ -55,29 +53,29 @@ public class RecActionController(IMediator mediator, IConfiguration config) : Co
|
||||
/// <summary>
|
||||
/// Updates a RecAction via the ACTION update procedure.
|
||||
/// </summary>
|
||||
/// <param name="id">RecAction identifier to update.</param>
|
||||
/// <param name="procedure">UpdateActionProcedure payload.</param>
|
||||
/// <param name="id">The identifier of the ACTION record to update.</param>
|
||||
/// <param name="data">UpdateActionProcedure payload.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpPut("{id:long}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Update([FromRoute] long id, [FromBody] UpdateActionProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Update([FromRoute] long id, [FromBody] UpdateActionDto data, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel);
|
||||
await mediator.Send(new UpdateActionCommand() { Id = id, Data = data }, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes RecActions via the ACTION delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="procedure">DeleteActionProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="command">DeleteActionProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>An HTTP 204 No Content response upon successful deletion.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteActionProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteActionCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
#endregion CRUD
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.API.Extensions;
|
||||
using ReC.API.Models;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.Results.Commands;
|
||||
using ReC.Application.Results.Queries;
|
||||
|
||||
@@ -32,38 +28,38 @@ public class ResultController(IMediator mediator) : ControllerBase
|
||||
/// <returns>The created RESULT identifier.</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
public async Task<IActionResult> Post([FromBody] InsertResultProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Post([FromBody] InsertResultCommand procedure, CancellationToken cancel)
|
||||
{
|
||||
var id = await mediator.ExecuteInsertProcedure(procedure, cancel: cancel);
|
||||
var id = await mediator.Send(procedure, cancel);
|
||||
return CreatedAtAction(nameof(Get), new { actionId = procedure.ActionId }, new { id, procedure.ActionId });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a RESULT record via the update procedure.
|
||||
/// </summary>
|
||||
/// <param name="id">RESULT identifier to update.</param>
|
||||
/// <param name="procedure">UpdateResultProcedure payload.</param>
|
||||
/// <param name="id">The identifier of the RESULT record to update.</param>
|
||||
/// <param name="data">UpdateResultProcedure payload.</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpPut("{id:long}")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateResultProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Put([FromRoute] long id, [FromBody] UpdateResultDto data, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteUpdateProcedure(procedure, id, cancel: cancel);
|
||||
await mediator.Send(new UpdateResultCommand() { Id = id, Data = data }, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes RESULT records via the delete procedure for the specified id range.
|
||||
/// </summary>
|
||||
/// <param name="procedure">DeleteResultProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="command">DeleteResultProcedure payload (Start, End, Force).</param>
|
||||
/// <param name="cancel">A token to cancel the operation.</param>
|
||||
/// <returns>No content on success.</returns>
|
||||
[HttpDelete]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
public async Task<IActionResult> Delete([FromBody] DeleteResultProcedure procedure, CancellationToken cancel)
|
||||
public async Task<IActionResult> Delete([FromQuery] DeleteResultCommand command, CancellationToken cancel)
|
||||
{
|
||||
await mediator.ExecuteDeleteProcedure(procedure, cancel);
|
||||
await mediator.Send(command, cancel);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace ReC.API.Extensions;
|
||||
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
public static int GetFakeProfileId(this IConfiguration config) => config.GetValue("FakeProfileId", 2);
|
||||
}
|
||||
@@ -7,13 +7,11 @@ using System.Text.Json;
|
||||
|
||||
namespace ReC.API.Middleware;
|
||||
|
||||
//TODO: Fix and use DigitalData.Core.Exceptions.Middleware
|
||||
/// <summary>
|
||||
/// Middleware for handling exceptions globally in the application.
|
||||
/// Captures exceptions thrown during the request pipeline execution,
|
||||
/// logs them, and returns an appropriate HTTP response with a JSON error details.
|
||||
/// </summary>
|
||||
[Obsolete("Use DigitalData.Core.Exceptions.Middleware")]
|
||||
public class ExceptionHandlingMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
@@ -164,6 +162,22 @@ public class ExceptionHandlingMiddleware
|
||||
};
|
||||
break;
|
||||
|
||||
case RecActionException recActionEx:
|
||||
logger.LogWarning(
|
||||
recActionEx,
|
||||
"Rec action failed. ActionId: {ActionId}, ProfileId: {ProfileId}",
|
||||
recActionEx.ActionId,
|
||||
recActionEx.ProfileId);
|
||||
|
||||
context.Response.StatusCode = (int)HttpStatusCode.UnprocessableEntity;
|
||||
details = new()
|
||||
{
|
||||
Title = "Rec Action Failed",
|
||||
Detail = recActionEx.InnerException?.Message
|
||||
?? "An error occurred while executing the rec action. Check the logs for more details."
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
logger.LogError(exception, "Unhandled exception occurred.");
|
||||
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
|
||||
@@ -70,9 +70,7 @@ try
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
#pragma warning disable CS0618
|
||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||
#pragma warning restore CS0618
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment() || config.GetValue<bool>("UseSwagger"))
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
<Product>ReC.API</Product>
|
||||
<PackageIcon>Assets\icon.ico</PackageIcon>
|
||||
<PackageTags>digital data rest-caller rec api</PackageTags>
|
||||
<Version>2.0.1-beta</Version>
|
||||
<AssemblyVersion>2.0.1.0</AssemblyVersion>
|
||||
<FileVersion>2.0.1.0</FileVersion>
|
||||
<Version>2.0.2-beta</Version>
|
||||
<AssemblyVersion>2.0.2.0</AssemblyVersion>
|
||||
<FileVersion>2.0.2.0</FileVersion>
|
||||
<InformationalVersion>2.0.1-beta</InformationalVersion>
|
||||
<Copyright>Copyright © 2025 Digital Data GmbH. All rights reserved.</Copyright>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
<UserSecretsId>cf893b96-c71a-4a96-a6a7-40004249e1a3</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
"AllowedHosts": "*",
|
||||
"LuckyPennySoftwareLicenseKey": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx1Y2t5UGVubnlTb2Z0d2FyZUxpY2Vuc2VLZXkvYmJiMTNhY2I1OTkwNGQ4OWI0Y2IxYzg1ZjA4OGNjZjkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2x1Y2t5cGVubnlzb2Z0d2FyZS5jb20iLCJhdWQiOiJMdWNreVBlbm55U29mdHdhcmUiLCJleHAiOiIxNzg0ODUxMjAwIiwiaWF0IjoiMTc1MzM2MjQ5MSIsImFjY291bnRfaWQiOiIwMTk4M2M1OWU0YjM3MjhlYmZkMzEwM2MyYTQ4NmU4NSIsImN1c3RvbWVyX2lkIjoiY3RtXzAxazB5NmV3MmQ4YTk4Mzg3aDJnbTRuOWswIiwic3ViX2lkIjoiLSIsImVkaXRpb24iOiIwIiwidHlwZSI6IjIifQ.ZqsFG7kv_-xGfxS6ACk3i0iuNiVUXX2AvPI8iAcZ6-z2170lGv__aO32tWpQccD9LCv5931lBNLWSblKS0MT3gOt-5he2TEftwiSQGFwoIBgtOHWsNRMinUrg2trceSp3IhyS3UaMwnxZDrCvx4-0O-kpOzVpizeHUAZNr5U7oSCWO34bpKdae6grtM5e3f93Z1vs7BW_iPgItd-aLvPwApbaG9VhmBTKlQ7b4Jh64y7UXJ9mKP7Qb_Oa97oEg0oY5DPHOWTZWeE1EzORgVr2qkK2DELSHuZ_EIUhODojkClPNAKtvEl_qEjpq0HZCIvGwfCCRlKlSkQqIeZdFkiXg",
|
||||
"RecAction": {
|
||||
"MaxConcurrentInvocations": 5
|
||||
"AddedWho": "ReC.API",
|
||||
"UseHttp1ForNtlm": false
|
||||
},
|
||||
// Bad request SqlException numbers numbers can be updated at runtime; no restart required.
|
||||
"SqlException": {
|
||||
// https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlexception.number
|
||||
"BadRequestSqlExceptionNumbers": [ 515, 547, 2601, 2627, 50000 ]
|
||||
},
|
||||
"AddedWho": "ReC.API",
|
||||
"FakeProfileId": 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.Common.Interfaces;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using ReC.Application.Results.Commands;
|
||||
using ReC.Domain.Constants;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReC.Application.Common.Behaviors.InvokeAction;
|
||||
|
||||
public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPipelineBehavior<InvokeRecActionViewCommand, Unit>
|
||||
{
|
||||
public async Task<Unit> Handle(InvokeRecActionViewCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancel)
|
||||
{
|
||||
await next(cancel);
|
||||
|
||||
try
|
||||
{
|
||||
if (request.Action.PostprocessingQuery is string query)
|
||||
{
|
||||
var result = await context.ExecuteDynamicSqlAsync(query, cancel);
|
||||
var info = JsonSerializer.Serialize(result);
|
||||
|
||||
await sender.Send(new InsertResultCommand()
|
||||
{
|
||||
ActionId = request.Action.Id,
|
||||
Info = info,
|
||||
Type = ResultType.Post
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = ex.ToString();
|
||||
|
||||
await sender.Send(new InsertResultCommand()
|
||||
{
|
||||
ActionId = request.Action.Id,
|
||||
Error = error,
|
||||
Type = ResultType.Post
|
||||
}, cancel);
|
||||
|
||||
if (request.Action.ErrorAction == ErrorAction.Stop)
|
||||
throw new RecActionException(request.Action.Id, request.Action.ProfileId, ex);
|
||||
}
|
||||
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.Common.Interfaces;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using ReC.Application.Results.Commands;
|
||||
using ReC.Domain.Constants;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReC.Application.Common.Behaviors.InvokeAction;
|
||||
|
||||
public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPipelineBehavior<InvokeRecActionViewCommand, Unit>
|
||||
{
|
||||
public async Task<Unit> Handle(InvokeRecActionViewCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (request.Action.PreprocessingQuery is string query)
|
||||
{
|
||||
var result = await context.ExecuteDynamicSqlAsync(query, cancel);
|
||||
|
||||
await sender.Send(new InsertResultCommand()
|
||||
{
|
||||
ActionId = request.Action.Id,
|
||||
Info = JsonSerializer.Serialize(result),
|
||||
Type = ResultType.Pre
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await sender.Send(new InsertResultCommand()
|
||||
{
|
||||
ActionId = request.Action.Id,
|
||||
Error = ex.ToString(),
|
||||
Type = ResultType.Pre
|
||||
}, cancel);
|
||||
|
||||
if (request.Action.ErrorAction == ErrorAction.Stop)
|
||||
throw new RecActionException(request.Action.Id, request.Action.ProfileId, ex);
|
||||
}
|
||||
|
||||
return await next(cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,38 @@
|
||||
namespace ReC.Application.Common.Dto;
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Application.Common.Dto;
|
||||
|
||||
public record OutResDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public long ActionId { get; set; }
|
||||
public long? ActionId { get; set; }
|
||||
|
||||
public RecActionDto? Action { get; set; }
|
||||
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
public ProfileDto? Profile { get; set; }
|
||||
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
public short? StatusCode { get; set; }
|
||||
|
||||
public string? StatusName { get; set; }
|
||||
|
||||
public ResultType? Type { get; set; }
|
||||
|
||||
public string? Header { get; set; }
|
||||
|
||||
public string? Body { get; set; }
|
||||
|
||||
public string AddedWho { get; set; } = null!;
|
||||
public string? Info { get; set; }
|
||||
|
||||
public DateTime AddedWhen { get; set; }
|
||||
public string? Error { get; set; }
|
||||
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
public string? ChangedWho { get; set; }
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ReC.Application.Common.Exceptions;
|
||||
|
||||
public class RecActionException(long actionId, long? profileId, Exception innerException)
|
||||
: Exception($"Rec action failed. ActionId: {actionId}, ProfileId: {profileId}", innerException)
|
||||
{
|
||||
public long ActionId { get; } = actionId;
|
||||
|
||||
public long? ProfileId { get; } = profileId;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using ReC.Domain.QueryOutput;
|
||||
using ReC.Domain.Views;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReC.Application.Common.Interfaces;
|
||||
|
||||
@@ -21,4 +23,39 @@ public interface IRecDbContext
|
||||
#endregion DbSets
|
||||
|
||||
public Task<int> SaveChangesAsync(CancellationToken cancel = default);
|
||||
|
||||
public DatabaseFacade Database { get; }
|
||||
}
|
||||
|
||||
public static class RecDbContextSaveExtensions
|
||||
{
|
||||
//TODO: Once it is finalized, move it to Common.Infrastructure
|
||||
public static async Task<IEnumerable<Dictionary<string, object?>>> ExecuteDynamicSqlAsync(this IRecDbContext context, string sql, CancellationToken cancel = default)
|
||||
{
|
||||
var result = new List<Dictionary<string, object?>>();
|
||||
|
||||
using var command = context.Database.GetDbConnection().CreateCommand();
|
||||
|
||||
command.CommandText = sql;
|
||||
|
||||
await context.Database.OpenConnectionAsync(cancel);
|
||||
|
||||
using var reader = await command.ExecuteReaderAsync(cancel);
|
||||
while (await reader.ReadAsync(cancel))
|
||||
{
|
||||
var row = new Dictionary<string, object?>();
|
||||
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
var columnName = reader.GetName(i);
|
||||
var value = reader.IsDBNull(i) ? null : reader.GetValue(i);
|
||||
|
||||
row[columnName] = value;
|
||||
}
|
||||
|
||||
result.Add(row);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public class RecActionOptions
|
||||
{
|
||||
public int MaxConcurrentInvocations { get; set; } = 5;
|
||||
public bool UseHttp1ForNtlm { get; set; } = false;
|
||||
}
|
||||
@@ -31,25 +31,6 @@ public record DeleteObjectProcedure : IRequest<int>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public static class DeleteObjectProcedureExtensions
|
||||
{
|
||||
public static Task<int> ExecuteDeleteProcedure(this ISender sender, IDeleteProcedure procedure, CancellationToken cancel = default)
|
||||
{
|
||||
return sender.Send(procedure.ToObjectProcedure(), cancel);
|
||||
}
|
||||
|
||||
public static Task<int> ExecuteDeleteProcedure(this ISender sender, string entity, long start, long end = 0, bool force = false, CancellationToken cancel = default)
|
||||
{
|
||||
return sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = entity,
|
||||
Start = start,
|
||||
End = end,
|
||||
Force = force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
|
||||
public class DeleteObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<DeleteObjectProcedure, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteObjectProcedure request, CancellationToken cancel)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediatR;
|
||||
|
||||
namespace ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
public interface IDeleteProcedure
|
||||
public interface IDeleteProcedure : IRequest<int>
|
||||
{
|
||||
public DeleteObjectProcedure ToObjectProcedure();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using MediatR;
|
||||
|
||||
public interface IInsertProcedure
|
||||
namespace ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
public interface IInsertProcedure : IRequest<long>
|
||||
{
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null);
|
||||
}
|
||||
@@ -21,28 +21,15 @@ public record InsertObjectProcedure : IRequest<long>
|
||||
/// </summary>
|
||||
public string Entity { get; set; } = null!;
|
||||
|
||||
internal string? AddedWho { get; private set; }
|
||||
//TODO: update to set in authentication middleware or similar, and remove from procedure properties
|
||||
internal string? AddedWho { get; private set; } = "ReC.API";
|
||||
|
||||
public InsertObjectProcedure AddedBy(string? addedWho = null)
|
||||
{
|
||||
AddedWho = addedWho ?? "ReC.API";
|
||||
return this;
|
||||
}
|
||||
|
||||
public InsertActionProcedure Action { get; set; } = new();
|
||||
public InsertEndpointProcedure Endpoint { get; set; } = new();
|
||||
public InsertEndpointAuthProcedure EndpointAuth { get; set; } = new();
|
||||
public InsertProfileProcedure Profile { get; set; } = new();
|
||||
public InsertResultProcedure Result { get; set; } = new();
|
||||
public InsertEndpointParamsProcedure EndpointParams { get; set; } = new();
|
||||
}
|
||||
|
||||
public static class InsertObjectProcedureExtensions
|
||||
{
|
||||
public static Task<long> ExecuteInsertProcedure(this ISender sender, IInsertProcedure procedure, string? addedWho = null, CancellationToken cancel = default)
|
||||
{
|
||||
return sender.Send(procedure.ToObjectProcedure(addedWho ?? "Rec.API"), cancel);
|
||||
}
|
||||
public InsertActionCommand? Action { get; set; }
|
||||
public InsertEndpointCommand? Endpoint { get; set; }
|
||||
public InsertEndpointAuthCommand? EndpointAuth { get; set; }
|
||||
public InsertProfileCommand? Profile { get; set; }
|
||||
public InsertResultCommand? Result { get; set; }
|
||||
public InsertEndpointParamsCommand? EndpointParams { get; set; }
|
||||
}
|
||||
|
||||
public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<InsertObjectProcedure, long>
|
||||
@@ -56,55 +43,58 @@ public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlE
|
||||
new SqlParameter("@pADDED_WHO", (object?)request.AddedWho ?? DBNull.Value),
|
||||
new SqlParameter("@pADDED_WHEN", (object?)DateTime.UtcNow ?? DBNull.Value),
|
||||
|
||||
new SqlParameter("@pACTION_PROFILE_ID", (object?)request.Action.ProfileId ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_ACTIVE", (object?)request.Action.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_SEQUENCE", (object?)request.Action.Sequence ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_ENDPOINT_ID", (object?)request.Action.EndpointId ?? DBNull.Value),
|
||||
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?)(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),
|
||||
new SqlParameter("@pACTION_POST_SQL", (object?)request.Action.PostSql ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_ERROR_ACTION_ID", (object?)request.Action.ErrorActionId ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_PROFILE_ID", (object?)request.Action?.ProfileId ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_ACTIVE", (object?)request.Action?.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_SEQUENCE", (object?)request.Action?.Sequence ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_ENDPOINT_ID", (object?)request.Action?.EndpointId ?? DBNull.Value),
|
||||
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?)(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),
|
||||
new SqlParameter("@pACTION_POST_SQL", (object?)request.Action?.PostSql ?? DBNull.Value),
|
||||
new SqlParameter("@pACTION_ERROR_ACTION_ID", (object?)request.Action?.ErrorActionId ?? DBNull.Value),
|
||||
|
||||
new SqlParameter("@pENDPOINT_ACTIVE", (object?)request.Endpoint.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_DESCRIPTION", (object?)request.Endpoint.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_URI", (object?)request.Endpoint.Uri ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_ACTIVE", (object?)request.Endpoint?.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_DESCRIPTION", (object?)request.Endpoint?.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_URI", (object?)request.Endpoint?.Uri ?? DBNull.Value),
|
||||
|
||||
new SqlParameter("@pENDPOINT_AUTH_ACTIVE", (object?)request.EndpointAuth.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_DESCRIPTION", (object?)request.EndpointAuth.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_TYPE_ID", (object?)request.EndpointAuth.TypeId ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_API_KEY", (object?)request.EndpointAuth.ApiKey ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_API_VALUE", (object?)request.EndpointAuth.ApiValue ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_API_KEY_ADD_TO_ID", (object?)request.EndpointAuth.ApiKeyAddToId ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_TOKEN", (object?)request.EndpointAuth.Token ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_USERNAME", (object?)request.EndpointAuth.Username ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_PASSWORD", (object?)request.EndpointAuth.Password ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_DOMAIN", (object?)request.EndpointAuth.Domain ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_WORKSTATION", (object?)request.EndpointAuth.Workstation ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_ACTIVE", (object?)request.EndpointAuth?.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_DESCRIPTION", (object?)request.EndpointAuth?.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_TYPE_ID", (object?)request.EndpointAuth?.TypeId ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_API_KEY", (object?)request.EndpointAuth?.ApiKey ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_API_VALUE", (object?)request.EndpointAuth?.ApiValue ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_API_KEY_ADD_TO_ID", (object?)request.EndpointAuth?.ApiKeyAddToId ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_TOKEN", (object?)request.EndpointAuth?.Token ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_USERNAME", (object?)request.EndpointAuth?.Username ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_PASSWORD", (object?)request.EndpointAuth?.Password ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_DOMAIN", (object?)request.EndpointAuth?.Domain ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_AUTH_WORKSTATION", (object?)request.EndpointAuth?.Workstation ?? DBNull.Value),
|
||||
|
||||
new SqlParameter("@pPROFILE_ACTIVE", (object?)request.Profile.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_TYPE_ID", (object?)request.Profile.TypeId ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_MANDANTOR", (object?)request.Profile.Mandantor ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_NAME", (object?)request.Profile.Name ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_DESCRIPTION", (object?)request.Profile.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_LOG_LEVEL_ID", (object?)request.Profile.LogLevelId ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_LANGUAGE_ID", (object?)request.Profile.LanguageId ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_ACTIVE", (object?)request.Profile?.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_TYPE_ID", (object?)request.Profile?.TypeId ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_MANDANTOR", (object?)request.Profile?.Mandantor ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_NAME", (object?)request.Profile?.Name ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_DESCRIPTION", (object?)request.Profile?.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_LOG_LEVEL_ID", (object?)request.Profile?.LogLevelId ?? DBNull.Value),
|
||||
new SqlParameter("@pPROFILE_LANGUAGE_ID", (object?)request.Profile?.LanguageId ?? DBNull.Value),
|
||||
|
||||
new SqlParameter("@pRESULT_ACTION_ID", (object?)request.Result.ActionId ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_STATUS_ID", (object?)request.Result.StatusId ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_HEADER", (object?)request.Result.Header ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_BODY", (object?)request.Result.Body ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_ACTION_ID", (object?)request.Result?.ActionId ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_STATUS_ID", (object?)request.Result?.StatusId ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_HEADER", (object?)request.Result?.Header ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_BODY", (object?)request.Result?.Body ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_INFO", (object?)request.Result?.Info ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_ERROR", (object?)request.Result?.Error ?? DBNull.Value),
|
||||
new SqlParameter("@pRESULT_TYPE_ID", (object?)(byte?)request.Result?.Type ?? DBNull.Value),
|
||||
|
||||
new SqlParameter("@pENDPOINT_PARAMS_ACTIVE", (object?)request.EndpointParams.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_DESCRIPTION", (object?)request.EndpointParams.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_GROUP_ID", (object?)request.EndpointParams.GroupId ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_SEQUENCE", (object?)request.EndpointParams.Sequence ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_KEY", (object?)request.EndpointParams.Key ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_VALUE", (object?)request.EndpointParams.Value ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_ACTIVE", (object?)request.EndpointParams?.Active ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_DESCRIPTION", (object?)request.EndpointParams?.Description ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_GROUP_ID", (object?)request.EndpointParams?.GroupId ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_SEQUENCE", (object?)request.EndpointParams?.Sequence ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_KEY", (object?)request.EndpointParams?.Key ?? DBNull.Value),
|
||||
new SqlParameter("@pENDPOINT_PARAMS_VALUE", (object?)request.EndpointParams?.Value ?? DBNull.Value),
|
||||
|
||||
new SqlParameter
|
||||
{
|
||||
@@ -123,7 +113,7 @@ public class InsertObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlE
|
||||
"@pENDPOINT_ACTIVE, @pENDPOINT_DESCRIPTION, @pENDPOINT_URI, " +
|
||||
"@pENDPOINT_AUTH_ACTIVE, @pENDPOINT_AUTH_DESCRIPTION, @pENDPOINT_AUTH_TYPE_ID, @pENDPOINT_AUTH_API_KEY, @pENDPOINT_AUTH_API_VALUE, @pENDPOINT_AUTH_API_KEY_ADD_TO_ID, @pENDPOINT_AUTH_TOKEN, @pENDPOINT_AUTH_USERNAME, @pENDPOINT_AUTH_PASSWORD, @pENDPOINT_AUTH_DOMAIN, @pENDPOINT_AUTH_WORKSTATION, " +
|
||||
"@pPROFILE_ACTIVE, @pPROFILE_TYPE_ID, @pPROFILE_MANDANTOR, @pPROFILE_NAME, @pPROFILE_DESCRIPTION, @pPROFILE_LOG_LEVEL_ID, @pPROFILE_LANGUAGE_ID, " +
|
||||
"@pRESULT_ACTION_ID, @pRESULT_STATUS_ID, @pRESULT_HEADER, @pRESULT_BODY, " +
|
||||
"@pRESULT_ACTION_ID, @pRESULT_STATUS_ID, @pRESULT_HEADER, @pRESULT_BODY, @pRESULT_INFO, @pRESULT_ERROR, @pRESULT_TYPE_ID, " +
|
||||
"@pENDPOINT_PARAMS_ACTIVE, @pENDPOINT_PARAMS_DESCRIPTION, @pENDPOINT_PARAMS_GROUP_ID, @pENDPOINT_PARAMS_SEQUENCE, @pENDPOINT_PARAMS_KEY, @pENDPOINT_PARAMS_VALUE, " +
|
||||
"@oGUID OUTPUT",
|
||||
parameters,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record UpdateActionProcedure : IUpdateProcedure
|
||||
public record UpdateActionDto
|
||||
{
|
||||
public long? ProfileId { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
@@ -17,14 +15,4 @@ public record UpdateActionProcedure : IUpdateProcedure
|
||||
public string? BodySql { get; set; }
|
||||
public string? PostSql { get; set; }
|
||||
public byte? ErrorActionId { get; set; }
|
||||
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
|
||||
{
|
||||
return new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ACTION",
|
||||
Id = id,
|
||||
Action = this
|
||||
}.ChangedBy(changedWho);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
public record InsertEndpointAuthProcedure : IInsertProcedure
|
||||
public record UpdateEndpointAuthDto
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
@@ -15,13 +13,4 @@ public record InsertEndpointAuthProcedure : IInsertProcedure
|
||||
public string? Password { get; set; }
|
||||
public string? Domain { get; set; }
|
||||
public string? Workstation { get; set; }
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_AUTH",
|
||||
EndpointAuth = this
|
||||
}.AddedBy(addedWho);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
public record UpdateEndpointDto
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Uri { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
public record UpdateEndpointParamsDto
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public short? GroupId { get; set; }
|
||||
public byte? Sequence { get; set; }
|
||||
public string? Key { get; set; }
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
public record UpdateProfileDto
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? Mandantor { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? LogLevelId { get; set; }
|
||||
public short? LanguageId { get; set; }
|
||||
public DateTime? FirstRun { get; set; }
|
||||
public DateTime? LastRun { get; set; }
|
||||
public string? LastResult { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
public record UpdateResultDto
|
||||
{
|
||||
public long? ActionId { get; set; }
|
||||
public short? StatusId { get; set; }
|
||||
public string? Header { get; set; }
|
||||
public string? Body { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
using MediatR;
|
||||
|
||||
namespace ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
public interface IUpdateProcedure
|
||||
public interface IUpdateProcedure<T> : IRequest<int>
|
||||
{
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null);
|
||||
public long Id { get; set; }
|
||||
|
||||
public T Data { get; set; }
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.Common.Options;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
using ReC.Application.EndpointAuth.Commands;
|
||||
using ReC.Application.EndpointParams.Commands;
|
||||
using ReC.Application.Endpoints.Commands;
|
||||
@@ -26,28 +27,15 @@ public record UpdateObjectProcedure : IRequest<int>
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
internal string? ChangedWho { get; private set; }
|
||||
//TODO: update to set in authentication middleware or similar, and remove from procedure properties
|
||||
internal string? ChangedWho { get; private set; } = "ReC.API";
|
||||
|
||||
public UpdateObjectProcedure ChangedBy(string? changedWho = null)
|
||||
{
|
||||
ChangedWho = changedWho ?? "ReC.API";
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateActionProcedure Action { get; set; } = new();
|
||||
public UpdateEndpointProcedure Endpoint { get; set; } = new();
|
||||
public UpdateEndpointAuthProcedure EndpointAuth { get; set; } = new();
|
||||
public UpdateProfileProcedure Profile { get; set; } = new();
|
||||
public UpdateResultProcedure Result { get; set; } = new();
|
||||
public UpdateEndpointParamsProcedure EndpointParams { get; set; } = new();
|
||||
}
|
||||
|
||||
public static class UpdateObjectProcedureExtensions
|
||||
{
|
||||
public static Task<int> ExecuteUpdateProcedure(this ISender sender, IUpdateProcedure procedure, long id, string? changedWho = null, CancellationToken cancel = default)
|
||||
{
|
||||
return sender.Send(procedure.ToObjectProcedure(id, changedWho ?? "ReC.API"), cancel);
|
||||
}
|
||||
public UpdateActionDto Action { get; set; } = new();
|
||||
public UpdateEndpointDto Endpoint { get; set; } = new();
|
||||
public UpdateEndpointAuthDto EndpointAuth { get; set; } = new();
|
||||
public UpdateProfileDto Profile { get; set; } = new();
|
||||
public UpdateResultDto Result { get; set; } = new();
|
||||
public UpdateEndpointParamsDto EndpointParams { get; set; } = new();
|
||||
}
|
||||
|
||||
public class UpdateObjectProcedureHandler(IRepository repo, IOptionsMonitor<SqlExceptionOptions> sqlExOpt) : IRequestHandler<UpdateObjectProcedure, int>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using ReC.Application.Common.Behaviors;
|
||||
using ReC.Application.Common.Behaviors.InvokeAction;
|
||||
using ReC.Application.Common.Constants;
|
||||
using ReC.Application.Common.Options;
|
||||
using ReC.Application.Common.Procedures;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ReC.Application;
|
||||
@@ -35,6 +35,8 @@ public static class DependencyInjection
|
||||
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
|
||||
cfg.AddOpenBehaviors([typeof(BodyQueryBehavior<,>), typeof(HeaderQueryBehavior<,>)]);
|
||||
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
||||
cfg.AddBehavior(typeof(IPipelineBehavior<InvokeRecActionViewCommand, Unit>), typeof(PostprocessingBehavior));
|
||||
cfg.AddBehavior(typeof(IPipelineBehavior<InvokeRecActionViewCommand, Unit>), typeof(PreprocessingBehavior));
|
||||
cfg.LicenseKey = configOpt.LuckyPennySoftwareLicenseKey;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
public record DeleteEndpointAuthProcedure : IDeleteProcedure
|
||||
public record DeleteEndpointAuthCommand : IDeleteProcedure
|
||||
{
|
||||
/// <summary>
|
||||
/// Start GUID/ID (inclusive)
|
||||
@@ -18,15 +19,18 @@ public record DeleteEndpointAuthProcedure : IDeleteProcedure
|
||||
/// If true, delete even if dependent ACTION data exists
|
||||
/// </summary>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public DeleteObjectProcedure ToObjectProcedure()
|
||||
public class DeleteEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointAuthCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteEndpointAuthCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new DeleteObjectProcedure
|
||||
return await sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_AUTH",
|
||||
Start = Start,
|
||||
End = End,
|
||||
Force = Force
|
||||
};
|
||||
Start = request.Start,
|
||||
End = request.End,
|
||||
Force = request.Force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
public record UpdateEndpointAuthProcedure : IUpdateProcedure
|
||||
public record InsertEndpointAuthCommand : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
@@ -15,14 +16,16 @@ public record UpdateEndpointAuthProcedure : IUpdateProcedure
|
||||
public string? Password { get; set; }
|
||||
public string? Domain { get; set; }
|
||||
public string? Workstation { get; set; }
|
||||
}
|
||||
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
|
||||
public class InsertEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointAuthCommand, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertEndpointAuthCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new UpdateObjectProcedure
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_AUTH",
|
||||
Id = id,
|
||||
EndpointAuth = this
|
||||
}.ChangedBy(changedWho);
|
||||
EndpointAuth = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.EndpointAuth.Commands;
|
||||
|
||||
public record UpdateEndpointAuthCommand : IUpdateProcedure<UpdateEndpointAuthDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public UpdateEndpointAuthDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateEndpointAuthProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointAuthCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(UpdateEndpointAuthCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_AUTH",
|
||||
Id = request.Id,
|
||||
EndpointAuth = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointParams.Commands;
|
||||
|
||||
public record DeleteEndpointParamsProcedure : IDeleteProcedure
|
||||
public record DeleteEndpointParamsCommand : IDeleteProcedure
|
||||
{
|
||||
/// <summary>
|
||||
/// Start GUID/ID (inclusive)
|
||||
@@ -18,15 +19,18 @@ public record DeleteEndpointParamsProcedure : IDeleteProcedure
|
||||
/// If true, delete even if dependent ACTION data exists
|
||||
/// </summary>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public DeleteObjectProcedure ToObjectProcedure()
|
||||
public class DeleteEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointParamsCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteEndpointParamsCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new DeleteObjectProcedure
|
||||
return await sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_PARAMS",
|
||||
Start = Start,
|
||||
End = End,
|
||||
Force = Force
|
||||
};
|
||||
Start = request.Start,
|
||||
End = request.End,
|
||||
Force = request.Force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointParams.Commands;
|
||||
|
||||
public record InsertEndpointParamsCommand : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public short? GroupId { get; set; }
|
||||
public byte? Sequence { get; set; }
|
||||
public string? Key { get; set; }
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
|
||||
public class InsertEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointParamsCommand, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertEndpointParamsCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_PARAMS",
|
||||
EndpointParams = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointParams.Commands;
|
||||
|
||||
public record InsertEndpointParamsProcedure : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public short? GroupId { get; set; }
|
||||
public byte? Sequence { get; set; }
|
||||
public string? Key { get; set; }
|
||||
public string? Value { get; set; }
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_PARAMS",
|
||||
EndpointParams = this
|
||||
}.AddedBy(addedWho);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.EndpointParams.Commands;
|
||||
|
||||
public record UpdateEndpointParamsCommand : IUpdateProcedure<UpdateEndpointParamsDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public UpdateEndpointParamsDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateEndpointParamsProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointParamsCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(UpdateEndpointParamsCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_PARAMS",
|
||||
Id = request.Id,
|
||||
EndpointParams = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
namespace ReC.Application.EndpointParams.Commands;
|
||||
|
||||
public record UpdateEndpointParamsProcedure : IUpdateProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public short? GroupId { get; set; }
|
||||
public byte? Sequence { get; set; }
|
||||
public string? Key { get; set; }
|
||||
public string? Value { get; set; }
|
||||
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
|
||||
{
|
||||
return new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT_PARAMS",
|
||||
Id = id,
|
||||
EndpointParams = this
|
||||
}.ChangedBy(changedWho);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record DeleteEndpointProcedure : IDeleteProcedure
|
||||
public record DeleteEndpointCommand : IDeleteProcedure
|
||||
{
|
||||
/// <summary>
|
||||
/// Start GUID/ID (inclusive)
|
||||
@@ -18,15 +19,18 @@ public record DeleteEndpointProcedure : IDeleteProcedure
|
||||
/// If true, delete even if dependent ACTION data exists
|
||||
/// </summary>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public DeleteObjectProcedure ToObjectProcedure()
|
||||
public class DeleteEndpointProcedureHandler(ISender sender) : IRequestHandler<DeleteEndpointCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteEndpointCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new DeleteObjectProcedure
|
||||
return await sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT",
|
||||
Start = Start,
|
||||
End = End,
|
||||
Force = Force
|
||||
};
|
||||
Start = request.Start,
|
||||
End = request.End,
|
||||
Force = request.Force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record InsertEndpointCommand : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Uri { get; set; }
|
||||
}
|
||||
|
||||
public class InsertEndpointProcedureHandler(ISender sender) : IRequestHandler<InsertEndpointCommand, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertEndpointCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT",
|
||||
Endpoint = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record InsertEndpointProcedure : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Uri { get; set; }
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT",
|
||||
Endpoint = this
|
||||
}.AddedBy(addedWho);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record UpdateEndpointCommand : IUpdateProcedure<UpdateEndpointDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public UpdateEndpointDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateEndpointProcedureHandler(ISender sender) : IRequestHandler<UpdateEndpointCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(UpdateEndpointCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT",
|
||||
Id = request.Id,
|
||||
Endpoint = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
namespace ReC.Application.Endpoints.Commands;
|
||||
|
||||
public record UpdateEndpointProcedure : IUpdateProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Uri { get; set; }
|
||||
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
|
||||
{
|
||||
return new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ENDPOINT",
|
||||
Id = id,
|
||||
Endpoint = this
|
||||
}.ChangedBy(changedWho);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
namespace ReC.Application.Profile.Commands;
|
||||
|
||||
public record DeleteProfileProcedure : IDeleteProcedure
|
||||
public record DeleteProfileCommand : IDeleteProcedure
|
||||
{
|
||||
/// <summary>
|
||||
/// Start GUID/ID (inclusive)
|
||||
@@ -18,15 +19,18 @@ public record DeleteProfileProcedure : IDeleteProcedure
|
||||
/// If true, delete even if dependent ACTION data exists
|
||||
/// </summary>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public DeleteObjectProcedure ToObjectProcedure()
|
||||
public class DeleteProfileProcedureHandler(ISender sender) : IRequestHandler<DeleteProfileCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteProfileCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new DeleteObjectProcedure
|
||||
return await sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = "PROFILE",
|
||||
Start = Start,
|
||||
End = End,
|
||||
Force = Force
|
||||
};
|
||||
Start = request.Start,
|
||||
End = request.End,
|
||||
Force = request.Force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
27
src/ReC.Application/Profile/Commands/InsertProfileCommand.cs
Normal file
27
src/ReC.Application/Profile/Commands/InsertProfileCommand.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.Profile.Commands;
|
||||
|
||||
public record InsertProfileCommand : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? Mandantor { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? LogLevelId { get; set; }
|
||||
public short? LanguageId { get; set; }
|
||||
}
|
||||
|
||||
public class InsertProfileProcedureHandler(ISender sender) : IRequestHandler<InsertProfileCommand, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertProfileCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "PROFILE",
|
||||
Profile = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.Profile.Commands;
|
||||
|
||||
public record InsertProfileProcedure : IInsertProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? Mandantor { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? LogLevelId { get; set; }
|
||||
public short? LanguageId { get; set; }
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
{
|
||||
Entity = "PROFILE",
|
||||
Profile = this
|
||||
}.AddedBy(addedWho);
|
||||
}
|
||||
}
|
||||
25
src/ReC.Application/Profile/Commands/UpdateProfileCommand.cs
Normal file
25
src/ReC.Application/Profile/Commands/UpdateProfileCommand.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.Profile.Commands;
|
||||
|
||||
public record UpdateProfileCommand : IUpdateProcedure<UpdateProfileDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public UpdateProfileDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateProfileProcedureHandler(ISender sender) : IRequestHandler<UpdateProfileCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(UpdateProfileCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "PROFILE",
|
||||
Id = request.Id,
|
||||
Profile = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
namespace ReC.Application.Profile.Commands;
|
||||
|
||||
public record UpdateProfileProcedure : IUpdateProcedure
|
||||
{
|
||||
public bool? Active { get; set; }
|
||||
public byte? TypeId { get; set; }
|
||||
public string? Mandantor { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public byte? LogLevelId { get; set; }
|
||||
public short? LanguageId { get; set; }
|
||||
public DateTime? FirstRun { get; set; }
|
||||
public DateTime? LastRun { get; set; }
|
||||
public string? LastResult { get; set; }
|
||||
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
|
||||
{
|
||||
return new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "PROFILE",
|
||||
Id = id,
|
||||
Profile = this
|
||||
}.ChangedBy(changedWho);
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,9 @@
|
||||
<ProjectReference Include="..\ReC.Domain\ReC.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Common\Behaviors\Action\" />
|
||||
<Folder Include="Common\Options\DbModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record DeleteActionProcedure : IDeleteProcedure
|
||||
public record DeleteActionCommand : IDeleteProcedure
|
||||
{
|
||||
/// <summary>
|
||||
/// Start GUID/ID (inclusive)
|
||||
@@ -18,15 +19,18 @@ public record DeleteActionProcedure : IDeleteProcedure
|
||||
/// If true, delete even if dependent RESULT data exists
|
||||
/// </summary>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public DeleteObjectProcedure ToObjectProcedure()
|
||||
public class DeleteActionProcedureHandler(ISender sender) : IRequestHandler<DeleteActionCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteActionCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new DeleteObjectProcedure
|
||||
return await sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = "ACTION",
|
||||
Start = Start,
|
||||
End = End,
|
||||
Force = Force
|
||||
};
|
||||
Start = request.Start,
|
||||
End = request.End,
|
||||
Force = request.Force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record InsertActionProcedure : IInsertProcedure
|
||||
public record InsertActionCommand : IInsertProcedure
|
||||
{
|
||||
public long? ProfileId { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
@@ -18,13 +19,16 @@ public record InsertActionProcedure : IInsertProcedure
|
||||
public string? BodySql { get; set; }
|
||||
public string? PostSql { get; set; }
|
||||
public byte? ErrorActionId { get; set; }
|
||||
}
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
public class InsertActionProcedureHandler(ISender sender) : IRequestHandler<InsertActionCommand, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertActionCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "ACTION",
|
||||
Action = this
|
||||
}.AddedBy(addedWho);
|
||||
Action = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
using MediatR;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.RecActions.Queries;
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
@@ -10,13 +11,7 @@ public record InvokeBatchRecActionViewsCommand : IRequest
|
||||
public long ProfileId { get; init; }
|
||||
}
|
||||
|
||||
public static class InvokeBatchRecActionViewsCommandExtensions
|
||||
{
|
||||
public static Task InvokeBatchRecActionView(this ISender sender, long profileId, CancellationToken cancel = default)
|
||||
=> sender.Send(new InvokeBatchRecActionViewsCommand { ProfileId = profileId }, cancel);
|
||||
}
|
||||
|
||||
public class InvokeRecActionViewsCommandHandler(ISender sender) : IRequestHandler<InvokeBatchRecActionViewsCommand>
|
||||
public class InvokeRecActionViewsCommandHandler(ISender sender, ILogger<InvokeRecActionViewsCommandHandler>? logger = null) : IRequestHandler<InvokeBatchRecActionViewsCommand>
|
||||
{
|
||||
public async Task Handle(InvokeBatchRecActionViewsCommand request, CancellationToken cancel)
|
||||
{
|
||||
@@ -24,15 +19,34 @@ public class InvokeRecActionViewsCommandHandler(ISender sender) : IRequestHandle
|
||||
|
||||
foreach (var action in actions)
|
||||
{
|
||||
var ok = await sender.Send(new InvokeRecActionViewCommand() { Action = action }, cancel);
|
||||
if (!ok)
|
||||
try
|
||||
{
|
||||
await sender.Send(new InvokeRecActionViewCommand() { Action = action }, cancel);
|
||||
}
|
||||
catch (RecActionException ex)
|
||||
{
|
||||
switch (action.ErrorAction)
|
||||
{
|
||||
case ErrorAction.Continue:
|
||||
logger?.LogWarning(ex, "Rec action failed but continuing. ActionId: {ActionId}, ProfileId: {ProfileId}", ex.ActionId, ex.ProfileId);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
// Rethrow the exception to stop processing further actions
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
switch (action.ErrorAction)
|
||||
{
|
||||
case ErrorAction.Continue:
|
||||
logger?.LogError(ex, "Unexpected error during rec action. ActionId: {ActionId}, ProfileId: {ProfileId}", action.Id, action.ProfileId);
|
||||
break;
|
||||
default:
|
||||
// Rethrow the exception to stop processing further actions
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using MediatR;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using ReC.Application.Common;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ReC.Application.Common.Constants;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Options;
|
||||
using ReC.Application.Results.Commands;
|
||||
using ReC.Domain.Constants;
|
||||
using System.Net;
|
||||
@@ -14,125 +14,161 @@ using System.Text.Json;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record InvokeRecActionViewCommand : IRequest<bool>
|
||||
public record InvokeRecActionViewCommand : IRequest
|
||||
{
|
||||
public RecActionViewDto Action { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class InvokeRecActionViewCommandHandler(
|
||||
IOptions<RecActionOptions> options,
|
||||
ISender sender,
|
||||
IHttpClientFactory clientFactory,
|
||||
IConfiguration? config = null
|
||||
) : IRequestHandler<InvokeRecActionViewCommand, bool>
|
||||
) : IRequestHandler<InvokeRecActionViewCommand>
|
||||
{
|
||||
public async Task<bool> Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
|
||||
private readonly RecActionOptions _options = options.Value;
|
||||
|
||||
public async Task Handle(InvokeRecActionViewCommand request, CancellationToken cancel)
|
||||
{
|
||||
var action = request.Action;
|
||||
HttpClient? ntlmClient = null;
|
||||
|
||||
using var http = clientFactory.CreateClient(Http.ClientName);
|
||||
|
||||
if (action.RestType is not RestType restType)
|
||||
throw new DataIntegrityException(
|
||||
$"Rec action could not be invoked because the RestType value is null. " +
|
||||
$"ProfileId: {action.ProfileId}, " +
|
||||
$"Id: {action.Id}"
|
||||
);
|
||||
|
||||
using var httpReq = CreateHttpRequestMessage(restType, action.EndpointUri);
|
||||
|
||||
if (action.Body is not null)
|
||||
httpReq.Content = new StringContent(action.Body);
|
||||
|
||||
if (action.Headers is not null)
|
||||
foreach (var header in action.Headers)
|
||||
httpReq.Headers.Add(header.Key, header.Value);
|
||||
|
||||
switch (action.EndpointAuthType)
|
||||
try
|
||||
{
|
||||
case EndpointAuthType.NoAuth:
|
||||
break;
|
||||
|
||||
case EndpointAuthType.ApiKey:
|
||||
if (action.EndpointAuthApiKey is string apiKey && action.EndpointAuthApiValue is string apiValue)
|
||||
{
|
||||
switch (action.EndpointAuthApiKeyAddTo)
|
||||
{
|
||||
case ApiKeyLocation.Header:
|
||||
httpReq.Headers.Add(apiKey, apiValue);
|
||||
break;
|
||||
case ApiKeyLocation.Query:
|
||||
var uriBuilder = new UriBuilder(httpReq.RequestUri!);
|
||||
var query = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
query[apiKey] = apiValue;
|
||||
uriBuilder.Query = query.ToString();
|
||||
httpReq.RequestUri = uriBuilder.Uri;
|
||||
break;
|
||||
default:
|
||||
throw new DataIntegrityException(
|
||||
$"The API key location '{action.EndpointAuthApiKeyAddTo}' is not supported. " +
|
||||
$"ProfileId: {action.ProfileId}, " +
|
||||
$"Id: {action.Id}"
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EndpointAuthType.BearerToken:
|
||||
case EndpointAuthType.JwtBearer:
|
||||
case EndpointAuthType.OAuth2:
|
||||
if (action.EndpointAuthToken is string authToken)
|
||||
httpReq.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authToken);
|
||||
break;
|
||||
|
||||
case EndpointAuthType.BasicAuth:
|
||||
if (action.EndpointAuthUsername is string authUsername && action.EndpointAuthPassword is string authPassword)
|
||||
{
|
||||
var basicAuth = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{authUsername}:{authPassword}"));
|
||||
httpReq.Headers.Authorization = new AuthenticationHeaderValue("Basic", basicAuth);
|
||||
}
|
||||
break;
|
||||
|
||||
case EndpointAuthType.NtlmAuth:
|
||||
if (!string.IsNullOrWhiteSpace(action.EndpointAuthUsername))
|
||||
{
|
||||
var credentials = new NetworkCredential(
|
||||
action.EndpointAuthUsername,
|
||||
action.EndpointAuthPassword,
|
||||
action.EndpointAuthDomain);
|
||||
var credentialCache = new CredentialCache { { httpReq.RequestUri!, "NTLM", credentials } };
|
||||
httpReq.Options.Set(new HttpRequestOptionsKey<CredentialCache>("Credentials"), credentialCache);
|
||||
}
|
||||
break;
|
||||
|
||||
case EndpointAuthType.DigestAuth:
|
||||
case EndpointAuthType.OAuth1:
|
||||
case EndpointAuthType.AwsSignature:
|
||||
// These authentication methods require more complex implementations,
|
||||
// often involving multi-step handshakes or specialized libraries.
|
||||
// They are left as placeholders for future implementation.
|
||||
default:
|
||||
throw new NotImplementedException(
|
||||
$"The authentication type '{action.EndpointAuthType}' is not supported yet. " +
|
||||
if (action.RestType is not RestType restType)
|
||||
throw new DataIntegrityException(
|
||||
$"Rec action could not be invoked because the RestType value is null. " +
|
||||
$"ProfileId: {action.ProfileId}, " +
|
||||
$"Id: {action.Id}"
|
||||
);
|
||||
|
||||
using var httpReq = CreateHttpRequestMessage(restType, action.EndpointUri);
|
||||
|
||||
if (action.Body is not null)
|
||||
httpReq.Content = new StringContent(action.Body);
|
||||
|
||||
if (action.Headers is not null)
|
||||
foreach (var header in action.Headers)
|
||||
httpReq.Headers.Add(header.Key, header.Value);
|
||||
|
||||
switch (action.EndpointAuthType)
|
||||
{
|
||||
case EndpointAuthType.NoAuth:
|
||||
break;
|
||||
|
||||
case EndpointAuthType.ApiKey:
|
||||
if (action.EndpointAuthApiKey is string apiKey && action.EndpointAuthApiValue is string apiValue)
|
||||
{
|
||||
switch (action.EndpointAuthApiKeyAddTo)
|
||||
{
|
||||
case ApiKeyLocation.Header:
|
||||
httpReq.Headers.Add(apiKey, apiValue);
|
||||
break;
|
||||
case ApiKeyLocation.Query:
|
||||
var uriBuilder = new UriBuilder(httpReq.RequestUri!);
|
||||
var query = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
query[apiKey] = apiValue;
|
||||
uriBuilder.Query = query.ToString();
|
||||
httpReq.RequestUri = uriBuilder.Uri;
|
||||
break;
|
||||
default:
|
||||
throw new DataIntegrityException(
|
||||
$"The API key location '{action.EndpointAuthApiKeyAddTo}' is not supported. " +
|
||||
$"ProfileId: {action.ProfileId}, " +
|
||||
$"Id: {action.Id}"
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EndpointAuthType.BearerToken:
|
||||
case EndpointAuthType.JwtBearer:
|
||||
case EndpointAuthType.OAuth2:
|
||||
if (action.EndpointAuthToken is string authToken)
|
||||
httpReq.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authToken);
|
||||
break;
|
||||
|
||||
case EndpointAuthType.BasicAuth:
|
||||
if (action.EndpointAuthUsername is string authUsername && action.EndpointAuthPassword is string authPassword)
|
||||
{
|
||||
var basicAuth = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{authUsername}:{authPassword}"));
|
||||
httpReq.Headers.Authorization = new AuthenticationHeaderValue("Basic", basicAuth);
|
||||
}
|
||||
break;
|
||||
|
||||
case EndpointAuthType.NtlmAuth:
|
||||
if (!string.IsNullOrWhiteSpace(action.EndpointAuthUsername))
|
||||
{
|
||||
if (_options.UseHttp1ForNtlm)
|
||||
{
|
||||
httpReq.Version = HttpVersion.Version11;
|
||||
httpReq.VersionPolicy = HttpVersionPolicy.RequestVersionExact;
|
||||
}
|
||||
var endpointAuthPassword = action.EndpointAuthPassword
|
||||
#if DEBUG
|
||||
?.Replace("%NTLM_PW%", config?.GetValue<string>("%NTLM_PW%"))
|
||||
#endif
|
||||
;
|
||||
var credentials = new NetworkCredential(
|
||||
action.EndpointAuthUsername,
|
||||
endpointAuthPassword,
|
||||
action.EndpointAuthDomain);
|
||||
var credentialCache = new CredentialCache { { httpReq.RequestUri!, "NTLM", credentials } };
|
||||
var ntlmHandler = new HttpClientHandler
|
||||
{
|
||||
Credentials = credentialCache,
|
||||
UseDefaultCredentials = false
|
||||
};
|
||||
ntlmClient = new HttpClient(ntlmHandler, disposeHandler: true);
|
||||
}
|
||||
break;
|
||||
|
||||
case EndpointAuthType.DigestAuth:
|
||||
case EndpointAuthType.OAuth1:
|
||||
case EndpointAuthType.AwsSignature:
|
||||
// These authentication methods require more complex implementations,
|
||||
// often involving multi-step handshakes or specialized libraries.
|
||||
// They are left as placeholders for future implementation.
|
||||
default:
|
||||
throw new NotImplementedException(
|
||||
$"The authentication type '{action.EndpointAuthType}' is not supported yet. " +
|
||||
$"ProfileId: {action.ProfileId}, " +
|
||||
$"Id: {action.Id}"
|
||||
);
|
||||
}
|
||||
|
||||
var http = ntlmClient ?? clientFactory.CreateClient(Http.ClientName);
|
||||
using var response = await http.SendAsync(httpReq, cancel);
|
||||
var resBody = await response.Content.ReadAsStringAsync(cancel);
|
||||
var resHeaders = response.Headers.ToDictionary();
|
||||
|
||||
var statusCode = (short)response.StatusCode;
|
||||
|
||||
await sender.Send(new InsertResultCommand()
|
||||
{
|
||||
StatusId = statusCode,
|
||||
ActionId = action.Id,
|
||||
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
|
||||
Body = resBody,
|
||||
Type = ResultType.Main
|
||||
}, cancel);
|
||||
}
|
||||
|
||||
using var response = await http.SendAsync(httpReq, cancel);
|
||||
var resBody = await response.Content.ReadAsStringAsync(cancel);
|
||||
var resHeaders = response.Headers.ToDictionary();
|
||||
|
||||
var statusCode = (short)response.StatusCode;
|
||||
|
||||
await sender.ExecuteInsertProcedure(new InsertResultProcedure()
|
||||
catch(Exception ex)
|
||||
{
|
||||
StatusId = statusCode,
|
||||
ActionId = action.Id,
|
||||
Header = JsonSerializer.Serialize(resHeaders, options: new() { WriteIndented = false }),
|
||||
Body = resBody
|
||||
}, config?["AddedWho"], cancel);
|
||||
await sender.Send(new InsertResultCommand()
|
||||
{
|
||||
ActionId = action.Id,
|
||||
Error = ex.ToString(),
|
||||
Type = ResultType.Main
|
||||
}, cancel);
|
||||
|
||||
return response.IsSuccessStatusCode;
|
||||
if (action.ErrorAction == ErrorAction.Stop)
|
||||
throw new RecActionException(action.Id, action.ProfileId, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ntlmClient?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static HttpRequestMessage CreateHttpRequestMessage(RestType restType, string? endpointUri)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.RecActions.Commands;
|
||||
|
||||
public record UpdateActionCommand : IUpdateProcedure<UpdateActionDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public UpdateActionDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateActionProcedureHandler(ISender sender) : IRequestHandler<UpdateActionCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(UpdateActionCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "ACTION",
|
||||
Id = request.Id,
|
||||
Action = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
|
||||
namespace ReC.Application.Results.Commands;
|
||||
|
||||
public record DeleteResultProcedure : IDeleteProcedure
|
||||
public record DeleteResultCommand : IDeleteProcedure
|
||||
{
|
||||
/// <summary>
|
||||
/// Start GUID/ID (inclusive)
|
||||
@@ -18,15 +19,18 @@ public record DeleteResultProcedure : IDeleteProcedure
|
||||
/// Force parameter (not used for RESULT entity as it has no dependencies)
|
||||
/// </summary>
|
||||
public bool Force { get; set; }
|
||||
}
|
||||
|
||||
public DeleteObjectProcedure ToObjectProcedure()
|
||||
public class DeleteResultProcedureHandler(ISender sender) : IRequestHandler<DeleteResultCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(DeleteResultCommand request, CancellationToken cancel)
|
||||
{
|
||||
return new DeleteObjectProcedure
|
||||
return await sender.Send(new DeleteObjectProcedure
|
||||
{
|
||||
Entity = "RESULT",
|
||||
Start = Start,
|
||||
End = End,
|
||||
Force = Force
|
||||
};
|
||||
Start = request.Start,
|
||||
End = request.End,
|
||||
Force = request.Force
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
28
src/ReC.Application/Results/Commands/InsertResultCommand.cs
Normal file
28
src/ReC.Application/Results/Commands/InsertResultCommand.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Domain.Constants;
|
||||
|
||||
namespace ReC.Application.Results.Commands;
|
||||
|
||||
public record InsertResultCommand : IInsertProcedure
|
||||
{
|
||||
public long? ActionId { get; set; }
|
||||
public short? StatusId { get; set; }
|
||||
public string? Header { get; set; }
|
||||
public string? Body { get; set; }
|
||||
public string? Info { get; set; }
|
||||
public string? Error { get; set; }
|
||||
public required ResultType Type { get; set; }
|
||||
}
|
||||
|
||||
public class InsertResultProcedureHandler(ISender sender) : IRequestHandler<InsertResultCommand, long>
|
||||
{
|
||||
public async Task<long> Handle(InsertResultCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new InsertObjectProcedure
|
||||
{
|
||||
Entity = "RESULT",
|
||||
Result = request
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
|
||||
namespace ReC.Application.Results.Commands;
|
||||
|
||||
public record InsertResultProcedure : IInsertProcedure
|
||||
{
|
||||
public long? ActionId { get; set; }
|
||||
public short? StatusId { get; set; }
|
||||
public string? Header { get; set; }
|
||||
public string? Body { get; set; }
|
||||
|
||||
public InsertObjectProcedure ToObjectProcedure(string? addedWho = null)
|
||||
{
|
||||
return new InsertObjectProcedure
|
||||
{
|
||||
Entity = "RESULT",
|
||||
Result = this
|
||||
}.AddedBy(addedWho ?? "Rec.API");
|
||||
}
|
||||
}
|
||||
25
src/ReC.Application/Results/Commands/UpdateResultCommand.cs
Normal file
25
src/ReC.Application/Results/Commands/UpdateResultCommand.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using MediatR;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure.Dto;
|
||||
|
||||
namespace ReC.Application.Results.Commands;
|
||||
|
||||
public record UpdateResultCommand : IUpdateProcedure<UpdateResultDto>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public UpdateResultDto Data { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UpdateResultProcedureHandler(ISender sender) : IRequestHandler<UpdateResultCommand, int>
|
||||
{
|
||||
public async Task<int> Handle(UpdateResultCommand request, CancellationToken cancel)
|
||||
{
|
||||
return await sender.Send(new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "RESULT",
|
||||
Id = request.Id,
|
||||
Result = request.Data
|
||||
}, cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
|
||||
namespace ReC.Application.Results.Commands;
|
||||
|
||||
public record UpdateResultProcedure : IUpdateProcedure
|
||||
{
|
||||
public long? ActionId { get; set; }
|
||||
public short? StatusId { get; set; }
|
||||
public string? Header { get; set; }
|
||||
public string? Body { get; set; }
|
||||
|
||||
public UpdateObjectProcedure ToObjectProcedure(long id, string? changedWho = null)
|
||||
{
|
||||
return new UpdateObjectProcedure
|
||||
{
|
||||
Entity = "RESULT",
|
||||
Id = id,
|
||||
Result = this
|
||||
}.ChangedBy(changedWho);
|
||||
}
|
||||
}
|
||||
8
src/ReC.Domain/Constants/ResultType.cs
Normal file
8
src/ReC.Domain/Constants/ResultType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace ReC.Domain.Constants;
|
||||
|
||||
public enum ResultType
|
||||
{
|
||||
Pre = 1,
|
||||
Main,
|
||||
Post
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace ReC.Domain.QueryOutput;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.QueryOutput;
|
||||
|
||||
public class BodyQueryResult
|
||||
{
|
||||
[Column("REQUEST_BODY")]
|
||||
public string? RawBody { get; init; }
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
namespace ReC.Domain.QueryOutput;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.QueryOutput;
|
||||
|
||||
public class HeaderQueryResult
|
||||
{
|
||||
[Column("REQUEST_HEADER")]
|
||||
public string? RawHeader { get; init; }
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ namespace ReC.Domain.QueryOutput;
|
||||
|
||||
public class InsertObjectResult
|
||||
{
|
||||
[Column("oGUID")]
|
||||
public required long NewObjectId { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using ReC.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Views;
|
||||
@@ -8,39 +9,58 @@ public record ProfileView
|
||||
{
|
||||
public virtual IEnumerable<RecActionView>? Actions { get; init; }
|
||||
|
||||
[Key]
|
||||
[Column("PROFILE_GUID")]
|
||||
public long Id { get; init; }
|
||||
|
||||
[Column("ACTIVE")]
|
||||
public bool Active { get; init; }
|
||||
|
||||
[Column("TYPE_ID")]
|
||||
public ProfileType TypeId { get; init; }
|
||||
|
||||
[Column("TYPE")]
|
||||
public string? Type { get; init; }
|
||||
|
||||
[Column("MANDANTOR")]
|
||||
public string? Mandantor { get; init; }
|
||||
|
||||
[Column("PROFILE_NAME")]
|
||||
public string? ProfileName { get; init; }
|
||||
|
||||
[Column("DESCRIPTION")]
|
||||
public string? Description { get; init; }
|
||||
|
||||
[Column("LOG_LEVEL_ID")]
|
||||
public byte LogLevelId { get; init; }
|
||||
|
||||
[Column("LOG_LEVEL")]
|
||||
public string? LogLevel { get; init; }
|
||||
|
||||
[Column("LANGUAGE_ID")]
|
||||
public short LanguageId { get; init; }
|
||||
|
||||
[Column("LANGUAGE")]
|
||||
public string? Language { get; init; }
|
||||
|
||||
[Column("ADDED_WHO")]
|
||||
public string? AddedWho { get; init; }
|
||||
|
||||
[Column("ADDED_WHEN")]
|
||||
public DateTime AddedWhen { get; init; }
|
||||
|
||||
[Column("CHANGED_WHO")]
|
||||
public string? ChangedWho { get; init; }
|
||||
|
||||
[Column("CHANGED_WHEN")]
|
||||
public DateTime? ChangedWhen { get; init; }
|
||||
|
||||
[Column("FIRST_RUN")]
|
||||
public DateTime? FirstRun { get; init; }
|
||||
|
||||
[Column("LAST_RUN")]
|
||||
public DateTime? LastRun { get; init; }
|
||||
|
||||
[Column("LAST_RESULT")]
|
||||
public string? LastResult { get; init; }
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using ReC.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Views;
|
||||
@@ -16,72 +17,106 @@ public class RecActionView
|
||||
{
|
||||
public virtual IEnumerable<ResultView>? Results { get; set; }
|
||||
|
||||
[Key]
|
||||
[Column("ACTION_GUID")]
|
||||
public required long Id { get; set; }
|
||||
|
||||
[Column("PROFILE_ID")]
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
[ForeignKey("ProfileId")]
|
||||
public ProfileView? Profile { get; set; }
|
||||
|
||||
[Column("PROFILE_NAME")]
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
[Column("PROFILE_TYPE_ID")]
|
||||
public ProfileType? ProfileType { get; set; }
|
||||
|
||||
[Column("SEQUENCE")]
|
||||
public byte? Sequence { get; set; }
|
||||
|
||||
[Column("ENDPOINT_ID")]
|
||||
public long? EndpointId { get; set; }
|
||||
|
||||
[Column("ENDPOINT_URI")]
|
||||
public string? EndpointUri { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_ID")]
|
||||
public long? EndpointAuthId { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_TYPE_ID")]
|
||||
public EndpointAuthType? EndpointAuthType { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_TYPE")]
|
||||
public string? EndpointAuthTypeName { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_KEY")]
|
||||
public string? EndpointAuthApiKey { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_VALUE")]
|
||||
public string? EndpointAuthApiValue { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_KEY_ADD_TO_ID")]
|
||||
public ApiKeyLocation? EndpointAuthApiKeyAddTo { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_API_KEY_ADD_TO")]
|
||||
public string? EndpointAuthApiKeyAddToName { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_TOKEN")]
|
||||
public string? EndpointAuthToken { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_USERNAME")]
|
||||
public string? EndpointAuthUsername { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_PASSWORD")]
|
||||
public string? EndpointAuthPassword { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_DOMAIN")]
|
||||
public string? EndpointAuthDomain { get; set; }
|
||||
|
||||
[Column("ENDPOINT_AUTH_WORKSTATION")]
|
||||
public string? EndpointAuthWorkstation { get; set; }
|
||||
|
||||
[Column("ENDPOINT_PARAMS_ID")]
|
||||
public short? EndpointParamsId { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_ID")]
|
||||
public short? SqlConnectionId { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_SERVER")]
|
||||
public string? SqlConnectionServer { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_DB")]
|
||||
public string? SqlConnectionDb { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_USERNAME")]
|
||||
public string? SqlConnectionUsername { get; set; }
|
||||
|
||||
[Column("SQL_CONNECTION_PASSWORD")]
|
||||
public string? SqlConnectionPassword { get; set; }
|
||||
|
||||
[Column("REST_TYPE_ID")]
|
||||
public RestType? RestType { get; set; }
|
||||
|
||||
[Column("REST_TYPE")]
|
||||
public string? RestTypeName { get; set; }
|
||||
|
||||
[Column("PREPROCESSING_QUERY")]
|
||||
public string? PreprocessingQuery { get; set; }
|
||||
|
||||
[Column("HEADER_QUERY")]
|
||||
public string? HeaderQuery { get; set; }
|
||||
|
||||
[Column("BODY_QUERY")]
|
||||
public string? BodyQuery { get; set; }
|
||||
|
||||
[Column("POSTPROCESSING_QUERY")]
|
||||
public string? PostprocessingQuery { get; set; }
|
||||
|
||||
[Column("ERROR_ACTION_ID")]
|
||||
public ErrorAction? ErrorAction { get; set; }
|
||||
|
||||
[Column("ERROR_ACTION")]
|
||||
public string? ErrorActionName { get; set; }
|
||||
}
|
||||
@@ -1,35 +1,62 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using ReC.Domain.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReC.Domain.Views;
|
||||
|
||||
[Table("VWREC_RESULT", Schema = "dbo")]
|
||||
public class ResultView
|
||||
{
|
||||
[Key]
|
||||
[Column("RESULT_GUID")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("ACTION_ID")]
|
||||
public long? ActionId { get; set; }
|
||||
|
||||
public RecActionView? Action { get; set; }
|
||||
|
||||
[Column("PROFILE_ID")]
|
||||
public long? ProfileId { get; set; }
|
||||
|
||||
public ProfileView? Profile { get; set; }
|
||||
|
||||
[Column("PROFILE_NAME")]
|
||||
public string? ProfileName { get; set; }
|
||||
|
||||
[Column("STATUS_ID")]
|
||||
public short? StatusCode { get; set; }
|
||||
|
||||
[Column("STATUS")]
|
||||
public string? StatusName { get; set; }
|
||||
|
||||
[Column("RESULT_TYPE_ID")]
|
||||
public ResultType? Type { get; set; }
|
||||
|
||||
[Column("RESULT_TYPE")]
|
||||
public string? TypeName { get; set; }
|
||||
|
||||
[Column("RESULT_HEADER")]
|
||||
public string? Header { get; set; }
|
||||
|
||||
[Column("RESULT_BODY")]
|
||||
public string? Body { get; set; }
|
||||
|
||||
[Column("RESULT_INFO")]
|
||||
public string? Info { get; set; }
|
||||
|
||||
[Column("RESULT_ERROR")]
|
||||
public string? Error { get; set; }
|
||||
|
||||
[Column("ADDED_WHO")]
|
||||
public string? AddedWho { get; set; }
|
||||
|
||||
[Column("ADDED_WHEN")]
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO")]
|
||||
public string? ChangedWho { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace ReC.Infrastructure.Exceptions;
|
||||
|
||||
public class DbModelConfigurationException : Exception
|
||||
{
|
||||
public DbModelConfigurationException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public DbModelConfigurationException()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using ReC.Infrastructure.Exceptions;
|
||||
using ReC.Infrastructure.Options.Shared;
|
||||
|
||||
namespace ReC.Infrastructure.Options;
|
||||
|
||||
public record DbModelOptions
|
||||
{
|
||||
public Dictionary<string, EntityOptions> Entities { get; init; } = [];
|
||||
|
||||
public Dictionary<string, VirtualEntityOptions> VirtualEntities { get; init; } = [];
|
||||
|
||||
public void EnsureEntity<T>(bool isVirtual)
|
||||
{
|
||||
var entities = isVirtual
|
||||
? VirtualEntities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions)
|
||||
: Entities.ToDictionary(kvp => kvp.Key, kvp => kvp.Value as EntityBaseOptions);
|
||||
|
||||
if(entities.TryGetValue(nameof(T), out var entityOptions))
|
||||
entityOptions.EnsureProperties<T>();
|
||||
else
|
||||
throw new DbModelConfigurationException($"Entity options for type '{typeof(T).FullName}' not found.");
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
using ReC.Domain.Attributes;
|
||||
using ReC.Infrastructure.Exceptions;
|
||||
|
||||
namespace ReC.Infrastructure.Options.Shared;
|
||||
|
||||
public record EntityBaseOptions()
|
||||
{
|
||||
public Dictionary<string, string> ColumnMappings { get; init; } = [];
|
||||
|
||||
public IEnumerable<string> PropertyNames => ColumnMappings.Select(col => col.Key);
|
||||
|
||||
public IEnumerable<string> ColumnNames => ColumnMappings.Select(col => col.Value);
|
||||
|
||||
public void EnsureProperties(IEnumerable<string> propertyNames)
|
||||
{
|
||||
var missingProperties = propertyNames.Except(PropertyNames).ToList();
|
||||
|
||||
if (missingProperties.Count != 0)
|
||||
throw new DbModelConfigurationException($"The following properties are not configured: {string.Join(", ", missingProperties)}");
|
||||
}
|
||||
|
||||
public void EnsureProperties(params string[] propertyNames)
|
||||
=> EnsureProperties(propertyNames.AsEnumerable());
|
||||
|
||||
public void EnsureProperties<T>()
|
||||
{
|
||||
var propertyNames = typeof(T)
|
||||
.GetProperties()
|
||||
.Where(prop => Attribute.IsDefined(prop, typeof(MustConfiguredAttribute)))
|
||||
.Select(prop => prop.Name);
|
||||
EnsureProperties(propertyNames);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace ReC.Infrastructure.Options.Shared;
|
||||
|
||||
public record EntityOptions(TableOptions Table) : EntityBaseOptions;
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace ReC.Infrastructure.Options.Shared;
|
||||
|
||||
public record TableOptions(string Name, string? Schema = null);
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace ReC.Infrastructure.Options.Shared;
|
||||
|
||||
public record VirtualEntityOptions : EntityBaseOptions;
|
||||
@@ -21,7 +21,6 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
public DbSet<InsertObjectResult> RecResults { get; set; }
|
||||
#endregion DB Sets
|
||||
|
||||
// TODO: Update to configure via appsettings.json
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
@@ -29,41 +28,6 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
modelBuilder.Entity<RecActionView>(b =>
|
||||
{
|
||||
b.ToView("VWREC_ACTION", "dbo");
|
||||
b.HasKey(e => e.Id);
|
||||
|
||||
b.Property(e => e.Id).HasColumnName("ACTION_GUID");
|
||||
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
|
||||
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
|
||||
b.Property(e => e.ProfileType).HasColumnName("PROFILE_TYPE_ID");
|
||||
b.Property(e => e.Sequence).HasColumnName("SEQUENCE");
|
||||
b.Property(e => e.EndpointId).HasColumnName("ENDPOINT_ID");
|
||||
b.Property(e => e.EndpointUri).HasColumnName("ENDPOINT_URI");
|
||||
b.Property(e => e.EndpointAuthId).HasColumnName("ENDPOINT_AUTH_ID");
|
||||
b.Property(e => e.EndpointAuthType).HasColumnName("ENDPOINT_AUTH_TYPE_ID");
|
||||
b.Property(e => e.EndpointAuthTypeName).HasColumnName("ENDPOINT_AUTH_TYPE");
|
||||
b.Property(e => e.EndpointAuthApiKey).HasColumnName("ENDPOINT_AUTH_API_KEY");
|
||||
b.Property(e => e.EndpointAuthApiValue).HasColumnName("ENDPOINT_AUTH_API_VALUE");
|
||||
b.Property(e => e.EndpointAuthApiKeyAddTo).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO_ID");
|
||||
b.Property(e => e.EndpointAuthApiKeyAddToName).HasColumnName("ENDPOINT_AUTH_API_KEY_ADD_TO");
|
||||
b.Property(e => e.EndpointAuthToken).HasColumnName("ENDPOINT_AUTH_TOKEN");
|
||||
b.Property(e => e.EndpointAuthUsername).HasColumnName("ENDPOINT_AUTH_USERNAME");
|
||||
b.Property(e => e.EndpointAuthPassword).HasColumnName("ENDPOINT_AUTH_PASSWORD");
|
||||
b.Property(e => e.EndpointAuthDomain).HasColumnName("ENDPOINT_AUTH_DOMAIN");
|
||||
b.Property(e => e.EndpointAuthWorkstation).HasColumnName("ENDPOINT_AUTH_WORKSTATION");
|
||||
b.Property(e => e.EndpointParamsId).HasColumnName("ENDPOINT_PARAMS_ID");
|
||||
b.Property(e => e.SqlConnectionId).HasColumnName("SQL_CONNECTION_ID");
|
||||
b.Property(e => e.SqlConnectionServer).HasColumnName("SQL_CONNECTION_SERVER");
|
||||
b.Property(e => e.SqlConnectionDb).HasColumnName("SQL_CONNECTION_DB");
|
||||
b.Property(e => e.SqlConnectionUsername).HasColumnName("SQL_CONNECTION_USERNAME");
|
||||
b.Property(e => e.SqlConnectionPassword).HasColumnName("SQL_CONNECTION_PASSWORD");
|
||||
b.Property(e => e.RestType).HasColumnName("REST_TYPE_ID");
|
||||
b.Property(e => e.RestTypeName).HasColumnName("REST_TYPE");
|
||||
b.Property(e => e.PreprocessingQuery).HasColumnName("PREPROCESSING_QUERY");
|
||||
b.Property(e => e.HeaderQuery).HasColumnName("HEADER_QUERY");
|
||||
b.Property(e => e.BodyQuery).HasColumnName("BODY_QUERY");
|
||||
b.Property(e => e.PostprocessingQuery).HasColumnName("POSTPROCESSING_QUERY");
|
||||
b.Property(e => e.ErrorAction).HasColumnName("ERROR_ACTION_ID");
|
||||
b.Property(e => e.ErrorActionName).HasColumnName("ERROR_ACTION");
|
||||
|
||||
b.HasMany(e => e.Results)
|
||||
.WithOne(r => r.Action)
|
||||
@@ -73,44 +37,11 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
modelBuilder.Entity<ProfileView>(b =>
|
||||
{
|
||||
b.ToView("VWREC_PROFILE", "dbo");
|
||||
b.HasKey(e => e.Id);
|
||||
b.Property(e => e.Id).HasColumnName("PROFILE_GUID");
|
||||
b.Property(e => e.Active).HasColumnName("ACTIVE");
|
||||
b.Property(e => e.TypeId).HasColumnName("TYPE_ID");
|
||||
b.Property(e => e.Type).HasColumnName("TYPE");
|
||||
b.Property(e => e.Mandantor).HasColumnName("MANDANTOR");
|
||||
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
|
||||
b.Property(e => e.Description).HasColumnName("DESCRIPTION");
|
||||
b.Property(e => e.LogLevelId).HasColumnName("LOG_LEVEL_ID");
|
||||
b.Property(e => e.LogLevel).HasColumnName("LOG_LEVEL");
|
||||
b.Property(e => e.LanguageId).HasColumnName("LANGUAGE_ID");
|
||||
b.Property(e => e.Language).HasColumnName("LANGUAGE");
|
||||
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||
b.Property(e => e.FirstRun).HasColumnName("FIRST_RUN");
|
||||
b.Property(e => e.LastRun).HasColumnName("LAST_RUN");
|
||||
b.Property(e => e.LastResult).HasColumnName("LAST_RESULT");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ResultView>(b =>
|
||||
{
|
||||
b.ToView("VWREC_RESULT", "dbo");
|
||||
b.HasKey(e => e.Id);
|
||||
|
||||
b.Property(e => e.Id).HasColumnName("RESULT_GUID");
|
||||
b.Property(e => e.ActionId).HasColumnName("ACTION_ID");
|
||||
b.Property(e => e.ProfileId).HasColumnName("PROFILE_ID");
|
||||
b.Property(e => e.ProfileName).HasColumnName("PROFILE_NAME");
|
||||
b.Property(e => e.StatusCode).HasColumnName("STATUS_ID");
|
||||
b.Property(e => e.StatusName).HasColumnName("STATUS");
|
||||
b.Property(e => e.Header).HasColumnName("RESULT_HEADER");
|
||||
b.Property(e => e.Body).HasColumnName("RESULT_BODY");
|
||||
b.Property(e => e.AddedWho).HasColumnName("ADDED_WHO");
|
||||
b.Property(e => e.AddedWhen).HasColumnName("ADDED_WHEN");
|
||||
b.Property(e => e.ChangedWho).HasColumnName("CHANGED_WHO");
|
||||
b.Property(e => e.ChangedWhen).HasColumnName("CHANGED_WHEN");
|
||||
|
||||
b.HasOne(r => r.Action)
|
||||
.WithMany(a => a.Results)
|
||||
@@ -124,19 +55,16 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
||||
modelBuilder.Entity<HeaderQueryResult>(b =>
|
||||
{
|
||||
b.HasNoKey();
|
||||
b.Property(e => e.RawHeader).HasColumnName("REQUEST_HEADER");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<BodyQueryResult>(b =>
|
||||
{
|
||||
b.HasNoKey();
|
||||
b.Property(e => e.RawBody).HasColumnName("REQUEST_BODY");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<InsertObjectResult>(b =>
|
||||
{
|
||||
b.HasNoKey();
|
||||
b.Property(e => e.NewObjectId).HasColumnName("oGUID");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,11 @@ public class EndpointAuthProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task InsertEndpointAuthProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new InsertEndpointAuthProcedure { Active = true, Description = "auth", TypeId = 1, ApiKey = "key", ApiValue = "value" };
|
||||
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
||||
var procedure = new InsertEndpointAuthCommand { Active = true, Description = "auth", TypeId = 1, ApiKey = "key", ApiValue = "value" };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0));
|
||||
}
|
||||
@@ -36,12 +35,11 @@ public class EndpointAuthProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task UpdateEndpointAuthProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateEndpointAuthProcedure { Active = false, Description = "auth-update", TypeId = 2 };
|
||||
var objectProc = procedure.ToObjectProcedure(15, "ReC.Tests");
|
||||
var procedure = new UpdateEndpointAuthCommand { Data = { Active = false, Description = "auth-update", TypeId = 2 }, Id = 15 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -49,12 +47,11 @@ public class EndpointAuthProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task DeleteEndpointAuthProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteEndpointAuthProcedure { Start = 3, End = 4, Force = false };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
var procedure = new DeleteEndpointAuthCommand { Start = 3, End = 4, Force = false };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NUnit.Framework;
|
||||
using ReC.Application.Common.Procedures.DeleteProcedure;
|
||||
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||
using ReC.Application.Common.Procedures.UpdateProcedure;
|
||||
using ReC.Application.EndpointParams.Commands;
|
||||
using ReC.Tests.Application;
|
||||
|
||||
namespace ReC.Tests.Application.EndpointParams;
|
||||
|
||||
@@ -23,12 +17,11 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task InsertEndpointParamsProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new InsertEndpointParamsProcedure { Active = true, Description = "param", GroupId = 1, Sequence = 1, Key = "k", Value = "v" };
|
||||
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
||||
var procedure = new InsertEndpointParamsCommand { Active = true, Description = "param", GroupId = 1, Sequence = 1, Key = "k", Value = "v" };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0));
|
||||
}
|
||||
@@ -36,12 +29,11 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task UpdateEndpointParamsProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateEndpointParamsProcedure { Active = false, Description = "param-update", GroupId = 2, Sequence = 2, Key = "k2", Value = "v2" };
|
||||
var objectProc = procedure.ToObjectProcedure(25, "ReC.Tests");
|
||||
var procedure = new UpdateEndpointParamsCommand { Data = { Active = false, Description = "param-update", GroupId = 2, Sequence = 2, Key = "k2", Value = "v2" }, Id = 25 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -49,12 +41,11 @@ public class EndpointParamsProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task DeleteEndpointParamsProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteEndpointParamsProcedure { Start = 5, End = 6, Force = true };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
var procedure = new DeleteEndpointParamsCommand { Start = 5, End = 6, Force = true };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
@@ -23,12 +23,11 @@ public class EndpointProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task InsertEndpointProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new InsertEndpointProcedure { Active = true, Description = "desc", Uri = "http://example" };
|
||||
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
||||
var procedure = new InsertEndpointCommand { Active = true, Description = "desc", Uri = "http://example" };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0));
|
||||
}
|
||||
@@ -36,12 +35,11 @@ public class EndpointProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task UpdateEndpointProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateEndpointProcedure { Active = false, Description = "updated", Uri = "http://updated" };
|
||||
var objectProc = procedure.ToObjectProcedure(12, "ReC.Tests");
|
||||
var procedure = new UpdateEndpointCommand { Data = { Active = false, Description = "updated", Uri = "http://updated" }, Id = 12 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -49,12 +47,11 @@ public class EndpointProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task DeleteEndpointProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteEndpointProcedure { Start = 1, End = 2, Force = true };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
var procedure = new DeleteEndpointCommand { Start = 1, End = 2, Force = true };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ public class ProcedureExecutionTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task ExecuteInsertProcedure_runs_with_addedWho()
|
||||
{
|
||||
var procedure = new InsertProfileProcedure { Name = "name" };
|
||||
var procedure = new InsertProfileCommand { Name = "name" };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.ExecuteInsertProcedure(procedure, "ReC.Tests");
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0));
|
||||
}
|
||||
@@ -35,11 +35,11 @@ public class ProcedureExecutionTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task ExecuteUpdateProcedure_runs_with_changedWho()
|
||||
{
|
||||
var procedure = new UpdateProfileProcedure { Name = "updated" };
|
||||
var procedure = new UpdateProfileCommand { Data = { Name = "updated" }, Id = 123 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.ExecuteUpdateProcedure(procedure, 123, "ReC.Tests");
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -47,11 +47,11 @@ public class ProcedureExecutionTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task ExecuteDeleteProcedure_runs()
|
||||
{
|
||||
var procedure = new DeleteProfileProcedure { Start = 1, End = 2, Force = true };
|
||||
var procedure = new DeleteProfileCommand { Start = 1, End = 2, Force = true };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.ExecuteDeleteProcedure(procedure);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
@@ -23,12 +23,11 @@ public class ProfileProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task InsertProfileProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new InsertProfileProcedure { Active = true, TypeId = 1, Name = "name", Mandantor = "man" };
|
||||
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
||||
var procedure = new InsertProfileCommand { Active = true, TypeId = 1, Name = "name", Mandantor = "man" };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0));
|
||||
}
|
||||
@@ -36,12 +35,11 @@ public class ProfileProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task UpdateProfileProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateProfileProcedure { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" };
|
||||
var objectProc = procedure.ToObjectProcedure(45, "ReC.Tests");
|
||||
var procedure = new UpdateProfileCommand { Data = { Active = false, TypeId = 2, Name = "updated", Mandantor = "man2" }, Id = 45 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -49,12 +47,11 @@ public class ProfileProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task DeleteProfileProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteProfileProcedure { Start = 9, End = 10, Force = false };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
var procedure = new DeleteProfileCommand { Start = 9, End = 10, Force = false };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
@@ -25,12 +25,11 @@ public class RecActionProcedureTests : RecApplicationTestBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var procedure = new InsertActionProcedure { ProfileId = 1, Active = true, Sequence = 1, EndpointId = 1 };
|
||||
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
||||
var procedure = new InsertActionCommand { ProfileId = 1, Active = true, Sequence = 1, EndpointId = 1 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0), "Expected a valid ID greater than 0 to be returned from the insert operation.");
|
||||
}
|
||||
@@ -54,12 +53,11 @@ public class RecActionProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task UpdateActionProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateActionProcedure { ProfileId = 2, Active = false, Sequence = 2 };
|
||||
var objectProc = procedure.ToObjectProcedure(35, "ReC.Tests");
|
||||
var procedure = new UpdateActionCommand { Data = { ProfileId = 2, Active = false, Sequence = 2 }, Id = 35 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -67,12 +65,11 @@ public class RecActionProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task DeleteActionProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteActionProcedure { Start = 7, End = 8, Force = true };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
var procedure = new DeleteActionCommand { Start = 7, End = 8, Force = true };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
@@ -23,12 +23,11 @@ public class ResultProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task InsertResultProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new InsertResultProcedure { ActionId = 1, StatusId = 200, Header = "h", Body = "b" };
|
||||
var objectProc = procedure.ToObjectProcedure("ReC.Tests");
|
||||
var procedure = new InsertResultCommand { ActionId = 1, StatusId = 200, Header = "h", Body = "b", Type = Domain.Constants.ResultType.Main };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.GreaterThan(0));
|
||||
}
|
||||
@@ -36,12 +35,11 @@ public class ResultProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task UpdateResultProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new UpdateResultProcedure { ActionId = 2, StatusId = 500, Header = "h2", Body = "b2" };
|
||||
var objectProc = procedure.ToObjectProcedure(55, "ReC.Tests");
|
||||
var procedure = new UpdateResultCommand { Data = { ActionId = 2, StatusId = 500, Header = "h2", Body = "b2" }, Id = 55 };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
@@ -49,12 +47,11 @@ public class ResultProcedureTests : RecApplicationTestBase
|
||||
[Test]
|
||||
public async Task DeleteResultProcedure_runs_via_mediator()
|
||||
{
|
||||
var procedure = new DeleteResultProcedure { Start = 11, End = 12, Force = false };
|
||||
var objectProc = procedure.ToObjectProcedure();
|
||||
var procedure = new DeleteResultCommand { Start = 11, End = 12, Force = false };
|
||||
|
||||
var (sender, scope) = CreateScopedSender();
|
||||
using var _ = scope;
|
||||
var result = await sender.Send(objectProc);
|
||||
var result = await sender.Send(procedure);
|
||||
|
||||
Assert.That(result, Is.Not.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user