From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../ArquivoDigitalServico.cs | 594 ++++++++++++ .../AssinaturaServico.cs | 209 +++++ .../Gestor.Application.Servicos/CepService.cs | 85 ++ .../Gestor.Application.Servicos/LogServico.cs | 267 ++++++ .../MalaDiretaServico.cs | 185 ++++ .../Gestor.Application.Servicos/ParceiroServico.cs | 124 +++ .../Gestor.Application.Servicos/ParcelaServico.cs | 994 +++++++++++++++++++++ .../PermissaoArquivoDigitalServico.cs | 181 ++++ .../PermissaoUsuarioServico.cs | 160 ++++ .../ProspeccaoServico.cs | 340 +++++++ .../RestricaoUsuarioServico.cs | 222 +++++ .../Gestor.Application.Servicos/ServicoExtrato.cs | 310 +++++++ .../Gestor.Application.Servicos/TarefaServico.cs | 817 +++++++++++++++++ .../VendedorUsuarioServico.cs | 175 ++++ 14 files changed, 4663 insertions(+) create mode 100644 Decompiler/Gestor.Application.Servicos/ArquivoDigitalServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/AssinaturaServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/CepService.cs create mode 100644 Decompiler/Gestor.Application.Servicos/LogServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/MalaDiretaServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/ParceiroServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/ParcelaServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/PermissaoArquivoDigitalServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/PermissaoUsuarioServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/RestricaoUsuarioServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs create mode 100644 Decompiler/Gestor.Application.Servicos/TarefaServico.cs create mode 100644 Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs (limited to 'Decompiler/Gestor.Application.Servicos') diff --git a/Decompiler/Gestor.Application.Servicos/ArquivoDigitalServico.cs b/Decompiler/Gestor.Application.Servicos/ArquivoDigitalServico.cs new file mode 100644 index 0000000..637a396 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/ArquivoDigitalServico.cs @@ -0,0 +1,594 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +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.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; + +namespace Gestor.Application.Servicos; + +public class ArquivoDigitalServico : BaseServico +{ + public async Task> BuscarPorTipo(TipoArquivoDigital tipo, long id) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + long usuario = ((DomainBase)Recursos.Usuario).Id; + return await Task.Run(delegate + { + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.IndiceArquivoDigitalRepository.Find(tipo, id, usuario, LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)64, tries, new { tipo, id }); + } + } + return new List(); + }); + } + + public async Task BuscarPorId(long id, string banco) + { + int tries = 3; + return await Task.Run((Func)delegate + { + while (tries > 0) + { + try + { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(banco); + if (string.IsNullOrEmpty(banco)) + { + banco = Gestor.Application.Helpers.ArquivoDigital.Banco; + } + UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read; + try + { + ArquivoDigital val = read.ArquivoDigitalRepository.FindById(id, true); + if (val == null) + { + return (ArquivoDigital)null; + } + if (val.AzureGuid.HasValue) + { + byte[] result = Connection.DownloadFile(val.AzureStorage, val.DataCriacao.Value.Year, val.AzureGuid.Value, val.Extensao).Result; + if (result == null) + { + return (ArquivoDigital)null; + } + val.Arquivo = result; + } + return val; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)65, tries, new { id, banco }); + } + } + return (ArquivoDigital)null; + }); + } + + public async Task BuscarPorId(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + ArquivoDigital val = read.IndiceArquivoDigitalRepository.FindAssinatura(id); + if (val.AzureGuid.HasValue) + { + byte[] result = Connection.DownloadFile(val.AzureStorage, val.DataCriacao.Value.Year, val.AzureGuid.Value, Path.GetExtension(val.Descricao), "siggner").Result; + if (result == null) + { + return (ArquivoDigital)null; + } + val.Arquivo = result; + } + return val; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)64, tries, id); + } + } + return (ArquivoDigital)null; + }); + } + + public async Task DeleteAttachment(IndiceArquivoDigital indice) + { + int tries = 3; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Expected O, but got Unknown + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Expected O, but got Unknown + //IL_0101: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + //IL_0111: Unknown result type (might be due to invalid IL or missing references) + //IL_011c: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Expected O, but got Unknown + while (tries > 0) + { + List list = new List(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + indice.Excluido = true; + List list2 = new List + { + new Diferenca + { + Campo = "Id", + Descricao = "ID", + ValorAtual = ((DomainBase)indice).Id.ToString() + }, + new Diferenca + { + Campo = "Descricao", + Descricao = "DESCRIÇÃO", + ValorAtual = indice.Descricao + } + }; + if (indice.AzureGuid.HasValue && Connection.DeleteFile(indice.AzureStorage, indice.DataCriacao.Value.Year, indice.AzureGuid.Value, indice.Extensao).Result) + { + list2.Add(new Diferenca + { + Campo = "AzureGuid", + Descricao = "AzureGuid", + ValorAtual = indice.AzureGuid.ToString() + }); + } + list.Add(CreateLog(((DomainBase)indice).Id, list2, (TipoTela)6, (TipoAcao)2)); + indice.DataAtualizacao = now; + if (!indice.DataCriacao.HasValue || indice.DataCriacao.Value.Year < 1754) + { + indice.DataCriacao = now; + } + commited.IndiceArquivoDigitalRepository.Merge(indice); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + return true; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)253, tries, indice); + } + } + return false; + }); + } + + public async Task Save(IndiceArquivoDigital indice) + { + int tries = 3; + base.Sucesso = true; + IndiceArquivoDigital indiceOriginal = indice; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run((Func)delegate + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Invalid comparison between Unknown and I4 + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Invalid comparison between Unknown and I4 + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00bd: Invalid comparison between Unknown and I4 + //IL_00c5: Unknown result type (might be due to invalid IL or missing references) + //IL_00ca: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Expected O, but got Unknown + //IL_010b: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + indice = indiceOriginal; + List list = new List(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val = (TipoAcao)(((DomainBase)indice).Id != 0L); + indice.DataAtualizacao = now; + indice.UsuarioAtualizacao = ((DomainBase)Recursos.Usuario).Id; + indice.Excluido = false; + if ((int)val == 1) + { + list.Add(CreateLog(((DomainBase)indice).Id, indice, (TipoTela)6)); + } + indice = (((int)val == 1) ? commited.IndiceArquivoDigitalRepository.Merge(indice) : commited.IndiceArquivoDigitalRepository.SaveOrUpdate(indice)); + if ((int)val != 1) + { + List diferenca = new List + { + new Diferenca + { + Campo = "Descricao", + Descricao = "DESCRIÇÃO", + ValorAtual = indice.Descricao + } + }; + list.Add(CreateLog(((DomainBase)indice).Id, diferenca, (TipoTela)6, val)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + return indice; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)252, tries, indice); + } + } + return indiceOriginal; + }); + } + + public async Task> Insert(List files) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + List filesOriginal = files; + return await Task.Run(delegate + { + while (tries > 0) + { + List logs = new List(); + files = filesOriginal; + try + { + List indices = new List(); + files.ForEach(delegate(ArquivoDigital file) + { + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Expected O, but got Unknown + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ce: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00e5: Unknown result type (might be due to invalid IL or missing references) + //IL_00f1: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_0115: Unknown result type (might be due to invalid IL or missing references) + //IL_0121: Unknown result type (might be due to invalid IL or missing references) + //IL_012d: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_0145: Unknown result type (might be due to invalid IL or missing references) + //IL_0151: Unknown result type (might be due to invalid IL or missing references) + //IL_015d: Unknown result type (might be due to invalid IL or missing references) + //IL_0169: Unknown result type (might be due to invalid IL or missing references) + //IL_0175: Unknown result type (might be due to invalid IL or missing references) + //IL_0181: Unknown result type (might be due to invalid IL or missing references) + //IL_018d: Unknown result type (might be due to invalid IL or missing references) + //IL_0199: Unknown result type (might be due to invalid IL or missing references) + //IL_01a5: Unknown result type (might be due to invalid IL or missing references) + //IL_01b1: Unknown result type (might be due to invalid IL or missing references) + //IL_01bd: Unknown result type (might be due to invalid IL or missing references) + //IL_01c9: Unknown result type (might be due to invalid IL or missing references) + //IL_01d5: Unknown result type (might be due to invalid IL or missing references) + //IL_01e1: Unknown result type (might be due to invalid IL or missing references) + //IL_01ed: Unknown result type (might be due to invalid IL or missing references) + //IL_01f9: Unknown result type (might be due to invalid IL or missing references) + //IL_0206: Expected O, but got Unknown + //IL_0268: Unknown result type (might be due to invalid IL or missing references) + //IL_026d: Unknown result type (might be due to invalid IL or missing references) + //IL_0278: Unknown result type (might be due to invalid IL or missing references) + //IL_0283: Unknown result type (might be due to invalid IL or missing references) + //IL_0294: Expected O, but got Unknown + file.UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id; + file.DataCriacao = now; + file.DataAtualizacao = null; + UploadFile val = new UploadFile + { + Ano = now.Year, + Id = Guid.NewGuid(), + Extensao = file.Extensao.Replace(".", string.Empty), + Arquivo = file.Arquivo + }; + if (Connection.ConnectionAddress.UsaAzureStorage && Connection.UploadFile(val).Result) + { + file.AzureGuid = val.Id; + file.Arquivo = null; + file.AzureStorage = Connection.ConnectionAddress.AzureStorage; + } + IndiceArquivoDigital val2 = new IndiceArquivoDigital + { + Descricao = file.Descricao, + Bd = Gestor.Application.Helpers.ArquivoDigital.Banco, + Extensao = file.Extensao, + IdCliente = file.IdCliente, + IdDocumento = file.IdDocumento, + IdEmpresa = file.IdEmpresa, + IdParcela = file.IdParcela, + IdItem = file.IdItem, + IdExtrato = file.IdExtrato, + IdSinistro = file.IdSinistro, + IdSeguradora = file.IdSeguradora, + IdVendedor = file.IdVendedor, + IdUsuario = file.IdUsuario, + IdLancamento = file.IdLancamento, + IdFornecedor = file.IdFornecedor, + IdProspeccao = file.IdProspeccao, + IdSocio = file.IdSocio, + IdTarefa = file.IdTarefa, + IdNotaFiscal = file.IdNotaFiscal, + IdEstipulante = file.IdEstipulante, + Excluido = file.Excluido, + UsuarioCriacao = file.UsuarioCriacao, + DataCriacao = file.DataCriacao, + DataAtualizacao = file.DataAtualizacao, + AzureGuid = file.AzureGuid, + AzureStorage = file.AzureStorage + }; + Gestor.Application.Helpers.ArquivoDigital.SetConnection(); + val2.Bd = Gestor.Application.Helpers.ArquivoDigital.Banco; + UnitOfWork commited = Gestor.Application.Helpers.ArquivoDigital.Commited; + try + { + file = commited.ArquivoDigitalRepository.SaveOrUpdate(file); + val2.IdArquivoDigital = ((DomainBase)file).Id; + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + UnitOfWork commited2 = Instancia.Commited; + try + { + val2 = commited2.IndiceArquivoDigitalRepository.SaveOrUpdate(val2); + List diferenca = new List + { + new Diferenca + { + Campo = "Descricao", + Descricao = "DESCRIÇÃO", + ValorAtual = val2.Descricao + } + }; + logs.Add(CreateLog(((DomainBase)val2).Id, diferenca, (TipoTela)6, (TipoAcao)0)); + SaveLog(logs, commited2); + ((GenericUnitOfWork)commited2).Commit(); + } + finally + { + ((IDisposable)commited2)?.Dispose(); + } + indices.Add(val2); + }); + return indices; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)252, tries, files); + } + } + return new List(); + }); + } + + public async Task> Buscar(List ids) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + List arquivos = new List(); + (from x in ids + group x by x.Bd).ToList().ForEach(delegate(IGrouping x) + { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(x.Key); + List list = (from l in x + where !l.Assinado + select l.IdArquivoDigital).ToList(); + List list2 = (from l in x + where l.Assinado + select ((DomainBase)l).Id).ToList(); + if (list2.Any()) + { + List _arquivos2 = new List(); + UnitOfWork unitOfWork2 = Instancia.Read; + try + { + list2.ForEach(delegate(long a) + { + ArquivoDigital val2 = unitOfWork2.IndiceArquivoDigitalRepository.FindAssinatura(a); + if (val2.AzureGuid.HasValue) + { + val2.Arquivo = Connection.DownloadFile(val2.AzureStorage, val2.DataCriacao.Value.Year, val2.AzureGuid.Value, Path.GetExtension(val2.Descricao), "siggner").Result; + } + if (val2.Arquivo != null) + { + _arquivos2.Add(val2); + } + }); + } + finally + { + if (unitOfWork2 != null) + { + ((IDisposable)unitOfWork2).Dispose(); + } + } + arquivos.AddRange(_arquivos2); + } + if (list.Any()) + { + List _arquivos = new List(); + UnitOfWork unitOfWork = Gestor.Application.Helpers.ArquivoDigital.Read; + try + { + list.ForEach(delegate(long a) + { + ArquivoDigital val = unitOfWork.ArquivoDigitalRepository.FindById(a, true); + if (val.AzureGuid.HasValue) + { + val.Arquivo = Connection.DownloadFile(val.AzureStorage, val.DataCriacao.Value.Year, val.AzureGuid.Value, val.Extensao).Result; + } + if (val.Arquivo != null) + { + _arquivos.Add(val); + } + }); + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + arquivos.AddRange(_arquivos); + } + }); + return arquivos; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)66, tries, ids); + } + } + return new List(); + }); + } + + public async Task Criar() + { + int tries = 3; + await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read; + try + { + read.ArquivoDigitalRepository.FindById(1L, false); + break; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)288, tries); + } + } + }); + } + + public async Task> BaixarArquivosPendentes(List arquivos) + { + string banco = Gestor.Application.Helpers.ArquivoDigital.Banco; + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read; + try + { + foreach (ArquivoVinculo arquivo in arquivos) + { + if (arquivo.Arquivo == null && !ExtensionMethods.IsNullOrEmpty((IEnumerable)arquivo.Chave)) + { + byte[] result = Connection.DownloadFile(arquivo.Storage, arquivo.Ano, Guid.Parse(arquivo.Chave), ".pdf", "aggilizador").Result; + if (result != null) + { + arquivo.Arquivo = result; + } + } + } + return arquivos; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)65, tries, new { arquivos, banco }); + } + } + return (List)null; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/AssinaturaServico.cs b/Decompiler/Gestor.Application.Servicos/AssinaturaServico.cs new file mode 100644 index 0000000..3232c05 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/AssinaturaServico.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Assinador.Infrastructure.UnitOfWork.Generic; +using Assinador.Infrastructure.UnitOfWork.Logic; +using Assinador.Model.Common; +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; + +namespace Gestor.Application.Servicos; + +public class AssinaturaServico +{ + internal async void SaveLog(AssinaturaLogAssinador keyValues, UnitOfWork unitOfWork) + { + if (keyValues == null) + { + return; + } + try + { + unitOfWork.AssinaturaLogRepository.SaveOrUpdate(keyValues); + ((GenericUnitOfWork)unitOfWork).Commit(); + } + catch (Exception) + { + } + } + + public static async Task BuscarParametrosAssinatura(long id) + { + return await Task.Run((Func)delegate + { + try + { + UnitOfWork read = InstanciaAssinador.Read; + try + { + return read.EmpresaRepository.FindByEmpresa(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception) + { + return (ParametrosAssinaturaAssinador)null; + } + }); + } + + public async Task Save(ArquivoParaAssinaturaAssinador arquivo) + { + return await Task.Run((Func)delegate + { + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_007d: Expected O, but got Unknown + //IL_0082: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_00a3: Expected O, but got Unknown + try + { + UnitOfWork commited = InstanciaAssinador.Commited; + try + { + arquivo = ((((BaseModel)arquivo).Id == 0L) ? commited.ArquivoParaAssinaturaRepository.SaveOrUpdate(arquivo) : commited.ArquivoParaAssinaturaRepository.Merge(arquivo)); + AssinaturaLogAssinador keyValues = new AssinaturaLogAssinador + { + Acao = (Acao)0, + EntidadeId = ((BaseModel)arquivo).Id, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)arquivo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + UsuarioId = ((DomainBase)Recursos.Usuario).Id, + Versao = ApplicationHelper.Versao.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return arquivo; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception) + { + return (ArquivoParaAssinaturaAssinador)null; + } + }); + } + + public async Task Assinar(ArquivoDigital arquivoDigital, ApoliceAssinador apolice) + { + AggerSigner val = new AggerSigner(AssinadorHelper.Remetente); + ArquivoAssinatura val2 = new ArquivoAssinatura + { + Bytes = arquivoDigital.Arquivo, + Nome = arquivoDigital.Descricao + arquivoDigital.Extensao.ToLower() + }; + List destinatarios = new List + { + new Destinatario + { + Email = apolice.Email, + Nome = apolice.Cliente, + Documento = apolice.Documento + } + }; + val2.Destinatarios = destinatarios; + ArquivoCriado val3 = await val.EnviarParaAssinatura(val2); + return new ArquivoParaAssinaturaAssinador + { + AssinaturaId = val3.Id, + Chave = val3.Chave, + DocumentoId = ((BaseModel)apolice).Id, + ClienteId = apolice.ClienteId, + IndiceId = apolice.ArquivoId, + UrlAssinatura = val3.Url, + Enviado = Funcoes.GetNetworkTime(), + UsuarioId = ((DomainBase)Recursos.Usuario).Id + }; + } + + public async Task VerificarAssinado(long id) + { + return await Task.Run(delegate + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Invalid comparison between Unknown and I4 + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Invalid comparison between Unknown and I4 + UnitOfWork read = InstanciaAssinador.Read; + try + { + ArquivoParaAssinaturaAssinador val = read.ArquivoParaAssinaturaRepository.FindByIndice(id); + return val != null && ((int)val.Status == 1 || (int)val.Status == 2); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + }); + } + + public async Task VerificarEnviado(long id) + { + return await Task.Run(delegate + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Invalid comparison between Unknown and I4 + UnitOfWork read = InstanciaAssinador.Read; + try + { + ArquivoParaAssinaturaAssinador val = read.ArquivoParaAssinaturaRepository.FindByIndice(id); + return val != null && (int)val.Status == 0; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + }); + } + + public async Task Reenviar(long indice) + { + AggerSigner val = new AggerSigner(AssinadorHelper.Remetente); + UnitOfWork unitOfWork = InstanciaAssinador.Commited; + try + { + ArquivoParaAssinaturaAssinador assinatura = unitOfWork.ArquivoParaAssinaturaRepository.FindByIndice(indice); + await val.ReenviarParaAssinatura(new List { assinatura.AssinaturaId }, (string)null); + AssinaturaLogAssinador keyValues = new AssinaturaLogAssinador + { + Acao = (Acao)1, + EntidadeId = ((BaseModel)assinatura).Id, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)assinatura, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + UsuarioId = ((DomainBase)Recursos.Usuario).Id, + Versao = ApplicationHelper.Versao.ToString() + }; + SaveLog(keyValues, unitOfWork); + return assinatura; + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } +} diff --git a/Decompiler/Gestor.Application.Servicos/CepService.cs b/Decompiler/Gestor.Application.Servicos/CepService.cs new file mode 100644 index 0000000..0ee1d2c --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/CepService.cs @@ -0,0 +1,85 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using Agger.Registro; +using Gestor.Application.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Helper; +using Newtonsoft.Json.Linq; + +namespace Gestor.Application.Servicos; + +public class CepService +{ + private const string GuidGestor = "bbbf4f03-01fc-4300-b430-33e007753578"; + + public async Task SearchDirect(string cep) + { + return await SearchDirectApiAgger(cep); + } + + private static async Task Authorization() + { + HttpClient client = new HttpClient(); + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string arg = DateTime.Now.ToString("yyyy-MM-dd"); + string content = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}", ApplicationHelper.IdFornecedor, "bbbf4f03-01fc-4300-b430-33e007753578", arg))); + Uri uri = Address.ApiCep.Append("/auth"); + HttpResponseMessage val = await client.PostAsync(uri, (HttpContent)(object)content.ToHttpContent()); + return (!val.IsSuccessStatusCode) ? string.Empty : ((object)val.Content.ToJObject()["token"])?.ToString(); + } + finally + { + ((IDisposable)client)?.Dispose(); + } + } + + public async Task SearchDirectApiAgger(string cep) + { + _ = 2; + try + { + string cepCleared = ValidationHelper.OnlyNumber(cep); + if (ValidationHelper.IsNullOrEmpty(cepCleared)) + { + return null; + } + HttpClient httpClient = new HttpClient(); + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string text = await Authorization(); + ((HttpHeaders)httpClient.DefaultRequestHeaders).TryAddWithoutValidation("Authorization", "Bearer " + text); + Uri uri = Address.ApiCep.Append(cepCleared); + string text2 = await (await httpClient.GetAsync(uri)).Content.ReadAsStringAsync(); + JObject val = JObject.Parse(text2); + if (val == null || text2.Equals("Endereço não encontrado")) + { + return null; + } + return new EnderecoBase + { + Endereco = ((object)val["logradouro"])?.ToString().ToUpper(), + Bairro = ((object)val["bairro"])?.ToString().ToUpper(), + Cidade = ((object)val["cidade"])?.ToString().ToUpper(), + Estado = ((object)val["estado"])?.ToString().ToUpper(), + Cep = ((object)val["cep"])?.ToString().ToUpper() + }; + } + finally + { + ((IDisposable)httpClient)?.Dispose(); + } + } + catch (Exception) + { + return null; + } + } +} diff --git a/Decompiler/Gestor.Application.Servicos/LogServico.cs b/Decompiler/Gestor.Application.Servicos/LogServico.cs new file mode 100644 index 0000000..45c1289 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/LogServico.cs @@ -0,0 +1,267 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.API; +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; + +namespace Gestor.Application.Servicos; + +public class LogServico : BaseServico +{ + public async Task> FindByEntityId(TipoTela tela, long id) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run(delegate + { + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.RegistroLogRepository.FindByEntityId(tela, id) + orderby x.DataHora descending + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)67, tries, new { tela, id }); + } + } + return new ObservableCollection(); + }); + } + + public async Task> BuscaLogParcelas(List ids) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.RegistroLogRepository.BuscaLogParcelas(ids) + orderby x.DataHora descending + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)67, tries, new + { + Parcela = (TipoTela)5, + ids = ids + }); + } + } + return new ObservableCollection(); + }); + } + + public async Task> FindByEntity(TipoTela tela, long id) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run(delegate + { + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.RegistroLogRepository.FindByEntity(tela, id) + orderby x.Data descending + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)68, tries, new { tela, id }); + } + } + return new ObservableCollection(); + }); + } + + public async Task> FindById(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(read.RegistroLogRepository.FindByIdSingle(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)69, tries, new { id }); + } + } + return new ObservableCollection(); + }); + } + + public async Task> FindAllByEntityId(TipoTela tela, long id) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run(delegate + { + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.RegistroLogRepository.FindByEntityId(tela, id) + orderby x.DataHora descending + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)67, tries, new { tela, id }); + } + } + return new ObservableCollection(); + }); + } + + public async Task> BuscarLogsEnvio(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RegistroLogRepository.LogsEnvio(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)9, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarLogs(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RegistroAcaoRepository.Find(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)321, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarLogsAntigos(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RegistroAcaoRepository.FindOld(filtro, Connection.GetConnectionString()); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)321, tries, filtro); + } + } + return new List(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/MalaDiretaServico.cs b/Decompiler/Gestor.Application.Servicos/MalaDiretaServico.cs new file mode 100644 index 0000000..61b55a6 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/MalaDiretaServico.cs @@ -0,0 +1,185 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +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.MalaDireta; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos; + +public class MalaDiretaServico : BaseServico +{ + public async Task> BuscarModelos() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ModeloMalaDiretaRepository.Find() + orderby x.Assunto + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)70, tries); + } + } + return new List(); + }); + } + + public async Task Save(ModeloMalaDireta modelo) + { + int tries = 3; + base.Sucesso = true; + ModeloMalaDireta modeloeOriginal = modelo; + return await Task.Run((Func)delegate + { + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_008a: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Expected O, but got Unknown + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00c4: Unknown result type (might be due to invalid IL or missing references) + //IL_00cf: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_0117: Expected O, but got Unknown + while (tries > 0) + { + modelo = modeloeOriginal; + try + { + TipoAcao val = (TipoAcao)(((DomainBase)modelo).Id != 0L); + UnitOfWork commited = Instancia.Commited; + try + { + modelo = (((int)val == 0) ? commited.ModeloMalaDiretaRepository.SaveOrUpdate(modelo) : commited.ModeloMalaDiretaRepository.Merge(modelo)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = val, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)modelo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)modelo).Id, + Tela = (TipoTela)39, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return modelo; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)254, tries, modelo); + } + } + return modeloeOriginal; + }); + } + + public async Task Delete(ModeloMalaDireta modelo) + { + int tries = 3; + return await Task.Run(delegate + { + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0039: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Expected O, but got Unknown + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + //IL_0085: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_00a6: Unknown result type (might be due to invalid IL or missing references) + //IL_00e3: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.ModeloMalaDiretaRepository.Delete(((DomainBase)modelo).Id); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)2, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)modelo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)modelo).Id, + Tela = (TipoTela)39, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)255, tries, modelo); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/ParceiroServico.cs b/Decompiler/Gestor.Application.Servicos/ParceiroServico.cs new file mode 100644 index 0000000..c96b2ed --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/ParceiroServico.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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; + +namespace Gestor.Application.Servicos; + +internal class ParceiroServico : BaseServico +{ + public async Task Save(Parceiro parceiro) + { + int tries = 3; + base.Sucesso = true; + Parceiro parceiroOriginal = parceiro; + return await Task.Run((Func)delegate + { + while (tries > 0) + { + List list = new List(); + parceiro = parceiroOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)parceiro).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)parceiro).Id, parceiro, (TipoTela)22)); + } + parceiro = ((((DomainBase)parceiro).Id == 0L) ? commited.ParceiroRepository.SaveOrUpdate(parceiro) : commited.ParceiroRepository.Merge(parceiro)); + if (!num) + { + list.Add(CreateLog(((DomainBase)parceiro).Id, ((DomainBase)parceiro).GetValorOriginal(), (TipoTela)22, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return parceiro; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)256, tries, parceiro); + } + } + return parceiroOriginal; + }); + } + + internal async Task BuscarParceiro(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParceiroRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)71, tries, id); + } + } + return new Parceiro(); + }); + } + + public async Task Delete(Parceiro parceiro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List list = new List(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)parceiro).Id, ((DomainBase)parceiro).GetValorOriginal(), (TipoTela)22, (TipoAcao)2)); + commited.ParceiroRepository.Delete(((DomainBase)parceiro).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)257, tries, parceiro); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/ParcelaServico.cs b/Decompiler/Gestor.Application.Servicos/ParcelaServico.cs new file mode 100644 index 0000000..4b00269 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/ParcelaServico.cs @@ -0,0 +1,994 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +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.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; + +namespace Gestor.Application.Servicos; + +internal class ParcelaServico : BaseServico +{ + internal async Task> BuscarParcelasAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.ParcelaRepository.FindByDocumentId(id) + orderby x.NumeroParcela + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)73, tries, id); + } + } + return new ObservableCollection(); + }); + } + + internal async Task> BuscarParcelasPorDocumento(Documento documento) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.ParcelaRepository.FindByDocumento(documento) + orderby x.NumeroParcela + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)73, tries, ((DomainBase)documento).Id); + } + } + return new ObservableCollection(); + }); + } + + internal async Task> BuscarTodasParcelas(List ids) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindByDocumentId(ids); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)73, tries, ids); + } + } + return new List(); + }); + } + + internal async Task> BuscarParcelas(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ParcelaRepository.FindByDocumentId(id) + orderby x.NumeroParcela + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)73, tries, id); + } + } + return new List(); + }); + } + + internal async Task> BuscarParcelas(string ids, List documentos) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindByDocumentIds(ids, documentos); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)75, tries); + } + } + return new List(); + }); + } + + internal async Task> BuscarVendedores(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.VendedorParcelaRepository.FindByDocumentId(id) + group x by ((DomainBase)x.Vendedor).Id into x + select x.First().Vendedor).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)140, tries); + } + } + return new List(); + }); + } + + public async Task Save(Parcela parcela, List todas, List repasses = null, bool abrirTela = true) + { + int tries = 3; + base.Sucesso = true; + Parcela parcelaOriginal = parcela; + List repassesOriginais = repasses; + Funcoes.GetNetworkTime(); + ObservableCollection oldParcelas = await BuscarParcelasAsync(((DomainBase)parcela.Documento).Id); + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + Parcela val = ((IEnumerable)oldParcelas).FirstOrDefault((Func)((Parcela x) => ((DomainBase)x).Id == ((DomainBase)parcela).Id)); + List list = new List(); + UnitOfWork commited = Instancia.Commited; + try + { + bool flag = ((DomainBase)parcela).Id == 0; + parcela.IdEmpresa = parcela.Documento.Controle.IdEmpresa; + parcela = (flag ? commited.ParcelaRepository.SaveOrUpdate(parcela) : commited.ParcelaRepository.Merge(parcela)); + if (repasses != null) + { + foreach (VendedorParcela repass in repasses) + { + repass.Documento = parcela.Documento; + repass.Parcela = parcela; + if (((DomainBase)repass).Id == 0L) + { + commited.VendedorParcelaRepository.SaveOrUpdate(repass); + } + else + { + commited.VendedorParcelaRepository.Merge(repass); + } + } + parcela.Vendedores = new ObservableCollection(repasses); + } + if (flag) + { + list.Add(CreateLog(((DomainBase)parcela).Id, ((DomainBase)parcela).GetValorOriginal(), (TipoTela)5, (TipoAcao)0)); + } + else + { + list.Add(CreateLog(((DomainBase)parcela).Id, ((DomainBase)parcela).Compare(((DomainBase)val).GetValorOriginal()), (TipoTela)5, (TipoAcao)1)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return parcela; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)24, tries, parcelaOriginal, abrirTela); + } + } + parcelaOriginal.Vendedores = ((repassesOriginais != null) ? new ObservableCollection(repassesOriginais) : null); + return parcelaOriginal; + }); + } + + public async Task Save(VendedorParcela pagamento) + { + int tries = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + return await Task.Run((Func)delegate + { + while (tries > 0) + { + VendedorParcela val = pagamento; + try + { + List list = new List(); + UnitOfWork commited = Instancia.Commited; + try + { + val = ((((DomainBase)val).Id == 0L) ? commited.VendedorParcelaRepository.SaveOrUpdate(val) : commited.VendedorParcelaRepository.Merge(val)); + if (((DomainBase)pagamento).Id == 0L) + { + list.Add(CreateLog(((DomainBase)val).Id, ((DomainBase)val).GetValorOriginal(), (TipoTela)37, (TipoAcao)0)); + } + else + { + list.Add(CreateLog(((DomainBase)val).Id, ((DomainBase)val).Compare(((DomainBase)val).GetValorOriginal()), (TipoTela)37, (TipoAcao)1)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return val; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)189, tries, pagamento); + } + } + return pagamento; + }); + } + + public async Task> SaveRange(List parcela) + { + int tries = 3; + base.Sucesso = true; + return await Task.Run(delegate + { + while (tries > 0) + { + List list = parcela; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + foreach (Parcela item in list) + { + if (((DomainBase)item).Id == 0L) + { + item.IdEmpresa = item.Documento.Controle.IdEmpresa; + commited.ParcelaRepository.SaveOrUpdate(item); + } + else + { + commited.ParcelaRepository.Merge(item); + } + } + ((GenericUnitOfWork)commited).Commit(); + return list; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)24, tries, parcela); + } + } + return parcela; + }); + } + + public async Task SaveRange(List repasses) + { + int tries = 3; + List repassesOriginais = repasses; + Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + repasses = repassesOriginais; + try + { + List logs = new List(); + UnitOfWork unitOfWork = Instancia.Commited; + try + { + repasses?.ForEach(Action); + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return true; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + void Action(VendedorParcela x) + { + _ = ((DomainBase)x).Id; + x = ((((DomainBase)x).Id == 0L) ? unitOfWork.VendedorParcelaRepository.SaveOrUpdate(x) : unitOfWork.VendedorParcelaRepository.Merge(x)); + if (((DomainBase)x).Id == 0L) + { + logs.Add(CreateLog(((DomainBase)x).Id, ((DomainBase)x).GetValorOriginal(), (TipoTela)37, (TipoAcao)0)); + } + else + { + logs.Add(CreateLog(((DomainBase)x).Id, ((DomainBase)x).Compare(((DomainBase)x).GetValorOriginal()), (TipoTela)37, (TipoAcao)1)); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)189, tries, repasses, abrirTela: false); + } + } + return false; + }); + } + + public async Task Delete(Parcela parcela, List todas) + { + int tries = 3; + Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.ParcelaRepository.Delete(((DomainBase)parcela).Id); + List keyValues = new List { CreateLog(((DomainBase)parcela).Id, ((DomainBase)parcela).GetValorOriginal(), (TipoTela)5, (TipoAcao)2) }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)190, tries, parcela); + } + } + return false; + }); + } + + public async Task DeletePagamentoRange(List repasses) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.VendedorParcelaRepository.DeleteRange(repasses); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)21, tries, repasses, abrirTela: false); + } + } + return false; + }); + } + + public async Task> UpdateRange(List parcelas) + { + base.Sucesso = true; + int tries = 3; + List parcelasOriginais = parcelas; + Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + parcelas = parcelasOriginais; + try + { + List logs = new List(); + UnitOfWork unitOfWork = Instancia.Commited; + try + { + parcelas = unitOfWork.ParcelaRepository.UpdateRange(parcelas); + parcelas.ForEach(delegate(Parcela x) + { + logs.Add(CreateLog(((DomainBase)x).Id, ((DomainBase)x).Compare(((DomainBase)x).GetValorOriginal()), (TipoTela)5, (TipoAcao)1)); + SaveLog(logs, unitOfWork); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + return parcelas; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)24, tries, parcelas, abrirTela: false); + } + } + return parcelasOriginais; + }); + } + + public async Task BuscarParcela(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)74, tries, id); + } + } + return new Parcela(); + }); + } + + public async Task UpdateDetalhes(List detalhes) + { + int tries = 3; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + bool flag = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 51); + bool result = unitOfWork.ParcelaRepository.Update(detalhes, flag); + IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); + detalhes.ForEach(delegate(DetalheExtrato x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Expected O, but got Unknown + //IL_0040: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_00b7: Expected O, but got Unknown + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)x, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)x).Id, + Tela = (TipoTela)23, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = host.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, unitOfWork); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + return result; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)192, tries, detalhes); + } + } + return false; + }); + } + + public async Task> BuscarFaturas(Filtros filtro, bool buscaAssinaturas = false, bool painelBi = false) + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ParcelaRepository.BuscaDocumentosPorVigencia(filtro, buscaAssinaturas, painelBi); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)76, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarFatura(string numero) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindNumFatura(numero); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)322, tries, numero); + } + } + return new List(); + }); + } + + public async Task> BuscarParcelasRecebimento(Filtros filtro) + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ParcelaRepository.FindByRecebimento(filtro); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)77, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarParcelasPendentes(Filtros filtro, bool somenteAtivos = false) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindByPendente(filtro, true, somenteAtivos); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)78, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarParcelas(Filtros filtro, bool somenteAtivos = false) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindByPendente(filtro, false, somenteAtivos); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)79, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarPagamentoVendedor(Filtros filtro, bool reciboPagamento, bool segundaViaReciboPagamento) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.FindByPagamento(filtro, reciboPagamento, segundaViaReciboPagamento, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 34)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)80, tries, filtro); + } + } + return new List(); + }); + } + + public async Task TemPagamento(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.TemPagamentoParcela(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)82, tries, id); + } + } + return false; + }); + } + + public async Task GerarPagamento(List pagamentos) + { + int tries = 3; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + if (!commited.VendedorParcelaRepository.GerarPagamento(pagamentos.Select((VendedorParcela x) => ((DomainBase)x).Id).ToList(), now)) + { + return false; + } + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)193, tries, pagamentos); + } + } + return false; + }); + } + + public async Task BuscarApolice(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.BuscarApolice(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)3, tries, id); + } + } + return new Documento(); + }); + } + + public async Task SalvarObservacoes(long id, string observacao) + { + int tries = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + List list = new List(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + Parcela val = commited.ParcelaRepository.FindById(id); + ((DomainBase)val).Initialize(); + val.Observacao = observacao; + list.Add(CreateLog(((DomainBase)val).Id, val, (TipoTela)5)); + commited.ParcelaRepository.Merge(val); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + return observacao; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)24, tries, new { id, observacao }); + } + } + return ""; + }); + } + + public async Task> FaturaPendente(Filtros filtro) + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ParcelaRepository.FaturaPendente(filtro); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)83, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarPrevisaoPagamentoComissao(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.PrevisaoPagamentoComissao(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)316, tries, filtro); + } + } + return new List(); + }); + } + + public async Task BuscarLogAntigo(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ParcelaRepository.BuscarLogAntigo(id, Connection.GetConnectionString()); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)319, tries, id); + } + } + return (string)null; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/PermissaoArquivoDigitalServico.cs b/Decompiler/Gestor.Application.Servicos/PermissaoArquivoDigitalServico.cs new file mode 100644 index 0000000..f48019c --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/PermissaoArquivoDigitalServico.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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; + +namespace Gestor.Application.Servicos; + +public class PermissaoArquivoDigitalServico : BaseServico +{ + public async Task> SavePermiss(List permissao, List prev) + { + int tries = 3; + base.Sucesso = true; + List permissaoOriginal = permissao; + List prevOriginal = prev; + return await Task.Run(delegate + { + while (tries > 0) + { + permissao = permissaoOriginal; + prev = prevOriginal; + new List(); + List logs = new List(); + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + permissao.ForEach(delegate(PermissaoArquivoDigital x) + { + PermissaoArquivoDigital val = ((IEnumerable)prev).FirstOrDefault((Func)((PermissaoArquivoDigital y) => ((DomainBase)y).Id == ((DomainBase)x).Id)); + if (val == null || val.Consultar != x.Consultar || val.Excluir != x.Excluir || val.Incluir != x.Incluir) + { + if (val == null) + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).GetValorOriginal(), (TipoTela)43, (TipoAcao)0)); + } + else + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).Compare(((DomainBase)val).GetValorOriginal()), (TipoTela)43, (TipoAcao)1)); + } + x = ((((DomainBase)x).Id == 0L) ? unitOfWork.PermissaoArquivoDigitalRepository.SaveOrUpdate(x) : unitOfWork.PermissaoArquivoDigitalRepository.Merge(x)); + } + }); + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return permissao; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)258, tries, new { permissao, prev }); + } + } + return permissaoOriginal; + }); + } + + public async Task> PermissArquivoDigital(Usuario usuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.PermissaoArquivoDigitalRepository.FindByUsuario(((DomainBase)usuario).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)84, tries, usuario); + } + } + return new List(); + }); + } + + public async Task VerificarPermissao(Usuario usuario, TipoArquivoDigital tela) + { + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.PermissaoArquivoDigitalRepository.FindByPermissao(((DomainBase)usuario).Id, tela); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)85, tries, new { usuario, tela }); + } + } + return (PermissaoArquivoDigital)null; + }); + } + + public PermissaoArquivoDigital BuscarPermissao(Usuario usuario, TipoArquivoDigital tela) + { + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004a: Expected O, but got Unknown + int num = 3; + while (num > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + PermissaoArquivoDigital val = read.PermissaoArquivoDigitalRepository.FindByPermissao(((DomainBase)usuario).Id, tela); + if (val == null) + { + return new PermissaoArquivoDigital + { + Usuario = usuario, + Tela = tela, + Consultar = true, + Excluir = true, + Incluir = true + }; + } + return val; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + num = Registrar(e, (TipoErro)85, num, new { usuario, tela }); + } + } + return null; + } +} diff --git a/Decompiler/Gestor.Application.Servicos/PermissaoUsuarioServico.cs b/Decompiler/Gestor.Application.Servicos/PermissaoUsuarioServico.cs new file mode 100644 index 0000000..6b7f0fe --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/PermissaoUsuarioServico.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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; + +namespace Gestor.Application.Servicos; + +public class PermissaoUsuarioServico : BaseServico +{ + public async Task> SavePermiss(List permissao, List prev) + { + int tries = 3; + base.Sucesso = true; + List permissaoOriginal = permissao; + List prevOriginal = prev; + return await Task.Run(delegate + { + List logs = new List(); + while (tries > 0) + { + permissao = permissaoOriginal; + prev = prevOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + permissao.ForEach(delegate(PermissaoUsuario x) + { + PermissaoUsuario val = ((IEnumerable)prev).FirstOrDefault((Func)((PermissaoUsuario y) => ((DomainBase)y).Id == ((DomainBase)x).Id)); + if (val == null || val.Alterar != x.Alterar || val.Consultar != x.Consultar || val.Excluir != x.Excluir || val.Incluir != x.Incluir) + { + if (val == null) + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).GetValorOriginal(), (TipoTela)43, (TipoAcao)0)); + } + else + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).Compare(((DomainBase)val).GetValorOriginal()), (TipoTela)43, (TipoAcao)1)); + } + x = ((((DomainBase)x).Id == 0L) ? unitOfWork.PermissaoUsuarioRepository.SaveOrUpdate(x) : unitOfWork.PermissaoUsuarioRepository.Merge(x)); + } + }); + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return permissao; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)258, tries, new { permissao, prev }); + } + } + return permissaoOriginal; + }); + } + + public async Task> PermissUsuario(Usuario usuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.PermissaoUsuarioRepository.FindByUsuario(((DomainBase)usuario).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)84, tries, usuario); + } + } + return new List(); + }); + } + + public async Task VerificarPermissao(Usuario usuario, TipoTela tela) + { + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.PermissaoUsuarioRepository.FindByPermissao(((DomainBase)usuario).Id, tela); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)85, tries, new { usuario, tela }); + } + } + return (PermissaoUsuario)null; + }); + } + + public PermissaoUsuario BuscarPermissao(Usuario usuario, TipoTela tela) + { + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int num = 3; + while (num > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.PermissaoUsuarioRepository.FindByPermissao(((DomainBase)usuario).Id, tela); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + num = Registrar(e, (TipoErro)85, num, new { usuario, tela }); + } + } + return null; + } +} diff --git a/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs b/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs new file mode 100644 index 0000000..6cdf7cf --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs @@ -0,0 +1,340 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos; + +public class ProspeccaoServico : BaseServico +{ + internal async Task> BuscarProspeccoes(long id, DateTime inicio, DateTime fim, StatusProspeccao? status) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ProspectRepository.Find(((DomainBase)Recursos.Empresa).Id, id, inicio, fim, status); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)86, tries, new { id, inicio, fim, status }); + } + } + return new List(); + }); + } + + public async Task Salvar(Prospeccao prospecao) + { + int tries = 3; + base.Sucesso = true; + Prospeccao prospecaoOriginal = prospecao; + return await Task.Run((Func)delegate + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0165: Unknown result type (might be due to invalid IL or missing references) + //IL_016a: Unknown result type (might be due to invalid IL or missing references) + //IL_016b: Unknown result type (might be due to invalid IL or missing references) + //IL_0171: Unknown result type (might be due to invalid IL or missing references) + //IL_017c: Unknown result type (might be due to invalid IL or missing references) + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_018a: Unknown result type (might be due to invalid IL or missing references) + //IL_018f: Unknown result type (might be due to invalid IL or missing references) + //IL_019b: Expected O, but got Unknown + //IL_01a0: Unknown result type (might be due to invalid IL or missing references) + //IL_01b1: Unknown result type (might be due to invalid IL or missing references) + //IL_01b9: Unknown result type (might be due to invalid IL or missing references) + //IL_01c4: Unknown result type (might be due to invalid IL or missing references) + //IL_01cf: Unknown result type (might be due to invalid IL or missing references) + //IL_01da: Unknown result type (might be due to invalid IL or missing references) + //IL_0219: Expected O, but got Unknown + while (tries > 0) + { + prospecao = prospecaoOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + DateTime networkTime = Funcoes.GetNetworkTime(); + TipoAcao acao = (TipoAcao)(((DomainBase)prospecao).Id != 0L); + prospecao.IdEmpresa = Recursos.Usuario.IdEmpresa; + if (!prospecao.DataCriacao.HasValue) + { + prospecao.DataCriacao = networkTime; + } + if (prospecao.UsuarioCriacao == 0L) + { + prospecao.UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id; + } + Tarefa tarefa = prospecao.Tarefa; + tarefa = ((!prospecao.CriarTarefa) ? null : ((((DomainBase)tarefa).Id == 0L) ? commited.TarefaRepository.Salvar(tarefa) : commited.TarefaRepository.Atualizar(tarefa))); + prospecao.Tarefa = tarefa; + prospecao = ((((DomainBase)prospecao).Id == 0L) ? commited.ProspectRepository.SaveOrUpdate(prospecao) : commited.ProspectRepository.Merge(prospecao)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (prospecao.Tarefa != null) + { + prospecao.Tarefa.IdEntidade = ((DomainBase)prospecao).Id; + prospecao.Tarefa = commited.TarefaRepository.Atualizar(prospecao.Tarefa); + } + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = networkTime, + Descricao = JsonConvert.SerializeObject((object)prospecao, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)prospecao).Id, + Tela = (TipoTela)33, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return prospecao; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)259, tries, prospecao); + } + } + return prospecaoOriginal; + }); + } + + public async Task Delete(Prospeccao prospeccao) + { + int tries = 3; + return await Task.Run(delegate + { + //IL_0134: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_0140: Unknown result type (might be due to invalid IL or missing references) + //IL_014b: Unknown result type (might be due to invalid IL or missing references) + //IL_0152: Unknown result type (might be due to invalid IL or missing references) + //IL_0159: Unknown result type (might be due to invalid IL or missing references) + //IL_015e: Unknown result type (might be due to invalid IL or missing references) + //IL_016a: Expected O, but got Unknown + //IL_016f: Unknown result type (might be due to invalid IL or missing references) + //IL_0180: Unknown result type (might be due to invalid IL or missing references) + //IL_0188: Unknown result type (might be due to invalid IL or missing references) + //IL_0193: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Unknown result type (might be due to invalid IL or missing references) + //IL_01a9: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0070: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_0082: Unknown result type (might be due to invalid IL or missing references) + //IL_0089: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_00a6: Expected O, but got Unknown + //IL_00ab: Unknown result type (might be due to invalid IL or missing references) + //IL_00c1: Unknown result type (might be due to invalid IL or missing references) + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00d4: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00ea: Unknown result type (might be due to invalid IL or missing references) + //IL_01e6: Expected O, but got Unknown + //IL_0127: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + if (prospeccao.Tarefa != null) + { + commited.TarefaRepository.Excluir(((DomainBase)prospeccao.Tarefa).Id); + } + commited.ProspectRepository.Delete(((DomainBase)prospeccao).Id); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues; + if (prospeccao.Tarefa != null) + { + keyValues = new RegistroLog + { + Acao = (TipoAcao)2, + Usuario = Recursos.Usuario, + DataHora = networkTime, + Descricao = JsonConvert.SerializeObject((object)prospeccao.Tarefa, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)prospeccao.Tarefa).Id, + Tela = (TipoTela)38, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + } + keyValues = new RegistroLog + { + Acao = (TipoAcao)2, + Usuario = Recursos.Usuario, + DataHora = networkTime, + Descricao = JsonConvert.SerializeObject((object)prospeccao, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)prospeccao).Id, + Tela = (TipoTela)33, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return true; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)260, tries, prospeccao); + } + } + return false; + }); + } + + public async Task BuscarProspeccao(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ProspectRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)87, tries, id); + } + } + return new Prospeccao(); + }); + } + + public async Task> BuscarProspeccoes(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ProspectRepository.Find(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)88, tries, filtro); + } + } + return new List(); + }); + } + + public async Task> BuscarProspeccoesPorStatus(StatusDeProspeccao statusProspeccao) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ProspectRepository.FindByStatusPersonalizado(((DomainBase)statusProspeccao).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)310, tries, new { statusProspeccao }); + } + } + return new List(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/RestricaoUsuarioServico.cs b/Decompiler/Gestor.Application.Servicos/RestricaoUsuarioServico.cs new file mode 100644 index 0000000..1c1e7ee --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/RestricaoUsuarioServico.cs @@ -0,0 +1,222 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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; + +namespace Gestor.Application.Servicos; + +public class RestricaoUsuarioServico : BaseServico +{ + public RestricaoUsuario BuscarRestricao(Usuario usuario, TipoRestricao restricao) + { + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int num = 3; + while (num > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RestricaoUsuarioRepository.FindRestricao(((DomainBase)usuario).Id, restricao); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + num = Registrar(e, (TipoErro)89, num, new { usuario, restricao }); + } + } + return null; + } + + public async Task> SaveRestri(List restricoes, List prev) + { + int tries = 3; + base.Sucesso = true; + List restricoesOriginal = restricoes; + List prevOriginal = prev; + return await Task.Run(delegate + { + while (tries > 0) + { + new List(); + List logs = new List(); + restricoes = restricoesOriginal; + prev = prevOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + restricoes.ForEach(delegate(RestricaoUsuario x) + { + RestricaoUsuario val = ((IEnumerable)prev).FirstOrDefault((Func)((RestricaoUsuario y) => (((DomainBase)x).Id != 0L) ? (((DomainBase)y).Id == ((DomainBase)x).Id) : (y.Tipo == x.Tipo))); + if (val == null || val.Restricao != x.Restricao) + { + if (val == null) + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).GetValorOriginal(), (TipoTela)43, (TipoAcao)0)); + } + else + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).Compare(((DomainBase)val).GetValorOriginal()), (TipoTela)43, (TipoAcao)1)); + } + x = ((((DomainBase)x).Id == 0L) ? unitOfWork.RestricaoUsuarioRepository.SaveOrUpdate(x) : unitOfWork.RestricaoUsuarioRepository.Merge(x)); + } + }); + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return restricoes; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)261, tries, new { restricoes, prev }); + } + } + return restricoesOriginal; + }); + } + + public async Task> SaveRestriCamposRelatorios(List restricoes, List prev) + { + int tries = 3; + base.Sucesso = true; + List restricoesOriginal = restricoes; + List prevOriginal = prev; + return await Task.Run(delegate + { + while (tries > 0) + { + new List(); + List logs = new List(); + restricoes = restricoesOriginal; + prev = prevOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + restricoes.ForEach(delegate(RestricaoUsuarioCamposRelatorios x) + { + RestricaoUsuarioCamposRelatorios val = ((IEnumerable)prev).FirstOrDefault((Func)delegate(RestricaoUsuarioCamposRelatorios y) + { + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + //IL_0040: Unknown result type (might be due to invalid IL or missing references) + if (((DomainBase)y).Id != 0L) + { + return ((DomainBase)y).Id == ((DomainBase)x).Id; + } + return y.Campo == x.Campo && y.Relatorio == x.Relatorio; + }); + if (val == null || val.Restricao != x.Restricao) + { + if (val == null) + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).GetValorOriginal(), (TipoTela)43, (TipoAcao)0)); + } + else + { + logs.Add(CreateLog(((DomainBase)x.Usuario).Id, ((DomainBase)x).Compare(((DomainBase)val).GetValorOriginal()), (TipoTela)43, (TipoAcao)1)); + } + x = ((((DomainBase)x).Id == 0L) ? unitOfWork.RestricaoUsuarioCamposRelatoriosRepository.SaveOrUpdate(x) : unitOfWork.RestricaoUsuarioCamposRelatoriosRepository.Merge(x)); + } + }); + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return restricoes; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)261, tries, new { restricoes, prev }); + } + } + return restricoesOriginal; + }); + } + + public async Task> BuscarRestricoes(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RestricaoUsuarioRepository.FindByUsuario(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)90, tries, id); + } + } + return new List(); + }); + } + + public async Task> BuscarRestricoesCamposRelatorios(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RestricaoUsuarioCamposRelatoriosRepository.FindByUsuario(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)90, tries, id); + } + } + return new List(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs b/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs new file mode 100644 index 0000000..d8dc8d4 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs @@ -0,0 +1,310 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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.Relatorios; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.Servicos; + +internal class ServicoExtrato : BaseServico +{ + internal async Task> BuscarDetalhes(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection(from x in read.DetalheExtratoRepository.Find(id) + orderby x.Cliente, x.Apolice, x.Endosso, x.NumeroParcela + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)91, tries, id); + } + } + return new ObservableCollection(); + }); + } + + internal async Task BuscarNumExtrato(long? id) + { + if (!id.HasValue || id <= 0) + { + return ""; + } + string numeroExtrato = ""; + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + DetalheExtrato val = read.DetalheExtratoRepository.FindByLongId(id).FirstOrDefault(); + numeroExtrato = ((val != null && ((DomainBase)val).Id > 0) ? val.Extrato.Numero : ""); + return numeroExtrato; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)91, tries, id); + } + } + return ""; + }); + } + + public async Task> BuscarExtrato(long id, long idusuario, StatusExtrato status, DateTime inicio, DateTime fim) + { + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_0027: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run(delegate + { + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ExtratoRepository.FindBySeguradora(id, idusuario, ((DomainBase)Recursos.Empresa).Id, inicio, fim, (StatusExtrato?)status) + orderby x.Numero, x.Data descending + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)92, tries, new { id, status, inicio, fim }); + } + } + return new List(); + }); + } + + public async Task> BuscarExtratoPorData(Filtros filtros) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ExtratoRepository.FindByData(filtros) + orderby x.Data + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)93, tries, filtros); + } + } + return new List(); + }); + } + + public async Task Save(DetalheExtrato detalhe) + { + int tries = 3; + base.Sucesso = true; + DetalheExtrato detalheOriginal = detalhe; + return await Task.Run((Func)delegate + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Invalid comparison between Unknown and I4 + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + detalhe = detalheOriginal; + try + { + List list = new List(); + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val = (TipoAcao)(((DomainBase)detalhe).Id != 0L); + commited.DetalheExtratoRepository.Merge(detalhe); + if ((int)val == 1) + { + list.Add(CreateLog(((DomainBase)detalhe).Id, ((DomainBase)detalhe).GetValorOriginal(), (TipoTela)23, val)); + } + else + { + list.Add(CreateLog(((DomainBase)detalhe).Id, ((DomainBase)detalhe).Compare(((DomainBase)detalheOriginal).GetValorOriginal()), (TipoTela)23, val)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return detalhe; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)262, tries, detalhe); + } + } + return detalheOriginal; + }); + } + + public async Task Save(Extrato extrato) + { + int tries = 3; + base.Sucesso = true; + Extrato extratoOriginal = extrato; + return await Task.Run((Func)delegate + { + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Invalid comparison between Unknown and I4 + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + extrato = extratoOriginal; + try + { + List list = new List(); + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val = (TipoAcao)(((DomainBase)extrato).Id != 0L); + commited.ExtratoRepository.Merge(extrato); + if ((int)val == 1) + { + list.Add(CreateLog(((DomainBase)extrato).Id, ((DomainBase)extrato).GetValorOriginal(), (TipoTela)23, val)); + } + else + { + list.Add(CreateLog(((DomainBase)extrato).Id, ((DomainBase)extrato).Compare(((DomainBase)extratoOriginal).GetValorOriginal()), (TipoTela)23, val)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + return extrato; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)263, tries, extrato); + } + } + return extratoOriginal; + }); + } + + public async Task Delete(Extrato extrato) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + List list = new List(); + UnitOfWork commited = Instancia.Commited; + try + { + commited.ExtratoRepository.Delete(((DomainBase)extrato).Id); + list.Add(CreateLog(((DomainBase)extrato).Id, ((DomainBase)extrato).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)264, tries, extrato); + } + } + return false; + }); + } + + public async Task FindByParcelaId(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.DetalheExtratoRepository.FindByParcelaId(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)74, tries, id); + } + } + return new DetalheExtrato(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/TarefaServico.cs b/Decompiler/Gestor.Application.Servicos/TarefaServico.cs new file mode 100644 index 0000000..6dd9c31 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/TarefaServico.cs @@ -0,0 +1,817 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Threading; +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos; + +public class TarefaServico : BaseServico +{ + public async Task> BuscarTarefas(TipoTarefa entidade, long id, bool? concluido) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + int tries = 3; + return await Task.Run(delegate + { + //IL_0045: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefa(entidade, id, concluido); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)94, tries, new { entidade, id, concluido }); + } + } + return new List(); + }); + } + + public async Task Salvar(Tarefa tarefa) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Tarefa tarefaOriginal = tarefa; + return await Task.Run((Func)delegate + { + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Invalid comparison between Unknown and I4 + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00c4: Unknown result type (might be due to invalid IL or missing references) + //IL_00d0: Unknown result type (might be due to invalid IL or missing references) + //IL_00d7: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_00e8: Expected O, but got Unknown + //IL_00ed: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + //IL_0111: Unknown result type (might be due to invalid IL or missing references) + //IL_011c: Unknown result type (might be due to invalid IL or missing references) + //IL_0127: Unknown result type (might be due to invalid IL or missing references) + //IL_0164: Expected O, but got Unknown + while (tries > 0) + { + tarefa = tarefaOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + CleanWebEditor(tarefa); + if ((int)tarefa.Entidade == 1) + { + tarefa.Descricao = ((!string.IsNullOrWhiteSpace(tarefa.Anotacoes)) ? tarefa.Anotacoes : tarefa.Descricao); + } + bool flag = ((DomainBase)tarefa).Id == 0; + tarefa = (flag ? commited.TarefaRepository.Salvar(tarefa) : commited.TarefaRepository.Atualizar(tarefa)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)tarefa, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)tarefa).Id, + Tela = (TipoTela)38, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return tarefa; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)265, tries, tarefa); + } + } + return tarefaOriginal; + }); + } + + private static void CleanWebEditor(Tarefa tarefa) + { + if (tarefa.Descricao != null) + { + tarefa.Descricao = RemoveXml(tarefa.Descricao); + } + if (tarefa.DescricaoInterna != null) + { + tarefa.DescricaoInterna = RemoveXml(tarefa.DescricaoInterna); + } + } + + public static string RemoveXml(string description) + { + try + { + List list = new List(); + string[] array = description.Split(new char[1] { '<' }); + foreach (string text in array) + { + if (text.Contains("?xml") || text.Contains("o:p")) + { + list.Add("<" + text); + } + } + foreach (string item in list) + { + description = description.Replace(item, ""); + } + return description; + } + catch (Exception ex) + { + throw ex; + } + } + + public async Task Salvar(Trilha trilha) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Trilha trilhaOriginal = trilha; + return await Task.Run((Func)delegate + { + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_0082: Unknown result type (might be due to invalid IL or missing references) + //IL_0089: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Expected O, but got Unknown + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00b0: Unknown result type (might be due to invalid IL or missing references) + //IL_00b7: Unknown result type (might be due to invalid IL or missing references) + //IL_00c2: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00d8: Unknown result type (might be due to invalid IL or missing references) + //IL_0115: Expected O, but got Unknown + while (tries > 0) + { + trilha = trilhaOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool flag = ((DomainBase)trilha).Id == 0; + trilha = (flag ? commited.TarefaRepository.Salvar(trilha) : commited.TarefaRepository.Atualizar(trilha)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)trilha, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)trilha).Id, + Tela = (TipoTela)4, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return trilha; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)267, tries, trilha); + } + } + return trilhaOriginal; + }); + } + + public async Task Excluir(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.TarefaRepository.Excluir(id); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return true; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)268, tries, id); + } + } + return false; + }); + } + + public async Task> BuscarTarefas(long id, DateTime inicio, DateTime fim, bool? concluido) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefaPorUsuario(id, inicio, fim, concluido); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)95, tries, new { id, inicio, fim, concluido }); + } + } + return new List(); + }); + } + + public async Task> BuscarTarefasCliente(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefaPorCliente(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)96, tries, id); + } + } + return new List(); + }); + } + + public async Task> BuscarNotas(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefaPorUsuario(id, (TipoTarefa)1); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)98, tries, id); + } + } + return new List(); + }); + } + + public async Task> BuscarNotasConcluidas(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefaConcluidaPorUsuario(id, (TipoTarefa)1); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)99, tries, id); + } + } + return new List(); + }); + } + + public async Task AtualizarNotasTarefas() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.ContarTarefas(((DomainBase)Recursos.Usuario).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)100, tries, ((DomainBase)Recursos.Usuario).Id); + } + } + return new int[1]; + }); + } + + public async Task> BuscarTarefas(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefaPorTrilha(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)101, tries, id); + } + } + return new List(); + }); + } + + public async Task> BuscarFases(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarFases(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)102, tries, id); + } + } + return new List(); + }); + } + + public async Task> BuscarTrilhas() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTrilhas(true); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)104, tries); + } + } + return new List(); + }); + } + + public async Task> Salvar(List fases) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + List fasesOriginal = fases; + return await Task.Run(delegate + { + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Expected O, but got Unknown + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0099: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00ab: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00c1: Unknown result type (might be due to invalid IL or missing references) + //IL_00ff: Expected O, but got Unknown + while (tries > 0) + { + fases = fasesOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + fases = commited.TarefaRepository.Salvar(fases); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + foreach (Fase fase in fases) + { + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)fase, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)fase).Id, + Tela = (TipoTela)4, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + } + ((GenericUnitOfWork)commited).Commit(); + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return fases; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)269, tries, fases); + } + } + return fasesOriginal; + }); + } + + public async Task> Salvar(List tarefas) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + List tarefasOriginal = tarefas; + return await Task.Run(delegate + { + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Expected O, but got Unknown + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0099: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00ab: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00c1: Unknown result type (might be due to invalid IL or missing references) + //IL_00ff: Expected O, but got Unknown + while (tries > 0) + { + tarefas = tarefasOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + tarefas = commited.TarefaRepository.Salvar(tarefas); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + foreach (Tarefa tarefa in tarefas) + { + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)tarefa, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)tarefa).Id, + Tela = (TipoTela)4, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + } + ((GenericUnitOfWork)commited).Commit(); + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return tarefas; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)265, tries, tarefas); + } + } + return tarefasOriginal; + }); + } + + public async Task> Validar(List ids, long trilhaId) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + return commited.TarefaRepository.Validar(ids, trilhaId); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)266, tries, new { ids, trilhaId }); + } + } + return (List)null; + }); + } + + public async Task BuscarTarefa(long id) + { + int tries = 3; + return await Task.Run((Func)delegate + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefa(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)105, tries, id); + } + } + return new Tarefa(); + }); + } + + public async Task> BuscarTarefasPorTipo(TipoDeTarefa tipoTarefa) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TarefaRepository.BuscarTarefasPorTipo(((DomainBase)tipoTarefa).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)309, tries, new { tipoTarefa }); + } + } + return new List(); + }); + } + + public async Task ExcluirTarefasDocumento(long id) + { + int tries = 3; + return await Task.Run(delegate + { + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_0099: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00ac: Expected O, but got Unknown + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00bd: Unknown result type (might be due to invalid IL or missing references) + //IL_00c4: Unknown result type (might be due to invalid IL or missing references) + //IL_00cf: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00e5: Unknown result type (might be due to invalid IL or missing references) + //IL_0124: Expected O, but got Unknown + while (tries > 0) + { + try + { + List list = new List(); + UnitOfWork read = Instancia.Read; + try + { + list = read.TarefaRepository.BuscarTarefa((TipoTarefa)0, id, (bool?)false); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + foreach (Tarefa item in list) + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.TarefaRepository.Excluir(((DomainBase)item).Id); + ((GenericUnitOfWork)commited).Commit(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = DateTime.Now, + Descricao = JsonConvert.SerializeObject((object)item, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)item).Id, + Tela = (TipoTela)4, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate + { + Gestor.Application.Actions.Actions.AtualizaBadges(); + }); + return true; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)268, tries, id); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs b/Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs new file mode 100644 index 0000000..b73e0aa --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos/VendedorUsuarioServico.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.API; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.Servicos; + +public class VendedorUsuarioServico : BaseServico +{ + public async Task> FindByVinculo(Usuario usuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorUsuarioRepository.FindByVinculo(((DomainBase)usuario).Id).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)106, tries, usuario); + } + } + return new List(); + }); + } + + public async Task> SaveOrUpdate(List vinculo) + { + int tries = 3; + base.Sucesso = true; + List vinculoOriginal = vinculo; + return await Task.Run(delegate + { + while (tries > 0) + { + vinculo = vinculoOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + vinculo.ForEach(delegate(VendedorUsuario x) + { + unitOfWork.VendedorUsuarioRepository.SaveOrUpdate(x); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + return vinculo; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)271, tries, vinculo); + } + } + return vinculoOriginal; + }); + } + + public async Task Delete(List vinculo) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + vinculo.ForEach(delegate(VendedorUsuario x) + { + unitOfWork.VendedorUsuarioRepository.Delete(((DomainBase)x).Id); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + return true; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)272, tries, vinculo); + } + } + return false; + }); + } + + public async Task FindVinculo(Vendedor vendedor) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorUsuarioRepository.Exist(((DomainBase)vendedor).Id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)271, tries, vendedor); + } + } + return false; + }); + } + + public async Task FindVinculoByUsuario(long idusuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorUsuarioRepository.ExistVinculoUsuario(idusuario); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)106, tries); + } + } + return false; + }); + } +} -- cgit v1.2.3