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/Seguros/PerfilEmpresaServico.cs | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs (limited to 'Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs') diff --git a/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs b/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs new file mode 100644 index 0000000..21aa774 --- /dev/null +++ b/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs @@ -0,0 +1,179 @@ +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.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Seguros +{ + internal class PerfilEmpresaServico : BaseServico + { + public PerfilEmpresaServico() + { + } + + internal async Task BuscarPerfis(long controleId) + { + int num = 3; + PerfilEmpresa perfilEmpresa1 = await Task.Run(() => { + PerfilEmpresa perfilEmpresa; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + perfilEmpresa = read.get_PerfilEmpresaRepository().FindByControleId(controleId); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 46, num, controleId, true); + continue; + } + return perfilEmpresa; + } + return new PerfilEmpresa(); + }); + return perfilEmpresa1; + } + + public async Task Delete(PerfilEmpresa perfil) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_PerfilEmpresaRepository().Delete(perfil.get_Id()); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(string.Concat(string.Format("O USUÁRIO {0} EXCLUIU O PERFIL, EM {1}, DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", perfil.get_Id()))); + registroLog.set_EntidadeId(perfil.get_Id()); + registroLog.set_Tela(3); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = PerfilEmpresaServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PerfilEmpresaServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_21); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 213, num, perfil, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(PerfilEmpresa perfil) + { + int num = 3; + base.Sucesso = true; + PerfilEmpresa perfilEmpresa2 = perfil; + PerfilEmpresa perfilEmpresa3 = await Task.Run(() => { + PerfilEmpresa perfilEmpresa; + string str; + while (num > 0) + { + perfil = perfilEmpresa2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (perfil.get_Id() == 0 ? 0 : 1); + perfil = (perfil.get_Id() == 0 ? commited.get_PerfilEmpresaRepository().SaveOrUpdate(perfil) : commited.get_PerfilEmpresaRepository().Merge(perfil)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + PerfilEmpresa perfilEmpresa1 = perfil; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(perfilEmpresa1, jsonSerializerSetting)); + registroLog.set_EntidadeId(perfil.get_Id()); + registroLog.set_Tela(32); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = PerfilEmpresaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PerfilEmpresaServico.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(); + perfilEmpresa = perfil; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 212, num, perfil, true); + continue; + } + return perfilEmpresa; + } + return perfilEmpresa2; + }); + return perfilEmpresa3; + } + } +} \ No newline at end of file -- cgit v1.2.3