From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../Servicos/Ferramentas/SeguradoraServico.cs | 372 +++++++++++++++++++++ 1 file changed, 372 insertions(+) create mode 100644 Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs (limited to 'Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs') diff --git a/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs b/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs new file mode 100644 index 0000000..fe44719 --- /dev/null +++ b/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs @@ -0,0 +1,372 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class SeguradoraServico : BaseServico + { + public SeguradoraServico() + { + } + + public async Task> BuscarAssistencias(long id) + { + int num = 3; + List seguradoraContatos1 = await Task.Run>(() => { + List seguradoraContatos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradoraContatos = read.get_SeguradoraContatoRepository().FindAssistencia(Recursos.Empresa.get_Id(), id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return seguradoraContatos; + } + return new List(); + }); + return seguradoraContatos1; + } + + internal async Task> BuscarConfig(long id) + { + int num = 3; + List configExtratoImports1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List configExtratoImports = read.get_ConfigExtratoImportRepository().FindBySeguradora(id); + Func u003cu003e9_21 = SeguradoraServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (ConfigExtratoImport x) => x.get_Descricao(); + SeguradoraServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + list = configExtratoImports.OrderBy(u003cu003e9_21).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 124, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return configExtratoImports1; + } + + public async Task> BuscarContatos(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoraContatos = read.get_SeguradoraContatoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id); + Func u003cu003e9_31 = SeguradoraServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (SeguradoraContato x) => x.get_NomeContato(); + SeguradoraServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + observableCollection = new ObservableCollection(seguradoraContatos.OrderBy(u003cu003e9_31)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarEnderecos(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoraEnderecos = read.get_SeguradoraEnderecoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id); + Func u003cu003e9_41 = SeguradoraServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (SeguradoraEndereco x) => x.get_Id(); + SeguradoraServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + observableCollection = new ObservableCollection(seguradoraEnderecos.OrderBy(u003cu003e9_41)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 126, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task BuscarSeguradora(long id) + { + int num = 3; + Seguradora seguradora1 = await Task.Run(() => { + Seguradora seguradora; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradora = read.get_SeguradoraRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 128, num, null, true); + continue; + } + return seguradora; + } + return new Seguradora(); + }); + return seguradora1; + } + + public async Task> BuscarSeguradoras() + { + int num = 3; + List seguradoras1 = await Task.Run>(() => { + List seguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradoras = read.get_SeguradoraRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 127, num, null, true); + continue; + } + return seguradoras; + } + return new List(); + }); + return seguradoras1; + } + + public async Task Insert(Seguradora seguradora) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Seguradora seguradora2 = seguradora; + Seguradora seguradora3 = await Task.Run(() => { + Seguradora seguradora4; + string str; + while (num > 0) + { + seguradora = seguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + seguradora = commited.get_SeguradoraRepository().SaveOrUpdate(seguradora); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Seguradora seguradora1 = seguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(seguradora.get_Id()); + registroLog.set_Tela(13); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = SeguradoraServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + SeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + seguradora4 = seguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 234, num, seguradora, true); + continue; + } + return seguradora4; + } + return seguradora2; + }); + return seguradora3; + } + + public async Task Save(Seguradora seguradora, List config, bool primeiroAcesso = false) + { + Action action2 = null; + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Seguradora seguradora2 = seguradora; + Seguradora seguradora3 = await Task.Run(() => { + Seguradora seguradora4; + string str; + while (num > 0) + { + seguradora = seguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (seguradora.get_Id() == 0 ? 0 : 1); + List contatos = seguradora.get_Contatos(); + if (contatos != null) + { + List seguradoraContatos = contatos; + Action u003cu003e9_1 = action2; + if (u003cu003e9_1 == null) + { + Action action = (SeguradoraContato x) => x.set_Seguradora(seguradora); + Action action1 = action; + action2 = action; + u003cu003e9_1 = action1; + } + seguradoraContatos.ForEach(u003cu003e9_1); + contatos = commited.get_SeguradoraContatoRepository().Merge(contatos, seguradora, Recursos.Empresa.get_Id()); + } + List enderecos = seguradora.get_Enderecos(); + if (contatos != null) + { + enderecos = commited.get_SeguradoraEnderecoRepository().Merge(enderecos, seguradora, Recursos.Empresa.get_Id()); + } + if (contatos != null | primeiroAcesso) + { + seguradora = commited.get_SeguradoraRepository().Merge(seguradora); + } + seguradora.set_Contatos(contatos); + seguradora.set_Enderecos(enderecos); + List configExtratoImports = config; + if (configExtratoImports != null) + { + configExtratoImports.ForEach((ConfigExtratoImport x) => commited.get_ConfigExtratoImportRepository().Merge(x)); + } + else + { + } + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Seguradora seguradora1 = seguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(seguradora.get_Id()); + registroLog.set_Tela(13); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_03 = SeguradoraServico.u003cu003ec.u003cu003e9__0_3; + if (u003cu003e9_03 == null) + { + u003cu003e9_03 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + SeguradoraServico.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_03); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + seguradora4 = seguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 233, num, new { seguradora = seguradora, config = config }, true); + continue; + } + return seguradora4; + } + return seguradora2; + }); + return seguradora3; + } + } +} \ No newline at end of file -- cgit v1.2.3