Compare commits
2 Commits
8efd900bb5
...
0fb1a59d44
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fb1a59d44 | |||
| 874eabe87a |
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
|
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
|
||||||
<RootNamespace>Download_Faturas</RootNamespace>
|
<RootNamespace>Download_Faturas</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@ -27,21 +27,22 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="itext7" Version="9.0.0" />
|
|
||||||
<PackageReference Include="itext7.bouncy-castle-adapter" Version="9.0.0" />
|
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
|
||||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
|
||||||
<PackageReference Include="XUnit" Version="2.9.3" />
|
<PackageReference Include="XUnit" Version="2.9.3" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Faturas\Faturas.csproj" />
|
||||||
|
<ProjectReference Include="..\Faturas\Faturas.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
|||||||
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
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", "SA1010:Opening square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M: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", "SA1011:Closing square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M: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("StyleCop.CSharp.SpacingRules", "SA1009:Closing parenthesis should be spaced correctly", Justification = "<Pendente>", Scope = "type", Target = "~T: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("Performance", "SYSLIB1045:Converter em 'GeneratedRegexAttribute'.", Justification = "<Pendente>", Scope = "member", Target = "~M: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("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M: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("Performance", "SYSLIB1045:Converter em 'GeneratedRegexAttribute'.", Justification = "<Pendente>", Scope = "member", Target = "~M: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("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M: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: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("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "<Pendente>", Scope = "member", Target = "~M: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")]
|
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Faturas.Program.Main")]
|
||||||
|
|||||||
@ -5,11 +5,8 @@
|
|||||||
namespace Download_Faturas
|
namespace Download_Faturas
|
||||||
{
|
{
|
||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using System.Globalization;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using Faturas;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Main program class for processing invoices.
|
/// Main program class for processing invoices.
|
||||||
|
|||||||
@ -14,7 +14,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Download Faturas.Tests", "Download Faturas.Tests\Download Faturas.Tests.csproj", "{67A025C1-B7A4-48D0-8157-C0BBA550469F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faturas.Tests", "Faturas.Tests\Faturas.Tests.csproj", "{67A025C1-B7A4-48D0-8157-C0BBA550469F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Faturas", "Faturas\Faturas.csproj", "{E0184772-C161-441B-8872-4BCBA20E4B47}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -38,6 +40,10 @@ Global
|
|||||||
{67A025C1-B7A4-48D0-8157-C0BBA550469F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{67A025C1-B7A4-48D0-8157-C0BBA550469F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{67A025C1-B7A4-48D0-8157-C0BBA550469F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{67A025C1-B7A4-48D0-8157-C0BBA550469F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{67A025C1-B7A4-48D0-8157-C0BBA550469F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{67A025C1-B7A4-48D0-8157-C0BBA550469F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E0184772-C161-441B-8872-4BCBA20E4B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E0184772-C161-441B-8872-4BCBA20E4B47}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E0184772-C161-441B-8872-4BCBA20E4B47}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E0184772-C161-441B-8872-4BCBA20E4B47}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using System.Numerics;
|
using Faturas;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Download_Faturas;
|
using Download_Faturas;
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
|
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
|
||||||
<RootNamespace>Download_Faturas.Tests</RootNamespace>
|
<RootNamespace>Download_Faturas.Tests</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Download Faturas\Download Faturas.csproj" />
|
<ProjectReference Include="..\Faturas\Faturas.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
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: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:Faturas.Tests.FaturaIntegrationTests.GetDadosTusd(System.Data.OleDb.OleDbConnection,System.Double)~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})")]
|
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Faturas.Tests.FaturaIntegrationTests.WriteCsv(System.String,System.Collections.Generic.List{System.String})")]
|
||||||
@ -1,18 +1,9 @@
|
|||||||
// <copyright file="CustomPdfSplitter.cs" company="Smart Energia">
|
// <copyright file="CustomPdfSplitter.cs" company="Smart Energia">
|
||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace 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.Pdf;
|
||||||
using iText.Kernel.Utils;
|
using iText.Kernel.Utils;
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
// <copyright file="DefaultDateTimeConverter.cs" company="Smart Energia">
|
// <copyright file="DefaultDateTimeConverter.cs" company="Smart Energia">
|
||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
namespace Download_Faturas
|
namespace Faturas
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@ -2,19 +2,14 @@
|
|||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace Faturas
|
||||||
{
|
{
|
||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using System.Globalization;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
|
||||||
using System.Runtime.Intrinsics.X86;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using iText.Kernel.Pdf;
|
|
||||||
using iText.Kernel.Utils;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Representa uma fatura eletrônica e fornece métodos para processá-la e movê-la.
|
/// Representa uma fatura eletrônica e fornece métodos para processá-la e movê-la.
|
||||||
@ -46,20 +41,20 @@ namespace Download_Faturas
|
|||||||
HttpResponseMessage fatura_response = GetStatus(httpClient, Token, id);
|
HttpResponseMessage fatura_response = GetStatus(httpClient, Token, id);
|
||||||
if (fatura_response.IsSuccessStatusCode)
|
if (fatura_response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
this.faturaParsed = JsonDocument.Parse(fatura_response.Content.ReadAsStringAsync().Result).RootElement;
|
faturaParsed = JsonDocument.Parse(fatura_response.Content.ReadAsStringAsync().Result).RootElement;
|
||||||
this.Agrupada = this.faturaParsed.TryGetProperty("multiple", out var _);
|
Agrupada = faturaParsed.TryGetProperty("multiple", out var _);
|
||||||
this.Status = this.faturaParsed.GetProperty("status").GetString();
|
Status = faturaParsed.GetProperty("status").GetString();
|
||||||
this.Arquivo = new FileInfo(fatura_path);
|
Arquivo = new FileInfo(fatura_path);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
if (this.faturaParsed.GetProperty("external").GetString() is not null)
|
if (faturaParsed.GetProperty("external").GetString() is not null)
|
||||||
{
|
{
|
||||||
this.pagina = JsonDocument.Parse(this.faturaParsed.GetProperty("external").GetString() !).RootElement.GetProperty("origin")[0].GetProperty("page").GetInt32();
|
pagina = JsonDocument.Parse(faturaParsed.GetProperty("external").GetString() !).RootElement.GetProperty("origin")[0].GetProperty("page").GetInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.Agrupada)
|
if (Agrupada)
|
||||||
{
|
{
|
||||||
this.Agrupada_children = this.faturaParsed.GetProperty("children").EnumerateArray();
|
Agrupada_children = faturaParsed.GetProperty("children").EnumerateArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,8 +69,8 @@ namespace Download_Faturas
|
|||||||
{
|
{
|
||||||
// Utilizado para gerar novo token
|
// Utilizado para gerar novo token
|
||||||
// this.token = Req_token(HttpClient).ToString();
|
// this.token = Req_token(HttpClient).ToString();
|
||||||
this.faturaParsed = fatura_Parsed;
|
faturaParsed = fatura_Parsed;
|
||||||
this.Agrupada = false;
|
Agrupada = false;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,18 +131,18 @@ namespace Download_Faturas
|
|||||||
public void Processar(OleDbConnection conn)
|
public void Processar(OleDbConnection conn)
|
||||||
{
|
{
|
||||||
// Resultado da fatura processada
|
// Resultado da fatura processada
|
||||||
if (!this.faturaParsed.TryGetProperty("result", out JsonElement a))
|
if (!faturaParsed.TryGetProperty("result", out JsonElement a))
|
||||||
{
|
{
|
||||||
this.faturaParsed.TryGetProperty("json", out a);
|
faturaParsed.TryGetProperty("json", out a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rootobject parsedResult = JsonSerializer.Deserialize<Rootobject>(a) !;
|
Rootobject parsedResult = a.Deserialize<Rootobject>() !;
|
||||||
if (parsedResult == null || parsedResult.dates == null || parsedResult.dates.reading == null || parsedResult.locationNumber == null || parsedResult.customer == null || parsedResult.items == null || parsedResult.dates.reading.periodUntil == DateTime.MinValue)
|
if (parsedResult == null || parsedResult.dates == null || parsedResult.dates.reading == null || parsedResult.locationNumber == null || parsedResult.customer == null || parsedResult.items == null || parsedResult.dates.reading.periodUntil == DateTime.MinValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
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);
|
string uc = new Regex("^0+").Replace(parsedResult.locationNumber, string.Empty).Replace("/", string.Empty).Replace("-", string.Empty).Replace(".", string.Empty);
|
||||||
|
|
||||||
@ -188,29 +183,29 @@ namespace Download_Faturas
|
|||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
// Dados cadastrais
|
// Dados cadastrais
|
||||||
this.dadosTusd.Cod_Smart_unidade = long.Parse(reader["Cod_Smart_unidade"].ToString() !);
|
dadosTusd.Cod_Smart_unidade = long.Parse(reader["Cod_Smart_unidade"].ToString() !);
|
||||||
this.dadosTusd.Perfil_CliqCCEE = reader["PerfilCCEE"].ToString();
|
dadosTusd.Perfil_CliqCCEE = reader["PerfilCCEE"].ToString();
|
||||||
this.dadosTusd.Submercado = reader["Submercado"].ToString();
|
dadosTusd.Submercado = reader["Submercado"].ToString();
|
||||||
DateTime dataMigração = DateTime.Parse(reader["Data_de_Migracao"].ToString() !);
|
DateTime dataMigração = DateTime.Parse(reader["Data_de_Migracao"].ToString() !);
|
||||||
if (int.Parse(dataMigração.ToString("yMM")) <= this.dadosTusd.Mes)
|
if (int.Parse(dataMigração.ToString("yMM")) <= dadosTusd.Mes)
|
||||||
{
|
{
|
||||||
this.dadosTusd.Ambiente = reader["Status_unidade"].ToString();
|
dadosTusd.Ambiente = reader["Status_unidade"].ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.dadosTusd.Ambiente = "Cativo";
|
dadosTusd.Ambiente = "Cativo";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dadosTusd.Grupo = reader["Grupo"].ToString();
|
dadosTusd.Grupo = reader["Grupo"].ToString();
|
||||||
this.dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
dadosTusd.Distribuidora = reader["Distribuidora"].ToString();
|
||||||
this.dadosTusd.ICMS = float.Parse(reader["ICMS_TUSD"].ToString() !);
|
dadosTusd.ICMS = float.Parse(reader["ICMS_TUSD"].ToString() !);
|
||||||
this.dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString() !);
|
dadosTusd.Dem_Cont_P = float.Parse(reader["Demanda_P"].ToString() !);
|
||||||
this.dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString() !);
|
dadosTusd.Dem_Cont_FP = float.Parse(reader["Demanda_FP"].ToString() !);
|
||||||
this.dadosTusd.Perfil = reader["Perfil"].ToString();
|
dadosTusd.Perfil = reader["Perfil"].ToString();
|
||||||
this.PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty, StringComparison.OrdinalIgnoreCase) + "\\TUSD");
|
PastaTUSD = new DirectoryInfo(reader["Caminho_NFs"].ToString() !.Replace("\\NFe", string.Empty, StringComparison.OrdinalIgnoreCase) + "\\TUSD");
|
||||||
this.Gestao = reader["Gestao"].ToString();
|
Gestao = reader["Gestao"].ToString();
|
||||||
this.Empresa = reader["Cliente"].ToString();
|
Empresa = reader["Cliente"].ToString();
|
||||||
this.Unidade = reader["Unidade"].ToString();
|
Unidade = reader["Unidade"].ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,8 +216,8 @@ namespace Download_Faturas
|
|||||||
sqlQuery = $"SELECT Cod_TUSD FROM Dados_TUSD WHERE Cod_TUSD = ?";
|
sqlQuery = $"SELECT Cod_TUSD FROM Dados_TUSD WHERE Cod_TUSD = ?";
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
this.CodTusd = double.Parse(this.dadosTusd.Cod_Smart_unidade.ToString() + this.dadosTusd.Mes.ToString());
|
CodTusd = double.Parse(dadosTusd.Cod_Smart_unidade.ToString() + dadosTusd.Mes.ToString());
|
||||||
cmd.Parameters.AddWithValue("?", this.CodTusd);
|
cmd.Parameters.AddWithValue("?", CodTusd);
|
||||||
|
|
||||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
@ -230,18 +225,18 @@ namespace Download_Faturas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.dadosTusd.Cod_Smart_unidade == 0)
|
if (dadosTusd.Cod_Smart_unidade == 0)
|
||||||
{
|
{
|
||||||
this.Status = "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD";
|
Status = "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD";
|
||||||
this.uc = uc;
|
this.uc = uc;
|
||||||
this.Mes = this.dadosTusd.Mes;
|
Mes = dadosTusd.Mes;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (tusdLanc)
|
else if (tusdLanc)
|
||||||
{
|
{
|
||||||
this.Status = "FATURA DUPLICADA NO BD";
|
Status = "FATURA DUPLICADA NO BD";
|
||||||
this.uc = uc;
|
this.uc = uc;
|
||||||
this.Mes = this.dadosTusd.Mes;
|
Mes = dadosTusd.Mes;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,62 +245,62 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("?", this.dadosTusd.Mes.ToString());
|
cmd.Parameters.AddWithValue("?", dadosTusd.Mes.ToString());
|
||||||
cmd.Parameters.AddWithValue("?", this.dadosTusd.Distribuidora);
|
cmd.Parameters.AddWithValue("?", dadosTusd.Distribuidora);
|
||||||
|
|
||||||
using (OleDbDataReader reader = cmd.ExecuteReader())
|
using (OleDbDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
// PIS e Cofins
|
// PIS e Cofins
|
||||||
this.dadosTusd.PIS = float.Parse(reader["PIS"].ToString() !);
|
dadosTusd.PIS = float.Parse(reader["PIS"].ToString() !);
|
||||||
this.dadosTusd.COFINS = float.Parse(reader["COFINS"].ToString() !);
|
dadosTusd.COFINS = float.Parse(reader["COFINS"].ToString() !);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dados da fatura processada
|
// Dados da fatura processada
|
||||||
this.dadosTusd.Cod_TUSD = long.Parse(this.dadosTusd.Cod_Smart_unidade.ToString() + this.dadosTusd.Mes.ToString());
|
dadosTusd.Cod_TUSD = long.Parse(dadosTusd.Cod_Smart_unidade.ToString() + dadosTusd.Mes.ToString());
|
||||||
switch (parsedResult.tariffModality, parsedResult.subgroup)
|
switch (parsedResult.tariffModality, parsedResult.subgroup)
|
||||||
{
|
{
|
||||||
case ("blue", _):
|
case ("blue", _):
|
||||||
this.dadosTusd.Perfil = "AZUL";
|
dadosTusd.Perfil = "AZUL";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ("green", _):
|
case ("green", _):
|
||||||
this.dadosTusd.Perfil = "VERDE";
|
dadosTusd.Perfil = "VERDE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ("standart", _):
|
case ("standart", _):
|
||||||
this.dadosTusd.Perfil = "CONVENCIONAL";
|
dadosTusd.Perfil = "CONVENCIONAL";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (_, "B3"):
|
case (_, "B3"):
|
||||||
this.dadosTusd.Perfil = "CONVENCIONAL";
|
dadosTusd.Perfil = "CONVENCIONAL";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dadosTusd.Valor = parsedResult.totalCharges;
|
dadosTusd.Valor = parsedResult.totalCharges;
|
||||||
this.dadosTusd.Inicio_Leitura = parsedResult.dates.reading.periodFrom;
|
dadosTusd.Inicio_Leitura = parsedResult.dates.reading.periodFrom;
|
||||||
this.dadosTusd.Fim_leitura = parsedResult.dates.reading.periodUntil;
|
dadosTusd.Fim_leitura = parsedResult.dates.reading.periodUntil;
|
||||||
DateTime d = DateTime.Now;
|
DateTime d = DateTime.Now;
|
||||||
this.dadosTusd.Hora_TUSD = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
dadosTusd.Hora_TUSD = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second);
|
||||||
this.dadosTusd.Dem_Reativa_kvar = 0;
|
dadosTusd.Dem_Reativa_kvar = 0;
|
||||||
this.dadosTusd.Multa = 0;
|
dadosTusd.Multa = 0;
|
||||||
this.dadosTusd.Credito = 0;
|
dadosTusd.Credito = 0;
|
||||||
this.dadosTusd.Bandeira_RS_MWh = 0;
|
dadosTusd.Bandeira_RS_MWh = 0;
|
||||||
this.dadosTusd.FIC_DIC = 0;
|
dadosTusd.FIC_DIC = 0;
|
||||||
this.dadosTusd.Enc_conexao = 0;
|
dadosTusd.Enc_conexao = 0;
|
||||||
this.dadosTusd.Liminar_ICMS = 0;
|
dadosTusd.Liminar_ICMS = 0;
|
||||||
this.dadosTusd.Outros = 0;
|
dadosTusd.Outros = 0;
|
||||||
this.dadosTusd.Cred_livre = 0;
|
dadosTusd.Cred_livre = 0;
|
||||||
this.dadosTusd.Tempo_TUSD = 0;
|
dadosTusd.Tempo_TUSD = 0;
|
||||||
this.dadosTusd.Lanc_aut = true;
|
dadosTusd.Lanc_aut = true;
|
||||||
this.dadosTusd.Rev_atual = true;
|
dadosTusd.Rev_atual = true;
|
||||||
this.dadosTusd.Revisao = 0;
|
dadosTusd.Revisao = 0;
|
||||||
|
|
||||||
// Loop entre os dados faturados na fatura
|
// Loop entre os dados faturados na fatura
|
||||||
int j = 0;
|
int j = 0;
|
||||||
@ -329,9 +324,9 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
if (item.kind == kind_P || item.kind == "TUSD")
|
if (item.kind == kind_P || item.kind == "TUSD")
|
||||||
{
|
{
|
||||||
if ((item.billed / 1000) != this.dadosTusd.Consumo_P)
|
if (item.billed / 1000 != dadosTusd.Consumo_P)
|
||||||
{
|
{
|
||||||
this.dadosTusd.Consumo_P += item.billed / 1000;
|
dadosTusd.Consumo_P += item.billed / 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,9 +343,9 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
if (item.kind == kind_FP)
|
if (item.kind == kind_FP)
|
||||||
{
|
{
|
||||||
if ((item.billed / 1000) != this.dadosTusd.Consumo_FP)
|
if (item.billed / 1000 != dadosTusd.Consumo_FP)
|
||||||
{
|
{
|
||||||
this.dadosTusd.Consumo_FP += item.billed / 1000;
|
dadosTusd.Consumo_FP += item.billed / 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,16 +363,16 @@ namespace Download_Faturas
|
|||||||
{
|
{
|
||||||
if (item.period == "peak")
|
if (item.period == "peak")
|
||||||
{
|
{
|
||||||
this.dadosTusd.Dem_Reg_P = item.billed;
|
dadosTusd.Dem_Reg_P = item.billed;
|
||||||
this.dadosTusd.Dem_Cont_P = item.contract;
|
dadosTusd.Dem_Cont_P = item.contract;
|
||||||
}
|
}
|
||||||
else if (item.period == "off-peak")
|
else if (item.period == "off-peak")
|
||||||
{
|
{
|
||||||
this.dadosTusd.Dem_Reg_FP = item.billed;
|
dadosTusd.Dem_Reg_FP = item.billed;
|
||||||
this.dadosTusd.Dem_Cont_FP = item.contract;
|
dadosTusd.Dem_Cont_FP = item.contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.dadosTusd.Perfil == "AZUL")
|
if (dadosTusd.Perfil == "AZUL")
|
||||||
{
|
{
|
||||||
if (item.period == "peak")
|
if (item.period == "peak")
|
||||||
{
|
{
|
||||||
@ -385,7 +380,7 @@ namespace Download_Faturas
|
|||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,18 +390,18 @@ namespace Download_Faturas
|
|||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (this.dadosTusd.Perfil == "VERDE")
|
else if (dadosTusd.Perfil == "VERDE")
|
||||||
{
|
{
|
||||||
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_P = @demanda, Demanda_FP = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
sqlQuery = $"UPDATE Dados_cadastrais SET Demanda_P = @demanda, Demanda_FP = @demanda WHERE Cod_Smart_unidade = @cod_smart_unidade";
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
cmd.Parameters.AddWithValue("@demanda", item.contract);
|
||||||
cmd.Parameters.AddWithValue("@cod_smart_unidade", this.dadosTusd.Cod_Smart_unidade);
|
cmd.Parameters.AddWithValue("@cod_smart_unidade", dadosTusd.Cod_Smart_unidade);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,22 +411,22 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
// Ilum. publica
|
// Ilum. publica
|
||||||
case ("publicLighting", _):
|
case ("publicLighting", _):
|
||||||
this.dadosTusd.Ilum_Publica = item.charge;
|
dadosTusd.Ilum_Publica = item.charge;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Energia Reativa
|
// Energia Reativa
|
||||||
case ("excessReactiveEnergy", _):
|
case ("excessReactiveEnergy", _):
|
||||||
this.dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Demanda Reativa
|
// Demanda Reativa
|
||||||
case ("excessReactiveDemand", _):
|
case ("excessReactiveDemand", _):
|
||||||
this.dadosTusd.Dem_Reativa_kvar += item.billed;
|
dadosTusd.Dem_Reativa_kvar += item.billed;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Bandeira Tarifaria
|
// Bandeira Tarifaria
|
||||||
case ("flagSurcharge", _):
|
case ("flagSurcharge", _):
|
||||||
this.dadosTusd.Bandeira_RS_MWh = item.charge;
|
dadosTusd.Bandeira_RS_MWh = item.charge;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Items não classificados
|
// Items não classificados
|
||||||
@ -444,7 +439,7 @@ namespace Download_Faturas
|
|||||||
sqlQuery = $"DELETE FROM Dados_TUSD_aux WHERE Cod_TUSD = @cod_tusd";
|
sqlQuery = $"DELETE FROM Dados_TUSD_aux WHERE Cod_TUSD = @cod_tusd";
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,22 +481,22 @@ namespace Download_Faturas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dem_Reg_P != null && (Math.Round((decimal)this.dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2)))
|
if (dem_Reg_P != null && Math.Round((decimal)dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2))
|
||||||
{
|
{
|
||||||
this.dadosTusd.Dem_Reg_P = (float)(dem_Reg_P * 1.025);
|
dadosTusd.Dem_Reg_P = (float)(dem_Reg_P * 1.025);
|
||||||
}
|
}
|
||||||
else if (dem_Reg_P != null)
|
else if (dem_Reg_P != null)
|
||||||
{
|
{
|
||||||
this.dadosTusd.Dem_Reg_P = (float)dem_Reg_P;
|
dadosTusd.Dem_Reg_P = (float)dem_Reg_P;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dem_Reg_FP != null && (Math.Round((decimal)this.dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2)))
|
if (dem_Reg_FP != null && Math.Round((decimal)dadosTusd.Consumo_FP, 2) == Math.Round((decimal)(consumo_Reg_FP * 1.025 / 1000) !, 2))
|
||||||
{
|
{
|
||||||
this.dadosTusd.Dem_Reg_FP = (float)(dem_Reg_FP * 1.025);
|
dadosTusd.Dem_Reg_FP = (float)(dem_Reg_FP * 1.025);
|
||||||
}
|
}
|
||||||
else if (dem_Reg_FP != null)
|
else if (dem_Reg_FP != null)
|
||||||
{
|
{
|
||||||
this.dadosTusd.Dem_Reg_FP = dem_Reg_FP ?? 0;
|
dadosTusd.Dem_Reg_FP = dem_Reg_FP ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// var dados = this.dadosTusd.GetType().GetProperties();
|
// var dados = this.dadosTusd.GetType().GetProperties();
|
||||||
@ -532,12 +527,12 @@ namespace Download_Faturas
|
|||||||
foreach (PropertyInfo propriedade in propriedades)
|
foreach (PropertyInfo propriedade in propriedades)
|
||||||
{
|
{
|
||||||
string nomeColuna = propriedade.Name;
|
string nomeColuna = propriedade.Name;
|
||||||
object valorColuna = propriedade.GetValue(this.dadosTusd) ?? string.Empty;
|
object valorColuna = propriedade.GetValue(dadosTusd) ?? string.Empty;
|
||||||
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valor do código TUSD na cláusula WHERE
|
// Valor do código TUSD na cláusula WHERE
|
||||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
@ -549,7 +544,7 @@ namespace Download_Faturas
|
|||||||
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor,0)";
|
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor,0)";
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||||
cmd.Parameters.AddWithValue("@j", j);
|
cmd.Parameters.AddWithValue("@j", j);
|
||||||
cmd.Parameters.AddWithValue("@name", name);
|
cmd.Parameters.AddWithValue("@name", name);
|
||||||
cmd.Parameters.AddWithValue("@valor", valor);
|
cmd.Parameters.AddWithValue("@valor", valor);
|
||||||
@ -590,7 +585,7 @@ namespace Download_Faturas
|
|||||||
foreach (PropertyInfo propriedade in propriedades)
|
foreach (PropertyInfo propriedade in propriedades)
|
||||||
{
|
{
|
||||||
string nomeColuna = propriedade.Name;
|
string nomeColuna = propriedade.Name;
|
||||||
object valorColuna = propriedade.GetValue(this.dadosTusd) ?? string.Empty;
|
object valorColuna = propriedade.GetValue(dadosTusd) ?? string.Empty;
|
||||||
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
cmd.Parameters.AddWithValue($"@{nomeColuna}", valorColuna);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,7 +600,7 @@ namespace Download_Faturas
|
|||||||
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor, 0)";
|
sqlQuery = "INSERT INTO Dados_TUSD_aux (Cod_TUSD,Id,Nome,Valor,Cod_lanc) VALUES (@cod_tusd, @j, @name, @valor, 0)";
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@cod_tusd", this.dadosTusd.Cod_TUSD);
|
cmd.Parameters.AddWithValue("@cod_tusd", dadosTusd.Cod_TUSD);
|
||||||
cmd.Parameters.AddWithValue("@j", j);
|
cmd.Parameters.AddWithValue("@j", j);
|
||||||
cmd.Parameters.AddWithValue("@name", name);
|
cmd.Parameters.AddWithValue("@name", name);
|
||||||
cmd.Parameters.AddWithValue("@valor", valor);
|
cmd.Parameters.AddWithValue("@valor", valor);
|
||||||
@ -614,9 +609,9 @@ namespace Download_Faturas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Status = "FATURA INCLUIDA NO BD";
|
Status = "FATURA INCLUIDA NO BD";
|
||||||
this.uc = uc;
|
this.uc = uc;
|
||||||
this.Mes = this.dadosTusd.Mes;
|
Mes = dadosTusd.Mes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -627,22 +622,22 @@ namespace Download_Faturas
|
|||||||
{
|
{
|
||||||
string destino;
|
string destino;
|
||||||
|
|
||||||
switch (this.Status, separar)
|
switch (Status, separar)
|
||||||
{
|
{
|
||||||
case ("UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD", _):
|
case ("UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD", _):
|
||||||
|
|
||||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\5 - {this.Status}\ID {this.id!} - Mês {this.Mes} - UC {this.uc}.pdf";
|
destino = Arquivo?.Directory?.Parent?.FullName + $@"\5 - {Status}\ID {id!} - Mês {Mes} - UC {uc}.pdf";
|
||||||
|
|
||||||
if (separar)
|
if (separar)
|
||||||
{
|
{
|
||||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
_ = new PDFSplitter(pagina, Arquivo!.ToString(), destino);
|
||||||
this.Arquivo = new FileInfo(destino);
|
Arquivo = new FileInfo(destino);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Arquivo!.MoveTo(destino);
|
Arquivo!.MoveTo(destino);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -653,18 +648,18 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
case ("FATURA DUPLICADA NO BD", _):
|
case ("FATURA DUPLICADA NO BD", _):
|
||||||
|
|
||||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\4 - {this.Status}\ID {this.id!} - Mês {this.Mes} - Empresa {this.Empresa} - Unidade {this.Unidade}.pdf";
|
destino = Arquivo?.Directory?.Parent?.FullName + $@"\4 - {Status}\ID {id!} - Mês {Mes} - Empresa {Empresa} - Unidade {Unidade}.pdf";
|
||||||
|
|
||||||
if (separar)
|
if (separar)
|
||||||
{
|
{
|
||||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
_ = new PDFSplitter(pagina, Arquivo!.ToString(), destino);
|
||||||
this.Arquivo = new FileInfo(destino);
|
Arquivo = new FileInfo(destino);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Arquivo!.MoveTo(destino);
|
Arquivo!.MoveTo(destino);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -675,25 +670,25 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
case ("FATURA INCLUIDA NO BD", _):
|
case ("FATURA INCLUIDA NO BD", _):
|
||||||
|
|
||||||
if (this.PastaTUSD!.Exists)
|
if (PastaTUSD!.Exists)
|
||||||
{
|
{
|
||||||
destino = this.PastaTUSD!.FullName + $@"\ID {this.id!} - Mês {this.Mes} - Empresa {this.Empresa} - Unidade {this.Unidade}.pdf";
|
destino = PastaTUSD!.FullName + $@"\ID {id!} - Mês {Mes} - Empresa {Empresa} - Unidade {Unidade}.pdf";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\6 - {this.Status}\ID {this.id!} - Mês {this.Mes} - Empresa {this.Empresa} - Unidade {this.Unidade}.pdf";
|
destino = Arquivo?.Directory?.Parent?.FullName + $@"\6 - {Status}\ID {id!} - Mês {Mes} - Empresa {Empresa} - Unidade {Unidade}.pdf";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (separar)
|
if (separar)
|
||||||
{
|
{
|
||||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
_ = new PDFSplitter(pagina, Arquivo!.ToString(), destino);
|
||||||
this.Arquivo = new FileInfo(destino);
|
Arquivo = new FileInfo(destino);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Arquivo!.MoveTo(destino);
|
Arquivo!.MoveTo(destino);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -704,18 +699,18 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
case ("INVALID", _):
|
case ("INVALID", _):
|
||||||
|
|
||||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\7 - ERRO\ID {this.id!} - {this.Arquivo?.Name}";
|
destino = Arquivo?.Directory?.Parent?.FullName + $@"\7 - ERRO\ID {id!} - {Arquivo?.Name}";
|
||||||
|
|
||||||
if (separar)
|
if (separar)
|
||||||
{
|
{
|
||||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
_ = new PDFSplitter(pagina, Arquivo!.ToString(), destino);
|
||||||
this.Arquivo = new FileInfo(destino);
|
Arquivo = new FileInfo(destino);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Arquivo!.MoveTo(destino);
|
Arquivo!.MoveTo(destino);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -727,10 +722,10 @@ namespace Download_Faturas
|
|||||||
|
|
||||||
case (_, true):
|
case (_, true):
|
||||||
|
|
||||||
destino = this.Arquivo?.Directory?.Parent?.FullName + $@"\3 - PROCESSANDO\ID {this.id!} - {this.Arquivo?.Name}";
|
destino = Arquivo?.Directory?.Parent?.FullName + $@"\3 - PROCESSANDO\ID {id!} - {Arquivo?.Name}";
|
||||||
|
|
||||||
_ = new PDFSplitter(this.pagina, this.Arquivo!.ToString(), destino);
|
_ = new PDFSplitter(pagina, Arquivo!.ToString(), destino);
|
||||||
this.Arquivo = new FileInfo(destino);
|
Arquivo = new FileInfo(destino);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,19 +2,14 @@
|
|||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace Faturas
|
||||||
{
|
{
|
||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using System.Globalization;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Metadata.Ecma335;
|
|
||||||
using System.Runtime.Intrinsics.X86;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using iText.Kernel.Pdf;
|
|
||||||
using iText.Kernel.Utils;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class representing the old invoice processing logic.
|
/// Class representing the old invoice processing logic.
|
||||||
14
Faturas/Faturas.csproj
Normal file
14
Faturas/Faturas.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="itext7" Version="9.0.0" />
|
||||||
|
<PackageReference Include="System.Data.OleDb" Version="10.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace Faturas
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
9
Faturas/GlobalSuppressions.cs
Normal file
9
Faturas/GlobalSuppressions.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// 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("Interoperability", "CA1416:Validar a compatibilidade da plataforma", Justification = "<Pendente>", Scope = "member", Target = "~M:Faturas.Fatura.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||||
|
[assembly: SuppressMessage("Style", "IDE0063:Usar a instrução 'using' simples", Justification = "<Pendente>", Scope = "member", Target = "~M:Faturas.Fatura.Processar(System.Data.OleDb.OleDbConnection)")]
|
||||||
@ -1,18 +1,9 @@
|
|||||||
// <copyright file="PDFSplitter.cs" company="Smart Energia">
|
// <copyright file="PDFSplitter.cs" company="Smart Energia">
|
||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace 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.Pdf;
|
||||||
using iText.Kernel.Utils;
|
using iText.Kernel.Utils;
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace Faturas
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Record set class representing invoice data.
|
/// Record set class representing invoice data.
|
||||||
@ -2,7 +2,7 @@
|
|||||||
// Copyright (c) Smart Energia. All rights reserved.
|
// Copyright (c) Smart Energia. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace Download_Faturas
|
namespace Faturas
|
||||||
{
|
{
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
namespace Download_Faturas
|
namespace Download_Faturas
|
||||||
{
|
{
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<RootNamespace>Download_Faturas</RootNamespace>
|
<RootNamespace>Download_Faturas</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@ -14,8 +14,6 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
|
||||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace Webhook_4docs
|
namespace Webhook_4docs
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,13 +1,9 @@
|
|||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.RateLimiting;
|
using System.Threading.RateLimiting;
|
||||||
using Download_Faturas;
|
using Faturas;
|
||||||
using iText.Layout.Splitting;
|
|
||||||
using Microsoft.AspNetCore.Http.Extensions;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
|
|
||||||
namespace Webhook_4docs
|
namespace Webhook_4docs
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
|
<TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<RootNamespace>Webhook_4docs</RootNamespace>
|
<RootNamespace>Webhook_4docs</RootNamespace>
|
||||||
@ -18,12 +18,11 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
|
||||||
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
<PackageReference Include="System.Data.OleDb" Version="10.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Download Faturas\Download Faturas.csproj" />
|
<ProjectReference Include="..\Faturas\Faturas.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user