summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs374
1 files changed, 374 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs
new file mode 100644
index 0000000..c8de222
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs
@@ -0,0 +1,374 @@
+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 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.Ferramentas;
+
+internal class SeguradoraServico : BaseServico
+{
+ public async Task<Seguradora> Save(Seguradora seguradora, List<ConfigExtratoImport> config, bool primeiroAcesso = false)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ Seguradora seguradoraOriginal = seguradora;
+ return await Task.Run((Func<Seguradora>)delegate
+ {
+ //IL_0033: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0127: 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_012d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0133: Unknown result type (might be due to invalid IL or missing references)
+ //IL_013e: 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_0151: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0156: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0162: Expected O, but got Unknown
+ //IL_0167: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0178: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0180: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0196: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01e0: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ seguradora = seguradoraOriginal;
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)seguradora).Id != 0L);
+ List<SeguradoraContato> list = seguradora.Contatos;
+ if (list != null)
+ {
+ list.ForEach(delegate(SeguradoraContato x)
+ {
+ x.Seguradora = seguradora;
+ });
+ list = unitOfWork.SeguradoraContatoRepository.Merge(list, seguradora, ((DomainBase)Recursos.Empresa).Id);
+ }
+ List<SeguradoraEndereco> list2 = seguradora.Enderecos;
+ if (list != null)
+ {
+ list2 = unitOfWork.SeguradoraEnderecoRepository.Merge(list2, seguradora, ((DomainBase)Recursos.Empresa).Id);
+ }
+ if (list != null || primeiroAcesso)
+ {
+ seguradora = unitOfWork.SeguradoraRepository.Merge(seguradora);
+ }
+ seguradora.Contatos = list;
+ seguradora.Enderecos = list2;
+ config?.ForEach(delegate(ConfigExtratoImport x)
+ {
+ unitOfWork.ConfigExtratoImportRepository.Merge(x);
+ });
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)seguradora, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)seguradora).Id,
+ Tela = (TipoTela)13,
+ 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 seguradora;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)233, tries, new { seguradora, config });
+ }
+ }
+ return seguradoraOriginal;
+ });
+ }
+
+ public async Task<Seguradora> Insert(Seguradora seguradora)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DateTime now = Funcoes.GetNetworkTime();
+ Seguradora seguradoraOriginal = seguradora;
+ return await Task.Run((Func<Seguradora>)delegate
+ {
+ //IL_0039: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003e: 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_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0068: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0074: Expected O, but got Unknown
+ //IL_0079: 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_0092: 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_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_00f0: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ seguradora = seguradoraOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ seguradora = commited.SeguradoraRepository.SaveOrUpdate(seguradora);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)0,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)seguradora, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)seguradora).Id,
+ Tela = (TipoTela)13,
+ 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 seguradora;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)234, tries, seguradora);
+ }
+ }
+ return seguradoraOriginal;
+ });
+ }
+
+ internal async Task<List<ConfigExtratoImport>> BuscarConfig(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from x in read.ConfigExtratoImportRepository.FindBySeguradora(id)
+ orderby x.Descricao
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)124, tries, id);
+ }
+ }
+ return new List<ConfigExtratoImport>();
+ });
+ }
+
+ public async Task<ObservableCollection<SeguradoraContato>> BuscarContatos(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<SeguradoraContato>(from x in read.SeguradoraContatoRepository.FindBySeguradora(((DomainBase)Recursos.Empresa).Id, id)
+ orderby x.NomeContato
+ select x);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)125, tries, new
+ {
+ ((DomainBase)Recursos.Empresa).Id,
+ id
+ });
+ }
+ }
+ return new ObservableCollection<SeguradoraContato>();
+ });
+ }
+
+ public async Task<ObservableCollection<SeguradoraEndereco>> BuscarEnderecos(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<SeguradoraEndereco>(from x in read.SeguradoraEnderecoRepository.FindBySeguradora(((DomainBase)Recursos.Empresa).Id, id)
+ orderby ((DomainBase)x).Id
+ select x);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)126, tries, new
+ {
+ ((DomainBase)Recursos.Empresa).Id,
+ id
+ });
+ }
+ }
+ return new ObservableCollection<SeguradoraEndereco>();
+ });
+ }
+
+ public async Task<List<SeguradoraContato>> BuscarAssistencias(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SeguradoraContatoRepository.FindAssistencia(((DomainBase)Recursos.Empresa).Id, id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)125, tries, new
+ {
+ ((DomainBase)Recursos.Empresa).Id,
+ id
+ });
+ }
+ }
+ return new List<SeguradoraContato>();
+ });
+ }
+
+ public async Task<List<Seguradora>> BuscarSeguradoras()
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SeguradoraRepository.Find();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)127, tries);
+ }
+ }
+ return new List<Seguradora>();
+ });
+ }
+
+ public async Task<Seguradora> BuscarSeguradora(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Seguradora>)delegate
+ {
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0058: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.SeguradoraRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)128, tries);
+ }
+ }
+ return new Seguradora();
+ });
+ }
+}