diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Seguros/CriticaApoliceServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Seguros/CriticaApoliceServico.cs | 302 |
1 files changed, 302 insertions, 0 deletions
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; + }); + } +} |