From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Servicos/Ferramentas/VendedorServico.cs | 851 +++++++++++++++++++++ 1 file changed, 851 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs (limited to 'Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs') diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs new file mode 100644 index 0000000..9c81d34 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs @@ -0,0 +1,851 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Common.Validation; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +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 +{ + public class VendedorServico : BaseServico + { + public VendedorServico() + { + } + + public async Task BuscarCorretora() + { + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorRepository().FindCorretora(); + } + } + catch (Exception exception) + { + vendedor = null; + } + return vendedor; + }); + return vendedor1; + } + + public async Task> BuscaRepasse(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByDocumentId(id); + Func u003cu003e9_31 = VendedorServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (VendedorParcela x) => x.get_TipoVendedor().get_Id(); + VendedorServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + list = vendedorParcelas.OrderBy(u003cu003e9_31).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 136, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task> BuscaRepasseParcela(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByParcela(id); + Func u003cu003e9_41 = VendedorServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (VendedorParcela x) => { + TipoVendedor tipoVendedor = x.get_TipoVendedor(); + if (tipoVendedor != null) + { + return new long?(tipoVendedor.get_Id()); + } + return null; + }; + VendedorServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + list = vendedorParcelas.OrderBy(u003cu003e9_41).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 137, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task> BuscaRepasses() + { + int num = 3; + List repasses1 = await Task.Run>(() => { + List repasses; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + repasses = read.get_RepasseRepository().DefaultSelect((long)0); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 142, num, null, true); + continue; + } + return repasses; + } + return new List(); + }); + return repasses1; + } + + public async Task> BuscaRepassesPorIdVendedor(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_RepasseRepository().FindByIdVendedor(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarPagos(Filtros filtro) + { + int num = 3; + List manutencaoPagamentos = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + list = read.get_VendedorParcelaRepository().FindByDate(filtro).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 80, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return manutencaoPagamentos; + } + + internal async Task> BuscarTelefonesAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorTelefones = read.get_VendedorTelefoneRepository().FindByVendedorId(id); + Func u003cu003e9_51 = VendedorServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = (VendedorTelefone x) => x.get_Nome(); + VendedorServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + observableCollection = new ObservableCollection(vendedorTelefones.OrderBy(u003cu003e9_51)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 138, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarVendedoresAtivosAsync() + { + int num = 3; + List vendedors2 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedors1 = read.get_VendedorRepository().Find(true, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_01 = VendedorServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (Vendedor x) => x.get_Nome(); + VendedorServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + vendedors = new List(vendedors1.OrderBy(u003cu003e9_01)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 135, num, null, true); + continue; + } + return vendedors; + } + return new List(); + }); + return vendedors2; + } + + public async Task> BuscarVendedorParcela(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List vendedorParcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedorParcelas = read.get_RepasseRepository().FindByIdRepasse(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, id, true); + continue; + } + return vendedorParcelas; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task BuscarVendedorParcelaCompleto(long id) + { + int num = 3; + VendedorParcela vendedorParcela1 = await Task.Run(() => { + VendedorParcela vendedorParcela; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedorParcela = read.get_VendedorParcelaRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 81, num, null, true); + continue; + } + return vendedorParcela; + } + return new VendedorParcela(); + }); + return vendedorParcela1; + } + + internal async Task BuscarVendedorPorId(long id) + { + int num = 3; + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 139, num, id, true); + continue; + } + return vendedor; + } + return new Vendedor(); + }); + return vendedor1; + } + + public async Task> BuscarVinculosCliente(long idCliente) + { + int num = 3; + List vendedors1 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + if (Recursos.Usuario.get_IdEmpresa() != (long)1) + { + Recursos.Usuario.get_IdEmpresa(); + } + vendedors = read.get_VendedorParcelaRepository().FindVinculoByIdCliente(idCliente); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, null, true); + continue; + } + return vendedors; + } + return null; + }); + return vendedors1; + } + + public async Task Delete(VinculoRepasse vinculo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_RepasseRepository().DeleteVinculo(vinculo.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + VinculoRepasse vinculoRepasse = vinculo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse, jsonSerializerSetting)); + registroLog.set_EntidadeId(vinculo.get_Id()); + registroLog.set_Tela(53); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_101 = VendedorServico.u003cu003ec.u003cu003e9__10_1; + if (u003cu003e9_101 == null) + { + u003cu003e9_101 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__10_1 = u003cu003e9_101; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_101); + 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, 311, num, vinculo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Delete(Vendedor vendedor) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_VendedorRepository().Delete(vendedor.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, O VENDEDOR DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", vendedor.get_Id()), ", NOME: '", null, null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(vendedor.get_Nome()) ? "" : vendedor.get_Nome() ?? ""); + strArrays[4] = "', DOCUMENTO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(vendedor.get_Documento()) ? "" : vendedor.get_Documento() ?? ""); + strArrays[6] = "', BANCO: '"; + strArrays[7] = (vendedor.get_Banco() == null ? "" : vendedor.get_Banco().get_Nome() ?? ""); + strArrays[8] = "', CONTA: '"; + strArrays[9] = (string.IsNullOrWhiteSpace(vendedor.get_Conta()) ? "" : vendedor.get_Conta() ?? ""); + strArrays[10] = "'."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(15); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_131 = VendedorServico.u003cu003ec.u003cu003e9__13_1; + if (u003cu003e9_131 == null) + { + u003cu003e9_131 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__13_1 = u003cu003e9_131; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_131); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + RegistroLog registroLog3 = registroLog; + if (vendedor.get_Telefones() != null && vendedor.get_Telefones().Count != 0) + { + foreach (VendedorTelefone telefone in vendedor.get_Telefones()) + { + RegistroLog registroLog4 = registroLog3; + string descricao = registroLog4.get_Descricao(); + object[] objArray = new object[] { vendedor.get_Telefones().IndexOf(telefone), null, null, null }; + objArray[1] = (!telefone.get_Tipo().HasValue ? "-" : Gestor.Common.Validation.ValidationHelper.GetDescription(telefone.get_Tipo())); + objArray[2] = (string.IsNullOrWhiteSpace(telefone.get_Prefixo()) ? "" : telefone.get_Prefixo() ?? ""); + objArray[3] = (string.IsNullOrWhiteSpace(telefone.get_Numero()) ? "" : telefone.get_Numero() ?? ""); + registroLog4.set_Descricao(string.Concat(descricao, string.Format(", TELEFONE {0}: {1} ({2}) {3}", objArray))); + } + } + RegistroLog registroLog5 = registroLog3; + registroLog5.set_Descricao(string.Concat(registroLog5.get_Descricao(), ".")); + base.SaveLog(registroLog3, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 242, num, vendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Vendedor vendedor, Repasse repasse) + { + int num = 3; + base.Sucesso = true; + Vendedor vendedor1 = vendedor; + Vendedor vendedor2 = await Task.Run(() => { + Vendedor vendedor3; + while (num > 0) + { + vendedor = vendedor1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa())); + vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor); + repasse.set_Vendedor(vendedor); + repasse = commited.get_RepasseRepository().SaveOrUpdate(repasse); + commited.Commit(); + vendedor3 = vendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasse = repasse }, true); + continue; + } + return vendedor3; + } + return vendedor1; + }); + return vendedor2; + } + + public async Task Save(VinculoRepasse vinculo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + VinculoRepasse vinculoRepasse2 = await Task.Run(() => { + VinculoRepasse vinculoRepasse; + string str; + while (num > 0) + { + VinculoRepasse vinculoRepasse1 = vinculo; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (vinculoRepasse1.get_Id() == 0 ? 0 : 1); + vinculoRepasse1 = (tipoAcao == null ? commited.get_RepasseRepository().SaveOrUpdate(vinculoRepasse1) : commited.get_RepasseRepository().Merge(vinculoRepasse1)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vinculoRepasse1.get_Id()); + registroLog.set_Tela(53); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_91 = VendedorServico.u003cu003ec.u003cu003e9__9_1; + if (u003cu003e9_91 == null) + { + u003cu003e9_91 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_91); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + vinculoRepasse = vinculoRepasse1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 311, num, vinculo, true); + continue; + } + return vinculoRepasse; + } + return vinculo; + }); + return vinculoRepasse2; + } + + public async Task Save(Vendedor vendedor, List repasses) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Vendedor vendedor2 = vendedor; + Vendedor vendedor3 = await Task.Run(() => { + Vendedor vendedor4; + string str; + string str1; + while (num > 0) + { + vendedor = vendedor2; + try + { + List telefones = vendedor.get_Telefones(); + using (UnitOfWork commited = Instancia.Commited) + { + List repasses1 = repasses; + Func u003cu003e9_111 = VendedorServico.u003cu003ec.u003cu003e9__11_1; + if (u003cu003e9_111 == null) + { + u003cu003e9_111 = (Repasse r) => { + Ramo ramo = r.get_Ramo(); + if (ramo == null) + { + return false; + } + return ramo.get_Id() == (long)0; + }; + VendedorServico.u003cu003ec.u003cu003e9__11_1 = u003cu003e9_111; + } + foreach (Repasse repasse in repasses1.Where(u003cu003e9_111)) + { + repasse.set_Ramo(null); + } + bool id = vendedor.get_Id() == (long)0; + vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa())); + TipoAcao tipoAcao = (vendedor.get_Id() == 0 ? 0 : 1); + if (!id) + { + vendedor = commited.get_VendedorRepository().Merge(vendedor); + if (telefones != null) + { + telefones = commited.get_VendedorTelefoneRepository().Merge(telefones, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass in repasses) + { + if (repass.get_Id() != 0) + { + commited.get_RepasseRepository().Merge(repass); + } + else + { + commited.get_RepasseRepository().SaveOrUpdate(repass); + } + } + } + } + else + { + vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor); + if (telefones != null) + { + telefones = commited.get_VendedorTelefoneRepository().Inserir(telefones, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass1 in repasses) + { + repass1.set_Vendedor(vendedor); + commited.get_RepasseRepository().SaveOrUpdate(repass1); + } + } + } + vendedor.set_Telefones(telefones); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (Recursos.Usuario.get_Id() != 0) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Vendedor vendedor1 = vendedor; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vendedor1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(15); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_112 = VendedorServico.u003cu003ec.u003cu003e9__11_2; + if (u003cu003e9_112 == null) + { + u003cu003e9_112 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__11_2 = u003cu003e9_112; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_112); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + foreach (Repasse repasse1 in repasses) + { + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(tipoAcao); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); + jsonSerializerSetting1.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting1)); + registroLog1.set_EntidadeId(repasse1.get_Id()); + registroLog1.set_Tela(54); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_113 = VendedorServico.u003cu003ec.u003cu003e9__11_3; + if (u003cu003e9_113 == null) + { + u003cu003e9_113 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__11_3 = u003cu003e9_113; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_113); + if (pAddress1 != null) + { + str1 = pAddress1.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + base.SaveLog(registroLog1, commited); + } + } + commited.Commit(); + vendedor4 = vendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasses = repasses }, true); + continue; + } + return vendedor4; + } + return vendedor2; + }); + return vendedor3; + } + + public async Task Save(Repasse repasse) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Repasse repasse2 = repasse; + Repasse repasse3 = await Task.Run(() => { + Repasse repasse4; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + repasse2 = commited.get_RepasseRepository().Merge(repasse2); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Repasse repasse1 = repasse; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(repasse.get_Id()); + registroLog.set_Tela(54); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_121 = VendedorServico.u003cu003ec.u003cu003e9__12_1; + if (u003cu003e9_121 == null) + { + u003cu003e9_121 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__12_1 = u003cu003e9_121; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_121); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + repasse4 = repasse2; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { repasse = repasse }, true); + continue; + } + return repasse4; + } + return repasse; + }); + return repasse3; + } + } +} \ No newline at end of file -- cgit v1.2.3