summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs340
1 files changed, 340 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs b/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs
new file mode 100644
index 0000000..6cdf7cf
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos/ProspeccaoServico.cs
@@ -0,0 +1,340 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos;
+
+public class ProspeccaoServico : BaseServico
+{
+ internal async Task<List<Prospeccao>> BuscarProspeccoes(long id, DateTime inicio, DateTime fim, StatusProspeccao? status)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ProspectRepository.Find(((DomainBase)Recursos.Empresa).Id, id, inicio, fim, status);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)86, tries, new { id, inicio, fim, status });
+ }
+ }
+ return new List<Prospeccao>();
+ });
+ }
+
+ public async Task<Prospeccao> Salvar(Prospeccao prospecao)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Prospeccao prospecaoOriginal = prospecao;
+ return await Task.Run((Func<Prospeccao>)delegate
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0165: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0171: Unknown result type (might be due to invalid IL or missing references)
+ //IL_017c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0183: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_019b: Expected O, but got Unknown
+ //IL_01a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01b1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01b9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01c4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01cf: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01da: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0219: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ prospecao = prospecaoOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ TipoAcao acao = (TipoAcao)(((DomainBase)prospecao).Id != 0L);
+ prospecao.IdEmpresa = Recursos.Usuario.IdEmpresa;
+ if (!prospecao.DataCriacao.HasValue)
+ {
+ prospecao.DataCriacao = networkTime;
+ }
+ if (prospecao.UsuarioCriacao == 0L)
+ {
+ prospecao.UsuarioCriacao = ((DomainBase)Recursos.Usuario).Id;
+ }
+ Tarefa tarefa = prospecao.Tarefa;
+ tarefa = ((!prospecao.CriarTarefa) ? null : ((((DomainBase)tarefa).Id == 0L) ? commited.TarefaRepository.Salvar(tarefa) : commited.TarefaRepository.Atualizar(tarefa)));
+ prospecao.Tarefa = tarefa;
+ prospecao = ((((DomainBase)prospecao).Id == 0L) ? commited.ProspectRepository.SaveOrUpdate(prospecao) : commited.ProspectRepository.Merge(prospecao));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ if (prospecao.Tarefa != null)
+ {
+ prospecao.Tarefa.IdEntidade = ((DomainBase)prospecao).Id;
+ prospecao.Tarefa = commited.TarefaRepository.Atualizar(prospecao.Tarefa);
+ }
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = networkTime,
+ Descricao = JsonConvert.SerializeObject((object)prospecao, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)prospecao).Id,
+ Tela = (TipoTela)33,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate
+ {
+ Gestor.Application.Actions.Actions.AtualizaBadges();
+ });
+ return prospecao;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)259, tries, prospecao);
+ }
+ }
+ return prospecaoOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(Prospeccao prospeccao)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0134: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0139: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0140: Unknown result type (might be due to invalid IL or missing references)
+ //IL_014b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0152: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0159: Unknown result type (might be due to invalid IL or missing references)
+ //IL_015e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_016a: Expected O, but got Unknown
+ //IL_016f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0180: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0188: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0193: Unknown result type (might be due to invalid IL or missing references)
+ //IL_019e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01a9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0070: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0082: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0089: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0095: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a6: Expected O, but got Unknown
+ //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00df: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01e6: Expected O, but got Unknown
+ //IL_0127: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ if (prospeccao.Tarefa != null)
+ {
+ commited.TarefaRepository.Excluir(((DomainBase)prospeccao.Tarefa).Id);
+ }
+ commited.ProspectRepository.Delete(((DomainBase)prospeccao).Id);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues;
+ if (prospeccao.Tarefa != null)
+ {
+ keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)2,
+ Usuario = Recursos.Usuario,
+ DataHora = networkTime,
+ Descricao = JsonConvert.SerializeObject((object)prospeccao.Tarefa, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)prospeccao.Tarefa).Id,
+ Tela = (TipoTela)38,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ }
+ keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)2,
+ Usuario = Recursos.Usuario,
+ DataHora = networkTime,
+ Descricao = JsonConvert.SerializeObject((object)prospeccao, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)prospeccao).Id,
+ Tela = (TipoTela)33,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ ((DispatcherObject)Application.Current).Dispatcher.Invoke((Action)delegate
+ {
+ Gestor.Application.Actions.Actions.AtualizaBadges();
+ });
+ return true;
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)260, tries, prospeccao);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<Prospeccao> BuscarProspeccao(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Prospeccao>)delegate
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ProspectRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)87, tries, id);
+ }
+ }
+ return new Prospeccao();
+ });
+ }
+
+ public async Task<List<Prospeccao>> BuscarProspeccoes(Filtros filtro)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ProspectRepository.Find(filtro);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)88, tries, filtro);
+ }
+ }
+ return new List<Prospeccao>();
+ });
+ }
+
+ public async Task<List<Prospeccao>> BuscarProspeccoesPorStatus(StatusDeProspeccao statusProspeccao)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ProspectRepository.FindByStatusPersonalizado(((DomainBase)statusProspeccao).Id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)310, tries, new { statusProspeccao });
+ }
+ }
+ return new List<Prospeccao>();
+ });
+ }
+}