diff options
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs | 1082 |
1 files changed, 1082 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs new file mode 100644 index 0000000..4b94129 --- /dev/null +++ b/Decompiler/Gestor.Application.Servicos.Seguros/ClienteServico.cs @@ -0,0 +1,1082 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +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.Relatorios.Classificacao; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Relatorios.Dashboard; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; + +namespace Gestor.Application.Servicos.Seguros; + +internal class ClienteServico : BaseServico +{ + internal async Task<List<Cliente>> BuscarCliente(string value, List<long> vinculos = null, TipoFiltroCliente tipoFiltroCliente = 2) + { + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_0027: Unknown result type (might be due to invalid IL or missing references) + value = ValidationHelper.RemoverAcentos(value.Trim()); + if (string.IsNullOrWhiteSpace(value)) + { + return new List<Cliente>(); + } + int tries = 3; + return await Task.Run(delegate + { + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + long num = ((Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + bool flag = LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3); + return (from x in read.ClienteRepository.FindClienteVinculo(value, vinculos, num, ((DomainBase)Recursos.Usuario).Id == 0, flag, tipoFiltroCliente) + orderby x.Nome + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)29, tries, value); + } + } + return new List<Cliente>(); + }); + } + + internal async Task<List<Cliente>> BuscarClientePorDocumento(string documento) + { + documento = ValidationHelper.RemoverAcentos(documento.Trim()).ToUpper(); + if (string.IsNullOrWhiteSpace(documento)) + { + return new List<Cliente>(); + } + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from c in read.ClienteRepository.FindClienteDocumento(documento) + orderby c.Nome + select c).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)29, tries, documento); + } + } + return new List<Cliente>(); + }); + } + + internal async Task<List<Cliente>> BuscarClienteVinculo(string value, long id) + { + if (string.IsNullOrWhiteSpace(value)) + { + return new List<Cliente>(); + } + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ClienteRepository.FindVinculo(value, id) + orderby x.Nome + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)29, tries, value); + } + } + return new List<Cliente>(); + }); + } + + internal async Task<Cliente> BuscarCliente(long id) + { + int tries = 3; + return await Task.Run((Func<Cliente>)delegate + { + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + Cliente obj = read.ClienteRepository.FindById(id); + obj.Nome = obj.Nome; + return obj; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)28, tries, id); + } + } + return new Cliente(); + }); + } + + internal async Task<ObservableCollection<ClienteTelefone>> BuscarTelefonesAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<ClienteTelefone>(from x in read.ClienteTelefoneRepository.FindByClienteId(id) + orderby x.Ordem + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)30, tries, id); + } + } + return new ObservableCollection<ClienteTelefone>(); + }); + } + + internal ObservableCollection<ClienteTelefone> BuscarTelefones(long id) + { + int num = 3; + while (num > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<ClienteTelefone>(from x in read.ClienteTelefoneRepository.FindByClienteId(id) + orderby x.Ordem + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + num = Registrar(e, (TipoErro)30, num, id); + } + } + return new ObservableCollection<ClienteTelefone>(); + } + + internal async Task<List<ClienteTelefone>> BuscarTelefonesClientes(string telefone) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteTelefoneRepository.Find(telefone, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)31, tries, telefone); + } + } + return new List<ClienteTelefone>(); + }); + } + + internal async Task<ObservableCollection<ClienteEmail>> BuscarEmailsAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<ClienteEmail>(from mail in read.ClienteEmailRepository.FindByClienteId(id) + orderby mail.Ordem + select mail); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)32, tries, id); + } + } + return new ObservableCollection<ClienteEmail>(); + }); + } + + internal async Task<ObservableCollection<ClienteVinculo>> BuscarVinculosAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<ClienteVinculo>(read.ClienteVinculoRepository.FindByCliente(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)33, tries, id); + } + } + return new ObservableCollection<ClienteVinculo>(); + }); + } + + internal async Task<ObservableCollection<ClienteEndereco>> BuscarEnderecosAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<ClienteEndereco>(from x in read.ClienteEnderecoRepository.FindByClienteId(id) + orderby x.Ordem + select x); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)34, tries, id); + } + } + return new ObservableCollection<ClienteEndereco>(); + }); + } + + internal async Task<ObservableCollection<MaisContato>> BuscarContatosAsync(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<MaisContato>(read.MaisContatoRepository.FindByCustomerId(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)35, tries, id); + } + } + return new ObservableCollection<MaisContato>(); + }); + } + + 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<Cliente> Save(Cliente cliente, bool salvando = false) + { + int tries = 3; + base.Sucesso = true; + Cliente clienteOriginal = cliente; + return await Task.Run((Func<Cliente>)delegate + { + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0160: Unknown result type (might be due to invalid IL or missing references) + //IL_0162: Invalid comparison between Unknown and I4 + //IL_015f: Unknown result type (might be due to invalid IL or missing references) + //IL_0536: Unknown result type (might be due to invalid IL or missing references) + while (tries > 0) + { + List<RegistroLog> logs = new List<RegistroLog>(); + cliente = clienteOriginal; + try + { + TipoAcao val = (TipoAcao)(((DomainBase)cliente).Id != 0L); + List<ClienteTelefone> list = cliente.Telefones?.ToList(); + List<ClienteEndereco> list2 = cliente.Enderecos?.ToList(); + List<MaisContato> list3 = cliente.Contatos?.ToList(); + List<ClienteEmail> list4 = cliente.Emails?.ToList(); + List<ClienteVinculo> list5 = cliente.Vinculos?.ToList(); + List<OrigemCliente> list6 = cliente.Origens; + cliente.Telefones = null; + cliente.Enderecos = null; + cliente.Contatos = null; + cliente.Emails = null; + cliente.Vinculos = null; + cliente.Contatos = null; + cliente.Origens = null; + UnitOfWork unitOfWork = Instancia.Commited; + try + { + bool flag = ((DomainBase)cliente).Id == 0; + if (((DomainBase)cliente).Id != 0 && salvando) + { + flag = true; + val = (TipoAcao)0; + } + if ((int)val == 1) + { + List<object> lista = new List<object> { list, list2, list3, list4, list5, cliente }; + logs.Add(CreateDynamicLog(((DomainBase)cliente).Id, lista, (TipoTela)1)); + unitOfWork.ClienteTelefoneRepository.DeleteFone(((DomainBase)cliente).Id, list)?.ForEach(delegate(ClienteTelefone fone) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)fone).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + }); + unitOfWork.ClienteEnderecoRepository.DeleteEndereco(((DomainBase)cliente).Id, list2)?.ForEach(delegate(ClienteEndereco endereco) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)endereco).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + }); + unitOfWork.MaisContatoRepository.DeleteContato(((DomainBase)cliente).Id, list3)?.ForEach(delegate(MaisContato contato) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)contato).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + }); + unitOfWork.ClienteEmailRepository.DeleteMail(((DomainBase)cliente).Id, list4)?.ForEach(delegate(ClienteEmail mail) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)mail).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + }); + unitOfWork.ClienteVinculoRepository.DeleteVinculo(((DomainBase)cliente).Id, list5)?.ForEach(delegate(ClienteVinculo vinculo) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)vinculo).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + }); + } + if (flag) + { + cliente = unitOfWork.ClienteRepository.SaveOrUpdate(cliente); + if (list != null) + { + list = unitOfWork.ClienteTelefoneRepository.Inserir(list, cliente); + } + if (list2 != null) + { + list2 = unitOfWork.ClienteEnderecoRepository.Inserir(list2, cliente); + } + if (list3 != null) + { + list3 = unitOfWork.MaisContatoRepository.Inserir(list3, cliente); + } + if (list4 != null) + { + list4 = unitOfWork.ClienteEmailRepository.Inserir(list4, cliente); + } + if (list5 != null) + { + list5 = unitOfWork.ClienteVinculoRepository.Inserir(list5, cliente); + } + list6?.ForEach(delegate(OrigemCliente x) + { + x.Cliente = cliente; + x = unitOfWork.ClienteRepository.SaveOrUpdate(x); + }); + } + else + { + if (list != null) + { + list = unitOfWork.ClienteTelefoneRepository.Merge(list, cliente); + } + if (list2 != null) + { + list2 = unitOfWork.ClienteEnderecoRepository.Merge(list2, cliente); + } + if (list3 != null) + { + list3 = unitOfWork.MaisContatoRepository.Merge(list3, cliente); + } + if (list4 != null) + { + list4 = unitOfWork.ClienteEmailRepository.Merge(list4, cliente); + } + if (list5 != null) + { + list5 = unitOfWork.ClienteVinculoRepository.Merge(list5, cliente); + } + list6 = unitOfWork.ClienteRepository.Sincronize(list6, ((DomainBase)cliente).Id); + cliente = unitOfWork.ClienteRepository.Merge(cliente); + } + cliente.Nome = cliente.Nome; + cliente.Telefones = ((list == null) ? null : new ObservableCollection<ClienteTelefone>(list)); + cliente.Enderecos = ((list2 == null) ? null : new ObservableCollection<ClienteEndereco>(list2)); + cliente.Contatos = ((list3 == null) ? null : new ObservableCollection<MaisContato>(list3)); + cliente.Emails = ((list4 == null) ? null : new ObservableCollection<ClienteEmail>(list4)); + cliente.Vinculos = ((list5 == null) ? null : new ObservableCollection<ClienteVinculo>(list5)); + cliente.Origens = list6; + if ((int)val == 0) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)cliente).GetValorOriginal(), (TipoTela)1, (TipoAcao)0)); + cliente.Telefones?.ToList().ForEach(delegate(ClienteTelefone fone) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)fone).GetValorOriginal(), (TipoTela)1, (TipoAcao)0)); + }); + cliente.Enderecos?.ToList().ForEach(delegate(ClienteEndereco endereco) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)endereco).GetValorOriginal(), (TipoTela)1, (TipoAcao)0)); + }); + cliente.Contatos?.ToList().ForEach(delegate(MaisContato contato) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)contato).GetValorOriginal(), (TipoTela)1, (TipoAcao)0)); + }); + cliente.Emails?.ToList().ForEach(delegate(ClienteEmail mail) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)mail).GetValorOriginal(), (TipoTela)1, (TipoAcao)0)); + }); + cliente.Vinculos?.ToList().ForEach(delegate(ClienteVinculo vinculo) + { + logs.Add(CreateLog(((DomainBase)cliente).Id, ((DomainBase)vinculo).GetValorOriginal(), (TipoTela)1, (TipoAcao)0)); + }); + } + SaveLog(logs, unitOfWork); + ((GenericUnitOfWork)unitOfWork).Commit(); + return cliente; + } + finally + { + if (unitOfWork != null) + { + ((IDisposable)unitOfWork).Dispose(); + } + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)171, tries, cliente); + } + } + return clienteOriginal; + }); + } + + public async Task<bool> Delete(Cliente cliente) + { + 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)cliente).Id, ((DomainBase)cliente).GetValorOriginal(), (TipoTela)1, (TipoAcao)2)); + commited.ClienteRepository.Merge(cliente); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + return true; + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)172, tries, cliente); + } + } + return false; + }); + } + + public async Task<List<ClientesAtivosInativos>> BuscarTodosClientes() + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return (from x in read.ClienteRepository.FindAllClientes(false, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa) + orderby x.Nome + select x).ToList(); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)36, tries); + } + } + return new List<ClientesAtivosInativos>(); + }); + } + + public async Task<IEnumerable<ClientesAtivosInativos>> BuscarClientesAtvosInativos(bool completo) + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ClienteRepository.BuscaClientes(completo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)286, tries); + } + } + return new List<ClientesAtivosInativos>(); + }); + } + + public async Task<Cliente> BuscarClienteAsync(long id) + { + int tries = 3; + return await Task.Run((Func<Cliente>)delegate + { + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Expected O, but got Unknown + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + Cliente obj = read.ClienteRepository.FindById(id); + obj.Nome = obj.Nome; + return obj; + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)27, tries); + } + } + return new Cliente(); + }); + } + + public async Task<List<ClienteEmail>> BuscarEmailsPorCliente(List<long> ids) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteEmailRepository.FindByCliente(ids); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)37, tries); + } + } + return new List<ClienteEmail>(); + }); + } + + public async Task<List<ClienteEndereco>> BuscarEnderecosPorCliente(List<Cliente> clientes) + { + int tries = 3; + if (clientes.All((Cliente x) => ((DomainBase)x).Id < 0)) + { + return new List<ClienteEndereco>(); + } + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteEnderecoRepository.FindByCliente(clientes); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)38, tries); + } + } + return new List<ClienteEndereco>(); + }); + } + + public async Task<List<Cliente>> BuscarObsCliente(string pesquisa) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.FindObsCliente(pesquisa, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)39, tries); + } + } + return new List<Cliente>(); + }); + } + + public async Task<List<Cliente>> BuscarPastaCliente(string pesquisa, bool busca) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.FindPastaCliente(pesquisa, busca, 0L); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)40, tries); + } + } + return new List<Cliente>(); + }); + } + + public async Task<List<ClientesAtivosInativos>> BuscarAniversariantes(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.BuscarAniversariantes(filtro, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)41, tries); + } + } + return new List<ClientesAtivosInativos>(); + }); + } + + public async Task<List<ClientesAtivosInativos>> BuscarVencimentosCnh(Filtros filtro) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.BuscarVencimentoCnh(filtro, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)42, tries); + } + } + return new List<ClientesAtivosInativos>(); + }); + } + + public async Task<List<Prospectar>> BuscarProspect(Filtros filtro) + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ClienteRepository.BuscaProspeccoes(filtro, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)324, tries); + } + } + return new List<Prospectar>(); + }); + } + + public async Task<string> SalvarObservacoes(long id, string observacao) + { + int tries = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + return await Task.Run(delegate + { + while (tries > 0) + { + List<RegistroLog> list = new List<RegistroLog>(); + try + { + UnitOfWork commited = Instancia.Commited; + try + { + Cliente val = commited.ClienteRepository.FindById(id); + ((DomainBase)val).Initialize(); + val.Observacao = observacao; + list.Add(CreateLog(((DomainBase)val).Id, val, (TipoTela)1)); + commited.ClienteRepository.Merge(val); + SaveLog(list, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + return observacao; + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)171, tries, new { id, observacao }); + } + } + return ""; + }); + } + + public async Task<ObservableCollection<OrigemCliente>> BuscarOrigens(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return new ObservableCollection<OrigemCliente>(read.ClienteRepository.BuscarOrigem(id)); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)326, tries, id); + } + } + return new ObservableCollection<OrigemCliente>(); + }); + } + + public async Task<string> BuscarLogAntigo(long id) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.BuscarLogAntigo(id, Connection.GetConnectionString()); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)319, tries, id); + } + } + return (string)null; + }); + } + + internal DateTime? BuscarNascimento(long id) + { + int num = 3; + while (num > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.BuscaNascimeto(id); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + num = Registrar(e, (TipoErro)328, num, id); + } + } + return null; + } + + public async Task<List<Classificacao>> BuscarClassificacoes() + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ClienteRepository.BuscarClassificacoes((Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)286, tries); + } + } + return new List<Classificacao>(); + }); + } + + public async Task<IEnumerable<ClientesAtivosInativos>> BuscarClientesAtvosInativosVinculo(bool completo, List<VendedorUsuario> vinculo) + { + int tries = 3; + return await Task.Run(async delegate + { + while (tries > 0) + { + try + { + UnitOfWork unitOfWork = Instancia.Read; + try + { + return await unitOfWork.ClienteRepository.BuscaClientesVinculo(completo, vinculo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)unitOfWork)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)286, tries); + } + } + return new List<ClientesAtivosInativos>(); + }); + } + + public async Task<List<ClientesAtivosInativos>> BuscarAniversariantesVinculo(Filtros filtro, List<VendedorUsuario> vinculo) + { + int tries = 3; + return await Task.Run(delegate + { + while (tries > 0) + { + try + { + UnitOfWork read = Instancia.Read; + try + { + return read.ClienteRepository.BuscarAniversariantesVinculo(filtro, vinculo, (Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa); + } + finally + { + ((IDisposable)read)?.Dispose(); + } + } + catch (Exception e) + { + tries = Registrar(e, (TipoErro)41, tries); + } + } + return new List<ClientesAtivosInativos>(); + }); + } +} |