diff options
Diffstat (limited to 'Gestor.Application/Servicos/Seguros/ClienteServico.cs')
| -rw-r--r-- | Gestor.Application/Servicos/Seguros/ClienteServico.cs | 1194 |
1 files changed, 0 insertions, 1194 deletions
diff --git a/Gestor.Application/Servicos/Seguros/ClienteServico.cs b/Gestor.Application/Servicos/Seguros/ClienteServico.cs deleted file mode 100644 index db5c9d2..0000000 --- a/Gestor.Application/Servicos/Seguros/ClienteServico.cs +++ /dev/null @@ -1,1194 +0,0 @@ -using Gestor.Application.Helpers;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Common.Validation;
-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.Relatorios.Classificacao;
-using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos;
-using Gestor.Model.Domain.Relatorios.Dashboard;
-using Gestor.Model.Domain.Seguros;
-using Gestor.Model.License;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-
-namespace Gestor.Application.Servicos.Seguros
-{
- internal class ClienteServico : BaseServico
- {
- public ClienteServico()
- {
- }
-
- public async Task AddCentralSegurado(long id, bool update = true)
- {
- await Task.Run(() => {
- using (UnitOfWork commited = Instancia.Commited)
- {
- commited.get_ClienteRepository().AddCentralSegurado(id, update);
- }
- });
- }
-
- public async Task<List<ClientesAtivosInativos>> BuscarAniversariantes(Filtros filtro)
- {
- int num = 3;
- List<ClientesAtivosInativos> clientesAtivosInativos1 = await Task.Run<List<ClientesAtivosInativos>>(() => {
- List<ClientesAtivosInativos> clientesAtivosInativos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientesAtivosInativos = read.get_ClienteRepository().BuscarAniversariantes(filtro, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 41, num, null, true);
- continue;
- }
- return clientesAtivosInativos;
- }
- return new List<ClientesAtivosInativos>();
- });
- return clientesAtivosInativos1;
- }
-
- public async Task<List<ClientesAtivosInativos>> BuscarAniversariantesVinculo(Filtros filtro, List<VendedorUsuario> vinculo)
- {
- int num = 3;
- List<ClientesAtivosInativos> clientesAtivosInativos1 = await Task.Run<List<ClientesAtivosInativos>>(() => {
- List<ClientesAtivosInativos> clientesAtivosInativos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientesAtivosInativos = read.get_ClienteRepository().BuscarAniversariantesVinculo(filtro, vinculo, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 41, num, null, true);
- continue;
- }
- return clientesAtivosInativos;
- }
- return new List<ClientesAtivosInativos>();
- });
- return clientesAtivosInativos1;
- }
-
- public async Task<List<Classificacao>> BuscarClassificacoes()
- {
- int num = 3;
- List<Classificacao> classificacaos1 = await Task.Run<List<Classificacao>>(async () => {
- List<Classificacao> classificacaos;
- while (true)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- classificacaos = await read.get_ClienteRepository().BuscarClassificacoes((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- return classificacaos;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 286, num, null, true);
- }
- if (num <= 0)
- {
- break;
- }
- }
- classificacaos = new List<Classificacao>();
- return classificacaos;
- });
- return classificacaos1;
- }
-
- internal async Task<List<Cliente>> BuscarCliente(string value, List<long> vinculos = null, TipoFiltroCliente tipoFiltroCliente = 2)
- {
- List<Cliente> clientes1;
- string str = value;
- str = ValidationHelper.RemoverAcentos(str.Trim());
- if (!string.IsNullOrWhiteSpace(str))
- {
- int num1 = 3;
- clientes1 = await Task.Run<List<Cliente>>(() => {
- List<Cliente> list;
- while (num1 > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- long num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa());
- List<Licenca> produtos = LicenseHelper.Produtos;
- Func<Licenca, bool> u003cu003e9_01 = ClienteServico.u003cu003ec.u003cu003e9__0_1;
- if (u003cu003e9_01 == null)
- {
- u003cu003e9_01 = (Licenca x) => {
- if (x.get_Produto() != 86)
- {
- return false;
- }
- return x.get_Status() != 3;
- };
- ClienteServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
- }
- bool flag = produtos.Any<Licenca>(u003cu003e9_01);
- List<Cliente> clientes = read.get_ClienteRepository().FindClienteVinculo(str, vinculos, num, Recursos.Usuario.get_Id() == (long)0, flag, tipoFiltroCliente);
- Func<Cliente, string> u003cu003e9_02 = ClienteServico.u003cu003ec.u003cu003e9__0_2;
- if (u003cu003e9_02 == null)
- {
- u003cu003e9_02 = (Cliente x) => x.get_Nome();
- ClienteServico.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02;
- }
- list = clientes.OrderBy<Cliente, string>(u003cu003e9_02).ToList<Cliente>();
- }
- }
- catch (Exception exception)
- {
- num1 = base.Registrar(exception, 29, num1, str, true);
- continue;
- }
- return list;
- }
- return new List<Cliente>();
- });
- }
- else
- {
- clientes1 = new List<Cliente>();
- }
- return clientes1;
- }
-
- internal async Task<Cliente> BuscarCliente(long id)
- {
- int num = 3;
- Cliente cliente2 = await Task.Run<Cliente>(() => {
- Cliente cliente;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- Cliente cliente1 = read.get_ClienteRepository().FindById(id);
- cliente1.set_Nome(cliente1.get_Nome());
- cliente = cliente1;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 28, num, id, true);
- continue;
- }
- return cliente;
- }
- return new Cliente();
- });
- return cliente2;
- }
-
- public async Task<Cliente> BuscarClienteAsync(long id)
- {
- int num = 3;
- Cliente cliente2 = await Task.Run<Cliente>(() => {
- Cliente cliente;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- Cliente cliente1 = read.get_ClienteRepository().FindById(id);
- cliente1.set_Nome(cliente1.get_Nome());
- cliente = cliente1;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 27, num, null, true);
- continue;
- }
- return cliente;
- }
- return new Cliente();
- });
- return cliente2;
- }
-
- internal async Task<List<Cliente>> BuscarClientePorDocumento(string documento)
- {
- List<Cliente> clientes1;
- string upper = documento;
- upper = ValidationHelper.RemoverAcentos(upper.Trim()).ToUpper();
- if (!string.IsNullOrWhiteSpace(upper))
- {
- int num = 3;
- clientes1 = await Task.Run<List<Cliente>>(() => {
- List<Cliente> list;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- List<Cliente> clientes = read.get_ClienteRepository().FindClienteDocumento(upper);
- Func<Cliente, string> u003cu003e9_11 = ClienteServico.u003cu003ec.u003cu003e9__1_1;
- if (u003cu003e9_11 == null)
- {
- u003cu003e9_11 = (Cliente c) => c.get_Nome();
- ClienteServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
- }
- list = clientes.OrderBy<Cliente, string>(u003cu003e9_11).ToList<Cliente>();
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 29, num, upper, true);
- continue;
- }
- return list;
- }
- return new List<Cliente>();
- });
- }
- else
- {
- clientes1 = new List<Cliente>();
- }
- return clientes1;
- }
-
- public async Task<IEnumerable<ClientesAtivosInativos>> BuscarClientesAtvosInativos(bool completo)
- {
- int num = 3;
- IEnumerable<ClientesAtivosInativos> clientesAtivosInativos1 = await Task.Run<IEnumerable<ClientesAtivosInativos>>(async () => {
- IEnumerable<ClientesAtivosInativos> clientesAtivosInativos;
- while (true)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientesAtivosInativos = await read.get_ClienteRepository().BuscaClientes(completo, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- return clientesAtivosInativos;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 286, num, null, true);
- }
- if (num <= 0)
- {
- break;
- }
- }
- clientesAtivosInativos = new List<ClientesAtivosInativos>();
- return clientesAtivosInativos;
- });
- return clientesAtivosInativos1;
- }
-
- public async Task<IEnumerable<ClientesAtivosInativos>> BuscarClientesAtvosInativosVinculo(bool completo, List<VendedorUsuario> vinculo)
- {
- int num = 3;
- IEnumerable<ClientesAtivosInativos> clientesAtivosInativos1 = await Task.Run<IEnumerable<ClientesAtivosInativos>>(async () => {
- IEnumerable<ClientesAtivosInativos> clientesAtivosInativos;
- while (true)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientesAtivosInativos = await read.get_ClienteRepository().BuscaClientesVinculo(completo, vinculo, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- return clientesAtivosInativos;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 286, num, null, true);
- }
- if (num <= 0)
- {
- break;
- }
- }
- clientesAtivosInativos = new List<ClientesAtivosInativos>();
- return clientesAtivosInativos;
- });
- return clientesAtivosInativos1;
- }
-
- internal async Task<List<Cliente>> BuscarClienteVinculo(string value, long id)
- {
- List<Cliente> clientes1;
- if (!string.IsNullOrWhiteSpace(value))
- {
- int num = 3;
- clientes1 = await Task.Run<List<Cliente>>(() => {
- List<Cliente> list;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- List<Cliente> clientes = read.get_ClienteRepository().FindVinculo(value, id);
- Func<Cliente, string> u003cu003e9_21 = ClienteServico.u003cu003ec.u003cu003e9__2_1;
- if (u003cu003e9_21 == null)
- {
- u003cu003e9_21 = (Cliente x) => x.get_Nome();
- ClienteServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
- }
- list = clientes.OrderBy<Cliente, string>(u003cu003e9_21).ToList<Cliente>();
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 29, num, value, true);
- continue;
- }
- return list;
- }
- return new List<Cliente>();
- });
- }
- else
- {
- clientes1 = new List<Cliente>();
- }
- return clientes1;
- }
-
- internal async Task<ObservableCollection<MaisContato>> BuscarContatosAsync(long id)
- {
- int num = 3;
- ObservableCollection<MaisContato> observableCollection1 = await Task.Run<ObservableCollection<MaisContato>>(() => {
- ObservableCollection<MaisContato> observableCollection;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- observableCollection = new ObservableCollection<MaisContato>(read.get_MaisContatoRepository().FindByCustomerId(id));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 35, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<MaisContato>();
- });
- return observableCollection1;
- }
-
- internal async Task<ObservableCollection<ClienteEmail>> BuscarEmailsAsync(long id)
- {
- int num = 3;
- ObservableCollection<ClienteEmail> observableCollection1 = await Task.Run<ObservableCollection<ClienteEmail>>(() => {
- ObservableCollection<ClienteEmail> observableCollection;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- List<ClienteEmail> clienteEmails = read.get_ClienteEmailRepository().FindByClienteId(id);
- Func<ClienteEmail, int?> u003cu003e9_71 = ClienteServico.u003cu003ec.u003cu003e9__7_1;
- if (u003cu003e9_71 == null)
- {
- u003cu003e9_71 = (ClienteEmail mail) => mail.get_Ordem();
- ClienteServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71;
- }
- observableCollection = new ObservableCollection<ClienteEmail>(clienteEmails.OrderBy<ClienteEmail, int?>(u003cu003e9_71));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 32, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<ClienteEmail>();
- });
- return observableCollection1;
- }
-
- public async Task<List<ClienteEmail>> BuscarEmailsPorCliente(List<long> ids)
- {
- int num = 3;
- List<ClienteEmail> clienteEmails1 = await Task.Run<List<ClienteEmail>>(() => {
- List<ClienteEmail> clienteEmails;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clienteEmails = read.get_ClienteEmailRepository().FindByCliente(ids);
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 37, num, null, true);
- continue;
- }
- return clienteEmails;
- }
- return new List<ClienteEmail>();
- });
- return clienteEmails1;
- }
-
- internal async Task<ObservableCollection<ClienteEndereco>> BuscarEnderecosAsync(long id)
- {
- int num = 3;
- ObservableCollection<ClienteEndereco> observableCollection1 = await Task.Run<ObservableCollection<ClienteEndereco>>(() => {
- ObservableCollection<ClienteEndereco> observableCollection;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- List<ClienteEndereco> clienteEnderecos = read.get_ClienteEnderecoRepository().FindByClienteId(id);
- Func<ClienteEndereco, int?> u003cu003e9_91 = ClienteServico.u003cu003ec.u003cu003e9__9_1;
- if (u003cu003e9_91 == null)
- {
- u003cu003e9_91 = (ClienteEndereco x) => x.get_Ordem();
- ClienteServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91;
- }
- observableCollection = new ObservableCollection<ClienteEndereco>(clienteEnderecos.OrderBy<ClienteEndereco, int?>(u003cu003e9_91));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 34, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<ClienteEndereco>();
- });
- return observableCollection1;
- }
-
- public async Task<List<ClienteEndereco>> BuscarEnderecosPorCliente(List<Cliente> clientes)
- {
- List<ClienteEndereco> clienteEnderecos1;
- int num = 3;
- List<Cliente> clientes1 = clientes;
- if (!clientes1.All<Cliente>((Cliente x) => x.get_Id() < (long)0))
- {
- clienteEnderecos1 = await Task.Run<List<ClienteEndereco>>(() => {
- List<ClienteEndereco> clienteEnderecos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clienteEnderecos = read.get_ClienteEnderecoRepository().FindByCliente(clientes);
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 38, num, null, true);
- continue;
- }
- return clienteEnderecos;
- }
- return new List<ClienteEndereco>();
- });
- }
- else
- {
- clienteEnderecos1 = new List<ClienteEndereco>();
- }
- return clienteEnderecos1;
- }
-
- public async Task<string> BuscarLogAntigo(long id)
- {
- int num = 3;
- string str1 = await Task.Run<string>(() => {
- string str;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- str = read.get_ClienteRepository().BuscarLogAntigo(id, Connection.GetConnectionString());
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 319, num, id, true);
- continue;
- }
- return str;
- }
- return null;
- });
- return str1;
- }
-
- internal DateTime? BuscarNascimento(long id)
- {
- DateTime? nullable;
- int num = 3;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- nullable = read.get_ClienteRepository().BuscaNascimeto(id);
- }
- }
- catch (Exception exception1)
- {
- Exception exception = exception1;
- num = base.Registrar(exception, 328, num, id, true);
- continue;
- }
- return nullable;
- }
- return null;
- }
-
- public async Task<List<Cliente>> BuscarObsCliente(string pesquisa)
- {
- int num = 3;
- List<Cliente> clientes1 = await Task.Run<List<Cliente>>(() => {
- List<Cliente> clientes;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientes = read.get_ClienteRepository().FindObsCliente(pesquisa, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 39, num, null, true);
- continue;
- }
- return clientes;
- }
- return new List<Cliente>();
- });
- return clientes1;
- }
-
- public async Task<ObservableCollection<OrigemCliente>> BuscarOrigens(long id)
- {
- int num = 3;
- ObservableCollection<OrigemCliente> observableCollection1 = await Task.Run<ObservableCollection<OrigemCliente>>(() => {
- ObservableCollection<OrigemCliente> observableCollection;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- observableCollection = new ObservableCollection<OrigemCliente>(read.get_ClienteRepository().BuscarOrigem(id));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 326, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<OrigemCliente>();
- });
- return observableCollection1;
- }
-
- public async Task<List<Cliente>> BuscarPastaCliente(string pesquisa, bool busca)
- {
- int num = 3;
- List<Cliente> clientes1 = await Task.Run<List<Cliente>>(() => {
- List<Cliente> clientes;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientes = read.get_ClienteRepository().FindPastaCliente(pesquisa, busca, (long)0);
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 40, num, null, true);
- continue;
- }
- return clientes;
- }
- return new List<Cliente>();
- });
- return clientes1;
- }
-
- public async Task<List<Prospectar>> BuscarProspect(Filtros filtro)
- {
- int num = 3;
- List<Prospectar> prospectars1 = await Task.Run<List<Prospectar>>(async () => {
- List<Prospectar> prospectars;
- while (true)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- prospectars = await read.get_ClienteRepository().BuscaProspeccoes(filtro, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- return prospectars;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 324, num, null, true);
- }
- if (num <= 0)
- {
- break;
- }
- }
- prospectars = new List<Prospectar>();
- return prospectars;
- });
- return prospectars1;
- }
-
- internal ObservableCollection<ClienteTelefone> BuscarTelefones(long id)
- {
- ObservableCollection<ClienteTelefone> observableCollection;
- int num = 3;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- observableCollection = new ObservableCollection<ClienteTelefone>(
- from x in read.get_ClienteTelefoneRepository().FindByClienteId(id)
- orderby x.get_Ordem()
- select x);
- }
- }
- catch (Exception exception1)
- {
- Exception exception = exception1;
- num = base.Registrar(exception, 30, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<ClienteTelefone>();
- }
-
- internal async Task<ObservableCollection<ClienteTelefone>> BuscarTelefonesAsync(long id)
- {
- int num = 3;
- ObservableCollection<ClienteTelefone> observableCollection1 = await Task.Run<ObservableCollection<ClienteTelefone>>(() => {
- ObservableCollection<ClienteTelefone> observableCollection;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- List<ClienteTelefone> clienteTelefones = read.get_ClienteTelefoneRepository().FindByClienteId(id);
- Func<ClienteTelefone, int?> u003cu003e9_41 = ClienteServico.u003cu003ec.u003cu003e9__4_1;
- if (u003cu003e9_41 == null)
- {
- u003cu003e9_41 = (ClienteTelefone x) => x.get_Ordem();
- ClienteServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
- }
- observableCollection = new ObservableCollection<ClienteTelefone>(clienteTelefones.OrderBy<ClienteTelefone, int?>(u003cu003e9_41));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 30, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<ClienteTelefone>();
- });
- return observableCollection1;
- }
-
- internal async Task<List<ClienteTelefone>> BuscarTelefonesClientes(string telefone)
- {
- int num = 3;
- List<ClienteTelefone> clienteTelefones1 = await Task.Run<List<ClienteTelefone>>(() => {
- List<ClienteTelefone> clienteTelefones;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clienteTelefones = read.get_ClienteTelefoneRepository().Find(telefone, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 31, num, telefone, true);
- continue;
- }
- return clienteTelefones;
- }
- return new List<ClienteTelefone>();
- });
- return clienteTelefones1;
- }
-
- public async Task<List<ClientesAtivosInativos>> BuscarTodosClientes()
- {
- int num = 3;
- List<ClientesAtivosInativos> clientesAtivosInativos1 = await Task.Run<List<ClientesAtivosInativos>>(() => {
- List<ClientesAtivosInativos> list;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- List<ClientesAtivosInativos> clientesAtivosInativos = read.get_ClienteRepository().FindAllClientes(false, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- Func<ClientesAtivosInativos, string> u003cu003e9_141 = ClienteServico.u003cu003ec.u003cu003e9__14_1;
- if (u003cu003e9_141 == null)
- {
- u003cu003e9_141 = (ClientesAtivosInativos x) => x.get_Nome();
- ClienteServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141;
- }
- list = clientesAtivosInativos.OrderBy<ClientesAtivosInativos, string>(u003cu003e9_141).ToList<ClientesAtivosInativos>();
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 36, num, null, true);
- continue;
- }
- return list;
- }
- return new List<ClientesAtivosInativos>();
- });
- return clientesAtivosInativos1;
- }
-
- public async Task<List<ClientesAtivosInativos>> BuscarVencimentosCnh(Filtros filtro)
- {
- int num = 3;
- List<ClientesAtivosInativos> clientesAtivosInativos1 = await Task.Run<List<ClientesAtivosInativos>>(() => {
- List<ClientesAtivosInativos> clientesAtivosInativos;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- clientesAtivosInativos = read.get_ClienteRepository().BuscarVencimentoCnh(filtro, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 42, num, null, true);
- continue;
- }
- return clientesAtivosInativos;
- }
- return new List<ClientesAtivosInativos>();
- });
- return clientesAtivosInativos1;
- }
-
- internal async Task<ObservableCollection<ClienteVinculo>> BuscarVinculosAsync(long id)
- {
- int num = 3;
- ObservableCollection<ClienteVinculo> observableCollection1 = await Task.Run<ObservableCollection<ClienteVinculo>>(() => {
- ObservableCollection<ClienteVinculo> observableCollection;
- while (num > 0)
- {
- try
- {
- using (UnitOfWork read = Instancia.Read)
- {
- observableCollection = new ObservableCollection<ClienteVinculo>(read.get_ClienteVinculoRepository().FindByCliente(id));
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 33, num, id, true);
- continue;
- }
- return observableCollection;
- }
- return new ObservableCollection<ClienteVinculo>();
- });
- return observableCollection1;
- }
-
- public async Task<bool> Delete(Cliente cliente)
- {
- int num = 3;
- bool flag1 = await Task.Run<bool>(() => {
- bool flag;
- while (num > 0)
- {
- List<RegistroLog> registroLogs = new List<RegistroLog>();
- try
- {
- using (UnitOfWork commited = Instancia.Commited)
- {
- registroLogs.Add(base.CreateLog(cliente.get_Id(), cliente.GetValorOriginal(), 1, 2));
- commited.get_ClienteRepository().Merge(cliente);
- base.SaveLog(registroLogs, commited);
- commited.Commit();
- flag = true;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 172, num, cliente, true);
- continue;
- }
- return flag;
- }
- return false;
- });
- return flag1;
- }
-
- public async Task<string> SalvarObservacoes(long id, string observacao)
- {
- int num = 3;
- base.Sucesso = true;
- Funcoes.GetNetworkTime();
- string str1 = await Task.Run<string>(() => {
- string str;
- while (num > 0)
- {
- List<RegistroLog> registroLogs = new List<RegistroLog>();
- try
- {
- using (UnitOfWork commited = Instancia.Commited)
- {
- Cliente cliente = commited.get_ClienteRepository().FindById(id);
- cliente.Initialize();
- cliente.set_Observacao(observacao);
- registroLogs.Add(base.CreateLog(cliente.get_Id(), cliente, 1));
- commited.get_ClienteRepository().Merge(cliente);
- base.SaveLog(registroLogs, commited);
- commited.Commit();
- }
- str = observacao;
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 171, num, new { id = id, observacao = observacao }, true);
- continue;
- }
- return str;
- }
- return "";
- });
- return str1;
- }
-
- public async Task<Cliente> Save(Cliente cliente, bool salvando = false)
- {
- int num = 3;
- base.Sucesso = true;
- Cliente cliente1 = cliente;
- Cliente cliente2 = await Task.Run<Cliente>(() => {
- Cliente cliente3;
- List<ClienteTelefone> list;
- List<ClienteEndereco> clienteEnderecos;
- List<MaisContato> maisContatos;
- List<ClienteEmail> clienteEmails;
- List<ClienteVinculo> clienteVinculos;
- while (num > 0)
- {
- List<RegistroLog> registroLogs = new List<RegistroLog>();
- cliente = cliente1;
- try
- {
- TipoAcao tipoAcao = (cliente.get_Id() == 0 ? 0 : 1);
- ObservableCollection<ClienteTelefone> telefones = cliente.get_Telefones();
- if (telefones != null)
- {
- list = telefones.ToList<ClienteTelefone>();
- }
- else
- {
- list = null;
- }
- List<ClienteTelefone> clienteTelefones = list;
- ObservableCollection<ClienteEndereco> enderecos = cliente.get_Enderecos();
- if (enderecos != null)
- {
- clienteEnderecos = enderecos.ToList<ClienteEndereco>();
- }
- else
- {
- clienteEnderecos = null;
- }
- List<ClienteEndereco> clienteEnderecos1 = clienteEnderecos;
- ObservableCollection<MaisContato> contatos = cliente.get_Contatos();
- if (contatos != null)
- {
- maisContatos = contatos.ToList<MaisContato>();
- }
- else
- {
- maisContatos = null;
- }
- List<MaisContato> maisContatos1 = maisContatos;
- ObservableCollection<ClienteEmail> emails = cliente.get_Emails();
- if (emails != null)
- {
- clienteEmails = emails.ToList<ClienteEmail>();
- }
- else
- {
- clienteEmails = null;
- }
- List<ClienteEmail> clienteEmails1 = clienteEmails;
- ObservableCollection<ClienteVinculo> vinculos = cliente.get_Vinculos();
- if (vinculos != null)
- {
- clienteVinculos = vinculos.ToList<ClienteVinculo>();
- }
- else
- {
- clienteVinculos = null;
- }
- List<ClienteVinculo> clienteVinculos1 = clienteVinculos;
- List<OrigemCliente> origens = cliente.get_Origens();
- cliente.set_Telefones(null);
- cliente.set_Enderecos(null);
- cliente.set_Contatos(null);
- cliente.set_Emails(null);
- cliente.set_Vinculos(null);
- cliente.set_Contatos(null);
- cliente.set_Origens(null);
- using (UnitOfWork commited = Instancia.Commited)
- {
- bool id = cliente.get_Id() == (long)0;
- if (cliente.get_Id() != (long)0 & salvando)
- {
- id = true;
- tipoAcao = 0;
- }
- if (tipoAcao == 1)
- {
- List<object> objs = new List<object>()
- {
- clienteTelefones,
- clienteEnderecos1,
- maisContatos1,
- clienteEmails1,
- clienteVinculos1,
- cliente
- };
- registroLogs.Add(base.CreateDynamicLog(cliente.get_Id(), objs, 1));
- List<ClienteTelefone> clienteTelefones1 = commited.get_ClienteTelefoneRepository().DeleteFone(cliente.get_Id(), clienteTelefones);
- if (clienteTelefones1 != null)
- {
- clienteTelefones1.ForEach((ClienteTelefone fone) => this.logs.Add(base.CreateLog(cliente.get_Id(), fone.GetValorOriginal(), 1, 2)));
- }
- else
- {
- }
- List<ClienteEndereco> clienteEnderecos2 = commited.get_ClienteEnderecoRepository().DeleteEndereco(cliente.get_Id(), clienteEnderecos1);
- if (clienteEnderecos2 != null)
- {
- clienteEnderecos2.ForEach((ClienteEndereco endereco) => this.logs.Add(base.CreateLog(cliente.get_Id(), endereco.GetValorOriginal(), 1, 2)));
- }
- else
- {
- }
- List<MaisContato> maisContatos2 = commited.get_MaisContatoRepository().DeleteContato(cliente.get_Id(), maisContatos1);
- if (maisContatos2 != null)
- {
- maisContatos2.ForEach((MaisContato contato) => this.logs.Add(base.CreateLog(cliente.get_Id(), contato.GetValorOriginal(), 1, 2)));
- }
- else
- {
- }
- List<ClienteEmail> clienteEmails2 = commited.get_ClienteEmailRepository().DeleteMail(cliente.get_Id(), clienteEmails1);
- if (clienteEmails2 != null)
- {
- clienteEmails2.ForEach((ClienteEmail mail) => this.logs.Add(base.CreateLog(cliente.get_Id(), mail.GetValorOriginal(), 1, 2)));
- }
- else
- {
- }
- List<ClienteVinculo> clienteVinculos2 = commited.get_ClienteVinculoRepository().DeleteVinculo(cliente.get_Id(), clienteVinculos1);
- if (clienteVinculos2 != null)
- {
- clienteVinculos2.ForEach((ClienteVinculo vinculo) => this.logs.Add(base.CreateLog(cliente.get_Id(), vinculo.GetValorOriginal(), 1, 2)));
- }
- else
- {
- }
- }
- if (!id)
- {
- if (clienteTelefones != null)
- {
- clienteTelefones = commited.get_ClienteTelefoneRepository().Merge(clienteTelefones, cliente);
- }
- if (clienteEnderecos1 != null)
- {
- clienteEnderecos1 = commited.get_ClienteEnderecoRepository().Merge(clienteEnderecos1, cliente);
- }
- if (maisContatos1 != null)
- {
- maisContatos1 = commited.get_MaisContatoRepository().Merge(maisContatos1, cliente);
- }
- if (clienteEmails1 != null)
- {
- clienteEmails1 = commited.get_ClienteEmailRepository().Merge(clienteEmails1, cliente);
- }
- if (clienteVinculos1 != null)
- {
- clienteVinculos1 = commited.get_ClienteVinculoRepository().Merge(clienteVinculos1, cliente);
- }
- origens = commited.get_ClienteRepository().Sincronize(origens, cliente.get_Id());
- cliente = commited.get_ClienteRepository().Merge(cliente);
- }
- else
- {
- cliente = commited.get_ClienteRepository().SaveOrUpdate(cliente);
- if (clienteTelefones != null)
- {
- clienteTelefones = commited.get_ClienteTelefoneRepository().Inserir(clienteTelefones, cliente);
- }
- if (clienteEnderecos1 != null)
- {
- clienteEnderecos1 = commited.get_ClienteEnderecoRepository().Inserir(clienteEnderecos1, cliente);
- }
- if (maisContatos1 != null)
- {
- maisContatos1 = commited.get_MaisContatoRepository().Inserir(maisContatos1, cliente);
- }
- if (clienteEmails1 != null)
- {
- clienteEmails1 = commited.get_ClienteEmailRepository().Inserir(clienteEmails1, cliente);
- }
- if (clienteVinculos1 != null)
- {
- clienteVinculos1 = commited.get_ClienteVinculoRepository().Inserir(clienteVinculos1, cliente);
- }
- if (origens != null)
- {
- origens.ForEach((OrigemCliente x) => {
- x.set_Cliente(cliente);
- x = commited.get_ClienteRepository().SaveOrUpdate(x);
- });
- }
- }
- cliente.set_Nome(cliente.get_Nome());
- cliente.set_Telefones((clienteTelefones == null ? null : new ObservableCollection<ClienteTelefone>(clienteTelefones)));
- cliente.set_Enderecos((clienteEnderecos1 == null ? null : new ObservableCollection<ClienteEndereco>(clienteEnderecos1)));
- cliente.set_Contatos((maisContatos1 == null ? null : new ObservableCollection<MaisContato>(maisContatos1)));
- cliente.set_Emails((clienteEmails1 == null ? null : new ObservableCollection<ClienteEmail>(clienteEmails1)));
- cliente.set_Vinculos((clienteVinculos1 == null ? null : new ObservableCollection<ClienteVinculo>(clienteVinculos1)));
- cliente.set_Origens(origens);
- if (tipoAcao == null)
- {
- registroLogs.Add(base.CreateLog(cliente.get_Id(), cliente.GetValorOriginal(), 1, 0));
- ObservableCollection<ClienteTelefone> observableCollection = cliente.get_Telefones();
- if (observableCollection != null)
- {
- observableCollection.ToList<ClienteTelefone>().ForEach((ClienteTelefone fone) => this.logs.Add(base.CreateLog(cliente.get_Id(), fone.GetValorOriginal(), 1, 0)));
- }
- else
- {
- }
- ObservableCollection<ClienteEndereco> enderecos1 = cliente.get_Enderecos();
- if (enderecos1 != null)
- {
- enderecos1.ToList<ClienteEndereco>().ForEach((ClienteEndereco endereco) => this.logs.Add(base.CreateLog(cliente.get_Id(), endereco.GetValorOriginal(), 1, 0)));
- }
- else
- {
- }
- ObservableCollection<MaisContato> contatos1 = cliente.get_Contatos();
- if (contatos1 != null)
- {
- contatos1.ToList<MaisContato>().ForEach((MaisContato contato) => this.logs.Add(base.CreateLog(cliente.get_Id(), contato.GetValorOriginal(), 1, 0)));
- }
- else
- {
- }
- ObservableCollection<ClienteEmail> emails1 = cliente.get_Emails();
- if (emails1 != null)
- {
- emails1.ToList<ClienteEmail>().ForEach((ClienteEmail mail) => this.logs.Add(base.CreateLog(cliente.get_Id(), mail.GetValorOriginal(), 1, 0)));
- }
- else
- {
- }
- ObservableCollection<ClienteVinculo> vinculos1 = cliente.get_Vinculos();
- if (vinculos1 != null)
- {
- vinculos1.ToList<ClienteVinculo>().ForEach((ClienteVinculo vinculo) => this.logs.Add(base.CreateLog(cliente.get_Id(), vinculo.GetValorOriginal(), 1, 0)));
- }
- else
- {
- }
- }
- base.SaveLog(registroLogs, commited);
- commited.Commit();
- cliente3 = cliente;
- }
- }
- catch (Exception exception)
- {
- num = base.Registrar(exception, 171, num, cliente, true);
- continue;
- }
- return cliente3;
- }
- return cliente1;
- });
- return cliente2;
- }
- }
-}
\ No newline at end of file |