summaryrefslogtreecommitdiff
path: root/Gestor.Application/Servicos/ProspeccaoServico.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Application/Servicos/ProspeccaoServico.cs')
-rw-r--r--Gestor.Application/Servicos/ProspeccaoServico.cs338
1 files changed, 0 insertions, 338 deletions
diff --git a/Gestor.Application/Servicos/ProspeccaoServico.cs b/Gestor.Application/Servicos/ProspeccaoServico.cs
deleted file mode 100644
index ab7ab6f..0000000
--- a/Gestor.Application/Servicos/ProspeccaoServico.cs
+++ /dev/null
@@ -1,338 +0,0 @@
-using Gestor.Application.Actions;
-using Gestor.Application.Helpers;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.ViewModels;
-using Gestor.Infrastructure.Repository.Interface;
-using Gestor.Infrastructure.UnitOfWork.Generic;
-using Gestor.Infrastructure.UnitOfWork.Logic;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Relatorios;
-using Gestor.Model.Domain.Seguros;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Threading;
-
-namespace Gestor.Application.Servicos
-{
- public class ProspeccaoServico : BaseServico
- {
- public ProspeccaoServico()
- {
- }
-
- public async Task<Prospeccao> BuscarProspeccao(long id)
- {
- int num = 3;
- Prospeccao prospeccao1 = await Task.Run<Prospeccao>(() => {
- Prospeccao prospeccao;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- prospeccao = read.get_ProspectRepository().FindById(id);
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 87, num, id, true);
- continue;
- }
- return prospeccao;
- }
- return new Prospeccao();
- });
- return prospeccao1;
- }
-
- internal async Task<List<Prospeccao>> BuscarProspeccoes(long id, DateTime inicio, DateTime fim, StatusProspeccao? status)
- {
- int num = 3;
- List<Prospeccao> prospeccaos1 = await Task.Run<List<Prospeccao>>(() => {
- List<Prospeccao> prospeccaos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- prospeccaos = read.get_ProspectRepository().Find(Recursos.Empresa.get_Id(), id, inicio, fim, status);
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 86, num, new { id = id, inicio = inicio, fim = fim, status = status }, true);
- continue;
- }
- return prospeccaos;
- }
- return new List<Prospeccao>();
- });
- return prospeccaos1;
- }
-
- public async Task<List<Prospeccao>> BuscarProspeccoes(Filtros filtro)
- {
- int num = 3;
- List<Prospeccao> prospeccaos1 = await Task.Run<List<Prospeccao>>(() => {
- List<Prospeccao> prospeccaos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- prospeccaos = read.get_ProspectRepository().Find(filtro);
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 88, num, filtro, true);
- continue;
- }
- return prospeccaos;
- }
- return new List<Prospeccao>();
- });
- return prospeccaos1;
- }
-
- public async Task<List<Prospeccao>> BuscarProspeccoesPorStatus(StatusDeProspeccao statusProspeccao)
- {
- int num = 3;
- List<Prospeccao> prospeccaos1 = await Task.Run<List<Prospeccao>>(() => {
- List<Prospeccao> prospeccaos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- prospeccaos = read.get_ProspectRepository().FindByStatusPersonalizado(statusProspeccao.get_Id());
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 310, num, new { statusProspeccao = statusProspeccao }, true);
- continue;
- }
- return prospeccaos;
- }
- return new List<Prospeccao>();
- });
- return prospeccaos1;
- }
-
- public async Task<bool> Delete(Prospeccao prospeccao)
- {
- int num = 3;
- bool flag1 = await Task.Run<bool>(() => {
- bool flag;
- string str;
- string str1;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork commited = Instancia.Commited)
- {
- if (prospeccao.get_Tarefa() != null)
- {
- commited.get_TarefaRepository().Excluir(prospeccao.get_Tarefa().get_Id());
- }
- commited.get_ProspectRepository().Delete(prospeccao.get_Id());
- DateTime networkTime = Funcoes.GetNetworkTime();
- IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
- if (prospeccao.get_Tarefa() != null)
- {
- RegistroLog registroLog = new RegistroLog();
- registroLog.set_Acao(2);
- registroLog.set_Usuario(Recursos.Usuario);
- registroLog.set_DataHora(networkTime);
- Tarefa tarefa = prospeccao.get_Tarefa();
- JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
- jsonSerializerSetting.set_ReferenceLoopHandling(1);
- registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting));
- registroLog.set_EntidadeId(prospeccao.get_Tarefa().get_Id());
- registroLog.set_Tela(38);
- registroLog.set_Versao(LoginViewModel.VersaoAtual);
- registroLog.set_NomeMaquina(Environment.MachineName);
- registroLog.set_UsuarioMaquina(Environment.UserName);
- IPAddress[] addressList = hostEntry.AddressList;
- Func<IPAddress, bool> u003cu003e9_22 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_2;
- if (u003cu003e9_22 == null)
- {
- u003cu003e9_22 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
- ProspeccaoServico.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22;
- }
- IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_22);
- if (pAddress != null)
- {
- str1 = pAddress.ToString();
- }
- else
- {
- str1 = null;
- }
- registroLog.set_Ip(str1);
- base.SaveLog(registroLog, commited);
- }
- RegistroLog registroLog1 = new RegistroLog();
- registroLog1.set_Acao(2);
- registroLog1.set_Usuario(Recursos.Usuario);
- registroLog1.set_DataHora(networkTime);
- Prospeccao prospeccao1 = prospeccao;
- JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings();
- jsonSerializerSetting1.set_ReferenceLoopHandling(1);
- registroLog1.set_Descricao(JsonConvert.SerializeObject(prospeccao1, jsonSerializerSetting1));
- registroLog1.set_EntidadeId(prospeccao.get_Id());
- registroLog1.set_Tela(33);
- registroLog1.set_Versao(LoginViewModel.VersaoAtual);
- registroLog1.set_NomeMaquina(Environment.MachineName);
- registroLog1.set_UsuarioMaquina(Environment.UserName);
- IPAddress[] pAddressArray = hostEntry.AddressList;
- Func<IPAddress, bool> u003cu003e9_23 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_3;
- if (u003cu003e9_23 == null)
- {
- u003cu003e9_23 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
- ProspeccaoServico.u003cu003ec.u003cu003e9__2_3 = u003cu003e9_23;
- }
- IPAddress pAddress1 = ((IEnumerable<IPAddress>)pAddressArray).FirstOrDefault<IPAddress>(u003cu003e9_23);
- if (pAddress1 != null)
- {
- str = pAddress1.ToString();
- }
- else
- {
- str = null;
- }
- registroLog1.set_Ip(str);
- base.SaveLog(registroLog1, commited);
- commited.Commit();
- }
- Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
- Action u003cu003e9_21 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_1;
- if (u003cu003e9_21 == null)
- {
- u003cu003e9_21 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
- ProspeccaoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
- }
- dispatcher.Invoke(u003cu003e9_21);
- flag = true;
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 260, num, prospeccao, true);
- continue;
- }
- return flag;
- }
- return false;
- });
- return flag1;
- }
-
- public async Task<Prospeccao> Salvar(Prospeccao prospecao)
- {
- int num = 3;
- base.Sucesso = true;
- Prospeccao prospeccao2 = prospecao;
- Prospeccao prospeccao3 = await Task.Run<Prospeccao>(() => {
- Prospeccao prospeccao;
- string str;
- while (num > 0)
- {
- prospecao = prospeccao2;
- try
- {
- using (UnitOfWork commited = Instancia.Commited)
- {
- DateTime networkTime = Funcoes.GetNetworkTime();
- TipoAcao tipoAcao = (prospecao.get_Id() == 0 ? 0 : 1);
- prospecao.set_IdEmpresa(Recursos.Usuario.get_IdEmpresa());
- if (!prospecao.get_DataCriacao().HasValue)
- {
- prospecao.set_DataCriacao(new DateTime?(networkTime));
- }
- if (prospecao.get_UsuarioCriacao() == 0)
- {
- prospecao.set_UsuarioCriacao(Recursos.Usuario.get_Id());
- }
- Tarefa tarefa = prospecao.get_Tarefa();
- tarefa = (!prospecao.get_CriarTarefa() ? null : (tarefa.get_Id() == 0 ? commited.get_TarefaRepository().Salvar(tarefa) : commited.get_TarefaRepository().Atualizar(tarefa)));
- prospecao.set_Tarefa(tarefa);
- prospecao = (prospecao.get_Id() == 0 ? commited.get_ProspectRepository().SaveOrUpdate(prospecao) : commited.get_ProspectRepository().Merge(prospecao));
- IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
- if (prospecao.get_Tarefa() != null)
- {
- prospecao.get_Tarefa().set_IdEntidade(prospecao.get_Id());
- prospecao.set_Tarefa(commited.get_TarefaRepository().Atualizar(prospecao.get_Tarefa()));
- }
- RegistroLog registroLog = new RegistroLog();
- registroLog.set_Acao(tipoAcao);
- registroLog.set_Usuario(Recursos.Usuario);
- registroLog.set_DataHora(networkTime);
- Prospeccao prospeccao1 = prospecao;
- JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
- jsonSerializerSetting.set_ReferenceLoopHandling(1);
- registroLog.set_Descricao(JsonConvert.SerializeObject(prospeccao1, jsonSerializerSetting));
- registroLog.set_EntidadeId(prospecao.get_Id());
- registroLog.set_Tela(33);
- registroLog.set_Versao(LoginViewModel.VersaoAtual);
- registroLog.set_NomeMaquina(Environment.MachineName);
- registroLog.set_UsuarioMaquina(Environment.UserName);
- IPAddress[] addressList = hostEntry.AddressList;
- Func<IPAddress, bool> u003cu003e9_12 = ProspeccaoServico.u003cu003ec.u003cu003e9__1_2;
- if (u003cu003e9_12 == null)
- {
- u003cu003e9_12 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
- ProspeccaoServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12;
- }
- IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_12);
- if (pAddress != null)
- {
- str = pAddress.ToString();
- }
- else
- {
- str = null;
- }
- registroLog.set_Ip(str);
- base.SaveLog(registroLog, commited);
- commited.Commit();
- Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
- Action u003cu003e9_11 = ProspeccaoServico.u003cu003ec.u003cu003e9__1_1;
- if (u003cu003e9_11 == null)
- {
- u003cu003e9_11 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
- ProspeccaoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
- }
- dispatcher.Invoke(u003cu003e9_11);
- prospeccao = prospecao;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 259, num, prospecao, true);
- continue;
- }
- return prospeccao;
- }
- return prospeccao2;
- });
- return prospeccao3;
- }
- }
-} \ No newline at end of file