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/Ajuda/AjudaServico.cs | 129 + .../Servicos/ArquivoDigitalServico.cs | 538 ++++ .../Servicos/AssinaturaServico.cs | 178 ++ Codemerx/Gestor.Application/Servicos/CepService.cs | 161 ++ .../Servicos/Configuracoes/ConfuguracoesServico.cs | 464 ++++ .../Servicos/Ferramentas/AdiantamentoServico.cs | 281 +++ .../Servicos/Ferramentas/AgendaServico.cs | 257 ++ .../Servicos/Ferramentas/EmailServico.cs | 127 + .../Servicos/Ferramentas/EmpresaServico.cs | 287 +++ .../Servicos/Ferramentas/EstipulanteServico.cs | 124 + .../Servicos/Ferramentas/ImpostoServico.cs | 171 ++ .../Servicos/Ferramentas/MetaSeguradoraServico.cs | 182 ++ .../Servicos/Ferramentas/MetaVendedorServico.cs | 182 ++ .../Servicos/Ferramentas/NotaFiscalServico.cs | 176 ++ .../Servicos/Ferramentas/ProdutoServico.cs | 92 + .../Servicos/Ferramentas/QualificacaoServico.cs | 57 + .../Servicos/Ferramentas/RamoServico.cs | 192 ++ .../Servicos/Ferramentas/ReciboServico.cs | 123 + .../Servicos/Ferramentas/SeguradoraServico.cs | 372 +++ .../Servicos/Ferramentas/SocioServico.cs | 97 + .../Ferramentas/StatusProspeccaoServico.cs | 93 + .../Servicos/Ferramentas/StatusServico.cs | 124 + .../Servicos/Ferramentas/TipoTarefaServico.cs | 93 + .../Servicos/Ferramentas/TipoVendedorServico.cs | 131 + .../Servicos/Ferramentas/UsuarioServico.cs | 303 +++ .../Servicos/Ferramentas/VendedorServico.cs | 851 +++++++ .../Servicos/Financeiro/BancosContasServico.cs | 362 +++ .../Servicos/Financeiro/CentroServico.cs | 92 + .../Servicos/Financeiro/FinanceiroServico.cs | 738 ++++++ .../Servicos/Financeiro/FornecedorServico.cs | 123 + .../Servicos/Financeiro/PlanoServico.cs | 120 + .../Servicos/Financeiro/PlanosServico.cs | 93 + .../Servicos/Generic/BaseServico.cs | 2567 ++++++++++++++++++++ Codemerx/Gestor.Application/Servicos/LogServico.cs | 262 ++ .../Servicos/MalaDiretaServico.cs | 188 ++ .../Gestor.Application/Servicos/ParceiroServico.cs | 123 + .../Gestor.Application/Servicos/ParcelaServico.cs | 1006 ++++++++ .../Servicos/PermissaoArquivoDigitalServico.cs | 167 ++ .../Servicos/PermissaoUsuarioServico.cs | 152 ++ .../Servicos/ProspeccaoServico.cs | 338 +++ .../Servicos/RestricaoUsuarioServico.cs | 221 ++ .../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 +++ .../Gestor.Application/Servicos/ServicoExtrato.cs | 335 +++ .../Gestor.Application/Servicos/TarefaServico.cs | 795 ++++++ .../Servicos/VendedorUsuarioServico.cs | 160 ++ 61 files changed, 21261 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/CepService.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/LogServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/ParceiroServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/ParcelaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs 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 create mode 100644 Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs create mode 100644 Codemerx/Gestor.Application/Servicos/TarefaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs (limited to 'Codemerx/Gestor.Application/Servicos') diff --git a/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs b/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs new file mode 100644 index 0000000..30e8886 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs @@ -0,0 +1,129 @@ +using CsQuery.ExtensionMethods.Internal; +using Gestor.Application.Helpers; +using Gestor.Application.Model.Ajuda; +using Gestor.Application.Servicos.Generic; +using Gestor.Model.License; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ajuda +{ + public class AjudaServico : BaseServico + { + public AjudaServico() + { + } + + internal async Task> BuscarAtendimentos(string status) + { + ObservableCollection observableCollection = await Task.Run>(() => { + ObservableCollection result; + try + { + result = Connection.Get>(string.Format("Attendance/{0}", (status == "PENDENTES" ? 1 : 2)), true, false).Result; + } + catch (Exception exception) + { + result = null; + } + return result; + }); + return observableCollection; + } + + internal async Task> BuscarBoletosNotas(string status) + { + List boletos = await Task.Run>(() => { + List result; + try + { + result = Connection.Get>(string.Format("Billet/{0}", status == "BAIXADOS"), true, false).Result; + } + catch (Exception exception) + { + result = null; + } + return result; + }); + return boletos; + } + + internal async Task BuscarContrato(Produto produto) + { + Contrato contrato = await Task.Run(() => { + Contrato result; + try + { + result = Connection.Get(string.Format("Contract/{0}", ExtensionMethods.GetValue(produto)), true, false).Result; + } + catch (Exception exception) + { + result = null; + } + return result; + }); + return contrato; + } + + internal async Task BuscarCorpoAtendimentos(long id) + { + string str = await Task.Run(() => { + string result; + try + { + result = Connection.Get(string.Format("Attendance/Body/{0}", id), true, false).Result; + } + catch (Exception exception) + { + result = null; + } + return result; + }); + return str; + } + + internal async Task> BuscarLicencas() + { + ObservableCollection observableCollection = await Task.Run>(() => { + ObservableCollection result; + try + { + result = Connection.Get>(string.Format("License/{0}", ApplicationHelper.IdFornecedor), true, false).Result; + } + catch (Exception exception) + { + result = null; + } + return result; + }); + return observableCollection; + } + + internal async Task ExcluirInstalacao(long id) + { + int num = 3; + bool flag = await Task.Run(() => { + bool result; + while (num > 0) + { + try + { + result = Connection.Delete(string.Format("License/{0}", id)).Result; + } + catch (Exception exception) + { + num = base.Registrar(exception, 273, num, id, true); + continue; + } + return result; + } + return false; + }); + return flag; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs b/Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs new file mode 100644 index 0000000..fdeae7d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs @@ -0,0 +1,538 @@ +using ArquivoDigital.Infrastructure.Repository.Interface; +using ArquivoDigital.Infrastructure.UnitOfWork.Generic; +using ArquivoDigital.Infrastructure.UnitOfWork.Logic; +using CsQuery.ExtensionMethods.Internal; +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.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Aggilizador; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.License; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class ArquivoDigitalServico : BaseServico + { + public ArquivoDigitalServico() + { + } + + public async Task> BaixarArquivosPendentes(List arquivos) + { + string banco = Gestor.Application.Helpers.ArquivoDigital.Banco; + int num = 3; + List arquivoVinculos1 = await Task.Run>(() => { + List arquivoVinculos; + while (num > 0) + { + try + { + using (Gestor.Application.Helpers.ArquivoDigital.Read) + { + foreach (ArquivoVinculo arquivo in arquivos) + { + if (arquivo.get_Arquivo() != null || ExtensionMethods.IsNullOrEmpty(arquivo.get_Chave())) + { + continue; + } + byte[] result = Connection.DownloadFile(arquivo.get_Storage(), arquivo.get_Ano(), Guid.Parse(arquivo.get_Chave()), ".pdf", "aggilizador", false).Result; + if (result == null) + { + continue; + } + arquivo.set_Arquivo(result); + } + arquivoVinculos = arquivos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 65, num, new { arquivos = arquivos, banco = banco }, true); + continue; + } + return arquivoVinculos; + } + return null; + }); + return arquivoVinculos1; + } + + public async Task> Buscar(List ids) + { + int num = 3; + List arquivoDigitals4 = await Task.Run>(() => { + List arquivoDigitals2; + while (num > 0) + { + try + { + List arquivoDigitals3 = new List(); + List indiceArquivoDigitals2 = ids; + Func u003cu003e9_61 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_1; + if (u003cu003e9_61 == null) + { + u003cu003e9_61 = (IndiceArquivoDigital x) => x.get_Bd(); + ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61; + } + indiceArquivoDigitals2.GroupBy(u003cu003e9_61).ToList>().ForEach((IGrouping x) => { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(x.Key); + IGrouping strs = x; + Func u003cu003e9_63 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_3; + if (u003cu003e9_63 == null) + { + u003cu003e9_63 = (IndiceArquivoDigital l) => !l.get_Assinado(); + ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_3 = u003cu003e9_63; + } + IEnumerable indiceArquivoDigitals = strs.Where(u003cu003e9_63); + Func u003cu003e9_64 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_4; + if (u003cu003e9_64 == null) + { + u003cu003e9_64 = (IndiceArquivoDigital l) => l.get_IdArquivoDigital(); + ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_4 = u003cu003e9_64; + } + List list = indiceArquivoDigitals.Select(u003cu003e9_64).ToList(); + IGrouping strs1 = x; + Func u003cu003e9_65 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_5; + if (u003cu003e9_65 == null) + { + u003cu003e9_65 = (IndiceArquivoDigital l) => l.get_Assinado(); + ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_5 = u003cu003e9_65; + } + IEnumerable indiceArquivoDigitals1 = strs1.Where(u003cu003e9_65); + Func u003cu003e9_66 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_6; + if (u003cu003e9_66 == null) + { + u003cu003e9_66 = (IndiceArquivoDigital l) => l.get_Id(); + ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_6 = u003cu003e9_66; + } + List nums = indiceArquivoDigitals1.Select(u003cu003e9_66).ToList(); + if (nums.Any()) + { + List arquivoDigitals = new List(); + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + nums.ForEach((long a) => { + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital = read.get_IndiceArquivoDigitalRepository().FindAssinatura(a); + if (arquivoDigital.get_AzureGuid().HasValue) + { + arquivoDigital.set_Arquivo(Connection.DownloadFile(arquivoDigital.get_AzureStorage(), arquivoDigital.get_DataCriacao().Value.Year, arquivoDigital.get_AzureGuid().Value, Path.GetExtension(arquivoDigital.get_Descricao()), "siggner", false).Result); + } + if (arquivoDigital.get_Arquivo() != null) + { + arquivoDigitals.Add(arquivoDigital); + } + }); + } + arquivoDigitals3.AddRange(arquivoDigitals); + } + if (list.Any()) + { + List arquivoDigitals1 = new List(); + using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Gestor.Application.Helpers.ArquivoDigital.Read) + { + list.ForEach((long a) => { + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital = unitOfWork.get_ArquivoDigitalRepository().FindById(a, true); + if (arquivoDigital.get_AzureGuid().HasValue) + { + arquivoDigital.set_Arquivo(Connection.DownloadFile(arquivoDigital.get_AzureStorage(), arquivoDigital.get_DataCriacao().Value.Year, arquivoDigital.get_AzureGuid().Value, arquivoDigital.get_Extensao(), "ad", false).Result); + } + if (arquivoDigital.get_Arquivo() != null) + { + arquivoDigitals1.Add(arquivoDigital); + } + }); + } + arquivoDigitals3.AddRange(arquivoDigitals1); + } + }); + arquivoDigitals2 = arquivoDigitals3; + } + catch (Exception exception) + { + num = base.Registrar(exception, 66, num, ids, true); + continue; + } + return arquivoDigitals2; + } + return new List(); + }); + return arquivoDigitals4; + } + + public async Task BuscarPorId(long id, string banco) + { + int num = 3; + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital2 = await Task.Run(() => { + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital; + while (num > 0) + { + try + { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(banco); + if (string.IsNullOrEmpty(banco)) + { + banco = Gestor.Application.Helpers.ArquivoDigital.Banco; + } + using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read) + { + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital1 = read.get_ArquivoDigitalRepository().FindById(id, true); + if (arquivoDigital1 != null) + { + if (arquivoDigital1.get_AzureGuid().HasValue) + { + byte[] result = Connection.DownloadFile(arquivoDigital1.get_AzureStorage(), arquivoDigital1.get_DataCriacao().Value.Year, arquivoDigital1.get_AzureGuid().Value, arquivoDigital1.get_Extensao(), "ad", false).Result; + if (result != null) + { + arquivoDigital1.set_Arquivo(result); + } + else + { + arquivoDigital = null; + return arquivoDigital; + } + } + arquivoDigital = arquivoDigital1; + } + else + { + arquivoDigital = null; + } + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 65, num, new { id = id, banco = banco }, true); + continue; + } + return arquivoDigital; + } + return null; + }); + return arquivoDigital2; + } + + public async Task BuscarPorId(long id) + { + int num = 3; + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital2 = await Task.Run(() => { + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital1 = read.get_IndiceArquivoDigitalRepository().FindAssinatura(id); + if (arquivoDigital1.get_AzureGuid().HasValue) + { + byte[] result = Connection.DownloadFile(arquivoDigital1.get_AzureStorage(), arquivoDigital1.get_DataCriacao().Value.Year, arquivoDigital1.get_AzureGuid().Value, Path.GetExtension(arquivoDigital1.get_Descricao()), "siggner", false).Result; + if (result != null) + { + arquivoDigital1.set_Arquivo(result); + } + else + { + arquivoDigital = null; + return arquivoDigital; + } + } + arquivoDigital = arquivoDigital1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 64, num, id, true); + continue; + } + return arquivoDigital; + } + return null; + }); + return arquivoDigital2; + } + + public async Task> BuscarPorTipo(TipoArquivoDigital tipo, long id) + { + int num2 = 3; + long num3 = Recursos.Usuario.get_Id(); + List indiceArquivoDigitals1 = await Task.Run>(() => { + List indiceArquivoDigitals; + while (num2 > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + IIndiceArquivoDigitalRepository indiceArquivoDigitalRepository = read.get_IndiceArquivoDigitalRepository(); + TipoArquivoDigital tipoArquivoDigital = tipo; + long num = id; + long num1 = num3; + List produtos = LicenseHelper.Produtos; + Func u003cu003e9_01 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (Licenca x) => { + if (x.get_Produto() != 86) + { + return false; + } + return x.get_Status() != 3; + }; + ArquivoDigitalServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + indiceArquivoDigitals = indiceArquivoDigitalRepository.Find(tipoArquivoDigital, num, num1, produtos.Any(u003cu003e9_01)); + } + } + catch (Exception exception) + { + num2 = base.Registrar(exception, 64, num2, new { tipo = tipo, id = id }, true); + continue; + } + return indiceArquivoDigitals; + } + return new List(); + }); + return indiceArquivoDigitals1; + } + + public async Task Criar() + { + int num = 3; + await Task.Run(() => { + while (num > 0) + { + try + { + using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read) + { + read.get_ArquivoDigitalRepository().FindById((long)1, false); + break; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 288, num, null, true); + } + } + }); + } + + public async Task DeleteAttachment(IndiceArquivoDigital indice) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + indice.set_Excluido(true); + List diferencas = new List(); + Diferenca diferenca = new Diferenca(); + diferenca.set_Campo("Id"); + diferenca.set_Descricao("ID"); + diferenca.set_ValorAtual(indice.get_Id().ToString()); + diferencas.Add(diferenca); + Diferenca diferenca1 = new Diferenca(); + diferenca1.set_Campo("Descricao"); + diferenca1.set_Descricao("DESCRIÇÃO"); + diferenca1.set_ValorAtual(indice.get_Descricao()); + diferencas.Add(diferenca1); + List diferencas1 = diferencas; + if (indice.get_AzureGuid().HasValue && Connection.DeleteFile(indice.get_AzureStorage(), indice.get_DataCriacao().Value.Year, indice.get_AzureGuid().Value, indice.get_Extensao(), "ad").Result) + { + Diferenca diferenca2 = new Diferenca(); + diferenca2.set_Campo("AzureGuid"); + diferenca2.set_Descricao("AzureGuid"); + diferenca2.set_ValorAtual(indice.get_AzureGuid().ToString()); + diferencas1.Add(diferenca2); + } + registroLogs.Add(base.CreateLog(indice.get_Id(), diferencas1, 6, 2)); + indice.set_DataAtualizacao(new DateTime?(networkTime)); + if (!indice.get_DataCriacao().HasValue || indice.get_DataCriacao().Value.Year < 1754) + { + indice.set_DataCriacao(new DateTime?(networkTime)); + } + commited.get_IndiceArquivoDigitalRepository().Merge(indice); + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 253, num, indice, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> Insert(List files) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + List arquivoDigitals = files; + List indiceArquivoDigitals2 = await Task.Run>(() => { + List indiceArquivoDigitals; + while (num > 0) + { + List registroLogs = new List(); + files = arquivoDigitals; + try + { + List indiceArquivoDigitals1 = new List(); + files.ForEach((Gestor.Model.Domain.Common.ArquivoDigital file) => { + file.set_UsuarioCriacao(Recursos.Usuario.get_Id()); + file.set_DataCriacao(new DateTime?(networkTime)); + file.set_DataAtualizacao(null); + UploadFile uploadFile = new UploadFile(); + uploadFile.set_Ano(networkTime.Year); + uploadFile.set_Id(Guid.NewGuid()); + uploadFile.set_Extensao(file.get_Extensao().Replace(".", string.Empty)); + uploadFile.set_Arquivo(file.get_Arquivo()); + UploadFile uploadFile1 = uploadFile; + if (Connection.ConnectionAddress.get_UsaAzureStorage() && Connection.UploadFile(uploadFile1, "ad").Result) + { + file.set_AzureGuid(new Guid?(uploadFile1.get_Id())); + file.set_Arquivo(null); + file.set_AzureStorage(Connection.ConnectionAddress.get_AzureStorage()); + } + IndiceArquivoDigital indiceArquivoDigital = new IndiceArquivoDigital(); + indiceArquivoDigital.set_Descricao(file.get_Descricao()); + indiceArquivoDigital.set_Bd(Gestor.Application.Helpers.ArquivoDigital.Banco); + indiceArquivoDigital.set_Extensao(file.get_Extensao()); + indiceArquivoDigital.set_IdCliente(file.get_IdCliente()); + indiceArquivoDigital.set_IdDocumento(file.get_IdDocumento()); + indiceArquivoDigital.set_IdEmpresa(file.get_IdEmpresa()); + indiceArquivoDigital.set_IdParcela(file.get_IdParcela()); + indiceArquivoDigital.set_IdItem(file.get_IdItem()); + indiceArquivoDigital.set_IdExtrato(file.get_IdExtrato()); + indiceArquivoDigital.set_IdSinistro(file.get_IdSinistro()); + indiceArquivoDigital.set_IdSeguradora(file.get_IdSeguradora()); + indiceArquivoDigital.set_IdVendedor(file.get_IdVendedor()); + indiceArquivoDigital.set_IdUsuario(file.get_IdUsuario()); + indiceArquivoDigital.set_IdLancamento(file.get_IdLancamento()); + indiceArquivoDigital.set_IdFornecedor(file.get_IdFornecedor()); + indiceArquivoDigital.set_IdProspeccao(file.get_IdProspeccao()); + indiceArquivoDigital.set_IdSocio(file.get_IdSocio()); + indiceArquivoDigital.set_IdTarefa(file.get_IdTarefa()); + indiceArquivoDigital.set_IdNotaFiscal(file.get_IdNotaFiscal()); + indiceArquivoDigital.set_IdEstipulante(file.get_IdEstipulante()); + indiceArquivoDigital.set_Excluido(file.get_Excluido()); + indiceArquivoDigital.set_UsuarioCriacao(file.get_UsuarioCriacao()); + indiceArquivoDigital.set_DataCriacao(file.get_DataCriacao()); + indiceArquivoDigital.set_DataAtualizacao(file.get_DataAtualizacao()); + indiceArquivoDigital.set_AzureGuid(file.get_AzureGuid()); + indiceArquivoDigital.set_AzureStorage(file.get_AzureStorage()); + IndiceArquivoDigital indiceArquivoDigital1 = indiceArquivoDigital; + Gestor.Application.Helpers.ArquivoDigital.SetConnection(""); + indiceArquivoDigital1.set_Bd(Gestor.Application.Helpers.ArquivoDigital.Banco); + using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Gestor.Application.Helpers.ArquivoDigital.Commited) + { + file = commited.get_ArquivoDigitalRepository().SaveOrUpdate(file); + indiceArquivoDigital1.set_IdArquivoDigital(file.get_Id()); + commited.Commit(); + } + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Instancia.Commited) + { + indiceArquivoDigital1 = unitOfWork.get_IndiceArquivoDigitalRepository().SaveOrUpdate(indiceArquivoDigital1); + List diferencas = new List(); + Diferenca diferenca = new Diferenca(); + diferenca.set_Campo("Descricao"); + diferenca.set_Descricao("DESCRIÇÃO"); + diferenca.set_ValorAtual(indiceArquivoDigital1.get_Descricao()); + diferencas.Add(diferenca); + registroLogs.Add(base.CreateLog(indiceArquivoDigital1.get_Id(), diferencas, 6, 0)); + base.SaveLog(registroLogs, unitOfWork); + unitOfWork.Commit(); + } + indiceArquivoDigitals1.Add(indiceArquivoDigital1); + }); + indiceArquivoDigitals = indiceArquivoDigitals1; + } + catch (Exception exception) + { + num = base.Registrar(exception, 252, num, files, true); + continue; + } + return indiceArquivoDigitals; + } + return new List(); + }); + return indiceArquivoDigitals2; + } + + public async Task Save(IndiceArquivoDigital indice) + { + int num = 3; + base.Sucesso = true; + IndiceArquivoDigital indiceArquivoDigital1 = indice; + DateTime networkTime = Funcoes.GetNetworkTime(); + IndiceArquivoDigital indiceArquivoDigital2 = await Task.Run(() => { + IndiceArquivoDigital indiceArquivoDigital; + while (num > 0) + { + indice = indiceArquivoDigital1; + List registroLogs = new List(); + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (indice.get_Id() == 0 ? 0 : 1); + indice.set_DataAtualizacao(new DateTime?(networkTime)); + indice.set_UsuarioAtualizacao(Recursos.Usuario.get_Id()); + indice.set_Excluido(false); + if (tipoAcao == 1) + { + registroLogs.Add(base.CreateLog(indice.get_Id(), indice, 6)); + } + indice = (tipoAcao == 1 ? commited.get_IndiceArquivoDigitalRepository().Merge(indice) : commited.get_IndiceArquivoDigitalRepository().SaveOrUpdate(indice)); + if (tipoAcao != 1) + { + List diferencas = new List(); + Diferenca diferenca = new Diferenca(); + diferenca.set_Campo("Descricao"); + diferenca.set_Descricao("DESCRIÇÃO"); + diferenca.set_ValorAtual(indice.get_Descricao()); + diferencas.Add(diferenca); + registroLogs.Add(base.CreateLog(indice.get_Id(), diferencas, 6, tipoAcao)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + indiceArquivoDigital = indice; + } + catch (Exception exception) + { + num = base.Registrar(exception, 252, num, indice, true); + continue; + } + return indiceArquivoDigital; + } + return indiceArquivoDigital1; + }); + return indiceArquivoDigital2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs b/Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs new file mode 100644 index 0000000..2151fd9 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs @@ -0,0 +1,178 @@ +using Assinador.Infrastructure.Repository.Interface; +using Assinador.Infrastructure.UnitOfWork.Generic; +using Assinador.Infrastructure.UnitOfWork.Logic; +using Assinador.Model.Domain; +using Assinador.Model.Generic; +using Assinador.Modelos; +using Assinador.Processos; +using Gestor.Application.Helpers; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Newtonsoft.Json; +using Sign.Modelos; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class AssinaturaServico + { + public AssinaturaServico() + { + } + + public async Task Assinar(Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital, ApoliceAssinador apolice) + { + AggerSigner aggerSigner = new AggerSigner(AssinadorHelper.Remetente); + ArquivoAssinatura arquivoAssinatura = new ArquivoAssinatura(); + arquivoAssinatura.set_Bytes(arquivoDigital.get_Arquivo()); + arquivoAssinatura.set_Nome(string.Concat(arquivoDigital.get_Descricao(), arquivoDigital.get_Extensao().ToLower())); + ArquivoAssinatura arquivoAssinatura1 = arquivoAssinatura; + List destinatarios = new List(); + Destinatario destinatario = new Destinatario(); + destinatario.set_Email(apolice.get_Email()); + destinatario.set_Nome(apolice.get_Cliente()); + destinatario.set_Documento(apolice.get_Documento()); + destinatarios.Add(destinatario); + arquivoAssinatura1.set_Destinatarios(destinatarios); + ArquivoCriado arquivoCriado = await aggerSigner.EnviarParaAssinatura(arquivoAssinatura1); + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador = new ArquivoParaAssinaturaAssinador(); + arquivoParaAssinaturaAssinador.set_AssinaturaId(arquivoCriado.get_Id()); + arquivoParaAssinaturaAssinador.set_Chave(arquivoCriado.get_Chave()); + arquivoParaAssinaturaAssinador.set_DocumentoId(apolice.get_Id()); + arquivoParaAssinaturaAssinador.set_ClienteId(apolice.get_ClienteId()); + arquivoParaAssinaturaAssinador.set_IndiceId(apolice.get_ArquivoId()); + arquivoParaAssinaturaAssinador.set_UrlAssinatura(arquivoCriado.get_Url()); + arquivoParaAssinaturaAssinador.set_Enviado(Funcoes.GetNetworkTime()); + arquivoParaAssinaturaAssinador.set_UsuarioId(Recursos.Usuario.get_Id()); + return arquivoParaAssinaturaAssinador; + } + + public static async Task BuscarParametrosAssinatura(long id) + { + ParametrosAssinaturaAssinador parametrosAssinaturaAssinador1 = await Task.Run(() => { + ParametrosAssinaturaAssinador parametrosAssinaturaAssinador; + try + { + using (UnitOfWork read = InstanciaAssinador.Read) + { + parametrosAssinaturaAssinador = read.get_EmpresaRepository().FindByEmpresa(id); + } + } + catch (Exception exception) + { + parametrosAssinaturaAssinador = null; + } + return parametrosAssinaturaAssinador; + }); + return parametrosAssinaturaAssinador1; + } + + public async Task Reenviar(long indice) + { + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador; + AggerSigner aggerSigner = new AggerSigner(AssinadorHelper.Remetente); + using (UnitOfWork commited = InstanciaAssinador.Commited) + { + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador1 = commited.get_ArquivoParaAssinaturaRepository().FindByIndice(indice); + List nums = new List() + { + arquivoParaAssinaturaAssinador1.get_AssinaturaId() + }; + await aggerSigner.ReenviarParaAssinatura(nums, null); + AssinaturaLogAssinador assinaturaLogAssinador = new AssinaturaLogAssinador(); + assinaturaLogAssinador.set_Acao(1); + assinaturaLogAssinador.set_EntidadeId(arquivoParaAssinaturaAssinador1.get_Id()); + assinaturaLogAssinador.set_DataHora(Funcoes.GetNetworkTime()); + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador2 = arquivoParaAssinaturaAssinador1; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + assinaturaLogAssinador.set_Descricao(JsonConvert.SerializeObject(arquivoParaAssinaturaAssinador2, jsonSerializerSetting)); + assinaturaLogAssinador.set_UsuarioId(Recursos.Usuario.get_Id()); + assinaturaLogAssinador.set_Versao(ApplicationHelper.Versao.ToString()); + this.SaveLog(assinaturaLogAssinador, commited); + arquivoParaAssinaturaAssinador = arquivoParaAssinaturaAssinador1; + } + return arquivoParaAssinaturaAssinador; + } + + public async Task Save(ArquivoParaAssinaturaAssinador arquivo) + { + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador2 = await Task.Run(() => { + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador; + try + { + using (UnitOfWork commited = InstanciaAssinador.Commited) + { + arquivo = (arquivo.get_Id() == 0 ? commited.get_ArquivoParaAssinaturaRepository().SaveOrUpdate(arquivo) : commited.get_ArquivoParaAssinaturaRepository().Merge(arquivo)); + AssinaturaLogAssinador assinaturaLogAssinador = new AssinaturaLogAssinador(); + assinaturaLogAssinador.set_Acao(0); + assinaturaLogAssinador.set_EntidadeId(arquivo.get_Id()); + assinaturaLogAssinador.set_DataHora(Funcoes.GetNetworkTime()); + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador1 = arquivo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + assinaturaLogAssinador.set_Descricao(JsonConvert.SerializeObject(arquivoParaAssinaturaAssinador1, jsonSerializerSetting)); + assinaturaLogAssinador.set_UsuarioId(Recursos.Usuario.get_Id()); + assinaturaLogAssinador.set_Versao(ApplicationHelper.Versao.ToString()); + this.SaveLog(assinaturaLogAssinador, commited); + commited.Commit(); + arquivoParaAssinaturaAssinador = arquivo; + } + } + catch (Exception exception) + { + arquivoParaAssinaturaAssinador = null; + } + return arquivoParaAssinaturaAssinador; + }); + return arquivoParaAssinaturaAssinador2; + } + + internal async void SaveLog(AssinaturaLogAssinador keyValues, UnitOfWork unitOfWork) + { + if (keyValues != null) + { + try + { + unitOfWork.get_AssinaturaLogRepository().SaveOrUpdate(keyValues); + unitOfWork.Commit(); + } + catch (Exception exception) + { + } + } + } + + public async Task VerificarAssinado(long id) + { + bool flag1 = await Task.Run(() => { + bool flag; + using (UnitOfWork read = InstanciaAssinador.Read) + { + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador = read.get_ArquivoParaAssinaturaRepository().FindByIndice(id); + flag = (arquivoParaAssinaturaAssinador == null ? false : (arquivoParaAssinaturaAssinador.get_Status() == 1 ? true : arquivoParaAssinaturaAssinador.get_Status() == 2)); + } + return flag; + }); + return flag1; + } + + public async Task VerificarEnviado(long id) + { + bool flag1 = await Task.Run(() => { + bool flag; + using (UnitOfWork read = InstanciaAssinador.Read) + { + ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador = read.get_ArquivoParaAssinaturaRepository().FindByIndice(id); + flag = (arquivoParaAssinaturaAssinador == null ? false : arquivoParaAssinaturaAssinador.get_Status() == 0); + } + return flag; + }); + return flag1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/CepService.cs b/Codemerx/Gestor.Application/Servicos/CepService.cs new file mode 100644 index 0000000..f33d711 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/CepService.cs @@ -0,0 +1,161 @@ +using Agger.Registro; +using Gestor.Application.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Newtonsoft.Json.Linq; +using System; +using System.Diagnostics; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class CepService + { + private const string GuidGestor = "bbbf4f03-01fc-4300-b430-33e007753578"; + + public CepService() + { + } + + private static async Task Authorization() + { + 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 apiCep = Address.get_ApiCep(); + string[] strArrays = new string[] { "/auth" }; + Uri uri = apiCep.Append(strArrays); + HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(uri, 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; + } + + public async Task SearchDirect(string cep) + { + return await this.SearchDirectApiAgger(cep); + } + + public async Task SearchDirectApiAgger(string cep) + { + EnderecoBase enderecoBase; + string upper; + string str; + string upper1; + string str1; + string upper2; + try + { + string str2 = Gestor.Model.Helper.ValidationHelper.OnlyNumber(cep); + if (!Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(str2)) + { + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string str3 = await CepService.Authorization(); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str3)); + Uri apiCep = Address.get_ApiCep(); + string[] strArrays = new string[] { str2 }; + Uri uri = apiCep.Append(strArrays); + string str4 = await await httpClient.GetAsync(uri).get_Content().ReadAsStringAsync(); + JObject jObject = JObject.Parse(str4); + if (jObject == null || str4.Equals("Endereço não encontrado")) + { + enderecoBase = null; + } + else + { + EnderecoBase enderecoBase1 = new EnderecoBase(); + JToken item = jObject.get_Item("logradouro"); + if (item != null) + { + upper = item.ToString().ToUpper(); + } + else + { + upper = null; + } + enderecoBase1.set_Endereco(upper); + JToken jToken = jObject.get_Item("bairro"); + if (jToken != null) + { + str = jToken.ToString().ToUpper(); + } + else + { + str = null; + } + enderecoBase1.set_Bairro(str); + JToken item1 = jObject.get_Item("cidade"); + if (item1 != null) + { + upper1 = item1.ToString().ToUpper(); + } + else + { + upper1 = null; + } + enderecoBase1.set_Cidade(upper1); + JToken jToken1 = jObject.get_Item("estado"); + if (jToken1 != null) + { + str1 = jToken1.ToString().ToUpper(); + } + else + { + str1 = null; + } + enderecoBase1.set_Estado(str1); + JToken item2 = jObject.get_Item("cep"); + if (item2 != null) + { + upper2 = item2.ToString().ToUpper(); + } + else + { + upper2 = null; + } + enderecoBase1.set_Cep(upper2); + enderecoBase = enderecoBase1; + } + } + } + else + { + enderecoBase = null; + } + } + catch (Exception exception) + { + enderecoBase = null; + } + return enderecoBase; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs b/Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs new file mode 100644 index 0000000..d61518e --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs @@ -0,0 +1,464 @@ +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.Seguros; +using Gestor.Model.Validation; +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.Configuracoes +{ + public class ConfuguracoesServico : BaseServico + { + public ConfuguracoesServico() + { + } + + public async Task> Buscar() + { + int num = 3; + List configuracaoSistemas1 = await Task.Run>(() => { + List configuracaoSistemas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + configuracaoSistemas = read.get_ConfiguracaoRepository().BuscarConfiguracoes(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 297, num, null, true); + continue; + } + return configuracaoSistemas; + } + return null; + }); + return configuracaoSistemas1; + } + + public async Task> BuscarParametros(Relatorio relatorio) + { + int num = 3; + List parametrosRelatorios1 = await Task.Run>(() => { + List parametrosRelatorios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parametrosRelatorios = read.get_ParametrosRelatorioRepository().Find(Recursos.Usuario.get_Id(), relatorio); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 301, num, new { Id = Recursos.Usuario.get_Id(), relatorio = relatorio }, true); + continue; + } + return parametrosRelatorios; + } + return null; + }); + return parametrosRelatorios1; + } + + public List BuscarParametroTotalizacao(Relatorio relatorio) + { + List parametrosTotalizacaos; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parametrosTotalizacaos = read.get_ParametrosTotalizacaoRepository().Find(Recursos.Usuario.get_Id(), relatorio); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = base.Registrar(exception, 302, num, new { Id = Recursos.Usuario.get_Id(), relatorio = relatorio }, true); + continue; + } + return parametrosTotalizacaos; + } + return null; + } + + public async Task> BuscarParametroTotalizacaoAsync(Relatorio relatorio) + { + int num = 3; + List parametrosTotalizacaos1 = await Task.Run>(() => { + List parametrosTotalizacaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parametrosTotalizacaos = read.get_ParametrosTotalizacaoRepository().Find(Recursos.Usuario.get_Id(), relatorio); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 302, num, new { Id = Recursos.Usuario.get_Id(), relatorio = relatorio }, true); + continue; + } + return parametrosTotalizacaos; + } + return null; + }); + return parametrosTotalizacaos1; + } + + public async Task Excluir(ConfiguracaoSistema configuracao) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ConfiguracaoRepository().Delete(configuracao.get_Id()); + DateTime networkTime = Gestor.Application.Helpers.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.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A CONFIGURAÇÃO {2} ", Recursos.Usuario.get_Nome(), networkTime, Gestor.Model.Validation.Funcoes.GetDescription(configuracao.get_Configuracao()))); + registroLog.set_EntidadeId(configuracao.get_Id()); + registroLog.set_Tela(50); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = ConfuguracoesServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConfuguracoesServico.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, 298, num, configuracao, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Salvar(ConfiguracaoSistema configuracao) + { + int num = 3; + ConfiguracaoSistema configuracaoSistema2 = await Task.Run(() => { + ConfiguracaoSistema configuracaoSistema; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ConfiguracaoSistema configuracaoSistema1 = commited.get_ConfiguracaoRepository().SaveOrUpdate(configuracao); + DateTime networkTime = Gestor.Application.Helpers.Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(string.Format("O USUÁRIO {0} ADICIONOU, EM {1}, A CONFIGURAÇÃO {2} ", Recursos.Usuario.get_Nome(), networkTime, Gestor.Model.Validation.Funcoes.GetDescription(configuracaoSistema1.get_Configuracao()))); + registroLog.set_EntidadeId(configuracaoSistema1.get_Id()); + registroLog.set_Tela(50); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = ConfuguracoesServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConfuguracoesServico.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(); + configuracaoSistema = configuracaoSistema1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 298, num, configuracao, true); + continue; + } + return configuracaoSistema; + } + return configuracao; + }); + return configuracaoSistema2; + } + + public async Task Salvar(List parametrosSalvar, List parametrosDelete) + { + int num = 3; + DateTime networkTime = Gestor.Application.Helpers.Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + string str1; + while (num > 0) + { + try + { + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + using (UnitOfWork commited = Instancia.Commited) + { + foreach (ParametrosRelatorio parametrosRelatorio in parametrosSalvar) + { + if (parametrosRelatorio.get_IdUsuario() == 0) + { + parametrosRelatorio.set_Id((long)0); + parametrosRelatorio.set_IdUsuario(Recursos.Usuario.get_Id()); + } + parametrosRelatorio.set_Ordem(parametrosSalvar.IndexOf(parametrosRelatorio)); + TipoAcao tipoAcao = (parametrosRelatorio.get_Id() == 0 ? 0 : 1); + ParametrosRelatorio parametrosRelatorio1 = (parametrosRelatorio.get_Id() == 0 ? commited.get_ParametrosRelatorioRepository().SaveOrUpdate(parametrosRelatorio) : commited.get_ParametrosRelatorioRepository().Merge(parametrosRelatorio)); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(JsonConvert.SerializeObject(parametrosRelatorio1)); + registroLog.set_EntidadeId(parametrosRelatorio1.get_Id()); + registroLog.set_Tela(50); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_61 = ConfuguracoesServico.u003cu003ec.u003cu003e9__6_1; + if (u003cu003e9_61 == null) + { + u003cu003e9_61 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConfuguracoesServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_61); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + foreach (ParametrosRelatorio parametrosRelatorio2 in parametrosDelete) + { + if (parametrosRelatorio2.get_Id() == 0) + { + continue; + } + commited.get_ParametrosRelatorioRepository().Delete(parametrosRelatorio2.get_Id()); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(2); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + registroLog1.set_Descricao(JsonConvert.SerializeObject(parametrosRelatorio2)); + registroLog1.set_EntidadeId(parametrosRelatorio2.get_Id()); + registroLog1.set_Tela(50); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_62 = ConfuguracoesServico.u003cu003ec.u003cu003e9__6_2; + if (u003cu003e9_62 == null) + { + u003cu003e9_62 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConfuguracoesServico.u003cu003ec.u003cu003e9__6_2 = u003cu003e9_62; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_62); + if (pAddress1 != null) + { + str1 = pAddress1.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + base.SaveLog(registroLog1, commited); + } + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 303, num, parametrosSalvar, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task SalvarTotalizacoes(List parametrosSalvar, List parametrosDeletar) + { + int num = 3; + DateTime networkTime = Gestor.Application.Helpers.Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + string str1; + while (num > 0) + { + try + { + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + using (UnitOfWork commited = Instancia.Commited) + { + foreach (ParametrosTotalizacao parametrosTotalizacao in parametrosSalvar) + { + if (parametrosTotalizacao.get_IdUsuario() == 0) + { + parametrosTotalizacao.set_Id((long)0); + parametrosTotalizacao.set_IdUsuario(Recursos.Usuario.get_Id()); + } + parametrosTotalizacao.set_Ativa(true); + TipoAcao tipoAcao = (parametrosTotalizacao.get_Id() == 0 ? 0 : 1); + ParametrosTotalizacao parametrosTotalizacao1 = (parametrosTotalizacao.get_Id() == 0 ? commited.get_ParametrosTotalizacaoRepository().SaveOrUpdate(parametrosTotalizacao) : commited.get_ParametrosTotalizacaoRepository().Merge(parametrosTotalizacao)); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(JsonConvert.SerializeObject(parametrosTotalizacao1)); + registroLog.set_EntidadeId(parametrosTotalizacao1.get_Id()); + registroLog.set_Tela(50); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_71 = ConfuguracoesServico.u003cu003ec.u003cu003e9__7_1; + if (u003cu003e9_71 == null) + { + u003cu003e9_71 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConfuguracoesServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_71); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + foreach (ParametrosTotalizacao parametrosTotalizacao2 in parametrosDeletar) + { + if (parametrosTotalizacao2.get_Id() == 0) + { + continue; + } + commited.get_ParametrosTotalizacaoRepository().Delete(parametrosTotalizacao2.get_Id()); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(2); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + registroLog1.set_Descricao(JsonConvert.SerializeObject(parametrosTotalizacao2)); + registroLog1.set_EntidadeId(parametrosTotalizacao2.get_Id()); + registroLog1.set_Tela(50); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_72 = ConfuguracoesServico.u003cu003ec.u003cu003e9__7_2; + if (u003cu003e9_72 == null) + { + u003cu003e9_72 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ConfuguracoesServico.u003cu003ec.u003cu003e9__7_2 = u003cu003e9_72; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_72); + if (pAddress1 != null) + { + str1 = pAddress1.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + base.SaveLog(registroLog1, commited); + } + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 304, num, parametrosSalvar, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs new file mode 100644 index 0000000..24289ac --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs @@ -0,0 +1,281 @@ +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.Relatorios; +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.Ferramentas +{ + public class AdiantamentoServico : BaseServico + { + public AdiantamentoServico() + { + } + + public async Task> BuscarAdiantamentos(long id, bool concluido) + { + int num = 3; + List adiantamentos1 = await Task.Run>(() => { + List adiantamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + adiantamentos = read.get_AdiantamentoRepository().BuscarAdiantamentos(id, concluido); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 16, num, new { id = id, concluido = concluido }, true); + continue; + } + return adiantamentos; + } + return new List(); + }); + return adiantamentos1; + } + + public async Task> BuscarPorData(Filtros filtro, bool segundavia = false) + { + int num = 3; + List adiantamentos1 = await Task.Run>(() => { + List adiantamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + adiantamentos = read.get_AdiantamentoRepository().FindByDate(filtro.get_Inicio(), filtro.get_Fim(), filtro.get_Vendedores(), segundavia); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 15, num, filtro, true); + continue; + } + return adiantamentos; + } + return new List(); + }); + return adiantamentos1; + } + + public async Task Delete(Adiantamento adiantamento) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + object obj; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_AdiantamentoRepository().Delete(adiantamento.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, O PARCEIRO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", adiantamento.get_Id()), ", HISTÓRICO: '", null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(adiantamento.get_Historico()) ? "" : adiantamento.get_Historico() ?? ""); + strArrays[4] = "', DATA DO ADIANTAMENTO: '"; + DateTime? data = adiantamento.get_Data(); + if (!data.HasValue) + { + obj = ""; + } + else + { + data = adiantamento.get_Data(); + obj = (data.HasValue ? data.GetValueOrDefault().ToShortDateString() : null) ?? ""; + } + strArrays[5] = (string)obj; + strArrays[6] = "'"; + strArrays[7] = string.Format(", VALOR DO ADIANTAMENTO: 'R${0}'.", adiantamento.get_Valor()); + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(adiantamento.get_Id()); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_Tela(36); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = AdiantamentoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AdiantamentoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + 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, 210, num, adiantamento, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task GerarPagamento(List adiantamentos) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + await Task.Run(() => { + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + adiantamentos.ForEach((Adiantamento x) => { + string str; + Adiantamento adiantamento = commited.get_AdiantamentoRepository().FindById(x.get_Id()); + adiantamento.set_Pago(true); + adiantamento.set_Pagamento(new DateTime?(networkTime)); + adiantamento = commited.get_AdiantamentoRepository().Merge(adiantamento); + 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(adiantamento, jsonSerializerSetting)); + registroLog.set_EntidadeId(adiantamento.get_Id()); + registroLog.set_Tela(36); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_42 = AdiantamentoServico.u003cu003ec.u003cu003e9__4_2; + if (u003cu003e9_42 == null) + { + u003cu003e9_42 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AdiantamentoServico.u003cu003ec.u003cu003e9__4_2 = u003cu003e9_42; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_42); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + commited.Commit(); + break; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 194, num, adiantamentos, true); + } + } + }); + } + + public async Task Save(Adiantamento adiatamento) + { + int num = 3; + base.Sucesso = true; + Adiantamento adiantamento2 = adiatamento; + DateTime networkTime = Funcoes.GetNetworkTime(); + Adiantamento adiantamento3 = await Task.Run(() => { + Adiantamento adiantamento; + string str; + while (num > 0) + { + adiatamento = adiantamento2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (adiatamento.get_Id() == 0 ? 0 : 1); + adiatamento.set_Pagamento((adiatamento.get_Pago() ? new DateTime?(networkTime) : null)); + adiatamento = (adiatamento.get_Id() == 0 ? commited.get_AdiantamentoRepository().SaveOrUpdate(adiatamento) : commited.get_AdiantamentoRepository().Merge(adiatamento)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Adiantamento adiantamento1 = adiatamento; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(adiantamento1, jsonSerializerSetting)); + registroLog.set_EntidadeId(adiatamento.get_Id()); + registroLog.set_Tela(36); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = AdiantamentoServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AdiantamentoServico.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(); + adiantamento = adiatamento; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 209, num, adiatamento, true); + continue; + } + return adiantamento; + } + return adiantamento2; + }); + return adiantamento3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs new file mode 100644 index 0000000..d52af23 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs @@ -0,0 +1,257 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class AgendaServico : BaseServico + { + public AgendaServico() + { + } + + 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) + { + observableCollection = new ObservableCollection(read.get_AgendaEmailRepository().FindByAgendaId(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 108, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + 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) + { + observableCollection = new ObservableCollection(read.get_AgendaTelefoneRepository().FindByAgendaId(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 107, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task Delete(Agenda agenda) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_AgendaRepository().Delete(agenda.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}, O CONTATO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", agenda.get_Id()), ", NOME: '", (string.IsNullOrWhiteSpace(agenda.get_Nome()) ? "" : agenda.get_Nome() ?? ""), "', ENDEREÇO: '", agenda.get_Endereco(), ", ", agenda.get_Numero(), ", ", (string.IsNullOrWhiteSpace(agenda.get_Complemento()) ? "-" : agenda.get_Complemento() ?? ""), ", ", agenda.get_Bairro(), ", ", agenda.get_Cidade(), "/", agenda.get_Estado(), " - ", agenda.get_Cep(), "', OBSERVAÇÃO: '", (string.IsNullOrWhiteSpace(agenda.get_Observacao()) ? "" : agenda.get_Observacao() ?? ""), "'." })); + registroLog.set_EntidadeId(agenda.get_Id()); + registroLog.set_Tela(34); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = AgendaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AgendaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + 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, 216, num, agenda, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Agenda agenda) + { + int num = 3; + base.Sucesso = true; + Agenda agenda2 = agenda; + Agenda agenda3 = await Task.Run(() => { + Agenda agenda4; + List list; + List agendaEmails; + string str; + while (num > 0) + { + agenda = agenda2; + try + { + TipoAcao tipoAcao = (agenda.get_Id() == 0 ? 0 : 1); + ObservableCollection telefones = agenda.get_Telefones(); + if (telefones != null) + { + list = telefones.ToList(); + } + else + { + list = null; + } + List agendaTelefones = list; + ObservableCollection emails = agenda.get_Emails(); + if (emails != null) + { + agendaEmails = emails.ToList(); + } + else + { + agendaEmails = null; + } + List agendaEmails1 = agendaEmails; + agenda.set_Telefones(null); + agenda.set_Emails(null); + using (UnitOfWork commited = Instancia.Commited) + { + if (agenda.get_Id() != (long)0) + { + if (agendaTelefones != null) + { + agendaTelefones = commited.get_AgendaTelefoneRepository().Merge(agendaTelefones, agenda); + } + if (agendaEmails1 != null) + { + agendaEmails1 = commited.get_AgendaEmailRepository().Merge(agendaEmails1, agenda); + } + agenda = commited.get_AgendaRepository().Merge(agenda); + } + else + { + agenda = commited.get_AgendaRepository().SaveOrUpdate(agenda); + if (agendaTelefones != null) + { + agendaTelefones = commited.get_AgendaTelefoneRepository().Inserir(agendaTelefones, agenda); + } + if (agendaEmails1 != null) + { + agendaEmails1 = commited.get_AgendaEmailRepository().Inserir(agendaEmails1, agenda); + } + } + agenda.set_Telefones((agendaTelefones == null ? null : new ObservableCollection(agendaTelefones))); + agenda.set_Emails((agendaEmails1 == null ? null : new ObservableCollection(agendaEmails1))); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Agenda agenda1 = agenda; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(agenda1, jsonSerializerSetting)); + registroLog.set_EntidadeId(agenda.get_Id()); + registroLog.set_Tela(34); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = AgendaServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AgendaServico.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(); + agenda4 = agenda; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 215, num, agenda, true); + continue; + } + return agenda4; + } + return agenda2; + }); + return agenda3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs new file mode 100644 index 0000000..2e8887d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs @@ -0,0 +1,127 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Common.Helpers; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +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.Ferramentas +{ + internal class EmailServico : BaseServico + { + public EmailServico() + { + } + + internal async Task> BuscarEmail(string email) + { + int num = 3; + List clienteEmails1 = await Task.Run>(() => { + List clienteEmails; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clienteEmails = read.get_ClienteEmailRepository().FindEmailCliente(email, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 109, num, email, true); + continue; + } + return clienteEmails; + } + return new List(); + }); + return clienteEmails1; + } + + public async Task Delete(Credencial email) + { + 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(email.get_Id(), email.GetValorOriginal(), 17, 2)); + commited.get_CredencialRepository().Delete(email.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 218, num, email, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Credencial credencial) + { + int num = 3; + base.Sucesso = true; + Credencial credencial1 = credencial; + Credencial credencial2 = await Task.Run(() => { + Credencial credencial3; + bool flag; + List registroLogs = new List(); + credencial = credencial1; + while (num > 0) + { + credencial = credencial1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (credencial.get_Id() == 0 ? false : true); + credencial.set_Senha(EncryptionHelper.Encrypt(credencial.get_Senha())); + if (flag) + { + registroLogs.Add(base.CreateLog(credencial.get_Id(), credencial, 17)); + } + credencial = (credencial.get_Id() == 0 ? commited.get_CredencialRepository().SaveOrUpdate(credencial) : commited.get_CredencialRepository().Merge(credencial)); + if (!flag) + { + registroLogs.Add(base.CreateLog(credencial.get_Id(), credencial.GetValorOriginal(), 17, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + credencial3 = credencial; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 217, num, credencial, true); + continue; + } + return credencial3; + } + return credencial1; + }); + return credencial2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs new file mode 100644 index 0000000..4d6d354 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs @@ -0,0 +1,287 @@ +using ArquivoDigital.Infrastructure.Repository.Interface; +using ArquivoDigital.Infrastructure.UnitOfWork.Logic; +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.API; +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.Ferramentas +{ + internal class EmpresaServico : BaseServico + { + public EmpresaServico() + { + } + + public async void AtualizarLogoId(long id, string idLogo) + { + await Task.Run(() => { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + Empresa empresa = commited.get_EmpresaRepository().FindById(id); + empresa.set_LogoId(idLogo); + commited.get_EmpresaRepository().Merge(empresa); + commited.Commit(); + } + } + catch (Exception exception) + { + } + }); + } + + internal async Task BuscarEmpresaPorId(long id) + { + int num = 3; + Empresa empresa1 = await Task.Run(() => { + Empresa empresa; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + empresa = read.get_EmpresaRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 114, num, id, true); + continue; + } + return empresa; + } + return new Empresa(); + }); + return empresa1; + } + + internal async Task> BuscarEmpresas() + { + int num = 3; + List empresas1 = await Task.Run>(() => { + List empresas; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + empresas = read.get_EmpresaRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 113, num, null, true); + continue; + } + return empresas; + } + return new List(); + }); + return empresas1; + } + + public string BuscarSenhaAdm() + { + string str; + int num = 3; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + str = read.get_EmpresaRepository().BuscarSenhaAdm((long)1); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 115, num, null, true); + continue; + } + return str; + } + return null; + } + + public async Task ConsultaEspacoBancoInGb() + { + double num3 = await Task.Run(() => { + double num; + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + double num1 = read.get_EmpresaRepository().ConsultaEspacoBancoInGb(); + double num2 = 0; + try + { + foreach (ControleArquivoDigital controleArquivoDigital in read.get_IndiceArquivoDigitalRepository().BuscarBancos()) + { + if (controleArquivoDigital.get_Tabela().ToLower() == "arquivos") + { + continue; + } + try + { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(controleArquivoDigital.get_Catalogo()); + using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Gestor.Application.Helpers.ArquivoDigital.Read) + { + num2 += unitOfWork.get_ArquivoDigitalRepository().ConsultaEspacoBancoInGb(); + } + } + catch + { + } + } + } + catch + { + } + num = num1 + num2; + } + } + catch (Exception exception) + { + return 0; + } + return num; + }); + return num3; + } + + internal async Task Save(Customer customer) + { + int num = 3; + base.Sucesso = true; + Customer customer1 = customer; + Customer customer2 = await Task.Run(() => { + Customer customer3; + while (num > 0) + { + customer = customer1; + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + Empresa empresa = new Empresa(); + empresa.set_Nome(customer.get_Name()); + empresa.set_Documento(customer.get_Document()); + empresa.set_Bairro(customer.get_District()); + empresa.set_Cidade(customer.get_City()); + empresa.set_Complemento(customer.get_Adjunct()); + empresa.set_Numero(customer.get_Number()); + empresa.set_Cep(customer.get_PostCode()); + empresa.set_Estado(customer.get_State()); + empresa.set_Email(customer.get_Mail()); + empresa.set_PrimeiroPrefixo(customer.get_AreaCode()); + empresa.set_PrimeiroTelefone(customer.get_Phone()); + empresa.set_SegundoPrefixo(customer.get_SecondAreaCode()); + empresa.set_SegundoTelefone(customer.get_SecondPhone()); + empresa.set_Serial(ApplicationHelper.NumeroSerial); + empresa.set_Site(customer.get_Site()); + commited.get_EmpresaRepository().SaveOrUpdate(empresa); + commited.Commit(); + customer3 = customer; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 277, num, customer, true); + continue; + } + return customer3; + } + return customer1; + }); + return customer2; + } + + public async Task Save(Empresa empresa) + { + int num = 3; + base.Sucesso = true; + Empresa empresa2 = empresa; + Empresa empresa3 = await Task.Run(() => { + Empresa empresa4; + string str; + while (num > 0) + { + empresa = empresa2; + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (empresa.get_Id() == 0 ? 0 : 1); + empresa = (empresa.get_Id() == 0 ? commited.get_EmpresaRepository().SaveOrUpdate(empresa) : commited.get_EmpresaRepository().Merge(empresa)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (Recursos.Usuario.get_Id() != 0) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Empresa empresa1 = empresa; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(empresa1, jsonSerializerSetting)); + registroLog.set_EntidadeId(empresa.get_Id()); + registroLog.set_Tela(18); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_31 = EmpresaServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + EmpresaServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_31); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + commited.Commit(); + empresa4 = empresa; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 277, num, empresa, true); + continue; + } + return empresa4; + } + return empresa2; + }); + return empresa3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs new file mode 100644 index 0000000..413a361 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs @@ -0,0 +1,124 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class EstipulanteServico : BaseServico + { + public EstipulanteServico() + { + } + + internal async Task BuscarEstipulantePorId(long id) + { + int num = 3; + Estipulante estipulante1 = await Task.Run(() => { + Estipulante estipulante; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + estipulante = read.get_EstipulanteRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 110, num, id, true); + continue; + } + return estipulante; + } + return new Estipulante(); + }); + return estipulante1; + } + + public async Task Delete(Estipulante estipulante) + { + 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(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 2)); + commited.get_EstipulanteRepository().Delete(estipulante.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 220, num, estipulante, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Estipulante estipulante) + { + int num = 3; + base.Sucesso = true; + Estipulante estipulante1 = estipulante; + Estipulante estipulante2 = await Task.Run(() => { + Estipulante estipulante3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + estipulante = estipulante1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + estipulante.set_IdEmpresa(Recursos.Empresa.get_Id()); + flag = (estipulante.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante, 9)); + } + estipulante = (estipulante.get_Id() == 0 ? commited.get_EstipulanteRepository().SaveOrUpdate(estipulante) : commited.get_EstipulanteRepository().Merge(estipulante)); + if (!flag) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + estipulante3 = estipulante; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 219, num, estipulante, true); + continue; + } + return estipulante3; + } + return estipulante1; + }); + return estipulante2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs new file mode 100644 index 0000000..ac8cd9f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs @@ -0,0 +1,171 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +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.Ferramentas +{ + public class ImpostoServico : BaseServico + { + public ImpostoServico() + { + } + + public async Task> Buscar(bool? ativo) + { + int num = 3; + List impostos1 = await Task.Run>(() => { + List impostos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + impostos = read.get_ImpostoRepository().DefaultSelect(ativo); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 317, num, ativo, true); + continue; + } + return impostos; + } + return new List(); + }); + return impostos1; + } + + public async Task> BuscarPorRamo(long id) + { + int num = 3; + List impostos1 = await Task.Run>(() => { + List impostos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + impostos = read.get_ImpostoRepository().FindByRamo(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 317, num, id, true); + continue; + } + return impostos; + } + return new List(); + }); + return impostos1; + } + + public async Task> BuscarPorSeguradora(long id) + { + int num = 3; + List impostos1 = await Task.Run>(() => { + List impostos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + impostos = read.get_ImpostoRepository().FindBySeguradora(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 317, num, id, true); + continue; + } + return impostos; + } + return new List(); + }); + return impostos1; + } + + public async Task Salvar(Imposto imposto) + { + int num = 3; + Imposto imposto2 = await Task.Run(() => { + Imposto imposto3; + string str; + while (num > 0) + { + this.Sucesso = true; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (imposto.get_Id() == 0 ? 0 : 1); + Imposto imposto1 = (tipoAcao == null ? commited.get_ImpostoRepository().SaveOrUpdate(imposto) : commited.get_ImpostoRepository().Merge(imposto)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(imposto1, jsonSerializerSetting)); + registroLog.set_EntidadeId(imposto1.get_Id()); + registroLog.set_Tela(56); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_31 = ImpostoServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ImpostoServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_31); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + imposto3 = imposto1; + } + } + catch (Exception exception1) + { + Exception exception = exception1; + this.Sucesso = false; + num = base.Registrar(exception, 318, num, imposto, false); + continue; + } + return imposto3; + } + return imposto; + }); + return imposto2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs new file mode 100644 index 0000000..3cac6b8 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs @@ -0,0 +1,182 @@ +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.Relatorios; +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.Ferramentas +{ + internal class MetaSeguradoraServico : BaseServico + { + public MetaSeguradoraServico() + { + } + + public async Task> BuscarMetasSeguradoras(Filtros filtro) + { + int num = 3; + List metaSeguradoras1 = await Task.Run>(() => { + List metaSeguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + metaSeguradoras = read.get_MetaSeguradoraRepository().FindByMeta(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 284, num, filtro, true); + continue; + } + return metaSeguradoras; + } + return new List(); + }); + return metaSeguradoras1; + } + + public async Task Delete(MetaSeguradora meta) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_MetaSeguradoraRepository().Delete(meta.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 META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) })); + registroLog.set_EntidadeId(meta.get_Id()); + registroLog.set_Tela(31); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + 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, 223, num, meta, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(MetaSeguradora metaSeguradora) + { + int num = 3; + base.Sucesso = true; + MetaSeguradora metaSeguradora2 = metaSeguradora; + MetaSeguradora metaSeguradora3 = await Task.Run(() => { + MetaSeguradora metaSeguradora4; + string str; + while (num > 0) + { + metaSeguradora = metaSeguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (metaSeguradora.get_Id() == 0 ? 0 : 1); + metaSeguradora = (metaSeguradora.get_Id() == 0 ? commited.get_MetaSeguradoraRepository().SaveOrUpdate(metaSeguradora) : commited.get_MetaSeguradoraRepository().Merge(metaSeguradora)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + MetaSeguradora metaSeguradora1 = metaSeguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(metaSeguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(metaSeguradora.get_Id()); + registroLog.set_Tela(31); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaSeguradoraServico.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(); + metaSeguradora4 = metaSeguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 222, num, metaSeguradora, true); + continue; + } + return metaSeguradora4; + } + return metaSeguradora2; + }); + return metaSeguradora3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs new file mode 100644 index 0000000..5e30a23 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs @@ -0,0 +1,182 @@ +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.Relatorios; +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.Ferramentas +{ + internal class MetaVendedorServico : BaseServico + { + public MetaVendedorServico() + { + } + + public async Task> BuscarMetasVendedores(Filtros filtro) + { + int num = 3; + List metaVendedors1 = await Task.Run>(() => { + List metaVendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + metaVendedors = read.get_MetaVendedorRepository().FindByMeta(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 285, num, filtro, true); + continue; + } + return metaVendedors; + } + return new List(); + }); + return metaVendedors1; + } + + public async Task Delete(MetaVendedor meta) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_MetaVendedorRepository().Delete(meta.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 META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) })); + registroLog.set_EntidadeId(meta.get_Id()); + registroLog.set_Tela(30); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = MetaVendedorServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaVendedorServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + 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, 225, num, meta, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(MetaVendedor metaVendedor) + { + int num = 3; + base.Sucesso = true; + MetaVendedor metaVendedor2 = metaVendedor; + MetaVendedor metaVendedor3 = await Task.Run(() => { + MetaVendedor metaVendedor4; + string str; + while (num > 0) + { + metaVendedor = metaVendedor2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (metaVendedor.get_Id() == 0 ? 0 : 1); + metaVendedor = (metaVendedor.get_Id() == 0 ? commited.get_MetaVendedorRepository().SaveOrUpdate(metaVendedor) : commited.get_MetaVendedorRepository().Merge(metaVendedor)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + MetaVendedor metaVendedor1 = metaVendedor; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(metaVendedor1, jsonSerializerSetting)); + registroLog.set_EntidadeId(metaVendedor.get_Id()); + registroLog.set_Tela(30); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = MetaVendedorServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaVendedorServico.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(); + metaVendedor4 = metaVendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 224, num, metaVendedor, true); + continue; + } + return metaVendedor4; + } + return metaVendedor2; + }); + return metaVendedor3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs new file mode 100644 index 0000000..9ea8485 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs @@ -0,0 +1,176 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class NotaFiscalServico : BaseServico + { + public NotaFiscalServico() + { + } + + internal async Task> BuscarNotasFiscais() + { + int num = 3; + List notaFiscals1 = await Task.Run>(() => { + List notaFiscals; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + notaFiscals = read.get_NotaFiscalRepository().FindAll(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 312, num, null, true); + continue; + } + return notaFiscals; + } + return new List(); + }); + return notaFiscals1; + } + + public async Task> BuscarNotasFiscais(Filtros filtro) + { + int num = 3; + List notaFiscals1 = await Task.Run>(() => { + List notaFiscals; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + notaFiscals = read.get_NotaFiscalRepository().FindByDatas(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 315, num, filtro, true); + continue; + } + return notaFiscals; + } + return new List(); + }); + return notaFiscals1; + } + + internal async Task Cadatrada(long idExtrato) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_NotaFiscalRepository().FindByExtrato(idExtrato); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 315, num, idExtrato, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Delete(NotaFiscal notaFiscal) + { + 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(notaFiscal.get_Id(), notaFiscal.GetValorOriginal(), 55, 2)); + commited.get_NotaFiscalRepository().Delete(notaFiscal.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 314, num, notaFiscal, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task Save(NotaFiscal notaFiscal) + { + int num = 3; + base.Sucesso = true; + NotaFiscal notaFiscal1 = notaFiscal; + NotaFiscal notaFiscal2 = await Task.Run(() => { + NotaFiscal notaFiscal3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + notaFiscal = notaFiscal1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (notaFiscal.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(notaFiscal.get_Id(), notaFiscal, 55)); + } + notaFiscal = (notaFiscal.get_Id() == 0 ? commited.get_NotaFiscalRepository().SaveOrUpdate(notaFiscal) : commited.get_NotaFiscalRepository().Merge(notaFiscal)); + if (!flag) + { + registroLogs.Add(base.CreateLog(notaFiscal.get_Id(), notaFiscal.GetValorOriginal(), 55, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + notaFiscal3 = notaFiscal; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 313, num, notaFiscal, true); + continue; + } + return notaFiscal3; + } + return notaFiscal1; + }); + return notaFiscal2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs new file mode 100644 index 0000000..76fd16d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs @@ -0,0 +1,92 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class ProdutoServico : BaseServico + { + public ProdutoServico() + { + } + + internal async Task BuscarProdutoPorId(long id) + { + int num = 3; + Produto produto1 = await Task.Run(() => { + Produto produto; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + produto = read.get_ProdutoRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 116, num, id, true); + continue; + } + return produto; + } + return new Produto(); + }); + return produto1; + } + + public async Task Save(Produto produto) + { + int num = 3; + base.Sucesso = true; + Produto produto1 = produto; + Produto produto2 = await Task.Run(() => { + Produto produto3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + produto = produto1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (produto.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(produto.get_Id(), produto, 10)); + } + produto = (produto.get_Id() == 0 ? commited.get_ProdutoRepository().SaveOrUpdate(produto) : commited.get_ProdutoRepository().Merge(produto)); + if (!flag) + { + registroLogs.Add(base.CreateLog(produto.get_Id(), produto.GetValorOriginal(), 10, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + produto3 = produto; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 226, num, produto, true); + continue; + } + return produto3; + } + return produto1; + }); + return produto2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs new file mode 100644 index 0000000..5d7507b --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs @@ -0,0 +1,57 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class QualificacaoServico : BaseServico + { + public QualificacaoServico() + { + } + + internal async Task Save(Qualificacao qualificacao) + { + int num = 3; + base.Sucesso = true; + Qualificacao qualificacao2 = qualificacao; + Qualificacao qualificacao3 = await Task.Run(() => { + Qualificacao qualificacao4; + while (num > 0) + { + List registroLogs = new List(); + qualificacao = qualificacao2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(qualificacao.get_Id(), qualificacao, 48)); + Qualificacao qualificacao1 = commited.get_QualificacaoRepository().SaveOrUpdate(qualificacao); + base.SaveLog(registroLogs, commited); + commited.Commit(); + qualificacao4 = qualificacao1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 229, num, qualificacao, true); + continue; + } + return qualificacao4; + } + return qualificacao2; + }); + return qualificacao3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs new file mode 100644 index 0000000..a347e2c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.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.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.Ferramentas +{ + internal class RamoServico : BaseServico + { + public RamoServico() + { + } + + public async Task> BuscarRamos() + { + int num = 3; + List ramos1 = await Task.Run>(() => { + List ramos; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ramos = commited.get_RamoRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 169, num, null, true); + continue; + } + return ramos; + } + return null; + }); + return ramos1; + } + + public async Task Insert(Ramo ramo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Ramo ramo2 = ramo; + Ramo ramo3 = await Task.Run(() => { + Ramo ramo4; + string str; + while (num > 0) + { + ramo = ramo2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ramo = commited.get_RamoRepository().SaveOrUpdate(ramo); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Ramo ramo1 = ramo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(ramo1, jsonSerializerSetting)); + registroLog.set_EntidadeId(ramo.get_Id()); + registroLog.set_Tela(12); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = RamoServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + RamoServico.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(); + ramo4 = ramo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 230, num, ramo, true); + continue; + } + return ramo4; + } + return ramo2; + }); + return ramo3; + } + + internal async Task Save(Ramo ramo, List coberturas) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Ramo ramo3 = ramo; + Ramo ramo4 = await Task.Run(() => { + Ramo ramo5; + string str; + while (num > 0) + { + ramo = ramo3; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Ramo ramo1 = commited.get_RamoRepository().SaveOrUpdate(ramo); + List coberturaPadraos = coberturas; + if (coberturaPadraos != null) + { + coberturaPadraos.ForEach((CoberturaPadrao x) => commited.get_CoberturaPadraoRepository().Merge(x)); + } + else + { + } + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Ramo ramo2 = ramo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(ramo2, jsonSerializerSetting)); + registroLog.set_EntidadeId(ramo.get_Id()); + registroLog.set_Tela(12); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_02 = RamoServico.u003cu003ec.u003cu003e9__0_2; + if (u003cu003e9_02 == null) + { + u003cu003e9_02 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + RamoServico.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_02); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + ramo5 = ramo1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 228, num, new { ramo = ramo, coberturas = coberturas }, true); + continue; + } + return ramo5; + } + return ramo3; + }); + return ramo4; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs new file mode 100644 index 0000000..ceee657 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs @@ -0,0 +1,123 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class ReciboServico : BaseServico + { + public ReciboServico() + { + } + + internal async Task> BuscarRecibos() + { + int num = 3; + List recibos1 = await Task.Run>(() => { + List recibos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + recibos = read.get_ReciboRepository().BuscarRecibos(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 123, num, null, true); + continue; + } + return recibos; + } + return new List(); + }); + return recibos1; + } + + public async Task Delete(Recibo recibo) + { + 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(recibo.get_Id(), recibo.GetValorOriginal(), 42, 2)); + commited.get_ReciboRepository().Delete(recibo.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 232, num, recibo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Recibo recibo) + { + int num = 3; + base.Sucesso = true; + Recibo recibo1 = recibo; + Recibo recibo2 = await Task.Run(() => { + Recibo recibo3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + recibo = recibo1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (recibo.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(recibo.get_Id(), recibo, 42)); + } + recibo = (recibo.get_Id() == 0 ? commited.get_ReciboRepository().SaveOrUpdate(recibo) : commited.get_ReciboRepository().Merge(recibo)); + if (!flag) + { + registroLogs.Add(base.CreateLog(recibo.get_Id(), recibo.GetValorOriginal(), 42, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + recibo3 = recibo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 231, num, recibo, true); + continue; + } + return recibo3; + } + return recibo1; + }); + return recibo2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs new file mode 100644 index 0000000..fe44719 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs @@ -0,0 +1,372 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class SeguradoraServico : BaseServico + { + public SeguradoraServico() + { + } + + public async Task> BuscarAssistencias(long id) + { + int num = 3; + List seguradoraContatos1 = await Task.Run>(() => { + List seguradoraContatos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradoraContatos = read.get_SeguradoraContatoRepository().FindAssistencia(Recursos.Empresa.get_Id(), id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return seguradoraContatos; + } + return new List(); + }); + return seguradoraContatos1; + } + + internal async Task> BuscarConfig(long id) + { + int num = 3; + List configExtratoImports1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List configExtratoImports = read.get_ConfigExtratoImportRepository().FindBySeguradora(id); + Func u003cu003e9_21 = SeguradoraServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (ConfigExtratoImport x) => x.get_Descricao(); + SeguradoraServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + list = configExtratoImports.OrderBy(u003cu003e9_21).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 124, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return configExtratoImports1; + } + + public async Task> BuscarContatos(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoraContatos = read.get_SeguradoraContatoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id); + Func u003cu003e9_31 = SeguradoraServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (SeguradoraContato x) => x.get_NomeContato(); + SeguradoraServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + observableCollection = new ObservableCollection(seguradoraContatos.OrderBy(u003cu003e9_31)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarEnderecos(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoraEnderecos = read.get_SeguradoraEnderecoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id); + Func u003cu003e9_41 = SeguradoraServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (SeguradoraEndereco x) => x.get_Id(); + SeguradoraServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + observableCollection = new ObservableCollection(seguradoraEnderecos.OrderBy(u003cu003e9_41)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 126, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task BuscarSeguradora(long id) + { + int num = 3; + Seguradora seguradora1 = await Task.Run(() => { + Seguradora seguradora; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradora = read.get_SeguradoraRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 128, num, null, true); + continue; + } + return seguradora; + } + return new Seguradora(); + }); + return seguradora1; + } + + public async Task> BuscarSeguradoras() + { + int num = 3; + List seguradoras1 = await Task.Run>(() => { + List seguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradoras = read.get_SeguradoraRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 127, num, null, true); + continue; + } + return seguradoras; + } + return new List(); + }); + return seguradoras1; + } + + public async Task Insert(Seguradora seguradora) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Seguradora seguradora2 = seguradora; + Seguradora seguradora3 = await Task.Run(() => { + Seguradora seguradora4; + string str; + while (num > 0) + { + seguradora = seguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + seguradora = commited.get_SeguradoraRepository().SaveOrUpdate(seguradora); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Seguradora seguradora1 = seguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(seguradora.get_Id()); + registroLog.set_Tela(13); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = SeguradoraServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + SeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + seguradora4 = seguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 234, num, seguradora, true); + continue; + } + return seguradora4; + } + return seguradora2; + }); + return seguradora3; + } + + public async Task Save(Seguradora seguradora, List config, bool primeiroAcesso = false) + { + Action action2 = null; + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Seguradora seguradora2 = seguradora; + Seguradora seguradora3 = await Task.Run(() => { + Seguradora seguradora4; + string str; + while (num > 0) + { + seguradora = seguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (seguradora.get_Id() == 0 ? 0 : 1); + List contatos = seguradora.get_Contatos(); + if (contatos != null) + { + List seguradoraContatos = contatos; + Action u003cu003e9_1 = action2; + if (u003cu003e9_1 == null) + { + Action action = (SeguradoraContato x) => x.set_Seguradora(seguradora); + Action action1 = action; + action2 = action; + u003cu003e9_1 = action1; + } + seguradoraContatos.ForEach(u003cu003e9_1); + contatos = commited.get_SeguradoraContatoRepository().Merge(contatos, seguradora, Recursos.Empresa.get_Id()); + } + List enderecos = seguradora.get_Enderecos(); + if (contatos != null) + { + enderecos = commited.get_SeguradoraEnderecoRepository().Merge(enderecos, seguradora, Recursos.Empresa.get_Id()); + } + if (contatos != null | primeiroAcesso) + { + seguradora = commited.get_SeguradoraRepository().Merge(seguradora); + } + seguradora.set_Contatos(contatos); + seguradora.set_Enderecos(enderecos); + List configExtratoImports = config; + if (configExtratoImports != null) + { + configExtratoImports.ForEach((ConfigExtratoImport x) => commited.get_ConfigExtratoImportRepository().Merge(x)); + } + else + { + } + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Seguradora seguradora1 = seguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(seguradora.get_Id()); + registroLog.set_Tela(13); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_03 = SeguradoraServico.u003cu003ec.u003cu003e9__0_3; + if (u003cu003e9_03 == null) + { + u003cu003e9_03 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + SeguradoraServico.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_03); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + seguradora4 = seguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 233, num, new { seguradora = seguradora, config = config }, true); + continue; + } + return seguradora4; + } + return seguradora2; + }); + return seguradora3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs new file mode 100644 index 0000000..9b46d97 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs @@ -0,0 +1,97 @@ +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.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class SocioServico : BaseServico + { + public SocioServico() + { + } + + public async Task Delete(Socio socio) + { + 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(socio.get_Id(), socio.GetValorOriginal(), 19, 2)); + commited.get_SocioRepository().Delete(socio.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 236, num, socio, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Socio socio) + { + int num = 3; + base.Sucesso = true; + Socio socio1 = socio; + Socio socio2 = await Task.Run(() => { + Socio socio3; + bool flag; + List registroLogs = new List(); + socio = socio1; + while (num > 0) + { + socio = socio1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (socio.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(socio.get_Id(), socio, 19)); + } + socio = (socio.get_Id() == 0 ? commited.get_SocioRepository().SaveOrUpdate(socio) : commited.get_SocioRepository().Merge(socio)); + if (!flag) + { + registroLogs.Add(base.CreateLog(socio.get_Id(), socio.GetValorOriginal(), 19, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + socio3 = socio; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 235, num, socio, true); + continue; + } + return socio3; + } + return socio1; + }); + return socio2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs new file mode 100644 index 0000000..1af6770 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs @@ -0,0 +1,93 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class StatusProspeccaoServico : BaseServico + { + public StatusProspeccaoServico() + { + } + + internal async Task> BuscarProspeccoes() + { + int num = 3; + List statusDeProspeccaos1 = await Task.Run>(() => { + List statusDeProspeccaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + statusDeProspeccaos = read.get_StatusProspeccaoRepository().FindAll(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 308, num, null, true); + continue; + } + return statusDeProspeccaos; + } + return new List(); + }); + return statusDeProspeccaos1; + } + + internal async Task Save(StatusDeProspeccao statusProspeccao) + { + int num = 3; + base.Sucesso = true; + StatusDeProspeccao statusDeProspeccao1 = statusProspeccao; + StatusDeProspeccao statusDeProspeccao2 = await Task.Run(() => { + StatusDeProspeccao statusDeProspeccao; + bool flag; + List registroLogs = new List(); + statusProspeccao = statusDeProspeccao1; + while (num > 0) + { + statusProspeccao = statusDeProspeccao1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (statusProspeccao.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(statusProspeccao.get_Id(), statusProspeccao, 57)); + } + statusProspeccao = (statusProspeccao.get_Id() == 0 ? commited.get_StatusProspeccaoRepository().SaveOrUpdate(statusProspeccao) : commited.get_StatusProspeccaoRepository().Merge(statusProspeccao)); + if (!flag) + { + registroLogs.Add(base.CreateLog(statusProspeccao.get_Id(), statusProspeccao.GetValorOriginal(), 57, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + statusDeProspeccao = statusProspeccao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 307, num, statusProspeccao, true); + continue; + } + return statusDeProspeccao; + } + return statusDeProspeccao1; + }); + return statusDeProspeccao2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs new file mode 100644 index 0000000..88b146c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs @@ -0,0 +1,124 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class StatusServico : BaseServico + { + public StatusServico() + { + } + + internal async Task BuscarStatusPorId(long id) + { + int num = 3; + Status statu1 = await Task.Run(() => { + Status statu; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + statu = read.get_StatusRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 119, num, id, true); + continue; + } + return statu; + } + return new Status(); + }); + return statu1; + } + + public async Task Delete(Status status) + { + 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(status.get_Id(), status.GetValorOriginal(), 11, 2)); + commited.get_StatusRepository().Delete(status.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 221, num, status, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Status status) + { + int num = 3; + base.Sucesso = true; + Status statu1 = status; + Status statu2 = await Task.Run(() => { + Status statu; + bool flag; + List registroLogs = new List(); + status = statu1; + while (num > 0) + { + status = statu1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (status.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status, 11)); + } + status = (status.get_Id() == 0 ? commited.get_StatusRepository().SaveOrUpdate(status) : commited.get_StatusRepository().Merge(status)); + if (!flag) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status.GetValorOriginal(), 11, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + statu = status; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 227, num, status, true); + continue; + } + return statu; + } + return statu1; + }); + return statu2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs new file mode 100644 index 0000000..fa7c297 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs @@ -0,0 +1,93 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class TipoTarefaServico : BaseServico + { + public TipoTarefaServico() + { + } + + internal async Task> BuscarTarefas() + { + int num = 3; + List tipoDeTarefas1 = await Task.Run>(() => { + List tipoDeTarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tipoDeTarefas = read.get_TipoTarefaRepository().FindAll(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 308, num, null, true); + continue; + } + return tipoDeTarefas; + } + return new List(); + }); + return tipoDeTarefas1; + } + + internal async Task Save(TipoDeTarefa tipoTarefa) + { + int num = 3; + base.Sucesso = true; + TipoDeTarefa tipoDeTarefa1 = tipoTarefa; + TipoDeTarefa tipoDeTarefa2 = await Task.Run(() => { + TipoDeTarefa tipoDeTarefa; + bool flag; + List registroLogs = new List(); + tipoTarefa = tipoDeTarefa1; + while (num > 0) + { + tipoTarefa = tipoDeTarefa1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (tipoTarefa.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(tipoTarefa.get_Id(), tipoTarefa, 52)); + } + tipoTarefa = (tipoTarefa.get_Id() == 0 ? commited.get_TipoTarefaRepository().SaveOrUpdate(tipoTarefa) : commited.get_TipoTarefaRepository().Merge(tipoTarefa)); + if (!flag) + { + registroLogs.Add(base.CreateLog(tipoTarefa.get_Id(), tipoTarefa.GetValorOriginal(), 52, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + tipoDeTarefa = tipoTarefa; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 306, num, tipoTarefa, true); + continue; + } + return tipoDeTarefa; + } + return tipoDeTarefa1; + }); + return tipoDeTarefa2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs new file mode 100644 index 0000000..0757820 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs @@ -0,0 +1,131 @@ +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.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +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.Ferramentas +{ + internal class TipoVendedorServico : BaseServico + { + public TipoVendedorServico() + { + } + + public async Task Delete(TipoVendedor tipoVendedor) + { + 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(tipoVendedor.get_Id(), tipoVendedor.GetValorOriginal(), 14, 2)); + commited.get_TipoVendedorRepository().Delete(tipoVendedor.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 238, num, tipoVendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + 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_TipoVendedorRepository().FindLastId(); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 17, num1, null, true); + continue; + } + return num; + } + return (long)0; + }); + return num2; + } + + internal async Task Save(TipoVendedor tipoVendedor) + { + int num = 3; + base.Sucesso = true; + TipoVendedor tipoVendedor2 = tipoVendedor; + TipoVendedor tipoVendedor3 = await Task.Run(async () => { + TipoVendedor tipoVendedor4; + while (num > 0) + { + List registroLogs = new List(); + tipoVendedor = tipoVendedor2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (tipoVendedor.get_Id() == 0 ? 0 : 1); + if (tipoVendedor.get_Id() == 0) + { + TipoVendedor tipoVendedor1 = tipoVendedor; + tipoVendedor1.set_Id(await this.FindLastId() + (long)1); + tipoVendedor1 = null; + } + TipoAcao tipoAcao1 = tipoAcao; + if (tipoAcao1 == null) + { + registroLogs.Add(base.CreateLog(tipoVendedor.get_Id(), tipoVendedor.GetValorOriginal(), 14, 0)); + } + else if (tipoAcao1 == 1) + { + registroLogs.Add(base.CreateLog(tipoVendedor.get_Id(), tipoVendedor, 14)); + } + tipoVendedor = (tipoAcao == null ? commited.get_TipoVendedorRepository().SaveOrUpdate(tipoVendedor) : commited.get_TipoVendedorRepository().Merge(tipoVendedor)); + base.SaveLog(registroLogs, commited); + commited.Commit(); + tipoVendedor4 = tipoVendedor; + return tipoVendedor4; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 237, num, tipoVendedor, true); + } + registroLogs = null; + } + tipoVendedor4 = tipoVendedor2; + return tipoVendedor4; + }); + return tipoVendedor3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs new file mode 100644 index 0000000..5b04623 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs @@ -0,0 +1,303 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Common.Security; +using Gestor.Common.Validation; +using Gestor.Infrastructure.Mappers; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +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.Ferramentas +{ + internal class UsuarioServico : BaseServico + { + public UsuarioServico() + { + } + + 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 BuscarLogin(string login) + { + int num = 3; + Usuario usuario2 = await Task.Run(() => { + Usuario usuario; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + AuthSso result = base.VerificaUsuarioSso(login, empresa.get_Documento()).Result; + if (result == null || result.get_Code() == 401) + { + usuario = new Usuario(); + } + else + { + Usuario usuario1 = read.get_UsuarioRepository().FindUsuario(login); + usuario = (result.get_Code() == 404 ? usuario1 : CustomMap.FromUserSso(usuario1, result.get_Data().get_User())); + } + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 134, num, login, true); + continue; + } + return usuario; + } + return new Usuario(); + }); + return usuario2; + } + + public async Task> BuscarPermissaoAggilizador() + { + List permissaoAggilizadors2 = await Task.Run>(() => { + List permissaoAggilizadors; + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoAggilizadors = read.get_UsuarioRepository().PermissaoAggilizador(); + } + } + catch (Exception exception) + { + List permissaoAggilizadors1 = new List(); + PermissaoAggilizador permissaoAggilizador = new PermissaoAggilizador(); + permissaoAggilizador.set_Id((long)1); + permissaoAggilizador.set_Descricao("ADMINISTRADOR"); + permissaoAggilizadors1.Add(permissaoAggilizador); + PermissaoAggilizador permissaoAggilizador1 = new PermissaoAggilizador(); + permissaoAggilizador1.set_Id((long)2); + permissaoAggilizador1.set_Descricao("NORMAL"); + permissaoAggilizadors1.Add(permissaoAggilizador1); + PermissaoAggilizador permissaoAggilizador2 = new PermissaoAggilizador(); + permissaoAggilizador2.set_Id((long)3); + permissaoAggilizador2.set_Descricao("LIMITADO"); + permissaoAggilizadors1.Add(permissaoAggilizador2); + permissaoAggilizadors = permissaoAggilizadors1; + } + return permissaoAggilizadors; + }); + return permissaoAggilizadors2; + } + + internal async Task BuscarUsuarioPorId(long id) + { + int num = 3; + Usuario usuario1 = await Task.Run(() => { + Usuario usuario; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + usuario = read.get_UsuarioRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 130, num, id, true); + continue; + } + return usuario; + } + return new Usuario(); + }); + return usuario1; + } + + public async Task BuscaUsuarioInicial(string usuario, string senha) + { + Usuario usuario2 = await Task.Run(() => { + Usuario usuario3; + using (UnitOfWork read = Instancia.Read) + { + Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + string str = (new Token()).AggerEncrypt(senha); + AuthSso result = base.BuscaUsuarioSso(usuario, str, empresa.get_Documento()).Result; + if (result.get_Code() != 401) + { + Usuario usuario1 = read.get_UsuarioRepository().FindUsuario(usuario); + usuario3 = (result.get_Code() != 404 || usuario1 != null ? (result.get_Data() != null || usuario1 == null ? (usuario1 != null || result.get_Data() == null ? usuario1 : CustomMap.ToUsuario(result.get_Data().get_User(), empresa.get_Id())) : usuario1) : new Usuario()); + } + else + { + usuario3 = null; + } + } + return usuario3; + }); + return usuario2; + } + + public async Task Delete(Usuario usuario) + { + 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(usuario.get_Id(), usuario.GetValorOriginal(), 16, 2)); + commited.get_UsuarioRepository().Delete(usuario.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + usuario.set_TokenSso(Recursos.Usuario.get_TokenSso()); + base.DeleteUsuarioSso(usuario, Recursos.Empresa.get_Documento()).Wait(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 240, num, usuario, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Usuario usuario) + { + int num = 3; + base.Sucesso = true; + Usuario usuario5 = usuario; + Usuario usuario6 = await Task.Run(() => { + Usuario usuario7; + long? nullable; + string tokenSso; + string documento; + long? nullable1; + bool flag; + List registroLogs = new List(); + while (num > 0) + { + usuario = usuario5; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Usuario usuario1 = Recursos.Usuario; + if (usuario1 != null) + { + tokenSso = usuario1.get_TokenSso(); + } + else + { + tokenSso = null; + } + string token = tokenSso; + Empresa empresa = Recursos.Empresa; + if (empresa != null) + { + documento = empresa.get_Documento(); + } + else + { + documento = null; + } + string str = documento; + if (ValidationHelper.IsNullOrEmpty(token)) + { + Empresa empresa1 = commited.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + string senha = usuario.get_Senha(); + if (ValidationHelper.IsNotNullOrEmpty(usuario.get_SenhaAnterior())) + { + if ((new Token()).AggerDecrypt(usuario.get_SenhaAnterior()).ToUpper().Contains("AGGER@")) + { + Usuario result = this.BuscarLogin(usuario.get_Login()).Result; + usuario.set_SenhaAnterior(result.get_Senha()); + } + senha = usuario.get_SenhaAnterior(); + } + AuthSso authSso = base.BuscaUsuarioSso(usuario.get_Login(), senha, empresa1.get_Documento()).Result; + if (authSso == null || authSso.get_Code() == 401) + { + this.Sucesso = false; + usuario7 = usuario5; + return usuario7; + } + else + { + token = authSso.get_Data().get_Token(); + str = empresa1.get_Documento(); + } + } + Usuario usuario2 = usuario; + if (!usuario.get_PermissaoAggilizador().HasValue) + { + Usuario usuario3 = usuario; + long? nullable2 = new long?((long)2); + nullable = nullable2; + usuario3.set_PermissaoAggilizador(nullable2); + nullable1 = nullable; + } + else + { + Usuario usuario4 = usuario; + long? permissaoAggilizador = usuario.get_PermissaoAggilizador(); + nullable = permissaoAggilizador; + usuario4.set_PermissaoAggilizador(permissaoAggilizador); + nullable1 = nullable; + } + usuario2.set_PermissaoAggilizador(nullable1); + flag = (usuario.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(usuario.get_Id(), usuario, 16)); + } + usuario = (usuario.get_Id() == 0 ? commited.get_UsuarioRepository().SaveOrUpdate(usuario) : commited.get_UsuarioRepository().Merge(usuario)); + if (!flag) + { + registroLogs.Add(base.CreateLog(usuario.get_Id(), usuario.GetValorOriginal(), 16, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + usuario.set_TokenSso(token); + base.AddOrUpdateUsuarioSso(usuario, str, usuario.get_SsoId()).Wait(); + usuario7 = usuario; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 239, num, usuario, true); + continue; + } + return usuario7; + } + return usuario5; + }); + return usuario6; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs new file mode 100644 index 0000000..9c81d34 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs @@ -0,0 +1,851 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Common.Validation; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + public class VendedorServico : BaseServico + { + public VendedorServico() + { + } + + public async Task BuscarCorretora() + { + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorRepository().FindCorretora(); + } + } + catch (Exception exception) + { + vendedor = null; + } + return vendedor; + }); + return vendedor1; + } + + public async Task> BuscaRepasse(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByDocumentId(id); + Func u003cu003e9_31 = VendedorServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (VendedorParcela x) => x.get_TipoVendedor().get_Id(); + VendedorServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + list = vendedorParcelas.OrderBy(u003cu003e9_31).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 136, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task> BuscaRepasseParcela(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByParcela(id); + Func u003cu003e9_41 = VendedorServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (VendedorParcela x) => { + TipoVendedor tipoVendedor = x.get_TipoVendedor(); + if (tipoVendedor != null) + { + return new long?(tipoVendedor.get_Id()); + } + return null; + }; + VendedorServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + list = vendedorParcelas.OrderBy(u003cu003e9_41).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 137, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task> BuscaRepasses() + { + int num = 3; + List repasses1 = await Task.Run>(() => { + List repasses; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + repasses = read.get_RepasseRepository().DefaultSelect((long)0); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 142, num, null, true); + continue; + } + return repasses; + } + return new List(); + }); + return repasses1; + } + + public async Task> BuscaRepassesPorIdVendedor(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_RepasseRepository().FindByIdVendedor(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarPagos(Filtros filtro) + { + int num = 3; + List manutencaoPagamentos = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + list = read.get_VendedorParcelaRepository().FindByDate(filtro).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 80, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return manutencaoPagamentos; + } + + internal async Task> BuscarTelefonesAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorTelefones = read.get_VendedorTelefoneRepository().FindByVendedorId(id); + Func u003cu003e9_51 = VendedorServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = (VendedorTelefone x) => x.get_Nome(); + VendedorServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + observableCollection = new ObservableCollection(vendedorTelefones.OrderBy(u003cu003e9_51)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 138, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarVendedoresAtivosAsync() + { + int num = 3; + List vendedors2 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedors1 = read.get_VendedorRepository().Find(true, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_01 = VendedorServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (Vendedor x) => x.get_Nome(); + VendedorServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + vendedors = new List(vendedors1.OrderBy(u003cu003e9_01)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 135, num, null, true); + continue; + } + return vendedors; + } + return new List(); + }); + return vendedors2; + } + + public async Task> BuscarVendedorParcela(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List vendedorParcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedorParcelas = read.get_RepasseRepository().FindByIdRepasse(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, id, true); + continue; + } + return vendedorParcelas; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task BuscarVendedorParcelaCompleto(long id) + { + int num = 3; + VendedorParcela vendedorParcela1 = await Task.Run(() => { + VendedorParcela vendedorParcela; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedorParcela = read.get_VendedorParcelaRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 81, num, null, true); + continue; + } + return vendedorParcela; + } + return new VendedorParcela(); + }); + return vendedorParcela1; + } + + internal async Task BuscarVendedorPorId(long id) + { + int num = 3; + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 139, num, id, true); + continue; + } + return vendedor; + } + return new Vendedor(); + }); + return vendedor1; + } + + public async Task> BuscarVinculosCliente(long idCliente) + { + int num = 3; + List vendedors1 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + if (Recursos.Usuario.get_IdEmpresa() != (long)1) + { + Recursos.Usuario.get_IdEmpresa(); + } + vendedors = read.get_VendedorParcelaRepository().FindVinculoByIdCliente(idCliente); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, null, true); + continue; + } + return vendedors; + } + return null; + }); + return vendedors1; + } + + public async Task Delete(VinculoRepasse vinculo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_RepasseRepository().DeleteVinculo(vinculo.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + VinculoRepasse vinculoRepasse = vinculo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse, jsonSerializerSetting)); + registroLog.set_EntidadeId(vinculo.get_Id()); + registroLog.set_Tela(53); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_101 = VendedorServico.u003cu003ec.u003cu003e9__10_1; + if (u003cu003e9_101 == null) + { + u003cu003e9_101 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__10_1 = u003cu003e9_101; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_101); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 311, num, vinculo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Delete(Vendedor vendedor) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_VendedorRepository().Delete(vendedor.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, O VENDEDOR DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", vendedor.get_Id()), ", NOME: '", null, null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(vendedor.get_Nome()) ? "" : vendedor.get_Nome() ?? ""); + strArrays[4] = "', DOCUMENTO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(vendedor.get_Documento()) ? "" : vendedor.get_Documento() ?? ""); + strArrays[6] = "', BANCO: '"; + strArrays[7] = (vendedor.get_Banco() == null ? "" : vendedor.get_Banco().get_Nome() ?? ""); + strArrays[8] = "', CONTA: '"; + strArrays[9] = (string.IsNullOrWhiteSpace(vendedor.get_Conta()) ? "" : vendedor.get_Conta() ?? ""); + strArrays[10] = "'."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(15); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_131 = VendedorServico.u003cu003ec.u003cu003e9__13_1; + if (u003cu003e9_131 == null) + { + u003cu003e9_131 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__13_1 = u003cu003e9_131; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_131); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + RegistroLog registroLog3 = registroLog; + if (vendedor.get_Telefones() != null && vendedor.get_Telefones().Count != 0) + { + foreach (VendedorTelefone telefone in vendedor.get_Telefones()) + { + RegistroLog registroLog4 = registroLog3; + string descricao = registroLog4.get_Descricao(); + object[] objArray = new object[] { vendedor.get_Telefones().IndexOf(telefone), null, null, null }; + objArray[1] = (!telefone.get_Tipo().HasValue ? "-" : Gestor.Common.Validation.ValidationHelper.GetDescription(telefone.get_Tipo())); + objArray[2] = (string.IsNullOrWhiteSpace(telefone.get_Prefixo()) ? "" : telefone.get_Prefixo() ?? ""); + objArray[3] = (string.IsNullOrWhiteSpace(telefone.get_Numero()) ? "" : telefone.get_Numero() ?? ""); + registroLog4.set_Descricao(string.Concat(descricao, string.Format(", TELEFONE {0}: {1} ({2}) {3}", objArray))); + } + } + RegistroLog registroLog5 = registroLog3; + registroLog5.set_Descricao(string.Concat(registroLog5.get_Descricao(), ".")); + base.SaveLog(registroLog3, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 242, num, vendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Vendedor vendedor, Repasse repasse) + { + int num = 3; + base.Sucesso = true; + Vendedor vendedor1 = vendedor; + Vendedor vendedor2 = await Task.Run(() => { + Vendedor vendedor3; + while (num > 0) + { + vendedor = vendedor1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa())); + vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor); + repasse.set_Vendedor(vendedor); + repasse = commited.get_RepasseRepository().SaveOrUpdate(repasse); + commited.Commit(); + vendedor3 = vendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasse = repasse }, true); + continue; + } + return vendedor3; + } + return vendedor1; + }); + return vendedor2; + } + + public async Task Save(VinculoRepasse vinculo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + VinculoRepasse vinculoRepasse2 = await Task.Run(() => { + VinculoRepasse vinculoRepasse; + string str; + while (num > 0) + { + VinculoRepasse vinculoRepasse1 = vinculo; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (vinculoRepasse1.get_Id() == 0 ? 0 : 1); + vinculoRepasse1 = (tipoAcao == null ? commited.get_RepasseRepository().SaveOrUpdate(vinculoRepasse1) : commited.get_RepasseRepository().Merge(vinculoRepasse1)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vinculoRepasse1.get_Id()); + registroLog.set_Tela(53); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_91 = VendedorServico.u003cu003ec.u003cu003e9__9_1; + if (u003cu003e9_91 == null) + { + u003cu003e9_91 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_91); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + vinculoRepasse = vinculoRepasse1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 311, num, vinculo, true); + continue; + } + return vinculoRepasse; + } + return vinculo; + }); + return vinculoRepasse2; + } + + public async Task Save(Vendedor vendedor, List repasses) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Vendedor vendedor2 = vendedor; + Vendedor vendedor3 = await Task.Run(() => { + Vendedor vendedor4; + string str; + string str1; + while (num > 0) + { + vendedor = vendedor2; + try + { + List telefones = vendedor.get_Telefones(); + using (UnitOfWork commited = Instancia.Commited) + { + List repasses1 = repasses; + Func u003cu003e9_111 = VendedorServico.u003cu003ec.u003cu003e9__11_1; + if (u003cu003e9_111 == null) + { + u003cu003e9_111 = (Repasse r) => { + Ramo ramo = r.get_Ramo(); + if (ramo == null) + { + return false; + } + return ramo.get_Id() == (long)0; + }; + VendedorServico.u003cu003ec.u003cu003e9__11_1 = u003cu003e9_111; + } + foreach (Repasse repasse in repasses1.Where(u003cu003e9_111)) + { + repasse.set_Ramo(null); + } + bool id = vendedor.get_Id() == (long)0; + vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa())); + TipoAcao tipoAcao = (vendedor.get_Id() == 0 ? 0 : 1); + if (!id) + { + vendedor = commited.get_VendedorRepository().Merge(vendedor); + if (telefones != null) + { + telefones = commited.get_VendedorTelefoneRepository().Merge(telefones, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass in repasses) + { + if (repass.get_Id() != 0) + { + commited.get_RepasseRepository().Merge(repass); + } + else + { + commited.get_RepasseRepository().SaveOrUpdate(repass); + } + } + } + } + else + { + vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor); + if (telefones != null) + { + telefones = commited.get_VendedorTelefoneRepository().Inserir(telefones, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass1 in repasses) + { + repass1.set_Vendedor(vendedor); + commited.get_RepasseRepository().SaveOrUpdate(repass1); + } + } + } + vendedor.set_Telefones(telefones); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (Recursos.Usuario.get_Id() != 0) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Vendedor vendedor1 = vendedor; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vendedor1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(15); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_112 = VendedorServico.u003cu003ec.u003cu003e9__11_2; + if (u003cu003e9_112 == null) + { + u003cu003e9_112 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__11_2 = u003cu003e9_112; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_112); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + foreach (Repasse repasse1 in repasses) + { + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(tipoAcao); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); + jsonSerializerSetting1.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting1)); + registroLog1.set_EntidadeId(repasse1.get_Id()); + registroLog1.set_Tela(54); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_113 = VendedorServico.u003cu003ec.u003cu003e9__11_3; + if (u003cu003e9_113 == null) + { + u003cu003e9_113 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__11_3 = u003cu003e9_113; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_113); + if (pAddress1 != null) + { + str1 = pAddress1.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + base.SaveLog(registroLog1, commited); + } + } + commited.Commit(); + vendedor4 = vendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasses = repasses }, true); + continue; + } + return vendedor4; + } + return vendedor2; + }); + return vendedor3; + } + + public async Task Save(Repasse repasse) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Repasse repasse2 = repasse; + Repasse repasse3 = await Task.Run(() => { + Repasse repasse4; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + repasse2 = commited.get_RepasseRepository().Merge(repasse2); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Repasse repasse1 = repasse; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(repasse.get_Id()); + registroLog.set_Tela(54); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_121 = VendedorServico.u003cu003ec.u003cu003e9__12_1; + if (u003cu003e9_121 == null) + { + u003cu003e9_121 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__12_1 = u003cu003e9_121; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_121); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + repasse4 = repasse2; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { repasse = repasse }, true); + continue; + } + return repasse4; + } + return repasse; + }); + return repasse3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs new file mode 100644 index 0000000..68c9a50 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs @@ -0,0 +1,362 @@ +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.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class BancosContasServico : BaseServico + { + public BancosContasServico() + { + } + + public async Task> BuscarBancos() + { + int num = 3; + List bancosContas1 = await Task.Run>(() => { + List bancosContas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + bancosContas = read.get_BancosContasRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 145, num, null, true); + continue; + } + return bancosContas; + } + return new List(); + }); + return bancosContas1; + } + + public async Task BuscarSaldo(DateTime inicio, long id) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo = read.get_SaldoRepository().BuscarPorData(inicio, id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 151, num, new { inicio = inicio, id = id }, true); + continue; + } + return saldo; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task BuscarSaldoAberto(long id) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo = read.get_SaldoRepository().BuscarAberto(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 147, num, id, true); + continue; + } + return saldo; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task> BuscarSaldoAberto(List ids) + { + int num = 3; + List saldos2 = await Task.Run>(() => { + List saldos; + while (num > 0) + { + try + { + List saldos1 = new List(); + using (UnitOfWork read = Instancia.Read) + { + ids.ForEach((long id) => { + Saldo saldo = read.get_SaldoRepository().BuscarAberto(id); + if (saldo == null) + { + return; + } + saldos1.Add(saldo); + }); + } + saldos = saldos1; + } + catch (Exception exception) + { + num = base.Registrar(exception, 148, num, ids, true); + continue; + } + return saldos; + } + return new List(); + }); + return saldos2; + } + + public async Task BuscarSaldoInicial(long id) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo = read.get_SaldoRepository().BuscarPorMenorData(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 151, num, new { id = id }, true); + continue; + } + return saldo; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task> BuscarSaldos(long id) + { + int num = 3; + List saldos1 = await Task.Run>(() => { + List saldos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldos = read.get_SaldoRepository().BuscarPorConta(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 150, num, id, true); + continue; + } + return saldos; + } + return new List(); + }); + return saldos1; + } + + public async Task Delete(BancosContas bancosContas) + { + 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(bancosContas.get_Id(), bancosContas.GetValorOriginal(), 26, 2)); + commited.get_BancosContasRepository().Delete(bancosContas.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 246, num, bancosContas, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task DeleteSaldo(Saldo saldo) + { + 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(saldo.get_Id(), saldo.GetValorOriginal(), 26, 2)); + commited.get_SaldoRepository().Delete(saldo.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 248, num, saldo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FecharSaldo(Saldo saldo) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo2; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo2 = read.get_LancamentoRepository().FecharSaldo(saldo); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 149, num, saldo, true); + continue; + } + return saldo2; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task Save(BancosContas bancosContas) + { + int num = 3; + base.Sucesso = true; + BancosContas bancosConta1 = bancosContas; + BancosContas bancosConta2 = await Task.Run(() => { + BancosContas bancosConta; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + bancosContas = bancosConta1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (bancosContas.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas, 26)); + } + bancosContas = (bancosContas.get_Id() == 0 ? commited.get_BancosContasRepository().SaveOrUpdate(bancosContas) : commited.get_BancosContasRepository().Merge(bancosContas)); + if (!flag) + { + registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas.GetValorOriginal(), 26, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + bancosConta = bancosContas; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 245, num, bancosContas, true); + continue; + } + return bancosConta; + } + return bancosConta1; + }); + return bancosConta2; + } + + public async Task Save(Saldo saldo) + { + int num = 3; + base.Sucesso = true; + Saldo saldo1 = saldo; + Saldo saldo2 = await Task.Run(() => { + Saldo saldo3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + saldo = saldo1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (saldo.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(saldo.get_Conta().get_Id(), saldo, 26)); + } + saldo = (saldo.get_Id() == 0 ? commited.get_SaldoRepository().SaveOrUpdate(saldo) : commited.get_SaldoRepository().Merge(saldo)); + if (!flag) + { + registroLogs.Add(base.CreateLog(saldo.get_Conta().get_Id(), saldo.GetValorOriginal(), 26, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + saldo3 = saldo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 247, num, saldo, true); + continue; + } + return saldo3; + } + return saldo1; + }); + return saldo2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs new file mode 100644 index 0000000..7d16a58 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs @@ -0,0 +1,92 @@ +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.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class CentroServico : BaseServico + { + public CentroServico() + { + } + + public async Task> BuscarCentros() + { + int num = 3; + List centros1 = await Task.Run>(() => { + List centros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + centros = read.get_CentroRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 153, num, null, true); + continue; + } + return centros; + } + return new List(); + }); + return centros1; + } + + public async Task Save(Centro centro) + { + int num = 3; + base.Sucesso = true; + Centro centro1 = centro; + Centro centro2 = await Task.Run(() => { + Centro centro3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + centro = centro1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (centro.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(centro.get_Id(), centro, 29)); + } + centro = (centro.get_Id() == 0 ? commited.get_CentroRepository().SaveOrUpdate(centro) : commited.get_CentroRepository().Merge(centro)); + if (!flag) + { + registroLogs.Add(base.CreateLog(centro.get_Id(), centro.GetValorOriginal(), 29, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + centro3 = centro; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 249, num, centro, true); + continue; + } + return centro3; + } + return centro1; + }); + return centro2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs new file mode 100644 index 0000000..817dca0 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs @@ -0,0 +1,738 @@ +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.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Financeiro.Relatorios; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + public class FinanceiroServico : BaseServico + { + public FinanceiroServico() + { + } + + public async Task> AddRange(List lancamentos) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + List lancamentos1 = lancamentos; + List lancamentos2 = await Task.Run>(() => { + List lancamentos3; + while (num > 0) + { + List registroLogs = new List(); + lancamentos = lancamentos1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ControleFinanceiro controle = lancamentos.First().get_Controle(); + controle = (controle.get_Id() == 0 ? commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle) : commited.get_ControleFinanceiroRepository().Merge(controle)); + lancamentos.ForEach((Lancamento x) => { + x.set_Controle(controle); + x.set_DataLancamento(new DateTime?(networkTime)); + }); + lancamentos = commited.get_LancamentoRepository().AddRange(lancamentos); + lancamentos.ForEach((Lancamento x) => this.logs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 25, 0))); + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamentos3 = lancamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 279, num, lancamentos, true); + continue; + } + return lancamentos3; + } + return lancamentos1; + }); + return lancamentos2; + } + + public async Task> Atualizar(List lancamentos) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + List lancamentos1 = lancamentos; + List lancamentos2 = await Task.Run>(() => { + List lancamentos3; + while (num > 0) + { + List registroLogs = new List(); + lancamentos = lancamentos1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + lancamentos.ForEach((Lancamento lancamento) => { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento, 25)); + lancamento.set_Controle(commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle())); + lancamento = commited.get_LancamentoRepository().Merge(lancamento); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamentos3 = lancamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 280, num, lancamentos, true); + continue; + } + return lancamentos3; + } + return lancamentos1; + }); + return lancamentos2; + } + + public async Task> BuscarFechamento(FiltroFinanceiro filtro) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List lancamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamentos = read.get_LancamentoRepository().Fechamento(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 294, num, filtro, true); + continue; + } + return lancamentos; + } + return new List(); + }); + return lancamentos1; + } + + public async Task BuscarLancamento(long id, int parcela) + { + int num = 3; + Lancamento lancamento1 = await Task.Run(() => { + Lancamento lancamento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamento = read.get_LancamentoRepository().FindByControle(id, parcela); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 163, num, new { id = id, parcela = parcela }, true); + continue; + } + return lancamento; + } + return new Lancamento(); + }); + return lancamento1; + } + + public async Task BuscarLancamento(long id) + { + int num = 3; + Lancamento lancamento1 = await Task.Run(() => { + Lancamento lancamento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamento = read.get_LancamentoRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 164, num, id, true); + continue; + } + return lancamento; + } + return new Lancamento(); + }); + return lancamento1; + } + + public async Task> BuscarLancamentos(DateTime inicio, DateTime fim, StatusLancamento status) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().Find(inicio, fim, status); + Func u003cu003e9_41 = FinanceiroServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + list = lancamentos.OrderByDescending(u003cu003e9_41).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 160, num, new { inicio = inicio, fim = fim, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentos(DateTime inicio, DateTime fim, long conta) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindLancamentosByConta(inicio, fim, conta); + Func u003cu003e9_61 = FinanceiroServico.u003cu003ec.u003cu003e9__6_1; + if (u003cu003e9_61 == null) + { + u003cu003e9_61 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61; + } + list = lancamentos.OrderByDescending(u003cu003e9_61).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 165, num, new { inicio = inicio, fim = fim, conta = conta }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPersonalizados(DateTime inicio, DateTime fim, StatusLancamento status, FiltroLancamentoData filtrodata) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindPersonalizado(inicio, fim, status, filtrodata); + Func u003cu003e9_71 = FinanceiroServico.u003cu003ec.u003cu003e9__7_1; + if (u003cu003e9_71 == null) + { + u003cu003e9_71 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71; + } + list = lancamentos.OrderByDescending(u003cu003e9_71).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 160, num, new { inicio = inicio, fim = fim, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorBaixa(DateTime inicio, DateTime fim) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByBaixa(inicio, fim); + Func u003cu003e9_81 = FinanceiroServico.u003cu003ec.u003cu003e9__8_1; + if (u003cu003e9_81 == null) + { + u003cu003e9_81 = (Lancamento x) => x.get_Baixa(); + FinanceiroServico.u003cu003ec.u003cu003e9__8_1 = u003cu003e9_81; + } + list = lancamentos.OrderByDescending(u003cu003e9_81).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 161, num, new { inicio = inicio, fim = fim }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorConta(DateTime inicio, DateTime fim, long id) + { + int num = 3; + List extratoContas1 = await Task.Run>(() => { + List extratoContas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + extratoContas = read.get_LancamentoRepository().FindByConta(inicio, fim, id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 165, num, new { inicio = inicio, fim = fim, id = id }, true); + continue; + } + return extratoContas; + } + return new List(); + }); + return extratoContas1; + } + + public async Task> BuscarLancamentosPorControle(long id) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List lancamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamentos = read.get_LancamentoRepository().FindByControle(id, 2); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 158, num, new { id = id }, true); + continue; + } + return lancamentos; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorFornecedor(long id, StatusLancamento status) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByFornecedor(id, status); + Func u003cu003e9_11 = FinanceiroServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + list = lancamentos.OrderByDescending(u003cu003e9_11).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 157, num, new { id = id, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorFornecedor(long id, DateTime date, Sinal sinal) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByFornecedor(id, date, sinal); + Func u003cu003e9_21 = FinanceiroServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + list = lancamentos.OrderByDescending(u003cu003e9_21).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 157, num, new { id = id, date = date }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorLancamento(DateTime inicio, DateTime fim, StatusLancamento status) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByLancamento(inicio, fim, status); + Func u003cu003e9_51 = FinanceiroServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = (Lancamento x) => x.get_DataLancamento(); + FinanceiroServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + list = lancamentos.OrderByDescending(u003cu003e9_51).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 329, num, new { inicio = inicio, fim = fim, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorPagamento(DateTime inicio, DateTime fim) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByPagamento(inicio, fim); + Func u003cu003e9_91 = FinanceiroServico.u003cu003ec.u003cu003e9__9_1; + if (u003cu003e9_91 == null) + { + u003cu003e9_91 = (Lancamento x) => x.get_Pagamento(); + FinanceiroServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91; + } + list = lancamentos.OrderBy(u003cu003e9_91).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 162, num, new { inicio = inicio, fim = fim }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task Excluir(List lancamentos) + { + int num = 3; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + lancamentos.ForEach((Lancamento x) => { + registroLogs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 25, 2)); + if (commited.get_LancamentoRepository().FindByControle(x.get_Controle().get_Id(), 2).Count == 1) + { + commited.get_ControleFinanceiroRepository().Delete(x.get_Controle().get_Id()); + return; + } + x.get_Controle().set_Parcelas(x.get_Controle().get_Parcelas() - 1); + commited.get_ControleFinanceiroRepository().Merge(x.get_Controle()); + commited.get_LancamentoRepository().Delete(x.get_Id()); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 282, num, lancamentos, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Excluir(Lancamento lancamento) + { + int num = 3; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 2)); + if (commited.get_LancamentoRepository().FindByControle(lancamento.get_Controle().get_Id(), 2).Count != 1) + { + lancamento.get_Controle().set_Parcelas(lancamento.get_Controle().get_Parcelas() - 1); + commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle()); + commited.get_LancamentoRepository().Delete(lancamento.get_Id()); + } + else + { + commited.get_ControleFinanceiroRepository().Delete(lancamento.get_Controle().get_Id()); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 282, num, lancamento, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> IncluirRange(List lancamentos) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + List lancamentos1 = lancamentos; + List lancamentos2 = await Task.Run>(() => { + List lancamentos3; + while (num > 0) + { + List registroLogs = new List(); + lancamentos = lancamentos1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + lancamentos.ForEach((Lancamento lancamento) => { + lancamento.set_Controle(commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle())); + lancamento = commited.get_LancamentoRepository().SaveOrUpdate(lancamento); + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 0)); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamentos3 = lancamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 281, num, lancamentos, true); + continue; + } + return lancamentos3; + } + return lancamentos1; + }); + return lancamentos2; + } + + public async Task Save(Lancamento lancamento) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Lancamento lancamento1 = lancamento; + Lancamento lancamento2 = await Task.Run(() => { + Lancamento lancamento3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + lancamento = lancamento1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (lancamento.get_Id() == 0 ? false : true); + if (!flag) + { + lancamento.set_DataLancamento(new DateTime?(networkTime)); + } + if (flag) + { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento, 25)); + } + ControleFinanceiro controle = lancamento.get_Controle(); + controle = (controle.get_Id() == 0 ? commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle) : commited.get_ControleFinanceiroRepository().Merge(controle)); + lancamento.set_Controle(controle); + lancamento = (lancamento.get_Id() == 0 ? commited.get_LancamentoRepository().SaveOrUpdate(lancamento) : commited.get_LancamentoRepository().Merge(lancamento)); + if (!flag) + { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamento3 = lancamento; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 279, num, lancamento, true); + continue; + } + return lancamento3; + } + return lancamento1; + }); + return lancamento2; + } + + public async Task TemLancamentosPorFornecedor(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_LancamentoRepository().HasByFornecedor(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 154, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Transferir(Lancamento lancamentoOrigem, Lancamento lancamentoDestino) + { + int num = 3; + Lancamento lancamento = lancamentoOrigem; + Lancamento lancamento1 = lancamentoDestino; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + lancamentoOrigem = lancamento; + lancamentoDestino = lancamento1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ControleFinanceiro controle = lancamentoOrigem.get_Controle(); + controle = commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle); + lancamentoOrigem.set_Controle(controle); + lancamentoDestino.set_Controle(controle); + lancamentoOrigem = commited.get_LancamentoRepository().SaveOrUpdate(lancamentoOrigem); + lancamentoDestino = commited.get_LancamentoRepository().SaveOrUpdate(lancamentoDestino); + registroLogs.Add(base.CreateLog(lancamentoOrigem.get_Id(), lancamentoOrigem.GetValorOriginal(), 25, 0)); + registroLogs.Add(base.CreateLog(lancamentoDestino.get_Id(), lancamentoDestino.GetValorOriginal(), 25, 0)); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 283, num, new { lancamentoOrigem = lancamentoOrigem, lancamentoDestino = lancamentoDestino }, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs new file mode 100644 index 0000000..674f46a --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs @@ -0,0 +1,123 @@ +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.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + public class FornecedorServico : BaseServico + { + public FornecedorServico() + { + } + + public async Task> BuscarFornecedores() + { + int num = 3; + List fornecedors1 = await Task.Run>(() => { + List fornecedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + fornecedors = read.get_FornecedorRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 166, num, null, true); + continue; + } + return fornecedors; + } + return new List(); + }); + return fornecedors1; + } + + public async Task Delete(Fornecedor fornecedor) + { + 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(fornecedor.get_Id(), fornecedor.GetValorOriginal(), 24, 2)); + commited.get_FornecedorRepository().Delete(fornecedor.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 244, num, fornecedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Fornecedor fornecedor) + { + int num = 3; + base.Sucesso = true; + Fornecedor fornecedor1 = fornecedor; + Fornecedor fornecedor2 = await Task.Run(() => { + Fornecedor fornecedor3; + while (num > 0) + { + List registroLogs = new List(); + fornecedor = fornecedor1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (fornecedor.get_Id() == 0 ? 0 : 1); + if (tipoAcao == 1) + { + registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor, 24)); + } + fornecedor = (tipoAcao == null ? commited.get_FornecedorRepository().SaveOrUpdate(fornecedor) : commited.get_FornecedorRepository().Merge(fornecedor)); + if (tipoAcao == null) + { + registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor.GetValorOriginal(), 24, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + fornecedor3 = fornecedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 243, num, fornecedor, true); + continue; + } + return fornecedor3; + } + return fornecedor1; + }); + return fornecedor2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs new file mode 100644 index 0000000..9fc078a --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs @@ -0,0 +1,120 @@ +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.Financeiro; +using Gestor.Model.Domain.Generic; +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.Financeiro +{ + internal class PlanoServico : BaseServico + { + public PlanoServico() + { + } + + public async Task> BuscarPlanos() + { + int num = 3; + List planos1 = await Task.Run>(() => { + List planos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + planos = read.get_PlanosRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 167, num, null, true); + continue; + } + return planos; + } + return new List(); + }); + return planos1; + } + + public async Task Save(Plano plano) + { + int num = 3; + base.Sucesso = true; + Plano plano2 = plano; + Plano plano3 = await Task.Run(() => { + Plano plano4; + string str; + while (num > 0) + { + plano = plano2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (plano.get_Id() == 0 ? 0 : 1); + plano = (plano.get_Id() == 0 ? commited.get_PlanoRepository().SaveOrUpdate(plano) : commited.get_PlanoRepository().Merge(plano)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Plano plano1 = plano; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(plano1, jsonSerializerSetting)); + registroLog.set_EntidadeId(plano.get_Id()); + registroLog.set_Tela(27); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = PlanoServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PlanoServico.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(); + plano4 = plano; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 250, num, plano, true); + continue; + } + return plano4; + } + return plano2; + }); + return plano3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs new file mode 100644 index 0000000..b00efbe --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs @@ -0,0 +1,93 @@ +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.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class PlanosServico : BaseServico + { + public PlanosServico() + { + } + + internal async Task> BuscarPlanos() + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_PlanosRepository().Find()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 168, num, null, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task Save(Planos planos) + { + int num = 3; + base.Sucesso = true; + Planos plano1 = planos; + Planos plano2 = await Task.Run(() => { + Planos plano; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + planos = plano1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (planos.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(planos.get_Id(), planos, 28)); + } + planos = (planos.get_Id() == 0 ? commited.get_PlanosRepository().SaveOrUpdate(planos) : commited.get_PlanosRepository().Merge(planos)); + if (!flag) + { + registroLogs.Add(base.CreateLog(planos.get_Id(), planos.GetValorOriginal(), 28, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + plano = planos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 251, num, planos, true); + continue; + } + return plano; + } + return plano1; + }); + return plano2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs b/Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs new file mode 100644 index 0000000..1570e96 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs @@ -0,0 +1,2567 @@ +using Agger.Registro; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels; +using Gestor.Common.Security; +using Gestor.Common.Validation; +using Gestor.Infrastructure.Helpers; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Aggilizador; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections; +using System.Collections.Generic; +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.Threading.Tasks; + +namespace Gestor.Application.Servicos.Generic +{ + public class BaseServico + { + private const int UnathorizedSsoCode = 401; + + private const int NotFoundSsoCode = 404; + + public bool Sucesso + { + get; + set; + } + + public BaseServico() + { + } + + internal async Task AddOrUpdateUsuarioSso(Usuario usuario, string documentoEmpresa, string ssoId = null) + { + UserSso userSso; + HttpResponseMessage httpResponseMessage; + UserSso userSso1; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + Uri apiSso = Address.get_ApiSso(); + string[] strArrays = new string[] { "user" }; + Uri uri = apiSso.Append(strArrays); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", usuario.get_TokenSso())); + UserSso userSso2 = usuario.ToUserSso(ApplicationHelper.NumeroSerial, documentoEmpresa, ssoId); + httpResponseMessage = (userSso2.get_Id() != null ? await httpClient.PutAsync(uri, userSso2.ToHttpContent(null, "application/json")) : await httpClient.PostAsync(uri, userSso2.ToHttpContent(null, "application/json"))); + HttpResponseMessage httpResponseMessage1 = httpResponseMessage; + if (!httpResponseMessage1.get_IsSuccessStatusCode()) + { + userSso1 = null; + } + else + { + userSso1 = JsonConvert.DeserializeObject(await httpResponseMessage1.get_Content().ReadAsStringAsync()); + } + userSso = userSso1; + } + return userSso; + } + + public async Task ArquivoDigital() + { + int num = 3; + ControleArquivoDigital controleArquivoDigital1 = await Task.Run(() => { + ControleArquivoDigital controleArquivoDigital; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + controleArquivoDigital = read.get_IndiceArquivoDigitalRepository().BuscarBanco(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 188, num, null, true); + continue; + } + return controleArquivoDigital; + } + return new ControleArquivoDigital(); + }); + return controleArquivoDigital1; + } + + public async Task ArquivoDigital(string banco) + { + int num = 3; + ControleArquivoDigital controleArquivoDigital1 = await Task.Run(() => { + ControleArquivoDigital controleArquivoDigital; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + controleArquivoDigital = read.get_IndiceArquivoDigitalRepository().ConsultarBanco(banco); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 188, num, banco, true); + continue; + } + return controleArquivoDigital; + } + return new ControleArquivoDigital(); + }); + return controleArquivoDigital1; + } + + public async Task> ArquivoVinculo(List ids, TipoArquivoVinculo type) + { + int num = 3; + List arquivoVinculos1 = await Task.Run>(() => { + List arquivoVinculos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + arquivoVinculos = read.get_VinculoDocumentoRepository().BuscarArquivos(ids, type); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 293, num, null, true); + continue; + } + return arquivoVinculos; + } + return null; + }); + return arquivoVinculos1; + } + + private async Task AtualizarUsuarios() + { + bool count; + try + { + if (!Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(Recursos.Usuario.get_TokenSso())) + { + List userSsos = await this.BuscarUsuariosSso(); + List userSsos1 = userSsos; + if (userSsos1 != null) + { + count = userSsos1.Count == 0; + } + else + { + count = false; + } + if (count || userSsos == null) + { + return; + } + else + { + List usuarios = await this.BuscarUsuariosAsync(); + foreach (UserSso userSso in userSsos) + { + Usuario usuario = usuarios.FirstOrDefault((Usuario u) => { + if (u.get_SsoId() != null) + { + return userSso.get_Id() == u.get_SsoId(); + } + return u.get_Login() == userSso.get_Username(); + }); + if (usuario != null && (userSso.get_IsDeleted() != usuario.get_Excluido() || Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Password(), usuario.get_Senha()) || Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Name(), usuario.get_Nome()) || Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(userSso.get_Email()) && Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Email(), usuario.get_Email()) || Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(userSso.get_Document()) && Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Document(), usuario.get_Documento().Clear()) || Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(userSso.get_Phone()) && Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Phone(), string.Concat(usuario.get_Prefixo(), usuario.get_Telefone()).Clear()) || Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(usuario.get_SsoId()))) + { + string phone = userSso.get_Phone(); + usuario.set_Nome(userSso.get_Name()); + usuario.set_Documento(userSso.get_Document()); + if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(phone) && phone.Length > 3) + { + usuario.set_Prefixo(phone.Substring(0, 2)); + usuario.set_Telefone(phone.Substring(2, phone.Length - 2)); + } + usuario.set_Login(userSso.get_Username()); + usuario.set_Senha(userSso.get_Password()); + usuario.set_Email(userSso.get_Email()); + usuario.set_Excluido(userSso.get_IsDeleted()); + usuario.set_SsoId(userSso.get_Id()); + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_UsuarioRepository().Merge(usuario); + commited.Commit(); + } + } + if (usuario != null) + { + continue; + } + using (UnitOfWork read = Instancia.Read) + { + Empresa empresa = read.get_EmpresaRepository().FindByDocumento(userSso.get_CustomerDocument()); + Usuario usuario1 = new Usuario(); + usuario1.set_IdEmpresa(empresa.get_Id()); + usuario1.set_Nome(userSso.get_Name()); + usuario1.set_Documento(userSso.get_Document()); + usuario1.set_Login(userSso.get_Username()); + usuario1.set_Senha(userSso.get_Password()); + usuario1.set_Email(userSso.get_Email()); + usuario1.set_SsoId(userSso.get_Id()); + usuario1.set_Excluido(userSso.get_IsDeleted()); + usuario1.set_Administrador(false); + usuario1.set_PermissaoAggilizador(new long?((long)1)); + usuario = usuario1; + string str = userSso.get_Phone(); + if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str) && str.Length > 3) + { + usuario.set_Prefixo(str.Substring(0, 2)); + usuario.set_Telefone(str.Substring(2, str.Length - 2)); + } + } + using (UnitOfWork unitOfWork = Instancia.Commited) + { + unitOfWork.get_UsuarioRepository().SaveOrUpdate(usuario); + unitOfWork.Commit(); + } + } + userSsos = null; + } + } + else + { + return; + } + } + catch (Exception exception) + { + this.Registrar(exception, 239, 1, null, true); + } + } + + private static async Task AtualizaUsuariosSso(List usuarios) + { + List list; + List usuarios1 = usuarios; + IEnumerable excluido = + from usuario in usuarios1 + where !usuario.get_Excluido() + select usuario; + if (excluido != null) + { + list = excluido.ToList(); + } + else + { + list = null; + } + usuarios = list; + foreach (Usuario usuario1 in usuarios) + { + UserSso userSso = new UserSso(); + userSso.set_Name(usuario1.get_Nome()); + userSso.set_Username(usuario1.get_Login()); + userSso.set_Password(usuario1.get_Senha()); + userSso.set_Email(usuario1.get_Email()); + userSso.set_Phone(usuario1.get_Telefone()); + userSso.set_IsDeleted(usuario1.get_Excluido()); + userSso.set_Id(usuario1.get_SsoId()); + string documento = Recursos.Empresas.FirstOrDefault((Empresa x) => x.get_Id() == usuario1.get_IdEmpresa()).get_Documento(); + await (new BaseServico()).AddOrUpdateUsuarioSso(usuario1, documento, usuario1.get_SsoId()); + } + } + + public async Task BancosContasUtilizado(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_LancamentoRepository().BancosContasUtilizado(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 155, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task> BuscaCoberturas() + { + int num = 3; + List coberturaPadraos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List coberturaPadraos = read.get_CoberturaPadraoRepository().Find(); + Func u003cu003e9_511 = BaseServico.u003cu003ec.u003cu003e9__51_1; + if (u003cu003e9_511 == null) + { + u003cu003e9_511 = (CoberturaPadrao x) => x.get_Descricao(); + BaseServico.u003cu003ec.u003cu003e9__51_1 = u003cu003e9_511; + } + list = coberturaPadraos.OrderBy(u003cu003e9_511).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 58, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return coberturaPadraos1; + } + + public async Task> BuscarAdiantamentoAsync(Vendedor vendedor) + { + int num = 3; + List adiantamentos2 = await Task.Run>(() => { + List adiantamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List adiantamentos1 = read.get_AdiantamentoRepository().Find(vendedor.get_Id()); + Func u003cu003e9_371 = BaseServico.u003cu003ec.u003cu003e9__37_1; + if (u003cu003e9_371 == null) + { + u003cu003e9_371 = (Adiantamento x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__37_1 = u003cu003e9_371; + } + adiantamentos = new List(adiantamentos1.OrderBy(u003cu003e9_371)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 185, num, vendedor, true); + continue; + } + return adiantamentos; + } + return new List(); + }); + return adiantamentos2; + } + + public async Task> BuscarAgendasAsync() + { + int num = 3; + List agendas2 = await Task.Run>(() => { + List agendas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List agendas1 = read.get_AgendaRepository().Find(); + Func u003cu003e9_461 = BaseServico.u003cu003ec.u003cu003e9__46_1; + if (u003cu003e9_461 == null) + { + u003cu003e9_461 = (Agenda x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__46_1 = u003cu003e9_461; + } + agendas = new List(agendas1.OrderBy(u003cu003e9_461)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 129, num, null, true); + continue; + } + return agendas; + } + return new List(); + }); + return agendas2; + } + + internal async Task> BuscarAtividade(string value) + { + int num = 3; + List atividades1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List atividades = read.get_AtividadeRepository().Find(value); + Func u003cu003e9_161 = BaseServico.u003cu003ec.u003cu003e9__16_1; + if (u003cu003e9_161 == null) + { + u003cu003e9_161 = (Atividade x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__16_1 = u003cu003e9_161; + } + list = atividades.OrderBy(u003cu003e9_161).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 181, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return atividades1; + } + + internal async Task> BuscarBanco(string value) + { + int num = 3; + List bancos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List bancos = read.get_BancoRepository().Find(value); + Func u003cu003e9_171 = BaseServico.u003cu003ec.u003cu003e9__17_1; + if (u003cu003e9_171 == null) + { + u003cu003e9_171 = (Banco x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__17_1 = u003cu003e9_171; + } + list = bancos.OrderBy(u003cu003e9_171).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 144, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return bancos1; + } + + internal async Task> BuscarBancosContas(string value) + { + int num = 3; + List bancosContas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List bancosContas = read.get_BancosContasRepository().Find(value); + Func u003cu003e9_181 = BaseServico.u003cu003ec.u003cu003e9__18_1; + if (u003cu003e9_181 == null) + { + u003cu003e9_181 = (BancosContas x) => x.get_Descricao(); + BaseServico.u003cu003ec.u003cu003e9__18_1 = u003cu003e9_181; + } + list = bancosContas.OrderBy(u003cu003e9_181).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 146, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return bancosContas1; + } + + public async Task> BuscarCentroAsync() + { + int num = 3; + List centros1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List centros = read.get_CentroRepository().Find(); + Func u003cu003e9_601 = BaseServico.u003cu003ec.u003cu003e9__60_1; + if (u003cu003e9_601 == null) + { + u003cu003e9_601 = (Centro x) => x.get_Descricao(); + BaseServico.u003cu003ec.u003cu003e9__60_1 = u003cu003e9_601; + } + list = centros.OrderBy(u003cu003e9_601).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 153, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return centros1; + } + + internal async Task> BuscarClienteEmpresa(string value) + { + List clientes3; + if (!string.IsNullOrWhiteSpace(value)) + { + int num = 3; + clientes3 = await Task.Run>(() => { + List clientes; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List clientes1 = read.get_ClienteRepository().Find(value, (long)0, false, false); + Func u003cu003e9_731 = BaseServico.u003cu003ec.u003cu003e9__73_1; + if (u003cu003e9_731 == null) + { + u003cu003e9_731 = (Cliente x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__73_1 = u003cu003e9_731; + } + List list = clientes1.OrderBy(u003cu003e9_731).ToList(); + List clientes2 = read.get_EmpresaRepository().FindAsCliente(value); + Func u003cu003e9_732 = BaseServico.u003cu003ec.u003cu003e9__73_2; + if (u003cu003e9_732 == null) + { + u003cu003e9_732 = (Cliente x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__73_2 = u003cu003e9_732; + } + list.AddRange(clientes2.OrderBy(u003cu003e9_732).ToList()); + clientes = list; + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 29, num, value, true); + continue; + } + return clientes; + } + return new List(); + }); + } + else + { + clientes3 = new List(); + } + return clientes3; + } + + public async Task BuscarControle() + { + ControleArquivoDigital controleArquivoDigital1 = await Task.Run(() => { + ControleArquivoDigital controleArquivoDigital; + try + { + using (UnitOfWork read = Instancia.Read) + { + controleArquivoDigital = read.get_IndiceArquivoDigitalRepository().BuscarBanco(); + } + } + catch (Exception exception) + { + controleArquivoDigital = null; + } + return controleArquivoDigital; + }); + return controleArquivoDigital1; + } + + public async Task> BuscarCredenciais() + { + int num = 3; + List credencials1 = await Task.Run>(() => { + List credencials; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + credencials = read.get_CredencialRepository().Find(Recursos.Empresa.get_Id()); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 187, num, null, true); + continue; + } + return credencials; + } + return new List(); + }); + return credencials1; + } + + public async Task> BuscarDocumentosPorEstipulante(long id) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().BuscarDocumentoPorEstipulante(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 11, num, id, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarDocumentosPorStatus(long id) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_DocumentoRepository().BuscarDocumentoPorStatus(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 12, num, id, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + internal Empresa BuscarEmpresa(long id) + { + Empresa empresa; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + empresa = read.get_EmpresaRepository().FindById(id); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = this.Registrar(exception, 114, num, id, true); + continue; + } + return empresa; + } + return new Empresa(); + } + + public async Task> BuscarEmpresasAsync() + { + int num = 3; + List empresas2 = await Task.Run>(() => { + List empresas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List empresas1 = read.get_EmpresaRepository().Find((long)0); + Func u003cu003e9_251 = BaseServico.u003cu003ec.u003cu003e9__25_1; + if (u003cu003e9_251 == null) + { + u003cu003e9_251 = (Empresa x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__25_1 = u003cu003e9_251; + } + empresas = new List(empresas1.OrderBy(u003cu003e9_251)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 113, num, null, true); + continue; + } + return empresas; + } + return new List(); + }); + return empresas2; + } + + public async Task> BuscarEstipulante(string value) + { + int num = 3; + List estipulantes1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List estipulantes = read.get_EstipulanteRepository().Find(value, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_221 = BaseServico.u003cu003ec.u003cu003e9__22_1; + if (u003cu003e9_221 == null) + { + u003cu003e9_221 = (Estipulante x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221; + } + list = estipulantes.OrderBy(u003cu003e9_221).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 111, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return estipulantes1; + } + + public async Task> BuscarEstipulantes() + { + int num = 3; + List estipulantes1 = await Task.Run>(() => { + List estipulantes; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + Recursos.Estipulantes = read.get_EstipulanteRepository().Find(); + estipulantes = Recursos.Estipulantes; + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 186, num, null, true); + continue; + } + return estipulantes; + } + return Recursos.Estipulantes; + }); + return estipulantes1; + } + + public async Task> BuscarEstipulantesAsync() + { + int num = 3; + List estipulantes2 = await Task.Run>(() => { + List estipulantes; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List estipulantes1 = read.get_EstipulanteRepository().Find(); + Func u003cu003e9_231 = BaseServico.u003cu003ec.u003cu003e9__23_1; + if (u003cu003e9_231 == null) + { + u003cu003e9_231 = (Estipulante x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__23_1 = u003cu003e9_231; + } + estipulantes = new List(estipulantes1.OrderBy(u003cu003e9_231)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 112, num, null, true); + continue; + } + return estipulantes; + } + return new List(); + }); + return estipulantes2; + } + + internal async Task> BuscarFabricante(string value) + { + int num = 3; + List fabricantes1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List fabricantes = read.get_FabricanteRepository().Find(value); + Func u003cu003e9_191 = BaseServico.u003cu003ec.u003cu003e9__19_1; + if (u003cu003e9_191 == null) + { + u003cu003e9_191 = (Fabricante x) => x.get_Descricao(); + BaseServico.u003cu003ec.u003cu003e9__19_1 = u003cu003e9_191; + } + list = fabricantes.OrderBy(u003cu003e9_191).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 182, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return fabricantes1; + } + + public async Task> BuscarFornecedor(string value, bool ativo = false) + { + int num = 3; + List fornecedors1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List fornecedors = read.get_FornecedorRepository().Find(value, ativo); + Func u003cu003e9_631 = BaseServico.u003cu003ec.u003cu003e9__63_1; + if (u003cu003e9_631 == null) + { + u003cu003e9_631 = (Fornecedor x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__63_1 = u003cu003e9_631; + } + list = fornecedors.OrderBy(u003cu003e9_631).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 159, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return fornecedors1; + } + + public async Task> BuscarFornecedor() + { + int num = 3; + List fornecedors1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List fornecedors = read.get_FornecedorRepository().Find(); + Func u003cu003e9_641 = BaseServico.u003cu003ec.u003cu003e9__64_1; + if (u003cu003e9_641 == null) + { + u003cu003e9_641 = (Fornecedor x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__64_1 = u003cu003e9_641; + } + list = fornecedors.OrderBy(u003cu003e9_641).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 166, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return fornecedors1; + } + + public async Task> BuscarMetaSeguradoraAsync(Seguradora seguradora) + { + int num = 3; + List metaSeguradoras2 = await Task.Run>(() => { + List metaSeguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List metaSeguradoras1 = read.get_MetaSeguradoraRepository().Find(seguradora.get_Id()); + Func u003cu003e9_381 = BaseServico.u003cu003ec.u003cu003e9__38_1; + if (u003cu003e9_381 == null) + { + u003cu003e9_381 = (MetaSeguradora x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__38_1 = u003cu003e9_381; + } + metaSeguradoras = new List(metaSeguradoras1.OrderBy(u003cu003e9_381)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 184, num, seguradora, true); + continue; + } + return metaSeguradoras; + } + return new List(); + }); + return metaSeguradoras2; + } + + public async Task> BuscarMetaVendedorAsync(Vendedor vendedor) + { + int num = 3; + List metaVendedors2 = await Task.Run>(() => { + List metaVendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List metaVendedors1 = read.get_MetaVendedorRepository().Find(vendedor.get_Id()); + Func u003cu003e9_361 = BaseServico.u003cu003ec.u003cu003e9__36_1; + if (u003cu003e9_361 == null) + { + u003cu003e9_361 = (MetaVendedor x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__36_1 = u003cu003e9_361; + } + metaVendedors = new List(metaVendedors1.OrderBy(u003cu003e9_361)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 183, num, vendedor, true); + continue; + } + return metaVendedors; + } + return new List(); + }); + return metaVendedors2; + } + + public async Task> BuscarParceirosAsync() + { + int num = 3; + List parceiros2 = await Task.Run>(() => { + List parceiros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List parceiros1 = read.get_ParceiroRepository().Find(); + Func u003cu003e9_351 = BaseServico.u003cu003ec.u003cu003e9__35_1; + if (u003cu003e9_351 == null) + { + u003cu003e9_351 = (Parceiro x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__35_1 = u003cu003e9_351; + } + parceiros = new List(parceiros1.OrderBy(u003cu003e9_351)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 72, num, null, true); + continue; + } + return parceiros; + } + return new List(); + }); + return parceiros2; + } + + public async Task BuscarParcelaPendente(long id) + { + int num = 3; + ParcelaPendente parcelaPendente1 = await Task.Run(() => { + ParcelaPendente parcelaPendente; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parcelaPendente = read.get_ParcelaRepository().BuscarPendencia(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 299, num, id, true); + continue; + } + return parcelaPendente; + } + return null; + }); + return parcelaPendente1; + } + + public async Task> BuscarPlanoAsync() + { + int num = 3; + List planos2 = await Task.Run>(() => { + List planos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List planos1 = read.get_PlanoRepository().Find(); + Func u003cu003e9_611 = BaseServico.u003cu003ec.u003cu003e9__61_1; + if (u003cu003e9_611 == null) + { + u003cu003e9_611 = (Plano x) => x.get_Descricao(); + BaseServico.u003cu003ec.u003cu003e9__61_1 = u003cu003e9_611; + } + planos = new List(planos1.OrderBy(u003cu003e9_611)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 167, num, null, true); + continue; + } + return planos; + } + return new List(); + }); + return planos2; + } + + public async Task> BuscarPlanosAsync() + { + int num = 3; + List planos1 = await Task.Run>(() => { + List planos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + planos = new List(read.get_PlanosRepository().Find()); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 168, num, null, true); + continue; + } + return planos; + } + return new List(); + }); + return planos1; + } + + public async Task> BuscarProduto(string value) + { + int num = 3; + List produtos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List produtos = read.get_ProdutoRepository().Find(value); + Func u003cu003e9_411 = BaseServico.u003cu003ec.u003cu003e9__41_1; + if (u003cu003e9_411 == null) + { + u003cu003e9_411 = (Produto x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__41_1 = u003cu003e9_411; + } + list = produtos.OrderBy(u003cu003e9_411).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 117, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return produtos1; + } + + public async Task> BuscarProdutosAsync() + { + int num = 3; + List produtos2 = await Task.Run>(() => { + List produtos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List produtos1 = read.get_ProdutoRepository().Find(); + Func u003cu003e9_491 = BaseServico.u003cu003ec.u003cu003e9__49_1; + if (u003cu003e9_491 == null) + { + u003cu003e9_491 = (Produto x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__49_1 = u003cu003e9_491; + } + produtos = new List(produtos1.OrderBy(u003cu003e9_491)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 118, num, null, true); + continue; + } + return produtos; + } + return new List(); + }); + return produtos2; + } + + internal async Task> BuscarProfissao(string value) + { + int num = 3; + List profissaos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List profissaos = read.get_ProfissaoRepository().Find(value); + Func u003cu003e9_151 = BaseServico.u003cu003ec.u003cu003e9__15_1; + if (u003cu003e9_151 == null) + { + u003cu003e9_151 = (Profissao x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151; + } + list = profissaos.OrderBy(u003cu003e9_151).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 180, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return profissaos1; + } + + public async Task BuscarQualificacaoAsync() + { + int num = 3; + Qualificacao qualificacao1 = await Task.Run(() => { + Qualificacao qualificacao; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + qualificacao = read.get_QualificacaoRepository().FindById((long)1); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 170, num, null, true); + continue; + } + return qualificacao; + } + return new Qualificacao(); + }); + return qualificacao1; + } + + public async Task> BuscarRamosAsync() + { + int num = 3; + List ramos2 = await Task.Run>(() => { + List ramos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List ramos1 = read.get_RamoRepository().Find(); + Func u003cu003e9_431 = BaseServico.u003cu003ec.u003cu003e9__43_1; + if (u003cu003e9_431 == null) + { + u003cu003e9_431 = (Ramo x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__43_1 = u003cu003e9_431; + } + ramos = new List(ramos1.OrderBy(u003cu003e9_431)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 169, num, null, true); + continue; + } + return ramos; + } + return new List(); + }); + return ramos2; + } + + public async Task> BuscarSeguradorasAsync() + { + int num = 3; + List seguradoras2 = await Task.Run>(() => { + List seguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoras1 = read.get_SeguradoraRepository().Find(); + Func u003cu003e9_451 = BaseServico.u003cu003ec.u003cu003e9__45_1; + if (u003cu003e9_451 == null) + { + u003cu003e9_451 = (Seguradora x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__45_1 = u003cu003e9_451; + } + seguradoras = new List(seguradoras1.OrderBy(u003cu003e9_451)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 127, num, null, true); + continue; + } + return seguradoras; + } + return new List(); + }); + return seguradoras2; + } + + public async Task> BuscarSociosAsync(long id) + { + int num = 3; + List socios1 = await Task.Run>(() => { + List socios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + socios = read.get_SocioRepository().FindByEmpresa(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 122, num, id, true); + continue; + } + return socios; + } + return new List(); + }); + return socios1; + } + + public async Task> BuscarStatus(string value) + { + int num = 3; + List statuses1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List statuses = read.get_StatusRepository().Find(value); + Func u003cu003e9_421 = BaseServico.u003cu003ec.u003cu003e9__42_1; + if (u003cu003e9_421 == null) + { + u003cu003e9_421 = (Status x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__42_1 = u003cu003e9_421; + } + list = statuses.OrderBy(u003cu003e9_421).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 120, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return statuses1; + } + + public async Task> BuscarStatusAsync() + { + int num = 3; + List statuses2 = await Task.Run>(() => { + List statuses; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List statuses1 = read.get_StatusRepository().Find(); + Func u003cu003e9_501 = BaseServico.u003cu003ec.u003cu003e9__50_1; + if (u003cu003e9_501 == null) + { + u003cu003e9_501 = (Status x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__50_1 = u003cu003e9_501; + } + statuses = new List(statuses1.OrderBy(u003cu003e9_501)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 121, num, null, true); + continue; + } + return statuses; + } + return new List(); + }); + return statuses2; + } + + public async Task> BuscarTipoVendedoresAsync() + { + int num = 3; + List tipoVendedors1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List tipoVendedors = read.get_TipoVendedorRepository().Find(); + Func u003cu003e9_481 = BaseServico.u003cu003ec.u003cu003e9__48_1; + if (u003cu003e9_481 == null) + { + u003cu003e9_481 = (TipoVendedor x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__48_1 = u003cu003e9_481; + } + list = tipoVendedors.OrderBy(u003cu003e9_481).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 141, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return tipoVendedors1; + } + + internal async Task> BuscarUsuario(string value) + { + int num = 3; + List usuarios1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List usuarios = read.get_UsuarioRepository().Find(value, (long)0); + Func u003cu003e9_271 = BaseServico.u003cu003ec.u003cu003e9__27_1; + if (u003cu003e9_271 == null) + { + u003cu003e9_271 = (Usuario x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__27_1 = u003cu003e9_271; + } + list = usuarios.OrderBy(u003cu003e9_271).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 132, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return usuarios1; + } + + internal async Task BuscarUsuario(string login, string password) + { + int num = 3; + string str = (new Token()).AggerEncrypt(password); + Usuario usuario2 = await Task.Run(() => { + Usuario usuario; + Usuario usuario1; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + AuthSso result = this.BuscaUsuarioSso(login, str, empresa.get_Documento()).Result; + if (result == null || result.get_Code() == 401) + { + usuario1 = null; + } + else if (result.get_Code() != 404) + { + usuario = read.get_UsuarioRepository().SsoId(result) ?? read.get_UsuarioRepository().FindFromSso(result.get_Data().get_User()); + if (usuario != null) + { + if (usuario.get_Excluido()) + { + using (UnitOfWork commited = Instancia.Commited) + { + usuario.set_Excluido(false); + commited.get_UsuarioRepository().Merge(usuario); + commited.Commit(); + } + } + usuario.set_TokenSso(result.get_Data().get_Token()); + if (!Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(usuario.get_SsoId()) || !usuario.get_SsoId().Equals(result.get_Data().get_User().get_Id())) + { + using (UnitOfWork unitOfWork = Instancia.Commited) + { + usuario.set_SsoId(result.get_Data().get_User().get_Id()); + unitOfWork.get_UsuarioRepository().Merge(usuario); + unitOfWork.Commit(); + } + usuario1 = usuario; + } + else + { + usuario1 = usuario; + } + } + else + { + using (UnitOfWork commited1 = Instancia.Commited) + { + usuario = commited1.get_UsuarioRepository().AddUsuarioFromSso(result.get_Data().get_User()); + commited1.Commit(); + } + usuario.set_TokenSso(result.get_Data().get_Token()); + usuario1 = usuario; + } + } + else + { + usuario = read.get_UsuarioRepository().ValidateLogin(login, str); + if (usuario != null) + { + usuario.set_TokenSso(result.get_Data().get_Token()); + UserSso userSso = this.AddOrUpdateUsuarioSso(usuario, empresa.get_Documento(), null).Result; + if (userSso != null) + { + using (UnitOfWork unitOfWork1 = Instancia.Commited) + { + usuario.set_SsoId(userSso.get_Id()); + unitOfWork1.get_UsuarioRepository().Merge(usuario); + unitOfWork1.Commit(); + } + usuario.set_TokenSso(this.BuscaUsuarioSso(login, str, empresa.get_Documento()).Result.get_Data().get_Token()); + usuario1 = usuario; + } + else + { + usuario1 = usuario; + } + } + else + { + usuario1 = null; + } + } + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 134, num, null, true); + continue; + } + return usuario1; + } + return new Usuario(); + }); + return usuario2; + } + + internal async Task BuscarUsuarioMesmoDocumento(string value, long id, long idempresa) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_UsuarioRepository().FindDocUsedByDocumento(value, id, idempresa); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 134, num, value, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task> BuscarUsuarioPorLoginInteiro(string value) + { + int num = 3; + List usuarios1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List usuarios = read.get_UsuarioRepository().FindByLoginInteiro(value); + Func u003cu003e9_391 = BaseServico.u003cu003ec.u003cu003e9__39_1; + if (u003cu003e9_391 == null) + { + u003cu003e9_391 = (Usuario x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__39_1 = u003cu003e9_391; + } + list = usuarios.OrderBy(u003cu003e9_391).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 134, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return usuarios1; + } + + public async Task> BuscarUsuariosAsync() + { + int num = 3; + List usuarios2 = await Task.Run>(() => { + List usuarios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List usuarios1 = read.get_UsuarioRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_241 = BaseServico.u003cu003ec.u003cu003e9__24_1; + if (u003cu003e9_241 == null) + { + u003cu003e9_241 = (Usuario x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__24_1 = u003cu003e9_241; + } + usuarios = new List(usuarios1.OrderBy(u003cu003e9_241)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 131, num, null, true); + continue; + } + return usuarios; + } + return new List(); + }); + return usuarios2; + } + + public async Task> BuscarUsuariosSso() + { + List userSsos; + List userSsos1; + try + { + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + Uri apiSso = Address.get_ApiSso(); + string[] strArrays = new string[] { "user" }; + Uri uri = apiSso.Append(strArrays); + string[] strArrays1 = new string[] { "onlyempresa" }; + Uri uri1 = uri.Append(strArrays1); + string[] strArrays2 = new string[] { "list" }; + Uri uri2 = uri1.Append(strArrays2); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", Recursos.Usuario.get_TokenSso())); + HttpResponseMessage async = await httpClient.GetAsync(uri2); + if (!async.get_IsSuccessStatusCode()) + { + userSsos1 = null; + } + else + { + userSsos1 = JsonConvert.DeserializeObject>(await async.get_Content().ReadAsStringAsync()); + } + userSsos = userSsos1; + } + } + catch + { + userSsos = new List(); + } + return userSsos; + } + + internal async Task> BuscarVendedor(string value) + { + int num = 3; + List vendedors1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedors = read.get_VendedorRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_211 = BaseServico.u003cu003ec.u003cu003e9__21_1; + if (u003cu003e9_211 == null) + { + u003cu003e9_211 = (Vendedor x) => x.get_Nome(); + BaseServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211; + } + list = vendedors.OrderBy(u003cu003e9_211).ToList(); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 140, num, value, true); + continue; + } + return list; + } + return new List(); + }); + return vendedors1; + } + + public async Task> BuscarVendedoresAsync() + { + int num = 3; + List vendedors2 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedors1 = read.get_VendedorRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_471 = BaseServico.u003cu003ec.u003cu003e9__47_1; + if (u003cu003e9_471 == null) + { + u003cu003e9_471 = (Vendedor x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__47_1 = u003cu003e9_471; + } + vendedors = new List(vendedors1.OrderBy(u003cu003e9_471)); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 140, num, null, true); + continue; + } + return vendedors; + } + return new List(); + }); + return vendedors2; + } + + private async Task BuscaUsuarioByToken(Usuario usuario) + { + bool flag; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + Uri apiSso = Address.get_ApiSso(); + string[] strArrays = new string[] { "user" }; + Uri uri = apiSso.Append(strArrays); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", usuario.get_TokenSso())); + JsonConvert.DeserializeObject(await await httpClient.GetAsync(uri).get_Content().ReadAsStringAsync()); + flag = true; + } + return flag; + } + + internal async Task BuscaUsuarioSso(string login, string password, string documentoEmpresa) + { + AuthSso authSso; + AuthSso authSso1; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + Uri apiSso = Address.get_ApiSso(); + string[] strArrays = new string[] { "auth" }; + Uri uri = apiSso.Append(strArrays); + object[] ticks = new object[] { login, password, ApplicationHelper.NumeroSerial, documentoEmpresa, null }; + DateTime universalTime = Funcoes.GetNetworkTime().ToUniversalTime(); + ticks[4] = universalTime.Ticks; + string base64BasicEncode = string.Format("{0}:{1}:{2}:{3}:{4}", ticks).ToBase64BasicEncode(); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", base64BasicEncode); + HttpResponseMessage async = await httpClient.GetAsync(uri); + if (!async.get_IsSuccessStatusCode()) + { + authSso1 = null; + } + else + { + authSso1 = JsonConvert.DeserializeObject(await async.get_Content().ReadAsStringAsync()); + } + authSso = authSso1; + } + return authSso; + } + + public async Task> CarregarUsuarios() + { + await this.AtualizarUsuarios(); + return await this.BuscarUsuariosAsync(); + } + + public RegistroLog CreateDynamicLog(long id, dynamic lista, TipoTela tela) + { + RegistroLog registroLog; + string str; + string str1; + string str2; + string str3; + try + { + List diferencas = new List(); + List valorOriginals = new List(); + foreach (dynamic listum in (IEnumerable)lista) + { + if (listum == (dynamic)null) + { + continue; + } + if (!listum.GetType().Name.ToUpper().StartsWith("LIST")) + { + try + { + diferencas.AddRange(this.DynamicObjeto(listum)); + } + catch + { + } + } + else + { + foreach (dynamic obj1 in (IEnumerable)listum) + { + try + { + if (obj1.Id != 0) + { + diferencas.AddRange(this.DynamicObjeto(obj1)); + } + else + { + valorOriginals.AddRange(obj1.GetValorOriginal()); + } + } + catch + { + } + } + } + } + DateTime networkTime = Funcoes.GetNetworkTime(); + if (diferencas == null || diferencas.Count != 0) + { + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + str = JsonConvert.SerializeObject(diferencas, jsonSerializerSetting).Replace("]", ",").Replace("[", ""); + } + else + { + str = ""; + } + string str4 = str; + if (valorOriginals == null || valorOriginals.Count != 0) + { + JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); + jsonSerializerSetting1.set_ReferenceLoopHandling(1); + str1 = JsonConvert.SerializeObject(valorOriginals, jsonSerializerSetting1).Replace("]", "").Replace("[", ""); + } + else + { + str1 = ""; + } + string str5 = str1; + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(1); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + if (!string.IsNullOrEmpty(str4) || !string.IsNullOrEmpty(str5)) + { + str2 = string.Concat("[", str4, str5, "]"); + } + else + { + str2 = null; + } + registroLog1.set_Descricao(str2); + registroLog1.set_EntidadeId(id); + registroLog1.set_Tela(tela); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress pAddress = ((IEnumerable)Recursos.Host.AddressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str3 = pAddress.ToString(); + } + else + { + str3 = null; + } + registroLog1.set_Ip(str3); + registroLog1.set_ModeloNovo(true); + registroLog = registroLog1; + } + catch (Exception exception) + { + registroLog = null; + } + return registroLog; + } + + public RegistroLog CreateLog(long id, dynamic obj, TipoTela tela) + { + RegistroLog registroLog; + string str; + string str1; + try + { + List diferencas = (List)obj.Compare(); + DateTime networkTime = Funcoes.GetNetworkTime(); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(1); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + if (diferencas == null || diferencas.Count != 0) + { + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + str = JsonConvert.SerializeObject(diferencas, jsonSerializerSetting); + } + else + { + str = null; + } + registroLog1.set_Descricao(str); + registroLog1.set_EntidadeId(id); + registroLog1.set_Tela(tela); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress pAddress = ((IEnumerable)Recursos.Host.AddressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str1 = pAddress.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + registroLog1.set_ModeloNovo(true); + registroLog = registroLog1; + } + catch (Exception exception) + { + registroLog = null; + } + return registroLog; + } + + public RegistroLog CreateLog(long id, List diferenca, TipoTela tela) + { + RegistroLog registroLog; + string str; + try + { + DateTime networkTime = Funcoes.GetNetworkTime(); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(1); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(diferenca, jsonSerializerSetting)); + registroLog1.set_EntidadeId(id); + registroLog1.set_Tela(tela); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress pAddress = ((IEnumerable)Recursos.Host.AddressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + registroLog1.set_ModeloNovo(true); + registroLog = registroLog1; + } + catch (Exception exception) + { + registroLog = null; + } + return registroLog; + } + + public RegistroLog CreateLog(long id, List diferenca, TipoTela tela, TipoAcao acao) + { + RegistroLog registroLog; + string str; + try + { + DateTime networkTime = Funcoes.GetNetworkTime(); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(acao); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(diferenca, jsonSerializerSetting)); + registroLog1.set_EntidadeId(id); + registroLog1.set_Tela(tela); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress pAddress = ((IEnumerable)Recursos.Host.AddressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + registroLog1.set_ModeloNovo(true); + registroLog = registroLog1; + } + catch (Exception exception) + { + registroLog = null; + } + return registroLog; + } + + public RegistroLog CreateLog(long id, List valor, TipoTela tela, TipoAcao acao) + { + RegistroLog registroLog; + string str; + try + { + DateTime networkTime = Funcoes.GetNetworkTime(); + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(acao); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(valor, jsonSerializerSetting)); + registroLog1.set_EntidadeId(id); + registroLog1.set_Tela(tela); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress pAddress = ((IEnumerable)Recursos.Host.AddressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + registroLog1.set_ModeloNovo(true); + registroLog = registroLog1; + } + catch (Exception exception) + { + registroLog = null; + } + return registroLog; + } + + internal async Task DeleteUsuarioSso(Usuario usuario, string documentoEmpresa) + { + UserSso userSso; + UserSso userSso1; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + Uri apiSso = Address.get_ApiSso(); + string[] strArrays = new string[] { "user" }; + Uri uri = apiSso.Append(strArrays).AddQuery("userId", usuario.get_SsoId()); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", usuario.get_TokenSso())); + HttpResponseMessage httpResponseMessage = await httpClient.DeleteAsync(uri); + if (!httpResponseMessage.get_IsSuccessStatusCode()) + { + userSso1 = null; + } + else + { + userSso1 = JsonConvert.DeserializeObject(await httpResponseMessage.get_Content().ReadAsStringAsync()); + } + userSso = userSso1; + } + return userSso; + } + + public List DynamicObjeto(dynamic objeto) + { + dynamic obj = objeto.Compare(); + if (obj.Count <= 0) + { + return new List(); + } + return (List)obj; + } + + public async Task LoadInicialParameters() + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List parceiros = read.get_ParceiroRepository().Find(); + Func u003cu003e9_521 = BaseServico.u003cu003ec.u003cu003e9__52_1; + if (u003cu003e9_521 == null) + { + u003cu003e9_521 = (Parceiro x) => x.get_Id(); + BaseServico.u003cu003ec.u003cu003e9__52_1 = u003cu003e9_521; + } + Recursos.Parceiros = new List(parceiros.OrderBy(u003cu003e9_521)); + List fabricantes = read.get_FabricanteRepository().Select(); + Func u003cu003e9_522 = BaseServico.u003cu003ec.u003cu003e9__52_2; + if (u003cu003e9_522 == null) + { + u003cu003e9_522 = (Fabricante x) => x.get_Descricao(); + BaseServico.u003cu003ec.u003cu003e9__52_2 = u003cu003e9_522; + } + Recursos.Fabricantes = fabricantes.OrderBy(u003cu003e9_522).ToList(); + Recursos.Configuracoes = read.get_ConfiguracaoRepository().BuscarConfiguracoes(); + read.CriarAuxiliar(false); + Recursos.Empresas = Auxiliar.get_Empresas(); + Recursos.Ramos = Auxiliar.get_Ramos(); + Recursos.Seguradoras = Auxiliar.get_Seguradoras(); + Recursos.Produtos = Auxiliar.get_Produtos(); + Recursos.Status = Auxiliar.get_StatusApolice(); + Recursos.TipoVendedor = Auxiliar.get_TipoVendedores(); + Recursos.Estipulantes = Auxiliar.get_Estipulantes(); + Recursos.Vendedores = Auxiliar.get_Vendedores(); + Recursos.Usuarios = Auxiliar.get_Usuarios(); + Recursos.TiposTarefa = Auxiliar.get_TiposTarefa(); + Recursos.StatusProspeccao = Auxiliar.get_StatusProspeccao(); + Recursos.Coberturas = Auxiliar.get_CoberturasPadrao(); + } + flag = true; + } + catch (Exception exception) + { + num = this.Registrar(exception, 186, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task ParceiroUtilizado(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_SinistroAutoRepository().ParceiroUtilizado(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 156, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public int Registrar(Exception e, TipoErro erro, int tries, object objeto = null, bool abrirTela = true) + { + string str; + string nome; + string nome1; + long id; + string str1; + tries--; + if (tries > 0) + { + return tries; + } + try + { + int fileLineNumber = (new StackTrace(e, true)).GetFrame(0).GetFileLineNumber(); + if (objeto != null) + { + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + str = JsonConvert.SerializeObject(objeto, 1, jsonSerializerSetting); + } + else + { + str = null; + } + string str2 = str; + LogError logError = new LogError(); + logError.set_IdFornecedor(ApplicationHelper.IdFornecedor); + Empresa empresa = Recursos.Empresa; + if (empresa != null) + { + nome = empresa.get_Nome(); + } + else + { + nome = null; + } + logError.set_Fornecedor(nome); + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + nome1 = usuario.get_Nome(); + } + else + { + nome1 = null; + } + logError.set_UsuarioLogado(nome1); + Usuario usuario1 = Recursos.Usuario; + if (usuario1 != null) + { + id = usuario1.get_Id(); + } + else + { + id = (long)0; + } + logError.set_IdUsuarioLogado(id); + logError.set_Versao(ApplicationHelper.Versao.ToString()); + logError.set_Data(Funcoes.GetNetworkTime()); + logError.set_IdErro(erro); + logError.set_Erro(Gestor.Common.Validation.ValidationHelper.GetDescription(erro)); + logError.set_HResult(e.HResult); + Exception innerException = e.InnerException; + if (innerException != null) + { + str1 = innerException.ToString(); + } + else + { + str1 = null; + } + logError.set_InnerException(str1); + logError.set_HelpLink(e.HelpLink); + logError.set_Message(e.Message); + logError.set_Source(e.Source); + logError.set_StackTrace(e.StackTrace); + logError.set_Maquina(Environment.MachineName); + logError.set_UsuarioMaquina(Environment.UserName); + logError.set_Linha(fileLineNumber.ToString()); + logError.set_Objeto(str2); + Erro.RegistrarErro(logError, abrirTela); + this.Sucesso = false; + } + catch (Exception exception) + { + } + return 0; + } + + public async Task ReloadAuxiliar() + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + read.CriarAuxiliar(true); + Recursos.Empresas = Auxiliar.get_Empresas(); + Recursos.Ramos = Auxiliar.get_Ramos(); + Recursos.Seguradoras = Auxiliar.get_Seguradoras(); + Recursos.Produtos = Auxiliar.get_Produtos(); + Recursos.Status = Auxiliar.get_StatusApolice(); + Recursos.TipoVendedor = Auxiliar.get_TipoVendedores(); + Recursos.Estipulantes = Auxiliar.get_Estipulantes(); + Recursos.Vendedores = Auxiliar.get_Vendedores(); + Recursos.Usuarios = Auxiliar.get_Usuarios(); + Recursos.TiposTarefa = Auxiliar.get_TiposTarefa(); + Recursos.StatusProspeccao = Auxiliar.get_StatusProspeccao(); + } + flag = true; + } + catch (Exception exception) + { + num = this.Registrar(exception, 186, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public void SalvarAcao(RegistroAcao log, object obs = null) + { + string str; + string str1; + if (log == null || Recursos.Usuario.get_Id() == 0) + { + return; + } + try + { + using (UnitOfWork commited = Instancia.Commited) + { + log.set_Usuario(Recursos.Usuario); + log.set_DataHora(Funcoes.GetNetworkTime()); + log.set_Versao(LoginViewModel.VersaoAtual); + log.set_NomeMaquina(Environment.MachineName); + log.set_UsuarioMaquina(Environment.UserName); + RegistroAcao registroAcao = log; + IPAddress pAddress = ((IEnumerable)Dns.GetHostEntry(Dns.GetHostName()).AddressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroAcao.set_Ip(str); + RegistroAcao registroAcao1 = log; + if (obs == null) + { + str1 = ""; + } + else if (!(obs is string)) + { + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + str1 = JsonConvert.SerializeObject(obs, jsonSerializerSetting); + } + else + { + str1 = obs.ToString(); + } + registroAcao1.set_Observacao(str1); + commited.get_RegistroAcaoRepository().SaveOrUpdate(log); + commited.Commit(); + } + } + catch (Exception exception) + { + this.Registrar(exception, 0, 3, log, true); + } + } + + public async Task SalvarControle(ControleArquivoDigital controle) + { + int num = 3; + await Task.Run(() => { + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_IndiceArquivoDigitalRepository().SaveOrUpdate(controle); + commited.Commit(); + } + break; + } + catch (Exception exception) + { + num = this.Registrar(exception, 179, num, controle, true); + } + } + }); + } + + public void SaveLog(RegistroLog keyValues, UnitOfWork unitOfWork) + { + if (keyValues == null) + { + return; + } + try + { + unitOfWork.get_RegistroLogRepository().SaveOrUpdate(keyValues); + } + catch (Exception exception) + { + } + } + + public void SaveLog(List keyValues, UnitOfWork unitOfWork) + { + if (keyValues == null) + { + return; + } + try + { + List list = keyValues.Where((RegistroLog x) => { + if (string.IsNullOrEmpty((x != null ? x.get_Descricao() : null))) + { + return false; + } + return !string.IsNullOrEmpty(x.get_Versao()); + }).ToList(); + unitOfWork.get_RegistroLogRepository().AddRange(list); + } + catch (Exception exception) + { + } + } + + public async Task Sincronizar(List dados, Filtros filtros) + { + int num2 = 3; + int num3 = await Task.Run(() => { + int num; + while (num2 > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + int num1 = commited.get_VinculoDocumentoRepository().Sincronize(filtros.get_Inicio(), dados); + commited.Commit(); + num = num1; + } + } + catch (Exception exception) + { + num2 = this.Registrar(exception, 293, num2, null, true); + continue; + } + return num; + } + return 0; + }); + return num3; + } + + public async Task Sincronizar(DateTime data, List ids = null) + { + int num = 3; + int[] numArray2 = await Task.Run(() => { + int[] numArray; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + int[] numArray1 = commited.get_ParcelaRepository().SincronizarPendencia(data, ids); + commited.Commit(); + numArray = numArray1; + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 300, num, false, true); + continue; + } + return numArray; + } + return new int[2]; + }); + return numArray2; + } + + public async Task TipoVendedorUtilizado(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_VendedorParcelaRepository().TipoVendedorUtilizado(id); + } + } + catch (Exception exception) + { + num = this.Registrar(exception, 155, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task VerificaUsuarioSso(string login, string documentoEmpresa) + { + AuthSso authSso; + AuthSso authSso1; + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + Uri apiSso = Address.get_ApiSso(); + string[] strArrays = new string[] { "exist" }; + Uri uri = apiSso.Append(strArrays); + object[] ticks = new object[] { login, login, ApplicationHelper.NumeroSerial, documentoEmpresa, null }; + DateTime universalTime = Funcoes.GetNetworkTime().ToUniversalTime(); + ticks[4] = universalTime.Ticks; + string base64BasicEncode = string.Format("{0}:{1}:{2}:{3}:{4}", ticks).ToBase64BasicEncode(); + httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", base64BasicEncode); + HttpResponseMessage async = await httpClient.GetAsync(uri); + if (!async.get_IsSuccessStatusCode()) + { + authSso1 = null; + } + else + { + authSso1 = JsonConvert.DeserializeObject(await async.get_Content().ReadAsStringAsync()); + } + authSso = authSso1; + } + return authSso; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/LogServico.cs b/Codemerx/Gestor.Application/Servicos/LogServico.cs new file mode 100644 index 0000000..bc61ed1 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/LogServico.cs @@ -0,0 +1,262 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Relatorios.LogsEnvio; +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 +{ + public class LogServico : BaseServico + { + public LogServico() + { + } + + public async Task> BuscaLogParcelas(List ids) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List registroLogs = read.get_RegistroLogRepository().BuscaLogParcelas(ids); + Func u003cu003e9_11 = LogServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (RegistroLog x) => x.get_DataHora(); + LogServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + observableCollection = new ObservableCollection(registroLogs.OrderByDescending(u003cu003e9_11)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 67, num, new { Parcela = 5, ids = ids }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarLogs(Filtros filtro) + { + int num = 3; + List registroAcaos1 = await Task.Run>(() => { + List registroAcaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + registroAcaos = read.get_RegistroAcaoRepository().Find(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 321, num, filtro, true); + continue; + } + return registroAcaos; + } + return new List(); + }); + return registroAcaos1; + } + + public async Task> BuscarLogsAntigos(Filtros filtro) + { + int num = 3; + List registroAcaos1 = await Task.Run>(() => { + List registroAcaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + registroAcaos = read.get_RegistroAcaoRepository().FindOld(filtro, Connection.GetConnectionString()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 321, num, filtro, true); + continue; + } + return registroAcaos; + } + return new List(); + }); + return registroAcaos1; + } + + public async Task> BuscarLogsEnvio(Filtros filtro) + { + int num = 3; + List logsEnvios1 = await Task.Run>(() => { + List logsEnvios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + logsEnvios = read.get_RegistroLogRepository().LogsEnvio(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 9, num, filtro, true); + continue; + } + return logsEnvios; + } + return new List(); + }); + return logsEnvios1; + } + + public async Task> FindAllByEntityId(TipoTela tela, long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List registroLogs = read.get_RegistroLogRepository().FindByEntityId(tela, id); + Func u003cu003e9_41 = LogServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (RegistroLog x) => x.get_DataHora(); + LogServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + observableCollection = new ObservableCollection(registroLogs.OrderByDescending(u003cu003e9_41)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 67, num, new { tela = tela, id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> FindByEntity(TipoTela tela, long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List logEmails = read.get_RegistroLogRepository().FindByEntity(tela, id); + Func u003cu003e9_21 = LogServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (LogEmail x) => x.get_Data(); + LogServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + observableCollection = new ObservableCollection(logEmails.OrderByDescending(u003cu003e9_21)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 68, num, new { tela = tela, id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> FindByEntityId(TipoTela tela, long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List registroLogs = read.get_RegistroLogRepository().FindByEntityId(tela, id); + Func u003cu003e9_01 = LogServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (RegistroLog x) => x.get_DataHora(); + LogServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + observableCollection = new ObservableCollection(registroLogs.OrderByDescending(u003cu003e9_01)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 67, num, new { tela = tela, id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> FindById(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_RegistroLogRepository().FindByIdSingle(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 69, num, new { id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs b/Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs new file mode 100644 index 0000000..3eb72d5 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs @@ -0,0 +1,188 @@ +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.MalaDireta; +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 +{ + public class MalaDiretaServico : BaseServico + { + public MalaDiretaServico() + { + } + + public async Task> BuscarModelos() + { + int num = 3; + List modeloMalaDiretas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List modeloMalaDiretas = read.get_ModeloMalaDiretaRepository().Find(); + Func u003cu003e9_01 = MalaDiretaServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (ModeloMalaDireta x) => x.get_Assunto(); + MalaDiretaServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + list = modeloMalaDiretas.OrderBy(u003cu003e9_01).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 70, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return modeloMalaDiretas1; + } + + public async Task Delete(ModeloMalaDireta modelo) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ModeloMalaDiretaRepository().Delete(modelo.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + ModeloMalaDireta modeloMalaDiretum = modelo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(modeloMalaDiretum, jsonSerializerSetting)); + registroLog.set_EntidadeId(modelo.get_Id()); + registroLog.set_Tela(39); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = MalaDiretaServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MalaDiretaServico.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, 255, num, modelo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(ModeloMalaDireta modelo) + { + int num = 3; + base.Sucesso = true; + ModeloMalaDireta modeloMalaDiretum2 = modelo; + ModeloMalaDireta modeloMalaDiretum3 = await Task.Run(() => { + ModeloMalaDireta modeloMalaDiretum; + string str; + while (num > 0) + { + modelo = modeloMalaDiretum2; + try + { + TipoAcao tipoAcao = (modelo.get_Id() == 0 ? 0 : 1); + using (UnitOfWork commited = Instancia.Commited) + { + modelo = (tipoAcao == null ? commited.get_ModeloMalaDiretaRepository().SaveOrUpdate(modelo) : commited.get_ModeloMalaDiretaRepository().Merge(modelo)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + ModeloMalaDireta modeloMalaDiretum1 = modelo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(modeloMalaDiretum1, jsonSerializerSetting)); + registroLog.set_EntidadeId(modelo.get_Id()); + registroLog.set_Tela(39); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = MalaDiretaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MalaDiretaServico.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(); + modeloMalaDiretum = modelo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 254, num, modelo, true); + continue; + } + return modeloMalaDiretum; + } + return modeloMalaDiretum2; + }); + return modeloMalaDiretum3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ParceiroServico.cs b/Codemerx/Gestor.Application/Servicos/ParceiroServico.cs new file mode 100644 index 0000000..b5b51f4 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ParceiroServico.cs @@ -0,0 +1,123 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + internal class ParceiroServico : BaseServico + { + public ParceiroServico() + { + } + + internal async Task BuscarParceiro(long id) + { + int num = 3; + Parceiro parceiro1 = await Task.Run(() => { + Parceiro parceiro; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parceiro = read.get_ParceiroRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 71, num, id, true); + continue; + } + return parceiro; + } + return new Parceiro(); + }); + return parceiro1; + } + + public async Task Delete(Parceiro parceiro) + { + 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(parceiro.get_Id(), parceiro.GetValorOriginal(), 22, 2)); + commited.get_ParceiroRepository().Delete(parceiro.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 257, num, parceiro, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Parceiro parceiro) + { + int num = 3; + base.Sucesso = true; + Parceiro parceiro1 = parceiro; + Parceiro parceiro2 = await Task.Run(() => { + Parceiro parceiro3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + parceiro = parceiro1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (parceiro.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(parceiro.get_Id(), parceiro, 22)); + } + parceiro = (parceiro.get_Id() == 0 ? commited.get_ParceiroRepository().SaveOrUpdate(parceiro) : commited.get_ParceiroRepository().Merge(parceiro)); + if (!flag) + { + registroLogs.Add(base.CreateLog(parceiro.get_Id(), parceiro.GetValorOriginal(), 22, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + parceiro3 = parceiro; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 256, num, parceiro, true); + continue; + } + return parceiro3; + } + return parceiro1; + }); + return parceiro2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ParcelaServico.cs b/Codemerx/Gestor.Application/Servicos/ParcelaServico.cs new file mode 100644 index 0000000..fcb987e --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ParcelaServico.cs @@ -0,0 +1,1006 @@ +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.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Relatorios.PrevisaoPagamentoComissao; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + internal class ParcelaServico : BaseServico + { + public ParcelaServico() + { + } + + public async Task BuscarApolice(long id) + { + int num = 3; + Documento documento1 = await Task.Run(() => { + Documento documento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documento = read.get_ParcelaRepository().BuscarApolice(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 3, num, id, true); + continue; + } + return documento; + } + return new Documento(); + }); + return documento1; + } + + public async Task> BuscarFatura(string numero) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = read.get_ParcelaRepository().FindNumFatura(numero); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 322, num, numero, true); + continue; + } + return documentos; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarFaturas(Filtros filtro, bool buscaAssinaturas = 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_ParcelaRepository().BuscaDocumentosPorVigencia(filtro, buscaAssinaturas, painelBi); + return documentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 76, num, filtro, true); + } + if (num <= 0) + { + break; + } + } + documentos = new List(); + return documentos; + }); + 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_ParcelaRepository().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> BuscarPagamentoVendedor(Filtros filtro, bool reciboPagamento, bool segundaViaReciboPagamento) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List vendedorParcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + IParcelaRepository parcelaRepository = read.get_ParcelaRepository(); + Filtros filtro1 = filtro; + bool flag = reciboPagamento; + bool flag1 = segundaViaReciboPagamento; + List configuracoes = Recursos.Configuracoes; + Func u003cu003e9_201 = ParcelaServico.u003cu003ec.u003cu003e9__20_1; + if (u003cu003e9_201 == null) + { + u003cu003e9_201 = (ConfiguracaoSistema x) => x.get_Configuracao() == 34; + ParcelaServico.u003cu003ec.u003cu003e9__20_1 = u003cu003e9_201; + } + vendedorParcelas = parcelaRepository.FindByPagamento(filtro1, flag, flag1, configuracoes.Any(u003cu003e9_201)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 80, num, filtro, true); + continue; + } + return vendedorParcelas; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task BuscarParcela(long id) + { + int num = 3; + Parcela parcela1 = await Task.Run(() => { + Parcela parcela; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parcela = read.get_ParcelaRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 74, num, id, true); + continue; + } + return parcela; + } + return new Parcela(); + }); + return parcela1; + } + + internal async Task> BuscarParcelas(long id) + { + int num = 3; + List parcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List parcelas = read.get_ParcelaRepository().FindByDocumentId(id); + Func u003cu003e9_31 = ParcelaServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (Parcela x) => x.get_NumeroParcela(); + ParcelaServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + list = parcelas.OrderBy(u003cu003e9_31).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 73, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return parcelas1; + } + + internal async Task> BuscarParcelas(string ids, List documentos) + { + int num = 3; + List documentos1 = await Task.Run>(() => { + List documentos2; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos2 = read.get_ParcelaRepository().FindByDocumentIds(ids, documentos); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 75, num, null, true); + continue; + } + return documentos2; + } + return new List(); + }); + return documentos1; + } + + public async Task> BuscarParcelas(Filtros filtro, bool somenteAtivos = false) + { + int num = 3; + List parcelas1 = await Task.Run>(() => { + List parcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parcelas = read.get_ParcelaRepository().FindByPendente(filtro, false, somenteAtivos); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 79, num, filtro, true); + continue; + } + return parcelas; + } + return new List(); + }); + return parcelas1; + } + + internal async Task> BuscarParcelasAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List parcelas = read.get_ParcelaRepository().FindByDocumentId(id); + Func u003cu003e9_01 = ParcelaServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (Parcela x) => x.get_NumeroParcela(); + ParcelaServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + observableCollection = new ObservableCollection(parcelas.OrderBy(u003cu003e9_01)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 73, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarParcelasPendentes(Filtros filtro, bool somenteAtivos = false) + { + int num = 3; + List parcelas1 = await Task.Run>(() => { + List parcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parcelas = read.get_ParcelaRepository().FindByPendente(filtro, true, somenteAtivos); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 78, num, filtro, true); + continue; + } + return parcelas; + } + return new List(); + }); + return parcelas1; + } + + internal async Task> BuscarParcelasPorDocumento(Documento documento) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List parcelas = read.get_ParcelaRepository().FindByDocumento(documento); + Func u003cu003e9_11 = ParcelaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (Parcela x) => x.get_NumeroParcela(); + ParcelaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + observableCollection = new ObservableCollection(parcelas.OrderBy(u003cu003e9_11)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 73, num, documento.get_Id(), true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarParcelasRecebimento(Filtros filtro) + { + int num = 3; + List parcelas1 = await Task.Run>(async () => { + List parcelas; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parcelas = await read.get_ParcelaRepository().FindByRecebimento(filtro); + return parcelas; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 77, num, filtro, true); + } + if (num <= 0) + { + break; + } + } + parcelas = new List(); + return parcelas; + }); + return parcelas1; + } + + public async Task> BuscarPrevisaoPagamentoComissao(Filtros filtro) + { + int num = 3; + List previsaoPagamentos1 = await Task.Run>(() => { + List previsaoPagamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + previsaoPagamentos = read.get_ParcelaRepository().PrevisaoPagamentoComissao(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 316, num, filtro, true); + continue; + } + return previsaoPagamentos; + } + return new List(); + }); + return previsaoPagamentos1; + } + + internal async Task> BuscarTodasParcelas(List ids) + { + int num = 3; + List parcelas1 = await Task.Run>(() => { + List parcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + parcelas = read.get_ParcelaRepository().FindByDocumentId(ids); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 73, num, ids, true); + continue; + } + return parcelas; + } + return new List(); + }); + return parcelas1; + } + + internal async Task> BuscarVendedores(long id) + { + int num = 3; + List vendedors = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByDocumentId(id); + Func u003cu003e9_51 = ParcelaServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = (VendedorParcela x) => x.get_Vendedor().get_Id(); + ParcelaServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + IEnumerable> groupings = vendedorParcelas.GroupBy(u003cu003e9_51); + Func, Vendedor> u003cu003e9_52 = ParcelaServico.u003cu003ec.u003cu003e9__5_2; + if (u003cu003e9_52 == null) + { + u003cu003e9_52 = (IGrouping x) => x.First().get_Vendedor(); + ParcelaServico.u003cu003ec.u003cu003e9__5_2 = u003cu003e9_52; + } + list = groupings.Select, Vendedor>(u003cu003e9_52).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 140, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return vendedors; + } + + public async Task Delete(Parcela parcela, List todas) + { + int num = 3; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ParcelaRepository().Delete(parcela.get_Id()); + List registroLogs = new List() + { + base.CreateLog(parcela.get_Id(), parcela.GetValorOriginal(), 5, 2) + }; + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 190, num, parcela, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task DeletePagamentoRange(List repasses) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_VendedorParcelaRepository().DeleteRange(repasses); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 21, num, repasses, false); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> FaturaPendente(Filtros filtro) + { + int num = 3; + List documentos1 = await Task.Run>(async () => { + List documentos; + while (true) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + documentos = await read.get_ParcelaRepository().FaturaPendente(filtro); + return documentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 83, num, filtro, true); + } + if (num <= 0) + { + break; + } + } + documentos = new List(); + return documentos; + }); + return documentos1; + } + + public async Task GerarPagamento(List pagamentos) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + IVendedorParcelaRepository vendedorParcelaRepository = commited.get_VendedorParcelaRepository(); + List vendedorParcelas = pagamentos; + Func u003cu003e9_221 = ParcelaServico.u003cu003ec.u003cu003e9__22_1; + if (u003cu003e9_221 == null) + { + u003cu003e9_221 = (VendedorParcela x) => x.get_Id(); + ParcelaServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221; + } + if (vendedorParcelaRepository.GerarPagamento(vendedorParcelas.Select(u003cu003e9_221).ToList(), networkTime)) + { + commited.Commit(); + flag = true; + } + else + { + flag = false; + } + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 193, num, pagamentos, 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) + { + Parcela parcela = commited.get_ParcelaRepository().FindById(id); + parcela.Initialize(); + parcela.set_Observacao(observacao); + registroLogs.Add(base.CreateLog(parcela.get_Id(), parcela, 5)); + commited.get_ParcelaRepository().Merge(parcela); + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + str = observacao; + } + catch (Exception exception) + { + num = base.Registrar(exception, 24, num, new { id = id, observacao = observacao }, true); + continue; + } + return str; + } + return ""; + }); + return str1; + } + + public async Task Save(Parcela parcela, List todas, List repasses = null, bool abrirTela = true) + { + Func func1 = null; + int num = 3; + base.Sucesso = true; + Parcela parcela2 = parcela; + List vendedorParcelas = repasses; + Funcoes.GetNetworkTime(); + ObservableCollection observableCollection1 = await this.BuscarParcelasAsync(parcela.get_Documento().get_Id()); + ObservableCollection observableCollection2 = observableCollection1; + Parcela parcela3 = await Task.Run(async () => { + Parcela parcela4; + while (num > 0) + { + try + { + ObservableCollection observableCollection = observableCollection2; + Func u003cu003e9_1 = func1; + if (u003cu003e9_1 == null) + { + Func id = (Parcela x) => x.get_Id() == parcela.get_Id(); + Func func = id; + func1 = id; + u003cu003e9_1 = func; + } + Parcela parcela1 = observableCollection.FirstOrDefault(u003cu003e9_1); + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + bool flag = parcela.get_Id() == (long)0; + parcela.set_IdEmpresa(parcela.get_Documento().get_Controle().get_IdEmpresa()); + parcela = (flag ? commited.get_ParcelaRepository().SaveOrUpdate(parcela) : commited.get_ParcelaRepository().Merge(parcela)); + if (repasses != null) + { + foreach (VendedorParcela repass in repasses) + { + repass.set_Documento(parcela.get_Documento()); + repass.set_Parcela(parcela); + if (repass.get_Id() != 0) + { + commited.get_VendedorParcelaRepository().Merge(repass); + } + else + { + commited.get_VendedorParcelaRepository().SaveOrUpdate(repass); + } + } + parcela.set_Vendedores(new ObservableCollection(repasses)); + } + if (!flag) + { + registroLogs.Add(base.CreateLog(parcela.get_Id(), parcela.Compare(parcela1.GetValorOriginal()), 5, 1)); + } + else + { + registroLogs.Add(base.CreateLog(parcela.get_Id(), parcela.GetValorOriginal(), 5, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + parcela4 = parcela; + return parcela4; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 24, num, parcela2, abrirTela); + } + } + parcela2.set_Vendedores((vendedorParcelas != null ? new ObservableCollection(vendedorParcelas) : null)); + parcela4 = parcela2; + return parcela4; + }); + return parcela3; + } + + public async Task Save(VendedorParcela pagamento) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + VendedorParcela vendedorParcela2 = await Task.Run(() => { + VendedorParcela vendedorParcela; + while (num > 0) + { + VendedorParcela vendedorParcela1 = pagamento; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + vendedorParcela1 = (vendedorParcela1.get_Id() == 0 ? commited.get_VendedorParcelaRepository().SaveOrUpdate(vendedorParcela1) : commited.get_VendedorParcelaRepository().Merge(vendedorParcela1)); + if (pagamento.get_Id() != 0) + { + registroLogs.Add(base.CreateLog(vendedorParcela1.get_Id(), vendedorParcela1.Compare(vendedorParcela1.GetValorOriginal()), 37, 1)); + } + else + { + registroLogs.Add(base.CreateLog(vendedorParcela1.get_Id(), vendedorParcela1.GetValorOriginal(), 37, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + vendedorParcela = vendedorParcela1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 189, num, pagamento, true); + continue; + } + return vendedorParcela; + } + return pagamento; + }); + return vendedorParcela2; + } + + public async Task> SaveRange(List parcela) + { + int num = 3; + base.Sucesso = true; + List parcelas2 = await Task.Run>(() => { + List parcelas; + while (num > 0) + { + List parcelas1 = parcela; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + foreach (Parcela parcela1 in parcelas1) + { + if (parcela1.get_Id() != 0) + { + commited.get_ParcelaRepository().Merge(parcela1); + } + else + { + parcela1.set_IdEmpresa(parcela1.get_Documento().get_Controle().get_IdEmpresa()); + commited.get_ParcelaRepository().SaveOrUpdate(parcela1); + } + } + commited.Commit(); + parcelas = parcelas1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 24, num, parcela, true); + continue; + } + return parcelas; + } + return parcela; + }); + return parcelas2; + } + + public async Task SaveRange(List repasses) + { + int num = 3; + List vendedorParcelas1 = repasses; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + repasses = vendedorParcelas1; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + List vendedorParcelas = repasses; + if (vendedorParcelas != null) + { + vendedorParcelas.ForEach((VendedorParcela x) => { + x.get_Id(); + x = (x.get_Id() == 0 ? commited.get_VendedorParcelaRepository().SaveOrUpdate(x) : commited.get_VendedorParcelaRepository().Merge(x)); + if (x.get_Id() == 0) + { + registroLogs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 37, 0)); + return; + } + registroLogs.Add(base.CreateLog(x.get_Id(), x.Compare(x.GetValorOriginal()), 37, 1)); + }); + } + else + { + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 189, num, repasses, false); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task TemPagamento(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_VendedorParcelaRepository().TemPagamentoParcela(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 82, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task UpdateDetalhes(List detalhes) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag3 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + List configuracoes = Recursos.Configuracoes; + Func u003cu003e9_141 = ParcelaServico.u003cu003ec.u003cu003e9__14_1; + if (u003cu003e9_141 == null) + { + u003cu003e9_141 = (ConfiguracaoSistema x) => x.get_Configuracao() == 51; + ParcelaServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141; + } + bool flag1 = configuracoes.Any(u003cu003e9_141); + bool flag2 = commited.get_ParcelaRepository().Update(detalhes, flag1); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + detalhes.ForEach((DetalheExtrato x) => { + 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(x, jsonSerializerSetting)); + registroLog.set_EntidadeId(x.get_Id()); + registroLog.set_Tela(23); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_143 = ParcelaServico.u003cu003ec.u003cu003e9__14_3; + if (u003cu003e9_143 == null) + { + u003cu003e9_143 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ParcelaServico.u003cu003ec.u003cu003e9__14_3 = u003cu003e9_143; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_143); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + commited.Commit(); + flag = flag2; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 192, num, detalhes, true); + continue; + } + return flag; + } + return false; + }); + return flag3; + } + + public async Task> UpdateRange(List parcelas) + { + base.Sucesso = true; + int num = 3; + List parcelas1 = parcelas; + Funcoes.GetNetworkTime(); + List parcelas2 = await Task.Run>(() => { + List parcelas3; + while (num > 0) + { + parcelas = parcelas1; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + parcelas = commited.get_ParcelaRepository().UpdateRange(parcelas); + parcelas.ForEach((Parcela x) => { + registroLogs.Add(base.CreateLog(x.get_Id(), x.Compare(x.GetValorOriginal()), 5, 1)); + base.SaveLog(registroLogs, commited); + }); + commited.Commit(); + parcelas3 = parcelas; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 24, num, parcelas, false); + continue; + } + return parcelas3; + } + return parcelas1; + }); + return parcelas2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs b/Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs new file mode 100644 index 0000000..525efc6 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs @@ -0,0 +1,167 @@ +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.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class PermissaoArquivoDigitalServico : BaseServico + { + public PermissaoArquivoDigitalServico() + { + } + + public PermissaoArquivoDigital BuscarPermissao(Usuario usuario, TipoArquivoDigital tela) + { + PermissaoArquivoDigital permissaoArquivoDigital; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + PermissaoArquivoDigital permissaoArquivoDigital1 = read.get_PermissaoArquivoDigitalRepository().FindByPermissao(usuario.get_Id(), tela); + if (permissaoArquivoDigital1 != null) + { + permissaoArquivoDigital = permissaoArquivoDigital1; + } + else + { + PermissaoArquivoDigital permissaoArquivoDigital2 = new PermissaoArquivoDigital(); + permissaoArquivoDigital2.set_Usuario(usuario); + permissaoArquivoDigital2.set_Tela(tela); + permissaoArquivoDigital2.set_Consultar(true); + permissaoArquivoDigital2.set_Excluir(true); + permissaoArquivoDigital2.set_Incluir(true); + permissaoArquivoDigital = permissaoArquivoDigital2; + } + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true); + continue; + } + return permissaoArquivoDigital; + } + return null; + } + + public async Task> PermissArquivoDigital(Usuario usuario) + { + int num = 3; + List permissaoArquivoDigitals1 = await Task.Run>(() => { + List permissaoArquivoDigitals; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoArquivoDigitals = read.get_PermissaoArquivoDigitalRepository().FindByUsuario(usuario.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 84, num, usuario, true); + continue; + } + return permissaoArquivoDigitals; + } + return new List(); + }); + return permissaoArquivoDigitals1; + } + + public async Task> SavePermiss(List permissao, List prev) + { + int num = 3; + base.Sucesso = true; + List permissaoArquivoDigitals1 = permissao; + List permissaoArquivoDigitals2 = prev; + List permissaoArquivoDigitals3 = await Task.Run>(() => { + List permissaoArquivoDigitals; + while (num > 0) + { + permissao = permissaoArquivoDigitals1; + prev = permissaoArquivoDigitals2; + List diferencas = new List(); + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + permissao.ForEach((PermissaoArquivoDigital x) => { + PermissaoArquivoDigital permissaoArquivoDigital = x; + PermissaoArquivoDigital permissaoArquivoDigital1 = prev.FirstOrDefault((PermissaoArquivoDigital y) => y.get_Id() == permissaoArquivoDigital.get_Id()); + if (permissaoArquivoDigital1 != null && permissaoArquivoDigital1.get_Consultar() == permissaoArquivoDigital.get_Consultar() && permissaoArquivoDigital1.get_Excluir() == permissaoArquivoDigital.get_Excluir() && permissaoArquivoDigital1.get_Incluir() == permissaoArquivoDigital.get_Incluir()) + { + return; + } + if (permissaoArquivoDigital1 != null) + { + registroLogs.Add(base.CreateLog(permissaoArquivoDigital.get_Usuario().get_Id(), permissaoArquivoDigital.Compare(permissaoArquivoDigital1.GetValorOriginal()), 43, 1)); + } + else + { + registroLogs.Add(base.CreateLog(permissaoArquivoDigital.get_Usuario().get_Id(), permissaoArquivoDigital.GetValorOriginal(), 43, 0)); + } + permissaoArquivoDigital = (permissaoArquivoDigital.get_Id() == 0 ? commited.get_PermissaoArquivoDigitalRepository().SaveOrUpdate(permissaoArquivoDigital) : commited.get_PermissaoArquivoDigitalRepository().Merge(permissaoArquivoDigital)); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + permissaoArquivoDigitals = permissao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 258, num, new { permissao = permissao, prev = prev }, true); + continue; + } + return permissaoArquivoDigitals; + } + return permissaoArquivoDigitals1; + }); + return permissaoArquivoDigitals3; + } + + public async Task VerificarPermissao(Usuario usuario, TipoArquivoDigital tela) + { + int num = 3; + PermissaoArquivoDigital permissaoArquivoDigital1 = await Task.Run(() => { + PermissaoArquivoDigital permissaoArquivoDigital; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoArquivoDigital = read.get_PermissaoArquivoDigitalRepository().FindByPermissao(usuario.get_Id(), tela); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true); + continue; + } + return permissaoArquivoDigital; + } + return null; + }); + return permissaoArquivoDigital1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs new file mode 100644 index 0000000..061797e --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs @@ -0,0 +1,152 @@ +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.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class PermissaoUsuarioServico : BaseServico + { + public PermissaoUsuarioServico() + { + } + + public PermissaoUsuario BuscarPermissao(Usuario usuario, TipoTela tela) + { + PermissaoUsuario permissaoUsuario; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoUsuario = read.get_PermissaoUsuarioRepository().FindByPermissao(usuario.get_Id(), tela); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true); + continue; + } + return permissaoUsuario; + } + return null; + } + + public async Task> PermissUsuario(Usuario usuario) + { + int num = 3; + List permissaoUsuarios1 = await Task.Run>(() => { + List permissaoUsuarios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoUsuarios = read.get_PermissaoUsuarioRepository().FindByUsuario(usuario.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 84, num, usuario, true); + continue; + } + return permissaoUsuarios; + } + return new List(); + }); + return permissaoUsuarios1; + } + + public async Task> SavePermiss(List permissao, List prev) + { + int num = 3; + base.Sucesso = true; + List permissaoUsuarios1 = permissao; + List permissaoUsuarios2 = prev; + List permissaoUsuarios3 = await Task.Run>(() => { + List permissaoUsuarios; + List registroLogs = new List(); + while (num > 0) + { + permissao = permissaoUsuarios1; + prev = permissaoUsuarios2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + permissao.ForEach((PermissaoUsuario x) => { + PermissaoUsuario permissaoUsuario = x; + PermissaoUsuario permissaoUsuario1 = prev.FirstOrDefault((PermissaoUsuario y) => y.get_Id() == permissaoUsuario.get_Id()); + if (permissaoUsuario1 != null && permissaoUsuario1.get_Alterar() == permissaoUsuario.get_Alterar() && permissaoUsuario1.get_Consultar() == permissaoUsuario.get_Consultar() && permissaoUsuario1.get_Excluir() == permissaoUsuario.get_Excluir() && permissaoUsuario1.get_Incluir() == permissaoUsuario.get_Incluir()) + { + return; + } + if (permissaoUsuario1 != null) + { + registroLogs.Add(base.CreateLog(permissaoUsuario.get_Usuario().get_Id(), permissaoUsuario.Compare(permissaoUsuario1.GetValorOriginal()), 43, 1)); + } + else + { + registroLogs.Add(base.CreateLog(permissaoUsuario.get_Usuario().get_Id(), permissaoUsuario.GetValorOriginal(), 43, 0)); + } + permissaoUsuario = (permissaoUsuario.get_Id() == 0 ? commited.get_PermissaoUsuarioRepository().SaveOrUpdate(permissaoUsuario) : commited.get_PermissaoUsuarioRepository().Merge(permissaoUsuario)); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + permissaoUsuarios = permissao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 258, num, new { permissao = permissao, prev = prev }, true); + continue; + } + return permissaoUsuarios; + } + return permissaoUsuarios1; + }); + return permissaoUsuarios3; + } + + public async Task VerificarPermissao(Usuario usuario, TipoTela tela) + { + int num = 3; + PermissaoUsuario permissaoUsuario1 = await Task.Run(() => { + PermissaoUsuario permissaoUsuario; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoUsuario = read.get_PermissaoUsuarioRepository().FindByPermissao(usuario.get_Id(), tela); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true); + continue; + } + return permissaoUsuario; + } + return null; + }); + return permissaoUsuario1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs b/Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs new file mode 100644 index 0000000..ab7ab6f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs @@ -0,0 +1,338 @@ +using Gestor.Application.Actions; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; + +namespace Gestor.Application.Servicos +{ + public class ProspeccaoServico : BaseServico + { + public ProspeccaoServico() + { + } + + public async Task BuscarProspeccao(long id) + { + int num = 3; + Prospeccao prospeccao1 = await Task.Run(() => { + Prospeccao prospeccao; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + prospeccao = read.get_ProspectRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 87, num, id, true); + continue; + } + return prospeccao; + } + return new Prospeccao(); + }); + return prospeccao1; + } + + internal async Task> BuscarProspeccoes(long id, DateTime inicio, DateTime fim, StatusProspeccao? status) + { + int num = 3; + List prospeccaos1 = await Task.Run>(() => { + List prospeccaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + prospeccaos = read.get_ProspectRepository().Find(Recursos.Empresa.get_Id(), id, inicio, fim, status); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 86, num, new { id = id, inicio = inicio, fim = fim, status = status }, true); + continue; + } + return prospeccaos; + } + return new List(); + }); + return prospeccaos1; + } + + public async Task> BuscarProspeccoes(Filtros filtro) + { + int num = 3; + List prospeccaos1 = await Task.Run>(() => { + List prospeccaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + prospeccaos = read.get_ProspectRepository().Find(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 88, num, filtro, true); + continue; + } + return prospeccaos; + } + return new List(); + }); + return prospeccaos1; + } + + public async Task> BuscarProspeccoesPorStatus(StatusDeProspeccao statusProspeccao) + { + int num = 3; + List prospeccaos1 = await Task.Run>(() => { + List prospeccaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + prospeccaos = read.get_ProspectRepository().FindByStatusPersonalizado(statusProspeccao.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 310, num, new { statusProspeccao = statusProspeccao }, true); + continue; + } + return prospeccaos; + } + return new List(); + }); + return prospeccaos1; + } + + public async Task Delete(Prospeccao prospeccao) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + string str1; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + if (prospeccao.get_Tarefa() != null) + { + commited.get_TarefaRepository().Excluir(prospeccao.get_Tarefa().get_Id()); + } + commited.get_ProspectRepository().Delete(prospeccao.get_Id()); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (prospeccao.get_Tarefa() != null) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Tarefa tarefa = prospeccao.get_Tarefa(); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting)); + registroLog.set_EntidadeId(prospeccao.get_Tarefa().get_Id()); + registroLog.set_Tela(38); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_22 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_2; + if (u003cu003e9_22 == null) + { + u003cu003e9_22 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ProspeccaoServico.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_22); + if (pAddress != null) + { + str1 = pAddress.ToString(); + } + else + { + str1 = null; + } + registroLog.set_Ip(str1); + base.SaveLog(registroLog, commited); + } + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(2); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + Prospeccao prospeccao1 = prospeccao; + JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); + jsonSerializerSetting1.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(prospeccao1, jsonSerializerSetting1)); + registroLog1.set_EntidadeId(prospeccao.get_Id()); + registroLog1.set_Tela(33); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_23 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_3; + if (u003cu003e9_23 == null) + { + u003cu003e9_23 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ProspeccaoServico.u003cu003ec.u003cu003e9__2_3 = u003cu003e9_23; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_23); + if (pAddress1 != null) + { + str = pAddress1.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + base.SaveLog(registroLog1, commited); + commited.Commit(); + } + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_21 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + ProspeccaoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + dispatcher.Invoke(u003cu003e9_21); + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 260, num, prospeccao, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Salvar(Prospeccao prospecao) + { + int num = 3; + base.Sucesso = true; + Prospeccao prospeccao2 = prospecao; + Prospeccao prospeccao3 = await Task.Run(() => { + Prospeccao prospeccao; + string str; + while (num > 0) + { + prospecao = prospeccao2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + TipoAcao tipoAcao = (prospecao.get_Id() == 0 ? 0 : 1); + prospecao.set_IdEmpresa(Recursos.Usuario.get_IdEmpresa()); + if (!prospecao.get_DataCriacao().HasValue) + { + prospecao.set_DataCriacao(new DateTime?(networkTime)); + } + if (prospecao.get_UsuarioCriacao() == 0) + { + prospecao.set_UsuarioCriacao(Recursos.Usuario.get_Id()); + } + Tarefa tarefa = prospecao.get_Tarefa(); + tarefa = (!prospecao.get_CriarTarefa() ? null : (tarefa.get_Id() == 0 ? commited.get_TarefaRepository().Salvar(tarefa) : commited.get_TarefaRepository().Atualizar(tarefa))); + prospecao.set_Tarefa(tarefa); + prospecao = (prospecao.get_Id() == 0 ? commited.get_ProspectRepository().SaveOrUpdate(prospecao) : commited.get_ProspectRepository().Merge(prospecao)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (prospecao.get_Tarefa() != null) + { + prospecao.get_Tarefa().set_IdEntidade(prospecao.get_Id()); + prospecao.set_Tarefa(commited.get_TarefaRepository().Atualizar(prospecao.get_Tarefa())); + } + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Prospeccao prospeccao1 = prospecao; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(prospeccao1, jsonSerializerSetting)); + registroLog.set_EntidadeId(prospecao.get_Id()); + registroLog.set_Tela(33); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_12 = ProspeccaoServico.u003cu003ec.u003cu003e9__1_2; + if (u003cu003e9_12 == null) + { + u003cu003e9_12 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ProspeccaoServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_12); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_11 = ProspeccaoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + ProspeccaoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + dispatcher.Invoke(u003cu003e9_11); + prospeccao = prospecao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 259, num, prospecao, true); + continue; + } + return prospeccao; + } + return prospeccao2; + }); + return prospeccao3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs new file mode 100644 index 0000000..c9cbe35 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs @@ -0,0 +1,221 @@ +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.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class RestricaoUsuarioServico : BaseServico + { + public RestricaoUsuarioServico() + { + } + + public RestricaoUsuario BuscarRestricao(Usuario usuario, TipoRestricao restricao) + { + RestricaoUsuario restricaoUsuario; + int num = 3; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + restricaoUsuario = read.get_RestricaoUsuarioRepository().FindRestricao(usuario.get_Id(), restricao); + } + } + catch (Exception exception1) + { + Exception exception = exception1; + num = base.Registrar(exception, 89, num, new { usuario = usuario, restricao = restricao }, true); + continue; + } + return restricaoUsuario; + } + return null; + } + + public async Task> BuscarRestricoes(long id) + { + int num = 3; + List restricaoUsuarios1 = await Task.Run>(() => { + List restricaoUsuarios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + restricaoUsuarios = read.get_RestricaoUsuarioRepository().FindByUsuario(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 90, num, id, true); + continue; + } + return restricaoUsuarios; + } + return new List(); + }); + return restricaoUsuarios1; + } + + public async Task> BuscarRestricoesCamposRelatorios(long id) + { + int num = 3; + List restricaoUsuarioCamposRelatorios1 = await Task.Run>(() => { + List restricaoUsuarioCamposRelatorios; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + restricaoUsuarioCamposRelatorios = read.get_RestricaoUsuarioCamposRelatoriosRepository().FindByUsuario(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 90, num, id, true); + continue; + } + return restricaoUsuarioCamposRelatorios; + } + return new List(); + }); + return restricaoUsuarioCamposRelatorios1; + } + + public async Task> SaveRestri(List restricoes, List prev) + { + int num = 3; + base.Sucesso = true; + List restricaoUsuarios1 = restricoes; + List restricaoUsuarios2 = prev; + List restricaoUsuarios3 = await Task.Run>(() => { + List restricaoUsuarios; + while (num > 0) + { + List diferencas = new List(); + List registroLogs = new List(); + restricoes = restricaoUsuarios1; + prev = restricaoUsuarios2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + restricoes.ForEach((RestricaoUsuario x) => { + RestricaoUsuario restricaoUsuario = x; + RestricaoUsuario restricaoUsuario1 = prev.FirstOrDefault((RestricaoUsuario y) => { + if (restricaoUsuario.get_Id() != 0) + { + return y.get_Id() == restricaoUsuario.get_Id(); + } + return y.get_Tipo() == restricaoUsuario.get_Tipo(); + }); + if (restricaoUsuario1 != null && restricaoUsuario1.get_Restricao() == restricaoUsuario.get_Restricao()) + { + return; + } + if (restricaoUsuario1 != null) + { + registroLogs.Add(base.CreateLog(restricaoUsuario.get_Usuario().get_Id(), restricaoUsuario.Compare(restricaoUsuario1.GetValorOriginal()), 43, 1)); + } + else + { + registroLogs.Add(base.CreateLog(restricaoUsuario.get_Usuario().get_Id(), restricaoUsuario.GetValorOriginal(), 43, 0)); + } + restricaoUsuario = (restricaoUsuario.get_Id() == 0 ? commited.get_RestricaoUsuarioRepository().SaveOrUpdate(restricaoUsuario) : commited.get_RestricaoUsuarioRepository().Merge(restricaoUsuario)); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + restricaoUsuarios = restricoes; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 261, num, new { restricoes = restricoes, prev = prev }, true); + continue; + } + return restricaoUsuarios; + } + return restricaoUsuarios1; + }); + return restricaoUsuarios3; + } + + public async Task> SaveRestriCamposRelatorios(List restricoes, List prev) + { + int num = 3; + base.Sucesso = true; + List restricaoUsuarioCamposRelatorios1 = restricoes; + List restricaoUsuarioCamposRelatorios2 = prev; + List restricaoUsuarioCamposRelatorios3 = await Task.Run>(() => { + List restricaoUsuarioCamposRelatorios; + while (num > 0) + { + List diferencas = new List(); + List registroLogs = new List(); + restricoes = restricaoUsuarioCamposRelatorios1; + prev = restricaoUsuarioCamposRelatorios2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + restricoes.ForEach((RestricaoUsuarioCamposRelatorios x) => { + RestricaoUsuarioCamposRelatorios restricaoUsuarioCamposRelatorio = x; + RestricaoUsuarioCamposRelatorios restricaoUsuarioCamposRelatorio1 = prev.FirstOrDefault((RestricaoUsuarioCamposRelatorios y) => { + if (y.get_Id() != 0) + { + return y.get_Id() == restricaoUsuarioCamposRelatorio.get_Id(); + } + if (y.get_Campo() != restricaoUsuarioCamposRelatorio.get_Campo()) + { + return false; + } + return y.get_Relatorio() == restricaoUsuarioCamposRelatorio.get_Relatorio(); + }); + if (restricaoUsuarioCamposRelatorio1 != null && restricaoUsuarioCamposRelatorio1.get_Restricao() == restricaoUsuarioCamposRelatorio.get_Restricao()) + { + return; + } + if (restricaoUsuarioCamposRelatorio1 != null) + { + registroLogs.Add(base.CreateLog(restricaoUsuarioCamposRelatorio.get_Usuario().get_Id(), restricaoUsuarioCamposRelatorio.Compare(restricaoUsuarioCamposRelatorio1.GetValorOriginal()), 43, 1)); + } + else + { + registroLogs.Add(base.CreateLog(restricaoUsuarioCamposRelatorio.get_Usuario().get_Id(), restricaoUsuarioCamposRelatorio.GetValorOriginal(), 43, 0)); + } + restricaoUsuarioCamposRelatorio = (restricaoUsuarioCamposRelatorio.get_Id() == 0 ? commited.get_RestricaoUsuarioCamposRelatoriosRepository().SaveOrUpdate(restricaoUsuarioCamposRelatorio) : commited.get_RestricaoUsuarioCamposRelatoriosRepository().Merge(restricaoUsuarioCamposRelatorio)); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + restricaoUsuarioCamposRelatorios = restricoes; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 261, num, new { restricoes = restricoes, prev = prev }, true); + continue; + } + return restricaoUsuarioCamposRelatorios; + } + return restricaoUsuarioCamposRelatorios1; + }); + return restricaoUsuarioCamposRelatorios3; + } + } +} \ No newline at end of file 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 diff --git a/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs b/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs new file mode 100644 index 0000000..a2742e4 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs @@ -0,0 +1,335 @@ +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.Common; +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.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + internal class ServicoExtrato : BaseServico + { + public ServicoExtrato() + { + } + + internal async Task> BuscarDetalhes(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List detalheExtratos = read.get_DetalheExtratoRepository().Find(id); + Func u003cu003e9_01 = ServicoExtrato.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (DetalheExtrato x) => x.get_Cliente(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IOrderedEnumerable detalheExtratos1 = detalheExtratos.OrderBy(u003cu003e9_01); + Func u003cu003e9_02 = ServicoExtrato.u003cu003ec.u003cu003e9__0_2; + if (u003cu003e9_02 == null) + { + u003cu003e9_02 = (DetalheExtrato x) => x.get_Apolice(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02; + } + IOrderedEnumerable detalheExtratos2 = detalheExtratos1.ThenBy(u003cu003e9_02); + Func u003cu003e9_03 = ServicoExtrato.u003cu003ec.u003cu003e9__0_3; + if (u003cu003e9_03 == null) + { + u003cu003e9_03 = (DetalheExtrato x) => x.get_Endosso(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03; + } + IOrderedEnumerable detalheExtratos3 = detalheExtratos2.ThenBy(u003cu003e9_03); + Func u003cu003e9_04 = ServicoExtrato.u003cu003ec.u003cu003e9__0_4; + if (u003cu003e9_04 == null) + { + u003cu003e9_04 = (DetalheExtrato x) => x.get_NumeroParcela(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_4 = u003cu003e9_04; + } + observableCollection = new ObservableCollection(detalheExtratos3.ThenBy(u003cu003e9_04)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 91, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarExtrato(long id, long idusuario, StatusExtrato status, DateTime inicio, DateTime fim) + { + int num = 3; + List extratos2 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List extratos = read.get_ExtratoRepository().FindBySeguradora(id, idusuario, Recursos.Empresa.get_Id(), inicio, fim, new StatusExtrato?(status)); + Func u003cu003e9_21 = ServicoExtrato.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (Extrato x) => x.get_Numero(); + ServicoExtrato.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + IOrderedEnumerable extratos1 = extratos.OrderBy(u003cu003e9_21); + Func u003cu003e9_22 = ServicoExtrato.u003cu003ec.u003cu003e9__2_2; + if (u003cu003e9_22 == null) + { + u003cu003e9_22 = (Extrato x) => x.get_Data(); + ServicoExtrato.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22; + } + list = extratos1.ThenByDescending(u003cu003e9_22).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 92, num, new { id = id, status = status, inicio = inicio, fim = fim }, true); + continue; + } + return list; + } + return new List(); + }); + return extratos2; + } + + public async Task> BuscarExtratoPorData(Filtros filtros) + { + int num = 3; + List extratos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List extratos = read.get_ExtratoRepository().FindByData(filtros); + Func u003cu003e9_31 = ServicoExtrato.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (Extrato x) => x.get_Data(); + ServicoExtrato.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + list = extratos.OrderBy(u003cu003e9_31).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 93, num, filtros, true); + continue; + } + return list; + } + return new List(); + }); + return extratos1; + } + + internal async Task BuscarNumExtrato(long? id) + { + string str1; + if (id.HasValue) + { + long? nullable = id; + long num = (long)0; + if (!(nullable.GetValueOrDefault() <= num & nullable.HasValue)) + { + string str2 = ""; + int num1 = 3; + str1 = await Task.Run(() => { + string str; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + DetalheExtrato detalheExtrato = read.get_DetalheExtratoRepository().FindByLongId(id).FirstOrDefault(); + str2 = (detalheExtrato == null || detalheExtrato.get_Id() <= (long)0 ? "" : detalheExtrato.get_Extrato().get_Numero()); + str = str2; + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 91, num1, id, true); + continue; + } + return str; + } + return ""; + }); + return str1; + } + } + str1 = ""; + return str1; + } + + public async Task Delete(Extrato extrato) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ExtratoRepository().Delete(extrato.get_Id()); + registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.GetValorOriginal(), 1, 2)); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 264, num, extrato, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FindByParcelaId(long id) + { + int num = 3; + DetalheExtrato detalheExtrato1 = await Task.Run(() => { + DetalheExtrato detalheExtrato; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + detalheExtrato = read.get_DetalheExtratoRepository().FindByParcelaId(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 74, num, id, true); + continue; + } + return detalheExtrato; + } + return new DetalheExtrato(); + }); + return detalheExtrato1; + } + + public async Task Save(DetalheExtrato detalhe) + { + int num = 3; + base.Sucesso = true; + DetalheExtrato detalheExtrato1 = detalhe; + DetalheExtrato detalheExtrato2 = await Task.Run(() => { + DetalheExtrato detalheExtrato; + while (num > 0) + { + detalhe = detalheExtrato1; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (detalhe.get_Id() == 0 ? 0 : 1); + commited.get_DetalheExtratoRepository().Merge(detalhe); + if (tipoAcao != 1) + { + registroLogs.Add(base.CreateLog(detalhe.get_Id(), detalhe.Compare(detalheExtrato1.GetValorOriginal()), 23, tipoAcao)); + } + else + { + registroLogs.Add(base.CreateLog(detalhe.get_Id(), detalhe.GetValorOriginal(), 23, tipoAcao)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + detalheExtrato = detalhe; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 262, num, detalhe, true); + continue; + } + return detalheExtrato; + } + return detalheExtrato1; + }); + return detalheExtrato2; + } + + public async Task Save(Extrato extrato) + { + int num = 3; + base.Sucesso = true; + Extrato extrato1 = extrato; + Extrato extrato2 = await Task.Run(() => { + Extrato extrato3; + while (num > 0) + { + extrato = extrato1; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (extrato.get_Id() == 0 ? 0 : 1); + commited.get_ExtratoRepository().Merge(extrato); + if (tipoAcao != 1) + { + registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.Compare(extrato1.GetValorOriginal()), 23, tipoAcao)); + } + else + { + registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.GetValorOriginal(), 23, tipoAcao)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + extrato3 = extrato; + } + catch (Exception exception) + { + num = base.Registrar(exception, 263, num, extrato, true); + continue; + } + return extrato3; + } + return extrato1; + }); + return extrato2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/TarefaServico.cs b/Codemerx/Gestor.Application/Servicos/TarefaServico.cs new file mode 100644 index 0000000..792aea6 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/TarefaServico.cs @@ -0,0 +1,795 @@ +using Gestor.Application.Actions; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +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; +using System.Windows; +using System.Windows.Threading; + +namespace Gestor.Application.Servicos +{ + public class TarefaServico : BaseServico + { + public TarefaServico() + { + } + + public async Task AtualizarNotasTarefas() + { + int num = 3; + int[] numArray1 = await Task.Run(() => { + int[] numArray; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + numArray = read.get_TarefaRepository().ContarTarefas(Recursos.Usuario.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 100, num, Recursos.Usuario.get_Id(), true); + continue; + } + return numArray; + } + return new int[1]; + }); + return numArray1; + } + + public async Task> BuscarFases(long id) + { + int num = 3; + List fases1 = await Task.Run>(() => { + List fases; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + fases = read.get_TarefaRepository().BuscarFases(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 102, num, id, true); + continue; + } + return fases; + } + return new List(); + }); + return fases1; + } + + public async Task> BuscarNotas(long id) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefaPorUsuario(id, 1); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 98, num, id, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task> BuscarNotasConcluidas(long id) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefaConcluidaPorUsuario(id, 1); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 99, num, id, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task BuscarTarefa(long id) + { + int num = 3; + Tarefa tarefa1 = await Task.Run(() => { + Tarefa tarefa; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefa = read.get_TarefaRepository().BuscarTarefa(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 105, num, id, true); + continue; + } + return tarefa; + } + return new Tarefa(); + }); + return tarefa1; + } + + public async Task> BuscarTarefas(TipoTarefa entidade, long id, bool? concluido) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefa(entidade, id, concluido); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 94, num, new { entidade = entidade, id = id, concluido = concluido }, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task> BuscarTarefas(long id, DateTime inicio, DateTime fim, bool? concluido) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefaPorUsuario(id, inicio, fim, concluido); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 95, num, new { id = id, inicio = inicio, fim = fim, concluido = concluido }, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task> BuscarTarefas(long id) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefaPorTrilha(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 101, num, id, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task> BuscarTarefasCliente(long id) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefaPorCliente(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 96, num, id, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task> BuscarTarefasPorTipo(TipoDeTarefa tipoTarefa) + { + int num = 3; + List tarefas1 = await Task.Run>(() => { + List tarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefasPorTipo(tipoTarefa.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 309, num, new { tipoTarefa = tipoTarefa }, true); + continue; + } + return tarefas; + } + return new List(); + }); + return tarefas1; + } + + public async Task> BuscarTrilhas() + { + int num = 3; + List trilhas1 = await Task.Run>(() => { + List trilhas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + trilhas = read.get_TarefaRepository().BuscarTrilhas(true); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 104, num, null, true); + continue; + } + return trilhas; + } + return new List(); + }); + return trilhas1; + } + + private static void CleanWebEditor(Tarefa tarefa) + { + if (tarefa.get_Descricao() != null) + { + tarefa.set_Descricao(TarefaServico.RemoveXml(tarefa.get_Descricao())); + } + if (tarefa.get_DescricaoInterna() != null) + { + tarefa.set_DescricaoInterna(TarefaServico.RemoveXml(tarefa.get_DescricaoInterna())); + } + } + + public async Task Excluir(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_TarefaRepository().Excluir(id); + commited.Commit(); + } + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_51 = TarefaServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + TarefaServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + dispatcher.Invoke(u003cu003e9_51); + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 268, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task ExcluirTarefasDocumento(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + List tarefas = new List(); + using (UnitOfWork read = Instancia.Read) + { + tarefas = read.get_TarefaRepository().BuscarTarefa(0, id, new bool?(false)); + } + foreach (Tarefa tarefa in tarefas) + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_TarefaRepository().Excluir(tarefa.get_Id()); + commited.Commit(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(DateTime.Now); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting)); + registroLog.set_EntidadeId(tarefa.get_Id()); + registroLog.set_Tela(4); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_192 = TarefaServico.u003cu003ec.u003cu003e9__19_2; + if (u003cu003e9_192 == null) + { + u003cu003e9_192 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + TarefaServico.u003cu003ec.u003cu003e9__19_2 = u003cu003e9_192; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_192); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + } + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_191 = TarefaServico.u003cu003ec.u003cu003e9__19_1; + if (u003cu003e9_191 == null) + { + u003cu003e9_191 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + TarefaServico.u003cu003ec.u003cu003e9__19_1 = u003cu003e9_191; + } + dispatcher.Invoke(u003cu003e9_191); + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 268, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public static string RemoveXml(string description) + { + try + { + List strs = new List(); + string[] strArrays = description.Split(new char[] { '<' }); + for (int i = 0; i < (int)strArrays.Length; i++) + { + string str = strArrays[i]; + if (str.Contains("?xml") || str.Contains("o:p")) + { + strs.Add(string.Concat("<", str)); + } + } + foreach (string str1 in strs) + { + description = description.Replace(str1, ""); + } + } + catch (Exception exception) + { + throw exception; + } + return description; + } + + public async Task Salvar(Tarefa tarefa) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Tarefa tarefa2 = tarefa; + Tarefa tarefa3 = await Task.Run(() => { + Tarefa tarefa4; + string str; + while (num > 0) + { + tarefa = tarefa2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TarefaServico.CleanWebEditor(tarefa); + if (tarefa.get_Entidade() == 1) + { + tarefa.set_Descricao((!string.IsNullOrWhiteSpace(tarefa.get_Anotacoes()) ? tarefa.get_Anotacoes() : tarefa.get_Descricao())); + } + tarefa = (tarefa.get_Id() == (long)0 ? commited.get_TarefaRepository().Salvar(tarefa) : commited.get_TarefaRepository().Atualizar(tarefa)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Tarefa tarefa1 = tarefa; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa1, jsonSerializerSetting)); + registroLog.set_EntidadeId(tarefa.get_Id()); + registroLog.set_Tela(38); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_12 = TarefaServico.u003cu003ec.u003cu003e9__1_2; + if (u003cu003e9_12 == null) + { + u003cu003e9_12 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + TarefaServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_12); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_11 = TarefaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + TarefaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + dispatcher.Invoke(u003cu003e9_11); + tarefa4 = tarefa; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 265, num, tarefa, true); + continue; + } + return tarefa4; + } + return tarefa2; + }); + return tarefa3; + } + + public async Task Salvar(Trilha trilha) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Trilha trilha2 = trilha; + Trilha trilha3 = await Task.Run(() => { + Trilha trilha4; + string str; + while (num > 0) + { + trilha = trilha2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + trilha = (trilha.get_Id() == (long)0 ? commited.get_TarefaRepository().Salvar(trilha) : commited.get_TarefaRepository().Atualizar(trilha)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Trilha trilha1 = trilha; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(trilha1, jsonSerializerSetting)); + registroLog.set_EntidadeId(trilha.get_Id()); + registroLog.set_Tela(4); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_42 = TarefaServico.u003cu003ec.u003cu003e9__4_2; + if (u003cu003e9_42 == null) + { + u003cu003e9_42 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + TarefaServico.u003cu003ec.u003cu003e9__4_2 = u003cu003e9_42; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_42); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_41 = TarefaServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + TarefaServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + dispatcher.Invoke(u003cu003e9_41); + trilha4 = trilha; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 267, num, trilha, true); + continue; + } + return trilha4; + } + return trilha2; + }); + return trilha3; + } + + public async Task> Salvar(List fases) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + List fases1 = fases; + List fases2 = await Task.Run>(() => { + List fases3; + string str; + while (num > 0) + { + fases = fases1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + fases = commited.get_TarefaRepository().Salvar(fases); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + foreach (Fase fase in fases) + { + 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(fase, jsonSerializerSetting)); + registroLog.set_EntidadeId(fase.get_Id()); + registroLog.set_Tela(4); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_142 = TarefaServico.u003cu003ec.u003cu003e9__14_2; + if (u003cu003e9_142 == null) + { + u003cu003e9_142 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + TarefaServico.u003cu003ec.u003cu003e9__14_2 = u003cu003e9_142; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_142); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + commited.Commit(); + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_141 = TarefaServico.u003cu003ec.u003cu003e9__14_1; + if (u003cu003e9_141 == null) + { + u003cu003e9_141 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + TarefaServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141; + } + dispatcher.Invoke(u003cu003e9_141); + fases3 = fases; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 269, num, fases, true); + continue; + } + return fases3; + } + return fases1; + }); + return fases2; + } + + public async Task> Salvar(List tarefas) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + List tarefas1 = tarefas; + List tarefas2 = await Task.Run>(() => { + List tarefas3; + string str; + while (num > 0) + { + tarefas = tarefas1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + tarefas = commited.get_TarefaRepository().Salvar(tarefas); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + foreach (Tarefa tarefa in tarefas) + { + 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(tarefa, jsonSerializerSetting)); + registroLog.set_EntidadeId(tarefa.get_Id()); + registroLog.set_Tela(4); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_152 = TarefaServico.u003cu003ec.u003cu003e9__15_2; + if (u003cu003e9_152 == null) + { + u003cu003e9_152 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + TarefaServico.u003cu003ec.u003cu003e9__15_2 = u003cu003e9_152; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_152); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + commited.Commit(); + Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher; + Action u003cu003e9_151 = TarefaServico.u003cu003ec.u003cu003e9__15_1; + if (u003cu003e9_151 == null) + { + u003cu003e9_151 = () => Gestor.Application.Actions.Actions.AtualizaBadges(); + TarefaServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151; + } + dispatcher.Invoke(u003cu003e9_151); + tarefas3 = tarefas; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 265, num, tarefas, true); + continue; + } + return tarefas3; + } + return tarefas1; + }); + return tarefas2; + } + + public async Task> Validar(List ids, long trilhaId) + { + int num = 3; + List nums1 = await Task.Run>(() => { + List nums; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + nums = commited.get_TarefaRepository().Validar(ids, trilhaId); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 266, num, new { ids = ids, trilhaId = trilhaId }, true); + continue; + } + return nums; + } + return null; + }); + return nums1; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs new file mode 100644 index 0000000..4804dac --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs @@ -0,0 +1,160 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + public class VendedorUsuarioServico : BaseServico + { + public VendedorUsuarioServico() + { + } + + public async Task Delete(List vinculo) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vinculo.ForEach((VendedorUsuario x) => commited.get_VendedorUsuarioRepository().Delete(x.get_Id())); + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 272, num, vinculo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> FindByVinculo(Usuario usuario) + { + int num = 3; + List vendedorUsuarios = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + list = read.get_VendedorUsuarioRepository().FindByVinculo(usuario.get_Id()).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 106, num, usuario, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorUsuarios; + } + + public async Task FindVinculo(Vendedor vendedor) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_VendedorUsuarioRepository().Exist(vendedor.get_Id()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 271, num, vendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FindVinculoByUsuario(long idusuario) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_VendedorUsuarioRepository().ExistVinculoUsuario(idusuario); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 106, num, null, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> SaveOrUpdate(List vinculo) + { + int num = 3; + base.Sucesso = true; + List vendedorUsuarios1 = vinculo; + List vendedorUsuarios2 = await Task.Run>(() => { + List vendedorUsuarios; + while (num > 0) + { + vinculo = vendedorUsuarios1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vinculo.ForEach((VendedorUsuario x) => commited.get_VendedorUsuarioRepository().SaveOrUpdate(x)); + commited.Commit(); + } + vendedorUsuarios = vinculo; + } + catch (Exception exception) + { + num = base.Registrar(exception, 271, num, vinculo, true); + continue; + } + return vendedorUsuarios; + } + return vendedorUsuarios1; + }); + return vendedorUsuarios2; + } + } +} \ No newline at end of file -- cgit v1.2.3