Compare commits
2 Commits
b0024a1fde
...
b41d272a7a
| Author | SHA1 | Date | |
|---|---|---|---|
| b41d272a7a | |||
| 864455c8cd |
@ -19,7 +19,7 @@ namespace Infrastructure
|
||||
using var connection = new OleDbConnection(_connectionString);
|
||||
await connection.OpenAsync(ct);
|
||||
|
||||
string sql = $"SELECT Cod_5min, Codigo_SCDE, Data_de_Migracao FROM Dados_cadastrais WHERE LEN(Codigo_SCDE) > 5 AND Unidade_gerenciada ORDER BY cod_smart_unidade";
|
||||
string sql = $"SELECT Cod_5min, Codigo_SCDE, Data_de_Migracao FROM Dados_cadastrais WHERE LEN(Codigo_SCDE) > 5 AND Unidade_gerenciada ORDER BY Codigo_SCDE";
|
||||
//string sql = "SELECT Cod_5min, Codigo_SCDE, Data_de_Migracao FROM Dados_cadastrais WHERE LEN(Codigo_SCDE) > 5 and (Cliente = 'RMC ALIMENTOS' OR Cliente = 'FERREIRA SUPERMERCADO' OR Cliente = 'VANGUARDA ALIMENTOS') AND Unidade_gerenciada ORDER BY PerfilCCEE";
|
||||
//string sql = "SELECT Cod_5min, Codigo_SCDE, Data_de_Migracao FROM Dados_cadastrais WHERE LEN(Codigo_SCDE) > 5 and Cliente = 'ABEVÊ' and Unidade = 'ABV LOJA 29 - COXIM' AND Unidade_gerenciada ORDER BY PerfilCCEE";
|
||||
//string sql = "SELECT Cod_5min, Codigo_SCDE, Data_de_Migracao FROM Dados_cadastrais WHERE LEN(Codigo_SCDE) > 5 and Cliente = 'SURF CENTER' AND Unidade_gerenciada ORDER BY PerfilCCEE";
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Globalization;
|
||||
using Application;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
@ -32,9 +35,31 @@ namespace Infrastructure
|
||||
|
||||
try
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
using var handler = new SocketsHttpHandler
|
||||
{
|
||||
// Adiciona Accept-Encoding automaticamente e faz a descompressão transparente
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | DecompressionMethods.Brotli
|
||||
};
|
||||
using var client = new HttpClient(handler);
|
||||
using var content = new FormUrlEncodedContent(values);
|
||||
var resp = await client.PostAsync(Url, content, ct);
|
||||
|
||||
using var request = new HttpRequestMessage(HttpMethod.Post, Url)
|
||||
{
|
||||
Content = content
|
||||
};
|
||||
|
||||
// Headers solicitados
|
||||
request.Headers.Host = "www.ccee.org.br";
|
||||
request.Headers.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||
request.Headers.Accept.Clear();
|
||||
request.Headers.Accept.ParseAdd("*/*");
|
||||
request.Headers.AcceptEncoding.Clear();
|
||||
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
|
||||
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate"));
|
||||
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("br"));
|
||||
request.Headers.Connection.Add("keep-alive");
|
||||
|
||||
var resp = await client.SendAsync(request, ct);
|
||||
var resposta = await resp.Content.ReadAsStringAsync(ct);
|
||||
|
||||
var alvo = $"Data limite para coleta diária dos dados de medição no SCDE";
|
||||
@ -42,14 +67,14 @@ namespace Infrastructure
|
||||
try
|
||||
{
|
||||
using var doc = JsonDocument.Parse(resposta);
|
||||
|
||||
|
||||
double? encontrado = null;
|
||||
double? startTimeDay = null;
|
||||
|
||||
void SearchJson(JsonElement el)
|
||||
{
|
||||
if (encontrado != null) return;
|
||||
|
||||
|
||||
if (el.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
// Verifica se alguma propriedade contém o texto alvo
|
||||
@ -69,7 +94,7 @@ namespace Infrastructure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var prop in el.EnumerateObject())
|
||||
SearchJson(prop.Value);
|
||||
}
|
||||
@ -79,7 +104,7 @@ namespace Infrastructure
|
||||
SearchJson(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SearchJson(doc.RootElement);
|
||||
if (encontrado != null) return encontrado;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user