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/Seguros/ApoliceServico.cs | 1848 +++++++++++++++++++ .../Servicos/Seguros/AtividadeServico.cs | 78 + .../Servicos/Seguros/ClienteServico.cs | 1194 ++++++++++++ .../Servicos/Seguros/CriticaApoliceServico.cs | 321 ++++ .../Servicos/Seguros/ExpedicaoServico.cs | 192 ++ .../Servicos/Seguros/Itens/AeronauticoServico.cs | 121 ++ .../Servicos/Seguros/Itens/AutoServico.cs | 262 +++ .../Servicos/Seguros/Itens/ConsorcioServico.cs | 156 ++ .../Servicos/Seguros/Itens/GranizoServico.cs | 156 ++ .../Servicos/Seguros/Itens/ItemServico.cs | 1900 ++++++++++++++++++++ .../Servicos/Seguros/Itens/PatrimonialServico.cs | 196 ++ .../Seguros/Itens/RiscosDiversosServico.cs | 156 ++ .../Servicos/Seguros/Itens/VidaServico.cs | 156 ++ .../Servicos/Seguros/PerfilEmpresaServico.cs | 179 ++ .../Servicos/Seguros/PerfilServico.cs | 241 +++ .../Servicos/Seguros/ProfissaoServico.cs | 78 + .../Servicos/Seguros/SinistroServico.cs | 400 +++++ 17 files changed, 7634 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs (limited to 'Codemerx/Gestor.Application/Servicos/Seguros') diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs new file mode 100644 index 0000000..0aae6a5 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs @@ -0,0 +1,1848 @@ +using CsQuery.ExtensionMethods; +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.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Relatorios.Fechamento; +using Gestor.Model.Domain.Relatorios.Tarefa; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +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.Seguros +{ + internal class ApoliceServico : BaseServico + { + private bool _carregando; + + public ApoliceServico() + { + } + + public async Task AtualizarNumero(long id, string numero, string endosso, int tipoDocumento) + { + bool flag2 = await Task.Run(() => { + bool flag; + try + { + bool flag1 = true; + using (UnitOfWork commited = Instancia.Commited) + { + flag1 = commited.get_DocumentoRepository().AtualizarNumero(id, numero, endosso, tipoDocumento); + commited.Commit(); + } + flag = flag1; + } + catch (Exception exception) + { + flag = false; + } + return flag; + }); + return flag2; + } + + public async Task> Auditoria(Filtros filtro) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().Auditoria(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 13, num, filtro, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task BaixarParcelasCancelamento(Documento documento, bool estorno) + { + int num1 = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str1; + Action action3 = null; + Action action4 = null; + while (num1 > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()).ToList().ForEach((Parcela x) => { + Action action; + List vendedorParcelas = commited.get_VendedorParcelaRepository().FindByParcela(x.get_Id()); + if (vendedorParcelas.Count > 0) + { + if (!estorno) + { + List vendedorParcelas1 = vendedorParcelas; + Func u003cu003e9_302 = ApoliceServico.u003cu003ec.u003cu003e9__30_2; + if (u003cu003e9_302 == null) + { + u003cu003e9_302 = (VendedorParcela v) => !v.get_DataPrePagamento().HasValue; + ApoliceServico.u003cu003ec.u003cu003e9__30_2 = u003cu003e9_302; + } + List list = vendedorParcelas1.Where(u003cu003e9_302).ToList(); + Action u003cu003e9_3 = action4; + if (u003cu003e9_3 == null) + { + Action action1 = (VendedorParcela v) => { + v.set_ValorRepasse(new decimal?(new decimal())); + v.set_DataPagamento(new DateTime?(networkTime)); + v.set_DataPrePagamento(new DateTime?(v.get_DataPrePagamento().GetValueOrDefault(networkTime))); + commited.get_VendedorParcelaRepository().Merge(v); + }; + action = action1; + action4 = action1; + u003cu003e9_3 = action; + } + list.ForEach(u003cu003e9_3); + } + else + { + string str = (documento.get_Tipo() == 0 ? string.Concat(" PROPOSTA ", documento.get_Proposta(), " DO CLIENTE ", documento.get_Controle().get_Cliente().get_Nome()) : string.Concat(" PROPOSTA DE ENDOSSO ", documento.get_PropostaEndosso(), " DO CLIENTE ", documento.get_Controle().get_Cliente().get_Nome())); + List vendedorParcelas2 = vendedorParcelas; + Func u003cu003e9_304 = ApoliceServico.u003cu003ec.u003cu003e9__30_4; + if (u003cu003e9_304 == null) + { + u003cu003e9_304 = (VendedorParcela v) => v.get_DataPagamento().HasValue; + ApoliceServico.u003cu003ec.u003cu003e9__30_4 = u003cu003e9_304; + } + IEnumerable vendedorParcelas3 = vendedorParcelas2.Where(u003cu003e9_304); + Func u003cu003e9_305 = ApoliceServico.u003cu003ec.u003cu003e9__30_5; + if (u003cu003e9_305 == null) + { + u003cu003e9_305 = (VendedorParcela v) => v.get_Vendedor().get_Id(); + ApoliceServico.u003cu003ec.u003cu003e9__30_5 = u003cu003e9_305; + } + List adiantamentos = vendedorParcelas3.GroupBy(u003cu003e9_305).Select, Adiantamento>((IGrouping v) => { + Adiantamento adiantamento = new Adiantamento(); + adiantamento.set_Vendedor(v.First().get_Vendedor()); + adiantamento.set_Data(new DateTime?(networkTime)); + IGrouping nums = v; + Func u003cu003e9_309 = ApoliceServico.u003cu003ec.u003cu003e9__30_9; + if (u003cu003e9_309 == null) + { + u003cu003e9_309 = (VendedorParcela s) => s.get_ValorRepasse().HasValue; + ApoliceServico.u003cu003ec.u003cu003e9__30_9 = u003cu003e9_309; + } + adiantamento.set_Valor(nums.Where(u003cu003e9_309).Sum((VendedorParcela s) => { + decimal? nullable; + decimal? nullable1; + decimal? valorRepasse = s.get_ValorRepasse(); + decimal value = valorRepasse.Value; + decimal num = 1; + valorRepasse = v.First().get_Vendedor().get_Desconto(); + if (valorRepasse.HasValue) + { + nullable1 = new decimal?(num - valorRepasse.GetValueOrDefault()); + } + else + { + nullable = null; + nullable1 = nullable; + } + nullable = nullable1; + return value * nullable.GetValueOrDefault(); + })); + adiantamento.set_Historico(string.Format("ESTORNO DEVIDO A RECUSA {0} PARCELA {1}", str, x.get_NumeroParcela())); + return adiantamento; + }).ToList(); + commited.get_AdiantamentoRepository().AddRange(adiantamentos); + List vendedorParcelas4 = vendedorParcelas; + Func u003cu003e9_307 = ApoliceServico.u003cu003ec.u003cu003e9__30_7; + if (u003cu003e9_307 == null) + { + u003cu003e9_307 = (VendedorParcela v) => !v.get_DataPagamento().HasValue; + ApoliceServico.u003cu003ec.u003cu003e9__30_7 = u003cu003e9_307; + } + List list1 = vendedorParcelas4.Where(u003cu003e9_307).ToList(); + Action u003cu003e9_8 = action3; + if (u003cu003e9_8 == null) + { + Action action2 = (VendedorParcela v) => { + v.set_ValorRepasse(new decimal?(new decimal())); + v.set_DataPagamento(new DateTime?(networkTime)); + v.set_DataPrePagamento(new DateTime?(v.get_DataPrePagamento().GetValueOrDefault(networkTime))); + commited.get_VendedorParcelaRepository().Merge(v); + }; + action = action2; + action3 = action2; + u003cu003e9_8 = action; + } + list1.ForEach(u003cu003e9_8); + } + } + if (x.get_DataRecebimento().HasValue) + { + return; + } + x.set_DataRecebimento(new DateTime?(networkTime)); + x.set_DataCredito(new DateTime?(networkTime)); + x.set_ValorComissao(decimal.Zero); + x.set_ValorComDesconto(decimal.Zero); + commited.get_ParcelaRepository().Merge(x); + }); + commited.get_DocumentoRepository().Merge(documento); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Documento documento1 = documento; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(documento1, jsonSerializerSetting)); + registroLog.set_EntidadeId(documento.get_Id()); + registroLog.set_Tela(2); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_3011 = ApoliceServico.u003cu003ec.u003cu003e9__30_11; + if (u003cu003e9_3011 == null) + { + u003cu003e9_3011 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__30_11 = u003cu003e9_3011; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_3011); + if (pAddress != null) + { + str1 = pAddress.ToString(); + } + else + { + str1 = null; + } + registroLog.set_Ip(str1); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 26, num1, documento, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task> BuscarApolice(string pesquisa, FiltroStatusDocumento status, List vendedorVinculado, string campo = "Apolice", bool tipobusca = false) + { + int num1 = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + long num; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + IDocumentoRepository documentoRepository = read.get_DocumentoRepository(); + string str = pesquisa; + FiltroStatusDocumento filtroStatusDocumento = status; + List vendedorUsuarios = vendedorVinculado; + string str1 = campo; + num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + List configuracoes = Recursos.Configuracoes; + Func u003cu003e9_211 = ApoliceServico.u003cu003ec.u003cu003e9__21_1; + if (u003cu003e9_211 == null) + { + u003cu003e9_211 = (ConfiguracaoSistema x) => x.get_Configuracao() == 43; + ApoliceServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211; + } + documentos = documentoRepository.FindApolice(str, filtroStatusDocumento, vendedorUsuarios, str1, num, configuracoes.Any(u003cu003e9_211), tipobusca); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 7, num1, new { pesquisa = pesquisa, status = status, campo = campo }, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task BuscarApoliceAsync(long id, bool itens = false, bool sinistrosPorControle = false) + { + int num = 3; + Documento documento1 = await Task.Run(() => { + Documento documento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documento = read.get_DocumentoRepository().FindById(id, itens, sinistrosPorControle); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 3, num, id, true); + continue; + } + return documento; + } + return new Documento(); + }); + return documento1; + } + + public async Task> BuscarApolices(Filtros filtro, bool buscarAssinatura = false, bool painelBi = false) + { + int num = 3; + List documentos1 = await Task.Run>(async () => { + List documentos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = await read.get_DocumentoRepository().BuscaDocumentosPorVigencia(filtro, buscarAssinatura, painelBi); + return documentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 5, num, filtro, true); + } + if (num <= 0) + { + break; + } + } + documentos = new List(); + return documentos; + }); + return documentos1; + } + + internal async Task> BuscarApolicesAsync(long id, FiltroStatusDocumento status = 0, List vendedorVinculado = null) + { + ObservableCollection observableCollection1; + if (!this._carregando) + { + int num1 = 3; + observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num1 > 0) + { + try + { + this._carregando = true; + using (UnitOfWork read = Instancia.Read) + { + IDocumentoRepository documentoRepository = read.get_DocumentoRepository(); + long num = id; + FiltroStatusDocumento filtroStatusDocumento = status; + List vendedorUsuarios = vendedorVinculado; + List produtos = LicenseHelper.Produtos; + bool flag1 = Recursos.Usuario.get_Id() == (long)0; + List configuracoes = Recursos.Configuracoes; + Func u003cu003e9_11 = ApoliceServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (ConfiguracaoSistema x) => x.get_Configuracao() == 43; + ApoliceServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + this._carregando = false; + observableCollection = new ObservableCollection(documentoRepository.FindApoliceByCustomer(num, filtroStatusDocumento, vendedorUsuarios, produtos, false, flag1, configuracoes.Any(u003cu003e9_11))); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + List licencas = LicenseHelper.Produtos; + Func u003cu003e9_12 = ApoliceServico.u003cu003ec.u003cu003e9__1_2; + if (u003cu003e9_12 == null) + { + u003cu003e9_12 = (Licenca x) => { + if (x.get_Produto() != 86) + { + return false; + } + return x.get_Status() != 3; + }; + ApoliceServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12; + } + bool flag = licencas.Any(u003cu003e9_12); + num1 = base.Registrar(exception, 1, num1, new { id = id, status = status, vendedorVinculado = vendedorVinculado, assinatura = flag }, true); + continue; + } + return observableCollection; + } + this._carregando = false; + return new ObservableCollection(); + }); + } + else + { + observableCollection1 = new ObservableCollection(); + } + return observableCollection1; + } + + internal async Task> BuscarApolicesComissao(long id, FiltroStatusDocumento status = 0) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_DocumentoRepository().FindApoliceByCustomer(id, status, null, LicenseHelper.Produtos, true, false, false)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 2, num, new { id = id, status = status }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarApolicesPendentes(Filtros filtro) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().FindPendenciasByVigencia(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 10, num, filtro, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarApolicesPorId(List ids) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().FindByIds(ids); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 3, num, ids, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarApolicesPorIdParcela(List ids) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().FindByParcelaIds(ids); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 3, num, ids, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarApolicesVigenciaFinal(Filtros filtro, bool somarPremios = false) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().FindByVigenciaFinal(filtro, LicenseHelper.Produtos, somarPremios); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 6, num, filtro, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + internal async Task BuscarCodDocumento(long pesquisa, List vendedorVinculado) + { + int num = 3; + Documento documento1 = await Task.Run(() => { + Documento documento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documento = read.get_DocumentoRepository().FindById(pesquisa, vendedorVinculado); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 3, num, pesquisa, true); + continue; + } + return documento; + } + return new Documento(); + }); + return documento1; + } + + public async Task BuscarControleAsync(long id) + { + int num = 3; + Controle controle1 = await Task.Run(() => { + Controle controle; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + controle = read.get_ControleRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 4, num, id, true); + continue; + } + return controle; + } + return new Controle(); + }); + return controle1; + } + + public async Task> BuscarEndossos(Filtros filtro, bool buscarAssinatura = false) + { + int num = 3; + List documentos1 = await Task.Run>(async () => { + List documentos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = await read.get_DocumentoRepository().FindEndossoByVigencia(filtro, buscarAssinatura); + return documentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 5, num, filtro, true); + } + if (num <= 0) + { + break; + } + } + documentos = new List(); + return documentos; + }); + return documentos1; + } + + public async Task> BuscarFechamento(Filtros filtro) + { + int num = 3; + List fechamentos1 = await Task.Run>(async () => { + List fechamentos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + fechamentos = await read.get_DocumentoRepository().Fechamento(filtro); + return fechamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 8, num, filtro, true); + } + if (num <= 0) + { + break; + } + } + fechamentos = new List(); + return fechamentos; + }); + return fechamentos1; + } + + public async Task> BuscarLicenciamentos(Filtros filtro) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().FindByLicenciamento(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 295, num, filtro, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task BuscarLogAntigo(long id) + { + int num = 3; + string str1 = await Task.Run(() => { + string str; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + str = read.get_DocumentoRepository().BuscarLogAntigo(id, Gestor.Application.Helpers.Connection.GetConnectionString()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 319, num, id, true); + continue; + } + return str; + } + return null; + }); + return str1; + } + + public async Task> BuscarPlacas(Filtros filtro) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().FindByPlaca(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 327, num, filtro, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarPlanilhaCompleta(List ids, bool configFranquia, bool configPremio) + { + int num = 3; + List planilhaCompletas1 = await Task.Run>(() => { + List planilhaCompletas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + planilhaCompletas = read.get_ReportRepository().PlanilhaCompleta(ids, configFranquia, configPremio); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 296, num, ids, true); + continue; + } + return planilhaCompletas; + } + return null; + }); + return planilhaCompletas1; + } + + public async Task> BuscarPlanilhaCompletaFatura(List ids, Relatorio relatorio, DateTime inicio, DateTime fim, bool configFranquia, bool configPremio) + { + int num = 3; + List planilhaCompletas1 = await Task.Run>(() => { + List planilhaCompletas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + planilhaCompletas = read.get_ReportRepository().PlanilhaCompletaFatura(ids, relatorio, inicio, fim, configFranquia, configPremio); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 296, num, ids, true); + continue; + } + return planilhaCompletas; + } + return null; + }); + return planilhaCompletas1; + } + + public async Task> BuscarPlanilhaCompletaProspeccao(List ids) + { + int num = 3; + List planilhaCompletas1 = await Task.Run>(() => { + List planilhaCompletas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + planilhaCompletas = read.get_DocumentoRepository().BuscarPlanilhaCompletaProspeccao(ids); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 296, num, ids, true); + continue; + } + return planilhaCompletas; + } + return null; + }); + return planilhaCompletas1; + } + + public async Task> BuscarTarefas(Filtros filtro) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefaPorFiltro(filtro.get_Inicio(), filtro.get_Fim()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 97, num, filtro, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task BuscarVendedorPrincipal(long id) + { + int num = 3; + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorParcelaRepository().BuscarVendedorPorControle(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 3, num, id, true); + continue; + } + return vendedor; + } + return new Vendedor(); + }); + return vendedor1; + } + + public async Task Cotacoes(Filtros filtro) + { + int num1 = 3; + int num2 = await Task.Run(() => { + int num; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + num = read.get_DocumentoRepository().Cotacoes(filtro); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 14, num1, filtro, true); + continue; + } + return num; + } + return 0; + }); + return num2; + } + + public async Task Excluir(Documento documento) + { + int num = 3; + base.Sucesso = true; + Documento documento2 = documento; + DateTime networkTime = Funcoes.GetNetworkTime(); + Documento documento3 = await Task.Run(() => { + Documento documento4; + bool id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = 2; + Controle controle = documento.get_Controle(); + if (controle == null) + { + controle = commited.get_DocumentoRepository().FindById(documento.get_Id(), false, false).get_Controle(); + documento.set_Controle(controle); + } + commited.get_ParcelaRepository().ExcluirVinculoParcelaPendenteDocExcluido(documento); + Status status = documento.get_Status(); + id = (status != null ? status.get_Id() == (long)0 : false); + if (id) + { + documento.set_Status(null); + } + documento = commited.get_DocumentoRepository().Merge(documento); + documento.set_Controle(commited.get_ControleRepository().Merge(controle)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Documento documento1 = documento; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(documento1, jsonSerializerSetting)); + registroLog.set_EntidadeId(documento.get_Id()); + registroLog.set_Tela(2); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_41 = ApoliceServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_41); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + documento4 = documento; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 20, num, documento, true); + continue; + } + return documento4; + } + return documento2; + }); + return documento3; + } + + public async Task ExcluirCritica(long id) + { + 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) + { + CriticaApolice criticaApolouse = commited.get_CriticaApoliceRepository().FindByApolice(id); + if (criticaApolouse != null) + { + commited.get_CriticaApoliceRepository().Delete(criticaApolouse.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Tela(20); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(criticaApolouse, jsonSerializerSetting)); + registroLog.set_EntidadeId(criticaApolouse.get_Id()); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_281 = ApoliceServico.u003cu003ec.u003cu003e9__28_1; + if (u003cu003e9_281 == null) + { + u003cu003e9_281 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__28_1 = u003cu003e9_281; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_281); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + else + { + flag = true; + } + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 25, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task ExcluirPagamento(List pagamentos) + { + 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_VendedorParcelaRepository().DeleteRange(pagamentos); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + foreach (VendedorParcela pagamento in pagamentos) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(pagamento, jsonSerializerSetting)); + registroLog.set_EntidadeId(pagamento.get_Parcela().get_Id()); + registroLog.set_Tela(37); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_141 = ApoliceServico.u003cu003ec.u003cu003e9__14_1; + if (u003cu003e9_141 == null) + { + u003cu003e9_141 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_141); + 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, 21, num, pagamentos, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task ExcluirVinculo(long id) + { + await Task.Run(() => { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_VinculoDocumentoRepository().Delete(id); + commited.Commit(); + } + } + catch (Exception exception) + { + } + }); + } + + public async Task IncluirVendedor(VendedorParcela vendedor) + { + int num = 3; + base.Sucesso = true; + VendedorParcela vendedorParcela1 = vendedor; + DateTime networkTime = Funcoes.GetNetworkTime(); + VendedorParcela vendedorParcela2 = await Task.Run(() => { + VendedorParcela vendedorParcela; + object obj; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vendedorParcela1 = commited.get_VendedorParcelaRepository().SaveOrUpdate(vendedorParcela1); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} INCLUIU, EM {1}, O VENDEDOR DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", vendedor.get_Id()), string.Format(", VALOR DO PAGAMENTO: 'R${0}'", vendedor.get_ValorRepasse()), string.Format(", VALOR TOTAL: 'R${0}'", vendedor.get_ValorTotal()), ", DATA DO PAGAMENTO: '", null, null, null }; + DateTime? dataPagamento = vendedor.get_DataPagamento(); + if (!dataPagamento.HasValue) + { + obj = ""; + } + else + { + dataPagamento = vendedor.get_DataPagamento(); + obj = (dataPagamento.HasValue ? dataPagamento.GetValueOrDefault().ToShortDateString() : null) ?? ""; + } + strArrays[5] = (string)obj; + strArrays[6] = "'"; + strArrays[7] = string.Format(", PORCENTAGEM DO PAGAMENTO: '{0}%'.", vendedor.get_PorcentagemRepasse()); + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(37); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_151 = ApoliceServico.u003cu003ec.u003cu003e9__15_1; + if (u003cu003e9_151 == null) + { + u003cu003e9_151 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_151); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + vendedorParcela = vendedorParcela1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 22, num, vendedor, true); + continue; + } + return vendedorParcela; + } + return vendedor; + }); + return vendedorParcela2; + } + + public async Task> IncluirVendedores(List repasses) + { + int num = 3; + base.Sucesso = true; + List vendedorParcelas1 = repasses; + DateTime networkTime = Funcoes.GetNetworkTime(); + List vendedorParcelas2 = await Task.Run>(() => { + List vendedorParcelas; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vendedorParcelas1 = commited.get_VendedorParcelaRepository().AddRange(vendedorParcelas1); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + vendedorParcelas1.ForEach((VendedorParcela x) => { + string str; + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting)); + registroLog.set_EntidadeId(x.get_Parcela().get_Id()); + registroLog.set_Tela(37); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_162 = ApoliceServico.u003cu003ec.u003cu003e9__16_2; + if (u003cu003e9_162 == null) + { + u003cu003e9_162 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__16_2 = u003cu003e9_162; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_162); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + }); + vendedorParcelas = vendedorParcelas1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 22, num, repasses, true); + continue; + } + return vendedorParcelas; + } + return repasses; + }); + return vendedorParcelas2; + } + + public async Task Perdido(long id) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_DocumentoRepository().FindByControle(id).ForEach((Documento x) => { + string str; + x.set_SituacaoAnterior(new TipoSeguro?(x.get_Situacao())); + x.set_Situacao(6); + commited.get_DocumentoRepository().Merge(x); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting)); + registroLog.set_EntidadeId(x.get_Id()); + registroLog.set_Tela(2); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_252 = ApoliceServico.u003cu003ec.u003cu003e9__25_2; + if (u003cu003e9_252 == null) + { + u003cu003e9_252 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__25_2 = u003cu003e9_252; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_252); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 23, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Prorrogar(long id, DateTime vigencia2) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_DocumentoRepository().FindByControle(id).ForEach((Documento x) => { + string str; + if (!x.get_NegocioCorretora().HasValue) + { + x.set_NegocioCorretora(new NegocioCorretora?((!x.get_Negocio().HasValue || x.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1))); + } + x.set_Vigencia2(new DateTime?(vigencia2)); + commited.get_DocumentoRepository().Merge(x); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting)); + registroLog.set_EntidadeId(x.get_Id()); + registroLog.set_Tela(2); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_232 = ApoliceServico.u003cu003ec.u003cu003e9__23_2; + if (u003cu003e9_232 == null) + { + u003cu003e9_232 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__23_2 = u003cu003e9_232; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_232); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 23, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Reabilitar(long id) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_DocumentoRepository().FindByControle(id).ForEach((Documento x) => { + string str; + if (x.get_TipoEndosso().HasValue && x.get_TipoEndosso().GetValueOrDefault() == 2) + { + return; + } + x.set_Situacao(4); + commited.get_DocumentoRepository().Merge(x); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting)); + registroLog.set_EntidadeId(x.get_Id()); + registroLog.set_Tela(2); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_242 = ApoliceServico.u003cu003ec.u003cu003e9__24_2; + if (u003cu003e9_242 == null) + { + u003cu003e9_242 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ApoliceServico.u003cu003ec.u003cu003e9__24_2 = u003cu003e9_242; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_242); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 23, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task SalvarAssistencia(string id, long controleId) + { + await Task.Run(() => { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_DocumentoRepository().SalvarAssistencia(id, controleId); + commited.Commit(); + } + } + catch (Exception exception) + { + } + }); + } + + public async Task Save(Controle controle, Cliente cliente) + { + int num = 3; + await Task.Run(() => { + while (num > 0) + { + List registroLogs = new List(); + List registroLogs1 = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + List diferencas = new List(); + List diferencas1 = new List(); + List diferencas2 = diferencas; + Diferenca diferenca = new Diferenca(); + diferenca.set_Campo("Cliente"); + diferenca.set_Descricao("NOME"); + diferenca.set_ValorAtual(cliente.get_Nome()); + diferenca.set_ValorAnterior(controle.get_Cliente().get_Nome()); + diferencas2.Insert(0, diferenca); + List diferencas3 = diferencas1; + Diferenca diferenca1 = new Diferenca(); + diferenca1.set_Campo("Cliente"); + diferenca1.set_Descricao("APÓLICE TROCADA DE CLIENTE"); + diferenca1.set_ValorAtual(cliente.get_Nome()); + diferenca1.set_ValorAnterior(controle.get_Cliente().get_Nome()); + diferencas3.Insert(0, diferenca1); + ExtensionMethods.ForEach(controle.get_Documentos(), (Documento x) => { + registroLogs.Add(base.CreateLog(x.get_Id(), diferencas, 2)); + registroLogs1.Add(base.CreateLog(x.get_Id(), diferencas1, 41)); + }); + commited.get_DocumentoRepository().TrocarCliente(controle, cliente); + base.SaveLog(registroLogs, commited); + base.SaveLog(registroLogs1, commited); + commited.Commit(); + break; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 325, num, controle, true); + } + } + }); + } + + public async Task Save(Documento documento, bool updateParcelas, bool criarParcelas) + { + Action action4 = null; + Action action5 = null; + int num = 3; + base.Sucesso = true; + Documento documento1 = documento; + DateTime networkTime = Funcoes.GetNetworkTime(); + List registroLogs = new List(); + Documento documento2 = await Task.Run(() => { + Documento documento3; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + documento.get_Id(); + bool id = documento.get_Id() == (long)0; + Controle controle = documento.get_Controle(); + ObservableCollection parcelas = documento.get_Parcelas(); + if (!id) + { + if (controle != null) + { + if ((controle != null ? controle.get_Seguradora() : false)) + { + goto Label0; + } + } + controle = commited.get_DocumentoRepository().FindById(documento.get_Id(), false, false).get_Controle(); + documento.set_Controle(controle); + Label0: + registroLogs.Add(base.CreateLog(documento.get_Id(), documento, 2)); + documento = commited.get_DocumentoRepository().Merge(documento); + if (documento.get_TipoRecebimento().GetValueOrDefault() == 1) + { + if (criarParcelas) + { + List parcelas1 = commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()); + if (parcelas1 != null) + { + Action u003cu003e9_3 = action4; + if (u003cu003e9_3 == null) + { + Action action = (Parcela pa) => registroLogs.Add(base.CreateLog(documento.get_Id(), pa.GetValorOriginal(), 5, 2)); + Action action1 = action; + action4 = action; + u003cu003e9_3 = action1; + } + parcelas1.ForEach(u003cu003e9_3); + } + else + { + } + List vendedorParcelas = commited.get_VendedorParcelaRepository().FindByDocumentId(documento.get_Id()); + if (vendedorParcelas != null) + { + Action u003cu003e9_4 = action5; + if (u003cu003e9_4 == null) + { + Action action2 = (VendedorParcela pa) => registroLogs.Add(base.CreateLog(pa.get_Parcela().get_Id(), pa.GetValorOriginal(), 37, 2)); + Action action3 = action2; + action5 = action2; + u003cu003e9_4 = action3; + } + vendedorParcelas.ForEach(u003cu003e9_4); + } + else + { + } + commited.get_VendedorParcelaRepository().DeleteRange(documento.get_Id()); + commited.get_ParcelaRepository().DeleteRange(documento.get_Id()); + parcelas.ToList().ForEach((Parcela p) => { + Parcela parcela = p; + ObservableCollection vendedores = parcela.get_Vendedores(); + parcela.set_Documento(documento); + parcela.set_IdEmpresa(documento.get_Controle().get_IdEmpresa()); + parcela = commited.get_ParcelaRepository().SaveOrUpdate(parcela); + vendedores.ToList().ForEach((VendedorParcela v) => { + v.set_Documento(documento); + v.set_Parcela(parcela); + if (v.get_Repasse() != null) + { + BaseRepasse? @base = v.get_Repasse().get_Base(); + if (@base.HasValue) + { + switch (@base.GetValueOrDefault()) + { + case 1: + { + v.set_DataPrePagamento(new DateTime?(documento.get_Vigencia1())); + break; + } + case 2: + { + v.set_DataPrePagamento(new DateTime?(networkTime)); + break; + } + case 3: + { + v.set_DataPrePagamento(new DateTime?(parcela.get_Vencimento())); + break; + } + case 4: + { + v.set_DataPrePagamento(documento.get_Emissao()); + break; + } + case 5: + { + v.set_DataPrePagamento(documento.get_Remessa()); + break; + } + } + } + } + v = commited.get_VendedorParcelaRepository().SaveOrUpdate(v); + registroLogs.Add(base.CreateLog(parcela.get_Id(), v.GetValorOriginal(), 37, 0)); + }); + parcela.set_Vendedores(vendedores); + registroLogs.Add(base.CreateLog(documento.get_Id(), parcela.GetValorOriginal(), 5, 0)); + }); + } + if (updateParcelas && !criarParcelas) + { + List parcelas2 = commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()); + List vendedorParcelas1 = commited.get_VendedorParcelaRepository().FindByDocumentId(documento.get_Id()); + parcelas.ToList().ForEach((Parcela p) => { + Parcela parcela = p; + ObservableCollection vendedores = parcela.get_Vendedores(); + parcela.set_Documento(documento); + parcela = commited.get_ParcelaRepository().Merge(parcela); + vendedores.ToList().ForEach((VendedorParcela v) => { + bool flag; + VendedorParcela vendedorParcela = v; + vendedorParcela.set_Documento(documento); + vendedorParcela.set_Parcela(parcela); + flag = (vendedorParcela.get_Id() > (long)0 ? false : true); + vendedorParcela = (vendedorParcela.get_Id() > (long)0 ? commited.get_VendedorParcelaRepository().Merge(vendedorParcela) : commited.get_VendedorParcelaRepository().SaveOrUpdate(vendedorParcela)); + if (!flag) + { + registroLogs.Add(base.CreateLog(parcela.get_Id(), vendedorParcela.GetValorOriginal(), 37, 0)); + } + VendedorParcela vendedorParcela1 = vendedorParcelas1.FirstOrDefault((VendedorParcela pa) => vendedorParcela.get_Id() == pa.get_Id()); + if (vendedorParcela1 == null) + { + return; + } + List diferencas = vendedorParcela.Compare(vendedorParcela1.GetValorOriginal()); + if (diferencas.Count > 0) + { + Diferenca diferenca = new Diferenca(); + diferenca.set_Campo("Vendedor"); + diferenca.set_Descricao("VENDEDOR"); + diferenca.set_ValorAtual(vendedorParcela.get_Vendedor().get_Nome()); + diferenca.set_ValorAnterior(vendedorParcela.get_Vendedor().get_Nome()); + diferencas.Insert(0, diferenca); + registroLogs.Add(base.CreateLog(parcela.get_Id(), diferencas, 37)); + } + }); + parcela.set_Vendedores(vendedores); + Parcela parcela1 = parcelas2.FirstOrDefault((Parcela pa) => parcela.get_Id() == pa.get_Id()); + if (parcela1 == null) + { + return; + } + List diferencas1 = parcela.Compare(parcela1.GetValorOriginal()); + if (diferencas1.Count > 0) + { + Diferenca diferenca1 = new Diferenca(); + diferenca1.set_Campo("Parcela"); + diferenca1.set_Descricao("PARCELA"); + int numeroParcela = parcela.get_NumeroParcela(); + diferenca1.set_ValorAtual(numeroParcela.ToString()); + numeroParcela = parcela.get_NumeroParcela(); + diferenca1.set_ValorAnterior(numeroParcela.ToString()); + diferencas1.Insert(0, diferenca1); + registroLogs.Add(base.CreateLog(documento.get_Id(), diferencas1, 5)); + } + }); + } + } + documento.set_Controle(commited.get_ControleRepository().Merge(controle)); + } + else + { + controle = (documento.get_Tipo() <= 0 || controle.get_Id() <= (long)0 ? commited.get_ControleRepository().SaveOrUpdate(controle) : controle); + documento.set_Controle(controle); + documento = commited.get_DocumentoRepository().SaveOrUpdate(documento); + registroLogs.Add(base.CreateLog(documento.get_Id(), documento.GetValorOriginal(), 2, 0)); + if (parcelas != null) + { + parcelas.ToList().ForEach((Parcela p) => { + Parcela parcela = p; + ObservableCollection vendedores = parcela.get_Vendedores(); + parcela.set_Documento(documento); + parcela.set_IdEmpresa(documento.get_Controle().get_IdEmpresa()); + parcela = commited.get_ParcelaRepository().SaveOrUpdate(parcela); + registroLogs.Add(base.CreateLog(documento.get_Id(), parcela.GetValorOriginal(), 5, 0)); + vendedores.ToList().ForEach((VendedorParcela v) => { + v.set_Documento(documento); + v.set_Parcela(parcela); + if (v.get_Repasse() != null) + { + BaseRepasse? @base = v.get_Repasse().get_Base(); + if (@base.HasValue) + { + switch (@base.GetValueOrDefault()) + { + case 1: + { + v.set_DataPrePagamento(new DateTime?(documento.get_Vigencia1())); + break; + } + case 2: + { + v.set_DataPrePagamento(new DateTime?(networkTime)); + break; + } + case 3: + { + v.set_DataPrePagamento(new DateTime?(parcela.get_Vencimento())); + break; + } + case 4: + { + v.set_DataPrePagamento(documento.get_Emissao()); + break; + } + case 5: + { + v.set_DataPrePagamento(documento.get_Remessa()); + break; + } + } + } + } + v = commited.get_VendedorParcelaRepository().SaveOrUpdate(v); + registroLogs.Add(base.CreateLog(parcela.get_Id(), v.GetValorOriginal(), 37, 0)); + }); + parcela.set_Vendedores(vendedores); + }); + } + } + documento.set_Parcelas(parcelas); + base.SaveLog(registroLogs, commited); + commited.Commit(); + documento3 = documento; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 18, num, new { documentoOriginal = documento1, updateParcelas = updateParcelas, criarParcelas = criarParcelas }, true); + continue; + } + return documento3; + } + return documento1; + }); + return documento2; + } + + public async Task Save(long id, string observacao) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + string str1 = await Task.Run(() => { + string str; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Documento documento = commited.get_DocumentoRepository().FindById(id, false, false); + documento.Initialize(); + documento.set_Observacao(observacao); + registroLogs.Add(base.CreateLog(documento.get_Id(), documento, 2)); + commited.get_DocumentoRepository().Merge(documento); + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + str = observacao; + } + catch (Exception exception) + { + num = base.Registrar(exception, 18, num, new { id = id, observacao = observacao }, true); + continue; + } + return str; + } + return ""; + }); + return str1; + } + + public async Task UpdateRange(Controle controle) + { + int num = 3; + Controle controle1 = controle; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + controle1 = commited.get_ControleRepository().Merge(controle1); + controle1.get_Documentos().ToList().ForEach((Documento x) => x = commited.get_DocumentoRepository().Merge(x)); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 19, num, controle, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs new file mode 100644 index 0000000..bec5089 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs @@ -0,0 +1,78 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using System; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Seguros +{ + internal class AtividadeServico : BaseServico + { + public AtividadeServico() + { + } + + public async Task FindLastId() + { + int num1 = 3; + long num2 = await Task.Run(() => { + long num; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + num = read.get_AtividadeRepository().FindLastId(); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 17, num1, null, true); + continue; + } + return num; + } + return (long)0; + }); + return num2; + } + + public async Task Save(Atividade atividade) + { + int num = 3; + base.Sucesso = true; + Atividade atividade1 = atividade; + Atividade atividade2 = await Task.Run(() => { + Atividade atividade3; + while (num > 0) + { + atividade = atividade1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + atividade = (atividade.get_Id() == (long)0 ? commited.get_AtividadeRepository().SaveOrUpdate(atividade) : commited.get_AtividadeRepository().Merge(atividade)); + commited.Commit(); + atividade3 = atividade; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 211, num, atividade, true); + continue; + } + return atividade3; + } + return atividade1; + }); + return atividade2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs new file mode 100644 index 0000000..db5c9d2 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs @@ -0,0 +1,1194 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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.Relatorios.Classificacao; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Relatorios.Dashboard; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Seguros +{ + internal class ClienteServico : BaseServico + { + public ClienteServico() + { + } + + public async Task AddCentralSegurado(long id, bool update = true) + { + await Task.Run(() => { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ClienteRepository().AddCentralSegurado(id, update); + } + }); + } + + public async Task> BuscarAniversariantes(Filtros filtro) + { + int num = 3; + List clientesAtivosInativos1 = await Task.Run>(() => { + List clientesAtivosInativos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientesAtivosInativos = read.get_ClienteRepository().BuscarAniversariantes(filtro, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 41, num, null, true); + continue; + } + return clientesAtivosInativos; + } + return new List(); + }); + return clientesAtivosInativos1; + } + + public async Task> BuscarAniversariantesVinculo(Filtros filtro, List vinculo) + { + int num = 3; + List clientesAtivosInativos1 = await Task.Run>(() => { + List clientesAtivosInativos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientesAtivosInativos = read.get_ClienteRepository().BuscarAniversariantesVinculo(filtro, vinculo, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 41, num, null, true); + continue; + } + return clientesAtivosInativos; + } + return new List(); + }); + return clientesAtivosInativos1; + } + + public async Task> BuscarClassificacoes() + { + int num = 3; + List classificacaos1 = await Task.Run>(async () => { + List classificacaos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + classificacaos = await read.get_ClienteRepository().BuscarClassificacoes((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + return classificacaos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 286, num, null, true); + } + if (num <= 0) + { + break; + } + } + classificacaos = new List(); + return classificacaos; + }); + return classificacaos1; + } + + internal async Task> BuscarCliente(string value, List vinculos = null, TipoFiltroCliente tipoFiltroCliente = 2) + { + List clientes1; + string str = value; + str = ValidationHelper.RemoverAcentos(str.Trim()); + if (!string.IsNullOrWhiteSpace(str)) + { + int num1 = 3; + clientes1 = await Task.Run>(() => { + List list; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + long num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + List produtos = LicenseHelper.Produtos; + Func u003cu003e9_01 = ClienteServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (Licenca x) => { + if (x.get_Produto() != 86) + { + return false; + } + return x.get_Status() != 3; + }; + ClienteServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + bool flag = produtos.Any(u003cu003e9_01); + List clientes = read.get_ClienteRepository().FindClienteVinculo(str, vinculos, num, Recursos.Usuario.get_Id() == (long)0, flag, tipoFiltroCliente); + Func u003cu003e9_02 = ClienteServico.u003cu003ec.u003cu003e9__0_2; + if (u003cu003e9_02 == null) + { + u003cu003e9_02 = (Cliente x) => x.get_Nome(); + ClienteServico.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02; + } + list = clientes.OrderBy(u003cu003e9_02).ToList(); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 29, num1, str, true); + continue; + } + return list; + } + return new List(); + }); + } + else + { + clientes1 = new List(); + } + return clientes1; + } + + internal async Task BuscarCliente(long id) + { + int num = 3; + Cliente cliente2 = await Task.Run(() => { + Cliente cliente; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + Cliente cliente1 = read.get_ClienteRepository().FindById(id); + cliente1.set_Nome(cliente1.get_Nome()); + cliente = cliente1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 28, num, id, true); + continue; + } + return cliente; + } + return new Cliente(); + }); + return cliente2; + } + + public async Task BuscarClienteAsync(long id) + { + int num = 3; + Cliente cliente2 = await Task.Run(() => { + Cliente cliente; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + Cliente cliente1 = read.get_ClienteRepository().FindById(id); + cliente1.set_Nome(cliente1.get_Nome()); + cliente = cliente1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 27, num, null, true); + continue; + } + return cliente; + } + return new Cliente(); + }); + return cliente2; + } + + internal async Task> BuscarClientePorDocumento(string documento) + { + List clientes1; + string upper = documento; + upper = ValidationHelper.RemoverAcentos(upper.Trim()).ToUpper(); + if (!string.IsNullOrWhiteSpace(upper)) + { + int num = 3; + clientes1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List clientes = read.get_ClienteRepository().FindClienteDocumento(upper); + Func u003cu003e9_11 = ClienteServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (Cliente c) => c.get_Nome(); + ClienteServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + list = clientes.OrderBy(u003cu003e9_11).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 29, num, upper, true); + continue; + } + return list; + } + return new List(); + }); + } + else + { + clientes1 = new List(); + } + return clientes1; + } + + public async Task> BuscarClientesAtvosInativos(bool completo) + { + int num = 3; + IEnumerable clientesAtivosInativos1 = await Task.Run>(async () => { + IEnumerable clientesAtivosInativos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientesAtivosInativos = await read.get_ClienteRepository().BuscaClientes(completo, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + return clientesAtivosInativos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 286, num, null, true); + } + if (num <= 0) + { + break; + } + } + clientesAtivosInativos = new List(); + return clientesAtivosInativos; + }); + return clientesAtivosInativos1; + } + + public async Task> BuscarClientesAtvosInativosVinculo(bool completo, List vinculo) + { + int num = 3; + IEnumerable clientesAtivosInativos1 = await Task.Run>(async () => { + IEnumerable clientesAtivosInativos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientesAtivosInativos = await read.get_ClienteRepository().BuscaClientesVinculo(completo, vinculo, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + return clientesAtivosInativos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 286, num, null, true); + } + if (num <= 0) + { + break; + } + } + clientesAtivosInativos = new List(); + return clientesAtivosInativos; + }); + return clientesAtivosInativos1; + } + + internal async Task> BuscarClienteVinculo(string value, long id) + { + List clientes1; + if (!string.IsNullOrWhiteSpace(value)) + { + int num = 3; + clientes1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List clientes = read.get_ClienteRepository().FindVinculo(value, id); + Func u003cu003e9_21 = ClienteServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (Cliente x) => x.get_Nome(); + ClienteServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + list = clientes.OrderBy(u003cu003e9_21).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 29, num, value, true); + continue; + } + return list; + } + return new List(); + }); + } + else + { + clientes1 = new List(); + } + return clientes1; + } + + internal async Task> BuscarContatosAsync(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_MaisContatoRepository().FindByCustomerId(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 35, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarEmailsAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List clienteEmails = read.get_ClienteEmailRepository().FindByClienteId(id); + Func u003cu003e9_71 = ClienteServico.u003cu003ec.u003cu003e9__7_1; + if (u003cu003e9_71 == null) + { + u003cu003e9_71 = (ClienteEmail mail) => mail.get_Ordem(); + ClienteServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71; + } + observableCollection = new ObservableCollection(clienteEmails.OrderBy(u003cu003e9_71)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 32, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarEmailsPorCliente(List ids) + { + int num = 3; + List clienteEmails1 = await Task.Run>(() => { + List clienteEmails; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clienteEmails = read.get_ClienteEmailRepository().FindByCliente(ids); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 37, num, null, true); + continue; + } + return clienteEmails; + } + return new List(); + }); + return clienteEmails1; + } + + internal async Task> BuscarEnderecosAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List clienteEnderecos = read.get_ClienteEnderecoRepository().FindByClienteId(id); + Func u003cu003e9_91 = ClienteServico.u003cu003ec.u003cu003e9__9_1; + if (u003cu003e9_91 == null) + { + u003cu003e9_91 = (ClienteEndereco x) => x.get_Ordem(); + ClienteServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91; + } + observableCollection = new ObservableCollection(clienteEnderecos.OrderBy(u003cu003e9_91)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 34, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarEnderecosPorCliente(List clientes) + { + List clienteEnderecos1; + int num = 3; + List clientes1 = clientes; + if (!clientes1.All((Cliente x) => x.get_Id() < (long)0)) + { + clienteEnderecos1 = await Task.Run>(() => { + List clienteEnderecos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clienteEnderecos = read.get_ClienteEnderecoRepository().FindByCliente(clientes); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 38, num, null, true); + continue; + } + return clienteEnderecos; + } + return new List(); + }); + } + else + { + clienteEnderecos1 = new List(); + } + return clienteEnderecos1; + } + + public async Task BuscarLogAntigo(long id) + { + int num = 3; + string str1 = await Task.Run(() => { + string str; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + str = read.get_ClienteRepository().BuscarLogAntigo(id, Connection.GetConnectionString()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 319, num, id, true); + continue; + } + return str; + } + return null; + }); + return str1; + } + + internal DateTime? BuscarNascimento(long id) + { + DateTime? nullable; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + nullable = read.get_ClienteRepository().BuscaNascimeto(id); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = base.Registrar(exception, 328, num, id, true); + continue; + } + return nullable; + } + return null; + } + + public async Task> BuscarObsCliente(string pesquisa) + { + int num = 3; + List clientes1 = await Task.Run>(() => { + List clientes; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientes = read.get_ClienteRepository().FindObsCliente(pesquisa, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 39, num, null, true); + continue; + } + return clientes; + } + return new List(); + }); + return clientes1; + } + + public async Task> BuscarOrigens(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_ClienteRepository().BuscarOrigem(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 326, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarPastaCliente(string pesquisa, bool busca) + { + int num = 3; + List clientes1 = await Task.Run>(() => { + List clientes; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientes = read.get_ClienteRepository().FindPastaCliente(pesquisa, busca, (long)0); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 40, num, null, true); + continue; + } + return clientes; + } + return new List(); + }); + return clientes1; + } + + public async Task> BuscarProspect(Filtros filtro) + { + int num = 3; + List prospectars1 = await Task.Run>(async () => { + List prospectars; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + prospectars = await read.get_ClienteRepository().BuscaProspeccoes(filtro, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + return prospectars; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 324, num, null, true); + } + if (num <= 0) + { + break; + } + } + prospectars = new List(); + return prospectars; + }); + return prospectars1; + } + + internal ObservableCollection BuscarTelefones(long id) + { + ObservableCollection observableCollection; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection( + from x in read.get_ClienteTelefoneRepository().FindByClienteId(id) + orderby x.get_Ordem() + select x); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = base.Registrar(exception, 30, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + } + + 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 clienteTelefones = read.get_ClienteTelefoneRepository().FindByClienteId(id); + Func u003cu003e9_41 = ClienteServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (ClienteTelefone x) => x.get_Ordem(); + ClienteServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + observableCollection = new ObservableCollection(clienteTelefones.OrderBy(u003cu003e9_41)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 30, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarTelefonesClientes(string telefone) + { + int num = 3; + List clienteTelefones1 = await Task.Run>(() => { + List clienteTelefones; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clienteTelefones = read.get_ClienteTelefoneRepository().Find(telefone, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 31, num, telefone, true); + continue; + } + return clienteTelefones; + } + return new List(); + }); + return clienteTelefones1; + } + + public async Task> BuscarTodosClientes() + { + int num = 3; + List clientesAtivosInativos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List clientesAtivosInativos = read.get_ClienteRepository().FindAllClientes(false, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_141 = ClienteServico.u003cu003ec.u003cu003e9__14_1; + if (u003cu003e9_141 == null) + { + u003cu003e9_141 = (ClientesAtivosInativos x) => x.get_Nome(); + ClienteServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141; + } + list = clientesAtivosInativos.OrderBy(u003cu003e9_141).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 36, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return clientesAtivosInativos1; + } + + public async Task> BuscarVencimentosCnh(Filtros filtro) + { + int num = 3; + List clientesAtivosInativos1 = await Task.Run>(() => { + List clientesAtivosInativos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clientesAtivosInativos = read.get_ClienteRepository().BuscarVencimentoCnh(filtro, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 42, num, null, true); + continue; + } + return clientesAtivosInativos; + } + return new List(); + }); + return clientesAtivosInativos1; + } + + internal async Task> BuscarVinculosAsync(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_ClienteVinculoRepository().FindByCliente(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 33, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task Delete(Cliente cliente) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(cliente.get_Id(), cliente.GetValorOriginal(), 1, 2)); + commited.get_ClienteRepository().Merge(cliente); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 172, num, cliente, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task SalvarObservacoes(long id, string observacao) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + string str1 = await Task.Run(() => { + string str; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Cliente cliente = commited.get_ClienteRepository().FindById(id); + cliente.Initialize(); + cliente.set_Observacao(observacao); + registroLogs.Add(base.CreateLog(cliente.get_Id(), cliente, 1)); + commited.get_ClienteRepository().Merge(cliente); + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + str = observacao; + } + catch (Exception exception) + { + num = base.Registrar(exception, 171, num, new { id = id, observacao = observacao }, true); + continue; + } + return str; + } + return ""; + }); + return str1; + } + + public async Task Save(Cliente cliente, bool salvando = false) + { + int num = 3; + base.Sucesso = true; + Cliente cliente1 = cliente; + Cliente cliente2 = await Task.Run(() => { + Cliente cliente3; + List list; + List clienteEnderecos; + List maisContatos; + List clienteEmails; + List clienteVinculos; + while (num > 0) + { + List registroLogs = new List(); + cliente = cliente1; + try + { + TipoAcao tipoAcao = (cliente.get_Id() == 0 ? 0 : 1); + ObservableCollection telefones = cliente.get_Telefones(); + if (telefones != null) + { + list = telefones.ToList(); + } + else + { + list = null; + } + List clienteTelefones = list; + ObservableCollection enderecos = cliente.get_Enderecos(); + if (enderecos != null) + { + clienteEnderecos = enderecos.ToList(); + } + else + { + clienteEnderecos = null; + } + List clienteEnderecos1 = clienteEnderecos; + ObservableCollection contatos = cliente.get_Contatos(); + if (contatos != null) + { + maisContatos = contatos.ToList(); + } + else + { + maisContatos = null; + } + List maisContatos1 = maisContatos; + ObservableCollection emails = cliente.get_Emails(); + if (emails != null) + { + clienteEmails = emails.ToList(); + } + else + { + clienteEmails = null; + } + List clienteEmails1 = clienteEmails; + ObservableCollection vinculos = cliente.get_Vinculos(); + if (vinculos != null) + { + clienteVinculos = vinculos.ToList(); + } + else + { + clienteVinculos = null; + } + List clienteVinculos1 = clienteVinculos; + List origens = cliente.get_Origens(); + cliente.set_Telefones(null); + cliente.set_Enderecos(null); + cliente.set_Contatos(null); + cliente.set_Emails(null); + cliente.set_Vinculos(null); + cliente.set_Contatos(null); + cliente.set_Origens(null); + using (UnitOfWork commited = Instancia.Commited) + { + bool id = cliente.get_Id() == (long)0; + if (cliente.get_Id() != (long)0 & salvando) + { + id = true; + tipoAcao = 0; + } + if (tipoAcao == 1) + { + List objs = new List() + { + clienteTelefones, + clienteEnderecos1, + maisContatos1, + clienteEmails1, + clienteVinculos1, + cliente + }; + registroLogs.Add(base.CreateDynamicLog(cliente.get_Id(), objs, 1)); + List clienteTelefones1 = commited.get_ClienteTelefoneRepository().DeleteFone(cliente.get_Id(), clienteTelefones); + if (clienteTelefones1 != null) + { + clienteTelefones1.ForEach((ClienteTelefone fone) => this.logs.Add(base.CreateLog(cliente.get_Id(), fone.GetValorOriginal(), 1, 2))); + } + else + { + } + List clienteEnderecos2 = commited.get_ClienteEnderecoRepository().DeleteEndereco(cliente.get_Id(), clienteEnderecos1); + if (clienteEnderecos2 != null) + { + clienteEnderecos2.ForEach((ClienteEndereco endereco) => this.logs.Add(base.CreateLog(cliente.get_Id(), endereco.GetValorOriginal(), 1, 2))); + } + else + { + } + List maisContatos2 = commited.get_MaisContatoRepository().DeleteContato(cliente.get_Id(), maisContatos1); + if (maisContatos2 != null) + { + maisContatos2.ForEach((MaisContato contato) => this.logs.Add(base.CreateLog(cliente.get_Id(), contato.GetValorOriginal(), 1, 2))); + } + else + { + } + List clienteEmails2 = commited.get_ClienteEmailRepository().DeleteMail(cliente.get_Id(), clienteEmails1); + if (clienteEmails2 != null) + { + clienteEmails2.ForEach((ClienteEmail mail) => this.logs.Add(base.CreateLog(cliente.get_Id(), mail.GetValorOriginal(), 1, 2))); + } + else + { + } + List clienteVinculos2 = commited.get_ClienteVinculoRepository().DeleteVinculo(cliente.get_Id(), clienteVinculos1); + if (clienteVinculos2 != null) + { + clienteVinculos2.ForEach((ClienteVinculo vinculo) => this.logs.Add(base.CreateLog(cliente.get_Id(), vinculo.GetValorOriginal(), 1, 2))); + } + else + { + } + } + if (!id) + { + if (clienteTelefones != null) + { + clienteTelefones = commited.get_ClienteTelefoneRepository().Merge(clienteTelefones, cliente); + } + if (clienteEnderecos1 != null) + { + clienteEnderecos1 = commited.get_ClienteEnderecoRepository().Merge(clienteEnderecos1, cliente); + } + if (maisContatos1 != null) + { + maisContatos1 = commited.get_MaisContatoRepository().Merge(maisContatos1, cliente); + } + if (clienteEmails1 != null) + { + clienteEmails1 = commited.get_ClienteEmailRepository().Merge(clienteEmails1, cliente); + } + if (clienteVinculos1 != null) + { + clienteVinculos1 = commited.get_ClienteVinculoRepository().Merge(clienteVinculos1, cliente); + } + origens = commited.get_ClienteRepository().Sincronize(origens, cliente.get_Id()); + cliente = commited.get_ClienteRepository().Merge(cliente); + } + else + { + cliente = commited.get_ClienteRepository().SaveOrUpdate(cliente); + if (clienteTelefones != null) + { + clienteTelefones = commited.get_ClienteTelefoneRepository().Inserir(clienteTelefones, cliente); + } + if (clienteEnderecos1 != null) + { + clienteEnderecos1 = commited.get_ClienteEnderecoRepository().Inserir(clienteEnderecos1, cliente); + } + if (maisContatos1 != null) + { + maisContatos1 = commited.get_MaisContatoRepository().Inserir(maisContatos1, cliente); + } + if (clienteEmails1 != null) + { + clienteEmails1 = commited.get_ClienteEmailRepository().Inserir(clienteEmails1, cliente); + } + if (clienteVinculos1 != null) + { + clienteVinculos1 = commited.get_ClienteVinculoRepository().Inserir(clienteVinculos1, cliente); + } + if (origens != null) + { + origens.ForEach((OrigemCliente x) => { + x.set_Cliente(cliente); + x = commited.get_ClienteRepository().SaveOrUpdate(x); + }); + } + } + cliente.set_Nome(cliente.get_Nome()); + cliente.set_Telefones((clienteTelefones == null ? null : new ObservableCollection(clienteTelefones))); + cliente.set_Enderecos((clienteEnderecos1 == null ? null : new ObservableCollection(clienteEnderecos1))); + cliente.set_Contatos((maisContatos1 == null ? null : new ObservableCollection(maisContatos1))); + cliente.set_Emails((clienteEmails1 == null ? null : new ObservableCollection(clienteEmails1))); + cliente.set_Vinculos((clienteVinculos1 == null ? null : new ObservableCollection(clienteVinculos1))); + cliente.set_Origens(origens); + if (tipoAcao == null) + { + registroLogs.Add(base.CreateLog(cliente.get_Id(), cliente.GetValorOriginal(), 1, 0)); + ObservableCollection observableCollection = cliente.get_Telefones(); + if (observableCollection != null) + { + observableCollection.ToList().ForEach((ClienteTelefone fone) => this.logs.Add(base.CreateLog(cliente.get_Id(), fone.GetValorOriginal(), 1, 0))); + } + else + { + } + ObservableCollection enderecos1 = cliente.get_Enderecos(); + if (enderecos1 != null) + { + enderecos1.ToList().ForEach((ClienteEndereco endereco) => this.logs.Add(base.CreateLog(cliente.get_Id(), endereco.GetValorOriginal(), 1, 0))); + } + else + { + } + ObservableCollection contatos1 = cliente.get_Contatos(); + if (contatos1 != null) + { + contatos1.ToList().ForEach((MaisContato contato) => this.logs.Add(base.CreateLog(cliente.get_Id(), contato.GetValorOriginal(), 1, 0))); + } + else + { + } + ObservableCollection emails1 = cliente.get_Emails(); + if (emails1 != null) + { + emails1.ToList().ForEach((ClienteEmail mail) => this.logs.Add(base.CreateLog(cliente.get_Id(), mail.GetValorOriginal(), 1, 0))); + } + else + { + } + ObservableCollection vinculos1 = cliente.get_Vinculos(); + if (vinculos1 != null) + { + vinculos1.ToList().ForEach((ClienteVinculo vinculo) => this.logs.Add(base.CreateLog(cliente.get_Id(), vinculo.GetValorOriginal(), 1, 0))); + } + else + { + } + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + cliente3 = cliente; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 171, num, cliente, true); + continue; + } + return cliente3; + } + return cliente1; + }); + return cliente2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs new file mode 100644 index 0000000..67d9e1f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs @@ -0,0 +1,321 @@ +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.Configuracoes; +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 CriticaApoliceServico : BaseServico + { + private bool _carregando; + + public CriticaApoliceServico() + { + } + + internal async Task BuscarCliente(long id) + { + int num = 3; + Cliente cliente1 = await Task.Run(() => { + Cliente cliente; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + cliente = read.get_ClienteRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 27, num, id, true); + continue; + } + return cliente; + } + return new Cliente(); + }); + return cliente1; + } + + public async Task> BuscarCritica(long usuario, DateTime inicio, DateTime fim, long id = 0L, bool criticado = false, List vinculos = null) + { + List criticaApolices1; + if (!this._carregando) + { + int num3 = 3; + criticaApolices1 = await Task.Run>(() => { + List criticaApolices; + long num; + while (num3 > 0) + { + try + { + this._carregando = true; + using (UnitOfWork read = Instancia.Read) + { + id = read.get_VendedorRepository().FindCorretora().get_Id(); + ICriticaApoliceRepository criticaApoliceRepository = read.get_CriticaApoliceRepository(); + long num1 = usuario; + DateTime dateTime = inicio; + DateTime dateTime1 = fim; + long num2 = id; + bool flag = criticado; + num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + List vendedorUsuarios = vinculos; + List configuracoes = Recursos.Configuracoes; + Func u003cu003e9_21 = CriticaApoliceServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (ConfiguracaoSistema x) => x.get_Configuracao() == 43; + CriticaApoliceServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + bool flag1 = configuracoes.Any(u003cu003e9_21); + List configuracaoSistemas = Recursos.Configuracoes; + Func u003cu003e9_22 = CriticaApoliceServico.u003cu003ec.u003cu003e9__2_2; + if (u003cu003e9_22 == null) + { + u003cu003e9_22 = (ConfiguracaoSistema x) => x.get_Configuracao() == 38; + CriticaApoliceServico.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22; + } + this._carregando = false; + criticaApolices = criticaApoliceRepository.Find(num1, dateTime, dateTime1, num2, flag, num, vendedorUsuarios, flag1, configuracaoSistemas.Any(u003cu003e9_22)); + } + } + catch (Exception exception) + { + num3 = base.Registrar(exception, 43, num3, new { usuario = usuario, inicio = inicio, fim = fim, criticado = criticado }, true); + continue; + } + return criticaApolices; + } + this._carregando = false; + return new List(); + }); + } + else + { + criticaApolices1 = new List(); + } + return criticaApolices1; + } + + public async Task> BuscarCritica(DateTime inicio, DateTime fim) + { + int num = 3; + List criticaApolices1 = await Task.Run>(() => { + List criticaApolices; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + criticaApolices = read.get_CriticaApoliceRepository().Find(inicio, fim, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 43, num, new { inicio = inicio, fim = fim }, true); + continue; + } + return criticaApolices; + } + return new List(); + }); + return criticaApolices1; + } + + public async Task> BuscarCritica(long id) + { + int num = 3; + List criticaApolices1 = await Task.Run>(() => { + List criticaApolices; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + criticaApolices = read.get_CriticaApoliceRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 44, num, id, true); + continue; + } + return criticaApolices; + } + return new List(); + }); + return criticaApolices1; + } + + public async Task> BuscarImportacao(long id) + { + int num = 3; + List criticaApolices1 = await Task.Run>(() => { + List criticaApolices; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + criticaApolices = read.get_CriticaApoliceRepository().FindImport(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 45, num, id, true); + continue; + } + return criticaApolices; + } + return new List(); + }); + return criticaApolices1; + } + + public async Task> BuscarSeguroCombinado(long id, DateTime vigencia) + { + int num = 3; + List criticaApolices1 = await Task.Run>(() => { + List criticaApolices; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + criticaApolices = read.get_CriticaApoliceRepository().FindDuo(id, vigencia); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 44, num, id, true); + continue; + } + return criticaApolices; + } + return new List(); + }); + return criticaApolices1; + } + + public async Task> BuscarUsuarioCritica(DateTime inicio, DateTime fim, bool criticado = false) + { + int num = 3; + List usuarios1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List usuarios = read.get_CriticaApoliceRepository().BuscarUsuarioCritica(inicio, fim, criticado, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_41 = CriticaApoliceServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (Usuario x) => x.get_Nome(); + CriticaApoliceServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + list = usuarios.OrderBy(u003cu003e9_41).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 43, num, new { inicio = inicio, fim = fim, criticado = criticado }, true); + continue; + } + return list; + } + return new List(); + }); + return usuarios1; + } + + public async Task Save(CriticaApolice critica) + { + int num = 3; + base.Sucesso = true; + CriticaApolice criticaApolouse2 = critica; + CriticaApolice criticaApolouse3 = await Task.Run(() => { + CriticaApolice criticaApolouse; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (criticaApolouse2.get_Id() == 0 ? 0 : 1); + criticaApolouse2 = commited.get_CriticaApoliceRepository().Merge(criticaApolouse2); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + CriticaApolice criticaApolouse1 = criticaApolouse2; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(criticaApolouse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(criticaApolouse2.get_Id()); + registroLog.set_Tela(20); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_81 = CriticaApoliceServico.u003cu003ec.u003cu003e9__8_1; + if (u003cu003e9_81 == null) + { + u003cu003e9_81 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + CriticaApoliceServico.u003cu003ec.u003cu003e9__8_1 = u003cu003e9_81; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_81); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + criticaApolouse = criticaApolouse2; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 173, num, critica, true); + continue; + } + return criticaApolouse; + } + return critica; + }); + return criticaApolouse3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs new file mode 100644 index 0000000..47fb942 --- /dev/null +++ b/Codemerx/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 diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs new file mode 100644 index 0000000..11c0f6f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs @@ -0,0 +1,121 @@ +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.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.Itens +{ + internal class AeronauticoServico : BaseServico + { + public AeronauticoServico() + { + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_Aeronautico() != null && item.get_Aeronautico().get_Id() > (long)0) + { + commited.get_AeronauticoRepository().Delete(item.get_Aeronautico().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + Aeronautico aeronautico = item.get_Aeronautico(); + id = (aeronautico != null ? aeronautico.get_Id() : (long)0); + registroLog.set_EntidadeId(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_11 = AeronauticoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AeronauticoServico.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(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 203, num, item, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Aeronautico aeronautico) + { + Aeronautico aeronautico1 = await Task.Run(() => { + Aeronautico aeronautico2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + aeronautico = (aeronautico.get_Id() == 0 ? commited.get_AeronauticoRepository().SaveOrUpdate(aeronautico) : commited.get_AeronauticoRepository().Merge(aeronautico)); + commited.Commit(); + aeronautico2 = aeronautico; + } + } + catch (Exception exception) + { + aeronautico2 = null; + } + return aeronautico2; + }); + return aeronautico1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs new file mode 100644 index 0000000..ba8eb2f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs @@ -0,0 +1,262 @@ +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.Itens +{ + internal class AutoServico : BaseServico + { + public AutoServico() + { + } + + internal async Task BuscarAuto(string value, long id, DateTime vigencia1, DateTime? vigencia2, long idSeguradora) + { + int num = 3; + Documento documento1 = await Task.Run(() => { + Documento documento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documento = read.get_AutoRepository().FindByChassi(value, id, vigencia1, vigencia2, idSeguradora); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 50, num, new { @value = value, id = id }, true); + continue; + } + return documento; + } + return new Documento(); + }); + return documento1; + } + + internal async Task> BuscarChassi(string chassi, FiltroStatusDocumento status, List vendedorVinculado, bool tipobusca = false) + { + List pesquisaAvancadas1 = await Task.Run>(() => { + List pesquisaAvancadas; + try + { + using (UnitOfWork read = Instancia.Read) + { + pesquisaAvancadas = read.get_AutoRepository().FindAuto(chassi, status, vendedorVinculado, 0, tipobusca); + } + } + catch (Exception exception) + { + pesquisaAvancadas = null; + } + return pesquisaAvancadas; + }); + return pesquisaAvancadas1; + } + + public async Task BuscarChassi(long id) + { + string str1 = await Task.Run(() => { + string str; + try + { + using (UnitOfWork read = Instancia.Read) + { + str = read.get_AutoRepository().FindChassi(id); + } + } + catch (Exception exception) + { + str = null; + } + return str; + }); + return str1; + } + + public async Task> BuscarItem(string item, FiltroStatusDocumento status, List vendedorVinculado, bool tipobusca = false) + { + List pesquisaAvancadas1 = await Task.Run>(() => { + List pesquisaAvancadas; + try + { + using (UnitOfWork read = Instancia.Read) + { + pesquisaAvancadas = read.get_AutoRepository().FindAuto(item, status, vendedorVinculado, 6, tipobusca); + } + } + catch (Exception exception) + { + pesquisaAvancadas = null; + } + return pesquisaAvancadas; + }); + return pesquisaAvancadas1; + } + + internal async Task> BuscarPlaca(string placa, FiltroStatusDocumento status, List vendedorVinculado, bool tipobusca = false) + { + List pesquisaAvancadas1 = await Task.Run>(() => { + List pesquisaAvancadas; + try + { + using (UnitOfWork read = Instancia.Read) + { + pesquisaAvancadas = read.get_AutoRepository().FindAuto(placa, status, vendedorVinculado, 14, tipobusca); + } + } + catch (Exception exception) + { + pesquisaAvancadas = null; + } + return pesquisaAvancadas; + }); + return pesquisaAvancadas1; + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_Auto() != null && item.get_Auto().get_Id() > (long)0) + { + commited.get_AutoRepository().Delete(item.get_Auto().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + Auto auto = item.get_Auto(); + id = (auto != null ? auto.get_Id() : (long)0); + registroLog.set_EntidadeId(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 = AutoServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AutoServico.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, 205, num, item, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Auto auto) + { + Auto auto2 = await Task.Run(() => { + Auto auto3; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (auto.get_Id() == 0 ? 0 : 1); + auto = (auto.get_Id() == 0 ? commited.get_AutoRepository().SaveOrUpdate(auto) : commited.get_AutoRepository().Merge(auto)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Auto auto1 = auto; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(auto1, jsonSerializerSetting)); + registroLog.set_EntidadeId(auto.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_11 = AutoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AutoServico.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(); + auto3 = auto; + } + } + catch (Exception exception) + { + auto3 = null; + } + return auto3; + }); + return auto2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs new file mode 100644 index 0000000..2c981c8 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs @@ -0,0 +1,156 @@ +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.Itens +{ + internal class ConsorcioServico : BaseServico + { + public ConsorcioServico() + { + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_Consorcio() != null && item.get_Consorcio().get_Id() > (long)0) + { + commited.get_ConsorcioRepository().Delete(item.get_Consorcio().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + Consorcio consorcio = item.get_Consorcio(); + id = (consorcio != null ? consorcio.get_Id() : (long)0); + registroLog.set_EntidadeId(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_11 = ConsorcioServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConsorcioServico.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(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 332, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Gestor.Model.Domain.Seguros.Consorcio Consorcio) + { + Gestor.Model.Domain.Seguros.Consorcio consorcio2 = await Task.Run(() => { + Gestor.Model.Domain.Seguros.Consorcio consorcio; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (Consorcio.get_Id() == 0 ? 0 : 1); + Consorcio = (Consorcio.get_Id() == 0 ? commited.get_ConsorcioRepository().SaveOrUpdate(Consorcio) : commited.get_ConsorcioRepository().Merge(Consorcio)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Gestor.Model.Domain.Seguros.Consorcio consorcio1 = Consorcio; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(consorcio1, jsonSerializerSetting)); + registroLog.set_EntidadeId(Consorcio.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_01 = ConsorcioServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConsorcioServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_01); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + consorcio = Consorcio; + } + } + catch (Exception exception) + { + consorcio = null; + } + return consorcio; + }); + return consorcio2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs new file mode 100644 index 0000000..054685c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs @@ -0,0 +1,156 @@ +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.Itens +{ + internal class GranizoServico : BaseServico + { + public GranizoServico() + { + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_Granizo() != null && item.get_Granizo().get_Id() > (long)0) + { + commited.get_GranizoRepository().Delete(item.get_Granizo().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + Granizo granizo = item.get_Granizo(); + id = (granizo != null ? granizo.get_Id() : (long)0); + registroLog.set_EntidadeId(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_11 = GranizoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + GranizoServico.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(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 207, num, item, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Granizo granizo) + { + Granizo granizo2 = await Task.Run(() => { + Granizo granizo3; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (granizo.get_Id() == 0 ? 0 : 1); + granizo = (granizo.get_Id() == 0 ? commited.get_GranizoRepository().SaveOrUpdate(granizo) : commited.get_GranizoRepository().Merge(granizo)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Granizo granizo1 = granizo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(granizo1, jsonSerializerSetting)); + registroLog.set_EntidadeId(granizo.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_01 = GranizoServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + GranizoServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_01); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + granizo3 = granizo; + } + } + catch (Exception exception) + { + granizo3 = null; + } + return granizo3; + }); + return granizo2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs new file mode 100644 index 0000000..a666367 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs @@ -0,0 +1,1900 @@ +using Agger.Registro; +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.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Seguros.Itens +{ + public class ItemServico : BaseServico + { + private const string GuidGestorFipe = "bbbf4f03-01fc-4300-b430-33e007753578"; + + public ItemServico() + { + } + + public async Task BuscaAeronautico(long id) + { + int num = 3; + Aeronautico aeronautico1 = await Task.Run(() => { + Aeronautico aeronautico; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + aeronautico = read.get_AeronauticoRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 63, num, id, true); + continue; + } + return aeronautico; + } + return new Aeronautico(); + }); + return aeronautico1; + } + + internal async Task BuscaAuto(long id) + { + int num = 3; + Auto auto1 = await Task.Run(() => { + Auto auto; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + auto = read.get_AutoRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 55, num, id, true); + continue; + } + return auto; + } + return new Auto(); + }); + return auto1; + } + + public async Task BuscaConsorcio(long id) + { + int num = 3; + Consorcio consorcio1 = await Task.Run(() => { + Consorcio consorcio; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + consorcio = read.get_ConsorcioRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 330, num, id, true); + continue; + } + return consorcio; + } + return new Consorcio(); + }); + return consorcio1; + } + + internal async Task BuscaGranizo(long id) + { + int num = 3; + Granizo granizo1 = await Task.Run(() => { + Granizo granizo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + granizo = read.get_GranizoRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 56, num, id, true); + continue; + } + return granizo; + } + return new Granizo(); + }); + return granizo1; + } + + internal async Task> BuscaItensPorObs(string observacao, FiltroStatusDocumento status, List vendedorVinculado, bool tipobusca = false) + { + List pesquisaAvancadas1 = await Task.Run>(async () => { + List pesquisaAvancadas; + try + { + using (UnitOfWork read = Instancia.Read) + { + pesquisaAvancadas = await read.get_ItemRepository().BuscaItensPorObs(observacao, status, vendedorVinculado, 18, tipobusca); + } + } + catch (Exception exception) + { + pesquisaAvancadas = null; + } + return pesquisaAvancadas; + }); + return pesquisaAvancadas1; + } + + public async Task BuscaPatrimonial(long id) + { + int num = 3; + Patrimonial patrimonial1 = await Task.Run(() => { + Patrimonial patrimonial; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + patrimonial = read.get_PatrimonialRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 59, num, id, true); + continue; + } + return patrimonial; + } + return new Patrimonial(); + }); + return patrimonial1; + } + + public async Task BuscarCliente(long id) + { + int num = 3; + Cliente cliente1 = await Task.Run(() => { + Cliente cliente; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + cliente = read.get_ItemRepository().BuscarCliente(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 27, num, id, true); + continue; + } + return cliente; + } + return new Cliente(); + }); + return cliente1; + } + + internal async Task> BuscarCoberturasPorItemAsync(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_CoberturaRepository().FindByItemId(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 57, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task BuscaRiscosDiversos(long id) + { + int num = 3; + RiscosDiversos riscosDiverso1 = await Task.Run(() => { + RiscosDiversos riscosDiverso; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + riscosDiverso = read.get_RiscosDiversosRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 62, num, id, true); + continue; + } + return riscosDiverso; + } + return new RiscosDiversos(); + }); + return riscosDiverso1; + } + + internal async Task BuscarItemPorIdAsync(long id) + { + int num = 3; + Item item1 = await Task.Run(() => { + Item item; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + item = read.get_ItemRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 51, num, id, true); + continue; + } + return item; + } + return new Item(); + }); + return item1; + } + + internal async Task> BuscarItems(long id, StatusItem status = 2, bool sinsitroCompleto = false) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_ItemRepository().FindByDocumentsIds(id, status, sinsitroCompleto)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 52, num, new { id = id, status = status }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarItems(List ids) + { + int num = 3; + List items1 = await Task.Run>(() => { + List items; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + items = read.get_ItemRepository().FindByIds(ids); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 52, num, ids, true); + continue; + } + return items; + } + return new List(); + }); + return items1; + } + + public async Task> BuscarItens(List ids) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List items = read.get_ItemRepository().FindItens(ids); + if (items != null) + { + List items1 = items; + Func u003cu003e9_281 = ItemServico.u003cu003ec.u003cu003e9__28_1; + if (u003cu003e9_281 == null) + { + u003cu003e9_281 = (Item x) => x.get_Ordem(); + ItemServico.u003cu003ec.u003cu003e9__28_1 = u003cu003e9_281; + } + IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_281); + Func u003cu003e9_282 = ItemServico.u003cu003ec.u003cu003e9__28_2; + if (u003cu003e9_282 == null) + { + u003cu003e9_282 = (Item x) => x.get_Descricao(); + ItemServico.u003cu003ec.u003cu003e9__28_2 = u003cu003e9_282; + } + observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_282)); + return observableCollection; + } + } + continue; + } + catch (Exception exception) + { + num = base.Registrar(exception, 52, num, ids, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarItens(long id, StatusItem status) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List items = read.get_ItemRepository().FindItens(id, status); + if (items != null) + { + List items1 = items; + Func u003cu003e9_291 = ItemServico.u003cu003ec.u003cu003e9__29_1; + if (u003cu003e9_291 == null) + { + u003cu003e9_291 = (Item x) => x.get_Ordem(); + ItemServico.u003cu003ec.u003cu003e9__29_1 = u003cu003e9_291; + } + IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_291); + Func u003cu003e9_292 = ItemServico.u003cu003ec.u003cu003e9__29_2; + if (u003cu003e9_292 == null) + { + u003cu003e9_292 = (Item x) => x.get_Descricao(); + ItemServico.u003cu003ec.u003cu003e9__29_2 = u003cu003e9_292; + } + observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_292)); + return observableCollection; + } + } + continue; + } + catch (Exception exception) + { + num = base.Registrar(exception, 53, num, new { id = id, status = status }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarItens(List documento) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List items = read.get_ItemRepository().FindItens(documento); + if (items != null) + { + List items1 = items; + Func u003cu003e9_301 = ItemServico.u003cu003ec.u003cu003e9__30_1; + if (u003cu003e9_301 == null) + { + u003cu003e9_301 = (Item x) => x.get_Ordem(); + ItemServico.u003cu003ec.u003cu003e9__30_1 = u003cu003e9_301; + } + IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_301); + Func u003cu003e9_302 = ItemServico.u003cu003ec.u003cu003e9__30_2; + if (u003cu003e9_302 == null) + { + u003cu003e9_302 = (Item x) => x.get_Descricao(); + ItemServico.u003cu003ec.u003cu003e9__30_2 = u003cu003e9_302; + } + observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_302)); + return observableCollection; + } + } + continue; + } + catch (Exception exception) + { + num = base.Registrar(exception, 305, num, documento, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarItens(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List items = read.get_ItemRepository().FindItens(id); + if (items != null) + { + List items1 = items; + Func u003cu003e9_311 = ItemServico.u003cu003ec.u003cu003e9__31_1; + if (u003cu003e9_311 == null) + { + u003cu003e9_311 = (Item x) => x.get_Ordem(); + ItemServico.u003cu003ec.u003cu003e9__31_1 = u003cu003e9_311; + } + IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_311); + Func u003cu003e9_312 = ItemServico.u003cu003ec.u003cu003e9__31_2; + if (u003cu003e9_312 == null) + { + u003cu003e9_312 = (Item x) => x.get_Descricao(); + ItemServico.u003cu003ec.u003cu003e9__31_2 = u003cu003e9_312; + } + observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_312)); + return observableCollection; + } + } + continue; + } + catch (Exception exception) + { + num = base.Registrar(exception, 53, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task BuscarModelo(string fipe) + { + Fipe fipe1; + try + { + fipe1 = await this.FipeCode(fipe); + } + catch (Exception exception) + { + fipe1 = null; + } + return fipe1; + } + + public async Task> BuscarPorModelo(string modelo) + { + List fipes; + try + { + fipes = await this.FipeModel(modelo); + } + catch (Exception exception) + { + fipes = null; + } + return fipes; + } + + public async Task BuscarProximoItem(long id) + { + int num1 = 3; + int num2 = await Task.Run(() => { + int num; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + num = read.get_ItemRepository().FindNextItem(id); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 54, num1, id, true); + continue; + } + return num; + } + return 0; + }); + return num2; + } + + public async Task> BuscaTitularesVida(long id) + { + int num = 3; + List titularesVidas1 = await Task.Run>(() => { + List titularesVidas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + titularesVidas = read.get_TitularesVidaRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 61, num, id, true); + continue; + } + return titularesVidas; + } + return new List(); + }); + return titularesVidas1; + } + + public async Task BuscaVida(long id) + { + int num = 3; + Vida vida1 = await Task.Run(() => { + Vida vida; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vida = read.get_VidaRepository().Find(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 60, num, id, true); + continue; + } + return vida; + } + return new Vida(); + }); + return vida1; + } + + public async Task Cancelar(Item item, string descricao, long idDocumento) + { + Item item1 = await Task.Run(() => { + Item item2; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + item = commited.get_ItemRepository().FindById(item.get_Id()); + item.set_Cancelado(true); + item.set_Status(descricao); + item.set_IdDocumentoCancelado(new long?(idDocumento)); + item = commited.get_ItemRepository().Merge(item); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} CANCELOU, EM {1}, O ITEM DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); + strArrays[4] = "', OBSERVAÇÃO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); + strArrays[6] = "', STATUS: '"; + strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); + strArrays[8] = "' - "; + strArrays[9] = descricao; + strArrays[10] = "."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(item.get_Id()); + registroLog.set_Tela(3); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_201 = ItemServico.u003cu003ec.u003cu003e9__20_1; + if (u003cu003e9_201 == null) + { + u003cu003e9_201 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__20_1 = u003cu003e9_201; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_201); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + item2 = item; + } + } + catch (Exception exception) + { + item2 = null; + } + return item2; + }); + return item1; + } + + public async Task ChecarQuantidade(long idDocumento) + { + int num1 = await Task.Run(() => { + int num; + try + { + using (UnitOfWork read = Instancia.Read) + { + num = read.get_ItemRepository().ChecarQuantidade(idDocumento); + } + } + catch + { + num = 0; + } + return num; + }); + return num1; + } + + public async Task Delete(Item item) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + await Task.Run(() => { + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().Delete(item.get_Id()); + commited.get_ItemRepository().Delete(item.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} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); + strArrays[4] = "', OBSERVAÇÃO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); + strArrays[6] = "', STATUS: '"; + strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); + strArrays[8] = "'."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(item.get_Id()); + registroLog.set_Tela(3); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_241 = ItemServico.u003cu003ec.u003cu003e9__24_1; + if (u003cu003e9_241 == null) + { + u003cu003e9_241 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__24_1 = u003cu003e9_241; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_241); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 274, num, item, true); + } + } + }); + } + + public async Task DeleteRange(List itens, long ramo) + { + if (itens != null && itens.Count != 0) + { + int num2 = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + await Task.Run(() => { + TipoTela tipoTela; + string str; + while (num2 > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ICoberturaRepository coberturaRepository = commited.get_CoberturaRepository(); + List items = itens; + Func u003cu003e9_251 = ItemServico.u003cu003ec.u003cu003e9__25_1; + if (u003cu003e9_251 == null) + { + u003cu003e9_251 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_1 = u003cu003e9_251; + } + coberturaRepository.DeleteRange(items.Select(u003cu003e9_251).ToList()); + IControleSinistroRepository controleSinistroRepository = commited.get_ControleSinistroRepository(); + List items1 = itens; + Func u003cu003e9_252 = ItemServico.u003cu003ec.u003cu003e9__25_2; + if (u003cu003e9_252 == null) + { + u003cu003e9_252 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_2 = u003cu003e9_252; + } + controleSinistroRepository.DeleteRange(items1.Select(u003cu003e9_252).ToList()); + long num = ramo; + if (num > (long)36) + { + if (num == (long)37) + { + goto Label0; + } + if (num == (long)53) + { + goto Label1; + } + } + else + { + long num1 = num - (long)1; + if (num1 <= (long)19) + { + switch ((uint)num1) + { + case 0: + case 1: + case 2: + case 14: + case 17: + { + IPatrimonialRepository patrimonialRepository = commited.get_PatrimonialRepository(); + List items2 = itens; + Func u003cu003e9_254 = ItemServico.u003cu003ec.u003cu003e9__25_4; + if (u003cu003e9_254 == null) + { + u003cu003e9_254 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_4 = u003cu003e9_254; + } + patrimonialRepository.DeleteRange(items2.Select(u003cu003e9_254).ToList()); + tipoTela = 3; + goto Label2; + } + case 3: + case 7: + case 10: + case 11: + case 13: + case 15: + case 16: + case 18: + { + goto Label3; + } + case 4: + { + goto Label0; + } + case 5: + case 6: + case 8: + case 9: + { + goto Label1; + } + case 12: + { + IAeronauticoRepository aeronauticoRepository = commited.get_AeronauticoRepository(); + List items3 = itens; + Func u003cu003e9_255 = ItemServico.u003cu003ec.u003cu003e9__25_5; + if (u003cu003e9_255 == null) + { + u003cu003e9_255 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_5 = u003cu003e9_255; + } + aeronauticoRepository.DeleteRange(items3.Select(u003cu003e9_255).ToList()); + tipoTela = 3; + goto Label2; + } + case 19: + { + IGranizoRepository granizoRepository = commited.get_GranizoRepository(); + List items4 = itens; + Func u003cu003e9_256 = ItemServico.u003cu003ec.u003cu003e9__25_6; + if (u003cu003e9_256 == null) + { + u003cu003e9_256 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_6 = u003cu003e9_256; + } + granizoRepository.DeleteRange(items4.Select(u003cu003e9_256).ToList()); + tipoTela = 3; + goto Label2; + } + } + } + else + { + } + if (num != (long)36) + { + goto Label3; + } + IConsorcioRepository consorcioRepository = commited.get_ConsorcioRepository(); + List items5 = itens; + Func u003cu003e9_258 = ItemServico.u003cu003ec.u003cu003e9__25_8; + if (u003cu003e9_258 == null) + { + u003cu003e9_258 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_8 = u003cu003e9_258; + } + consorcioRepository.DeleteRange(items5.Select(u003cu003e9_258).ToList()); + tipoTela = 3; + goto Label2; + } + Label3: + IRiscosDiversosRepository riscosDiversosRepository = commited.get_RiscosDiversosRepository(); + List items6 = itens; + Func u003cu003e9_259 = ItemServico.u003cu003ec.u003cu003e9__25_9; + if (u003cu003e9_259 == null) + { + u003cu003e9_259 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_9 = u003cu003e9_259; + } + riscosDiversosRepository.DeleteRange(items6.Select(u003cu003e9_259).ToList()); + tipoTela = 3; + Label2: + IItemRepository itemRepository = commited.get_ItemRepository(); + List items7 = itens; + Func u003cu003e9_2510 = ItemServico.u003cu003ec.u003cu003e9__25_10; + if (u003cu003e9_2510 == null) + { + u003cu003e9_2510 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_10 = u003cu003e9_2510; + } + itemRepository.DeleteRange(items7.Select(u003cu003e9_2510).ToList()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + List.Enumerator enumerator = itens.GetEnumerator(); + try + { + if (enumerator.MoveNext()) + { + Item current = enumerator.Current; + 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} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", current.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(current.get_Descricao()) ? "" : current.get_Descricao() ?? ""); + strArrays[4] = "', OBSERVAÇÃO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(current.get_Observacao()) ? "" : current.get_Observacao() ?? ""); + strArrays[6] = "', STATUS: '"; + strArrays[7] = (string.IsNullOrWhiteSpace(current.get_Status()) ? "" : current.get_Status() ?? ""); + strArrays[8] = "'"; + strArrays[9] = string.Format(", RAMO: '{0}'.", ramo); + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(current.get_Id()); + registroLog.set_Tela(tipoTela); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_2511 = ItemServico.u003cu003ec.u003cu003e9__25_11; + if (u003cu003e9_2511 == null) + { + u003cu003e9_2511 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__25_11 = u003cu003e9_2511; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_2511); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + break; + } + } + finally + { + ((IDisposable)enumerator).Dispose(); + } + } + } + catch (Exception exception) + { + num2 = base.Registrar(exception, 275, num2, itens, true); + } + } + return; + Label0: + IAutoRepository autoRepository = commited.get_AutoRepository(); + List items8 = itens; + Func u003cu003e9_253 = ItemServico.u003cu003ec.u003cu003e9__25_3; + if (u003cu003e9_253 == null) + { + u003cu003e9_253 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_3 = u003cu003e9_253; + } + autoRepository.DeleteRange(items8.Select(u003cu003e9_253).ToList()); + tipoTela = 3; + goto Label2; + Label1: + IVidaRepository vidaRepository = commited.get_VidaRepository(); + List items9 = itens; + Func u003cu003e9_257 = ItemServico.u003cu003ec.u003cu003e9__25_7; + if (u003cu003e9_257 == null) + { + u003cu003e9_257 = (Item x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__25_7 = u003cu003e9_257; + } + vidaRepository.DeleteRange(items9.Select(u003cu003e9_257).ToList()); + tipoTela = 3; + goto Label2; + }); + } + } + + public async Task DeleteTitulares(List titularesVidas) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ITitularesVidaRepository titularesVidaRepository = commited.get_TitularesVidaRepository(); + List titularesVidas1 = titularesVidas; + Func u003cu003e9_331 = ItemServico.u003cu003ec.u003cu003e9__33_1; + if (u003cu003e9_331 == null) + { + u003cu003e9_331 = (TitularesVida x) => x.get_Id(); + ItemServico.u003cu003ec.u003cu003e9__33_1 = u003cu003e9_331; + } + titularesVidaRepository.DeleteRange(titularesVidas1.Select(u003cu003e9_331).ToList()); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 276, num, titularesVidas, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + private async Task FipeAuthentication() + { + string str; + string empty; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string str1 = DateTime.Now.ToString("yyyy-MM-dd"); + string base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}", ApplicationHelper.IdFornecedor, "bbbf4f03-01fc-4300-b430-33e007753578", str1))); + Uri apiFipe = Address.get_ApiFipe(); + string[] strArrays = new string[] { "api" }; + Uri uri = apiFipe.Append(strArrays); + string[] strArrays1 = new string[] { "auth" }; + Uri uri1 = uri.Append(strArrays1); + HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(uri1, base64String.ToHttpContent(null, "application/json")); + if (httpResponseMessage.get_IsSuccessStatusCode()) + { + JToken item = httpResponseMessage.get_Content().ToJObject().get_Item("token"); + if (item != null) + { + empty = item.ToString(); + } + else + { + empty = null; + } + } + else + { + empty = string.Empty; + } + str = empty; + } + return str; + } + + private async Task FipeCode(string code) + { + Fipe fipe; + Fipe fipe1; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string str = await this.FipeAuthentication(); + if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str)) + { + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str)); + } + Uri apiFipe = Address.get_ApiFipe(); + string[] strArrays = new string[] { "v1" }; + Uri uri = apiFipe.Append(strArrays); + string[] strArrays1 = new string[] { "fipe" }; + Uri uri1 = uri.Append(strArrays1).AddQuery("fipeCode", code); + HttpResponseMessage async = await httpClient.GetAsync(uri1); + fipe1 = (!async.get_IsSuccessStatusCode() ? new Fipe() : JsonConvert.DeserializeObject(await async.get_Content().ReadAsStringAsync())); + fipe = fipe1; + } + return fipe; + } + + private async Task> FipeModel(string model) + { + List fipes; + List fipes1; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string str = await this.FipeAuthentication(); + if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str)) + { + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str)); + } + Uri apiFipe = Address.get_ApiFipe(); + string[] strArrays = new string[] { "v1" }; + Uri uri = apiFipe.Append(strArrays); + string[] strArrays1 = new string[] { "fipe" }; + Uri uri1 = uri.Append(strArrays1); + string[] strArrays2 = new string[] { "modelo" }; + Uri uri2 = uri1.Append(strArrays2); + string[] strArrays3 = new string[] { model }; + Uri uri3 = uri2.Append(strArrays3); + HttpResponseMessage async = await httpClient.GetAsync(uri3); + fipes1 = (!async.get_IsSuccessStatusCode() ? new List() : JsonConvert.DeserializeObject>(await async.get_Content().ReadAsStringAsync())); + fipes = fipes1; + } + return fipes; + } + + private static async Task Get(string command) + where T : class + { + Uri uri = new Uri(command); + ConfiguredTaskAwaitable configuredTaskAwaitable = (new HttpClient()).GetAsync(uri).ConfigureAwait(false); + HttpResponseMessage httpResponseMessage = await configuredTaskAwaitable; + if (httpResponseMessage.get_StatusCode() != HttpStatusCode.OK) + { + throw new Exception(string.Concat("Api connection Error ", Environment.NewLine, " ", command), null); + } + T t = JsonConvert.DeserializeObject(httpResponseMessage.get_Content().ReadAsStringAsync().Result); + return t; + } + + public async Task Reativar(Item item, string descricao) + { + Item item1 = await Task.Run(() => { + Item item2; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + item = commited.get_ItemRepository().FindById(item.get_Id()); + item.set_Cancelado(false); + long? nullable = null; + item.set_Substituido(nullable); + nullable = null; + item.set_IdDocumentoCancelado(nullable); + item.set_Status(descricao); + item = commited.get_ItemRepository().Merge(item); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} REATIVOU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); + strArrays[4] = "', OBSERVAÇÃO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); + strArrays[6] = "', STATUS: '"; + strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); + strArrays[8] = "' - "; + strArrays[9] = descricao; + strArrays[10] = "."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(item.get_Id()); + registroLog.set_Tela(3); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_211 = ItemServico.u003cu003ec.u003cu003e9__21_1; + if (u003cu003e9_211 == null) + { + u003cu003e9_211 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_211); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + item2 = item; + } + } + catch (Exception exception) + { + item2 = null; + } + return item2; + }); + return item1; + } + + public async Task Save(Item item) + { + Action action3 = null; + Action action4 = null; + int num3 = 3; + Item item2 = item; + base.Sucesso = true; + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + DateTime networkTime = Funcoes.GetNetworkTime(); + Item item3 = await Task.Run(() => { + bool id; + Auto auto; + Vida vida; + RiscosDiversos riscosDiversos; + Action action; + Item item4; + string str1; + TipoTela tipoTela; + Label5: + while (num3 > 0) + { + item = item2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + id = item.get_Id() == (long)0; + auto = item.get_Auto(); + Patrimonial patrimonial = item.get_Patrimonial(); + Granizo granizo = item.get_Granizo(); + Aeronautico aeronautico = item.get_Aeronautico(); + vida = item.get_Vida(); + riscosDiversos = item.get_RiscosDiversos(); + Consorcio consorcio = item.get_Consorcio(); + tipoTela = 3; + IList coberturas = item.get_Coberturas(); + item.set_StatusInclusao((item.get_Documento().get_Tipo() == 0 ? "ITEM DA APÓLICE" : "ITEM DO ENDOSSO")); + if (id) + { + item.set_Coberturas(null); + } + if (!id && coberturas != null && coberturas.Count > 0) + { + try + { + List list = coberturas.ToList(); + Action u003cu003e9_2 = action3; + if (u003cu003e9_2 == null) + { + Action action1 = (Cobertura x) => x.set_Item(item); + action = action1; + action3 = action1; + u003cu003e9_2 = action; + } + list.ForEach(u003cu003e9_2); + IList coberturas1 = coberturas; + Func u003cu003e9_233 = ItemServico.u003cu003ec.u003cu003e9__23_3; + if (u003cu003e9_233 == null) + { + u003cu003e9_233 = (Cobertura c) => c.get_Id() == (long)0; + ItemServico.u003cu003ec.u003cu003e9__23_3 = u003cu003e9_233; + } + List list1 = coberturas1.Where(u003cu003e9_233).ToList(); + if (list1.Count > 0) + { + list1 = commited.get_CoberturaRepository().AddRange(list1.ToList()); + list1.ForEach((Cobertura c) => { + string str; + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(c, jsonSerializerSetting)); + registroLog.set_EntidadeId(c.get_Id()); + registroLog.set_Tela(tipoTela); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_237 = ItemServico.u003cu003ec.u003cu003e9__23_7; + if (u003cu003e9_237 == null) + { + u003cu003e9_237 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__23_7 = u003cu003e9_237; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_237); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + } + IList coberturas2 = coberturas; + Func u003cu003e9_235 = ItemServico.u003cu003ec.u003cu003e9__23_5; + if (u003cu003e9_235 == null) + { + u003cu003e9_235 = (Cobertura c) => c.get_Id() > (long)0; + ItemServico.u003cu003ec.u003cu003e9__23_5 = u003cu003e9_235; + } + List list2 = coberturas2.Where(u003cu003e9_235).ToList(); + if (list2.Count > 0) + { + list2 = commited.get_CoberturaRepository().MergeRange(list2); + list2.ForEach((Cobertura c) => { + string str; + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(c, jsonSerializerSetting)); + registroLog.set_EntidadeId(c.get_Id()); + registroLog.set_Tela(tipoTela); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_238 = ItemServico.u003cu003ec.u003cu003e9__23_8; + if (u003cu003e9_238 == null) + { + u003cu003e9_238 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__23_8 = u003cu003e9_238; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_238); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + } + list2.AddRange(list1); + item.set_Coberturas(list2); + } + catch (Exception exception) + { + num3 = base.Registrar(exception, 208, num3, coberturas, true); + continue; + } + } + if (!item.get_Documento().get_Sinistro() && item.get_Sinistrado() && item.get_Documento().get_Situacao() == 2 && item.get_Status() != null && !item.get_Status().Contains("ALTERADO")) + { + item.set_Sinistrado(false); + } + item = (id ? commited.get_ItemRepository().SaveOrUpdate(item) : commited.get_ItemRepository().Merge(item)); + long num = item.get_Documento().get_Controle().get_Ramo().get_Id(); + if (num > (long)38) + { + if (num == (long)47 || num == (long)53 || num == (long)66) + { + goto Label0; + } + goto Label1; + } + else + { + long num1 = num - (long)1; + if (num1 <= (long)19) + { + switch ((uint)num1) + { + case 0: + case 1: + case 2: + case 14: + case 17: + { + goto Label3; + } + case 3: + case 7: + case 10: + case 11: + case 13: + case 15: + case 16: + case 18: + { + goto Label1; + } + case 4: + { + goto Label4; + } + case 5: + case 6: + case 8: + case 9: + { + goto Label0; + } + case 12: + { + try + { + if (aeronautico != null) + { + aeronautico.set_Item(item); + aeronautico = (id ? commited.get_AeronauticoRepository().SaveOrUpdate(aeronautico) : commited.get_AeronauticoRepository().Merge(aeronautico)); + item.set_Aeronautico(aeronautico); + tipoTela = 3; + goto Label2; + } + else + { + goto Label2; + } + } + catch (Exception exception1) + { + num3 = base.Registrar(exception1, 202, num3, aeronautico, true); + continue; + } + break; + } + case 19: + { + try + { + if (granizo != null) + { + granizo.set_Item(item); + granizo = (id ? commited.get_GranizoRepository().SaveOrUpdate(granizo) : commited.get_GranizoRepository().Merge(granizo)); + item.set_Granizo(granizo); + tipoTela = 3; + goto Label2; + } + else + { + goto Label2; + } + } + catch (Exception exception2) + { + num3 = base.Registrar(exception2, 206, num3, granizo, true); + continue; + } + break; + } + } + } + else + { + } + if (num != (long)30) + { + long num2 = num - (long)36; + if (num2 <= (long)2) + { + switch ((uint)num2) + { + case 0: + { + try + { + if (consorcio != null) + { + consorcio.set_Item(item); + consorcio = (id ? commited.get_ConsorcioRepository().SaveOrUpdate(consorcio) : commited.get_ConsorcioRepository().Merge(consorcio)); + item.set_Consorcio(consorcio); + tipoTela = 3; + goto Label2; + } + else + { + goto Label2; + } + } + catch (Exception exception3) + { + num3 = base.Registrar(exception3, 331, num3, consorcio, true); + continue; + } + break; + } + case 1: + { + goto Label4; + } + case 2: + { + break; + } + default: + { + goto Label1; + } + } + } + else + { + goto Label1; + } + } + Label3: + try + { + if (patrimonial != null) + { + patrimonial.set_Item(item); + patrimonial = (id ? commited.get_PatrimonialRepository().SaveOrUpdate(patrimonial) : commited.get_PatrimonialRepository().Merge(patrimonial)); + item.set_Patrimonial(patrimonial); + tipoTela = 3; + } + } + catch (Exception exception4) + { + num3 = base.Registrar(exception4, 196, num3, patrimonial, true); + continue; + } + } + Label2: + if (id && coberturas != null && coberturas.Count > 0) + { + try + { + item.set_Coberturas(new List()); + List list3 = coberturas.ToList(); + Action u003cu003e9_1 = action4; + if (u003cu003e9_1 == null) + { + Action action2 = (Cobertura x) => { + x.set_Id((long)0); + x.set_Item(item); + }; + action = action2; + action4 = action2; + u003cu003e9_1 = action; + } + list3.ForEach(u003cu003e9_1); + coberturas = commited.get_CoberturaRepository().AddRange(coberturas.ToList()); + item.set_Coberturas(coberturas); + } + catch (Exception exception5) + { + num3 = base.Registrar(exception5, 208, num3, coberturas, true); + continue; + } + } + TipoAcao tipoAcao = (id ? 0 : 1); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(tipoAcao); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); + jsonSerializerSetting1.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting1)); + registroLog1.set_EntidadeId(item.get_Id()); + registroLog1.set_Tela(tipoTela); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_239 = ItemServico.u003cu003ec.u003cu003e9__23_9; + if (u003cu003e9_239 == null) + { + u003cu003e9_239 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__23_9 = u003cu003e9_239; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_239); + if (pAddress1 != null) + { + str1 = pAddress1.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + base.SaveLog(registroLog1, commited); + commited.Commit(); + item4 = item; + } + } + catch (Exception exception6) + { + num3 = base.Registrar(exception6, 195, num3, item, true); + continue; + } + return item4; + } + return item2; + Label0: + try + { + if (vida != null) + { + vida.set_Item(item); + vida = (id ? commited.get_VidaRepository().SaveOrUpdate(vida) : commited.get_VidaRepository().Merge(vida)); + item.set_Vida(vida); + tipoTela = 3; + goto Label2; + } + else + { + goto Label2; + } + } + catch (Exception exception7) + { + num3 = base.Registrar(exception7, 200, num3, vida, true); + goto Label5; + } + Label1: + try + { + if (riscosDiversos != null) + { + riscosDiversos.set_Item(item); + riscosDiversos = (id ? commited.get_RiscosDiversosRepository().SaveOrUpdate(riscosDiversos) : commited.get_RiscosDiversosRepository().Merge(riscosDiversos)); + item.set_RiscosDiversos(riscosDiversos); + tipoTela = 3; + goto Label2; + } + else + { + goto Label2; + } + } + catch (Exception exception8) + { + num3 = base.Registrar(exception8, 198, num3, riscosDiversos, true); + goto Label5; + } + Label4: + try + { + if (auto != null) + { + auto.set_Item(item); + auto = (id ? commited.get_AutoRepository().SaveOrUpdate(auto) : commited.get_AutoRepository().Merge(auto)); + item.set_Auto(auto); + tipoTela = 3; + goto Label2; + } + else + { + goto Label2; + } + } + catch (Exception exception9) + { + num3 = base.Registrar(exception9, 204, num3, auto, true); + goto Label5; + } + }); + return item3; + } + + public async Task SaveRange(List itens) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + await Task.Run(() => { + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + itens.ForEach((Item x) => commited.get_ItemRepository().Merge(x)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + foreach (Item iten in itens) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(iten, jsonSerializerSetting)); + registroLog.set_EntidadeId(iten.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_272 = ItemServico.u003cu003ec.u003cu003e9__27_2; + if (u003cu003e9_272 == null) + { + u003cu003e9_272 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__27_2 = u003cu003e9_272; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_272); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + commited.Commit(); + this.Sucesso = true; + break; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 276, num, itens, true); + } + } + }); + } + + public async Task> SaveTitulares(List titularesVidas) + { + int num = 3; + List titularesVidas5 = await Task.Run>(() => { + List titularesVidas6; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + List titularesVidas1 = titularesVidas; + Action u003cu003e9_321 = ItemServico.u003cu003ec.u003cu003e9__32_1; + if (u003cu003e9_321 == null) + { + u003cu003e9_321 = (TitularesVida x) => { + if (x.get_Tipo().GetValueOrDefault() != 2 && x.get_Dependente() != null) + { + x.set_Dependente(null); + } + }; + ItemServico.u003cu003ec.u003cu003e9__32_1 = u003cu003e9_321; + } + titularesVidas1.ForEach(u003cu003e9_321); + List titularesVidas2 = titularesVidas; + Func u003cu003e9_322 = ItemServico.u003cu003ec.u003cu003e9__32_2; + if (u003cu003e9_322 == null) + { + u003cu003e9_322 = (TitularesVida x) => { + if (x.get_Id() != 0) + { + return false; + } + return x.get_Tipo().GetValueOrDefault() != 2; + }; + ItemServico.u003cu003ec.u003cu003e9__32_2 = u003cu003e9_322; + } + titularesVidas2.Where(u003cu003e9_322).ToList().ForEach((TitularesVida x) => titularesVidas.First((TitularesVida y) => (object)y == (object)x).set_Id(commited.get_TitularesVidaRepository().SaveOrUpdate(x).get_Id())); + List titularesVidas3 = titularesVidas; + Func u003cu003e9_324 = ItemServico.u003cu003ec.u003cu003e9__32_4; + if (u003cu003e9_324 == null) + { + u003cu003e9_324 = (TitularesVida x) => { + if (x.get_Id() != 0) + { + return false; + } + return x.get_Tipo().GetValueOrDefault() == 2; + }; + ItemServico.u003cu003ec.u003cu003e9__32_4 = u003cu003e9_324; + } + titularesVidas3.Where(u003cu003e9_324).ToList().ForEach((TitularesVida x) => titularesVidas.First((TitularesVida y) => (object)y == (object)x).set_Id(commited.get_TitularesVidaRepository().SaveOrUpdate(x).get_Id())); + List titularesVidas4 = titularesVidas; + Func u003cu003e9_326 = ItemServico.u003cu003ec.u003cu003e9__32_6; + if (u003cu003e9_326 == null) + { + u003cu003e9_326 = (TitularesVida x) => x.get_Id() > (long)0; + ItemServico.u003cu003ec.u003cu003e9__32_6 = u003cu003e9_326; + } + titularesVidas4.Where(u003cu003e9_326).ToList().ForEach((TitularesVida x) => commited.get_TitularesVidaRepository().Merge(x)); + commited.Commit(); + this.Sucesso = true; + titularesVidas6 = titularesVidas; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 276, num, titularesVidas, true); + continue; + } + return titularesVidas6; + } + return new List(); + }); + return titularesVidas5; + } + + public async Task Substituir(Item item, long substituido, string descricao) + { + Item item1 = await Task.Run(() => { + Item item2; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + item = commited.get_ItemRepository().FindById(item.get_Id()); + item.set_Substituido(new long?(substituido)); + item.set_Status(descricao); + item = commited.get_ItemRepository().Merge(item); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); + strArrays[4] = "', OBSERVAÇÃO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); + strArrays[6] = "', STATUS: '"; + strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); + strArrays[8] = "' - "; + strArrays[9] = descricao; + strArrays[10] = "."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(item.get_Id()); + registroLog.set_Tela(3); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_221 = ItemServico.u003cu003ec.u003cu003e9__22_1; + if (u003cu003e9_221 == null) + { + u003cu003e9_221 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ItemServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_221); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + item2 = item; + } + } + catch (Exception exception) + { + item2 = null; + } + return item2; + }); + return item1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs new file mode 100644 index 0000000..2bd46f5 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs @@ -0,0 +1,196 @@ +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.Itens +{ + internal class PatrimonialServico : BaseServico + { + public PatrimonialServico() + { + } + + public async Task> BuscarImobiliaria(string imobiliaria, FiltroStatusDocumento status, List vendedorVinculado) + { + List pesquisaAvancadas1 = await Task.Run>(() => { + List pesquisaAvancadas; + try + { + using (UnitOfWork read = Instancia.Read) + { + pesquisaAvancadas = read.get_PatrimonialRepository().FindImobiliaria(imobiliaria, status, vendedorVinculado); + } + } + catch (Exception exception) + { + pesquisaAvancadas = null; + } + return pesquisaAvancadas; + }); + return pesquisaAvancadas1; + } + + public async Task> BuscarLocatario(string locatario, FiltroStatusDocumento status, List vendedorVinculado) + { + List pesquisaAvancadas1 = await Task.Run>(() => { + List pesquisaAvancadas; + try + { + using (UnitOfWork read = Instancia.Read) + { + pesquisaAvancadas = read.get_PatrimonialRepository().Findlocatario(locatario, status, vendedorVinculado); + } + } + catch (Exception exception) + { + pesquisaAvancadas = null; + } + return pesquisaAvancadas; + }); + return pesquisaAvancadas1; + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_Patrimonial() != null && item.get_Patrimonial().get_Id() > (long)0) + { + commited.get_PatrimonialRepository().Delete(item.get_Patrimonial().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + Patrimonial patrimonial = item.get_Patrimonial(); + id = (patrimonial != null ? patrimonial.get_Id() : (long)0); + registroLog.set_EntidadeId(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_11 = PatrimonialServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PatrimonialServico.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(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 197, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Patrimonial patrimonial) + { + Patrimonial patrimonial2 = await Task.Run(() => { + Patrimonial patrimonial3; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (patrimonial.get_Id() == 0 ? 0 : 1); + patrimonial = (patrimonial.get_Id() == 0 ? commited.get_PatrimonialRepository().SaveOrUpdate(patrimonial) : commited.get_PatrimonialRepository().Merge(patrimonial)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Patrimonial patrimonial1 = patrimonial; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(patrimonial1, jsonSerializerSetting)); + registroLog.set_EntidadeId(patrimonial.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_01 = PatrimonialServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PatrimonialServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_01); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + patrimonial3 = patrimonial; + } + } + catch (Exception exception) + { + patrimonial3 = null; + } + return patrimonial3; + }); + return patrimonial2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs new file mode 100644 index 0000000..77873c3 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs @@ -0,0 +1,156 @@ +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.Itens +{ + internal class RiscosDiversosServico : BaseServico + { + public RiscosDiversosServico() + { + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_RiscosDiversos() != null && item.get_RiscosDiversos().get_Id() > (long)0) + { + commited.get_RiscosDiversosRepository().Delete(item.get_RiscosDiversos().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + RiscosDiversos riscosDiversos = item.get_RiscosDiversos(); + id = (riscosDiversos != null ? riscosDiversos.get_Id() : (long)0); + registroLog.set_EntidadeId(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_11 = RiscosDiversosServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + RiscosDiversosServico.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(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 199, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(RiscosDiversos riscosdiversos) + { + RiscosDiversos riscosDiverso2 = await Task.Run(() => { + RiscosDiversos riscosDiverso; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (riscosdiversos.get_Id() == 0 ? 0 : 1); + riscosdiversos = (riscosdiversos.get_Id() == 0 ? commited.get_RiscosDiversosRepository().SaveOrUpdate(riscosdiversos) : commited.get_RiscosDiversosRepository().Merge(riscosdiversos)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + RiscosDiversos riscosDiverso1 = riscosdiversos; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(riscosDiverso1, jsonSerializerSetting)); + registroLog.set_EntidadeId(riscosdiversos.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_01 = RiscosDiversosServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + RiscosDiversosServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_01); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + riscosDiverso = riscosdiversos; + } + } + catch (Exception exception) + { + riscosDiverso = null; + } + return riscosDiverso; + }); + return riscosDiverso2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs new file mode 100644 index 0000000..3e03bfb --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs @@ -0,0 +1,156 @@ +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.Itens +{ + internal class VidaServico : BaseServico + { + public VidaServico() + { + } + + public async Task Delete(Item item) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + long id; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (item.get_Vida() != null && item.get_Vida().get_Id() > (long)0) + { + commited.get_VidaRepository().Delete(item.get_Vida().get_Id()); + } + commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); + commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id()); + commited.get_ItemRepository().Delete(item.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); + Item item1 = item; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting)); + Vida vida = item.get_Vida(); + id = (vida != null ? vida.get_Id() : (long)0); + registroLog.set_EntidadeId(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_11 = VidaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VidaServico.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(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 201, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Vida vida) + { + Vida vida2 = await Task.Run(() => { + Vida vida3; + string str; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (vida.get_Id() == 0 ? 0 : 1); + vida = (vida.get_Id() == 0 ? commited.get_VidaRepository().SaveOrUpdate(vida) : commited.get_VidaRepository().Merge(vida)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Vida vida1 = vida; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vida1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vida.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_01 = VidaServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VidaServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_01); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + vida3 = vida; + } + } + catch (Exception exception) + { + vida3 = null; + } + return vida3; + }); + return vida2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs new file mode 100644 index 0000000..21aa774 --- /dev/null +++ b/Codemerx/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 diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs new file mode 100644 index 0000000..293af5c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs @@ -0,0 +1,241 @@ +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.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 PerfilServico : BaseServico + { + public PerfilServico() + { + } + + internal async Task> BuscarPerfis(long controleId) + { + int num = 3; + List perfils1 = await Task.Run>(() => { + List perfils; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + perfils = read.get_PerfilRepository().FindByControleId(controleId); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 46, num, controleId, true); + continue; + } + return perfils; + } + return new List(); + }); + return perfils1; + } + + public async Task Delete(Perfil perfil) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + object obj; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_PerfilRepository().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 registroLog1 = registroLog; + string[] description = new string[47]; + description[0] = string.Format("O USUÁRIO {0} EXCLUIU O PERFIL, EM {1}, DE ", Recursos.Usuario.get_Nome(), networkTime); + description[1] = string.Format("ID: '{0}'", perfil.get_Id()); + description[2] = ", NOME: '"; + description[3] = (string.IsNullOrWhiteSpace(perfil.get_Nome()) ? "" : perfil.get_Nome() ?? ""); + description[4] = "', CPF: '"; + description[5] = (string.IsNullOrWhiteSpace(perfil.get_Cpf()) ? "" : perfil.get_Cpf() ?? ""); + description[6] = "', HABILITAÇÃO: '"; + description[7] = (string.IsNullOrWhiteSpace(perfil.get_Habilitacao()) ? "" : perfil.get_Habilitacao() ?? ""); + description[8] = "', TEMPO DE HABILITAÇÃO: '"; + description[9] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_TempoHabilitacao()); + description[10] = "', NASCIMENTO: '"; + DateTime? nascimento = perfil.get_Nascimento(); + if (!nascimento.HasValue) + { + obj = ""; + } + else + { + nascimento = perfil.get_Nascimento(); + obj = (nascimento.HasValue ? nascimento.GetValueOrDefault().ToShortDateString() : null) ?? ""; + } + description[11] = (string)obj; + description[12] = "', SEXO: '"; + description[13] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_Sexo()); + description[14] = "', ESTADO CIVIL: '"; + description[15] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_EstadoCivil()); + description[16] = "', OCUPAÇÃO: '"; + description[17] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_Ocupacao()); + description[18] = "', RELAÇÃOO: '"; + description[19] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_Relacao()); + description[20] = "', DISTÂNCIA DO TRABALHO: '"; + description[21] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_DistanciaResidenciaTrabalho()); + description[22] = "', USO POR DEPENDENTES: '"; + description[23] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_UsoDependentes()); + description[24] = "', TIPO DE RESIDÊNCIA: '"; + description[25] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_TipoResidencia()); + description[26] = "', GARAGEM NA RESIDÊNCIA: '"; + description[27] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_GaragemResidencia()); + description[28] = "', GARAGEM NO TRABALHO: '"; + description[29] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_GaragemTrabalho()); + description[30] = "', GARAGEM NO ESTUDO: '"; + description[31] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_GaragemEstudo()); + description[32] = "', VEÍCULOS NA RESIDÊNCIA: '"; + description[33] = (!perfil.get_VeiculoResidencia().HasValue ? "" : string.Format("{0}", perfil.get_VeiculoResidencia())); + description[34] = "', ANTFURTO: '"; + description[35] = (!perfil.get_AntiFurto().HasValue ? "" : Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_AntiFurto())); + description[36] = "', SEGURO DE VIDA: '"; + description[37] = (!perfil.get_SeguroVida().HasValue ? "" : (perfil.get_SeguroVida().Value ? "SIM" : "NÃO")); + description[38] = "', USO PROFISSIONAL: '"; + description[39] = (!perfil.get_UsoProfissional().HasValue ? "" : (perfil.get_UsoProfissional().Value ? "SIM" : "NÃO")); + description[40] = "', COBERTURA ESTENDIDA: '"; + description[41] = (!perfil.get_EstenderCobertura().HasValue ? "" : (perfil.get_EstenderCobertura().Value ? "SIM" : "NÃO")); + description[42] = "', CEP CIRCULAÇÃO: '"; + description[43] = (string.IsNullOrWhiteSpace(perfil.get_CepCirculacao()) ? "" : perfil.get_CepCirculacao() ?? ""); + description[44] = "', CEP PERNOITE: '"; + description[45] = (string.IsNullOrWhiteSpace(perfil.get_CepPernoite()) ? "" : perfil.get_CepPernoite() ?? ""); + description[46] = "'."; + registroLog1.set_Descricao(string.Concat(description)); + 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); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = PerfilServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PerfilServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_21); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.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(Perfil perfil) + { + int num = 3; + base.Sucesso = true; + Perfil perfil2 = perfil; + Perfil perfil3 = await Task.Run(() => { + Perfil perfil4; + string str; + while (num > 0) + { + perfil = perfil2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (perfil.get_Id() == 0 ? 0 : 1); + perfil = (perfil.get_Id() == 0 ? commited.get_PerfilRepository().SaveOrUpdate(perfil) : commited.get_PerfilRepository().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()); + Perfil perfil1 = perfil; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(perfil1, 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 = PerfilServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PerfilServico.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(); + perfil4 = perfil; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 212, num, perfil, true); + continue; + } + return perfil4; + } + return perfil2; + }); + return perfil3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs new file mode 100644 index 0000000..f528fcb --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs @@ -0,0 +1,78 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using System; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Seguros +{ + internal class ProfissaoServico : BaseServico + { + public ProfissaoServico() + { + } + + public async Task FindLastId() + { + int num1 = 3; + long num2 = await Task.Run(() => { + long num; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + num = read.get_ProfissaoRepository().FindLastId(); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 17, num1, null, true); + continue; + } + return num; + } + return (long)0; + }); + return num2; + } + + public async Task Save(Profissao profissao) + { + int num = 3; + base.Sucesso = true; + Profissao profissao1 = profissao; + Profissao profissao2 = await Task.Run(() => { + Profissao profissao3; + while (num > 0) + { + profissao = profissao1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + profissao = (profissao.get_Id() == (long)0 ? commited.get_ProfissaoRepository().SaveOrUpdate(profissao) : commited.get_ProfissaoRepository().Merge(profissao)); + commited.Commit(); + profissao3 = profissao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 214, num, profissao, true); + continue; + } + return profissao3; + } + return profissao1; + }); + return profissao2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs new file mode 100644 index 0000000..19049b1 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs @@ -0,0 +1,400 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Seguros +{ + internal class SinistroServico : BaseServico + { + public SinistroServico() + { + } + + internal async Task> BuscarControles(long id) + { + int num = 3; + List controleSinistros1 = await Task.Run>(() => { + List controleSinistros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + controleSinistros = read.get_ControleSinistroRepository().FindByIdItem(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 48, num, id, true); + continue; + } + return controleSinistros; + } + return new List(); + }); + return controleSinistros1; + } + + public async Task BuscarSinistro(long id) + { + int num = 3; + Sinistro sinistro1 = await Task.Run(() => { + Sinistro sinistro; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + sinistro = read.get_SinistroRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 49, num, id, true); + continue; + } + return sinistro; + } + return new Sinistro(); + }); + return sinistro1; + } + + public async Task> BuscarSinistro(Filtros filtro) + { + int num = 3; + List sinistros1 = await Task.Run>(() => { + List sinistros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + sinistros = read.get_SinistroRepository().FindByData(filtro, false); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 176, num, filtro, true); + continue; + } + return sinistros; + } + return new List(); + }); + return sinistros1; + } + + public async Task> BuscarSinistroPendente(Filtros filtro) + { + int num = 3; + List sinistros1 = await Task.Run>(() => { + List sinistros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + sinistros = read.get_SinistroRepository().FindByData(filtro, true); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 176, num, filtro, true); + continue; + } + return sinistros; + } + return new List(); + }); + return sinistros1; + } + + public async Task> BuscarSinistros(string numero) + { + int num = 3; + List sinistros1 = await Task.Run>(() => { + List sinistros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + sinistros = read.get_SinistroRepository().FindNumeroSinistro(numero); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 177, num, numero, true); + continue; + } + return sinistros; + } + return new List(); + }); + return sinistros1; + } + + public async Task Delete(Sinistro sinistro) + { + int num = 3; + base.Sucesso = true; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(sinistro.get_Id(), sinistro.GetValorOriginal(), 26, 2)); + SinistroAuto sinistroAuto = commited.get_SinistroAutoRepository().FindBySinistroId(sinistro.get_Id()); + SinistroVida sinistroVida = commited.get_SinistroVidaRepository().FindBySinistroId(sinistro.get_Id()); + if (sinistroAuto != null) + { + commited.get_SinistroAutoRepository().Delete(sinistroAuto.get_Id()); + } + if (sinistroVida != null) + { + commited.get_SinistroVidaRepository().Delete(sinistroVida.get_Id()); + } + commited.get_SinistroRepository().Delete(sinistro.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 174, num, sinistro, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task DeleteControle(ControleSinistro controle, bool atualizarItem) + { + int num = 3; + base.Sucesso = true; + bool flag1 = await Task.Run(async () => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (atualizarItem) + { + Item item = commited.get_ItemRepository().FindById(controle.get_Item().get_Id()); + item.set_Sinistrado(false); + commited.get_ItemRepository().Merge(item); + } + foreach (Sinistro sinistro in commited.get_SinistroRepository().FindByControleId(controle.get_Id())) + { + registroLogs.Add(base.CreateLog(sinistro.get_Id(), sinistro.GetValorOriginal(), 26, 2)); + if (await this.Delete(sinistro)) + { + continue; + } + flag = false; + return flag; + } + commited.get_ControleSinistroRepository().Delete(controle.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + return flag; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 174, num, controle, true); + } + registroLogs = null; + } + flag = false; + return flag; + }); + return flag1; + } + + public async Task Save(Sinistro sinistro, long idramo) + { + int num3 = 3; + base.Sucesso = true; + Sinistro sinistro1 = sinistro; + Funcoes.GetNetworkTime(); + Sinistro sinistro2 = await Task.Run(() => { + SinistroVida sinistroVida; + long num; + Sinistro sinistro3; + while (num3 > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Item item = commited.get_ItemRepository().FindById(sinistro.get_ControleSinistro().get_Item().get_Id()); + item.set_Sinistrado(true); + sinistro1.get_ControleSinistro().set_Item(commited.get_ItemRepository().Merge(item)); + bool id = sinistro1.get_ControleSinistro().get_Id() == (long)0; + SinistroAuto sinistroAuto = sinistro1.get_SinistroAuto(); + sinistroVida = sinistro1.get_SinistroVida(); + if (!id) + { + registroLogs.Add(base.CreateLog(sinistro1.get_Id(), sinistro1, 7)); + sinistro1.set_ControleSinistro(commited.get_ControleSinistroRepository().Merge(sinistro1.get_ControleSinistro())); + sinistro1 = (sinistro1.get_Id() == 0 ? commited.get_SinistroRepository().SaveOrUpdate(sinistro1) : commited.get_SinistroRepository().Merge(sinistro1)); + num = idramo; + long num1 = num - (long)5; + if (num1 <= (long)5) + { + switch ((uint)num1) + { + case 0: + { + goto Label0; + } + case 1: + case 2: + case 4: + case 5: + { + goto Label1; + } + case 3: + { + goto Label2; + } + } + } + else + { + } + if (num != (long)37) + { + goto Label3; + } + Label0: + if (sinistroAuto != null) + { + sinistroAuto.set_Sinistro(sinistro1); + sinistroAuto = (sinistroAuto.get_Id() == 0 ? commited.get_SinistroAutoRepository().SaveOrUpdate(sinistroAuto) : commited.get_SinistroAutoRepository().Merge(sinistroAuto)); + sinistro1.set_SinistroAuto(sinistroAuto); + } + } + else + { + sinistro1.set_ControleSinistro(commited.get_ControleSinistroRepository().SaveOrUpdate(sinistro1.get_ControleSinistro())); + sinistro1 = commited.get_SinistroRepository().SaveOrUpdate(sinistro1); + registroLogs.Add(base.CreateLog(sinistro1.get_Id(), sinistro1.GetValorOriginal(), 7, 0)); + num = idramo; + long num2 = num - (long)5; + if (num2 <= (long)5) + { + switch ((uint)num2) + { + case 0: + { + goto Label4; + } + case 1: + case 2: + case 4: + case 5: + { + goto Label5; + } + case 3: + { + goto Label2; + } + } + } + else + { + } + if (num != (long)37) + { + goto Label6; + } + Label4: + sinistroAuto.set_Sinistro(sinistro1); + sinistroAuto = commited.get_SinistroAutoRepository().SaveOrUpdate(sinistroAuto); + sinistro1.set_SinistroAuto(sinistroAuto); + } + Label2: + base.SaveLog(registroLogs, commited); + commited.Commit(); + sinistro3 = sinistro1; + } + } + catch (Exception exception) + { + num3 = base.Registrar(exception, 175, num3, sinistro, true); + continue; + } + return sinistro3; + } + return sinistro; + Label1: + if (sinistroVida == null) + { + sinistroVida = new SinistroVida(); + } + sinistroVida.set_Sinistro(sinistro1); + sinistroVida = (sinistroVida.get_Id() == 0 ? commited.get_SinistroVidaRepository().SaveOrUpdate(sinistroVida) : commited.get_SinistroVidaRepository().Merge(sinistroVida)); + sinistro1.set_SinistroVida(sinistroVida); + goto Label2; + Label3: + if (num != (long)53) + { + goto Label2; + } + else + { + goto Label1; + } + Label5: + sinistroVida.set_Sinistro(sinistro1); + sinistroVida = commited.get_SinistroVidaRepository().SaveOrUpdate(sinistroVida); + sinistro1.set_SinistroVida(sinistroVida); + goto Label2; + Label6: + if (num != (long)53) + { + goto Label2; + } + else + { + goto Label5; + } + }); + return sinistro2; + } + } +} \ No newline at end of file -- cgit v1.2.3