Refatoração e melhorias gerais no processamento de faturas
- Alterado namespace para `Download_Faturas.Tests` e adicionados cabeçalhos de copyright. - Refatoração para uso de recursos modernos do C# (ex.: inicializações simplificadas, métodos estáticos). - Adicionados comentários XML e arquivo `stylecop.json` para padronização. - Melhorias em testes de integração, incluindo ajustes na lógica de comparação e manipulação de CSV. - Refatoração das classes `Fatura` e `FaturaOld` para encapsulamento e redução de duplicação. - Adicionado suporte a conversores JSON personalizados (`DefaultDateTimeConverter`, `FloatArrayOrSingleConverter`). - Melhorias no arquivo `Program.cs` com novos métodos auxiliares e tratamento de erros. - Adicionadas classes auxiliares para manipulação de PDFs (`PDFSplitter`, `CustomPdfSplitter`). - Ajustes nos arquivos de projeto para geração de documentação XML e inclusão do `StyleCop.Analyzers`. - Correções em valores de consumo e demanda nos arquivos CSV. - Melhor tratamento de erros e mensagens de log para facilitar o diagnóstico.
This commit is contained in:
parent
414a489f29
commit
6b0a5d61d3
@ -3,28 +3,35 @@ using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using Download_Faturas;
|
||||
|
||||
namespace Download_Faturas1.Tests
|
||||
namespace Download_Faturas.Tests
|
||||
{
|
||||
public class FaturaIntegrationTests
|
||||
{
|
||||
private const string Token = "UFY4VWzqcHYcGNd0gkBOMFL9G5ZThV6gXBQIJ79F5HSqITzavz4Fe7iXvAbJLvZJ";
|
||||
private static readonly HttpClient httpClient = new HttpClient();
|
||||
private static readonly HttpClient httpClient = new ();
|
||||
|
||||
[Fact]
|
||||
public async Task CompareFaturaWithFaturaOld_ShouldReportDifferences()
|
||||
{
|
||||
// Sample fatura IDs to test (replace with real IDs or fetch dynamically)
|
||||
var faturaIds = LoadCsvColumn("../../../../Download Faturas.Tests/4Docs_2025_07.csv", 0);
|
||||
var differences = new List<string>();
|
||||
differences.Add($"FaturaId\tDistribuidora\toldConsumo_P\tnewConsumo_P\toldConsumo_FP\tnewConsumo_FP\toldDem_Reg_P\tnewDem_Reg_P\toldDem_Reg_FP\tnewDem_Reg_FP\toldEn_Reativa_Mvarh\tnewEn_Reativa_Mvarh");
|
||||
var differences = new List<string>
|
||||
{
|
||||
$"FaturaId\tDistribuidora\toldConsumo_P\tnewConsumo_P\toldConsumo_FP\tnewConsumo_FP\toldDem_Reg_P\tnewDem_Reg_P\toldDem_Reg_FP\tnewDem_Reg_FP\toldEn_Reativa_Mvarh\tnewEn_Reativa_Mvarh"
|
||||
};
|
||||
|
||||
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:/Middle/Informativo Setorial/Modelo Word/BD1_Testes.accdb;Jet OLEDB:Database Password=gds21"))
|
||||
using (OleDbConnection conn = new (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:/Middle/Informativo Setorial/Modelo Word/BD1_Testes.accdb;Jet OLEDB:Database Password=gds21"))
|
||||
{
|
||||
// Open the connection to the test database
|
||||
conn.Open();
|
||||
|
||||
foreach (var faturaId in faturaIds)
|
||||
{
|
||||
if (faturaId == "2640189")
|
||||
{
|
||||
int i = 0;
|
||||
if (i == 0) continue;
|
||||
}
|
||||
// Retrieve fatura JSON from 4Docs API
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, $"https://api.4docs.cloud/v2/request/status?id={faturaId}");
|
||||
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {Token}");
|
||||
@ -32,7 +39,6 @@ namespace Download_Faturas1.Tests
|
||||
if (!response.IsSuccessStatusCode) continue;
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var faturaParsed = JsonDocument.Parse(json).RootElement;
|
||||
int? pagina;
|
||||
|
||||
// Process with old logic (FaturaOld)
|
||||
var faturaOld = new FaturaOld(faturaId, faturaParsed);
|
||||
@ -40,14 +46,14 @@ namespace Download_Faturas1.Tests
|
||||
var fatura = new Fatura(faturaId, faturaParsed);
|
||||
|
||||
faturaOld.Processar(conn); // This will write to DB, but we want to compare without writing
|
||||
var oldVal = GetDadosTusd(conn, faturaOld.cod_tusd);
|
||||
DeleteTusdRecords(conn, faturaOld.cod_tusd); // Delete old TUSD records before processing
|
||||
var oldVal = GetDadosTusd(conn, faturaOld.CodTusd);
|
||||
DeleteTusdRecords(conn, faturaOld.CodTusd); // Delete old TUSD records before processing
|
||||
|
||||
fatura.Processar(conn); // This will also write to DB, but we want to compare without writing
|
||||
var newVal = GetDadosTusd(conn, fatura.cod_tusd);
|
||||
DeleteTusdRecords(conn, fatura.cod_tusd); // Delete old TUSD records before processing
|
||||
var newVal = GetDadosTusd(conn, fatura.CodTusd);
|
||||
DeleteTusdRecords(conn, fatura.CodTusd); // Delete old TUSD records before processing
|
||||
|
||||
if (!string.Equals(newVal, oldVal))
|
||||
if (!Equals(newVal, oldVal))
|
||||
{
|
||||
differences.Add($"{faturaId}\t{oldVal.Distribuidora}\t{oldVal.Consumo_P}\t{newVal.Consumo_P}\t{oldVal.Consumo_FP}\t{newVal.Consumo_FP}\t{oldVal.Dem_Reg_P}\t{newVal.Dem_Reg_P}\t{oldVal.Dem_Reg_FP}\t{newVal.Dem_Reg_FP}\t{oldVal.En_Reativa_Mvarh}\t{newVal.En_Reativa_Mvarh}");
|
||||
}
|
||||
@ -60,23 +66,23 @@ namespace Download_Faturas1.Tests
|
||||
Assert.True(differences.Count == 0, $"Differences found between Fatura and FaturaOld:\n{string.Join("\n", differences)}");
|
||||
}
|
||||
|
||||
void DeleteTusdRecords(OleDbConnection conn, double codTusd)
|
||||
static void DeleteTusdRecords(OleDbConnection conn, double codTusd)
|
||||
{
|
||||
// Deletes TUSD records based on cod_tusd
|
||||
string sqlQuery = "DELETE FROM Dados_TUSD WHERE Cod_TUSD = ?";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?", codTusd);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
RecordSet GetDadosTusd(OleDbConnection conn, double codTusd)
|
||||
static RecordSet GetDadosTusd(OleDbConnection conn, double codTusd)
|
||||
{
|
||||
RecordSet dadosTusd = new RecordSet();
|
||||
RecordSet dadosTusd = new ();
|
||||
// Retrieves TUSD records based on cod_tusd
|
||||
string sqlQuery = "SELECT * FROM Dados_TUSD WHERE Cod_TUSD = ?";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?", codTusd);
|
||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||
@ -85,29 +91,29 @@ namespace Download_Faturas1.Tests
|
||||
{
|
||||
// Dados Tusd
|
||||
;
|
||||
dadosTusd.Cod_TUSD = double.Parse(reader["Cod_TUSD"].ToString());
|
||||
dadosTusd.Mes = int.Parse(reader["Mes"].ToString());
|
||||
dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
||||
dadosTusd.Grupo = reader["Grupo"].ToString();
|
||||
dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||
dadosTusd.Inicio_Leitura = DateTime.Parse(reader["Inicio_Leitura"].ToString());
|
||||
dadosTusd.Fim_leitura = DateTime.Parse(reader["Fim_leitura"].ToString());
|
||||
dadosTusd.Valor = float.Parse(reader["Valor"].ToString());
|
||||
dadosTusd.Consumo_P = float.Parse(reader["Consumo_P"].ToString());
|
||||
dadosTusd.Consumo_FP = float.Parse(reader["Consumo_FP"].ToString());
|
||||
dadosTusd.Dem_Reg_P = float.Parse(reader["Dem_Reg_P"].ToString());
|
||||
dadosTusd.Dem_Reg_FP = float.Parse(reader["Dem_Reg_FP"].ToString());
|
||||
dadosTusd.Dem_Cont_P = float.Parse(reader["Dem_Cont_P"].ToString());
|
||||
dadosTusd.Dem_Cont_FP = float.Parse(reader["Dem_Cont_FP"].ToString());
|
||||
dadosTusd.En_Reativa_Mvarh = float.Parse(reader["En_Reativa_Mvarh"].ToString());
|
||||
dadosTusd.Dem_Reativa_kvar = float.Parse(reader["Dem_Reativa_kvar"].ToString());
|
||||
dadosTusd.Cod_TUSD = double.Parse(reader["Cod_TUSD"].ToString()!);
|
||||
dadosTusd.Mes = int.Parse(reader["Mes"].ToString()!);
|
||||
dadosTusd.Distribuidora = reader["Distribuidora"].ToString()!;
|
||||
dadosTusd.Grupo = reader["Grupo"].ToString()!;
|
||||
dadosTusd.Perfil = reader["Perfil"].ToString()!;
|
||||
dadosTusd.Inicio_Leitura = DateTime.Parse(reader["Inicio_Leitura"].ToString()!);
|
||||
dadosTusd.Fim_leitura = DateTime.Parse(reader["Fim_leitura"].ToString()!);
|
||||
dadosTusd.Valor = float.Parse(reader["Valor"].ToString()!);
|
||||
dadosTusd.Consumo_P = float.Parse(reader["Consumo_P"].ToString()!);
|
||||
dadosTusd.Consumo_FP = float.Parse(reader["Consumo_FP"].ToString()!);
|
||||
dadosTusd.Dem_Reg_P = float.Parse(reader["Dem_Reg_P"].ToString()!);
|
||||
dadosTusd.Dem_Reg_FP = float.Parse(reader["Dem_Reg_FP"].ToString()!);
|
||||
dadosTusd.Dem_Cont_P = float.Parse(reader["Dem_Cont_P"].ToString()!);
|
||||
dadosTusd.Dem_Cont_FP = float.Parse(reader["Dem_Cont_FP"].ToString()!);
|
||||
dadosTusd.En_Reativa_Mvarh = float.Parse(reader["En_Reativa_Mvarh"].ToString()!);
|
||||
dadosTusd.Dem_Reativa_kvar = float.Parse(reader["Dem_Reativa_kvar"].ToString()!);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dadosTusd;
|
||||
}
|
||||
//load csv column
|
||||
List<string> LoadCsvColumn(string filePath, int columnIndex)
|
||||
static List<string> LoadCsvColumn(string filePath, int columnIndex)
|
||||
{
|
||||
var columnData = new List<string>();
|
||||
using (var reader = new StreamReader(filePath))
|
||||
@ -131,7 +137,7 @@ namespace Download_Faturas1.Tests
|
||||
}
|
||||
|
||||
//write data to csv
|
||||
void WriteCsv(string filePath, List<string> data)
|
||||
static void WriteCsv(string filePath, List<string> data)
|
||||
{
|
||||
using (var writer = new StreamWriter(filePath))
|
||||
{
|
||||
|
||||
10
Download Faturas.Tests/GlobalSuppressions.cs
Normal file
10
Download Faturas.Tests/GlobalSuppressions.cs
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Tests.FaturaIntegrationTests.DeleteTusdRecords(System.Data.OleDb.OleDbConnection,System.Double)")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Tests.FaturaIntegrationTests.GetDadosTusd(System.Data.OleDb.OleDbConnection,System.Double)~Download_Faturas.RecordSet")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Tests.FaturaIntegrationTests.WriteCsv(System.String,System.Collections.Generic.List{System.String})")]
|
||||
@ -18,7 +18,7 @@ FaturaId Distribuidora oldConsumo_P newConsumo_P oldConsumo_FP newConsumo_FP old
|
||||
2657251 ELETROPAULO 0 0 1,926 1,926 0 0 0 0 0 0
|
||||
2657249 ELETROPAULO 0 0 2,427 2,427 0 0 0 0 0 0
|
||||
2657247 ESCELSA 12,808945 12,808945 112,56336 112,56336 308,16 308,16 371,52 371,52 1,2908161 1,2908161
|
||||
2657245 CEMIG 2,045 2,045 0 42,366 74 74 116 116 3,7159998 3,7159998
|
||||
2657245 CEMIG 2,045 2,045 0 0 74 74 116 116 3,7159998 3,7159998
|
||||
2657243 AMPLA 0,17639999 0,17639999 1,722 1,722 6,38 6,38 8,73 8,73 0,120288 0,120288
|
||||
2657241 LIGHT 0 12,957 118,419 118,419 0 0 406 406 0,632 0,632
|
||||
2651045 CEPISA 2,14103 2,14103 26,00794 26,00794 57,81 57,81 64,01125 64,01125 0,01244 0,01244
|
||||
@ -32,7 +32,7 @@ FaturaId Distribuidora oldConsumo_P newConsumo_P oldConsumo_FP newConsumo_FP old
|
||||
2651029 CEPISA 6,52224 6,52224 61,94176 61,94176 139,6255 139,6255 144,35075 144,35075 1,37341 1,37341
|
||||
2651027 0 0 0 0 0 0 0 0 0 0
|
||||
2651025 LIGHT 0 2,916 155,358 155,358 0 0 1156 1156 5,676 5,676
|
||||
2651023 CEAL 2,33626 0 19,12764 0 52,808 51,52 65,6 64 0 0
|
||||
2651023 CEAL 2,33626 2,33626 19,12764 19,12764 52,808 52,808 65,6 65,6 0 0
|
||||
2651021 0 0 0 0 0 0 0 0 0 0
|
||||
2651019 LIGHT 0 9,416 101,152 101,152 0 0 226 226 0,148 0,148
|
||||
2651017 ESCELSA 0 0 0 0 0 0 0 0 0 0
|
||||
@ -48,10 +48,10 @@ FaturaId Distribuidora oldConsumo_P newConsumo_P oldConsumo_FP newConsumo_FP old
|
||||
2648777 ESCELSA 1,2243912 1,2243912 8,927733 8,927733 85,7064 85,7064 108,141594 108,141594 1,7908062 1,7908062
|
||||
2648775 ESCELSA 0 0 0 0 0 0 0 0 0 0
|
||||
2648773 EPB 3,2951698 3,2951698 31,32226 31,32226 98,4 98,4 121,16 121,16 2,2639399 2,2639399
|
||||
2648771 CEMIG 0,049 0,049 0 23,074 11 11 255 255 0,015 0,015
|
||||
2648771 CEMIG 0,049 0,049 0 0 11 11 255 255 0,015 0,015
|
||||
2648769 ESCELSA 0,295176 0,295176 100,56077 100,56077 5,376 5,376 696,864 696,864 4,44696 4,44696
|
||||
2648767 CEMIG 2,68 2,68 0 28,158 147 147 175 175 0,187 0,187
|
||||
2648765 CEMIG 3,52 3,52 0 91,388 144 144 336 336 2,21 2,21
|
||||
2648767 CEMIG 2,68 2,68 0 0 147 147 175 175 0,187 0,187
|
||||
2648765 CEMIG 3,52 3,52 0 0 144 144 336 336 2,21 2,21
|
||||
2648763 AMPLA 2,365083 2,365083 19,2213 19,2213 106,59 106,59 128,77 128,77 0,9909899 0,9909899
|
||||
2647742 LIGHT 0 3,252 37,896 37,896 0 0 95 95 0 0
|
||||
2647740 LIGHT 0 17,267 201,999 201,999 0 0 444 444 0 0
|
||||
@ -62,19 +62,18 @@ FaturaId Distribuidora oldConsumo_P newConsumo_P oldConsumo_FP newConsumo_FP old
|
||||
2642379 0 0 0 0 0 0 0 0 0 0
|
||||
2642377 0 0 0 0 0 0 0 0 0 0
|
||||
2642375 0 0 0 0 0 0 0 0 0 0
|
||||
2642373 LIGHT 0 0 31,2 0 0 0 0 0 0 0
|
||||
2642371 LIGHT 0 0 28,2 0 0 0 0 0 0 0
|
||||
2642373 LIGHT 0 0 31,2 31,2 0 0 0 0 0 0
|
||||
2642371 LIGHT 0 0 28,2 28,2 0 0 0 0 0 0
|
||||
2642369 0 0 0 0 0 0 0 0 0 0
|
||||
2642367 LIGHT 0 0 28,4 0 0 0 0 0 0 0
|
||||
2642367 LIGHT 0 0 28,4 28,4 0 0 0 0 0 0
|
||||
2642365 0 0 0 0 0 0 0 0 0 0
|
||||
2642363 0 0 0 0 0 0 0 0 0 0
|
||||
2642361 0 0 0 0 0 0 0 0 0 0
|
||||
2642359 CEMIG 21,919 21,919 203,795 203,795 406 406 454 454 0 0
|
||||
2641859 ESCELSA 0,364392 0,364392 42,21798 42,21798 15,792 15,792 326,928 326,928 3,543792 3,543792
|
||||
2641857 CEAL 2,65737 0 21,834301 0 61,664 60,16 80,688 78,72 0 0
|
||||
2641857 CEAL 2,65737 2,65737 21,834301 21,834301 61,664 61,664 80,688 80,688 0 0
|
||||
2641855 ESCELSA 1,2725999 1,2725999 81,32006 81,32006 67,2 67,2 491,904 491,904 0,027384 0,027384
|
||||
2640192 ENERGISA-MS 1,8795 0 31,0065 0 169,79 169,79 227,64 227,64 9,7923 9,7923
|
||||
2640189 CPFL PIRATININGA 91,2192 91,2192 638,16235 638,16235 1814,4 1814,4 2169,6 2169,6 0,014784001 0,014784001
|
||||
2640192 ENERGISA-MS 1,8795 1,8795 31,0065 31,0065 169,79 169,79 227,64 227,64 9,7923 9,7923
|
||||
2640187 CPFL PIRATININGA 52,9044 52,9044 584,6424 584,6424 1670,4 1670,4 2400 2400 2,301805 2,301805
|
||||
2640185 CPFL PIRATININGA 50,46 50,46 518,0424 518,0424 1699,2 1699,2 2347,2 2347,2 2,160003 2,160003
|
||||
2640183 CPFL PIRATININGA 54,162 54,162 597,40436 597,40436 1612,8 1612,8 2592 2592 0,65190303 0,65190303
|
||||
|
||||
|
39
Download Faturas/CustomPdfSplitter.cs
Normal file
39
Download Faturas/CustomPdfSplitter.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// <copyright file="CustomPdfSplitter.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Data.OleDb;
|
||||
using System.Globalization;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Custom PDF splitter that allows specifying a function to create the next PDF writer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="CustomPdfSplitter"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="pdfDocument">The PDF document to split.</param>
|
||||
/// <param name="nextWriter">A function that returns the next PdfWriter given a PageRange.</param>
|
||||
public class CustomPdfSplitter(PdfDocument pdfDocument, Func<PageRange, PdfWriter> nextWriter) : PdfSplitter(pdfDocument)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the next PDF writer for the specified page range.
|
||||
/// </summary>
|
||||
/// <param name="documentPageRange">The page range for which to get the next PDF writer.</param>
|
||||
/// <returns>The next PDF writer.</returns>
|
||||
protected override PdfWriter GetNextPdfWriter(PageRange documentPageRange)
|
||||
{
|
||||
return nextWriter.Invoke(documentPageRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,24 @@
|
||||
using System;
|
||||
// <copyright file="DefaultDateTimeConverter.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom JSON converter for DateTime to handle default values.
|
||||
/// </summary>
|
||||
public class DefaultDateTimeConverter : JsonConverter<DateTime>
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads and converts the JSON to DateTime, returning DateTime.MinValue for invalid or empty strings.
|
||||
/// </summary>
|
||||
/// <param name="reader">The Utf8JsonReader instance to read JSON tokens from.</param>
|
||||
/// <param name="typeToConvert">The target type to convert to (expected DateTime).</param>
|
||||
/// <param name="options">The serializer options that may affect parsing behavior.</param>
|
||||
/// <returns>The parsed DateTime value, or DateTime.MinValue when the input is null, empty, or invalid.</returns>
|
||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
@ -26,9 +39,16 @@ namespace Download_Faturas
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the DateTime value as a string in JSON.
|
||||
/// </summary>
|
||||
/// <param name="writer">The Utf8JsonWriter instance to write JSON tokens to.</param>
|
||||
/// <param name="value">The DateTime value to write.</param>
|
||||
/// <param name="options">The serializer options that may affect writing behavior.</param>
|
||||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value);
|
||||
// Write DateTime in round-trip ISO 8601 format so JSON consumers can parse it reliably.
|
||||
writer.WriteStringValue(value.ToString("o"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@ -7,6 +7,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU</Platforms>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -14,7 +15,15 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\.editorconfig" Link=".editorconfig" />
|
||||
<None Remove="stylecop.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="stylecop.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="..\.editorconfig" Link=".editorconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
namespace Download_Faturas
|
||||
// <copyright file="Fatura.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Data.OleDb;
|
||||
using System.Globalization;
|
||||
@ -12,19 +16,34 @@
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Representa uma fatura eletrônica e fornece métodos para processá-la e movê-la.
|
||||
/// </summary>
|
||||
public class Fatura
|
||||
{
|
||||
private const string Token = "UFY4VWzqcHYcGNd0gkBOMFL9G5ZThV6gXBQIJ79F5HSqITzavz4Fe7iXvAbJLvZJ";
|
||||
private JsonElement faturaParsed;
|
||||
private string? id;
|
||||
private string? uc;
|
||||
private int? pagina;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data to be recorded for TUSD in the database.
|
||||
/// </summary>
|
||||
private readonly RecordSet dadosTusd = new ();
|
||||
private readonly JsonElement faturaParsed;
|
||||
private readonly string? id;
|
||||
private readonly int? pagina;
|
||||
private string? uc;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Fatura"/> class.
|
||||
/// Inicializa uma nova instância da classe <see cref="Fatura"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Identificador da fatura no serviço 4docs.</param>
|
||||
/// <param name="fatura_path">Caminho completo para o arquivo PDF da fatura local.</param>
|
||||
/// <param name="httpClient">Instância de HttpClient usada para realizar chamadas HTTP à API.</param>
|
||||
public Fatura(string id, string fatura_path, HttpClient httpClient)
|
||||
{
|
||||
// Utilizado para gerar novo token
|
||||
// this.token = Req_token(httpClient).ToString();
|
||||
HttpResponseMessage fatura_response = this.GetStatus(httpClient, Token, id);
|
||||
// this.token = Req_token(HttpClient).ToString();
|
||||
HttpResponseMessage fatura_response = GetStatus(httpClient, Token, id);
|
||||
if (fatura_response.IsSuccessStatusCode)
|
||||
{
|
||||
this.faturaParsed = JsonDocument.Parse(fatura_response.Content.ReadAsStringAsync().Result).RootElement;
|
||||
@ -45,43 +64,79 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Fatura"/> class.
|
||||
/// Inicializa uma nova instância da classe <see cref="Fatura"/> para faturas já processadas.
|
||||
/// </summary>
|
||||
/// <param name="id">Identificador da fatura no serviço 4docs.</param>
|
||||
/// <param name="fatura_Parsed">JsonElement contendo os dados da fatura já parseados.</param>
|
||||
public Fatura(string id, JsonElement fatura_Parsed)
|
||||
{
|
||||
// Utilizado para gerar novo token
|
||||
// this.token = Req_token(httpClient).ToString();
|
||||
// this.token = Req_token(HttpClient).ToString();
|
||||
this.faturaParsed = fatura_Parsed;
|
||||
this.Agrupada = false;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TUSD code for the invoice.
|
||||
/// </summary>
|
||||
public double CodTusd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the consumer unit code associated with the invoice.
|
||||
/// </summary>
|
||||
public string? Gestao { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the company name associated with the invoice.
|
||||
/// </summary>
|
||||
public string? Empresa { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unit name associated with the invoice.
|
||||
/// </summary>
|
||||
public string? Unidade { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the month associated with the invoice.
|
||||
/// </summary>
|
||||
public int? Mes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of the invoice.
|
||||
/// </summary>
|
||||
public string? Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file information of the invoice PDF.
|
||||
/// </summary>
|
||||
public FileInfo? Arquivo { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the directory information for the TUSD folder.
|
||||
/// </summary>
|
||||
public DirectoryInfo? PastaTUSD { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the invoice is grouped.
|
||||
/// </summary>
|
||||
public bool Agrupada { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children elements if the invoice is grouped.
|
||||
/// </summary>
|
||||
public JsonElement.ArrayEnumerator Agrupada_children { get; private set; }
|
||||
|
||||
// Variavel para armazenar os dados a serem lancados para a TUSD no BD
|
||||
public RecordSet dadosTusd = new ();
|
||||
|
||||
public double cod_tusd;
|
||||
|
||||
/// <summary>
|
||||
/// Processes the invoice and records the TUSD data in the database.
|
||||
/// </summary>
|
||||
/// <param name="conn">An open OleDbConnection to the database used to insert or update TUSD records.</param>
|
||||
public void Processar(OleDbConnection conn)
|
||||
{
|
||||
// Resultado da fatura processada
|
||||
JsonElement a;
|
||||
if (!this.faturaParsed.TryGetProperty("result", out a))
|
||||
if (!this.faturaParsed.TryGetProperty("result", out JsonElement a))
|
||||
{
|
||||
this.faturaParsed.TryGetProperty("json", out a);
|
||||
}
|
||||
@ -92,14 +147,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
||||
this.dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
||||
|
||||
string uc = new Regex("^0+").Replace(parsedResult.locationNumber, string.Empty).Replace("/", string.Empty).Replace("-", string.Empty).Replace(".", string.Empty);
|
||||
|
||||
// Vinculo da fatura com os dados cadastrais
|
||||
int? unidades;
|
||||
string sqlQuery = $"SELECT COUNT (Cod_Smart_unidade) FROM Dados_cadastrais WHERE Codigo_Instalacao = @uc AND unidade_gerenciada";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@uc", uc);
|
||||
|
||||
@ -115,7 +170,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
if (unidades == 1)
|
||||
{
|
||||
@ -133,25 +188,25 @@
|
||||
while (reader.Read())
|
||||
{
|
||||
// Dados cadastrais
|
||||
dadosTusd.Cod_Smart_unidade = long.Parse(reader["Cod_Smart_unidade"].ToString()!);
|
||||
dadosTusd.Perfil_CliqCCEE = reader["PerfilCCEE"].ToString();
|
||||
dadosTusd.Submercado = reader["Submercado"].ToString();
|
||||
this.dadosTusd.Cod_Smart_unidade = long.Parse(reader["Cod_Smart_unidade"].ToString() !);
|
||||
this.dadosTusd.Perfil_CliqCCEE = reader["PerfilCCEE"].ToString();
|
||||
this.dadosTusd.Submercado = reader["Submercado"].ToString();
|
||||
DateTime dataMigração = DateTime.Parse(reader["Data_de_Migracao"].ToString() !);
|
||||
if (int.Parse(dataMigração.ToString("yMM")) <= dadosTusd.Mes)
|
||||
if (int.Parse(dataMigração.ToString("yMM")) <= this.dadosTusd.Mes)
|
||||
{
|
||||
dadosTusd.Ambiente = reader["Status_unidade"].ToString();
|
||||
this.dadosTusd.Ambiente = reader["Status_unidade"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
dadosTusd.Ambiente = "Cativo";
|
||||
this.dadosTusd.Ambiente = "Cativo";
|
||||
}
|
||||
|
||||
dadosTusd.Grupo = reader["Grupo"].ToString();
|
||||
dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
||||
dadosTusd.ICMS = float.Parse(reader["ICMS_TUSD"].ToString()!);
|
||||
dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString()!);
|
||||
dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString()!);
|
||||
dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||
this.dadosTusd.Grupo = reader["Grupo"].ToString();
|
||||
this.dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
||||
this.dadosTusd.ICMS = float.Parse(reader["ICMS_TUSD"].ToString() !);
|
||||
this.dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString() !);
|
||||
this.dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString() !);
|
||||
this.dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||
this.PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty, StringComparison.OrdinalIgnoreCase) + "\\TUSD");
|
||||
this.Gestao = reader["Gestao"].ToString();
|
||||
this.Empresa = reader["Cliente"].ToString();
|
||||
@ -164,10 +219,10 @@
|
||||
bool tusdLanc;
|
||||
|
||||
sqlQuery = $"SELECT Cod_TUSD FROM Dados_TUSD WHERE Cod_TUSD = ?";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cod_tusd = double.Parse(dadosTusd.Cod_Smart_unidade.ToString() + dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", cod_tusd);
|
||||
this.CodTusd = double.Parse(this.dadosTusd.Cod_Smart_unidade.ToString() + this.dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", this.CodTusd);
|
||||
|
||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
@ -175,82 +230,82 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (dadosTusd.Cod_Smart_unidade == 0)
|
||||
if (this.dadosTusd.Cod_Smart_unidade == 0)
|
||||
{
|
||||
this.Status = "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD";
|
||||
this.uc = uc;
|
||||
this.Mes = dadosTusd.Mes;
|
||||
this.Mes = this.dadosTusd.Mes;
|
||||
return;
|
||||
}
|
||||
else if (tusdLanc)
|
||||
{
|
||||
this.Status = "FATURA DUPLICADA NO BD";
|
||||
this.uc = uc;
|
||||
this.Mes = dadosTusd.Mes;
|
||||
this.Mes = this.dadosTusd.Mes;
|
||||
return;
|
||||
}
|
||||
|
||||
// PIS e Cofins
|
||||
sqlQuery = $"SELECT Distribuidoras_PIS.PIS, Distribuidoras_PIS.COFINS FROM Distribuidoras_geral INNER JOIN Distribuidoras_PIS ON Distribuidoras_geral.ID_dist = Distribuidoras_PIS.ID_dist WHERE Distribuidoras_PIS.Mes = ? AND Distribuidoras_geral.Distribuidora = ?";
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?", dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", dadosTusd.Distribuidora);
|
||||
cmd.Parameters.AddWithValue("?", this.dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", this.dadosTusd.Distribuidora);
|
||||
|
||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
// PIS e Cofins
|
||||
dadosTusd.PIS = float.Parse(reader["PIS"].ToString()!);
|
||||
dadosTusd.COFINS = float.Parse(reader["COFINS"].ToString()!);
|
||||
this.dadosTusd.PIS = float.Parse(reader["PIS"].ToString() !);
|
||||
this.dadosTusd.COFINS = float.Parse(reader["COFINS"].ToString() !);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dados da fatura processada
|
||||
dadosTusd.Cod_TUSD = long.Parse(dadosTusd.Cod_Smart_unidade.ToString() + dadosTusd.Mes.ToString());
|
||||
this.dadosTusd.Cod_TUSD = long.Parse(this.dadosTusd.Cod_Smart_unidade.ToString() + this.dadosTusd.Mes.ToString());
|
||||
switch (parsedResult.tariffModality, parsedResult.subgroup)
|
||||
{
|
||||
case ("blue", _):
|
||||
dadosTusd.Perfil = "AZUL";
|
||||
this.dadosTusd.Perfil = "AZUL";
|
||||
break;
|
||||
|
||||
case ("green", _):
|
||||
dadosTusd.Perfil = "VERDE";
|
||||
this.dadosTusd.Perfil = "VERDE";
|
||||
break;
|
||||
|
||||
case ("standart", _):
|
||||
dadosTusd.Perfil = "CONVENCIONAL";
|
||||
this.dadosTusd.Perfil = "CONVENCIONAL";
|
||||
break;
|
||||
|
||||
case (_, "B3"):
|
||||
dadosTusd.Perfil = "CONVENCIONAL";
|
||||
this.dadosTusd.Perfil = "CONVENCIONAL";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dadosTusd.Valor = parsedResult.totalCharges;
|
||||
dadosTusd.Inicio_Leitura = parsedResult.dates.reading.periodFrom;
|
||||
dadosTusd.Fim_leitura = parsedResult.dates.reading.periodUntil;
|
||||
this.dadosTusd.Valor = parsedResult.totalCharges;
|
||||
this.dadosTusd.Inicio_Leitura = parsedResult.dates.reading.periodFrom;
|
||||
this.dadosTusd.Fim_leitura = parsedResult.dates.reading.periodUntil;
|
||||
DateTime d = DateTime.Now;
|
||||
dadosTusd.Hora_TUSD = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
||||
dadosTusd.Dem_Reativa_kvar = 0;
|
||||
dadosTusd.Multa = 0;
|
||||
dadosTusd.Credito = 0;
|
||||
dadosTusd.Bandeira_RS_MWh = 0;
|
||||
dadosTusd.FIC_DIC = 0;
|
||||
dadosTusd.Enc_conexao = 0;
|
||||
dadosTusd.Liminar_ICMS = 0;
|
||||
dadosTusd.Outros = 0;
|
||||
dadosTusd.Cred_livre = 0;
|
||||
dadosTusd.Tempo_TUSD = 0;
|
||||
dadosTusd.Lanc_aut = true;
|
||||
dadosTusd.Rev_atual = true;
|
||||
dadosTusd.Revisao = 0;
|
||||
this.dadosTusd.Hora_TUSD = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
||||
this.dadosTusd.Dem_Reativa_kvar = 0;
|
||||
this.dadosTusd.Multa = 0;
|
||||
this.dadosTusd.Credito = 0;
|
||||
this.dadosTusd.Bandeira_RS_MWh = 0;
|
||||
this.dadosTusd.FIC_DIC = 0;
|
||||
this.dadosTusd.Enc_conexao = 0;
|
||||
this.dadosTusd.Liminar_ICMS = 0;
|
||||
this.dadosTusd.Outros = 0;
|
||||
this.dadosTusd.Cred_livre = 0;
|
||||
this.dadosTusd.Tempo_TUSD = 0;
|
||||
this.dadosTusd.Lanc_aut = true;
|
||||
this.dadosTusd.Rev_atual = true;
|
||||
this.dadosTusd.Revisao = 0;
|
||||
|
||||
// Loop entre os dados faturados na fatura
|
||||
int j = 0;
|
||||
@ -260,22 +315,44 @@
|
||||
string? kind_P = string.Empty;
|
||||
string? kind_FP = string.Empty;
|
||||
|
||||
List<(string, float)> insertOthers = new List<(string, float)>();
|
||||
List<(string, float)> insertOthers = [];
|
||||
foreach (Item item in parsedResult.items)
|
||||
{
|
||||
switch (item.type, item.period, item.kind)
|
||||
switch (item.type, item.period)
|
||||
{
|
||||
// Energia Ponta
|
||||
case ("energy", "peak", "TUSD"):
|
||||
dadosTusd.Consumo_P += item.billed / 1000;
|
||||
case ("energy", "peak"):
|
||||
if (kind_P == string.Empty)
|
||||
{
|
||||
kind_P = item.kind;
|
||||
}
|
||||
|
||||
if (item.kind == kind_P || item.kind == "TUSD")
|
||||
{
|
||||
if ((item.billed / 1000) != this.dadosTusd.Consumo_P)
|
||||
{
|
||||
this.dadosTusd.Consumo_P += item.billed / 1000;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Energia Fora de Ponta
|
||||
case ("energy", _, "TUSD"):
|
||||
case ("energy", _):
|
||||
if (item.period == "off-peak" || item.period == "off-peak inductive" || item.period == "off-peak capacitive" || item.period == "reserved")
|
||||
{
|
||||
dadosTusd.Consumo_FP += item.billed / 1000;
|
||||
if (kind_FP == string.Empty)
|
||||
{
|
||||
kind_FP = item.kind;
|
||||
}
|
||||
|
||||
if (item.kind == kind_FP)
|
||||
{
|
||||
if ((item.billed / 1000) != this.dadosTusd.Consumo_FP)
|
||||
{
|
||||
this.dadosTusd.Consumo_FP += item.billed / 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,51 +362,51 @@
|
||||
break;
|
||||
|
||||
// Demanda
|
||||
case ("demand", _, _):
|
||||
case ("demand", _):
|
||||
|
||||
if (item.contract != 0)
|
||||
{
|
||||
if (item.period == "peak")
|
||||
{
|
||||
dadosTusd.Dem_Reg_P = item.billed;
|
||||
dadosTusd.Dem_Cont_P = item.contract;
|
||||
this.dadosTusd.Dem_Reg_P = item.billed;
|
||||
this.dadosTusd.Dem_Cont_P = item.contract;
|
||||
}
|
||||
else if (item.period == "off-peak")
|
||||
{
|
||||
dadosTusd.Dem_Reg_FP = item.billed;
|
||||
dadosTusd.Dem_Cont_FP = item.contract;
|
||||
this.dadosTusd.Dem_Reg_FP = item.billed;
|
||||
this.dadosTusd.Dem_Cont_FP = item.contract;
|
||||
}
|
||||
|
||||
if (dadosTusd.Perfil == "AZUL")
|
||||
if (this.dadosTusd.Perfil == "AZUL")
|
||||
{
|
||||
if (item.period == "peak")
|
||||
{
|
||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_P = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
else if (item.period == "off-peak")
|
||||
{
|
||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_FP = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dadosTusd.Perfil == "VERDE")
|
||||
else if (this.dadosTusd.Perfil == "VERDE")
|
||||
{
|
||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_P = @demanda, Demanda_FP = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@ -338,36 +415,36 @@
|
||||
break;
|
||||
|
||||
// Ilum. publica
|
||||
case ("publicLighting", _, _):
|
||||
dadosTusd.Ilum_Publica = item.charge;
|
||||
case ("publicLighting", _):
|
||||
this.dadosTusd.Ilum_Publica = item.charge;
|
||||
break;
|
||||
|
||||
// Energia Reativa
|
||||
case ("excessReactiveEnergy", _, _):
|
||||
dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
||||
case ("excessReactiveEnergy", _):
|
||||
this.dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
||||
break;
|
||||
|
||||
// Demanda Reativa
|
||||
case ("excessReactiveDemand", _, _):
|
||||
dadosTusd.Dem_Reativa_kvar += item.billed;
|
||||
case ("excessReactiveDemand", _):
|
||||
this.dadosTusd.Dem_Reativa_kvar += item.billed;
|
||||
break;
|
||||
|
||||
// Bandeira Tarifaria
|
||||
case ("flagSurcharge", _, _):
|
||||
dadosTusd.Bandeira_RS_MWh = item.charge;
|
||||
case ("flagSurcharge", _):
|
||||
this.dadosTusd.Bandeira_RS_MWh = item.charge;
|
||||
break;
|
||||
|
||||
// Items não classificados
|
||||
case ("other", _, _):
|
||||
case ("other", _):
|
||||
j++;
|
||||
|
||||
// Exclui os items lançados anteriormente para a fatura e cria a instrução SQL para inserir os novos items
|
||||
if (j == 1)
|
||||
{
|
||||
sqlQuery = $"DELETE FROM Dados_TUSD_aux WHERE Cod_TUSD = @cod_tusd";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@ -409,27 +486,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (dem_Reg_P != null && (Math.Round((decimal)dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000)!, 2)))
|
||||
if (dem_Reg_P != null && (Math.Round((decimal)this.dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2)))
|
||||
{
|
||||
dadosTusd.Dem_Reg_P = (float)(dem_Reg_P * 1.025);
|
||||
this.dadosTusd.Dem_Reg_P = (float)(dem_Reg_P * 1.025);
|
||||
}
|
||||
else if (dem_Reg_P != null)
|
||||
{
|
||||
dadosTusd.Dem_Reg_P = (float)dem_Reg_P;
|
||||
this.dadosTusd.Dem_Reg_P = (float)dem_Reg_P;
|
||||
}
|
||||
|
||||
if (dem_Reg_FP != null && (Math.Round((decimal)dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000)!, 2)))
|
||||
if (dem_Reg_FP != null && (Math.Round((decimal)this.dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2)))
|
||||
{
|
||||
dadosTusd.Dem_Reg_FP = (float)(dem_Reg_FP * 1.025);
|
||||
this.dadosTusd.Dem_Reg_FP = (float)(dem_Reg_FP * 1.025);
|
||||
}
|
||||
else if (dem_Reg_FP != null)
|
||||
{
|
||||
dadosTusd.Dem_Reg_FP = dem_Reg_FP ?? 0;
|
||||
this.dadosTusd.Dem_Reg_FP = dem_Reg_FP ?? 0;
|
||||
}
|
||||
|
||||
var dados = dadosTusd.GetType().GetProperties();
|
||||
StringBuilder fields = new StringBuilder();
|
||||
StringBuilder values = new StringBuilder();
|
||||
// var dados = this.dadosTusd.GetType().GetProperties();
|
||||
// StringBuilder fields = new StringBuilder();
|
||||
// StringBuilder values = new StringBuilder();
|
||||
|
||||
// Verifica se já existe a fatura lançada | atualizar fatura ou nova fatura
|
||||
if (tusdLanc)
|
||||
@ -450,17 +527,17 @@
|
||||
// Remova a última vírgula e adicione a cláusula WHERE
|
||||
sqlQuery = sqlQuery.TrimEnd(',', ' ') + $" WHERE Cod_TUSD = @cod_tusd";
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
foreach (PropertyInfo propriedade in propriedades)
|
||||
{
|
||||
string nomeColuna = propriedade.Name;
|
||||
object valorColuna = propriedade.GetValue(dadosTusd) ?? string.Empty;
|
||||
object valorColuna = propriedade.GetValue(this.dadosTusd) ?? string.Empty;
|
||||
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
||||
}
|
||||
|
||||
// Valor do código TUSD na cláusula WHERE
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
@ -470,9 +547,9 @@
|
||||
{
|
||||
j++;
|
||||
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor,0)";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@j", j);
|
||||
cmd.Parameters.AddWithValue("@name", name);
|
||||
cmd.Parameters.AddWithValue("@valor", valor);
|
||||
@ -508,12 +585,12 @@
|
||||
// Remova a última vírgula e feche a instrução SQL
|
||||
sqlQuery = sqlQuery.TrimEnd(',', ' ') + ")";
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
foreach (PropertyInfo propriedade in propriedades)
|
||||
{
|
||||
string nomeColuna = propriedade.Name;
|
||||
object valorColuna = propriedade.GetValue(dadosTusd) ?? string.Empty;
|
||||
object valorColuna = propriedade.GetValue(this.dadosTusd) ?? string.Empty;
|
||||
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
||||
}
|
||||
|
||||
@ -526,9 +603,9 @@
|
||||
{
|
||||
j++;
|
||||
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor, 0)";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@j", j);
|
||||
cmd.Parameters.AddWithValue("@name", name);
|
||||
cmd.Parameters.AddWithValue("@valor", valor);
|
||||
@ -539,13 +616,16 @@
|
||||
|
||||
this.Status = "FATURA INCLUIDA NO BD";
|
||||
this.uc = uc;
|
||||
this.Mes = dadosTusd.Mes;
|
||||
|
||||
this.Mes = this.dadosTusd.Mes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the invoice PDF to the appropriate directory based on its status.
|
||||
/// </summary>
|
||||
/// <param name="separar">If true, split the PDF into the target page range before moving; if false, move the whole file.</param>
|
||||
public void Mover(bool separar)
|
||||
{
|
||||
string destino = string.Empty;
|
||||
string destino;
|
||||
|
||||
switch (this.Status, separar)
|
||||
{
|
||||
@ -555,7 +635,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -577,7 +657,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -606,7 +686,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -628,7 +708,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -649,13 +729,13 @@
|
||||
|
||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\3 - PROCESSANDO\ID {this.id!} - {this.Arquivo?.Name}";
|
||||
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private HttpResponseMessage GetStatus(HttpClient httpClient, string token, string id)
|
||||
private static HttpResponseMessage GetStatus(HttpClient httpClient, string token, string id)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"https://api.4docs.cloud/v2/request/status?id={id}");
|
||||
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {token}");
|
||||
@ -663,7 +743,7 @@
|
||||
return response;
|
||||
}
|
||||
|
||||
private string Req_token(HttpClient httpClient)
|
||||
private static string Req_token(HttpClient httpClient)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/oauth2/token");
|
||||
var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes("smart:vnqtvmesikjzyipc"));
|
||||
@ -674,33 +754,4 @@
|
||||
return JsonDocument.Parse(response.Content.ReadAsStringAsync().Result).RootElement.GetProperty("access_token").GetString() !;
|
||||
}
|
||||
}
|
||||
|
||||
public class PDFSplitter
|
||||
{
|
||||
public PDFSplitter(int? pagina, string origem, string destino)
|
||||
{
|
||||
FileStream document = new FileStream(origem, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
PdfDocument pdfDocument = new PdfDocument(new PdfReader(document));
|
||||
var split = new CustomPdfSplitter(pdfDocument, pageRange => new PdfWriter(destino));
|
||||
PdfDocument result = split.ExtractPageRange(new PageRange(pagina.ToString()));
|
||||
document.Close();
|
||||
result.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomPdfSplitter : PdfSplitter
|
||||
{
|
||||
private Func<PageRange, PdfWriter> nextWriter;
|
||||
|
||||
public CustomPdfSplitter(PdfDocument pdfDocument, Func<PageRange, PdfWriter> nextWriter)
|
||||
: base(pdfDocument)
|
||||
{
|
||||
this.nextWriter = nextWriter;
|
||||
}
|
||||
|
||||
protected override PdfWriter GetNextPdfWriter(PageRange documentPageRange)
|
||||
{
|
||||
return this.nextWriter.Invoke(documentPageRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,8 @@
|
||||
namespace Download_Faturas
|
||||
// <copyright file="FaturaOld.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Data.OleDb;
|
||||
using System.Globalization;
|
||||
@ -12,19 +16,29 @@
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing the old invoice processing logic.
|
||||
/// </summary>
|
||||
public class FaturaOld
|
||||
{
|
||||
private const string Token = "UFY4VWzqcHYcGNd0gkBOMFL9G5ZThV6gXBQIJ79F5HSqITzavz4Fe7iXvAbJLvZJ";
|
||||
private JsonElement faturaParsed;
|
||||
private string? id;
|
||||
private readonly JsonElement faturaParsed;
|
||||
private readonly string? id;
|
||||
private readonly int? pagina;
|
||||
private readonly RecordSet dadosTusd = new ();
|
||||
private string? uc;
|
||||
private int? pagina;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FaturaOld"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the invoice.</param>
|
||||
/// <param name="fatura_path">The file path of the invoice.</param>
|
||||
/// <param name="httpClient">The HTTP client used for requests.</param>
|
||||
public FaturaOld(string id, string fatura_path, HttpClient httpClient)
|
||||
{
|
||||
// Utilizado para gerar novo token
|
||||
// this.token = Req_token(httpClient).ToString();
|
||||
HttpResponseMessage fatura_response = this.GetStatus(httpClient, Token, id);
|
||||
// this.token = Req_token(HttpClient).ToString();
|
||||
HttpResponseMessage fatura_response = GetStatus(httpClient, Token, id);
|
||||
if (fatura_response.IsSuccessStatusCode)
|
||||
{
|
||||
this.faturaParsed = JsonDocument.Parse(fatura_response.Content.ReadAsStringAsync().Result).RootElement;
|
||||
@ -45,42 +59,78 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FaturaOld"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier of the invoice.</param>
|
||||
/// <param name="fatura_Parsed">The parsed JSON element of the invoice.</param>
|
||||
public FaturaOld(string id, JsonElement fatura_Parsed)
|
||||
{
|
||||
// Utilizado para gerar novo token
|
||||
// this.token = Req_token(httpClient).ToString();
|
||||
// this.token = Req_token(HttpClient).ToString();
|
||||
this.faturaParsed = fatura_Parsed;
|
||||
this.Agrupada = false;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TUSD code for the invoice.
|
||||
/// </summary>
|
||||
public double CodTusd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the consumer managing group associated with the invoice.
|
||||
/// </summary>
|
||||
public string? Gestao { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the company associated with the invoice.
|
||||
/// </summary>
|
||||
public string? Empresa { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unit associated with the invoice.
|
||||
/// </summary>
|
||||
public string? Unidade { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the month associated with the invoice.
|
||||
/// </summary>
|
||||
public int? Mes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of the invoice.
|
||||
/// </summary>
|
||||
public string? Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file information associated with the invoice.
|
||||
/// </summary>
|
||||
public FileInfo? Arquivo { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the directory information for TUSD associated with the invoice.
|
||||
/// </summary>
|
||||
public DirectoryInfo? PastaTUSD { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the invoice is grouped.
|
||||
/// </summary>
|
||||
public bool Agrupada { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the children invoices if the invoice is grouped.
|
||||
/// </summary>
|
||||
public JsonElement.ArrayEnumerator Agrupada_children { get; private set; }
|
||||
|
||||
// Variavel para armazenar os dados a serem lancados para a TUSD no BD
|
||||
public RecordSet dadosTusd = new ();
|
||||
|
||||
public double cod_tusd;
|
||||
/// <summary>
|
||||
/// Processes the invoice and writes data to the database.
|
||||
/// </summary>
|
||||
/// <param name="conn">The database connection to use for processing.</param>
|
||||
public void Processar(OleDbConnection conn)
|
||||
{
|
||||
// Resultado da fatura processada
|
||||
JsonElement a;
|
||||
if (!this.faturaParsed.TryGetProperty("result", out a))
|
||||
if (!this.faturaParsed.TryGetProperty("result", out JsonElement a))
|
||||
{
|
||||
this.faturaParsed.TryGetProperty("json", out a);
|
||||
}
|
||||
@ -91,14 +141,14 @@
|
||||
return;
|
||||
}
|
||||
|
||||
dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
||||
this.dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
||||
|
||||
string uc = new Regex("^0+").Replace(parsedResult.locationNumber, string.Empty).Replace("/", string.Empty).Replace("-", string.Empty).Replace(".", string.Empty);
|
||||
|
||||
// Vinculo da fatura com os dados cadastrais
|
||||
int? unidades;
|
||||
string sqlQuery = $"SELECT COUNT (Cod_Smart_unidade) FROM Dados_cadastrais WHERE Codigo_Instalacao = @uc AND unidade_gerenciada";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@uc", uc);
|
||||
|
||||
@ -114,7 +164,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
if (unidades == 1)
|
||||
{
|
||||
@ -132,25 +182,25 @@
|
||||
while (reader.Read())
|
||||
{
|
||||
// Dados cadastrais
|
||||
dadosTusd.Cod_Smart_unidade = long.Parse(reader["Cod_Smart_unidade"].ToString()!);
|
||||
dadosTusd.Perfil_CliqCCEE = reader["PerfilCCEE"].ToString();
|
||||
dadosTusd.Submercado = reader["Submercado"].ToString();
|
||||
this.dadosTusd.Cod_Smart_unidade = long.Parse(reader["Cod_Smart_unidade"].ToString() !);
|
||||
this.dadosTusd.Perfil_CliqCCEE = reader["PerfilCCEE"].ToString();
|
||||
this.dadosTusd.Submercado = reader["Submercado"].ToString();
|
||||
DateTime dataMigração = DateTime.Parse(reader["Data_de_Migracao"].ToString() !);
|
||||
if (int.Parse(dataMigração.ToString("yMM")) <= dadosTusd.Mes)
|
||||
if (int.Parse(dataMigração.ToString("yMM")) <= this.dadosTusd.Mes)
|
||||
{
|
||||
dadosTusd.Ambiente = reader["Status_unidade"].ToString();
|
||||
this.dadosTusd.Ambiente = reader["Status_unidade"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
dadosTusd.Ambiente = "Cativo";
|
||||
this.dadosTusd.Ambiente = "Cativo";
|
||||
}
|
||||
|
||||
dadosTusd.Grupo = reader["Grupo"].ToString();
|
||||
dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
||||
dadosTusd.ICMS = float.Parse(reader["ICMS_TUSD"].ToString()!);
|
||||
dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString()!);
|
||||
dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString()!);
|
||||
dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||
this.dadosTusd.Grupo = reader["Grupo"].ToString();
|
||||
this.dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
||||
this.dadosTusd.ICMS = float.Parse(reader["ICMS_TUSD"].ToString() !);
|
||||
this.dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString() !);
|
||||
this.dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString() !);
|
||||
this.dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||
this.PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty, StringComparison.OrdinalIgnoreCase) + "\\TUSD");
|
||||
this.Gestao = reader["Gestao"].ToString();
|
||||
this.Empresa = reader["Cliente"].ToString();
|
||||
@ -163,10 +213,10 @@
|
||||
bool tusdLanc;
|
||||
|
||||
sqlQuery = $"SELECT Cod_TUSD FROM Dados_TUSD WHERE Cod_TUSD = ?";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cod_tusd = double.Parse(dadosTusd.Cod_Smart_unidade.ToString() + dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", cod_tusd);
|
||||
this.CodTusd = double.Parse(this.dadosTusd.Cod_Smart_unidade.ToString() + this.dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", this.CodTusd);
|
||||
|
||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
@ -174,82 +224,82 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (dadosTusd.Cod_Smart_unidade == 0)
|
||||
if (this.dadosTusd.Cod_Smart_unidade == 0)
|
||||
{
|
||||
this.Status = "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD";
|
||||
this.uc = uc;
|
||||
this.Mes = dadosTusd.Mes;
|
||||
this.Mes = this.dadosTusd.Mes;
|
||||
return;
|
||||
}
|
||||
else if (tusdLanc)
|
||||
{
|
||||
this.Status = "FATURA DUPLICADA NO BD";
|
||||
this.uc = uc;
|
||||
this.Mes = dadosTusd.Mes;
|
||||
this.Mes = this.dadosTusd.Mes;
|
||||
return;
|
||||
}
|
||||
|
||||
// PIS e Cofins
|
||||
sqlQuery = $"SELECT Distribuidoras_PIS.PIS, Distribuidoras_PIS.COFINS FROM Distribuidoras_geral INNER JOIN Distribuidoras_PIS ON Distribuidoras_geral.ID_dist = Distribuidoras_PIS.ID_dist WHERE Distribuidoras_PIS.Mes = ? AND Distribuidoras_geral.Distribuidora = ?";
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?", dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", dadosTusd.Distribuidora);
|
||||
cmd.Parameters.AddWithValue("?", this.dadosTusd.Mes.ToString());
|
||||
cmd.Parameters.AddWithValue("?", this.dadosTusd.Distribuidora);
|
||||
|
||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
// PIS e Cofins
|
||||
dadosTusd.PIS = float.Parse(reader["PIS"].ToString()!);
|
||||
dadosTusd.COFINS = float.Parse(reader["COFINS"].ToString()!);
|
||||
this.dadosTusd.PIS = float.Parse(reader["PIS"].ToString() !);
|
||||
this.dadosTusd.COFINS = float.Parse(reader["COFINS"].ToString() !);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dados da fatura processada
|
||||
dadosTusd.Cod_TUSD = long.Parse(dadosTusd.Cod_Smart_unidade.ToString() + dadosTusd.Mes.ToString());
|
||||
this.dadosTusd.Cod_TUSD = long.Parse(this.dadosTusd.Cod_Smart_unidade.ToString() + this.dadosTusd.Mes.ToString());
|
||||
switch (parsedResult.tariffModality, parsedResult.subgroup)
|
||||
{
|
||||
case ("blue", _):
|
||||
dadosTusd.Perfil = "AZUL";
|
||||
this.dadosTusd.Perfil = "AZUL";
|
||||
break;
|
||||
|
||||
case ("green", _):
|
||||
dadosTusd.Perfil = "VERDE";
|
||||
this.dadosTusd.Perfil = "VERDE";
|
||||
break;
|
||||
|
||||
case ("standart", _):
|
||||
dadosTusd.Perfil = "CONVENCIONAL";
|
||||
this.dadosTusd.Perfil = "CONVENCIONAL";
|
||||
break;
|
||||
|
||||
case (_, "B3"):
|
||||
dadosTusd.Perfil = "CONVENCIONAL";
|
||||
this.dadosTusd.Perfil = "CONVENCIONAL";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dadosTusd.Valor = parsedResult.totalCharges;
|
||||
dadosTusd.Inicio_Leitura = parsedResult.dates.reading.periodFrom;
|
||||
dadosTusd.Fim_leitura = parsedResult.dates.reading.periodUntil;
|
||||
this.dadosTusd.Valor = parsedResult.totalCharges;
|
||||
this.dadosTusd.Inicio_Leitura = parsedResult.dates.reading.periodFrom;
|
||||
this.dadosTusd.Fim_leitura = parsedResult.dates.reading.periodUntil;
|
||||
DateTime d = DateTime.Now;
|
||||
dadosTusd.Hora_TUSD = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
||||
dadosTusd.Dem_Reativa_kvar = 0;
|
||||
dadosTusd.Multa = 0;
|
||||
dadosTusd.Credito = 0;
|
||||
dadosTusd.Bandeira_RS_MWh = 0;
|
||||
dadosTusd.FIC_DIC = 0;
|
||||
dadosTusd.Enc_conexao = 0;
|
||||
dadosTusd.Liminar_ICMS = 0;
|
||||
dadosTusd.Outros = 0;
|
||||
dadosTusd.Cred_livre = 0;
|
||||
dadosTusd.Tempo_TUSD = 0;
|
||||
dadosTusd.Lanc_aut = true;
|
||||
dadosTusd.Rev_atual = true;
|
||||
dadosTusd.Revisao = 0;
|
||||
this.dadosTusd.Hora_TUSD = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
||||
this.dadosTusd.Dem_Reativa_kvar = 0;
|
||||
this.dadosTusd.Multa = 0;
|
||||
this.dadosTusd.Credito = 0;
|
||||
this.dadosTusd.Bandeira_RS_MWh = 0;
|
||||
this.dadosTusd.FIC_DIC = 0;
|
||||
this.dadosTusd.Enc_conexao = 0;
|
||||
this.dadosTusd.Liminar_ICMS = 0;
|
||||
this.dadosTusd.Outros = 0;
|
||||
this.dadosTusd.Cred_livre = 0;
|
||||
this.dadosTusd.Tempo_TUSD = 0;
|
||||
this.dadosTusd.Lanc_aut = true;
|
||||
this.dadosTusd.Rev_atual = true;
|
||||
this.dadosTusd.Revisao = 0;
|
||||
|
||||
// Loop entre os dados faturados na fatura
|
||||
int j = 0;
|
||||
@ -259,13 +309,7 @@
|
||||
string? kind_P = 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 = [];
|
||||
foreach (Item item in parsedResult.items)
|
||||
{
|
||||
switch (item.type, item.period)
|
||||
@ -279,7 +323,7 @@
|
||||
|
||||
if (item.kind == kind_P)
|
||||
{
|
||||
dadosTusd.Consumo_P += item.billed / 1000;
|
||||
this.dadosTusd.Consumo_P += item.billed / 1000;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -295,7 +339,7 @@
|
||||
|
||||
if (item.kind == kind_FP)
|
||||
{
|
||||
dadosTusd.Consumo_FP += item.billed / 1000;
|
||||
this.dadosTusd.Consumo_FP += item.billed / 1000;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -312,45 +356,45 @@
|
||||
{
|
||||
if (item.period == "peak")
|
||||
{
|
||||
dadosTusd.Dem_Reg_P = item.billed;
|
||||
dadosTusd.Dem_Cont_P = item.contract;
|
||||
this.dadosTusd.Dem_Reg_P = item.billed;
|
||||
this.dadosTusd.Dem_Cont_P = item.contract;
|
||||
}
|
||||
else if (item.period == "off-peak")
|
||||
{
|
||||
dadosTusd.Dem_Reg_FP = item.billed;
|
||||
dadosTusd.Dem_Cont_FP = item.contract;
|
||||
this.dadosTusd.Dem_Reg_FP = item.billed;
|
||||
this.dadosTusd.Dem_Cont_FP = item.contract;
|
||||
}
|
||||
|
||||
if (dadosTusd.Perfil == "AZUL")
|
||||
if (this.dadosTusd.Perfil == "AZUL")
|
||||
{
|
||||
if (item.period == "peak")
|
||||
{
|
||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_P = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
else if (item.period == "off-peak")
|
||||
{
|
||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_FP = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dadosTusd.Perfil == "VERDE")
|
||||
else if (this.dadosTusd.Perfil == "VERDE")
|
||||
{
|
||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_P = @demanda, Demanda_FP = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@ -360,22 +404,22 @@
|
||||
|
||||
// Ilum. publica
|
||||
case ("publicLighting", _):
|
||||
dadosTusd.Ilum_Publica = item.charge;
|
||||
this.dadosTusd.Ilum_Publica = item.charge;
|
||||
break;
|
||||
|
||||
// Energia Reativa
|
||||
case ("excessReactiveEnergy", _):
|
||||
dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
||||
this.dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
||||
break;
|
||||
|
||||
// Demanda Reativa
|
||||
case ("excessReactiveDemand", _):
|
||||
dadosTusd.Dem_Reativa_kvar += item.billed;
|
||||
this.dadosTusd.Dem_Reativa_kvar += item.billed;
|
||||
break;
|
||||
|
||||
// Bandeira Tarifaria
|
||||
case ("flagSurcharge", _):
|
||||
dadosTusd.Bandeira_RS_MWh = item.charge;
|
||||
this.dadosTusd.Bandeira_RS_MWh = item.charge;
|
||||
break;
|
||||
|
||||
// Items não classificados
|
||||
@ -386,9 +430,9 @@
|
||||
if (j == 1)
|
||||
{
|
||||
sqlQuery = $"DELETE FROM Dados_TUSD_aux WHERE Cod_TUSD = @cod_tusd";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
@ -430,27 +474,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (dem_Reg_P != null && (Math.Round((decimal)dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000)!, 2)))
|
||||
if (dem_Reg_P != null && (Math.Round((decimal)this.dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2)))
|
||||
{
|
||||
dadosTusd.Dem_Reg_P = (float)(dem_Reg_P * 1.025);
|
||||
this.dadosTusd.Dem_Reg_P = (float)(dem_Reg_P * 1.025);
|
||||
}
|
||||
else if (dem_Reg_P != null)
|
||||
{
|
||||
dadosTusd.Dem_Reg_P = (float)dem_Reg_P;
|
||||
this.dadosTusd.Dem_Reg_P = (float)dem_Reg_P;
|
||||
}
|
||||
|
||||
if (dem_Reg_FP != null && (Math.Round((decimal)dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000)!, 2)))
|
||||
if (dem_Reg_FP != null && (Math.Round((decimal)this.dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2)))
|
||||
{
|
||||
dadosTusd.Dem_Reg_FP = (float)(dem_Reg_FP * 1.025);
|
||||
this.dadosTusd.Dem_Reg_FP = (float)(dem_Reg_FP * 1.025);
|
||||
}
|
||||
else if (dem_Reg_FP != null)
|
||||
{
|
||||
dadosTusd.Dem_Reg_FP = dem_Reg_FP ?? 0;
|
||||
this.dadosTusd.Dem_Reg_FP = dem_Reg_FP ?? 0;
|
||||
}
|
||||
|
||||
var dados = dadosTusd.GetType().GetProperties();
|
||||
StringBuilder fields = new StringBuilder();
|
||||
StringBuilder values = new StringBuilder();
|
||||
// var dados = this.dadosTusd.GetType().GetProperties();
|
||||
// StringBuilder fields = new StringBuilder();
|
||||
// StringBuilder values = new StringBuilder();
|
||||
|
||||
// Verifica se já existe a fatura lançada | atualizar fatura ou nova fatura
|
||||
if (tusdLanc)
|
||||
@ -471,17 +515,17 @@
|
||||
// Remova a última vírgula e adicione a cláusula WHERE
|
||||
sqlQuery = sqlQuery.TrimEnd(',', ' ') + $" WHERE Cod_TUSD = @cod_tusd";
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
foreach (PropertyInfo propriedade in propriedades)
|
||||
{
|
||||
string nomeColuna = propriedade.Name;
|
||||
object valorColuna = propriedade.GetValue(dadosTusd) ?? string.Empty;
|
||||
object valorColuna = propriedade.GetValue(this.dadosTusd) ?? string.Empty;
|
||||
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
||||
}
|
||||
|
||||
// Valor do código TUSD na cláusula WHERE
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
@ -491,9 +535,9 @@
|
||||
{
|
||||
j++;
|
||||
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor,0)";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@j", j);
|
||||
cmd.Parameters.AddWithValue("@name", name);
|
||||
cmd.Parameters.AddWithValue("@valor", valor);
|
||||
@ -529,12 +573,12 @@
|
||||
// Remova a última vírgula e feche a instrução SQL
|
||||
sqlQuery = sqlQuery.TrimEnd(',', ' ') + ")";
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
foreach (PropertyInfo propriedade in propriedades)
|
||||
{
|
||||
string nomeColuna = propriedade.Name;
|
||||
object valorColuna = propriedade.GetValue(dadosTusd) ?? string.Empty;
|
||||
object valorColuna = propriedade.GetValue(this.dadosTusd) ?? string.Empty;
|
||||
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
||||
}
|
||||
|
||||
@ -547,9 +591,9 @@
|
||||
{
|
||||
j++;
|
||||
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor, 0)";
|
||||
using (OleDbCommand cmd = new OleDbCommand(sqlQuery, conn))
|
||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
||||
cmd.Parameters.AddWithValue("@j", j);
|
||||
cmd.Parameters.AddWithValue("@name", name);
|
||||
cmd.Parameters.AddWithValue("@valor", valor);
|
||||
@ -560,13 +604,16 @@
|
||||
|
||||
this.Status = "FATURA INCLUIDA NO BD";
|
||||
this.uc = uc;
|
||||
this.Mes = dadosTusd.Mes;
|
||||
|
||||
this.Mes = this.dadosTusd.Mes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the invoice file based on its status.
|
||||
/// </summary>
|
||||
/// <param name="separar">Indicates whether to split the PDF before moving.</param>
|
||||
public void Mover(bool separar)
|
||||
{
|
||||
string destino = string.Empty;
|
||||
string destino;
|
||||
|
||||
switch (this.Status, separar)
|
||||
{
|
||||
@ -576,7 +623,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -598,7 +645,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -627,7 +674,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -649,7 +696,7 @@
|
||||
|
||||
if (separar)
|
||||
{
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
}
|
||||
else
|
||||
@ -670,13 +717,13 @@
|
||||
|
||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\3 - PROCESSANDO\ID {this.id!} - {this.Arquivo?.Name}";
|
||||
|
||||
new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
||||
this.Arquivo = new FileInfo(destino);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private HttpResponseMessage GetStatus(HttpClient httpClient, string token, string id)
|
||||
private static HttpResponseMessage GetStatus(HttpClient httpClient, string token, string id)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"https://api.4docs.cloud/v2/request/status?id={id}");
|
||||
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {token}");
|
||||
@ -684,7 +731,7 @@
|
||||
return response;
|
||||
}
|
||||
|
||||
private string Req_token(HttpClient httpClient)
|
||||
private static string Req_token(HttpClient httpClient)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/oauth2/token");
|
||||
var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes("smart:vnqtvmesikjzyipc"));
|
||||
|
||||
@ -1,12 +1,27 @@
|
||||
namespace Download_Faturas
|
||||
// <copyright file="FloatArrayOrSingleConverter.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// Custom JSON converter to handle float arrays or single float values.
|
||||
/// </summary>
|
||||
public class FloatArrayOrSingleConverter : JsonConverter<float[]>
|
||||
{
|
||||
public override float[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
/// <summary>
|
||||
/// Reads and converts the JSON to either a float array or a single float value.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader to read from.</param>
|
||||
/// <param name="typeToConvert">The type to convert.</param>
|
||||
/// <param name="options">Serialization options.</param>
|
||||
/// <returns>The converted float array.</returns>
|
||||
/// <exception cref="JsonException">Thrown when the JSON token is not an array or a number.</exception>
|
||||
public override float[]? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.StartArray)
|
||||
{
|
||||
@ -16,7 +31,7 @@
|
||||
else if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
// Se for um único valor, cria um array com esse valor
|
||||
return new float[] { reader.GetSingle() };
|
||||
return [reader.GetSingle()];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -24,6 +39,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the float array or single float value to JSON.
|
||||
/// </summary>
|
||||
/// <param name="writer">The writer to write to.</param>
|
||||
/// <param name="value">The float array value to write.</param>
|
||||
/// <param name="options">Serialization options.</param>
|
||||
public override void Write(Utf8JsonWriter writer, float[] value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value.Length == 1)
|
||||
|
||||
16
Download Faturas/GlobalSuppressions.cs
Normal file
16
Download Faturas/GlobalSuppressions.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// <copyright file="GlobalSuppressions.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Fatura.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1011:Closing square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.FloatArrayOrSingleConverter.Read(System.Text.Json.Utf8JsonReader@,System.Type,System.Text.Json.JsonSerializerOptions)~System.Single[]")]
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1009:Closing parenthesis should be spaced correctly", Justification = "<Pendente>", Scope = "type", Target = "~T:Download_Faturas.CustomPdfSplitter")]
|
||||
[assembly: SuppressMessage("Performance", "SYSLIB1045:Converter em 'GeneratedRegexAttribute'.", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Fatura.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Fatura.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||
[assembly: SuppressMessage("Performance", "SYSLIB1045:Converter em 'GeneratedRegexAttribute'.", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.FaturaOld.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.FaturaOld.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.FaturaOld.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||
[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.FloatArrayOrSingleConverter.Read(System.Text.Json.Utf8JsonReader@,System.Type,System.Text.Json.JsonSerializerOptions)~System.Single[]")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Program.Main")]
|
||||
40
Download Faturas/PDFSplitter.cs
Normal file
40
Download Faturas/PDFSplitter.cs
Normal file
@ -0,0 +1,40 @@
|
||||
// <copyright file="PDFSplitter.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Data.OleDb;
|
||||
using System.Globalization;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Class for splitting PDF documents.
|
||||
/// </summary>
|
||||
public class PDFSplitter
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PDFSplitter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="pagina">The 1-based page number to extract; if null, the whole document is used.</param>
|
||||
/// <param name="origem">Full path to the source PDF file to read.</param>
|
||||
/// <param name="destino">Full path to the destination PDF file to create containing the extracted pages.</param>
|
||||
public PDFSplitter(int? pagina, string origem, string destino)
|
||||
{
|
||||
FileStream document = new (origem, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
PdfDocument pdfDocument = new (new PdfReader(document));
|
||||
var split = new CustomPdfSplitter(pdfDocument, pageRange => new PdfWriter(destino));
|
||||
PdfDocument result = split.ExtractPageRange(new PageRange(pagina.ToString()));
|
||||
document.Close();
|
||||
result.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,8 @@
|
||||
namespace Download_Faturas
|
||||
// <copyright file="Program.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Data.OleDb;
|
||||
using System.Globalization;
|
||||
@ -7,53 +11,64 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/// <summary>
|
||||
/// Main program class for processing invoices.
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// Path to the log file for invoices.
|
||||
/// </summary>
|
||||
public const string LogFaturas = @"X:\Back\Carteira x.x\4Docs\import.txt";
|
||||
|
||||
/// <summary>
|
||||
/// Path to the secondary log file for invoices.
|
||||
/// </summary>
|
||||
public const string LogFaturas2 = @"X:\Back\Carteira x.x\4Docs\import2.txt";
|
||||
#else
|
||||
public const String LogFaturas = "import.txt";
|
||||
public const String LogFaturas2 = "import2.txt";
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Path to the database file.
|
||||
/// </summary>
|
||||
public const string CaminhoDB = "X:/Middle/Informativo Setorial/Modelo Word/BD1_dados cadastrais e faturas.accdb";
|
||||
private static HttpClient httpClient = new ();
|
||||
private static StreamReader sr = new (LogFaturas);
|
||||
private static StreamWriter sw = new (LogFaturas2);
|
||||
private static readonly HttpClient HttpClient = new ();
|
||||
private static readonly StreamReader Sr = new (LogFaturas);
|
||||
private static readonly StreamWriter Sw = new (LogFaturas2);
|
||||
private static string? fatura;
|
||||
|
||||
/// <summary>
|
||||
/// Main entry point of the program.
|
||||
/// </summary>
|
||||
public static void Main()
|
||||
{
|
||||
// Abre a conexao com o banco de dados
|
||||
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21"))
|
||||
using (OleDbConnection conn = new (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21"))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
// Loop entre as faturas pendentes
|
||||
while ((fatura = sr.ReadLine()) != null)
|
||||
while ((fatura = Sr.ReadLine()) != null)
|
||||
{
|
||||
string fatura_ID = fatura.Split(",")[0];
|
||||
string fatura_status = fatura.Split(",")[1];
|
||||
string fatura_arquivo = fatura.Split(",")[2];
|
||||
|
||||
if (fatura_ID == "1826871")
|
||||
{
|
||||
int i = 0;
|
||||
i++;
|
||||
}
|
||||
|
||||
// Verifica se a fatura foi processada e atualiza os valores para banco de dados
|
||||
if (fatura_status == "DELAYED" | fatura_status == "MULTACTIONABLE" | fatura_status == "ACTIONABLE" | fatura_status == string.Empty | fatura_status == "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD" | fatura_status == "PREPROCESS")
|
||||
{
|
||||
if (fatura_status == "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD" && !File.Exists(fatura_arquivo))
|
||||
{
|
||||
sw.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura_arquivo);
|
||||
Sw.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura_arquivo);
|
||||
Console.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura_arquivo);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verifica se a fatura foi processada e atualiza os valores para o banco de dados
|
||||
Fatura fatura = new Fatura(fatura_ID, fatura_arquivo, httpClient);
|
||||
Fatura fatura = new (fatura_ID, fatura_arquivo, HttpClient);
|
||||
|
||||
if (fatura.Status == "SUCCESS" & !fatura.Agrupada)
|
||||
{
|
||||
@ -61,12 +76,12 @@
|
||||
try
|
||||
{
|
||||
fatura.Mover(separar: false);
|
||||
sw.WriteLine(fatura_ID + "," + fatura.Status + "," + fatura.Arquivo);
|
||||
Sw.WriteLine(fatura_ID + "," + fatura.Status + "," + fatura.Arquivo);
|
||||
Console.WriteLine(fatura_ID + "," + fatura.Status + "," + fatura.Arquivo);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
sw.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura.Arquivo);
|
||||
Sw.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura.Arquivo);
|
||||
Console.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura.Arquivo);
|
||||
}
|
||||
}
|
||||
@ -74,7 +89,7 @@
|
||||
{
|
||||
foreach (JsonElement individual_ID in fatura.Agrupada_children)
|
||||
{
|
||||
Fatura faturaIndividual = new (individual_ID.ToString(), fatura_arquivo, httpClient);
|
||||
Fatura faturaIndividual = new (individual_ID.ToString(), fatura_arquivo, HttpClient);
|
||||
|
||||
if (faturaIndividual.Status == "SUCCESS")
|
||||
{
|
||||
@ -82,12 +97,12 @@
|
||||
try
|
||||
{
|
||||
faturaIndividual.Mover(separar: true);
|
||||
sw.WriteLine(individual_ID.ToString() + "," + faturaIndividual.Status + "," + faturaIndividual.Arquivo);
|
||||
Sw.WriteLine(individual_ID.ToString() + "," + faturaIndividual.Status + "," + faturaIndividual.Arquivo);
|
||||
Console.WriteLine(individual_ID.ToString() + "," + faturaIndividual.Status + "," + faturaIndividual.Arquivo);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
sw.WriteLine(individual_ID.ToString() + "," + "ARQUIVO NÃO LOCALIZADO" + "," + faturaIndividual.Arquivo);
|
||||
Sw.WriteLine(individual_ID.ToString() + "," + "ARQUIVO NÃO LOCALIZADO" + "," + faturaIndividual.Arquivo);
|
||||
Console.WriteLine(individual_ID.ToString() + "," + "ARQUIVO NÃO LOCALIZADO" + "," + faturaIndividual.Arquivo);
|
||||
}
|
||||
}
|
||||
@ -96,12 +111,12 @@
|
||||
try
|
||||
{
|
||||
faturaIndividual.Mover(separar: true);
|
||||
sw.WriteLine(individual_ID.ToString() + "," + faturaIndividual.Status + "," + faturaIndividual.Arquivo);
|
||||
Sw.WriteLine(individual_ID.ToString() + "," + faturaIndividual.Status + "," + faturaIndividual.Arquivo);
|
||||
Console.WriteLine(individual_ID.ToString() + "," + faturaIndividual.Status + "," + faturaIndividual.Arquivo);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
sw.WriteLine(individual_ID.ToString() + "," + "ARQUIVO NÃO LOCALIZADO" + "," + faturaIndividual.Arquivo);
|
||||
Sw.WriteLine(individual_ID.ToString() + "," + "ARQUIVO NÃO LOCALIZADO" + "," + faturaIndividual.Arquivo);
|
||||
Console.WriteLine(individual_ID.ToString() + "," + "ARQUIVO NÃO LOCALIZADO" + "," + faturaIndividual.Arquivo);
|
||||
}
|
||||
}
|
||||
@ -117,26 +132,26 @@
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
sw.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura.Arquivo);
|
||||
Sw.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura.Arquivo);
|
||||
Console.WriteLine(fatura_ID + "," + "ARQUIVO NÃO LOCALIZADO" + "," + fatura.Arquivo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sw.WriteLine(fatura_ID + "," + fatura.Status + "," + fatura_arquivo);
|
||||
Sw.WriteLine(fatura_ID + "," + fatura.Status + "," + fatura_arquivo);
|
||||
Console.WriteLine(fatura_ID + "," + fatura.Status + "," + fatura_arquivo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sw.WriteLine(fatura);
|
||||
Sw.WriteLine(fatura);
|
||||
Console.WriteLine(fatura);
|
||||
}
|
||||
}
|
||||
|
||||
sr.Close();
|
||||
sw.Close();
|
||||
Sr.Close();
|
||||
Sw.Close();
|
||||
File.Move(LogFaturas2, LogFaturas, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,100 +1,249 @@
|
||||
namespace Download_Faturas
|
||||
// <copyright file="RecordSet.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
/// <summary>
|
||||
/// Record set class representing invoice data.
|
||||
/// </summary>
|
||||
public class RecordSet
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the TUSD code.
|
||||
/// </summary>
|
||||
public double Cod_TUSD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Smart unit code.
|
||||
/// </summary>
|
||||
public double Cod_Smart_unidade { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the month.
|
||||
/// </summary>
|
||||
public int Mes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the revision.
|
||||
/// </summary>
|
||||
public int Revisao { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this is the current revision.
|
||||
/// </summary>
|
||||
public bool Rev_atual { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TUSD hour.
|
||||
/// </summary>
|
||||
public DateTime Hora_TUSD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TUSD time.
|
||||
/// </summary>
|
||||
public int Tempo_TUSD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CliqCCEE profile.
|
||||
/// </summary>
|
||||
public string? Perfil_CliqCCEE { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the submarket.
|
||||
/// </summary>
|
||||
public string? Submercado { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the environment.
|
||||
/// </summary>
|
||||
public string? Ambiente { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the distributor.
|
||||
/// </summary>
|
||||
public string? Distribuidora { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the group.
|
||||
/// </summary>
|
||||
public string? Grupo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the profile.
|
||||
/// </summary>
|
||||
public string? Perfil { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the start of the reading period.
|
||||
/// </summary>
|
||||
public DateTime Inicio_Leitura { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end of the reading period.
|
||||
/// </summary>
|
||||
public DateTime Fim_leitura { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
public float Valor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the P consumption.
|
||||
/// </summary>
|
||||
public float Consumo_P { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the FP consumption.
|
||||
/// </summary>
|
||||
public float Consumo_FP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the registered P demand.
|
||||
/// </summary>
|
||||
public float Dem_Reg_P { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the registered FP demand.
|
||||
/// </summary>
|
||||
public float Dem_Reg_FP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the contracted P demand.
|
||||
/// </summary>
|
||||
public float Dem_Cont_P { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the contracted FP demand.
|
||||
/// </summary>
|
||||
public float Dem_Cont_FP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the PIS value.
|
||||
/// </summary>
|
||||
public float PIS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the COFINS value.
|
||||
/// </summary>
|
||||
public float COFINS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ICMS value.
|
||||
/// </summary>
|
||||
public float ICMS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the public lighting value.
|
||||
/// </summary>
|
||||
public float Ilum_Publica { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fine value.
|
||||
/// </summary>
|
||||
public float Multa { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the credit value.
|
||||
/// </summary>
|
||||
public float Credito { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the other values.
|
||||
/// </summary>
|
||||
public float Outros { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reactive energy in Mvarh.
|
||||
/// </summary>
|
||||
public float En_Reativa_Mvarh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reactive demand in kvar.
|
||||
/// </summary>
|
||||
public float Dem_Reativa_kvar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Bandeira RS in MWh.
|
||||
/// </summary>
|
||||
public float Bandeira_RS_MWh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Liminar ICMS value.
|
||||
/// </summary>
|
||||
public float Liminar_ICMS { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection charge.
|
||||
/// </summary>
|
||||
public float Enc_conexao { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the FIC DIC value.
|
||||
/// </summary>
|
||||
public float FIC_DIC { get; set; }
|
||||
|
||||
// public string Hora_compliance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the P billed demand.
|
||||
/// </summary>
|
||||
public float Dem_Fat_P { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the FP billed demand.
|
||||
/// </summary>
|
||||
public float Dem_Fat_FP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reactive real value.
|
||||
/// </summary>
|
||||
public float Reativos_reais { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reactive real value.
|
||||
/// </summary>
|
||||
public float Ultrapassagem_reais { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Bandeira real value.
|
||||
/// </summary>
|
||||
public float Bandeira_reais { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the compliance calculation value.
|
||||
/// </summary>
|
||||
public float Compliance_calc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the compliance is correct.
|
||||
/// </summary>
|
||||
public bool Compliance_Correto { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether DEVEC is declared.
|
||||
/// </summary>
|
||||
public bool Decl_DEVEC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the free market credit value.
|
||||
/// </summary>
|
||||
public float Cred_livre { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the internal comments.
|
||||
/// </summary>
|
||||
public string? Coment_int { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the client comments.
|
||||
/// </summary>
|
||||
public string? Coment_cli { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the entry is automatic.
|
||||
/// </summary>
|
||||
public bool Lanc_aut { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,142 +1,333 @@
|
||||
namespace Download_Faturas
|
||||
// <copyright file="Rootobject.cs" company="Smart Energia">
|
||||
// Copyright (c) Smart Energia. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
#pragma warning disable CS8618, SA1300, SA1402
|
||||
|
||||
/// <summary>
|
||||
/// Root object class representing the invoice JSON structure.
|
||||
/// </summary>
|
||||
public class Rootobject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the version.
|
||||
/// </summary>
|
||||
public string version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MD5 hash.
|
||||
/// </summary>
|
||||
public string md5 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider.
|
||||
/// </summary>
|
||||
public string provider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the provider data.
|
||||
/// </summary>
|
||||
public Providerdata providerData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the location number.
|
||||
/// </summary>
|
||||
public string locationNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the subclass.
|
||||
/// </summary>
|
||||
public string subclass { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the subgroup.
|
||||
/// </summary>
|
||||
public string subgroup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the customer.
|
||||
/// </summary>
|
||||
public Customer customer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the losses.
|
||||
/// </summary>
|
||||
public float losses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the total charges.
|
||||
/// </summary>
|
||||
public float totalCharges { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the tariff modality.
|
||||
/// </summary>
|
||||
public string tariffModality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the dates.
|
||||
/// </summary>
|
||||
public Dates dates { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the measured items.
|
||||
/// </summary>
|
||||
public Measureditem[] measuredItems { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the items.
|
||||
/// </summary>
|
||||
public Item[] items { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provider data class representing provider information.
|
||||
/// </summary>
|
||||
public class Providerdata
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
public Name name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CNPJ.
|
||||
/// </summary>
|
||||
public Cnpj cnpj { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class representing the name information.
|
||||
/// </summary>
|
||||
public class Name
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
public string value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the confidence.
|
||||
/// </summary>
|
||||
public string confidence { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class representing the CNPJ information.
|
||||
/// </summary>
|
||||
public class Cnpj
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
public string value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the confidence.
|
||||
/// </summary>
|
||||
public string confidence { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customer class representing customer information.
|
||||
/// </summary>
|
||||
public class Customer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the CNPJ.
|
||||
/// </summary>
|
||||
public string cnpj { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the address.
|
||||
/// </summary>
|
||||
public Address address { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Address class representing customer address information.
|
||||
/// </summary>
|
||||
public class Address
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the street and number.
|
||||
/// </summary>
|
||||
public string streetAndNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the city.
|
||||
/// </summary>
|
||||
public string city { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the state.
|
||||
/// </summary>
|
||||
public string state { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the zip code.
|
||||
/// </summary>
|
||||
public string zipCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the district.
|
||||
/// </summary>
|
||||
public string district { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dates class representing various date information.
|
||||
/// </summary>
|
||||
public class Dates
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the due date.
|
||||
/// </summary>
|
||||
public DateTime due { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the issue month.
|
||||
/// </summary>
|
||||
public DateTime month { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reading information.
|
||||
/// </summary>
|
||||
public Reading reading { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reading class representing reading period information.
|
||||
/// </summary>
|
||||
public class Reading
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the start of the reading period.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(DefaultDateTimeConverter))]
|
||||
public DateTime periodFrom { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end of the reading period.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(DefaultDateTimeConverter))]
|
||||
public DateTime periodUntil { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measured item class representing measured item information.
|
||||
/// </summary>
|
||||
public class Measureditem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the type.
|
||||
/// </summary>
|
||||
public string type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind.
|
||||
/// </summary>
|
||||
public string kind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the period.
|
||||
/// </summary>
|
||||
public string period { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the texts.
|
||||
/// </summary>
|
||||
public string[] texts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the measured values.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(FloatArrayOrSingleConverter))]
|
||||
public float[] measured { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Item class representing invoice item information.
|
||||
/// </summary>
|
||||
public class Item
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the item type.
|
||||
/// </summary>
|
||||
public string type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the kind.
|
||||
/// </summary>
|
||||
public string kind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the period.
|
||||
/// </summary>
|
||||
public string period { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the billed amount.
|
||||
/// </summary>
|
||||
public float billed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rate.
|
||||
/// </summary>
|
||||
public float? rate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the charge.
|
||||
/// </summary>
|
||||
public float charge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TUSD rate.
|
||||
/// </summary>
|
||||
public float tusdRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the TE rate.
|
||||
/// </summary>
|
||||
public float teRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the texts.
|
||||
/// </summary>
|
||||
public string[] texts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the basic rate.
|
||||
/// </summary>
|
||||
public float basicRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the contract.
|
||||
/// </summary>
|
||||
public float contract { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the taxable amount.
|
||||
/// </summary>
|
||||
public float? taxable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the item is summable.
|
||||
/// </summary>
|
||||
public bool summable { get; set; }
|
||||
}
|
||||
#pragma warning restore CS8618, SA1300, SA1402
|
||||
|
||||
8
Download Faturas/stylecop.json
Normal file
8
Download Faturas/stylecop.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||
"settings": {
|
||||
"documentationRules": {
|
||||
"companyName": "Smart Energia"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Upload Faturas/GlobalSuppressions.cs
Normal file
8
Upload Faturas/GlobalSuppressions.cs
Normal file
@ -0,0 +1,8 @@
|
||||
// <copyright file="GlobalSuppressions.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Program.SendFatura(System.String,System.String,System.Boolean)~System.Net.Http.HttpResponseMessage")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Download_Faturas.Program.IsFileLocked(System.IO.FileInfo)~System.Boolean")]
|
||||
@ -1,26 +1,41 @@
|
||||
using System.Net;
|
||||
// <copyright file="Program.cs" company="PlaceholderCompany">
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Download_Faturas
|
||||
{
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
/// <summary>
|
||||
/// Main program class.
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// Path to the log file for invoices.
|
||||
/// </summary>
|
||||
public const string LogFaturas = @"X:\Back\Carteira x.x\4Docs\import.txt";
|
||||
#else
|
||||
public const string LogFaturas = "import.txt";
|
||||
#endif
|
||||
|
||||
private static HttpClient httpClient = new HttpClient();
|
||||
private static readonly HttpClient HttpClient = new ();
|
||||
|
||||
/// <summary>
|
||||
/// Main entry point of the program.
|
||||
/// </summary>
|
||||
public static void Main()
|
||||
{
|
||||
for (int i = 1; i < 3; i++)
|
||||
{
|
||||
for (int j = 1; j < 7; j++)
|
||||
{
|
||||
DirectoryInfo pasta = new DirectoryInfo(@"X:\Middle\Carteira " + i + @"\Carteira " + i + "." + j + @"\Faturas fourdocs\1 - INDIVIDUAIS");
|
||||
DirectoryInfo pasta_agrupadas = new DirectoryInfo(@"X:\Middle\Carteira " + i + @"\Carteira " + i + "." + j + @"\Faturas fourdocs\2 - AGRUPADAS");
|
||||
DirectoryInfo pasta = new (@"X:\Middle\Carteira " + i + @"\Carteira " + i + "." + j + @"\Faturas fourdocs\1 - INDIVIDUAIS");
|
||||
DirectoryInfo pasta_agrupadas = new (@"X:\Middle\Carteira " + i + @"\Carteira " + i + "." + j + @"\Faturas fourdocs\2 - AGRUPADAS");
|
||||
|
||||
if (LerPasta(pasta, agrupada: false))
|
||||
{
|
||||
@ -30,6 +45,12 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the specified folder and processes the invoices.
|
||||
/// </summary>
|
||||
/// <param name="pasta">The directory to read invoices from.</param>
|
||||
/// <param name="agrupada">Indicates whether the invoices are grouped.</param>
|
||||
/// <returns>True if the folder was read successfully; otherwise, false.</returns>
|
||||
public static bool LerPasta(DirectoryInfo pasta, bool agrupada)
|
||||
{
|
||||
if (pasta.Exists)
|
||||
@ -38,7 +59,7 @@ public class Program
|
||||
|
||||
// token = await req_token();
|
||||
FileInfo[] faturas = pasta.GetFiles("*.pdf");
|
||||
StreamWriter sw = new StreamWriter(LogFaturas, true);
|
||||
StreamWriter sw = new (LogFaturas, true);
|
||||
|
||||
foreach (FileInfo fatura in faturas)
|
||||
{
|
||||
@ -66,6 +87,10 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests an authentication token.
|
||||
/// </summary>
|
||||
/// <returns>The authentication token as a string.</returns>
|
||||
public static string? ReqToken()
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.4docs.cloud/v2/oauth2/token");
|
||||
@ -76,11 +101,18 @@ public class Program
|
||||
request.Content = new StringContent("grant_type=client_credentials");
|
||||
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");
|
||||
|
||||
var response = httpClient.Send(request);
|
||||
var response = HttpClient.Send(request);
|
||||
|
||||
return JsonDocument.Parse(response.Content.ReadAsStringAsync().Result).RootElement.GetProperty("access_token").GetString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an invoice to the API for processing.
|
||||
/// </summary>
|
||||
/// <param name="token">The authentication token.</param>
|
||||
/// <param name="fatura">The path to the invoice file.</param>
|
||||
/// <param name="agrupada">Indicates whether the invoices are grouped.</param>
|
||||
/// <returns>The HTTP response from the API.</returns>
|
||||
public static HttpResponseMessage SendFatura(string token, string fatura, bool agrupada)
|
||||
{
|
||||
var handler = new HttpClientHandler
|
||||
@ -96,8 +128,10 @@ public class Program
|
||||
|
||||
request.Headers.TryAddWithoutValidation("Authorization", $"Bearer {token}");
|
||||
|
||||
var multipartContent = new MultipartFormDataContent();
|
||||
multipartContent.Add(new ByteArrayContent(File.ReadAllBytes(fatura)), @"""file""", @$"""{Path.GetFileName(fatura)}""");
|
||||
var multipartContent = new MultipartFormDataContent
|
||||
{
|
||||
{ new ByteArrayContent(File.ReadAllBytes(fatura)), @"""file""", @$"""{Path.GetFileName(fatura)}""" },
|
||||
};
|
||||
multipartContent.ElementAt(0).Headers.Add("Content-Type", "application/pdf");
|
||||
|
||||
multipartContent.Add(new StringContent($"{{\"callbackUrl\":\"https://api.4docs.cloud/v2/null\",\"pipelineName\":\"energy\",\"multiple\":{agrupada.ToString().ToLower()},\"clientData\":{{\"fatura_PATH\":\"{fatura.Replace(",", string.Empty)}\"}}}}"), "json");
|
||||
@ -108,6 +142,11 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a file is locked.
|
||||
/// </summary>
|
||||
/// <param name="file">The file to check.</param>
|
||||
/// <returns>True if the file is locked; otherwise, false.</returns>
|
||||
public static bool IsFileLocked(FileInfo file)
|
||||
{
|
||||
try
|
||||
@ -130,3 +169,4 @@ public class Program
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
<RootNamespace>Download_Faturas</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
11
Webhook 4docs/GlobalSuppressions.cs
Normal file
11
Webhook 4docs/GlobalSuppressions.cs
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Usage", "CA2254:O modelo deve ser uma expressão estática", Justification = "<Pendente>", Scope = "member", Target = "~M:Webhook_4docs.Program.Main(System.String[])")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Webhook_4docs.Program.Main(System.String[])")]
|
||||
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Webhook_4docs.Program.UpdateErrorIdStatusAsync(System.String,System.Double,System.Double,System.String,Microsoft.Extensions.Logging.ILogger)~System.Threading.Tasks.Task{System.Int32}")]
|
||||
[assembly: SuppressMessage("Usage", "CA2254:O modelo deve ser uma expressão estática", Justification = "<Pendente>", Scope = "member", Target = "~M:Webhook_4docs.Program.UpdateErrorIdStatusAsync(System.String,System.Double,System.Double,System.String,Microsoft.Extensions.Logging.ILogger)~System.Threading.Tasks.Task{System.Int32}")]
|
||||
@ -2,6 +2,8 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Webhook_4docs
|
||||
{
|
||||
public class ProcessedInvoices
|
||||
{
|
||||
[Key]
|
||||
@ -10,3 +12,4 @@ public class ProcessedInvoices
|
||||
public string? Status { get; set; }
|
||||
public string? InvoicePath { get; set; }
|
||||
}
|
||||
}
|
||||
@ -257,6 +257,8 @@ namespace Webhook_4docs
|
||||
endpoints.MapPut("/api", async context =>
|
||||
{
|
||||
var a = 10;
|
||||
a++;
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
});
|
||||
app.Run();
|
||||
@ -264,7 +266,7 @@ namespace Webhook_4docs
|
||||
//tenta pegar o deactivationReport, se não conseguir ou for null, tenta pegar o websiteText, se não conseguir ou for null, tenta pegar o systemText. As propriedades podem não exisir
|
||||
public static string GetErrorText(JsonElement root)
|
||||
{
|
||||
string errorText = string.Empty;
|
||||
string errorText;
|
||||
|
||||
if (root.TryGetProperty("deactivationReport", out JsonElement deactivationReportElement) && deactivationReportElement.ValueKind != JsonValueKind.Null)
|
||||
{
|
||||
@ -299,11 +301,11 @@ namespace Webhook_4docs
|
||||
{
|
||||
try
|
||||
{
|
||||
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21"))
|
||||
using (OleDbConnection conn = new (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21"))
|
||||
{
|
||||
await conn.OpenAsync();
|
||||
|
||||
using (OleDbCommand cmd = new OleDbCommand(
|
||||
using (OleDbCommand cmd = new (
|
||||
@"UPDATE AgVirtual4Docs
|
||||
SET errorID = @errorID, status = @status
|
||||
WHERE location_id = @location_id", conn))
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
public class WebhookDbContext : DbContext
|
||||
namespace Webhook_4docs
|
||||
{
|
||||
public WebhookDbContext(DbContextOptions<WebhookDbContext> options) : base(options)
|
||||
public class WebhookDbContext(DbContextOptions<WebhookDbContext> options) : DbContext(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<ProcessedInvoices> ProcessedInvoices { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user