Faturas duplicadas não são mais salvas.
Criado endpoint para teste.
This commit is contained in:
parent
9197d900ff
commit
13c7356d9e
@ -188,6 +188,9 @@ namespace Webhook_4docs
|
||||
{
|
||||
path = fatura.PastaTUSD!.FullName;
|
||||
}
|
||||
|
||||
if (status_id != 4)
|
||||
{
|
||||
fatura_arquivo = IndexedFilename($@"{path}\ID {fatura_ID!} - Mês {fatura.Mes} - Empresa {fatura.Empresa} - Unidade {fatura.Unidade}", "pdf");
|
||||
CriarArquivo(fatura_arquivo, JsonBody.GetProperty("pdfFile").ToString());
|
||||
|
||||
@ -201,20 +204,26 @@ namespace Webhook_4docs
|
||||
|
||||
logger.LogInformation("Fatura incluída no BD");
|
||||
|
||||
logger.LogInformation("Fatura salva na pasta " + fatura_arquivo);
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<WebhookDbContext>();
|
||||
dbContext.ProcessedInvoices.Add(DatabaseModel);
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogInformation("Fatura duplicada no BD");
|
||||
|
||||
logger.LogInformation("Fatura salva na pasta " + fatura_arquivo);
|
||||
logger.LogInformation("Fatura descartada");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
logger.LogError("Erro no processamento da fatura");
|
||||
}
|
||||
|
||||
}
|
||||
else if (JsonBody.TryGetProperty("healthy", out _) && JsonBody.TryGetProperty("blame", out _) && JsonBody.TryGetProperty("locationID", out _))
|
||||
{
|
||||
@ -247,6 +256,10 @@ namespace Webhook_4docs
|
||||
}
|
||||
}
|
||||
});
|
||||
endpoints.MapPut("/api", async context =>
|
||||
{
|
||||
var a = 10;
|
||||
});
|
||||
});
|
||||
app.Run();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user