-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into ofmcc-636-setup-uat-e…
…nvironment
- Loading branch information
Showing
48 changed files
with
2,689 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
OFM.Infrastructure.WebAPI/Extensions/D365BackgroundProcessHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.Extensions.Logging; | ||
using OFM.Infrastructure.WebAPI.Services.Processes; | ||
using System.Reflection.Metadata; | ||
|
||
namespace OFM.Infrastructure.WebAPI.Extensions; | ||
|
||
public interface ID365BackgroundProcessHandler | ||
{ | ||
void Execute(Func<ID365ScheduledProcessService, Task> processor); | ||
} | ||
|
||
public class D365BackgroundProcessHandler : ID365BackgroundProcessHandler | ||
{ | ||
private readonly IServiceScopeFactory _serviceScopeFactory; | ||
private readonly ILogger _logger; | ||
|
||
//[FromServices] IServiceScopeFactory | ||
public D365BackgroundProcessHandler(IServiceScopeFactory serviceScopeFactory, ILoggerFactory loggerFactory) | ||
{ | ||
_serviceScopeFactory = serviceScopeFactory; | ||
_logger = loggerFactory.CreateLogger(LogCategory.Process); | ||
} | ||
|
||
public void Execute(Func<ID365ScheduledProcessService, Task> processor) | ||
{ | ||
Task.Run(async () => | ||
{ | ||
try | ||
{ | ||
using var scope = _serviceScopeFactory.CreateScope(); | ||
var service = scope.ServiceProvider.GetRequiredService<ID365ScheduledProcessService>(); | ||
await processor(service); | ||
} | ||
catch (Exception exp) | ||
{ | ||
_logger.LogCritical(exp.Message); | ||
} | ||
}); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
OFM.Infrastructure.WebAPI/Extensions/D365ServiceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Net; | ||
|
||
namespace OFM.Infrastructure.WebAPI.Extensions; | ||
public class D365ServiceException : Exception | ||
{ | ||
public HttpStatusCode HttpStatusCode { get; set; } | ||
|
||
public string? ReasonPhrase { get; set; } | ||
|
||
public ODataError? ODataError { get; set; } | ||
|
||
public string? Content { get; set; } | ||
|
||
public string? RequestId { get; set; } | ||
|
||
public D365ServiceException() | ||
{ | ||
} | ||
|
||
public D365ServiceException(string message) | ||
: base(message) | ||
{ | ||
} | ||
|
||
public D365ServiceException(string message, Exception inner) | ||
: base(message, inner) | ||
{ | ||
} | ||
} | ||
|
||
public class ODataException | ||
{ | ||
public string? Message { get; set; } | ||
public string? ExceptionMessage { get; set; } | ||
public string? StackTrace { get; set; } | ||
public string? ErrorCode { get; set; } | ||
} | ||
|
||
public class ODataError | ||
{ | ||
public Error? Error { get; set; } | ||
} | ||
|
||
public class Error | ||
{ | ||
public string? Code { get; set; } | ||
public string? Message { get; set; } | ||
} |
41 changes: 29 additions & 12 deletions
41
OFM.Infrastructure.WebAPI/Extensions/EndpointRouteBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,70 @@ | ||
using OFM.Infrastructure.WebAPI.Handlers; | ||
using OFM.Infrastructure.WebAPI.Handlers.D365; | ||
|
||
namespace OFM.Infrastructure.WebAPI.Extensions; | ||
|
||
public static class EndpointRouteBuilderExtensions | ||
{ | ||
#region Portal | ||
|
||
public static void RegisterEnvironmentEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var endpoints = endpointRouteBuilder.MapGroup("/api/environment"); | ||
|
||
endpoints.MapGet("", EnvironmentHandlers.Get).WithTags("Environment").Produces(200).ProducesProblem(404); | ||
endpoints.MapGet("", EnvironmentHandlers.Get).WithTags("Portal Environment").Produces(200).ProducesProblem(404); | ||
} | ||
|
||
public static void RegisterSearchesEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var searchesEndpoints = endpointRouteBuilder.MapGroup("/api/searches"); | ||
|
||
searchesEndpoints.MapPost("", SearchesHandlers.DataverseSearchAsync).WithTags("Searches").Produces(200).ProducesProblem(404); | ||
searchesEndpoints.MapPost("", SearchesHandlers.DataverseSearchAsync).WithTags("Portal Searches").Produces(200).ProducesProblem(404); | ||
} | ||
|
||
public static void RegisterProviderProfileEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var searchesEndpoints = endpointRouteBuilder.MapGroup("/api/providerprofile"); | ||
|
||
searchesEndpoints.MapGet("", ProviderProfilesHandlers.GetProfileAsync).WithTags("Providers").Produces(200).ProducesProblem(404); | ||
searchesEndpoints.MapGet("", ProviderProfilesHandlers.GetProfileAsync).WithTags("Portal Providers").Produces(200).ProducesProblem(404); | ||
} | ||
|
||
public static void RegisterOperationsEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var operationsEndpoints = endpointRouteBuilder.MapGroup("/api/operations"); | ||
|
||
operationsEndpoints.MapGet("", OperationsHandlers.GetAsync).WithTags("Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapPost("", OperationsHandlers.PostAsync).WithTags("Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapPatch("", OperationsHandlers.PatchAsync).WithTags("Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapDelete("", OperationsHandlers.DeleteAsync).WithTags("Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapGet("", OperationsHandlers.GetAsync).WithTags("Portal Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapPost("", OperationsHandlers.PostAsync).WithTags("Portal Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapPatch("", OperationsHandlers.PatchAsync).WithTags("Portal Operations").Produces(200).ProducesProblem(404); | ||
operationsEndpoints.MapDelete("", OperationsHandlers.DeleteAsync).WithTags("Portal Operations").Produces(200).ProducesProblem(404); | ||
} | ||
|
||
public static void RegisterDocumentsEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var documentsEndpoints = endpointRouteBuilder.MapGroup("/api/documents"); | ||
|
||
documentsEndpoints.MapGet("", DocumentsHandlers.GetAsync).WithTags("Documents").Produces(200).ProducesProblem(404); | ||
documentsEndpoints.MapPost("", DocumentsHandlers.PostAsync).WithTags("Documents").Produces(200).ProducesProblem(404); | ||
documentsEndpoints.MapDelete("", DocumentsHandlers.DeleteAsync).WithTags("Documents").Produces(200).ProducesProblem(404); | ||
documentsEndpoints.MapGet("", DocumentsHandlers.GetAsync).WithTags("Portal Documents").Produces(200).ProducesProblem(404); | ||
documentsEndpoints.MapPost("", DocumentsHandlers.PostAsync).WithTags("Portal Documents").Produces(200).ProducesProblem(404).DisableAntiforgery(); | ||
documentsEndpoints.MapDelete("", DocumentsHandlers.DeleteAsync).WithTags("Portal Documents").Produces(200).ProducesProblem(404); | ||
} | ||
|
||
public static void RegisterBatchOperationsEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var searchesEndpoints = endpointRouteBuilder.MapGroup("/api/batches"); | ||
var batchEndpoints = endpointRouteBuilder.MapGroup("/api/batches"); | ||
|
||
searchesEndpoints.MapPost("", BatchOperationsHandlers.BatchOperationAsync).WithTags("Batches").Produces(200).ProducesProblem(404); | ||
batchEndpoints.MapPost("", BatchOperationsHandlers.BatchOperationsAsync).WithTags("Portal Batches").Produces(200).ProducesProblem(404); | ||
} | ||
|
||
#endregion | ||
|
||
#region D365 | ||
|
||
public static void RegisterBatchProcessesEndpoints(this IEndpointRouteBuilder endpointRouteBuilder) | ||
{ | ||
var requestsEndpoints = endpointRouteBuilder.MapGroup("/api/processes"); | ||
|
||
requestsEndpoints.MapPost("/{processId}", ProcessesHandlers.RunProcessById).WithTags("D365 Processes"); | ||
|
||
} | ||
|
||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.