Skip to content

Commit

Permalink
Ajustes na importação
Browse files Browse the repository at this point in the history
  • Loading branch information
VanderleiDenir committed Nov 23, 2024
1 parent 7985d22 commit 987a9b4
Show file tree
Hide file tree
Showing 32 changed files with 1,415 additions and 647 deletions.
42 changes: 42 additions & 0 deletions OPS.Core/Entity/DeputadoEstadualEmpenhoTemp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Text.Json.Serialization;
using Dapper;

namespace OPS.Core.Entity
{
[Table("cl_empenho_temp", Schema = "ops_tmp")]
public class DeputadoEstadualEmpenhoTemp
{
[JsonIgnore]
[Column("id")]
public int Id { get; set; }

[Column("nome_favorecido")]
public string NomeFavorecido { get; set; }

[Column("cnpj_cpf")]
public string CNPJCPF { get; set; }

//[Column("objeto")]
//public string Objeto { get; set; }

//[Column("tipo_licitacao")]
//public string TipoLicitacao { get; set; }

[Column("numero_empenho")]
public string NumeroEmpenho { get; set; }

[Column("data")]
public DateOnly Data { get; set; }

[Column("competencia")]
public DateOnly Competencia { get; set; }

[Column("valor_empenhado")]
public decimal ValorEmpenhado { get; set; }

[Column("valor_pago")]
public decimal ValorPago { get; set; }

}
}
31 changes: 31 additions & 0 deletions OPS.Core/Utilities/StringExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OPS.Core.Utilities
{
public static class StringExtension
{
public static string ReplaceFirst(this string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}

public static string ReplaceLast(this string text, string search, string replace)
{
int pos = text.LastIndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}
}
}
13 changes: 5 additions & 8 deletions OPS.Core/Utilities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Security.Cryptography;
Expand Down Expand Up @@ -315,14 +316,10 @@ public static string RemoveAccents(this string text)
{
if (string.IsNullOrEmpty(text)) return text;

StringBuilder sbReturn = new StringBuilder();
var arrayText = text.Normalize(NormalizationForm.FormD).ToCharArray();
foreach (char letter in arrayText)
{
if (CharUnicodeInfo.GetUnicodeCategory(letter) != UnicodeCategory.NonSpacingMark)
sbReturn.Append(letter);
}
return sbReturn.ToString();
return string.Concat(
text.Normalize(NormalizationForm.FormD)
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark)
).Normalize(NormalizationForm.FormC);
}

public static string ForceWindows1252ToUtf8Encoding(this string text)
Expand Down
8 changes: 4 additions & 4 deletions OPS.Importador/ALE/Acre.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ImportadorDespesasAcre(IServiceProvider serviceProvider) : base(servicePr
{
BaseAddress = "https://app.al.ac.leg.br/financa/despesaVI", // TODO: Gastos totais mensais apenas
Estado = Estado.Acre,
ChaveImportacao = ChaveDespesaTemp.Indefinido
ChaveImportacao = ChaveDespesaTemp.NomeParlamentar
};
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public override Task Importar()
List<DeputadoAcre> objDeputadosAcre = RestApiGet<List<DeputadoAcre>>(address);

foreach (var parlamentar in objDeputadosAcre)
{
{
var matricula = (uint)parlamentar.Id;
DeputadoEstadual deputado = GetDeputadoByMatriculaOrNew(matricula);

Expand All @@ -97,7 +97,7 @@ private async Task ObterDetalhesDoPerfil(DeputadoEstadual deputado)

var document = await context.OpenAsyncAutoRetry(deputado.UrlPerfil);
if (document.StatusCode != HttpStatusCode.OK)
{
{
Console.WriteLine($"{config.BaseAddress} {document.StatusCode}");
};

Expand All @@ -116,7 +116,7 @@ private async Task ObterDetalhesDoPerfil(DeputadoEstadual deputado)
logger.LogWarning("Verificar possivel mudança no perfil do parlamentar: {UrlPerfil}", deputado.UrlPerfil);
}
}
}
}

public class DeputadoAcre
{
Expand Down
Loading

0 comments on commit 987a9b4

Please sign in to comment.