summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Seguros
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Servicos.Seguros
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Seguros')
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/ApoliceServico.cs1842
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/AtividadeServico.cs76
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs1082
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/CriticaApoliceServico.cs302
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/ExpedicaoServico.cs178
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/PerfilEmpresaServico.cs178
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/PerfilServico.cs167
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/ProfissaoServico.cs76
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros/SinistroServico.cs385
9 files changed, 4286 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/ApoliceServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/ApoliceServico.cs
new file mode 100644
index 0000000..f68ae01
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/ApoliceServico.cs
@@ -0,0 +1,1842 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using CsQuery.ExtensionMethods;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Relatorios.Fechamento;
+using Gestor.Model.Domain.Relatorios.Tarefa;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class ApoliceServico : BaseServico
+{
+ private bool _carregando;
+
+ internal async Task<ObservableCollection<Documento>> BuscarApolicesAsync(long id, FiltroStatusDocumento status = 0, List<VendedorUsuario> vendedorVinculado = null)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ if (_carregando)
+ {
+ return new ObservableCollection<Documento>();
+ }
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0025: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ _carregando = true;
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ ObservableCollection<Documento> result = new ObservableCollection<Documento>(read.DocumentoRepository.FindApoliceByCustomer(id, status, vendedorVinculado, LicenseHelper.Produtos, false, ((DomainBase)Recursos.Usuario).Id == 0, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 43)));
+ _carregando = false;
+ return result;
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ bool assinatura = LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3);
+ tries = Registrar(e, (TipoErro)1, tries, new { id, status, vendedorVinculado, assinatura });
+ }
+ }
+ _carregando = false;
+ return new ObservableCollection<Documento>();
+ });
+ }
+
+ internal async Task<ObservableCollection<Documento>> BuscarApolicesComissao(long id, FiltroStatusDocumento status = 0)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<Documento>(read.DocumentoRepository.FindApoliceByCustomer(id, status, (List<VendedorUsuario>)null, LicenseHelper.Produtos, true, false, false));
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)2, tries, new { id, status });
+ }
+ }
+ return new ObservableCollection<Documento>();
+ });
+ }
+
+ public async Task<bool> UpdateRange(Controle controle)
+ {
+ int tries = 3;
+ Controle controleSalvo = controle;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ controleSalvo = unitOfWork.ControleRepository.Merge(controleSalvo);
+ controleSalvo.Documentos.ToList().ForEach(delegate(Documento x)
+ {
+ x = unitOfWork.DocumentoRepository.Merge(x);
+ });
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return true;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)19, tries, controle);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<Documento> Excluir(Documento documento)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Documento documentoOriginal = documento;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run((Func<Documento>)delegate
+ {
+ //IL_000d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00de: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f6: Expected O, but got Unknown
+ //IL_00fb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_010c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0113: Unknown result type (might be due to invalid IL or missing references)
+ //IL_011e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0129: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0134: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0172: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)2;
+ Controle controle = documento.Controle;
+ if (controle == null)
+ {
+ controle = commited.DocumentoRepository.FindById(((DomainBase)documento).Id, false, false).Controle;
+ documento.Controle = controle;
+ }
+ commited.ParcelaRepository.ExcluirVinculoParcelaPendenteDocExcluido(documento);
+ Status status = documento.Status;
+ if (status != null && ((DomainBase)status).Id == 0)
+ {
+ documento.Status = null;
+ }
+ documento = commited.DocumentoRepository.Merge(documento);
+ documento.Controle = commited.ControleRepository.Merge(controle);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)documento, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)documento).Id,
+ Tela = (TipoTela)2,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return documento;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)20, tries, documento);
+ }
+ }
+ return documentoOriginal;
+ });
+ }
+
+ public async Task<bool> AtualizarNumero(long id, string numero, string endosso, int tipoDocumento)
+ {
+ return await Task.Run(delegate
+ {
+ try
+ {
+ bool result = true;
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ result = commited.DocumentoRepository.AtualizarNumero(id, numero, endosso, tipoDocumento);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ return result;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ });
+ }
+
+ public async Task Save(Controle controle, Cliente cliente)
+ {
+ int tries = 3;
+ await Task.Run(delegate
+ {
+ //IL_004b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0066: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0092: Expected O, but got Unknown
+ //IL_0099: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e0: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ List<RegistroLog> logs = new List<RegistroLog>();
+ List<RegistroLog> logsTroca = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ List<Diferenca> diferenca = new List<Diferenca>();
+ List<Diferenca> diferencaTroca = new List<Diferenca>();
+ diferenca.Insert(0, new Diferenca
+ {
+ Campo = "Cliente",
+ Descricao = "NOME",
+ ValorAtual = cliente.Nome,
+ ValorAnterior = controle.Cliente.Nome
+ });
+ diferencaTroca.Insert(0, new Diferenca
+ {
+ Campo = "Cliente",
+ Descricao = "APÓLICE TROCADA DE CLIENTE",
+ ValorAtual = cliente.Nome,
+ ValorAnterior = controle.Cliente.Nome
+ });
+ ExtensionMethods.ForEach<Documento>((IEnumerable<Documento>)controle.Documentos, (Action<Documento>)delegate(Documento x)
+ {
+ logs.Add(CreateLog(((DomainBase)x).Id, diferenca, (TipoTela)2));
+ logsTroca.Add(CreateLog(((DomainBase)x).Id, diferencaTroca, (TipoTela)41));
+ });
+ commited.DocumentoRepository.TrocarCliente(controle, cliente);
+ SaveLog(logs, commited);
+ SaveLog(logsTroca, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ break;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)325, tries, controle);
+ }
+ }
+ });
+ }
+
+ public async Task<Documento> Save(Documento documento, bool updateParcelas, bool criarParcelas)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Documento documentoOriginal = documento;
+ DateTime now = Funcoes.GetNetworkTime();
+ List<RegistroLog> logs = new List<RegistroLog>();
+ return await Task.Run((Func<Documento>)delegate
+ {
+ //IL_018d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0193: Invalid comparison between Unknown and I4
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ _ = ((DomainBase)documento).Id;
+ bool num = ((DomainBase)documento).Id == 0;
+ Controle controle = documento.Controle;
+ ObservableCollection<Parcela> parcelas = documento.Parcelas;
+ if (num)
+ {
+ controle = ((documento.Tipo > 0 && ((DomainBase)controle).Id > 0) ? controle : unitOfWork.ControleRepository.SaveOrUpdate(controle));
+ documento.Controle = controle;
+ documento = unitOfWork.DocumentoRepository.SaveOrUpdate(documento);
+ logs.Add(CreateLog(((DomainBase)documento).Id, ((DomainBase)documento).GetValorOriginal(), (TipoTela)2, (TipoAcao)0));
+ parcelas?.ToList().ForEach(delegate(Parcela p)
+ {
+ ObservableCollection<VendedorParcela> vendedores3 = p.Vendedores;
+ p.Documento = documento;
+ p.IdEmpresa = documento.Controle.IdEmpresa;
+ p = unitOfWork.ParcelaRepository.SaveOrUpdate(p);
+ logs.Add(CreateLog(((DomainBase)documento).Id, ((DomainBase)p).GetValorOriginal(), (TipoTela)5, (TipoAcao)0));
+ vendedores3.ToList().ForEach(delegate(VendedorParcela v)
+ {
+ //IL_0047: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Expected I4, but got Unknown
+ v.Documento = documento;
+ v.Parcela = p;
+ if (v.Repasse != null)
+ {
+ switch (v.Repasse.Base)
+ {
+ case 2L:
+ v.DataPrePagamento = p.Vencimento;
+ break;
+ case 0L:
+ v.DataPrePagamento = documento.Vigencia1;
+ break;
+ case 1L:
+ v.DataPrePagamento = now;
+ break;
+ case 3L:
+ v.DataPrePagamento = documento.Emissao;
+ break;
+ case 4L:
+ v.DataPrePagamento = documento.Remessa;
+ break;
+ }
+ }
+ v = unitOfWork.VendedorParcelaRepository.SaveOrUpdate(v);
+ logs.Add(CreateLog(((DomainBase)p).Id, ((DomainBase)v).GetValorOriginal(), (TipoTela)37, (TipoAcao)0));
+ });
+ p.Vendedores = vendedores3;
+ });
+ }
+ else
+ {
+ if (controle == null || ((controle != null) ? controle.Seguradora : null) == null)
+ {
+ controle = unitOfWork.DocumentoRepository.FindById(((DomainBase)documento).Id, false, false).Controle;
+ documento.Controle = controle;
+ }
+ logs.Add(CreateLog(((DomainBase)documento).Id, documento, (TipoTela)2));
+ documento = unitOfWork.DocumentoRepository.Merge(documento);
+ if ((int)documento.TipoRecebimento.GetValueOrDefault() == 1)
+ {
+ if (criarParcelas)
+ {
+ unitOfWork.ParcelaRepository.FindByDocumentId(((DomainBase)documento).Id)?.ForEach(delegate(Parcela pa)
+ {
+ logs.Add(CreateLog(((DomainBase)documento).Id, ((DomainBase)pa).GetValorOriginal(), (TipoTela)5, (TipoAcao)2));
+ });
+ unitOfWork.VendedorParcelaRepository.FindByDocumentId(((DomainBase)documento).Id)?.ForEach(delegate(VendedorParcela pa)
+ {
+ logs.Add(CreateLog(((DomainBase)pa.Parcela).Id, ((DomainBase)pa).GetValorOriginal(), (TipoTela)37, (TipoAcao)2));
+ });
+ unitOfWork.VendedorParcelaRepository.DeleteRange(((DomainBase)documento).Id);
+ unitOfWork.ParcelaRepository.DeleteRange(((DomainBase)documento).Id);
+ parcelas.ToList().ForEach(delegate(Parcela p)
+ {
+ ObservableCollection<VendedorParcela> vendedores2 = p.Vendedores;
+ p.Documento = documento;
+ p.IdEmpresa = documento.Controle.IdEmpresa;
+ p = unitOfWork.ParcelaRepository.SaveOrUpdate(p);
+ vendedores2.ToList().ForEach(delegate(VendedorParcela v)
+ {
+ //IL_0047: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Expected I4, but got Unknown
+ v.Documento = documento;
+ v.Parcela = p;
+ if (v.Repasse != null)
+ {
+ switch (v.Repasse.Base)
+ {
+ case 2L:
+ v.DataPrePagamento = p.Vencimento;
+ break;
+ case 0L:
+ v.DataPrePagamento = documento.Vigencia1;
+ break;
+ case 1L:
+ v.DataPrePagamento = now;
+ break;
+ case 3L:
+ v.DataPrePagamento = documento.Emissao;
+ break;
+ case 4L:
+ v.DataPrePagamento = documento.Remessa;
+ break;
+ }
+ }
+ v = unitOfWork.VendedorParcelaRepository.SaveOrUpdate(v);
+ logs.Add(CreateLog(((DomainBase)p).Id, ((DomainBase)v).GetValorOriginal(), (TipoTela)37, (TipoAcao)0));
+ });
+ p.Vendedores = vendedores2;
+ logs.Add(CreateLog(((DomainBase)documento).Id, ((DomainBase)p).GetValorOriginal(), (TipoTela)5, (TipoAcao)0));
+ });
+ }
+ if (updateParcelas && !criarParcelas)
+ {
+ List<Parcela> parcelasAnteriores = unitOfWork.ParcelaRepository.FindByDocumentId(((DomainBase)documento).Id);
+ List<VendedorParcela> vendedoresAnteriores = unitOfWork.VendedorParcelaRepository.FindByDocumentId(((DomainBase)documento).Id);
+ parcelas.ToList().ForEach(delegate(Parcela p)
+ {
+ //IL_00c0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00db: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0114: Expected O, but got Unknown
+ ObservableCollection<VendedorParcela> vendedores = p.Vendedores;
+ p.Documento = documento;
+ p = unitOfWork.ParcelaRepository.Merge(p);
+ vendedores.ToList().ForEach(delegate(VendedorParcela v)
+ {
+ //IL_013a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0155: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0186: Expected O, but got Unknown
+ v.Documento = documento;
+ v.Parcela = p;
+ int num2 = ((((DomainBase)v).Id <= 0) ? 1 : 0);
+ v = ((((DomainBase)v).Id > 0) ? unitOfWork.VendedorParcelaRepository.Merge(v) : unitOfWork.VendedorParcelaRepository.SaveOrUpdate(v));
+ if (num2 == 0)
+ {
+ logs.Add(CreateLog(((DomainBase)p).Id, ((DomainBase)v).GetValorOriginal(), (TipoTela)37, (TipoAcao)0));
+ }
+ VendedorParcela val2 = ((IEnumerable<VendedorParcela>)vendedoresAnteriores).FirstOrDefault((Func<VendedorParcela, bool>)((VendedorParcela pa) => ((DomainBase)v).Id == ((DomainBase)pa).Id));
+ if (val2 != null)
+ {
+ List<ValorOriginal> valorOriginal2 = ((DomainBase)val2).GetValorOriginal();
+ List<Diferenca> list2 = ((DomainBase)v).Compare(valorOriginal2);
+ if (list2.Count > 0)
+ {
+ list2.Insert(0, new Diferenca
+ {
+ Campo = "Vendedor",
+ Descricao = "VENDEDOR",
+ ValorAtual = v.Vendedor.Nome,
+ ValorAnterior = v.Vendedor.Nome
+ });
+ logs.Add(CreateLog(((DomainBase)p).Id, list2, (TipoTela)37));
+ }
+ }
+ });
+ p.Vendedores = vendedores;
+ Parcela val = ((IEnumerable<Parcela>)parcelasAnteriores).FirstOrDefault((Func<Parcela, bool>)((Parcela pa) => ((DomainBase)p).Id == ((DomainBase)pa).Id));
+ if (val != null)
+ {
+ List<ValorOriginal> valorOriginal = ((DomainBase)val).GetValorOriginal();
+ List<Diferenca> list = ((DomainBase)p).Compare(valorOriginal);
+ if (list.Count > 0)
+ {
+ list.Insert(0, new Diferenca
+ {
+ Campo = "Parcela",
+ Descricao = "PARCELA",
+ ValorAtual = p.NumeroParcela.ToString(),
+ ValorAnterior = p.NumeroParcela.ToString()
+ });
+ logs.Add(CreateLog(((DomainBase)documento).Id, list, (TipoTela)5));
+ }
+ }
+ });
+ }
+ }
+ documento.Controle = unitOfWork.ControleRepository.Merge(controle);
+ }
+ documento.Parcelas = parcelas;
+ SaveLog(logs, unitOfWork);
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return documento;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)18, tries, new { documentoOriginal, updateParcelas, criarParcelas });
+ }
+ }
+ return documentoOriginal;
+ });
+ }
+
+ internal async Task ExcluirVinculo(long id)
+ {
+ await Task.Run(delegate
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.VinculoDocumentoRepository.Delete(id);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ });
+ }
+
+ public async Task<Documento> BuscarApoliceAsync(long id, bool itens = false, bool sinistrosPorControle = false)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Documento>)delegate
+ {
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006a: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindById(id, itens, sinistrosPorControle);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)3, tries, id);
+ }
+ }
+ return new Documento();
+ });
+ }
+
+ public async Task<Vendedor> BuscarVendedorPrincipal(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Vendedor>)delegate
+ {
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.VendedorParcelaRepository.BuscarVendedorPorControle(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)3, tries, id);
+ }
+ }
+ return new Vendedor();
+ });
+ }
+
+ public async Task<List<Documento>> BuscarApolicesPorId(List<long> ids)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindByIds(ids);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)3, tries, ids);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<List<Documento>> BuscarApolicesPorIdParcela(List<long> ids)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindByParcelaIds(ids);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)3, tries, ids);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<Controle> BuscarControleAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Controle>)delegate
+ {
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ControleRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)4, tries, id);
+ }
+ }
+ return new Controle();
+ });
+ }
+
+ public async Task<bool> ExcluirPagamento(List<VendedorParcela> pagamentos)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime dateHora = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0066: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Expected O, but got Unknown
+ //IL_007c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0095: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f4: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.VendedorParcelaRepository.DeleteRange(pagamentos);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (VendedorParcela pagamento in pagamentos)
+ {
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)2,
+ Usuario = Recursos.Usuario,
+ DataHora = dateHora,
+ Descricao = JsonConvert.SerializeObject((object)pagamento, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)pagamento.Parcela).Id,
+ Tela = (TipoTela)37,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)21, tries, pagamentos);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<VendedorParcela> IncluirVendedor(VendedorParcela vendedor)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ VendedorParcela vendedorSalvo = vendedor;
+ DateTime dateHora = Funcoes.GetNetworkTime();
+ return await Task.Run((Func<VendedorParcela>)delegate
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0034: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ vendedorSalvo = commited.VendedorParcelaRepository.SaveOrUpdate(vendedorSalvo);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)0;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = dateHora;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} INCLUIU, EM {dateHora}, O VENDEDOR DE " + $"ID: '{((DomainBase)vendedor).Id}'" + $", VALOR DO PAGAMENTO: 'R${vendedor.ValorRepasse}'" + $", VALOR TOTAL: 'R${vendedor.ValorTotal}'" + ", DATA DO PAGAMENTO: '" + ((!vendedor.DataPagamento.HasValue) ? "" : (vendedor.DataPagamento?.ToShortDateString() ?? "")) + "'" + $", PORCENTAGEM DO PAGAMENTO: '{vendedor.PorcentagemRepasse}%'.";
+ val.EntidadeId = ((DomainBase)vendedor).Id;
+ val.Tela = (TipoTela)37;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return vendedorSalvo;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)22, tries, vendedor);
+ }
+ }
+ return vendedor;
+ });
+ }
+
+ public async Task<List<VendedorParcela>> IncluirVendedores(List<VendedorParcela> repasses)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ List<VendedorParcela> repassesSalvos = repasses;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ repassesSalvos = unitOfWork.VendedorParcelaRepository.AddRange(repassesSalvos);
+ IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
+ repassesSalvos.ForEach(delegate(VendedorParcela x)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003b: Expected O, but got Unknown
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bc: Expected O, but got Unknown
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)0,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)x, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)x.Parcela).Id,
+ Tela = (TipoTela)37,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = host.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ });
+ return repassesSalvos;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)22, tries, repasses);
+ }
+ }
+ return repasses;
+ });
+ }
+
+ public async Task<List<Documento>> BuscarApolices(Filtros filtro, bool buscarAssinatura = false, bool painelBi = false)
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.DocumentoRepository.BuscaDocumentosPorVigencia(filtro, buscarAssinatura, painelBi);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)5, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<List<Documento>> BuscarEndossos(Filtros filtro, bool buscarAssinatura = false)
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.DocumentoRepository.FindEndossoByVigencia(filtro, buscarAssinatura);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)5, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<List<Documento>> BuscarApolicesVigenciaFinal(Filtros filtro, bool somarPremios = false)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindByVigenciaFinal(filtro, LicenseHelper.Produtos, somarPremios);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)6, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ internal async Task<Documento> BuscarCodDocumento(long pesquisa, List<VendedorUsuario> vendedorVinculado)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Documento>)delegate
+ {
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindById(pesquisa, vendedorVinculado);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)3, tries, pesquisa);
+ }
+ }
+ return new Documento();
+ });
+ }
+
+ internal async Task<List<Documento>> BuscarApolice(string pesquisa, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, string campo = "Apolice", bool tipobusca = false)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_009e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindApolice(pesquisa, status, vendedorVinculado, campo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 43), tipobusca);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)7, tries, new { pesquisa, status, campo });
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<List<Fechamento>> BuscarFechamento(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.DocumentoRepository.Fechamento(filtro);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)8, tries, filtro);
+ }
+ }
+ return new List<Fechamento>();
+ });
+ }
+
+ public async Task<bool> Prorrogar(long id, DateTime vigencia2)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ unitOfWork.DocumentoRepository.FindByControle(id).ForEach(delegate(Documento x)
+ {
+ //IL_0073: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0078: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ae: Expected O, but got Unknown
+ //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bf: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00dc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0030: Invalid comparison between Unknown and I4
+ //IL_0124: Expected O, but got Unknown
+ if (!x.NegocioCorretora.HasValue)
+ {
+ x.NegocioCorretora = (NegocioCorretora)((x.Negocio.HasValue && (int)x.Negocio.GetValueOrDefault() == 1) ? 1 : 0);
+ }
+ x.Vigencia2 = vigencia2;
+ unitOfWork.DocumentoRepository.Merge(x);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)1,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)x, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)x).Id,
+ Tela = (TipoTela)2,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ });
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return true;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)23, tries, id);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<bool> Reabilitar(long id)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ unitOfWork.DocumentoRepository.FindByControle(id).ForEach(delegate(Documento x)
+ {
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0075: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0081: Expected O, but got Unknown
+ //IL_0086: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0092: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0099: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00af: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ba: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Invalid comparison between Unknown and I4
+ //IL_00f7: Expected O, but got Unknown
+ if (!x.TipoEndosso.HasValue || (int)x.TipoEndosso.GetValueOrDefault() != 2)
+ {
+ x.Situacao = (TipoSeguro)4;
+ unitOfWork.DocumentoRepository.Merge(x);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)1,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)x, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)x).Id,
+ Tela = (TipoTela)2,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ }
+ });
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return true;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)23, tries, id);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<bool> Perdido(long id)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ unitOfWork.DocumentoRepository.FindByControle(id).ForEach(delegate(Documento x)
+ {
+ //IL_0002: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0035: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Expected O, but got Unknown
+ //IL_0075: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0081: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0088: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0093: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e6: Expected O, but got Unknown
+ x.SituacaoAnterior = x.Situacao;
+ x.Situacao = (TipoSeguro)6;
+ unitOfWork.DocumentoRepository.Merge(x);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)1,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)x, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)x).Id,
+ Tela = (TipoTela)2,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ });
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return true;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)23, tries, id);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<List<Documento>> BuscarApolicesPendentes(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindPendenciasByVigencia(filtro);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)10, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<string> Save(long id, string observacao)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ Documento val = commited.DocumentoRepository.FindById(id, false, false);
+ ((DomainBase)val).Initialize();
+ val.Observacao = observacao;
+ list.Add(CreateLog(((DomainBase)val).Id, val, (TipoTela)2));
+ commited.DocumentoRepository.Merge(val);
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ return observacao;
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)18, tries, new { id, observacao });
+ }
+ }
+ return "";
+ });
+ }
+
+ public async Task<bool> ExcluirCritica(long id)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ //IL_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0072: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0083: Expected O, but got Unknown
+ //IL_0088: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f2: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ CriticaApolice val = commited.CriticaApoliceRepository.FindByApolice(id);
+ if (val == null)
+ {
+ return true;
+ }
+ commited.CriticaApoliceRepository.Delete(((DomainBase)val).Id);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)2,
+ Tela = (TipoTela)20,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)val, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)val).Id,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)25, tries, id);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<List<Documento>> Auditoria(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.Auditoria(filtro);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)13, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<bool> BaixarParcelasCancelamento(Documento documento, bool estorno)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0076: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0088: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ac: Expected O, but got Unknown
+ //IL_00b1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00df: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0127: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ unitOfWork.ParcelaRepository.FindByDocumentId(((DomainBase)documento).Id).ToList().ForEach(delegate(Parcela x)
+ {
+ List<VendedorParcela> list = unitOfWork.VendedorParcelaRepository.FindByParcela(((DomainBase)x).Id);
+ if (list.Count > 0)
+ {
+ if (estorno)
+ {
+ string documentoLabel = ((documento.Tipo == 0) ? (" PROPOSTA " + documento.Proposta + " DO CLIENTE " + documento.Controle.Cliente.Nome) : (" PROPOSTA DE ENDOSSO " + documento.PropostaEndosso + " DO CLIENTE " + documento.Controle.Cliente.Nome));
+ List<Adiantamento> list2 = (from v in list
+ where v.DataPagamento.HasValue
+ group v by ((DomainBase)v.Vendedor).Id).Select((Func<IGrouping<long, VendedorParcela>, Adiantamento>)((IGrouping<long, VendedorParcela> v) => new Adiantamento
+ {
+ Vendedor = v.First().Vendedor,
+ Data = now,
+ Valor = v.Where((VendedorParcela s) => s.ValorRepasse.HasValue).Sum(delegate(VendedorParcela s)
+ {
+ decimal value = s.ValorRepasse.Value;
+ decimal value2 = 1;
+ decimal? desconto = v.First().Vendedor.Desconto;
+ return value * ((decimal?)value2 - desconto).GetValueOrDefault();
+ }),
+ Historico = $"ESTORNO DEVIDO A RECUSA {documentoLabel} PARCELA {x.NumeroParcela}"
+ })).ToList();
+ unitOfWork.AdiantamentoRepository.AddRange(list2);
+ list.Where((VendedorParcela v) => !v.DataPagamento.HasValue).ToList().ForEach(delegate(VendedorParcela v)
+ {
+ v.ValorRepasse = default(decimal);
+ v.DataPagamento = now;
+ v.DataPrePagamento = v.DataPrePagamento.GetValueOrDefault(now);
+ unitOfWork.VendedorParcelaRepository.Merge(v);
+ });
+ }
+ else
+ {
+ list.Where((VendedorParcela v) => !v.DataPrePagamento.HasValue).ToList().ForEach(delegate(VendedorParcela v)
+ {
+ v.ValorRepasse = default(decimal);
+ v.DataPagamento = now;
+ v.DataPrePagamento = v.DataPrePagamento.GetValueOrDefault(now);
+ unitOfWork.VendedorParcelaRepository.Merge(v);
+ });
+ }
+ }
+ if (!x.DataRecebimento.HasValue)
+ {
+ x.DataRecebimento = now;
+ x.DataCredito = now;
+ x.ValorComissao = 0m;
+ x.ValorComDesconto = 0m;
+ unitOfWork.ParcelaRepository.Merge(x);
+ }
+ });
+ unitOfWork.DocumentoRepository.Merge(documento);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)1,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)documento, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)documento).Id,
+ Tela = (TipoTela)2,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return true;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)26, tries, documento);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<int> Cotacoes(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.Cotacoes(filtro);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)14, tries, filtro);
+ }
+ }
+ return 0;
+ });
+ }
+
+ public async Task<List<Documento>> BuscarLicenciamentos(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindByLicenciamento(filtro);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)295, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<List<Documento>> BuscarPlacas(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.FindByPlaca(filtro);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)327, tries, filtro);
+ }
+ }
+ return new List<Documento>();
+ });
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.TarefaRepository.BuscarTarefaPorFiltro(filtro.Inicio, filtro.Fim);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)97, tries, filtro);
+ }
+ }
+ return new List<Tarefa>();
+ });
+ }
+
+ public async Task<List<PlanilhaCompleta>> BuscarPlanilhaCompleta(List<long> ids, bool configFranquia, bool configPremio)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ReportRepository.PlanilhaCompleta(ids, configFranquia, configPremio);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)296, tries, ids);
+ }
+ }
+ return (List<PlanilhaCompleta>)null;
+ });
+ }
+
+ public async Task<List<PlanilhaCompleta>> BuscarPlanilhaCompletaFatura(List<long> ids, Relatorio relatorio, DateTime inicio, DateTime fim, bool configFranquia, bool configPremio)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ReportRepository.PlanilhaCompletaFatura(ids, relatorio, inicio, fim, configFranquia, configPremio);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)296, tries, ids);
+ }
+ }
+ return (List<PlanilhaCompleta>)null;
+ });
+ }
+
+ public async Task<List<PlanilhaCompleta>> BuscarPlanilhaCompletaProspeccao(List<long> ids)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.BuscarPlanilhaCompletaProspeccao(ids);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)296, tries, ids);
+ }
+ }
+ return (List<PlanilhaCompleta>)null;
+ });
+ }
+
+ public async Task<string> BuscarLogAntigo(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DocumentoRepository.BuscarLogAntigo(id, Connection.GetConnectionString());
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)319, tries, id);
+ }
+ }
+ return (string)null;
+ });
+ }
+
+ public async Task SalvarAssistencia(string id, long controleId)
+ {
+ await Task.Run(delegate
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.DocumentoRepository.SalvarAssistencia(id, controleId);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/AtividadeServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/AtividadeServico.cs
new file mode 100644
index 0000000..44347a0
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/AtividadeServico.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class AtividadeServico : BaseServico
+{
+ public async Task<Atividade> Save(Atividade atividade)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Atividade atividadeOriginal = atividade;
+ return await Task.Run((Func<Atividade>)delegate
+ {
+ while (tries > 0)
+ {
+ atividade = atividadeOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ bool flag = ((DomainBase)atividade).Id == 0;
+ atividade = (flag ? commited.AtividadeRepository.SaveOrUpdate(atividade) : commited.AtividadeRepository.Merge(atividade));
+ ((GenericUnitOfWork)commited).Commit();
+ return atividade;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)211, tries, atividade);
+ }
+ }
+ return atividadeOriginal;
+ });
+ }
+
+ public async Task<long> FindLastId()
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.AtividadeRepository.FindLastId();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)17, tries);
+ }
+ }
+ return 0L;
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs
new file mode 100644
index 0000000..4b94129
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs
@@ -0,0 +1,1082 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Common.Validation;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Relatorios.Classificacao;
+using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos;
+using Gestor.Model.Domain.Relatorios.Dashboard;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class ClienteServico : BaseServico
+{
+ internal async Task<List<Cliente>> BuscarCliente(string value, List<long> vinculos = null, TipoFiltroCliente tipoFiltroCliente = 2)
+ {
+ //IL_0026: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Unknown result type (might be due to invalid IL or missing references)
+ value = ValidationHelper.RemoverAcentos(value.Trim());
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ return new List<Cliente>();
+ }
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0076: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ long num = ((Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ bool flag = LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3);
+ return (from x in read.ClienteRepository.FindClienteVinculo(value, vinculos, num, ((DomainBase)Recursos.Usuario).Id == 0, flag, tipoFiltroCliente)
+ orderby x.Nome
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)29, tries, value);
+ }
+ }
+ return new List<Cliente>();
+ });
+ }
+
+ internal async Task<List<Cliente>> BuscarClientePorDocumento(string documento)
+ {
+ documento = ValidationHelper.RemoverAcentos(documento.Trim()).ToUpper();
+ if (string.IsNullOrWhiteSpace(documento))
+ {
+ return new List<Cliente>();
+ }
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from c in read.ClienteRepository.FindClienteDocumento(documento)
+ orderby c.Nome
+ select c).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)29, tries, documento);
+ }
+ }
+ return new List<Cliente>();
+ });
+ }
+
+ internal async Task<List<Cliente>> BuscarClienteVinculo(string value, long id)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ return new List<Cliente>();
+ }
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from x in read.ClienteRepository.FindVinculo(value, id)
+ orderby x.Nome
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)29, tries, value);
+ }
+ }
+ return new List<Cliente>();
+ });
+ }
+
+ internal async Task<Cliente> BuscarCliente(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Cliente>)delegate
+ {
+ //IL_0065: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ Cliente obj = read.ClienteRepository.FindById(id);
+ obj.Nome = obj.Nome;
+ return obj;
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)28, tries, id);
+ }
+ }
+ return new Cliente();
+ });
+ }
+
+ internal async Task<ObservableCollection<ClienteTelefone>> BuscarTelefonesAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<ClienteTelefone>(from x in read.ClienteTelefoneRepository.FindByClienteId(id)
+ orderby x.Ordem
+ select x);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)30, tries, id);
+ }
+ }
+ return new ObservableCollection<ClienteTelefone>();
+ });
+ }
+
+ internal ObservableCollection<ClienteTelefone> BuscarTelefones(long id)
+ {
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<ClienteTelefone>(from x in read.ClienteTelefoneRepository.FindByClienteId(id)
+ orderby x.Ordem
+ select x);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ num = Registrar(e, (TipoErro)30, num, id);
+ }
+ }
+ return new ObservableCollection<ClienteTelefone>();
+ }
+
+ internal async Task<List<ClienteTelefone>> BuscarTelefonesClientes(string telefone)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteTelefoneRepository.Find(telefone, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)31, tries, telefone);
+ }
+ }
+ return new List<ClienteTelefone>();
+ });
+ }
+
+ internal async Task<ObservableCollection<ClienteEmail>> BuscarEmailsAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<ClienteEmail>(from mail in read.ClienteEmailRepository.FindByClienteId(id)
+ orderby mail.Ordem
+ select mail);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)32, tries, id);
+ }
+ }
+ return new ObservableCollection<ClienteEmail>();
+ });
+ }
+
+ internal async Task<ObservableCollection<ClienteVinculo>> BuscarVinculosAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<ClienteVinculo>(read.ClienteVinculoRepository.FindByCliente(id));
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)33, tries, id);
+ }
+ }
+ return new ObservableCollection<ClienteVinculo>();
+ });
+ }
+
+ internal async Task<ObservableCollection<ClienteEndereco>> BuscarEnderecosAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<ClienteEndereco>(from x in read.ClienteEnderecoRepository.FindByClienteId(id)
+ orderby x.Ordem
+ select x);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)34, tries, id);
+ }
+ }
+ return new ObservableCollection<ClienteEndereco>();
+ });
+ }
+
+ internal async Task<ObservableCollection<MaisContato>> BuscarContatosAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<MaisContato>(read.MaisContatoRepository.FindByCustomerId(id));
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)35, tries, id);
+ }
+ }
+ return new ObservableCollection<MaisContato>();
+ });
+ }
+
+ public async Task AddCentralSegurado(long id, bool update = true)
+ {
+ await Task.Run(delegate
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.ClienteRepository.AddCentralSegurado(id, update);
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ });
+ }
+
+ public async Task<Cliente> Save(Cliente cliente, bool salvando = false)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Cliente clienteOriginal = cliente;
+ return await Task.Run((Func<Cliente>)delegate
+ {
+ //IL_003a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0160: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0162: Invalid comparison between Unknown and I4
+ //IL_015f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0536: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ List<RegistroLog> logs = new List<RegistroLog>();
+ cliente = clienteOriginal;
+ try
+ {
+ TipoAcao val = (TipoAcao)(((DomainBase)cliente).Id != 0L);
+ List<ClienteTelefone> list = cliente.Telefones?.ToList();
+ List<ClienteEndereco> list2 = cliente.Enderecos?.ToList();
+ List<MaisContato> list3 = cliente.Contatos?.ToList();
+ List<ClienteEmail> list4 = cliente.Emails?.ToList();
+ List<ClienteVinculo> list5 = cliente.Vinculos?.ToList();
+ List<OrigemCliente> list6 = cliente.Origens;
+ cliente.Telefones = null;
+ cliente.Enderecos = null;
+ cliente.Contatos = null;
+ cliente.Emails = null;
+ cliente.Vinculos = null;
+ cliente.Contatos = null;
+ cliente.Origens = null;
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ bool flag = ((DomainBase)cliente).Id == 0;
+ if (((DomainBase)cliente).Id != 0 && salvando)
+ {
+ flag = true;
+ val = (TipoAcao)0;
+ }
+ if ((int)val == 1)
+ {
+ List<object> lista = new List<object> { list, list2, list3, list4, list5, cliente };
+ logs.Add(CreateDynamicLog(((DomainBase)cliente).Id, lista, (TipoTela)1));
+ unitOfWork.ClienteTelefoneRepository.DeleteFone(((DomainBase)cliente).Id, list)?.ForEach(delegate(ClienteTelefone fone)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)fone).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ });
+ unitOfWork.ClienteEnderecoRepository.DeleteEndereco(((DomainBase)cliente).Id, list2)?.ForEach(delegate(ClienteEndereco endereco)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)endereco).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ });
+ unitOfWork.MaisContatoRepository.DeleteContato(((DomainBase)cliente).Id, list3)?.ForEach(delegate(MaisContato contato)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)contato).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ });
+ unitOfWork.ClienteEmailRepository.DeleteMail(((DomainBase)cliente).Id, list4)?.ForEach(delegate(ClienteEmail mail)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)mail).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ });
+ unitOfWork.ClienteVinculoRepository.DeleteVinculo(((DomainBase)cliente).Id, list5)?.ForEach(delegate(ClienteVinculo vinculo)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)vinculo).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ });
+ }
+ if (flag)
+ {
+ cliente = unitOfWork.ClienteRepository.SaveOrUpdate(cliente);
+ if (list != null)
+ {
+ list = unitOfWork.ClienteTelefoneRepository.Inserir(list, cliente);
+ }
+ if (list2 != null)
+ {
+ list2 = unitOfWork.ClienteEnderecoRepository.Inserir(list2, cliente);
+ }
+ if (list3 != null)
+ {
+ list3 = unitOfWork.MaisContatoRepository.Inserir(list3, cliente);
+ }
+ if (list4 != null)
+ {
+ list4 = unitOfWork.ClienteEmailRepository.Inserir(list4, cliente);
+ }
+ if (list5 != null)
+ {
+ list5 = unitOfWork.ClienteVinculoRepository.Inserir(list5, cliente);
+ }
+ list6?.ForEach(delegate(OrigemCliente x)
+ {
+ x.Cliente = cliente;
+ x = unitOfWork.ClienteRepository.SaveOrUpdate(x);
+ });
+ }
+ else
+ {
+ if (list != null)
+ {
+ list = unitOfWork.ClienteTelefoneRepository.Merge(list, cliente);
+ }
+ if (list2 != null)
+ {
+ list2 = unitOfWork.ClienteEnderecoRepository.Merge(list2, cliente);
+ }
+ if (list3 != null)
+ {
+ list3 = unitOfWork.MaisContatoRepository.Merge(list3, cliente);
+ }
+ if (list4 != null)
+ {
+ list4 = unitOfWork.ClienteEmailRepository.Merge(list4, cliente);
+ }
+ if (list5 != null)
+ {
+ list5 = unitOfWork.ClienteVinculoRepository.Merge(list5, cliente);
+ }
+ list6 = unitOfWork.ClienteRepository.Sincronize(list6, ((DomainBase)cliente).Id);
+ cliente = unitOfWork.ClienteRepository.Merge(cliente);
+ }
+ cliente.Nome = cliente.Nome;
+ cliente.Telefones = ((list == null) ? null : new ObservableCollection<ClienteTelefone>(list));
+ cliente.Enderecos = ((list2 == null) ? null : new ObservableCollection<ClienteEndereco>(list2));
+ cliente.Contatos = ((list3 == null) ? null : new ObservableCollection<MaisContato>(list3));
+ cliente.Emails = ((list4 == null) ? null : new ObservableCollection<ClienteEmail>(list4));
+ cliente.Vinculos = ((list5 == null) ? null : new ObservableCollection<ClienteVinculo>(list5));
+ cliente.Origens = list6;
+ if ((int)val == 0)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)cliente).GetValorOriginal(), (TipoTela)1, (TipoAcao)0));
+ cliente.Telefones?.ToList().ForEach(delegate(ClienteTelefone fone)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)fone).GetValorOriginal(), (TipoTela)1, (TipoAcao)0));
+ });
+ cliente.Enderecos?.ToList().ForEach(delegate(ClienteEndereco endereco)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)endereco).GetValorOriginal(), (TipoTela)1, (TipoAcao)0));
+ });
+ cliente.Contatos?.ToList().ForEach(delegate(MaisContato contato)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)contato).GetValorOriginal(), (TipoTela)1, (TipoAcao)0));
+ });
+ cliente.Emails?.ToList().ForEach(delegate(ClienteEmail mail)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)mail).GetValorOriginal(), (TipoTela)1, (TipoAcao)0));
+ });
+ cliente.Vinculos?.ToList().ForEach(delegate(ClienteVinculo vinculo)
+ {
+ logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)vinculo).GetValorOriginal(), (TipoTela)1, (TipoAcao)0));
+ });
+ }
+ SaveLog(logs, unitOfWork);
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return cliente;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)171, tries, cliente);
+ }
+ }
+ return clienteOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(Cliente cliente)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ list.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)cliente).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ commited.ClienteRepository.Merge(cliente);
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)172, tries, cliente);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<List<ClientesAtivosInativos>> BuscarTodosClientes()
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from x in read.ClienteRepository.FindAllClientes(false, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa)
+ orderby x.Nome
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)36, tries);
+ }
+ }
+ return new List<ClientesAtivosInativos>();
+ });
+ }
+
+ public async Task<IEnumerable<ClientesAtivosInativos>> BuscarClientesAtvosInativos(bool completo)
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.ClienteRepository.BuscaClientes(completo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)286, tries);
+ }
+ }
+ return new List<ClientesAtivosInativos>();
+ });
+ }
+
+ public async Task<Cliente> BuscarClienteAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Cliente>)delegate
+ {
+ //IL_005b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0061: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ Cliente obj = read.ClienteRepository.FindById(id);
+ obj.Nome = obj.Nome;
+ return obj;
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)27, tries);
+ }
+ }
+ return new Cliente();
+ });
+ }
+
+ public async Task<List<ClienteEmail>> BuscarEmailsPorCliente(List<long> ids)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteEmailRepository.FindByCliente(ids);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)37, tries);
+ }
+ }
+ return new List<ClienteEmail>();
+ });
+ }
+
+ public async Task<List<ClienteEndereco>> BuscarEnderecosPorCliente(List<Cliente> clientes)
+ {
+ int tries = 3;
+ if (clientes.All((Cliente x) => ((DomainBase)x).Id < 0))
+ {
+ return new List<ClienteEndereco>();
+ }
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteEnderecoRepository.FindByCliente(clientes);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)38, tries);
+ }
+ }
+ return new List<ClienteEndereco>();
+ });
+ }
+
+ public async Task<List<Cliente>> BuscarObsCliente(string pesquisa)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.FindObsCliente(pesquisa, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)39, tries);
+ }
+ }
+ return new List<Cliente>();
+ });
+ }
+
+ public async Task<List<Cliente>> BuscarPastaCliente(string pesquisa, bool busca)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.FindPastaCliente(pesquisa, busca, 0L);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)40, tries);
+ }
+ }
+ return new List<Cliente>();
+ });
+ }
+
+ public async Task<List<ClientesAtivosInativos>> BuscarAniversariantes(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.BuscarAniversariantes(filtro, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)41, tries);
+ }
+ }
+ return new List<ClientesAtivosInativos>();
+ });
+ }
+
+ public async Task<List<ClientesAtivosInativos>> BuscarVencimentosCnh(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.BuscarVencimentoCnh(filtro, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)42, tries);
+ }
+ }
+ return new List<ClientesAtivosInativos>();
+ });
+ }
+
+ public async Task<List<Prospectar>> BuscarProspect(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.ClienteRepository.BuscaProspeccoes(filtro, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)324, tries);
+ }
+ }
+ return new List<Prospectar>();
+ });
+ }
+
+ public async Task<string> SalvarObservacoes(long id, string observacao)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ Cliente val = commited.ClienteRepository.FindById(id);
+ ((DomainBase)val).Initialize();
+ val.Observacao = observacao;
+ list.Add(CreateLog(((DomainBase)val).Id, val, (TipoTela)1));
+ commited.ClienteRepository.Merge(val);
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ return observacao;
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)171, tries, new { id, observacao });
+ }
+ }
+ return "";
+ });
+ }
+
+ public async Task<ObservableCollection<OrigemCliente>> BuscarOrigens(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<OrigemCliente>(read.ClienteRepository.BuscarOrigem(id));
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)326, tries, id);
+ }
+ }
+ return new ObservableCollection<OrigemCliente>();
+ });
+ }
+
+ public async Task<string> BuscarLogAntigo(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.BuscarLogAntigo(id, Connection.GetConnectionString());
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)319, tries, id);
+ }
+ }
+ return (string)null;
+ });
+ }
+
+ internal DateTime? BuscarNascimento(long id)
+ {
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.BuscaNascimeto(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ num = Registrar(e, (TipoErro)328, num, id);
+ }
+ }
+ return null;
+ }
+
+ public async Task<List<Classificacao>> BuscarClassificacoes()
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.ClienteRepository.BuscarClassificacoes((Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)286, tries);
+ }
+ }
+ return new List<Classificacao>();
+ });
+ }
+
+ public async Task<IEnumerable<ClientesAtivosInativos>> BuscarClientesAtvosInativosVinculo(bool completo, List<VendedorUsuario> vinculo)
+ {
+ int tries = 3;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.ClienteRepository.BuscaClientesVinculo(completo, vinculo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)286, tries);
+ }
+ }
+ return new List<ClientesAtivosInativos>();
+ });
+ }
+
+ public async Task<List<ClientesAtivosInativos>> BuscarAniversariantesVinculo(Filtros filtro, List<VendedorUsuario> vinculo)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.BuscarAniversariantesVinculo(filtro, vinculo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)41, tries);
+ }
+ }
+ return new List<ClientesAtivosInativos>();
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/CriticaApoliceServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/CriticaApoliceServico.cs
new file mode 100644
index 0000000..bf95774
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/CriticaApoliceServico.cs
@@ -0,0 +1,302 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class CriticaApoliceServico : BaseServico
+{
+ private bool _carregando;
+
+ internal async Task<Cliente> BuscarCliente(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Cliente>)delegate
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ClienteRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)27, tries, id);
+ }
+ }
+ return new Cliente();
+ });
+ }
+
+ public async Task<List<CriticaApolice>> BuscarCritica(long usuario, DateTime inicio, DateTime fim, long id = 0L, bool criticado = false, List<VendedorUsuario> vinculos = null)
+ {
+ if (_carregando)
+ {
+ return new List<CriticaApolice>();
+ }
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ _carregando = true;
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ id = ((DomainBase)read.VendedorRepository.FindCorretora()).Id;
+ List<CriticaApolice> result = read.CriticaApoliceRepository.Find(usuario, inicio, fim, id, criticado, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa, vinculos, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 43), Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 38));
+ _carregando = false;
+ return result;
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)43, tries, new { usuario, inicio, fim, criticado });
+ }
+ }
+ _carregando = false;
+ return new List<CriticaApolice>();
+ });
+ }
+
+ public async Task<List<CriticaApolice>> BuscarCritica(DateTime inicio, DateTime fim)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.CriticaApoliceRepository.Find(inicio, fim, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)43, tries, new { inicio, fim });
+ }
+ }
+ return new List<CriticaApolice>();
+ });
+ }
+
+ public async Task<List<Usuario>> BuscarUsuarioCritica(DateTime inicio, DateTime fim, bool criticado = false)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from x in read.CriticaApoliceRepository.BuscarUsuarioCritica(inicio, fim, criticado, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa)
+ orderby x.Nome
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)43, tries, new { inicio, fim, criticado });
+ }
+ }
+ return new List<Usuario>();
+ });
+ }
+
+ public async Task<List<CriticaApolice>> BuscarCritica(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.CriticaApoliceRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)44, tries, id);
+ }
+ }
+ return new List<CriticaApolice>();
+ });
+ }
+
+ public async Task<List<CriticaApolice>> BuscarImportacao(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.CriticaApoliceRepository.FindImport(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)45, tries, id);
+ }
+ }
+ return new List<CriticaApolice>();
+ });
+ }
+
+ public async Task<List<CriticaApolice>> BuscarSeguroCombinado(long id, DateTime vigencia)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.CriticaApoliceRepository.FindDuo(id, vigencia);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)44, tries, id);
+ }
+ }
+ return new List<CriticaApolice>();
+ });
+ }
+
+ public async Task<CriticaApolice> Save(CriticaApolice critica)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ CriticaApolice criticaSalva = critica;
+ return await Task.Run((Func<CriticaApolice>)delegate
+ {
+ //IL_001d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0045: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0046: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0057: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0062: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007a: Expected O, but got Unknown
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0090: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0098: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ae: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f6: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)criticaSalva).Id != 0L);
+ criticaSalva = commited.CriticaApoliceRepository.Merge(criticaSalva);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = Funcoes.GetNetworkTime(),
+ Descricao = JsonConvert.SerializeObject((object)criticaSalva, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)criticaSalva).Id,
+ Tela = (TipoTela)20,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return criticaSalva;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)173, tries, critica);
+ }
+ }
+ return critica;
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/ExpedicaoServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/ExpedicaoServico.cs
new file mode 100644
index 0000000..ae17e2d
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/ExpedicaoServico.cs
@@ -0,0 +1,178 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+public class ExpedicaoServico : BaseServico
+{
+ public async Task<List<Expedicao>> BuscarExpedicoes(Documento documento)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ExpedicaoRepository.FindByIdDocumento(((DomainBase)documento).Id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)289, tries, documento);
+ }
+ }
+ return new List<Expedicao>();
+ });
+ }
+
+ public async Task<Expedicao> Save(Expedicao expedicao)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Expedicao expedicaoOriginal = expedicao;
+ return await Task.Run((Func<Expedicao>)delegate
+ {
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0103: Expected O, but got Unknown
+ //IL_0108: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0119: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0121: Unknown result type (might be due to invalid IL or missing references)
+ //IL_012c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0137: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0142: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0180: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ expedicao = expedicaoOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)expedicao).Id != 0L);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ if (((DomainBase)expedicao).Id == 0L)
+ {
+ expedicao.UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id;
+ expedicao.DataCriacao = networkTime;
+ expedicao = commited.ExpedicaoRepository.SaveOrUpdate(expedicao);
+ }
+ else
+ {
+ expedicao.UsuarioAlteracao = ((DomainBase)Recursos.Usuario).Id;
+ expedicao.DataAlteracao = networkTime;
+ expedicao = commited.ExpedicaoRepository.Merge(expedicao);
+ }
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = networkTime,
+ Descricao = JsonConvert.SerializeObject((object)expedicao, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)expedicao).Id,
+ Tela = (TipoTela)46,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return expedicao;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)290, tries, expedicao);
+ }
+ }
+ return expedicaoOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(Expedicao expedicao)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0033: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.ExpedicaoRepository.Delete(((DomainBase)expedicao).Id);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)2;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = networkTime;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {networkTime}, A EXPEDIÇÃO DE " + $"ID: '{((DomainBase)expedicao).Id}'" + ", DOCUMENTO: '" + expedicao.Documento + "', DESTINO: '" + expedicao.Destino + "'" + $", DATA ENVIO: '{expedicao.DataEnvio}'" + $", DATA RECEBIMENTO: '{expedicao.DataRecebimento}'" + ", RESPONSÁVEL: 'R$" + expedicao.Responsavel + "'.";
+ val.EntidadeId = ((DomainBase)expedicao).Id;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.Tela = (TipoTela)46;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)291, tries, expedicao);
+ }
+ }
+ return false;
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/PerfilEmpresaServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/PerfilEmpresaServico.cs
new file mode 100644
index 0000000..05291e2
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/PerfilEmpresaServico.cs
@@ -0,0 +1,178 @@
+using System;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class PerfilEmpresaServico : BaseServico
+{
+ internal async Task<PerfilEmpresa> BuscarPerfis(long controleId)
+ {
+ int tries = 3;
+ return await Task.Run((Func<PerfilEmpresa>)delegate
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.PerfilEmpresaRepository.FindByControleId(controleId);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)46, tries, controleId);
+ }
+ }
+ return new PerfilEmpresa();
+ });
+ }
+
+ public async Task<PerfilEmpresa> Save(PerfilEmpresa perfil)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ PerfilEmpresa perfilOriginal = perfil;
+ return await Task.Run((Func<PerfilEmpresa>)delegate
+ {
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0082: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0099: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a5: Expected O, but got Unknown
+ //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ce: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0121: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ perfil = perfilOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)perfil).Id != 0L);
+ perfil = ((((DomainBase)perfil).Id == 0L) ? commited.PerfilEmpresaRepository.SaveOrUpdate(perfil) : commited.PerfilEmpresaRepository.Merge(perfil));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = Funcoes.GetNetworkTime(),
+ Descricao = JsonConvert.SerializeObject((object)perfil, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)perfil).Id,
+ Tela = (TipoTela)32,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return perfil;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)212, tries, perfil);
+ }
+ }
+ return perfilOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(PerfilEmpresa perfil)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0033: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0038: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0090: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00be: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0106: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.PerfilEmpresaRepository.Delete(((DomainBase)perfil).Id);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)2,
+ Usuario = Recursos.Usuario,
+ DataHora = networkTime,
+ Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU O PERFIL, EM {networkTime}, DE " + $"ID: '{((DomainBase)perfil).Id}'",
+ EntidadeId = ((DomainBase)perfil).Id,
+ Tela = (TipoTela)3,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)213, tries, perfil);
+ }
+ }
+ return false;
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/PerfilServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/PerfilServico.cs
new file mode 100644
index 0000000..b7955f7
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/PerfilServico.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Common.Validation;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class PerfilServico : BaseServico
+{
+ internal async Task<List<Perfil>> BuscarPerfis(long controleId)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.PerfilRepository.FindByControleId(controleId);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)46, tries, controleId);
+ }
+ }
+ return new List<Perfil>();
+ });
+ }
+
+ public async Task<Perfil> Save(Perfil perfil)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Perfil perfilOriginal = perfil;
+ return await Task.Run((Func<Perfil>)delegate
+ {
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0082: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0099: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a5: Expected O, but got Unknown
+ //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ce: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0121: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ perfil = perfilOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)perfil).Id != 0L);
+ perfil = ((((DomainBase)perfil).Id == 0L) ? commited.PerfilRepository.SaveOrUpdate(perfil) : commited.PerfilRepository.Merge(perfil));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = Funcoes.GetNetworkTime(),
+ Descricao = JsonConvert.SerializeObject((object)perfil, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)perfil).Id,
+ Tela = (TipoTela)32,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return perfil;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)212, tries, perfil);
+ }
+ }
+ return perfilOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(Perfil perfil)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0033: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003a: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.PerfilRepository.Delete(((DomainBase)perfil).Id);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)2;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = networkTime;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU O PERFIL, EM {networkTime}, DE " + $"ID: '{((DomainBase)perfil).Id}'" + ", NOME: '" + (string.IsNullOrWhiteSpace(perfil.Nome) ? "" : (perfil.Nome ?? "")) + "', CPF: '" + (string.IsNullOrWhiteSpace(perfil.Cpf) ? "" : (perfil.Cpf ?? "")) + "', HABILITAÇÃO: '" + (string.IsNullOrWhiteSpace(perfil.Habilitacao) ? "" : (perfil.Habilitacao ?? "")) + "', TEMPO DE HABILITAÇÃO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.TempoHabilitacao) + "', NASCIMENTO: '" + ((!perfil.Nascimento.HasValue) ? "" : (perfil.Nascimento?.ToShortDateString() ?? "")) + "', SEXO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.Sexo) + "', ESTADO CIVIL: '" + ValidationHelper.GetDescription((Enum)(object)perfil.EstadoCivil) + "', OCUPAÇÃO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.Ocupacao) + "', RELAÇÃOO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.Relacao) + "', DISTÂNCIA DO TRABALHO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.DistanciaResidenciaTrabalho) + "', USO POR DEPENDENTES: '" + ValidationHelper.GetDescription((Enum)(object)perfil.UsoDependentes) + "', TIPO DE RESIDÊNCIA: '" + ValidationHelper.GetDescription((Enum)(object)perfil.TipoResidencia) + "', GARAGEM NA RESIDÊNCIA: '" + ValidationHelper.GetDescription((Enum)(object)perfil.GaragemResidencia) + "', GARAGEM NO TRABALHO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.GaragemTrabalho) + "', GARAGEM NO ESTUDO: '" + ValidationHelper.GetDescription((Enum)(object)perfil.GaragemEstudo) + "', VEÍCULOS NA RESIDÊNCIA: '" + ((!perfil.VeiculoResidencia.HasValue) ? "" : $"{perfil.VeiculoResidencia}") + "', ANTFURTO: '" + ((!perfil.AntiFurto.HasValue) ? "" : ValidationHelper.GetDescription((Enum)(object)perfil.AntiFurto)) + "', SEGURO DE VIDA: '" + ((!perfil.SeguroVida.HasValue) ? "" : (perfil.SeguroVida.Value ? "SIM" : "NÃO")) + "', USO PROFISSIONAL: '" + ((!perfil.UsoProfissional.HasValue) ? "" : (perfil.UsoProfissional.Value ? "SIM" : "NÃO")) + "', COBERTURA ESTENDIDA: '" + ((!perfil.EstenderCobertura.HasValue) ? "" : (perfil.EstenderCobertura.Value ? "SIM" : "NÃO")) + "', CEP CIRCULAÇÃO: '" + (string.IsNullOrWhiteSpace(perfil.CepCirculacao) ? "" : (perfil.CepCirculacao ?? "")) + "', CEP PERNOITE: '" + (string.IsNullOrWhiteSpace(perfil.CepPernoite) ? "" : (perfil.CepPernoite ?? "")) + "'.";
+ val.EntidadeId = ((DomainBase)perfil).Id;
+ val.Tela = (TipoTela)3;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)213, tries, perfil);
+ }
+ }
+ return false;
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/ProfissaoServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/ProfissaoServico.cs
new file mode 100644
index 0000000..ed83d06
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/ProfissaoServico.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class ProfissaoServico : BaseServico
+{
+ public async Task<Profissao> Save(Profissao profissao)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Profissao profissaoOriginal = profissao;
+ return await Task.Run((Func<Profissao>)delegate
+ {
+ while (tries > 0)
+ {
+ profissao = profissaoOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ bool flag = ((DomainBase)profissao).Id == 0;
+ profissao = (flag ? commited.ProfissaoRepository.SaveOrUpdate(profissao) : commited.ProfissaoRepository.Merge(profissao));
+ ((GenericUnitOfWork)commited).Commit();
+ return profissao;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)214, tries, profissao);
+ }
+ }
+ return profissaoOriginal;
+ });
+ }
+
+ public async Task<long> FindLastId()
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ProfissaoRepository.FindLastId();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)17, tries);
+ }
+ }
+ return 0L;
+ });
+ }
+}
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/SinistroServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/SinistroServico.cs
new file mode 100644
index 0000000..5a06c52
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros/SinistroServico.cs
@@ -0,0 +1,385 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.Servicos.Seguros;
+
+internal class SinistroServico : BaseServico
+{
+ internal async Task<List<ControleSinistro>> BuscarControles(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ControleSinistroRepository.FindByIdItem(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)48, tries, id);
+ }
+ }
+ return new List<ControleSinistro>();
+ });
+ }
+
+ public async Task<Sinistro> BuscarSinistro(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Sinistro>)delegate
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SinistroRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)49, tries, id);
+ }
+ }
+ return new Sinistro();
+ });
+ }
+
+ public async Task<bool> Delete(Sinistro sinistro)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ list.Add(CreateLog(((DomainBase)sinistro).Id, ((DomainBase)sinistro).GetValorOriginal(), (TipoTela)26, (TipoAcao)2));
+ SinistroAuto val = commited.SinistroAutoRepository.FindBySinistroId(((DomainBase)sinistro).Id);
+ SinistroVida val2 = commited.SinistroVidaRepository.FindBySinistroId(((DomainBase)sinistro).Id);
+ if (val != null)
+ {
+ commited.SinistroAutoRepository.Delete(((DomainBase)val).Id);
+ }
+ if (val2 != null)
+ {
+ commited.SinistroVidaRepository.Delete(((DomainBase)val2).Id);
+ }
+ commited.SinistroRepository.Delete(((DomainBase)sinistro).Id);
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)174, tries, sinistro);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<bool> DeleteControle(ControleSinistro controle, bool atualizarItem)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ return await Task.Run(async delegate
+ {
+ while (tries > 0)
+ {
+ List<RegistroLog> logs = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ if (atualizarItem)
+ {
+ Item val = unitOfWork.ItemRepository.FindById(((DomainBase)controle.Item).Id);
+ val.Sinistrado = false;
+ unitOfWork.ItemRepository.Merge(val);
+ }
+ List<Sinistro> list = unitOfWork.SinistroRepository.FindByControleId(((DomainBase)controle).Id);
+ foreach (Sinistro item in list)
+ {
+ logs.Add(CreateLog(((DomainBase)item).Id, ((DomainBase)item).GetValorOriginal(), (TipoTela)26, (TipoAcao)2));
+ if (!(await Delete(item)))
+ {
+ return false;
+ }
+ }
+ unitOfWork.ControleSinistroRepository.Delete(((DomainBase)controle).Id);
+ SaveLog(logs, unitOfWork);
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)174, tries, controle);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<Sinistro> Save(Sinistro sinistro, long idramo)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Sinistro sinistroSalvo = sinistro;
+ Funcoes.GetNetworkTime();
+ return await Task.Run((Func<Sinistro>)delegate
+ {
+ //IL_028e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0295: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ Item val = commited.ItemRepository.FindById(((DomainBase)sinistro.ControleSinistro.Item).Id);
+ val.Sinistrado = true;
+ sinistroSalvo.ControleSinistro.Item = commited.ItemRepository.Merge(val);
+ bool num = ((DomainBase)sinistroSalvo.ControleSinistro).Id == 0;
+ SinistroAuto sinistroAuto = sinistroSalvo.SinistroAuto;
+ SinistroVida val2 = sinistroSalvo.SinistroVida;
+ if (num)
+ {
+ sinistroSalvo.ControleSinistro = commited.ControleSinistroRepository.SaveOrUpdate(sinistroSalvo.ControleSinistro);
+ sinistroSalvo = commited.SinistroRepository.SaveOrUpdate(sinistroSalvo);
+ list.Add(CreateLog(((DomainBase)sinistroSalvo).Id, ((DomainBase)sinistroSalvo).GetValorOriginal(), (TipoTela)7, (TipoAcao)0));
+ long num2 = idramo;
+ long num3 = num2 - 5;
+ if ((ulong)num3 <= 5uL)
+ {
+ switch (num3)
+ {
+ case 0L:
+ goto IL_012e;
+ case 1L:
+ case 2L:
+ case 4L:
+ case 5L:
+ goto IL_0158;
+ case 3L:
+ goto IL_02d6;
+ }
+ }
+ if (num2 == 37)
+ {
+ goto IL_012e;
+ }
+ if (num2 == 53)
+ {
+ goto IL_0158;
+ }
+ }
+ else
+ {
+ list.Add(CreateLog(((DomainBase)sinistroSalvo).Id, sinistroSalvo, (TipoTela)7));
+ sinistroSalvo.ControleSinistro = commited.ControleSinistroRepository.Merge(sinistroSalvo.ControleSinistro);
+ sinistroSalvo = ((((DomainBase)sinistroSalvo).Id == 0L) ? commited.SinistroRepository.SaveOrUpdate(sinistroSalvo) : commited.SinistroRepository.Merge(sinistroSalvo));
+ long num2 = idramo;
+ long num4 = num2 - 5;
+ if ((ulong)num4 <= 5uL)
+ {
+ switch (num4)
+ {
+ case 0L:
+ goto IL_0247;
+ case 1L:
+ case 2L:
+ case 4L:
+ case 5L:
+ goto IL_028a;
+ case 3L:
+ goto IL_02d6;
+ }
+ }
+ if (num2 == 37)
+ {
+ goto IL_0247;
+ }
+ if (num2 == 53)
+ {
+ goto IL_028a;
+ }
+ }
+ goto IL_02d6;
+ IL_0247:
+ if (sinistroAuto != null)
+ {
+ sinistroAuto.Sinistro = sinistroSalvo;
+ sinistroAuto = ((((DomainBase)sinistroAuto).Id == 0L) ? commited.SinistroAutoRepository.SaveOrUpdate(sinistroAuto) : commited.SinistroAutoRepository.Merge(sinistroAuto));
+ sinistroSalvo.SinistroAuto = sinistroAuto;
+ }
+ goto IL_02d6;
+ IL_028a:
+ if (val2 == null)
+ {
+ val2 = new SinistroVida();
+ }
+ val2.Sinistro = sinistroSalvo;
+ val2 = ((((DomainBase)val2).Id == 0L) ? commited.SinistroVidaRepository.SaveOrUpdate(val2) : commited.SinistroVidaRepository.Merge(val2));
+ sinistroSalvo.SinistroVida = val2;
+ goto IL_02d6;
+ IL_012e:
+ sinistroAuto.Sinistro = sinistroSalvo;
+ sinistroAuto = commited.SinistroAutoRepository.SaveOrUpdate(sinistroAuto);
+ sinistroSalvo.SinistroAuto = sinistroAuto;
+ goto IL_02d6;
+ IL_0158:
+ val2.Sinistro = sinistroSalvo;
+ val2 = commited.SinistroVidaRepository.SaveOrUpdate(val2);
+ sinistroSalvo.SinistroVida = val2;
+ goto IL_02d6;
+ IL_02d6:
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return sinistroSalvo;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)175, tries, sinistro);
+ }
+ }
+ return sinistro;
+ });
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistro(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SinistroRepository.FindByData(filtro, false);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)176, tries, filtro);
+ }
+ }
+ return new List<Sinistro>();
+ });
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistroPendente(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SinistroRepository.FindByData(filtro, true);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)176, tries, filtro);
+ }
+ }
+ return new List<Sinistro>();
+ });
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistros(string numero)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SinistroRepository.FindNumeroSinistro(numero);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)177, tries, numero);
+ }
+ }
+ return new List<Sinistro>();
+ });
+ }
+}