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/ExpedicaoServico.cs | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs (limited to 'Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs') diff --git a/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs b/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs new file mode 100644 index 0000000..47fb942 --- /dev/null +++ b/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs @@ -0,0 +1,192 @@ +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 +{ + public class ExpedicaoServico : BaseServico + { + public ExpedicaoServico() + { + } + + public async Task> BuscarExpedicoes(Documento documento) + { + int num = 3; + List expedicaos1 = await Task.Run>(() => { + List expedicaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + expedicaos = read.get_ExpedicaoRepository().FindByIdDocumento(documento.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 289, num, documento, true); + continue; + } + return expedicaos; + } + return new List(); + }); + return expedicaos1; + } + + public async Task Delete(Expedicao expedicao) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ExpedicaoRepository().Delete(expedicao.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(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A EXPEDIÇÃO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", expedicao.get_Id()), ", DOCUMENTO: '", expedicao.get_Documento(), "', DESTINO: '", expedicao.get_Destino(), "'", string.Format(", DATA ENVIO: '{0}'", expedicao.get_DataEnvio()), string.Format(", DATA RECEBIMENTO: '{0}'", expedicao.get_DataRecebimento()), ", RESPONSÁVEL: 'R$", expedicao.get_Responsavel(), "'." })); + registroLog.set_EntidadeId(expedicao.get_Id()); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_Tela(46); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = ExpedicaoServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ExpedicaoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_21); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 291, num, expedicao, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Expedicao expedicao) + { + int num = 3; + base.Sucesso = true; + Expedicao expedicao2 = expedicao; + Expedicao expedicao3 = await Task.Run(() => { + Expedicao expedicao4; + string str; + while (num > 0) + { + expedicao = expedicao2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (expedicao.get_Id() == 0 ? 0 : 1); + DateTime networkTime = Funcoes.GetNetworkTime(); + if (expedicao.get_Id() != 0) + { + expedicao.set_UsuarioAlteracao(new long?(Recursos.Usuario.get_Id())); + expedicao.set_DataAlteracao(new DateTime?(networkTime)); + expedicao = commited.get_ExpedicaoRepository().Merge(expedicao); + } + else + { + expedicao.set_UsuarioCriacao(new long?(Recursos.Usuario.get_Id())); + expedicao.set_DataCriacao(new DateTime?(networkTime)); + expedicao = commited.get_ExpedicaoRepository().SaveOrUpdate(expedicao); + } + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Expedicao expedicao1 = expedicao; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(expedicao1, jsonSerializerSetting)); + registroLog.set_EntidadeId(expedicao.get_Id()); + registroLog.set_Tela(46); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = ExpedicaoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ExpedicaoServico.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(); + expedicao4 = expedicao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 290, num, expedicao, true); + continue; + } + return expedicao4; + } + return expedicao2; + }); + return expedicao3; + } + } +} \ No newline at end of file -- cgit v1.2.3