Integracion envio de registros
This commit is contained in:
parent
765e9aaa98
commit
6cba1fef95
236 changed files with 251 additions and 13308 deletions
|
@ -1,8 +1,38 @@
|
|||
namespace DAS
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace DAS
|
||||
{
|
||||
public class RegistrarMedicion
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public RegistrarMedicion(HttpClient httpClient, IConfiguration configuration)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task<bool> EnviarMedicionAsync(string codigoObra, MedicionSubterraneaRequest request)
|
||||
{
|
||||
var baseUrl = _configuration["ApiSubterranea:BaseUrl"];
|
||||
var endpoint = _configuration["ApiSubterranea:Endpoint"];
|
||||
var url = $"{baseUrl}{endpoint}";
|
||||
|
||||
var timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss-0000");
|
||||
|
||||
var json = JsonSerializer.Serialize(request);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
content.Headers.Add("codigoObra", codigoObra);
|
||||
content.Headers.Add("timeStampOrigen", timeStamp);
|
||||
|
||||
var response = await _httpClient.PostAsync(url, content);
|
||||
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue