Download Faturas: Substituição de pasta NFe para TUSD utilizando Case Insensitive.
WebHook: Salvar somente arquivos do tipo "nota_fiscal", ignorar arquivos devec e decisões judiciais. Salvar no histórico a mensagem de erro.
This commit is contained in:
parent
b29ae2e3d3
commit
48c729e5b6
@ -147,7 +147,7 @@
|
|||||||
dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString() !);
|
dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString() !);
|
||||||
dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString() !);
|
dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString() !);
|
||||||
dadosTusd.Perfil = reader["Perfil"].ToString();
|
dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||||
this.PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty) + "\\TUSD");
|
this.PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty, StringComparison.OrdinalIgnoreCase) + "\\TUSD");
|
||||||
this.Gestao = reader["Gestao"].ToString();
|
this.Gestao = reader["Gestao"].ToString();
|
||||||
this.Empresa = reader["Cliente"].ToString();
|
this.Empresa = reader["Cliente"].ToString();
|
||||||
this.Unidade = reader["Unidade"].ToString();
|
this.Unidade = reader["Unidade"].ToString();
|
||||||
@ -254,6 +254,12 @@
|
|||||||
string? kind_P = string.Empty;
|
string? kind_P = string.Empty;
|
||||||
string? kind_FP = string.Empty;
|
string? kind_FP = string.Empty;
|
||||||
|
|
||||||
|
if (this.id == "2356193")
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
List<(string, float)> insertOthers = new List<(string, float)>();
|
List<(string, float)> insertOthers = new List<(string, float)>();
|
||||||
foreach (Item item in parsedResult.items)
|
foreach (Item item in parsedResult.items)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Net.Http.Headers;
|
using System.Net;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
@ -81,6 +82,15 @@ public class Program
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HttpResponseMessage SendFatura(string token, string fatura, bool agrupada)
|
public static HttpResponseMessage SendFatura(string token, string fatura, bool agrupada)
|
||||||
|
{
|
||||||
|
var handler = new HttpClientHandler
|
||||||
|
{
|
||||||
|
//Proxy = new WebProxy("http://127.0.0.1:8888"),
|
||||||
|
//UseProxy = true,
|
||||||
|
//ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var httpClient = new HttpClient(handler))
|
||||||
{
|
{
|
||||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/parse");
|
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/parse");
|
||||||
|
|
||||||
@ -96,6 +106,7 @@ public class Program
|
|||||||
|
|
||||||
return httpClient.Send(request);
|
return httpClient.Send(request);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsFileLocked(FileInfo file)
|
public static bool IsFileLocked(FileInfo file)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -118,8 +118,7 @@ namespace Webhook_4docs
|
|||||||
|
|
||||||
JsonElement DadosJson = JsonDocument.Parse(root.ToString()).RootElement;
|
JsonElement DadosJson = JsonDocument.Parse(root.ToString()).RootElement;
|
||||||
|
|
||||||
if (root.Get("documentType")?.ToString().ToLower() == "devec") { return; }
|
if (root.Get("documentType")?.ToString().ToLower() != "nota_fiscal") { return; }
|
||||||
|
|
||||||
|
|
||||||
Fatura fatura = new(fatura_ID, JsonBody);
|
Fatura fatura = new(fatura_ID, JsonBody);
|
||||||
bool completed = false;
|
bool completed = false;
|
||||||
@ -235,7 +234,7 @@ namespace Webhook_4docs
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test = await UpdateErrorIdStatusAsync(CaminhoDB, JsonBody.GetProperty("locationID").GetInt64(), errorID, JsonBody.GetProperty("systemText").ToString(), logger);
|
int test = await UpdateErrorIdStatusAsync(CaminhoDB, JsonBody.GetProperty("locationID").GetInt64(), errorID, (JsonBody.GetProperty("systemText").ToString() == "" ? JsonBody.GetProperty("websiteText").ToString() : JsonBody.GetProperty("systemText").ToString()), logger);
|
||||||
|
|
||||||
if (test == 0)
|
if (test == 0)
|
||||||
{
|
{
|
||||||
@ -361,8 +360,8 @@ namespace Webhook_4docs
|
|||||||
|
|
||||||
using (OleDbCommand cmd = new OleDbCommand(
|
using (OleDbCommand cmd = new OleDbCommand(
|
||||||
@"UPDATE AgVirtual4Docs
|
@"UPDATE AgVirtual4Docs
|
||||||
SET errorID = ?, status = ?
|
SET errorID = @errorID, status = @status
|
||||||
WHERE location_id = ?", conn))
|
WHERE location_id = @location_id", conn))
|
||||||
{
|
{
|
||||||
// Adiciona parâmetros de forma segura
|
// Adiciona parâmetros de forma segura
|
||||||
cmd.Parameters.AddWithValue("@errorID", errorID);
|
cmd.Parameters.AddWithValue("@errorID", errorID);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user