diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas')
21 files changed, 4262 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs new file mode 100644 index 0000000..07b5444 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs @@ -0,0 +1,269 @@ +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.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +public class AdiantamentoServico : BaseServico +{ + public async Task<Adiantamento> Save(Adiantamento adiatamento) + { + int tries = 3; + base.Sucesso = true; + Adiantamento adiantamentoOriginal = adiatamento; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run((Func<Adiantamento>)delegate + { + //IL_0028: 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_009f: 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_00a6: 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_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_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Expected O, but got Unknown + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00eb: Unknown result type (might be due to invalid IL or missing references) + //IL_00f3: 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_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_0114: Unknown result type (might be due to invalid IL or missing references) + //IL_0151: Expected O, but got Unknown + while (tries > 0) + { + adiatamento = adiantamentoOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)adiatamento).Id != 0L); + adiatamento.Pagamento = (adiatamento.Pago ? new DateTime?(now) : null); + adiatamento = ((((DomainBase)adiatamento).Id == 0L) ? commited.AdiantamentoRepository.SaveOrUpdate(adiatamento) : commited.AdiantamentoRepository.Merge(adiatamento)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)adiatamento, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)adiatamento).Id, + Tela = (TipoTela)36, + 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 adiatamento; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)209, tries, adiatamento); + } + } + return adiantamentoOriginal; + }); + } + + public async Task<bool> Delete(Adiantamento adiantamento) + { + int tries = 3; + DateTime dateHora = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.AdiantamentoRepository.Delete(((DomainBase)adiantamento).Id); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog val = new RegistroLog(); + val.Acao = (TipoAcao)2; + val.Usuario = Recursos.Usuario; + val.DataHora = dateHora; + val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {dateHora}, O PARCEIRO DE " + $"ID: '{((DomainBase)adiantamento).Id}'" + ", HISTÓRICO: '" + (string.IsNullOrWhiteSpace(adiantamento.Historico) ? "" : (adiantamento.Historico ?? "")) + "', DATA DO ADIANTAMENTO: '" + ((!adiantamento.Data.HasValue) ? "" : (adiantamento.Data?.ToShortDateString() ?? "")) + "'" + $", VALOR DO ADIANTAMENTO: 'R${adiantamento.Valor}'."; + val.EntidadeId = ((DomainBase)adiantamento).Id; + val.Versao = LoginViewModel.VersaoAtual; + val.Tela = (TipoTela)36; + val.NomeMaquina = Environment.MachineName; + val.UsuarioMaquina = Environment.UserName; + val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(); + RegistroLog keyValues = val; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)210, tries, adiantamento); + } + } + return false; + }); + } + + public async Task<List<Adiantamento>> BuscarPorData(Filtros filtro, bool segundavia = false) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.AdiantamentoRepository.FindByDate(filtro.Inicio, filtro.Fim, filtro.Vendedores, segundavia); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)15, tries, filtro); + } + } + return new List<Adiantamento>(); + }); + } + + public async Task<List<Adiantamento>> BuscarAdiantamentos(long id, bool concluido) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.AdiantamentoRepository.BuscarAdiantamentos(id, concluido); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)16, tries, new { id, concluido }); + } + } + return new List<Adiantamento>(); + }); + } + + public async Task GerarPagamento(List<Adiantamento> adiantamentos) + { + int tries = 3; + DateTime now = Funcoes.GetNetworkTime(); + await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + adiantamentos.ForEach(delegate(Adiantamento x) + { + //IL_0051: 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_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0079: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: Unknown result type (might be due to invalid IL or missing references) + //IL_008c: Expected O, but got Unknown + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: 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_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_0103: Expected O, but got Unknown + Adiantamento val = unitOfWork.AdiantamentoRepository.FindById(((DomainBase)x).Id); + val.Pago = true; + val.Pagamento = now; + val = unitOfWork.AdiantamentoRepository.Merge(val); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)val, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)val).Id, + Tela = (TipoTela)36, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, unitOfWork); + }); + ((GenericUnitOfWork)unitOfWork).Commit(); + break; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)194, tries, adiantamentos); + } + } + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/AgendaServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/AgendaServico.cs new file mode 100644 index 0000000..855f036 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/AgendaServico.cs @@ -0,0 +1,224 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class AgendaServico : BaseServico +{ + public async Task<Agenda> Save(Agenda agenda) + { + int tries = 3; + base.Sucesso = true; + Agenda agendaOriginal = agenda; + return await Task.Run((Func<Agenda>)delegate + { + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0144: Unknown result type (might be due to invalid IL or missing references) + //IL_0149: Unknown result type (might be due to invalid IL or missing references) + //IL_014a: Unknown result type (might be due to invalid IL or missing references) + //IL_0150: Unknown result type (might be due to invalid IL or missing references) + //IL_015b: Unknown result type (might be due to invalid IL or missing references) + //IL_0166: Unknown result type (might be due to invalid IL or missing references) + //IL_016d: Unknown result type (might be due to invalid IL or missing references) + //IL_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_017e: Expected O, but got Unknown + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_019c: Unknown result type (might be due to invalid IL or missing references) + //IL_01a7: Unknown result type (might be due to invalid IL or missing references) + //IL_01b2: 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_01fc: Expected O, but got Unknown + while (tries > 0) + { + agenda = agendaOriginal; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)agenda).Id != 0L); + List<AgendaTelefone> list = agenda.Telefones?.ToList(); + List<AgendaEmail> list2 = agenda.Emails?.ToList(); + agenda.Telefones = null; + agenda.Emails = null; + UnitOfWork commited = Instancia.Commited; + try + { + if (((DomainBase)agenda).Id == 0) + { + agenda = commited.AgendaRepository.SaveOrUpdate(agenda); + if (list != null) + { + list = commited.AgendaTelefoneRepository.Inserir(list, agenda); + } + if (list2 != null) + { + list2 = commited.AgendaEmailRepository.Inserir(list2, agenda); + } + } + else + { + if (list != null) + { + list = commited.AgendaTelefoneRepository.Merge(list, agenda); + } + if (list2 != null) + { + list2 = commited.AgendaEmailRepository.Merge(list2, agenda); + } + agenda = commited.AgendaRepository.Merge(agenda); + } + agenda.Telefones = ((list == null) ? null : new ObservableCollection<AgendaTelefone>(list)); + agenda.Emails = ((list2 == null) ? null : new ObservableCollection<AgendaEmail>(list2)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)agenda, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)agenda).Id, + Tela = (TipoTela)34, + 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 agenda; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)215, tries, agenda); + } + } + return agendaOriginal; + }); + } + + public async Task<bool> Delete(Agenda agenda) + { + int tries = 3; + return await Task.Run(delegate + { + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.AgendaRepository.Delete(((DomainBase)agenda).Id); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog val = new RegistroLog(); + val.Acao = (TipoAcao)2; + val.Usuario = Recursos.Usuario; + val.DataHora = networkTime; + val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {networkTime}, O CONTATO DE " + $"ID: '{((DomainBase)agenda).Id}'" + ", NOME: '" + (string.IsNullOrWhiteSpace(agenda.Nome) ? "" : (agenda.Nome ?? "")) + "', ENDEREÇO: '" + agenda.Endereco + ", " + agenda.Numero + ", " + (string.IsNullOrWhiteSpace(agenda.Complemento) ? "-" : (agenda.Complemento ?? "")) + ", " + agenda.Bairro + ", " + agenda.Cidade + "/" + agenda.Estado + " - " + agenda.Cep + "', OBSERVAÇÃO: '" + (string.IsNullOrWhiteSpace(agenda.Observacao) ? "" : (agenda.Observacao ?? "")) + "'."; + val.EntidadeId = ((DomainBase)agenda).Id; + val.Tela = (TipoTela)34; + val.Versao = LoginViewModel.VersaoAtual; + val.NomeMaquina = Environment.MachineName; + val.UsuarioMaquina = Environment.UserName; + val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(); + RegistroLog keyValues = val; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)216, tries, agenda); + } + } + return false; + }); + } + + internal async Task<ObservableCollection<AgendaTelefone>> BuscarTelefonesAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<AgendaTelefone>(read.AgendaTelefoneRepository.FindByAgendaId(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)107, tries, id); + } + } + return new ObservableCollection<AgendaTelefone>(); + }); + } + + internal async Task<ObservableCollection<AgendaEmail>> BuscarEmailsAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<AgendaEmail>(read.AgendaEmailRepository.FindByAgendaId(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)108, tries, id); + } + } + return new ObservableCollection<AgendaEmail>(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/EmailServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/EmailServico.cs new file mode 100644 index 0000000..1a9c528 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/EmailServico.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Common.Helpers; +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.Seguros; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class EmailServico : BaseServico +{ + public async Task<Credencial> Save(Credencial credencial) + { + int tries = 3; + base.Sucesso = true; + Credencial credencialOriginal = credencial; + return await Task.Run((Func<Credencial>)delegate + { + List<RegistroLog> list = new List<RegistroLog>(); + credencial = credencialOriginal; + while (tries > 0) + { + credencial = credencialOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)credencial).Id != 0L; + credencial.Senha = EncryptionHelper.Encrypt(credencial.Senha); + if (num) + { + list.Add(CreateLog(((DomainBase)credencial).Id, credencial, (TipoTela)17)); + } + credencial = ((((DomainBase)credencial).Id == 0L) ? commited.CredencialRepository.SaveOrUpdate(credencial) : commited.CredencialRepository.Merge(credencial)); + if (!num) + { + list.Add(CreateLog(((DomainBase)credencial).Id, ((DomainBase)credencial).GetValorOriginal(), (TipoTela)17, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return credencial; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)217, tries, credencial); + } + } + return credencialOriginal; + }); + } + + public async Task<bool> Delete(Credencial email) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)email).Id, ((DomainBase)email).GetValorOriginal(), (TipoTela)17, (TipoAcao)2)); + commited.CredencialRepository.Delete(((DomainBase)email).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)218, tries, email); + } + } + return false; + }); + } + + internal async Task<List<ClienteEmail>> BuscarEmail(string email) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteEmailRepository.FindEmailCliente(email, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)109, tries, email); + } + } + return new List<ClienteEmail>(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs new file mode 100644 index 0000000..4f47cdf --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs @@ -0,0 +1,323 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using ArquivoDigital.Infrastructure.UnitOfWork.Logic; +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 Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class EmpresaServico : BaseServico +{ + internal async Task<List<Empresa>> BuscarEmpresas() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.EmpresaRepository.Find((Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)113, tries); + } + } + return new List<Empresa>(); + }); + } + + internal async Task<Empresa> BuscarEmpresaPorId(long id) + { + int tries = 3; + return await Task.Run((Func<Empresa>)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.EmpresaRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)114, tries, id); + } + } + return new Empresa(); + }); + } + + internal async Task<Customer> Save(Customer customer) + { + int tries = 3; + base.Sucesso = true; + Customer customerOriginal = customer; + return await Task.Run((Func<Customer>)delegate + { + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: 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_003e: 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_0060: 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_0082: Unknown result type (might be due to invalid IL or missing references) + //IL_0093: Unknown result type (might be due to invalid IL or missing references) + //IL_00a4: Unknown result type (might be due to invalid IL or missing references) + //IL_00b5: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: 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_00e8: Unknown result type (might be due to invalid IL or missing references) + //IL_00f9: Unknown result type (might be due to invalid IL or missing references) + //IL_0104: Unknown result type (might be due to invalid IL or missing references) + //IL_0116: Expected O, but got Unknown + while (tries > 0) + { + customer = customerOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + Empresa val = new Empresa + { + Nome = customer.Name, + Documento = customer.Document, + Bairro = customer.District, + Cidade = customer.City, + Complemento = customer.Adjunct, + Numero = customer.Number, + Cep = customer.PostCode, + Estado = customer.State, + Email = customer.Mail, + PrimeiroPrefixo = customer.AreaCode, + PrimeiroTelefone = customer.Phone, + SegundoPrefixo = customer.SecondAreaCode, + SegundoTelefone = customer.SecondPhone, + Serial = ApplicationHelper.NumeroSerial, + Site = customer.Site + }; + commited.EmpresaRepository.SaveOrUpdate(val); + ((GenericUnitOfWork)commited).Commit(); + return customer; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)277, tries, customer); + } + } + return customerOriginal; + }); + } + + public async Task<Empresa> Save(Empresa empresa) + { + int tries = 3; + base.Sucesso = true; + Empresa empresaOriginal = empresa; + return await Task.Run((Func<Empresa>)delegate + { + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a3: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00b4: Expected O, but got Unknown + //IL_00b9: 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_00d2: Unknown result type (might be due to invalid IL or missing references) + //IL_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_00e8: Unknown result type (might be due to invalid IL or missing references) + //IL_00f3: Unknown result type (might be due to invalid IL or missing references) + //IL_0130: Expected O, but got Unknown + while (tries > 0) + { + empresa = empresaOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)empresa).Id != 0L); + empresa = ((((DomainBase)empresa).Id == 0L) ? commited.EmpresaRepository.SaveOrUpdate(empresa) : commited.EmpresaRepository.Merge(empresa)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (((DomainBase)Recursos.Usuario).Id != 0L) + { + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)empresa, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)empresa).Id, + Tela = (TipoTela)18, + 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 empresa; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)277, tries, empresa); + } + } + return empresaOriginal; + }); + } + + public string BuscarSenhaAdm() + { + int num = 3; + while (num > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.EmpresaRepository.BuscarSenhaAdm(1L); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + num = Registrar(e, (TipoErro)115, num); + } + } + return null; + } + + public async void AtualizarLogoId(long id, string idLogo) + { + await Task.Run(delegate + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + Empresa val = commited.EmpresaRepository.FindById(id); + val.LogoId = idLogo; + commited.EmpresaRepository.Merge(val); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception) + { + } + }); + } + + public async Task<double> ConsultaEspacoBancoInGb() + { + return await Task.Run(delegate + { + try + { + UnitOfWork read = Instancia.Read; + try + { + double num = read.EmpresaRepository.ConsultaEspacoBancoInGb(); + double num2 = 0.0; + try + { + foreach (ControleArquivoDigital item in read.IndiceArquivoDigitalRepository.BuscarBancos()) + { + if (!(item.Tabela.ToLower() == "arquivos")) + { + try + { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(item.Catalogo); + UnitOfWork read2 = Gestor.Application.Helpers.ArquivoDigital.Read; + try + { + num2 += read2.ArquivoDigitalRepository.ConsultaEspacoBancoInGb(); + } + finally + { + ((IDisposable)read2)?.Dispose(); + } + } + catch + { + } + } + } + } + catch + { + } + return num + num2; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception) + { + } + return 0.0; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs new file mode 100644 index 0000000..126c369 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/EstipulanteServico.cs @@ -0,0 +1,125 @@ +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.Ferramentas; + +internal class EstipulanteServico : BaseServico +{ + internal async Task<Estipulante> BuscarEstipulantePorId(long id) + { + int tries = 3; + return await Task.Run((Func<Estipulante>)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.EstipulanteRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)110, tries, id); + } + } + return new Estipulante(); + }); + } + + public async Task<Estipulante> Save(Estipulante estipulante) + { + int tries = 3; + base.Sucesso = true; + Estipulante estipulanteOriginal = estipulante; + return await Task.Run((Func<Estipulante>)delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + estipulante = estipulanteOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + estipulante.IdEmpresa = ((DomainBase)Recursos.Empresa).Id; + bool num = ((DomainBase)estipulante).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)estipulante).Id, estipulante, (TipoTela)9)); + } + estipulante = ((((DomainBase)estipulante).Id == 0L) ? commited.EstipulanteRepository.SaveOrUpdate(estipulante) : commited.EstipulanteRepository.Merge(estipulante)); + if (!num) + { + list.Add(CreateLog(((DomainBase)estipulante).Id, ((DomainBase)estipulante).GetValorOriginal(), (TipoTela)9, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return estipulante; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)219, tries, estipulante); + } + } + return estipulanteOriginal; + }); + } + + public async Task<bool> Delete(Estipulante estipulante) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)estipulante).Id, ((DomainBase)estipulante).GetValorOriginal(), (TipoTela)9, (TipoAcao)2)); + commited.EstipulanteRepository.Delete(((DomainBase)estipulante).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)220, tries, estipulante); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/ImpostoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/ImpostoServico.cs new file mode 100644 index 0000000..45b5b7b --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/ImpostoServico.cs @@ -0,0 +1,175 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +public class ImpostoServico : BaseServico +{ + public async Task<List<Imposto>> Buscar(bool? ativo) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ImpostoRepository.DefaultSelect(ativo); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)317, tries, ativo); + } + } + return new List<Imposto>(); + }); + } + + public async Task<List<Imposto>> BuscarPorSeguradora(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ImpostoRepository.FindBySeguradora(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)317, tries, id); + } + } + return new List<Imposto>(); + }); + } + + public async Task<List<Imposto>> BuscarPorRamo(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ImpostoRepository.FindByRamo(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)317, tries, id); + } + } + return new List<Imposto>(); + }); + } + + public async Task<Imposto> Salvar(Imposto imposto) + { + int tries = 3; + return await Task.Run((Func<Imposto>)delegate + { + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: 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_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: 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_0091: Expected O, but got Unknown + //IL_0096: Unknown result type (might be due to invalid IL or missing references) + //IL_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00b5: Unknown result type (might be due to invalid IL or missing references) + //IL_00c0: Unknown result type (might be due to invalid IL or missing references) + //IL_00cb: Unknown result type (might be due to invalid IL or missing references) + //IL_0109: Expected O, but got Unknown + while (tries > 0) + { + base.Sucesso = true; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val = (TipoAcao)(((DomainBase)imposto).Id != 0L); + Imposto val2 = (((int)val == 0) ? commited.ImpostoRepository.SaveOrUpdate(imposto) : commited.ImpostoRepository.Merge(imposto)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = val, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)val2, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)val2).Id, + Tela = (TipoTela)56, + 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 val2; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + base.Sucesso = false; + tries = Registrar(e, (TipoErro)318, tries, imposto, abrirTela: false); + } + } + return imposto; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/MetaSeguradoraServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/MetaSeguradoraServico.cs new file mode 100644 index 0000000..e7afb7b --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/MetaSeguradoraServico.cs @@ -0,0 +1,169 @@ +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.Common.Validation; +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; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class MetaSeguradoraServico : BaseServico +{ + public async Task<MetaSeguradora> Save(MetaSeguradora metaSeguradora) + { + int tries = 3; + base.Sucesso = true; + MetaSeguradora metaSeguradoraOriginal = metaSeguradora; + return await Task.Run((Func<MetaSeguradora>)delegate + { + //IL_0028: 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_0071: 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_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: 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_00a5: Expected O, but got Unknown + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00c3: 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_00d9: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Unknown result type (might be due to invalid IL or missing references) + //IL_0121: Expected O, but got Unknown + while (tries > 0) + { + metaSeguradora = metaSeguradoraOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)metaSeguradora).Id != 0L); + metaSeguradora = ((((DomainBase)metaSeguradora).Id == 0L) ? commited.MetaSeguradoraRepository.SaveOrUpdate(metaSeguradora) : commited.MetaSeguradoraRepository.Merge(metaSeguradora)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)metaSeguradora, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)metaSeguradora).Id, + Tela = (TipoTela)31, + 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 metaSeguradora; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)222, tries, metaSeguradora); + } + } + return metaSeguradoraOriginal; + }); + } + + public async Task<bool> Delete(MetaSeguradora meta) + { + int tries = 3; + return await Task.Run(delegate + { + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Expected O, but got Unknown + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.MetaSeguradoraRepository.Delete(((DomainBase)meta).Id); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog val = new RegistroLog(); + val.Acao = (TipoAcao)2; + val.Usuario = Recursos.Usuario; + val.DataHora = networkTime; + val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {networkTime}, A META DE" + $"ID: '{((DomainBase)meta).Id}'" + ", MÊS: '" + ValidationHelper.GetDescription((Enum)(object)meta.Mes) + "'" + $", ANO: '{meta.Ano}'" + $", VALOR: 'R${meta.Valor}'."; + val.EntidadeId = ((DomainBase)meta).Id; + val.Tela = (TipoTela)31; + val.Versao = LoginViewModel.VersaoAtual; + val.NomeMaquina = Environment.MachineName; + val.UsuarioMaquina = Environment.UserName; + val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(); + RegistroLog keyValues = val; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)223, tries, meta); + } + } + return false; + }); + } + + public async Task<List<MetaSeguradora>> BuscarMetasSeguradoras(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.MetaSeguradoraRepository.FindByMeta(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)284, tries, filtro); + } + } + return new List<MetaSeguradora>(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/MetaVendedorServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/MetaVendedorServico.cs new file mode 100644 index 0000000..f5aac7b --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/MetaVendedorServico.cs @@ -0,0 +1,169 @@ +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.Common.Validation; +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; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class MetaVendedorServico : BaseServico +{ + public async Task<MetaVendedor> Save(MetaVendedor metaVendedor) + { + int tries = 3; + base.Sucesso = true; + MetaVendedor metaVendedorOriginal = metaVendedor; + return await Task.Run((Func<MetaVendedor>)delegate + { + //IL_0028: 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_0071: 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_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: 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_00a5: Expected O, but got Unknown + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00c3: 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_00d9: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Unknown result type (might be due to invalid IL or missing references) + //IL_0121: Expected O, but got Unknown + while (tries > 0) + { + metaVendedor = metaVendedorOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)metaVendedor).Id != 0L); + metaVendedor = ((((DomainBase)metaVendedor).Id == 0L) ? commited.MetaVendedorRepository.SaveOrUpdate(metaVendedor) : commited.MetaVendedorRepository.Merge(metaVendedor)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)metaVendedor, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)metaVendedor).Id, + Tela = (TipoTela)30, + 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 metaVendedor; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)224, tries, metaVendedor); + } + } + return metaVendedorOriginal; + }); + } + + public async Task<bool> Delete(MetaVendedor meta) + { + int tries = 3; + return await Task.Run(delegate + { + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Expected O, but got Unknown + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.MetaVendedorRepository.Delete(((DomainBase)meta).Id); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog val = new RegistroLog(); + val.Acao = (TipoAcao)2; + val.Usuario = Recursos.Usuario; + val.DataHora = networkTime; + val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {networkTime}, A META DE" + $"ID: '{((DomainBase)meta).Id}'" + ", MÊS: '" + ValidationHelper.GetDescription((Enum)(object)meta.Mes) + "'" + $", ANO: '{meta.Ano}'" + $", VALOR: 'R${meta.Valor}'."; + val.EntidadeId = ((DomainBase)meta).Id; + val.Tela = (TipoTela)30; + val.Versao = LoginViewModel.VersaoAtual; + val.NomeMaquina = Environment.MachineName; + val.UsuarioMaquina = Environment.UserName; + val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(); + RegistroLog keyValues = val; + SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)225, tries, meta); + } + } + return false; + }); + } + + public async Task<List<MetaVendedor>> BuscarMetasVendedores(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.MetaVendedorRepository.FindByMeta(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)285, tries, filtro); + } + } + return new List<MetaVendedor>(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/NotaFiscalServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/NotaFiscalServico.cs new file mode 100644 index 0000000..eede45d --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/NotaFiscalServico.cs @@ -0,0 +1,179 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class NotaFiscalServico : BaseServico +{ + internal async Task<List<NotaFiscal>> BuscarNotasFiscais() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.NotaFiscalRepository.FindAll(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)312, tries); + } + } + return new List<NotaFiscal>(); + }); + } + + internal async Task<NotaFiscal> Save(NotaFiscal notaFiscal) + { + int tries = 3; + base.Sucesso = true; + NotaFiscal notaFiscalOriginal = notaFiscal; + return await Task.Run((Func<NotaFiscal>)delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + notaFiscal = notaFiscalOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)notaFiscal).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)notaFiscal).Id, notaFiscal, (TipoTela)55)); + } + notaFiscal = ((((DomainBase)notaFiscal).Id == 0L) ? commited.NotaFiscalRepository.SaveOrUpdate(notaFiscal) : commited.NotaFiscalRepository.Merge(notaFiscal)); + if (!num) + { + list.Add(CreateLog(((DomainBase)notaFiscal).Id, ((DomainBase)notaFiscal).GetValorOriginal(), (TipoTela)55, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return notaFiscal; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)313, tries, notaFiscal); + } + } + return notaFiscalOriginal; + }); + } + + public async Task<bool> Delete(NotaFiscal notaFiscal) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)notaFiscal).Id, ((DomainBase)notaFiscal).GetValorOriginal(), (TipoTela)55, (TipoAcao)2)); + commited.NotaFiscalRepository.Delete(((DomainBase)notaFiscal).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)314, tries, notaFiscal); + } + } + return false; + }); + } + + internal async Task<bool> Cadatrada(long idExtrato) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.NotaFiscalRepository.FindByExtrato(idExtrato); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)315, tries, idExtrato); + } + } + return false; + }); + } + + public async Task<List<NotaFiscal>> BuscarNotasFiscais(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.NotaFiscalRepository.FindByDatas(filtro); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)315, tries, filtro); + } + } + return new List<NotaFiscal>(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/ProdutoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/ProdutoServico.cs new file mode 100644 index 0000000..4289f60 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/ProdutoServico.cs @@ -0,0 +1,91 @@ +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.Ferramentas; + +internal class ProdutoServico : BaseServico +{ + internal async Task<Produto> BuscarProdutoPorId(long id) + { + int tries = 3; + return await Task.Run((Func<Produto>)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.ProdutoRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)116, tries, id); + } + } + return new Produto(); + }); + } + + public async Task<Produto> Save(Produto produto) + { + int tries = 3; + base.Sucesso = true; + Produto produtoOriginal = produto; + return await Task.Run((Func<Produto>)delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + produto = produtoOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)produto).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)produto).Id, produto, (TipoTela)10)); + } + produto = ((((DomainBase)produto).Id == 0L) ? commited.ProdutoRepository.SaveOrUpdate(produto) : commited.ProdutoRepository.Merge(produto)); + if (!num) + { + list.Add(CreateLog(((DomainBase)produto).Id, ((DomainBase)produto).GetValorOriginal(), (TipoTela)10, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return produto; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)226, tries, produto); + } + } + return produtoOriginal; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/QualificacaoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/QualificacaoServico.cs new file mode 100644 index 0000000..c3e5138 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/QualificacaoServico.cs @@ -0,0 +1,53 @@ +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.Ferramentas; + +internal class QualificacaoServico : BaseServico +{ + internal async Task<Qualificacao> Save(Qualificacao qualificacao) + { + int tries = 3; + base.Sucesso = true; + Qualificacao qualificacaoOriginal = qualificacao; + return await Task.Run((Func<Qualificacao>)delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + qualificacao = qualificacaoOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)qualificacao).Id, qualificacao, (TipoTela)48)); + Qualificacao result = commited.QualificacaoRepository.SaveOrUpdate(qualificacao); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return result; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)229, tries, qualificacao); + } + } + return qualificacaoOriginal; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/RamoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/RamoServico.cs new file mode 100644 index 0000000..fc0dbe7 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/RamoServico.cs @@ -0,0 +1,191 @@ +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.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class RamoServico : BaseServico +{ + internal async Task<Ramo> Save(Ramo ramo, List<CoberturaPadrao> coberturas) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Ramo ramoOriginal = ramo; + return await Task.Run((Func<Ramo>)delegate + { + //IL_0060: 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_0077: 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) + { + ramo = ramoOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + Ramo result = unitOfWork.RamoRepository.SaveOrUpdate(ramo); + coberturas?.ForEach(delegate(CoberturaPadrao x) + { + unitOfWork.CoberturaPadraoRepository.Merge(x); + }); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)ramo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)ramo).Id, + Tela = (TipoTela)12, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.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)228, tries, new { ramo, coberturas }); + } + } + return ramoOriginal; + }); + } + + public async Task<List<Ramo>> BuscarRamos() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + return commited.RamoRepository.Find(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)169, tries); + } + } + return (List<Ramo>)null; + }); + } + + public async Task<Ramo> Insert(Ramo ramo) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Ramo ramoOriginal = ramo; + return await Task.Run((Func<Ramo>)delegate + { + //IL_0039: 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_0045: 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_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0074: Expected O, but got Unknown + //IL_0079: 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_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Expected O, but got Unknown + while (tries > 0) + { + ramo = ramoOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + ramo = commited.RamoRepository.SaveOrUpdate(ramo); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)0, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)ramo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)ramo).Id, + Tela = (TipoTela)12, + 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 ramo; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)230, tries, ramo); + } + } + return ramoOriginal; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/ReciboServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/ReciboServico.cs new file mode 100644 index 0000000..4fb8220 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/ReciboServico.cs @@ -0,0 +1,122 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class ReciboServico : BaseServico +{ + internal async Task<List<Recibo>> BuscarRecibos() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ReciboRepository.BuscarRecibos(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)123, tries); + } + } + return new List<Recibo>(); + }); + } + + public async Task<Recibo> Save(Recibo recibo) + { + int tries = 3; + base.Sucesso = true; + Recibo reciboOriginal = recibo; + return await Task.Run((Func<Recibo>)delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + recibo = reciboOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)recibo).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)recibo).Id, recibo, (TipoTela)42)); + } + recibo = ((((DomainBase)recibo).Id == 0L) ? commited.ReciboRepository.SaveOrUpdate(recibo) : commited.ReciboRepository.Merge(recibo)); + if (!num) + { + list.Add(CreateLog(((DomainBase)recibo).Id, ((DomainBase)recibo).GetValorOriginal(), (TipoTela)42, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return recibo; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)231, tries, recibo); + } + } + return reciboOriginal; + }); + } + + public async Task<bool> Delete(Recibo recibo) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)recibo).Id, ((DomainBase)recibo).GetValorOriginal(), (TipoTela)42, (TipoAcao)2)); + commited.ReciboRepository.Delete(((DomainBase)recibo).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)232, tries, recibo); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs new file mode 100644 index 0000000..c8de222 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/SeguradoraServico.cs @@ -0,0 +1,374 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class SeguradoraServico : BaseServico +{ + public async Task<Seguradora> Save(Seguradora seguradora, List<ConfigExtratoImport> config, bool primeiroAcesso = false) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Seguradora seguradoraOriginal = seguradora; + return await Task.Run((Func<Seguradora>)delegate + { + //IL_0033: 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_012c: 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_0133: Unknown result type (might be due to invalid IL or missing references) + //IL_013e: Unknown result type (might be due to invalid IL or missing references) + //IL_014a: 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_0156: Unknown result type (might be due to invalid IL or missing references) + //IL_0162: Expected O, but got Unknown + //IL_0167: Unknown result type (might be due to invalid IL or missing references) + //IL_0178: 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_018b: Unknown result type (might be due to invalid IL or missing references) + //IL_0196: Unknown result type (might be due to invalid IL or missing references) + //IL_01a1: Unknown result type (might be due to invalid IL or missing references) + //IL_01e0: Expected O, but got Unknown + while (tries > 0) + { + seguradora = seguradoraOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)seguradora).Id != 0L); + List<SeguradoraContato> list = seguradora.Contatos; + if (list != null) + { + list.ForEach(delegate(SeguradoraContato x) + { + x.Seguradora = seguradora; + }); + list = unitOfWork.SeguradoraContatoRepository.Merge(list, seguradora, ((DomainBase)Recursos.Empresa).Id); + } + List<SeguradoraEndereco> list2 = seguradora.Enderecos; + if (list != null) + { + list2 = unitOfWork.SeguradoraEnderecoRepository.Merge(list2, seguradora, ((DomainBase)Recursos.Empresa).Id); + } + if (list != null || primeiroAcesso) + { + seguradora = unitOfWork.SeguradoraRepository.Merge(seguradora); + } + seguradora.Contatos = list; + seguradora.Enderecos = list2; + config?.ForEach(delegate(ConfigExtratoImport x) + { + unitOfWork.ConfigExtratoImportRepository.Merge(x); + }); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)seguradora, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)seguradora).Id, + Tela = (TipoTela)13, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return seguradora; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)233, tries, new { seguradora, config }); + } + } + return seguradoraOriginal; + }); + } + + public async Task<Seguradora> Insert(Seguradora seguradora) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Seguradora seguradoraOriginal = seguradora; + return await Task.Run((Func<Seguradora>)delegate + { + //IL_0039: 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_0045: 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_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0074: Expected O, but got Unknown + //IL_0079: 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_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Expected O, but got Unknown + while (tries > 0) + { + seguradora = seguradoraOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + seguradora = commited.SeguradoraRepository.SaveOrUpdate(seguradora); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)0, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)seguradora, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)seguradora).Id, + Tela = (TipoTela)13, + 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 seguradora; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)234, tries, seguradora); + } + } + return seguradoraOriginal; + }); + } + + internal async Task<List<ConfigExtratoImport>> BuscarConfig(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ConfigExtratoImportRepository.FindBySeguradora(id) + orderby x.Descricao + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)124, tries, id); + } + } + return new List<ConfigExtratoImport>(); + }); + } + + public async Task<ObservableCollection<SeguradoraContato>> BuscarContatos(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<SeguradoraContato>(from x in read.SeguradoraContatoRepository.FindBySeguradora(((DomainBase)Recursos.Empresa).Id, id) + orderby x.NomeContato + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)125, tries, new + { + ((DomainBase)Recursos.Empresa).Id, + id + }); + } + } + return new ObservableCollection<SeguradoraContato>(); + }); + } + + public async Task<ObservableCollection<SeguradoraEndereco>> BuscarEnderecos(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<SeguradoraEndereco>(from x in read.SeguradoraEnderecoRepository.FindBySeguradora(((DomainBase)Recursos.Empresa).Id, id) + orderby ((DomainBase)x).Id + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)126, tries, new + { + ((DomainBase)Recursos.Empresa).Id, + id + }); + } + } + return new ObservableCollection<SeguradoraEndereco>(); + }); + } + + public async Task<List<SeguradoraContato>> BuscarAssistencias(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.SeguradoraContatoRepository.FindAssistencia(((DomainBase)Recursos.Empresa).Id, id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)125, tries, new + { + ((DomainBase)Recursos.Empresa).Id, + id + }); + } + } + return new List<SeguradoraContato>(); + }); + } + + public async Task<List<Seguradora>> BuscarSeguradoras() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.SeguradoraRepository.Find(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)127, tries); + } + } + return new List<Seguradora>(); + }); + } + + public async Task<Seguradora> BuscarSeguradora(long id) + { + int tries = 3; + return await Task.Run((Func<Seguradora>)delegate + { + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.SeguradoraRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)128, tries); + } + } + return new Seguradora(); + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs new file mode 100644 index 0000000..1b3a52c --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/SocioServico.cs @@ -0,0 +1,94 @@ +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; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class SocioServico : BaseServico +{ + public async Task<Socio> Save(Socio socio) + { + int tries = 3; + base.Sucesso = true; + Socio socioOriginal = socio; + return await Task.Run((Func<Socio>)delegate + { + List<RegistroLog> list = new List<RegistroLog>(); + socio = socioOriginal; + while (tries > 0) + { + socio = socioOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)socio).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)socio).Id, socio, (TipoTela)19)); + } + socio = ((((DomainBase)socio).Id == 0L) ? commited.SocioRepository.SaveOrUpdate(socio) : commited.SocioRepository.Merge(socio)); + if (!num) + { + list.Add(CreateLog(((DomainBase)socio).Id, ((DomainBase)socio).GetValorOriginal(), (TipoTela)19, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return socio; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)235, tries, socio); + } + } + return socioOriginal; + }); + } + + public async Task<bool> Delete(Socio socio) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)socio).Id, ((DomainBase)socio).GetValorOriginal(), (TipoTela)19, (TipoAcao)2)); + commited.SocioRepository.Delete(((DomainBase)socio).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)236, tries, socio); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/StatusProspeccaoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/StatusProspeccaoServico.cs new file mode 100644 index 0000000..0801f13 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/StatusProspeccaoServico.cs @@ -0,0 +1,90 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class StatusProspeccaoServico : BaseServico +{ + internal async Task<List<StatusDeProspeccao>> BuscarProspeccoes() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.StatusProspeccaoRepository.FindAll(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)308, tries); + } + } + return new List<StatusDeProspeccao>(); + }); + } + + internal async Task<StatusDeProspeccao> Save(StatusDeProspeccao statusProspeccao) + { + int tries = 3; + base.Sucesso = true; + StatusDeProspeccao statusProspeccaoOriginal = statusProspeccao; + return await Task.Run((Func<StatusDeProspeccao>)delegate + { + List<RegistroLog> list = new List<RegistroLog>(); + statusProspeccao = statusProspeccaoOriginal; + while (tries > 0) + { + statusProspeccao = statusProspeccaoOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)statusProspeccao).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)statusProspeccao).Id, statusProspeccao, (TipoTela)57)); + } + statusProspeccao = ((((DomainBase)statusProspeccao).Id == 0L) ? commited.StatusProspeccaoRepository.SaveOrUpdate(statusProspeccao) : commited.StatusProspeccaoRepository.Merge(statusProspeccao)); + if (!num) + { + list.Add(CreateLog(((DomainBase)statusProspeccao).Id, ((DomainBase)statusProspeccao).GetValorOriginal(), (TipoTela)57, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return statusProspeccao; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)307, tries, statusProspeccao); + } + } + return statusProspeccaoOriginal; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/StatusServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/StatusServico.cs new file mode 100644 index 0000000..b7a6068 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/StatusServico.cs @@ -0,0 +1,125 @@ +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.Ferramentas; + +internal class StatusServico : BaseServico +{ + internal async Task<Status> BuscarStatusPorId(long id) + { + int tries = 3; + return await Task.Run((Func<Status>)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.StatusRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)119, tries, id); + } + } + return new Status(); + }); + } + + public async Task<Status> Save(Status status) + { + int tries = 3; + base.Sucesso = true; + Status statusOriginal = status; + return await Task.Run((Func<Status>)delegate + { + List<RegistroLog> list = new List<RegistroLog>(); + status = statusOriginal; + while (tries > 0) + { + status = statusOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)status).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)status).Id, status, (TipoTela)11)); + } + status = ((((DomainBase)status).Id == 0L) ? commited.StatusRepository.SaveOrUpdate(status) : commited.StatusRepository.Merge(status)); + if (!num) + { + list.Add(CreateLog(((DomainBase)status).Id, ((DomainBase)status).GetValorOriginal(), (TipoTela)11, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return status; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)227, tries, status); + } + } + return statusOriginal; + }); + } + + public async Task<bool> Delete(Status status) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)status).Id, ((DomainBase)status).GetValorOriginal(), (TipoTela)11, (TipoAcao)2)); + commited.StatusRepository.Delete(((DomainBase)status).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)221, tries, status); + } + } + return false; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/TipoTarefaServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/TipoTarefaServico.cs new file mode 100644 index 0000000..9c49d4a --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/TipoTarefaServico.cs @@ -0,0 +1,90 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; + +namespace Gestor.Application.Servicos.Ferramentas; + +internal class TipoTarefaServico : BaseServico +{ + internal async Task<List<TipoDeTarefa>> BuscarTarefas() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TipoTarefaRepository.FindAll(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)308, tries); + } + } + return new List<TipoDeTarefa>(); + }); + } + + internal async Task<TipoDeTarefa> Save(TipoDeTarefa tipoTarefa) + { + int tries = 3; + base.Sucesso = true; + TipoDeTarefa tipoTarefaOriginal = tipoTarefa; + return await Task.Run((Func<TipoDeTarefa>)delegate + { + List<RegistroLog> list = new List<RegistroLog>(); + tipoTarefa = tipoTarefaOriginal; + while (tries > 0) + { + tipoTarefa = tipoTarefaOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + bool num = ((DomainBase)tipoTarefa).Id != 0L; + if (num) + { + list.Add(CreateLog(((DomainBase)tipoTarefa).Id, tipoTarefa, (TipoTela)52)); + } + tipoTarefa = ((((DomainBase)tipoTarefa).Id == 0L) ? commited.TipoTarefaRepository.SaveOrUpdate(tipoTarefa) : commited.TipoTarefaRepository.Merge(tipoTarefa)); + if (!num) + { + list.Add(CreateLog(((DomainBase)tipoTarefa).Id, ((DomainBase)tipoTarefa).GetValorOriginal(), (TipoTela)52, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return tipoTarefa; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)306, tries, tipoTarefa); + } + } + return tipoTarefaOriginal; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/TipoVendedorServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/TipoVendedorServico.cs new file mode 100644 index 0000000..76349c2 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/TipoVendedorServico.cs @@ -0,0 +1,131 @@ +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.Ferramentas; + +internal class TipoVendedorServico : BaseServico +{ + internal async Task<TipoVendedor> Save(TipoVendedor tipoVendedor) + { + int tries = 3; + base.Sucesso = true; + TipoVendedor tipoVendedorOriginal = tipoVendedor; + return await Task.Run<TipoVendedor>(async delegate + { + while (tries > 0) + { + List<RegistroLog> logs = new List<RegistroLog>(); + tipoVendedor = tipoVendedorOriginal; + try + { + UnitOfWork unitOfWork = Instancia.Commited; + try + { + TipoAcao acao = (TipoAcao)(((DomainBase)tipoVendedor).Id != 0L); + if (((DomainBase)tipoVendedor).Id == 0L) + { + TipoVendedor val = tipoVendedor; + ((DomainBase)val).Id = await FindLastId() + 1; + } + TipoAcao val2 = acao; + if ((int)val2 != 0) + { + if ((int)val2 == 1) + { + logs.Add(CreateLog(((DomainBase)tipoVendedor).Id, tipoVendedor, (TipoTela)14)); + } + } + else + { + logs.Add(CreateLog(((DomainBase)tipoVendedor).Id, ((DomainBase)tipoVendedor).GetValorOriginal(), (TipoTela)14, (TipoAcao)0)); + } + tipoVendedor = (((int)acao == 0) ? unitOfWork.TipoVendedorRepository.SaveOrUpdate(tipoVendedor) : unitOfWork.TipoVendedorRepository.Merge(tipoVendedor)); + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return tipoVendedor; + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)237, tries, tipoVendedor); + } + } + return tipoVendedorOriginal; + }); + } + + public async Task<bool> Delete(TipoVendedor tipoVendedor) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)tipoVendedor).Id, ((DomainBase)tipoVendedor).GetValorOriginal(), (TipoTela)14, (TipoAcao)2)); + commited.TipoVendedorRepository.Delete(((DomainBase)tipoVendedor).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)238, tries, tipoVendedor); + } + } + return false; + }); + } + + public async Task<long> FindLastId() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.TipoVendedorRepository.FindLastId(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)17, tries); + } + } + return 0L; + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/UsuarioServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/UsuarioServico.cs new file mode 100644 index 0000000..1ee95e1 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/UsuarioServico.cs @@ -0,0 +1,317 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Common.Security; +using Gestor.Common.Validation; +using Gestor.Infrastructure.Mappers; +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.Ferramentas; + +internal class UsuarioServico : BaseServico +{ + internal async Task<Usuario> BuscarUsuarioPorId(long id) + { + int tries = 3; + return await Task.Run((Func<Usuario>)delegate + { + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.UsuarioRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)130, tries, id); + } + } + return new Usuario(); + }); + } + + public async Task<Usuario> Save(Usuario usuario) + { + int tries = 3; + base.Sucesso = true; + Usuario usuarioOriginal = usuario; + return await Task.Run((Func<Usuario>)delegate + { + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + List<RegistroLog> list = new List<RegistroLog>(); + while (tries > 0) + { + usuario = usuarioOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + Usuario usuario2 = Recursos.Usuario; + string text = ((usuario2 != null) ? usuario2.TokenSso : null); + Empresa empresa = Recursos.Empresa; + string documentoEmpresa = ((empresa != null) ? empresa.Documento : null); + if (ValidationHelper.IsNullOrEmpty(text)) + { + Empresa val = commited.EmpresaRepository.FindBySerial(ApplicationHelper.NumeroSerial); + string password = usuario.Senha; + if (ValidationHelper.IsNotNullOrEmpty(usuario.SenhaAnterior)) + { + if (new Token().AggerDecrypt(usuario.SenhaAnterior).ToUpper().Contains("AGGER@")) + { + Usuario result = BuscarLogin(usuario.Login).Result; + usuario.SenhaAnterior = result.Senha; + } + password = usuario.SenhaAnterior; + } + AuthSso result2 = BuscaUsuarioSso(usuario.Login, password, val.Documento).Result; + if (result2 == null || result2.Code == 401) + { + base.Sucesso = false; + return usuarioOriginal; + } + text = result2.Data.Token; + documentoEmpresa = val.Documento; + } + Usuario obj = usuario; + long? permissaoAggilizador2; + if (usuario.PermissaoAggilizador.HasValue) + { + long? num = (usuario.PermissaoAggilizador = usuario.PermissaoAggilizador); + permissaoAggilizador2 = num; + } + else + { + long? num = (usuario.PermissaoAggilizador = 2L); + permissaoAggilizador2 = num; + } + obj.PermissaoAggilizador = permissaoAggilizador2; + bool num3 = ((DomainBase)usuario).Id != 0L; + if (num3) + { + list.Add(CreateLog(((DomainBase)usuario).Id, usuario, (TipoTela)16)); + } + usuario = ((((DomainBase)usuario).Id == 0L) ? commited.UsuarioRepository.SaveOrUpdate(usuario) : commited.UsuarioRepository.Merge(usuario)); + if (!num3) + { + list.Add(CreateLog(((DomainBase)usuario).Id, ((DomainBase)usuario).GetValorOriginal(), (TipoTela)16, (TipoAcao)0)); + } + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + usuario.TokenSso = text; + AddOrUpdateUsuarioSso(usuario, documentoEmpresa, usuario.SsoId).Wait(); + return usuario; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)239, tries, usuario); + } + } + return usuarioOriginal; + }); + } + + public async Task<bool> Delete(Usuario usuario) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + list.Add(CreateLog(((DomainBase)usuario).Id, ((DomainBase)usuario).GetValorOriginal(), (TipoTela)16, (TipoAcao)2)); + commited.UsuarioRepository.Delete(((DomainBase)usuario).Id); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + usuario.TokenSso = Recursos.Usuario.TokenSso; + DeleteUsuarioSso(usuario, Recursos.Empresa.Documento).Wait(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)240, tries, usuario); + } + } + return false; + }); + } + + public async Task<List<PermissaoAggilizador>> BuscarPermissaoAggilizador() + { + return await Task.Run(delegate + { + //IL_0025: 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_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Expected O, but got Unknown + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_0048: 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_0060: Expected O, but got Unknown + //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_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Expected O, but got Unknown + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.UsuarioRepository.PermissaoAggilizador(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception) + { + return new List<PermissaoAggilizador> + { + new PermissaoAggilizador + { + Id = 1L, + Descricao = "ADMINISTRADOR" + }, + new PermissaoAggilizador + { + Id = 2L, + Descricao = "NORMAL" + }, + new PermissaoAggilizador + { + Id = 3L, + Descricao = "LIMITADO" + } + }; + } + }); + } + + public async Task<Usuario> BuscarLogin(string login) + { + int tries = 3; + return await Task.Run((Func<Usuario>)delegate + { + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00cf: Expected O, but got Unknown + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + Empresa val = read.EmpresaRepository.FindBySerial(ApplicationHelper.NumeroSerial); + AuthSso result = VerificaUsuarioSso(login, val.Documento).Result; + if (result == null || result.Code == 401) + { + return new Usuario(); + } + Usuario val2 = read.UsuarioRepository.FindUsuario(login); + return (result.Code == 404) ? val2 : CustomMap.FromUserSso(val2, result.Data.User); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)134, tries, login); + } + } + return new Usuario(); + }); + } + + public async Task AddCentralSegurado(long id, bool update = true) + { + await Task.Run(delegate + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.ClienteRepository.AddCentralSegurado(id, update); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + }); + } + + public async Task<Usuario> BuscaUsuarioInicial(string usuario, string senha) + { + return await Task.Run((Func<Usuario>)delegate + { + //IL_0017: 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: Expected O, but got Unknown + UnitOfWork read = Instancia.Read; + try + { + Empresa val = read.EmpresaRepository.FindBySerial(ApplicationHelper.NumeroSerial); + string password = new Token().AggerEncrypt(senha); + AuthSso result = BuscaUsuarioSso(usuario, password, val.Documento).Result; + if (result.Code == 401) + { + return (Usuario)null; + } + Usuario val2 = read.UsuarioRepository.FindUsuario(usuario); + if (result.Code == 404 && val2 == null) + { + return new Usuario(); + } + if (result.Data == null && val2 != null) + { + return val2; + } + if (val2 == null && result.Data != null) + { + return CustomMap.ToUsuario(result.Data.User, ((DomainBase)val).Id); + } + return val2; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + }); + } +} diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs new file mode 100644 index 0000000..b9327fb --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/VendedorServico.cs @@ -0,0 +1,825 @@ +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.Common.Validation; +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.Ferramentas; + +public class VendedorServico : BaseServico +{ + internal async Task<List<Vendedor>> BuscarVendedoresAtivosAsync() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new List<Vendedor>(from x in read.VendedorRepository.Find(true, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa) + orderby x.Nome + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)135, tries); + } + } + return new List<Vendedor>(); + }); + } + + public async Task<List<ManutencaoPagamentos>> BuscarPagos(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.FindByDate(filtro).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)80, tries); + } + } + return new List<ManutencaoPagamentos>(); + }); + } + + public async Task<VendedorParcela> BuscarVendedorParcelaCompleto(long id) + { + int tries = 3; + return await Task.Run((Func<VendedorParcela>)delegate + { + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)81, tries); + } + } + return new VendedorParcela(); + }); + } + + public async Task<List<VendedorParcela>> BuscaRepasse(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) + orderby ((DomainBase)x.TipoVendedor).Id + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)136, tries, id); + } + } + return new List<VendedorParcela>(); + }); + } + + public async Task<List<VendedorParcela>> BuscaRepasseParcela(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorParcelaRepository.FindByParcela(id).OrderBy(delegate(VendedorParcela x) + { + TipoVendedor tipoVendedor = x.TipoVendedor; + return (tipoVendedor == null) ? null : new long?(((DomainBase)tipoVendedor).Id); + }).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)137, tries, id); + } + } + return new List<VendedorParcela>(); + }); + } + + internal async Task<ObservableCollection<VendedorTelefone>> BuscarTelefonesAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<VendedorTelefone>(from x in read.VendedorTelefoneRepository.FindByVendedorId(id) + orderby x.Nome + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)138, tries, id); + } + } + return new ObservableCollection<VendedorTelefone>(); + }); + } + + internal async Task<Vendedor> BuscarVendedorPorId(long id) + { + int tries = 3; + return await Task.Run((Func<Vendedor>)delegate + { + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorRepository.FindById(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)139, tries, id); + } + } + return new Vendedor(); + }); + } + + public async Task<List<Repasse>> BuscaRepasses() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RepasseRepository.DefaultSelect(0L); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)142, tries); + } + } + return new List<Repasse>(); + }); + } + + public async Task<Vendedor> Save(Vendedor vendedor, Repasse repasse) + { + int tries = 3; + base.Sucesso = true; + Vendedor vendedorOriginal = vendedor; + return await Task.Run((Func<Vendedor>)delegate + { + while (tries > 0) + { + vendedor = vendedorOriginal; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + vendedor.IdEmpresa = ((vendedor.IdEmpresa == 0L) ? ((DomainBase)Recursos.Empresa).Id : vendedor.IdEmpresa); + vendedor = commited.VendedorRepository.SaveOrUpdate(vendedor); + repasse.Vendedor = vendedor; + repasse = commited.RepasseRepository.SaveOrUpdate(repasse); + ((GenericUnitOfWork)commited).Commit(); + return vendedor; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)241, tries, new { vendedor, repasse }); + } + } + return vendedorOriginal; + }); + } + + public async Task<VinculoRepasse> Save(VinculoRepasse vinculo) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + return await Task.Run((Func<VinculoRepasse>)delegate + { + //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) + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: 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_006b: 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_0072: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Expected O, but got Unknown + //IL_0083: 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_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Expected O, but got Unknown + while (tries > 0) + { + VinculoRepasse val = vinculo; + try + { + UnitOfWork commited = Instancia.Commited; + try + { + TipoAcao val2 = (TipoAcao)(((DomainBase)val).Id != 0L); + val = (((int)val2 == 0) ? commited.RepasseRepository.SaveOrUpdate(val) : commited.RepasseRepository.Merge(val)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = val2, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)val, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)val).Id, + Tela = (TipoTela)53, + 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 val; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)311, tries, vinculo); + } + } + return vinculo; + }); + } + + public async Task<bool> Delete(VinculoRepasse vinculo) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + 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_0050: 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_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Expected O, but got Unknown + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.RepasseRepository.DeleteVinculo(((DomainBase)vinculo).Id); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)2, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)vinculo, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)vinculo).Id, + Tela = (TipoTela)53, + 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)311, tries, vinculo); + } + } + return false; + }); + } + + public async Task<Vendedor> Save(Vendedor vendedor, List<Repasse> repasses) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Vendedor vendedorOriginal = vendedor; + return await Task.Run((Func<Vendedor>)delegate + { + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_0228: Unknown result type (might be due to invalid IL or missing references) + //IL_022d: Unknown result type (might be due to invalid IL or missing references) + //IL_022e: Unknown result type (might be due to invalid IL or missing references) + //IL_0234: Unknown result type (might be due to invalid IL or missing references) + //IL_023f: Unknown result type (might be due to invalid IL or missing references) + //IL_024b: Unknown result type (might be due to invalid IL or missing references) + //IL_0252: Unknown result type (might be due to invalid IL or missing references) + //IL_0257: Unknown result type (might be due to invalid IL or missing references) + //IL_0263: Expected O, but got Unknown + //IL_0268: Unknown result type (might be due to invalid IL or missing references) + //IL_0279: Unknown result type (might be due to invalid IL or missing references) + //IL_0281: Unknown result type (might be due to invalid IL or missing references) + //IL_028c: Unknown result type (might be due to invalid IL or missing references) + //IL_0297: Unknown result type (might be due to invalid IL or missing references) + //IL_02a2: Unknown result type (might be due to invalid IL or missing references) + //IL_02e0: Expected O, but got Unknown + //IL_0309: Unknown result type (might be due to invalid IL or missing references) + //IL_030e: Unknown result type (might be due to invalid IL or missing references) + //IL_030f: Unknown result type (might be due to invalid IL or missing references) + //IL_0315: Unknown result type (might be due to invalid IL or missing references) + //IL_0320: Unknown result type (might be due to invalid IL or missing references) + //IL_032c: Unknown result type (might be due to invalid IL or missing references) + //IL_032f: Unknown result type (might be due to invalid IL or missing references) + //IL_0334: Unknown result type (might be due to invalid IL or missing references) + //IL_0340: Expected O, but got Unknown + //IL_0345: Unknown result type (might be due to invalid IL or missing references) + //IL_0352: Unknown result type (might be due to invalid IL or missing references) + //IL_035a: Unknown result type (might be due to invalid IL or missing references) + //IL_0365: Unknown result type (might be due to invalid IL or missing references) + //IL_0370: Unknown result type (might be due to invalid IL or missing references) + //IL_037b: Unknown result type (might be due to invalid IL or missing references) + //IL_03b9: Expected O, but got Unknown + while (tries > 0) + { + vendedor = vendedorOriginal; + try + { + List<VendedorTelefone> list = vendedor.Telefones; + UnitOfWork commited = Instancia.Commited; + try + { + foreach (Repasse item in repasses.Where(delegate(Repasse r) + { + Ramo ramo = r.Ramo; + return ramo != null && ((DomainBase)ramo).Id == 0; + })) + { + item.Ramo = null; + } + bool num = ((DomainBase)vendedor).Id == 0; + vendedor.IdEmpresa = ((vendedor.IdEmpresa == 0L) ? ((DomainBase)Recursos.Empresa).Id : vendedor.IdEmpresa); + TipoAcao acao = (TipoAcao)(((DomainBase)vendedor).Id != 0L); + if (num) + { + vendedor = commited.VendedorRepository.SaveOrUpdate(vendedor); + if (list != null) + { + list = commited.VendedorTelefoneRepository.Inserir(list, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass in repasses) + { + repass.Vendedor = vendedor; + commited.RepasseRepository.SaveOrUpdate(repass); + } + } + } + else + { + vendedor = commited.VendedorRepository.Merge(vendedor); + if (list != null) + { + list = commited.VendedorTelefoneRepository.Merge(list, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass2 in repasses) + { + if (((DomainBase)repass2).Id == 0L) + { + commited.RepasseRepository.SaveOrUpdate(repass2); + } + else + { + commited.RepasseRepository.Merge(repass2); + } + } + } + } + vendedor.Telefones = list; + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (((DomainBase)Recursos.Usuario).Id != 0L) + { + RegistroLog keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)vendedor, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)vendedor).Id, + Tela = (TipoTela)15, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + SaveLog(keyValues, commited); + foreach (Repasse repass3 in repasses) + { + keyValues = new RegistroLog + { + Acao = acao, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)repass3, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)repass3).Id, + Tela = (TipoTela)54, + 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 vendedor; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)241, tries, new { vendedor, repasses }); + } + } + return vendedorOriginal; + }); + } + + public async Task<Repasse> Save(Repasse repasse) + { + int tries = 3; + base.Sucesso = true; + DateTime now = Funcoes.GetNetworkTime(); + Repasse repasseSave = repasse; + return await Task.Run((Func<Repasse>)delegate + { + //IL_002e: 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_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0045: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Expected O, but got Unknown + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0087: 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_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00e5: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + repasseSave = commited.RepasseRepository.Merge(repasseSave); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)1, + Usuario = Recursos.Usuario, + DataHora = now, + Descricao = JsonConvert.SerializeObject((object)repasse, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)repasse).Id, + Tela = (TipoTela)54, + 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 repasseSave; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)241, tries, new { repasse }); + } + } + return repasse; + }); + } + + public async Task<bool> Delete(Vendedor vendedor) + { + int tries = 3; + DateTime dateHora = Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork commited = Instancia.Commited; + try + { + commited.VendedorRepository.Delete(((DomainBase)vendedor).Id); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog val = new RegistroLog(); + val.Acao = (TipoAcao)2; + val.Usuario = Recursos.Usuario; + val.DataHora = dateHora; + val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {dateHora}, O VENDEDOR DE " + $"ID: '{((DomainBase)vendedor).Id}'" + ", NOME: '" + (string.IsNullOrWhiteSpace(vendedor.Nome) ? "" : (vendedor.Nome ?? "")) + "', DOCUMENTO: '" + (string.IsNullOrWhiteSpace(vendedor.Documento) ? "" : (vendedor.Documento ?? "")) + "', BANCO: '" + ((vendedor.Banco == null) ? "" : (vendedor.Banco.Nome ?? "")) + "', CONTA: '" + (string.IsNullOrWhiteSpace(vendedor.Conta) ? "" : (vendedor.Conta ?? "")) + "'."; + val.EntidadeId = ((DomainBase)vendedor).Id; + val.Tela = (TipoTela)15; + val.Versao = LoginViewModel.VersaoAtual; + val.NomeMaquina = Environment.MachineName; + val.UsuarioMaquina = Environment.UserName; + val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(); + RegistroLog val2 = val; + if (vendedor.Telefones != null && vendedor.Telefones.Count != 0) + { + foreach (VendedorTelefone telefone in vendedor.Telefones) + { + val2.Descricao += string.Format(", TELEFONE {0}: {1} ({2}) {3}", vendedor.Telefones.IndexOf(telefone), (!((TelefoneBase)telefone).Tipo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)((TelefoneBase)telefone).Tipo), string.IsNullOrWhiteSpace(((TelefoneBase)telefone).Prefixo) ? "" : (((TelefoneBase)telefone).Prefixo ?? ""), string.IsNullOrWhiteSpace(((TelefoneBase)telefone).Numero) ? "" : (((TelefoneBase)telefone).Numero ?? "")); + } + } + val2.Descricao += "."; + SaveLog(val2, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)242, tries, vendedor); + } + } + return false; + }); + } + + public async Task<ObservableCollection<Repasse>> BuscaRepassesPorIdVendedor(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<Repasse>(read.RepasseRepository.FindByIdVendedor(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)143, tries, id); + } + } + return new ObservableCollection<Repasse>(); + }); + } + + public async Task<List<VendedorParcela>> BuscarVendedorParcela(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.RepasseRepository.FindByIdRepasse(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)143, tries, id); + } + } + return new List<VendedorParcela>(); + }); + } + + public async Task<Vendedor> BuscarCorretora() + { + return await Task.Run((Func<Vendedor>)delegate + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.VendedorRepository.FindCorretora(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception) + { + return (Vendedor)null; + } + }); + } + + public async Task<List<Vendedor>> BuscarVinculosCliente(long idCliente) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + if (Recursos.Usuario.IdEmpresa != 1) + { + _ = Recursos.Usuario.IdEmpresa; + } + return read.VendedorParcelaRepository.FindVinculoByIdCliente(idCliente); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)143, tries); + } + } + return (List<Vendedor>)null; + }); + } +} |