Skip to content

Commit

Permalink
Inclusão de novos campos na tabela de log de votos.
Browse files Browse the repository at this point in the history
  • Loading branch information
danarrib committed Nov 21, 2022
1 parent 9e9b3e8 commit 05eaf2f
Show file tree
Hide file tree
Showing 8 changed files with 996 additions and 8 deletions.
1 change: 1 addition & 0 deletions TSEParser/DBContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
else if (motorBanco == MotorBanco.Postgres)
optionsBuilder.UseNpgsql(connectionString);
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<UnidadeFederativa>().Property(e => e.Sigla).IsUnicode(false).HasMaxLength(2).IsFixedLength();
Expand Down
5 changes: 4 additions & 1 deletion TSEParser/DBModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public class SecaoEleitoral
public short QtdJustificativasLog { get; set; }
public short QtdJaVotouLog { get; set; }
public int CodigoIdentificacaoUrnaEletronicaLog { get; set; }

}

public class VotosSecao
Expand Down Expand Up @@ -247,6 +246,10 @@ public class VotosLog
public bool EleitorSuspenso { get; set; }
public short ModeloUrnaEletronica { get; set; }
public int CodigoIdentificacaoUrnaEletronica { get; set; }
public bool UrnaTestada { get; set; }
public int MunicipioCodigoLog { get; set; }
public short CodigoZonaEleitoralLog { get; set; }
public short CodigoSecaoLog { get; set; }
}

public class VotosMunicipio
Expand Down
71 changes: 66 additions & 5 deletions TSEParser/LogDeUrnaServico.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace TSEParser
public class LogDeUrnaServico
{
public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codMunicipio, string nomeMunicipio, string codZona, string codSecao, string diretorioHash,
out DateTime dhZeresima, out string mensagens, out short modeloUrna, bool segundoTurno, string arquivoLogSA, out int codigoIdentificacaoUrnaEletronica,
out DateTime dhZeresima, out string mensagens, out short modeloUrna, bool segundoTurno, string arquivoLogSA, out int codigoIdentificacaoUrnaEletronica,
out short qtdJaVotou, out short qtdJustificativas, out DateTime dhAberturaUrna, out DateTime dhFechamentoUrna)
{
string descricaoSecao = $"UF {UF}, Município {codMunicipio} {nomeMunicipio}, Zona {codZona}, Seção {codSecao}";
Expand Down Expand Up @@ -254,10 +254,10 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM
}

// Começar a processar os logs
var urnaProntaParaReceberVotos = false;
var urnaEncerrada = false;
var estaVotando = false;
short numeroVoto = 0;
var urnaTestada = false;

var dhInicioVoto = DateTime.MinValue;
var dhHabilitacaoUrna = DateTime.MinValue;
Expand All @@ -284,6 +284,9 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM
var dataLinha = DateTime.MinValue;
bool houveTrocaDeModeloDeUrna = false;
bool houveTrocaDeCodigoIdentificadorDeUrna = false;
int codigoMunicipioLog = 0;
short codigoZonaEleitoralLog = 0;
short codigoSecaoEleitoralLog = 0;

foreach (var linha in arrTextoLog)
{
Expand Down Expand Up @@ -324,12 +327,11 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM
codigoIdentificacaoUrnaEletronica = codIdenUE;
}

if (!urnaProntaParaReceberVotos && linha.ToLower().Contains("Urna pronta para receber votos".ToLower()))
if (linha.ToLower().Contains("Urna pronta para receber votos".ToLower()))
{
urnaProntaParaReceberVotos = true;
if (dhAberturaUrna != DateTime.MinValue)
{
if(dhAberturaUrna > dataLinha)
if (dhAberturaUrna > dataLinha)
dhAberturaUrna = dataLinha;
else
mensagens += $"Linha {linhaAtual} - Urna re-aberta para votos.\n";
Expand All @@ -339,6 +341,14 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM
dhAberturaUrna = dataLinha;
}
}
else if (!estaVotando && linha.ToLower().Contains("Identifica que a Urna está testada".ToLower()))
{
urnaTestada = true;
}
else if (!estaVotando && linha.ToLower().Contains("Urna não testada".ToLower()))
{
urnaTestada = false;
}
else if (!estaVotando &&
(linha.ToLower().Contains("Imprimindo relatório [ZERÉSIMA]".ToLower())
|| linha.ToLower().Contains("Imprimindo relatório [ZERÉSIMA DE SEÇÃO]".ToLower()))
Expand All @@ -360,6 +370,49 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM

modeloUrna = tmpModeloUrna;
}
else if (!estaVotando && linha.ToLower().Contains("Município: ".ToLower()))
{
var chave = "Município: ";
var tmp = linha.Substring(linha.IndexOf(chave) + chave.Length);
tmp = tmp.Substring(0, tmp.IndexOf("\t"));
var tmpCodigo = tmp.ToInt();

if (tmpCodigo != 0)
{
if (codigoMunicipioLog != 0 && codigoMunicipioLog != tmpCodigo)
mensagens += $"Linha {linhaAtual} - Municipio foi trocado de {codigoMunicipioLog} para {tmpCodigo}.\n";

codigoMunicipioLog = tmpCodigo;
}
}
else if (!estaVotando && linha.ToLower().Contains("Zona Eleitoral: ".ToLower()))
{
var chave = "Zona Eleitoral: ";
var tmp = linha.Substring(linha.IndexOf(chave) + chave.Length);
tmp = tmp.Substring(0, tmp.IndexOf("\t"));
var tmpCodigo = tmp.ToShort();
if (tmpCodigo != 0)
{
if (codigoZonaEleitoralLog != 0 && codigoZonaEleitoralLog != tmpCodigo)
mensagens += $"Linha {linhaAtual} - Zona eleitoral foi trocada de {codigoZonaEleitoralLog} para {tmpCodigo}.\n";

codigoZonaEleitoralLog = tmpCodigo;
}
}
else if (!estaVotando && linha.ToLower().Contains("Seção Eleitoral: ".ToLower()))
{
var chave = "Seção Eleitoral: ";
var tmp = linha.Substring(linha.IndexOf(chave) + chave.Length);
tmp = tmp.Substring(0, tmp.IndexOf("\t"));
var tmpCodigo = tmp.ToShort();
if (tmpCodigo != 0)
{
if (codigoSecaoEleitoralLog != 0 && codigoSecaoEleitoralLog != tmpCodigo)
mensagens += $"Linha {linhaAtual} - Seção eleitoral foi trocada de {codigoSecaoEleitoralLog} para {tmpCodigo}.\n";

codigoSecaoEleitoralLog = tmpCodigo;
}
}
else if (!estaVotando && linha.ToLower().Contains("Título digitado pelo mesário".ToLower()))
{
estaVotando = true;
Expand Down Expand Up @@ -428,6 +481,10 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM
HabilitacaoUrna = dhHabilitacaoUrna,
ModeloUrnaEletronica = modeloUrna,
CodigoIdentificacaoUrnaEletronica = codigoIdentificacaoUrnaEletronica,
UrnaTestada = urnaTestada,
MunicipioCodigoLog = codigoMunicipioLog,
CodigoZonaEleitoralLog = codigoZonaEleitoralLog,
CodigoSecaoLog = codigoSecaoEleitoralLog,
};
retorno.Add(voto);

Expand Down Expand Up @@ -549,6 +606,10 @@ public List<VotosLog> ProcessarLogUrna(string arquivoLog, string UF, string codM
HabilitacaoUrna = dhHabilitacaoUrna,
ModeloUrnaEletronica = modeloUrna,
CodigoIdentificacaoUrnaEletronica = codigoIdentificacaoUrnaEletronica,
UrnaTestada = urnaTestada,
MunicipioCodigoLog = codigoMunicipioLog,
CodigoZonaEleitoralLog = codigoZonaEleitoralLog,
CodigoSecaoLog = codigoSecaoEleitoralLog,
};
retorno.Add(voto);

Expand Down
Loading

0 comments on commit 05eaf2f

Please sign in to comment.