a873dce31b
- Modificato GetAllRecordsAsync per utilizzare la stessa connection string del discovery schema - Aggiunto metodo CreateConnection per creare connessioni DB appropriate per tipo - Migliorata gestione nomi tabelle con schema (es. "dbo.OCRD") - Rimossi metodi obsoleti di creazione entità (UpdateEntityData, CreateNewEntity) - Eliminati riferimenti a variabili non dichiarate (newEntityData, isCreatingEntity) - Aggiunto logging debug per connection string e query SQL - Completata implementazione trasferimento dati da database a REST API Il trasferimento dati ora utilizza la stessa connessione per discovery e estrazione, risolvendo problemi di accesso alle tabelle durante l'operazione di upsert.
60 lines
3.3 KiB
C#
60 lines
3.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
|
|
namespace DataConnection.REST.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// Interface for a generic REST service client.
|
|
/// </summary>
|
|
public interface IRestServiceClient
|
|
{
|
|
/// <summary>
|
|
/// Authenticates the client using the provided credentials.
|
|
/// Implementation varies by service type.
|
|
/// </summary>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>True if authentication was successful, false otherwise.</returns>
|
|
Task<bool> AuthenticateAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Sends a GET request to the specified URI.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of the object to deserialize the response content to.</typeparam>
|
|
/// <param name="requestUri">The URI the request is sent to.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>The deserialized response content.</returns>
|
|
Task<T?> GetAsync<T>(string requestUri, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Sends a POST request to the specified URI.
|
|
/// </summary>
|
|
/// <typeparam name="TRequest">The type of the request object.</typeparam>
|
|
/// <typeparam name="TResponse">The type of the object to deserialize the response content to.</typeparam>
|
|
/// <param name="requestUri">The URI the request is sent to.</param>
|
|
/// <param name="payload">The HTTP request content sent to the server.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>The deserialized response content.</returns>
|
|
Task<TResponse?> PostAsync<TRequest, TResponse>(string requestUri, TRequest payload, CancellationToken cancellationToken = default); /// <summary>
|
|
/// Creates a new entity by sending a POST request with the provided data.
|
|
/// </summary>
|
|
/// <param name="entityName">The name of the entity to create.</param>
|
|
/// <param name="entityData">The data for the new entity as key-value pairs.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>The created entity data or null if creation failed.</returns>
|
|
Task<Dictionary<string, object>?> CreateEntityAsync(string entityName, Dictionary<string, object> entityData, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Creates a new entity or updates an existing one (upsert operation).
|
|
/// </summary>
|
|
/// <param name="entityName">The name of the entity to upsert.</param>
|
|
/// <param name="entityData">The data for the entity as key-value pairs.</param>
|
|
/// <param name="cancellationToken">Cancellation token.</param>
|
|
/// <returns>The upserted entity data or null if operation failed.</returns>
|
|
Task<Dictionary<string, object>?> UpsertEntityAsync(string entityName, Dictionary<string, object> entityData, CancellationToken cancellationToken = default);
|
|
|
|
// Add other methods as needed (PUT, DELETE, PATCH, etc.)
|
|
// Consider adding methods for handling raw HttpResponseMessage or string responses
|
|
}
|
|
}
|