diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Servicos.Ferramentas/AgendaServico.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/AgendaServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Ferramentas/AgendaServico.cs | 224 |
1 files changed, 224 insertions, 0 deletions
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>(); + }); + } +} |