26/11/2024
This commit is contained in:
parent
82d6df6a35
commit
3274f26415
14
Compliance/Compliance.csproj
Normal file
14
Compliance/Compliance.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
52
Compliance/Program.cs
Normal file
52
Compliance/Program.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System.Data;
|
||||||
|
using System.Data.OleDb;
|
||||||
|
|
||||||
|
namespace Compliance
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
public const string CaminhoDB = "X:/Middle/Informativo Setorial/Modelo Word/BD1_dados cadastrais e faturas.accdb";
|
||||||
|
|
||||||
|
public static void Compliance(OleDbConnection conn, OleDbDataReader reader)
|
||||||
|
{
|
||||||
|
DataTable distribuidoras_PIS = GetDistribuidoras_PIS(conn, reader["Dados_TUSD.Distribuidora"].ToString()!, reader["Mes"].ToString()!);
|
||||||
|
|
||||||
|
var test = distribuidoras_PIS.Rows.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DataTable GetDistribuidoras_PIS(OleDbConnection conn, string distribuidora, string mes)
|
||||||
|
{
|
||||||
|
DataTable dados_ = new();
|
||||||
|
string sqlQuery = $"SELECT [Distribuidoras_geral].*, [Distribuidoras_PIS].* FROM [Distribuidoras_geral] INNER JOIN [Distribuidoras_PIS] ON [Distribuidoras_geral].ID_dist = [Distribuidoras_PIS].ID_dist WHERE (([Distribuidoras_geral].Distribuidora) = @distribuidora AND ([Distribuidoras_PIS].Mes) = @mes)";
|
||||||
|
using (OleDbCommand cmd = new(sqlQuery, conn))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("@distribuidora", distribuidora);
|
||||||
|
cmd.Parameters.AddWithValue("@mes", mes);
|
||||||
|
|
||||||
|
using OleDbDataReader reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
dados_.Load(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dados_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// Abre a conexao com o banco de dados
|
||||||
|
using OleDbConnection conn = new(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21");
|
||||||
|
conn.Open();
|
||||||
|
string sqlQuery = @"SELECT Dados_cadastrais.*, Dados_TUSD.*
|
||||||
|
FROM Dados_cadastrais INNER JOIN Dados_TUSD ON Dados_cadastrais.Cod_Smart_unidade = Dados_TUSD.Cod_Smart_unidade
|
||||||
|
WHERE (((Dados_TUSD.Hora_compliance) Is Null))
|
||||||
|
ORDER BY Dados_cadastrais.Gestao, Dados_cadastrais.Cliente, Dados_cadastrais.Unidade, Dados_TUSD.Mes;
|
||||||
|
";
|
||||||
|
using OleDbCommand cmd = new(sqlQuery, conn);
|
||||||
|
using OleDbDataReader reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
Compliance(conn, reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
76
Compliance1/Compliance.cs
Normal file
76
Compliance1/Compliance.cs
Normal file
File diff suppressed because one or more lines are too long
18
Compliance1/Compliance.csproj
Normal file
18
Compliance1/Compliance.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Data.OleDb" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Download Faturas\Download Faturas.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||||
<RootNamespace>Download_Faturas</RootNamespace>
|
<RootNamespace>Download_Faturas</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@ -14,13 +14,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="itext7" Version="7.2.5" />
|
<PackageReference Include="itext7" 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="7.0.0" />
|
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Compliance;
|
||||||
using iText.Kernel.Pdf;
|
using iText.Kernel.Pdf;
|
||||||
using iText.Kernel.Utils;
|
using iText.Kernel.Utils;
|
||||||
using Org.BouncyCastle.Asn1.Cmp;
|
|
||||||
|
|
||||||
public class Fatura
|
public class Fatura
|
||||||
{
|
{
|
||||||
@ -84,6 +84,7 @@
|
|||||||
this.faturaParsed.TryGetProperty("json", out a);
|
this.faturaParsed.TryGetProperty("json", out a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var val = a.ToString().Contains("\"measured\": [");
|
||||||
Rootobject parsedResult = JsonSerializer.Deserialize<Rootobject>(a) !;
|
Rootobject parsedResult = JsonSerializer.Deserialize<Rootobject>(a) !;
|
||||||
dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
||||||
|
|
||||||
@ -352,7 +353,7 @@
|
|||||||
|
|
||||||
// Energia Reativa
|
// Energia Reativa
|
||||||
case ("excessReactiveEnergy", _):
|
case ("excessReactiveEnergy", _):
|
||||||
dadosTusd.En_Reativa_Mvarh += (item.billed / 1000);
|
dadosTusd.En_Reativa_Mvarh += item.billed / 1000;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Demanda Reativa
|
// Demanda Reativa
|
||||||
|
|||||||
41
Download Faturas/FloatArrayOrSingleConverter.cs
Normal file
41
Download Faturas/FloatArrayOrSingleConverter.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
namespace Download_Faturas
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
public class FloatArrayOrSingleConverter : JsonConverter<float[]>
|
||||||
|
{
|
||||||
|
public override float[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (reader.TokenType == JsonTokenType.StartArray)
|
||||||
|
{
|
||||||
|
// Se for um array, desserializa como array de floats
|
||||||
|
return JsonSerializer.Deserialize<float[]>(ref reader, options);
|
||||||
|
}
|
||||||
|
else if (reader.TokenType == JsonTokenType.Number)
|
||||||
|
{
|
||||||
|
// Se for um único valor, cria um array com esse valor
|
||||||
|
return new float[] { reader.GetSingle() };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new JsonException($"Unexpected token {reader.TokenType} when parsing a float array or single float.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, float[] value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (value.Length == 1)
|
||||||
|
{
|
||||||
|
// Se o array tiver apenas um valor, escreve como um único número
|
||||||
|
writer.WriteNumberValue(value[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Se o array tiver múltiplos valores, escreve como array
|
||||||
|
JsonSerializer.Serialize(writer, value, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Download Faturas/JsonExtensions.cs
Normal file
25
Download Faturas/JsonExtensions.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
namespace Compliance
|
||||||
|
{
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.OleDb;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Download_Faturas;
|
||||||
|
|
||||||
|
public static partial class JsonExtensions
|
||||||
|
{
|
||||||
|
public static JsonElement? Get(this JsonElement element, string name) =>
|
||||||
|
element.ValueKind != JsonValueKind.Null && element.ValueKind != JsonValueKind.Undefined && element.TryGetProperty(name, out var value)
|
||||||
|
? value : (JsonElement?)null;
|
||||||
|
|
||||||
|
public static JsonElement? Get(this JsonElement element, int index)
|
||||||
|
{
|
||||||
|
if (element.ValueKind == JsonValueKind.Null || element.ValueKind == JsonValueKind.Undefined)
|
||||||
|
return null;
|
||||||
|
// Throw if index < 0
|
||||||
|
return index < element.GetArrayLength() ? element[index] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -36,6 +36,12 @@
|
|||||||
string fatura_status = fatura.Split(",")[1];
|
string fatura_status = fatura.Split(",")[1];
|
||||||
string fatura_arquivo = fatura.Split(",")[2];
|
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
|
// 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 == "DELAYED" | fatura_status == "MULTACTIONABLE" | fatura_status == "ACTIONABLE" | fatura_status == string.Empty | fatura_status == "UNIDADE CONSUMIDORA NÃO LOCALIZADA NO BD" | fatura_status == "PREPROCESS")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -101,6 +101,7 @@
|
|||||||
|
|
||||||
public string[] texts { get; set; }
|
public string[] texts { get; set; }
|
||||||
|
|
||||||
|
[JsonConverter(typeof(FloatArrayOrSingleConverter))]
|
||||||
public float measured { get; set; }
|
public float measured { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +125,8 @@
|
|||||||
|
|
||||||
public string[] texts { get; set; }
|
public string[] texts { get; set; }
|
||||||
|
|
||||||
|
public float basicRate { get; set; }
|
||||||
|
|
||||||
public float contract { get; set; }
|
public float contract { get; set; }
|
||||||
|
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
|
|||||||
@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compliance", "Compliance\Compliance.csproj", "{C964A170-4A1E-4492-A52F-258BF831BDAA}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -32,6 +34,10 @@ Global
|
|||||||
{75EFF4FA-14FE-4540-B872-F84224CDECAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{75EFF4FA-14FE-4540-B872-F84224CDECAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{75EFF4FA-14FE-4540-B872-F84224CDECAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{75EFF4FA-14FE-4540-B872-F84224CDECAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{75EFF4FA-14FE-4540-B872-F84224CDECAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
{75EFF4FA-14FE-4540-B872-F84224CDECAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C964A170-4A1E-4492-A52F-258BF831BDAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C964A170-4A1E-4492-A52F-258BF831BDAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C964A170-4A1E-4492-A52F-258BF831BDAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C964A170-4A1E-4492-A52F-258BF831BDAA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>Download_Faturas</RootNamespace>
|
<RootNamespace>Download_Faturas</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@ -13,8 +13,8 @@
|
|||||||
<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="7.0.0" />
|
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
<PackageReference Include="System.Text.Json" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -2,6 +2,7 @@ using System.Data.OleDb;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Download_Faturas;
|
using Download_Faturas;
|
||||||
|
using iText.Layout.Splitting;
|
||||||
using Microsoft.AspNetCore.Http.Extensions;
|
using Microsoft.AspNetCore.Http.Extensions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
@ -106,15 +107,20 @@ namespace Webhook_4docs
|
|||||||
var JsonBody = JsonDocument.Parse(requestBody).RootElement;
|
var JsonBody = JsonDocument.Parse(requestBody).RootElement;
|
||||||
string CaminhoDB = "X:/Middle/Informativo Setorial/Modelo Word/BD1_dados cadastrais e faturas.accdb";
|
string CaminhoDB = "X:/Middle/Informativo Setorial/Modelo Word/BD1_dados cadastrais e faturas.accdb";
|
||||||
|
|
||||||
if (JsonBody.TryGetProperty("requestID", out _))
|
if (JsonBody.TryGetProperty("requestID", out JsonElement fatura_ID_json))
|
||||||
{
|
{
|
||||||
string fatura_ID = JsonBody.GetProperty("requestID").ToString();
|
string fatura_ID = fatura_ID_json.ToString();
|
||||||
|
|
||||||
JsonElement DadosJson = JsonDocument.Parse(JsonBody.GetProperty("json").ToString()).RootElement;
|
if (!JsonBody.TryGetProperty("json", out JsonElement root)) { return; }
|
||||||
|
|
||||||
Fatura fatura = new Fatura(fatura_ID, JsonBody);
|
JsonElement DadosJson = JsonDocument.Parse(root.ToString()).RootElement;
|
||||||
|
|
||||||
using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21"))
|
if (root.Get("documentType")?.ToString().ToLower() == "devec") { return; }
|
||||||
|
|
||||||
|
|
||||||
|
Fatura fatura = new(fatura_ID, JsonBody);
|
||||||
|
|
||||||
|
using (OleDbConnection conn = new(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + CaminhoDB + ";Jet OLEDB:Database Password=gds21"))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
@ -230,25 +236,20 @@ namespace Webhook_4docs
|
|||||||
string lastDeactivated = JsonBody.GetProperty("lastDeactivated").ToString() ;
|
string lastDeactivated = JsonBody.GetProperty("lastDeactivated").ToString() ;
|
||||||
string lastDeactivatedBy = JsonBody.GetProperty("lastDeactivatedBy").ToString() ;
|
string lastDeactivatedBy = JsonBody.GetProperty("lastDeactivatedBy").ToString() ;
|
||||||
|
|
||||||
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();
|
conn.Open();
|
||||||
int test = 0;
|
int test = 0;
|
||||||
using (OleDbCommand cmd = new OleDbCommand($"INSERT INTO AgVirtual4DocsErros (locationID, accountID, errorID, deliveryTimeStamp, provider, accessPoint, slaStatus, healthy, blame, lastSuccess, active, blacklistStatus, lastActivated, lastDeactivated, lastDeactivatedBy) VALUES ({locationID}, {accountID}, {errorID}, \'{deliveryTimeStamp}\', \'{provider}\', \'{accessPoint}\', \'{slaStatus}\', \'{healthy}\', \'{blame}\', \'{lastSuccess}\', \'{active}\', \'{blacklistStatus}\', \'{lastActivated}\', \'{lastDeactivated}\', \'{lastDeactivatedBy}\')", conn))
|
using OleDbCommand cmd = new($"INSERT INTO AgVirtual4DocsErros (locationID, accountID, errorID, deliveryTimeStamp, provider, accessPoint, slaStatus, healthy, blame, lastSuccess, active, blacklistStatus, lastActivated, lastDeactivated, lastDeactivatedBy) VALUES ({locationID}, {accountID}, {errorID}, \'{deliveryTimeStamp}\', \'{provider}\', \'{accessPoint}\', \'{slaStatus}\', \'{healthy}\', \'{blame}\', \'{lastSuccess}\', \'{active}\', \'{blacklistStatus}\', \'{lastActivated}\', \'{lastDeactivated}\', \'{lastDeactivatedBy}\')", conn);
|
||||||
{
|
|
||||||
//cmd.Parameters.AddWithValue("@location_id", location_id);
|
//cmd.Parameters.AddWithValue("@location_id", location_id);
|
||||||
//cmd.Parameters.AddWithValue("@errorID", errorID);
|
//cmd.Parameters.AddWithValue("@errorID", errorID);
|
||||||
test = cmd.ExecuteNonQuery();
|
test = cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
public static int UpdateErrorIdStatus(string CaminhoDB, double location_id, double errorID)
|
public static int UpdateErrorIdStatus(string CaminhoDB, double location_id, double errorID)
|
||||||
{
|
{
|
||||||
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();
|
conn.Open();
|
||||||
int test = 0;
|
int test = 0;
|
||||||
using (OleDbCommand cmd = new OleDbCommand($"UPDATE AgVirtual4Docs SET AgVirtual4Docs.errorID = {errorID}\r\nWHERE (((AgVirtual4Docs.location_id)={location_id}));\r\n", conn))
|
using (OleDbCommand cmd = new($"UPDATE AgVirtual4Docs SET AgVirtual4Docs.errorID = {errorID}\r\nWHERE (((AgVirtual4Docs.location_id)={location_id}));\r\n", conn))
|
||||||
{
|
{
|
||||||
//cmd.Parameters.AddWithValue("@location_id", location_id);
|
//cmd.Parameters.AddWithValue("@location_id", location_id);
|
||||||
//cmd.Parameters.AddWithValue("@errorID", errorID);
|
//cmd.Parameters.AddWithValue("@errorID", errorID);
|
||||||
@ -257,7 +258,6 @@ namespace Webhook_4docs
|
|||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public static bool CriarArquivo(string fatura_arquivo, string pdfFile64)
|
public static bool CriarArquivo(string fatura_arquivo, string pdfFile64)
|
||||||
{
|
{
|
||||||
//string fatura_arquivo = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test.pdf";
|
//string fatura_arquivo = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test.pdf";
|
||||||
@ -266,9 +266,9 @@ namespace Webhook_4docs
|
|||||||
{
|
{
|
||||||
byte[] bytes = Convert.FromBase64String(pdfFile64);
|
byte[] bytes = Convert.FromBase64String(pdfFile64);
|
||||||
|
|
||||||
System.IO.FileStream stream = new FileStream(fatura_arquivo, FileMode.CreateNew);
|
System.IO.FileStream stream = new(fatura_arquivo, FileMode.CreateNew);
|
||||||
System.IO.BinaryWriter writer =
|
System.IO.BinaryWriter writer =
|
||||||
new BinaryWriter(stream);
|
new(stream);
|
||||||
writer.Write(bytes, 0, bytes.Length);
|
writer.Write(bytes, 0, bytes.Length);
|
||||||
writer.Close();
|
writer.Close();
|
||||||
t = true;
|
t = true;
|
||||||
@ -276,4 +276,18 @@ namespace Webhook_4docs
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static partial class JsonExtensions
|
||||||
|
{
|
||||||
|
public static JsonElement? Get(this JsonElement element, string name) =>
|
||||||
|
element.ValueKind != JsonValueKind.Null && element.ValueKind != JsonValueKind.Undefined && element.TryGetProperty(name, out var value)
|
||||||
|
? value : (JsonElement?)null;
|
||||||
|
|
||||||
|
public static JsonElement? Get(this JsonElement element, int index)
|
||||||
|
{
|
||||||
|
if (element.ValueKind == JsonValueKind.Null || element.ValueKind == JsonValueKind.Undefined)
|
||||||
|
return null;
|
||||||
|
// Throw if index < 0
|
||||||
|
return index < element.GetArrayLength() ? element[index] : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<RootNamespace>Webhook_4docs</RootNamespace>
|
<RootNamespace>Webhook_4docs</RootNamespace>
|
||||||
@ -12,13 +12,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.17" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
|
||||||
<PackageReference Include="System.Data.OleDb" Version="7.0.0" />
|
<PackageReference Include="System.Data.OleDb" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user