Faturas incluidas no BD serão salvas automaticamente na pasta da unidade.
This commit is contained in:
parent
3274f26415
commit
5a019cddec
@ -18,7 +18,6 @@
|
|||||||
private const string Token = "UFY4VWzqcHYcGNd0gkBOMFL9G5ZThV6gXBQIJ79F5HSqITzavz4Fe7iXvAbJLvZJ";
|
private const string Token = "UFY4VWzqcHYcGNd0gkBOMFL9G5ZThV6gXBQIJ79F5HSqITzavz4Fe7iXvAbJLvZJ";
|
||||||
private JsonElement faturaParsed;
|
private JsonElement faturaParsed;
|
||||||
private string? id;
|
private string? id;
|
||||||
private string? pastaMiddle;
|
|
||||||
private string? uc;
|
private string? uc;
|
||||||
private int? pagina;
|
private int? pagina;
|
||||||
|
|
||||||
@ -68,6 +67,8 @@
|
|||||||
|
|
||||||
public FileInfo? Arquivo { get; private set; }
|
public FileInfo? Arquivo { get; private set; }
|
||||||
|
|
||||||
|
public DirectoryInfo? PastaTUSD { get; private set; }
|
||||||
|
|
||||||
public bool Agrupada { get; private set; }
|
public bool Agrupada { get; private set; }
|
||||||
|
|
||||||
public JsonElement.ArrayEnumerator Agrupada_children { get; private set; }
|
public JsonElement.ArrayEnumerator Agrupada_children { get; private set; }
|
||||||
@ -146,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.pastaMiddle = reader["Caminho_NFs"].ToString();
|
this.PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty) + "\\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();
|
||||||
@ -604,7 +605,14 @@
|
|||||||
|
|
||||||
case ("FATURA INCLUIDA NO BD", _):
|
case ("FATURA INCLUIDA NO BD", _):
|
||||||
|
|
||||||
|
if (this.PastaTUSD!.Exists)
|
||||||
|
{
|
||||||
|
destino = this.PastaTUSD!.FullName + $@"\ID {this.id!} - Mês {this.Mes} - Empresa {this.Empresa} - Unidade {this.Unidade}.pdf";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\6 - {this.Status}\ID {this.id!} - Mês {this.Mes} - Empresa {this.Empresa} - Unidade {this.Unidade}.pdf";
|
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\6 - {this.Status}\ID {this.id!} - Mês {this.Mes} - Empresa {this.Empresa} - Unidade {this.Unidade}.pdf";
|
||||||
|
}
|
||||||
|
|
||||||
if (separar)
|
if (separar)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -101,7 +101,6 @@
|
|||||||
|
|
||||||
public string[] texts { get; set; }
|
public string[] texts { get; set; }
|
||||||
|
|
||||||
[JsonConverter(typeof(FloatArrayOrSingleConverter))]
|
|
||||||
public float measured { get; set; }
|
public float measured { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,13 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"isRoot": true,
|
"isRoot": true,
|
||||||
"tools": {}
|
"tools": {
|
||||||
|
"dotnet-ef": {
|
||||||
|
"version": "9.0.0",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-ef"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -73,8 +73,6 @@ namespace Webhook_4docs
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.UsePathBase(appFolder);
|
app.UsePathBase(appFolder);
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
@ -127,8 +125,6 @@ namespace Webhook_4docs
|
|||||||
fatura.Processar(conn);
|
fatura.Processar(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t = false;
|
|
||||||
|
|
||||||
string? status = fatura.Status;
|
string? status = fatura.Status;
|
||||||
|
|
||||||
int status_id = 0;
|
int status_id = 0;
|
||||||
@ -153,9 +149,12 @@ namespace Webhook_4docs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string path = $@"X:\Middle\Carteira {fatura.Gestao![0]}\Carteira {fatura.Gestao}\Faturas fourdocs\{status_id} - {status}";
|
string path = $@"X:\Middle\Carteira {fatura.Gestao![0]}\Carteira {fatura.Gestao}\Faturas fourdocs\{status_id} - {status}";
|
||||||
System.IO.Directory.CreateDirectory(path);
|
if (status_id == 6 && fatura.PastaTUSD!.Exists)
|
||||||
|
{
|
||||||
|
path = fatura.PastaTUSD!.FullName;
|
||||||
|
}
|
||||||
fatura_arquivo = IndexedFilename($@"{path}\ID {fatura_ID!} - Mês {fatura.Mes} - Empresa {fatura.Empresa} - Unidade {fatura.Unidade}", "pdf");
|
fatura_arquivo = IndexedFilename($@"{path}\ID {fatura_ID!} - Mês {fatura.Mes} - Empresa {fatura.Empresa} - Unidade {fatura.Unidade}", "pdf");
|
||||||
t = CriarArquivo(fatura_arquivo, JsonBody.GetProperty("pdfFile").ToString());
|
CriarArquivo(fatura_arquivo, JsonBody.GetProperty("pdfFile").ToString());
|
||||||
|
|
||||||
var DatabaseModel = new ProcessedInvoices
|
var DatabaseModel = new ProcessedInvoices
|
||||||
{
|
{
|
||||||
@ -178,7 +177,6 @@ namespace Webhook_4docs
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
t = false;
|
|
||||||
logger.LogError("Erro no processamento da fatura");
|
logger.LogError("Erro no processamento da fatura");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,10 +256,9 @@ namespace Webhook_4docs
|
|||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
public static bool CriarArquivo(string fatura_arquivo, string pdfFile64)
|
public static void CriarArquivo(string fatura_arquivo, string pdfFile64)
|
||||||
{
|
{
|
||||||
//string fatura_arquivo = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test.pdf";
|
//string fatura_arquivo = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test.pdf";
|
||||||
bool t = false;
|
|
||||||
if (!File.Exists(fatura_arquivo))
|
if (!File.Exists(fatura_arquivo))
|
||||||
{
|
{
|
||||||
byte[] bytes = Convert.FromBase64String(pdfFile64);
|
byte[] bytes = Convert.FromBase64String(pdfFile64);
|
||||||
@ -271,9 +268,7 @@ namespace Webhook_4docs
|
|||||||
new(stream);
|
new(stream);
|
||||||
writer.Write(bytes, 0, bytes.Length);
|
writer.Write(bytes, 0, bytes.Length);
|
||||||
writer.Close();
|
writer.Close();
|
||||||
t = true;
|
|
||||||
}
|
}
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static partial class JsonExtensions
|
public static partial class JsonExtensions
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user