diff options
Diffstat (limited to 'Codemerx/Gestor.Application/Servicos/Seguros')
17 files changed, 7634 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs new file mode 100644 index 0000000..0aae6a5 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ApoliceServico.cs @@ -0,0 +1,1848 @@ +using CsQuery.ExtensionMethods;
+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.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Relatorios.Fechamento;
+using Gestor.Model.Domain.Relatorios.Tarefa;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.License;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class ApoliceServico : BaseServico
+ {
+ private bool _carregando;
+
+ public ApoliceServico()
+ {
+ }
+
+ public async Task<bool> AtualizarNumero(long id, string numero, string endosso, int tipoDocumento)
+ {
+ bool flag2 = await Task.Run<bool>(() => {
+ bool flag;
+ try
+ {
+ bool flag1 = true;
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag1 = commited.get_DocumentoRepository().AtualizarNumero(id, numero, endosso, tipoDocumento);
+ commited.Commit();
+ }
+ flag = flag1;
+ }
+ catch (Exception exception)
+ {
+ flag = false;
+ }
+ return flag;
+ });
+ return flag2;
+ }
+
+ public async Task<List<Documento>> Auditoria(Filtros filtro)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().Auditoria(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 13, num, filtro, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<bool> BaixarParcelasCancelamento(Documento documento, bool estorno)
+ {
+ int num1 = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str1;
+ Action<VendedorParcela> action3 = null;
+ Action<VendedorParcela> action4 = null;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()).ToList<Parcela>().ForEach((Parcela x) => {
+ Action<VendedorParcela> action;
+ List<VendedorParcela> vendedorParcelas = commited.get_VendedorParcelaRepository().FindByParcela(x.get_Id());
+ if (vendedorParcelas.Count > 0)
+ {
+ if (!estorno)
+ {
+ List<VendedorParcela> vendedorParcelas1 = vendedorParcelas;
+ Func<VendedorParcela, bool> u003cu003e9_302 = ApoliceServico.u003cu003ec.u003cu003e9__30_2;
+ if (u003cu003e9_302 == null)
+ {
+ u003cu003e9_302 = (VendedorParcela v) => !v.get_DataPrePagamento().HasValue;
+ ApoliceServico.u003cu003ec.u003cu003e9__30_2 = u003cu003e9_302;
+ }
+ List<VendedorParcela> list = vendedorParcelas1.Where<VendedorParcela>(u003cu003e9_302).ToList<VendedorParcela>();
+ Action<VendedorParcela> u003cu003e9_3 = action4;
+ if (u003cu003e9_3 == null)
+ {
+ Action<VendedorParcela> action1 = (VendedorParcela v) => {
+ v.set_ValorRepasse(new decimal?(new decimal()));
+ v.set_DataPagamento(new DateTime?(networkTime));
+ v.set_DataPrePagamento(new DateTime?(v.get_DataPrePagamento().GetValueOrDefault(networkTime)));
+ commited.get_VendedorParcelaRepository().Merge(v);
+ };
+ action = action1;
+ action4 = action1;
+ u003cu003e9_3 = action;
+ }
+ list.ForEach(u003cu003e9_3);
+ }
+ else
+ {
+ string str = (documento.get_Tipo() == 0 ? string.Concat(" PROPOSTA ", documento.get_Proposta(), " DO CLIENTE ", documento.get_Controle().get_Cliente().get_Nome()) : string.Concat(" PROPOSTA DE ENDOSSO ", documento.get_PropostaEndosso(), " DO CLIENTE ", documento.get_Controle().get_Cliente().get_Nome()));
+ List<VendedorParcela> vendedorParcelas2 = vendedorParcelas;
+ Func<VendedorParcela, bool> u003cu003e9_304 = ApoliceServico.u003cu003ec.u003cu003e9__30_4;
+ if (u003cu003e9_304 == null)
+ {
+ u003cu003e9_304 = (VendedorParcela v) => v.get_DataPagamento().HasValue;
+ ApoliceServico.u003cu003ec.u003cu003e9__30_4 = u003cu003e9_304;
+ }
+ IEnumerable<VendedorParcela> vendedorParcelas3 = vendedorParcelas2.Where<VendedorParcela>(u003cu003e9_304);
+ Func<VendedorParcela, long> u003cu003e9_305 = ApoliceServico.u003cu003ec.u003cu003e9__30_5;
+ if (u003cu003e9_305 == null)
+ {
+ u003cu003e9_305 = (VendedorParcela v) => v.get_Vendedor().get_Id();
+ ApoliceServico.u003cu003ec.u003cu003e9__30_5 = u003cu003e9_305;
+ }
+ List<Adiantamento> adiantamentos = vendedorParcelas3.GroupBy<VendedorParcela, long>(u003cu003e9_305).Select<IGrouping<long, VendedorParcela>, Adiantamento>((IGrouping<long, VendedorParcela> v) => {
+ Adiantamento adiantamento = new Adiantamento();
+ adiantamento.set_Vendedor(v.First<VendedorParcela>().get_Vendedor());
+ adiantamento.set_Data(new DateTime?(networkTime));
+ IGrouping<long, VendedorParcela> nums = v;
+ Func<VendedorParcela, bool> u003cu003e9_309 = ApoliceServico.u003cu003ec.u003cu003e9__30_9;
+ if (u003cu003e9_309 == null)
+ {
+ u003cu003e9_309 = (VendedorParcela s) => s.get_ValorRepasse().HasValue;
+ ApoliceServico.u003cu003ec.u003cu003e9__30_9 = u003cu003e9_309;
+ }
+ adiantamento.set_Valor(nums.Where<VendedorParcela>(u003cu003e9_309).Sum<VendedorParcela>((VendedorParcela s) => {
+ decimal? nullable;
+ decimal? nullable1;
+ decimal? valorRepasse = s.get_ValorRepasse();
+ decimal value = valorRepasse.Value;
+ decimal num = 1;
+ valorRepasse = v.First<VendedorParcela>().get_Vendedor().get_Desconto();
+ if (valorRepasse.HasValue)
+ {
+ nullable1 = new decimal?(num - valorRepasse.GetValueOrDefault());
+ }
+ else
+ {
+ nullable = null;
+ nullable1 = nullable;
+ }
+ nullable = nullable1;
+ return value * nullable.GetValueOrDefault();
+ }));
+ adiantamento.set_Historico(string.Format("ESTORNO DEVIDO A RECUSA {0} PARCELA {1}", str, x.get_NumeroParcela()));
+ return adiantamento;
+ }).ToList<Adiantamento>();
+ commited.get_AdiantamentoRepository().AddRange(adiantamentos);
+ List<VendedorParcela> vendedorParcelas4 = vendedorParcelas;
+ Func<VendedorParcela, bool> u003cu003e9_307 = ApoliceServico.u003cu003ec.u003cu003e9__30_7;
+ if (u003cu003e9_307 == null)
+ {
+ u003cu003e9_307 = (VendedorParcela v) => !v.get_DataPagamento().HasValue;
+ ApoliceServico.u003cu003ec.u003cu003e9__30_7 = u003cu003e9_307;
+ }
+ List<VendedorParcela> list1 = vendedorParcelas4.Where<VendedorParcela>(u003cu003e9_307).ToList<VendedorParcela>();
+ Action<VendedorParcela> u003cu003e9_8 = action3;
+ if (u003cu003e9_8 == null)
+ {
+ Action<VendedorParcela> action2 = (VendedorParcela v) => {
+ v.set_ValorRepasse(new decimal?(new decimal()));
+ v.set_DataPagamento(new DateTime?(networkTime));
+ v.set_DataPrePagamento(new DateTime?(v.get_DataPrePagamento().GetValueOrDefault(networkTime)));
+ commited.get_VendedorParcelaRepository().Merge(v);
+ };
+ action = action2;
+ action3 = action2;
+ u003cu003e9_8 = action;
+ }
+ list1.ForEach(u003cu003e9_8);
+ }
+ }
+ if (x.get_DataRecebimento().HasValue)
+ {
+ return;
+ }
+ x.set_DataRecebimento(new DateTime?(networkTime));
+ x.set_DataCredito(new DateTime?(networkTime));
+ x.set_ValorComissao(decimal.Zero);
+ x.set_ValorComDesconto(decimal.Zero);
+ commited.get_ParcelaRepository().Merge(x);
+ });
+ commited.get_DocumentoRepository().Merge(documento);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Documento documento1 = documento;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(documento1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(documento.get_Id());
+ registroLog.set_Tela(2);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_3011 = ApoliceServico.u003cu003ec.u003cu003e9__30_11;
+ if (u003cu003e9_3011 == null)
+ {
+ u003cu003e9_3011 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__30_11 = u003cu003e9_3011;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_3011);
+ if (pAddress != null)
+ {
+ str1 = pAddress.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog.set_Ip(str1);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 26, num1, documento, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ internal async Task<List<Documento>> BuscarApolice(string pesquisa, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, string campo = "Apolice", bool tipobusca = false)
+ {
+ int num1 = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ long num;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ IDocumentoRepository documentoRepository = read.get_DocumentoRepository();
+ string str = pesquisa;
+ FiltroStatusDocumento filtroStatusDocumento = status;
+ List<VendedorUsuario> vendedorUsuarios = vendedorVinculado;
+ string str1 = campo;
+ num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa());
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ Func<ConfiguracaoSistema, bool> u003cu003e9_211 = ApoliceServico.u003cu003ec.u003cu003e9__21_1;
+ if (u003cu003e9_211 == null)
+ {
+ u003cu003e9_211 = (ConfiguracaoSistema x) => x.get_Configuracao() == 43;
+ ApoliceServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211;
+ }
+ documentos = documentoRepository.FindApolice(str, filtroStatusDocumento, vendedorUsuarios, str1, num, configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_211), tipobusca);
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 7, num1, new { pesquisa = pesquisa, status = status, campo = campo }, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<Documento> BuscarApoliceAsync(long id, bool itens = false, bool sinistrosPorControle = false)
+ {
+ int num = 3;
+ Documento documento1 = await Task.Run<Documento>(() => {
+ Documento documento;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documento = read.get_DocumentoRepository().FindById(id, itens, sinistrosPorControle);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 3, num, id, true);
+ continue;
+ }
+ return documento;
+ }
+ return new Documento();
+ });
+ return documento1;
+ }
+
+ public async Task<List<Documento>> BuscarApolices(Filtros filtro, bool buscarAssinatura = false, bool painelBi = false)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(async () => {
+ List<Documento> documentos;
+ while (true)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = await read.get_DocumentoRepository().BuscaDocumentosPorVigencia(filtro, buscarAssinatura, painelBi);
+ return documentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 5, num, filtro, true);
+ }
+ if (num <= 0)
+ {
+ break;
+ }
+ }
+ documentos = new List<Documento>();
+ return documentos;
+ });
+ return documentos1;
+ }
+
+ internal async Task<ObservableCollection<Documento>> BuscarApolicesAsync(long id, FiltroStatusDocumento status = 0, List<VendedorUsuario> vendedorVinculado = null)
+ {
+ ObservableCollection<Documento> observableCollection1;
+ if (!this._carregando)
+ {
+ int num1 = 3;
+ observableCollection1 = await Task.Run<ObservableCollection<Documento>>(() => {
+ ObservableCollection<Documento> observableCollection;
+ while (num1 > 0)
+ {
+ try
+ {
+ this._carregando = true;
+ using (UnitOfWork read = Instancia.Read)
+ {
+ IDocumentoRepository documentoRepository = read.get_DocumentoRepository();
+ long num = id;
+ FiltroStatusDocumento filtroStatusDocumento = status;
+ List<VendedorUsuario> vendedorUsuarios = vendedorVinculado;
+ List<Licenca> produtos = LicenseHelper.Produtos;
+ bool flag1 = Recursos.Usuario.get_Id() == (long)0;
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ Func<ConfiguracaoSistema, bool> u003cu003e9_11 = ApoliceServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (ConfiguracaoSistema x) => x.get_Configuracao() == 43;
+ ApoliceServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ this._carregando = false;
+ observableCollection = new ObservableCollection<Documento>(documentoRepository.FindApoliceByCustomer(num, filtroStatusDocumento, vendedorUsuarios, produtos, false, flag1, configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_11)));
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ List<Licenca> licencas = LicenseHelper.Produtos;
+ Func<Licenca, bool> u003cu003e9_12 = ApoliceServico.u003cu003ec.u003cu003e9__1_2;
+ if (u003cu003e9_12 == null)
+ {
+ u003cu003e9_12 = (Licenca x) => {
+ if (x.get_Produto() != 86)
+ {
+ return false;
+ }
+ return x.get_Status() != 3;
+ };
+ ApoliceServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12;
+ }
+ bool flag = licencas.Any<Licenca>(u003cu003e9_12);
+ num1 = base.Registrar(exception, 1, num1, new { id = id, status = status, vendedorVinculado = vendedorVinculado, assinatura = flag }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ this._carregando = false;
+ return new ObservableCollection<Documento>();
+ });
+ }
+ else
+ {
+ observableCollection1 = new ObservableCollection<Documento>();
+ }
+ return observableCollection1;
+ }
+
+ internal async Task<ObservableCollection<Documento>> BuscarApolicesComissao(long id, FiltroStatusDocumento status = 0)
+ {
+ int num = 3;
+ ObservableCollection<Documento> observableCollection1 = await Task.Run<ObservableCollection<Documento>>(() => {
+ ObservableCollection<Documento> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<Documento>(read.get_DocumentoRepository().FindApoliceByCustomer(id, status, null, LicenseHelper.Produtos, true, false, false));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 2, num, new { id = id, status = status }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Documento>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<List<Documento>> BuscarApolicesPendentes(Filtros filtro)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().FindPendenciasByVigencia(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 10, num, filtro, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Documento>> BuscarApolicesPorId(List<long> ids)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().FindByIds(ids);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 3, num, ids, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Documento>> BuscarApolicesPorIdParcela(List<long> ids)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().FindByParcelaIds(ids);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 3, num, ids, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Documento>> BuscarApolicesVigenciaFinal(Filtros filtro, bool somarPremios = false)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().FindByVigenciaFinal(filtro, LicenseHelper.Produtos, somarPremios);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 6, num, filtro, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ internal async Task<Documento> BuscarCodDocumento(long pesquisa, List<VendedorUsuario> vendedorVinculado)
+ {
+ int num = 3;
+ Documento documento1 = await Task.Run<Documento>(() => {
+ Documento documento;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documento = read.get_DocumentoRepository().FindById(pesquisa, vendedorVinculado);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 3, num, pesquisa, true);
+ continue;
+ }
+ return documento;
+ }
+ return new Documento();
+ });
+ return documento1;
+ }
+
+ public async Task<Controle> BuscarControleAsync(long id)
+ {
+ int num = 3;
+ Controle controle1 = await Task.Run<Controle>(() => {
+ Controle controle;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ controle = read.get_ControleRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 4, num, id, true);
+ continue;
+ }
+ return controle;
+ }
+ return new Controle();
+ });
+ return controle1;
+ }
+
+ public async Task<List<Documento>> BuscarEndossos(Filtros filtro, bool buscarAssinatura = false)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(async () => {
+ List<Documento> documentos;
+ while (true)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = await read.get_DocumentoRepository().FindEndossoByVigencia(filtro, buscarAssinatura);
+ return documentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 5, num, filtro, true);
+ }
+ if (num <= 0)
+ {
+ break;
+ }
+ }
+ documentos = new List<Documento>();
+ return documentos;
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Fechamento>> BuscarFechamento(Filtros filtro)
+ {
+ int num = 3;
+ List<Fechamento> fechamentos1 = await Task.Run<List<Fechamento>>(async () => {
+ List<Fechamento> fechamentos;
+ while (true)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ fechamentos = await read.get_DocumentoRepository().Fechamento(filtro);
+ return fechamentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 8, num, filtro, true);
+ }
+ if (num <= 0)
+ {
+ break;
+ }
+ }
+ fechamentos = new List<Fechamento>();
+ return fechamentos;
+ });
+ return fechamentos1;
+ }
+
+ public async Task<List<Documento>> BuscarLicenciamentos(Filtros filtro)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().FindByLicenciamento(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 295, num, filtro, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ 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_DocumentoRepository().BuscarLogAntigo(id, Gestor.Application.Helpers.Connection.GetConnectionString());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 319, num, id, true);
+ continue;
+ }
+ return str;
+ }
+ return null;
+ });
+ return str1;
+ }
+
+ public async Task<List<Documento>> BuscarPlacas(Filtros filtro)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos = read.get_DocumentoRepository().FindByPlaca(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 327, num, filtro, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<PlanilhaCompleta>> BuscarPlanilhaCompleta(List<long> ids, bool configFranquia, bool configPremio)
+ {
+ int num = 3;
+ List<PlanilhaCompleta> planilhaCompletas1 = await Task.Run<List<PlanilhaCompleta>>(() => {
+ List<PlanilhaCompleta> planilhaCompletas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ planilhaCompletas = read.get_ReportRepository().PlanilhaCompleta(ids, configFranquia, configPremio);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 296, num, ids, true);
+ continue;
+ }
+ return planilhaCompletas;
+ }
+ return null;
+ });
+ return planilhaCompletas1;
+ }
+
+ public async Task<List<PlanilhaCompleta>> BuscarPlanilhaCompletaFatura(List<long> ids, Relatorio relatorio, DateTime inicio, DateTime fim, bool configFranquia, bool configPremio)
+ {
+ int num = 3;
+ List<PlanilhaCompleta> planilhaCompletas1 = await Task.Run<List<PlanilhaCompleta>>(() => {
+ List<PlanilhaCompleta> planilhaCompletas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ planilhaCompletas = read.get_ReportRepository().PlanilhaCompletaFatura(ids, relatorio, inicio, fim, configFranquia, configPremio);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 296, num, ids, true);
+ continue;
+ }
+ return planilhaCompletas;
+ }
+ return null;
+ });
+ return planilhaCompletas1;
+ }
+
+ public async Task<List<PlanilhaCompleta>> BuscarPlanilhaCompletaProspeccao(List<long> ids)
+ {
+ int num = 3;
+ List<PlanilhaCompleta> planilhaCompletas1 = await Task.Run<List<PlanilhaCompleta>>(() => {
+ List<PlanilhaCompleta> planilhaCompletas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ planilhaCompletas = read.get_DocumentoRepository().BuscarPlanilhaCompletaProspeccao(ids);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 296, num, ids, true);
+ continue;
+ }
+ return planilhaCompletas;
+ }
+ return null;
+ });
+ return planilhaCompletas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(Filtros filtro)
+ {
+ int num = 3;
+ List<Tarefa> tarefas1 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefaPorFiltro(filtro.get_Inicio(), filtro.get_Fim());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 97, num, filtro, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<Vendedor> BuscarVendedorPrincipal(long id)
+ {
+ int num = 3;
+ Vendedor vendedor1 = await Task.Run<Vendedor>(() => {
+ Vendedor vendedor;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ vendedor = read.get_VendedorParcelaRepository().BuscarVendedorPorControle(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 3, num, id, true);
+ continue;
+ }
+ return vendedor;
+ }
+ return new Vendedor();
+ });
+ return vendedor1;
+ }
+
+ public async Task<int> Cotacoes(Filtros filtro)
+ {
+ int num1 = 3;
+ int num2 = await Task.Run<int>(() => {
+ int num;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ num = read.get_DocumentoRepository().Cotacoes(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 14, num1, filtro, true);
+ continue;
+ }
+ return num;
+ }
+ return 0;
+ });
+ return num2;
+ }
+
+ public async Task<Documento> Excluir(Documento documento)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Documento documento2 = documento;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Documento documento3 = await Task.Run<Documento>(() => {
+ Documento documento4;
+ bool id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = 2;
+ Controle controle = documento.get_Controle();
+ if (controle == null)
+ {
+ controle = commited.get_DocumentoRepository().FindById(documento.get_Id(), false, false).get_Controle();
+ documento.set_Controle(controle);
+ }
+ commited.get_ParcelaRepository().ExcluirVinculoParcelaPendenteDocExcluido(documento);
+ Status status = documento.get_Status();
+ id = (status != null ? status.get_Id() == (long)0 : false);
+ if (id)
+ {
+ documento.set_Status(null);
+ }
+ documento = commited.get_DocumentoRepository().Merge(documento);
+ documento.set_Controle(commited.get_ControleRepository().Merge(controle));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Documento documento1 = documento;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(documento1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(documento.get_Id());
+ registroLog.set_Tela(2);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_41 = ApoliceServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_41);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ documento4 = documento;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 20, num, documento, true);
+ continue;
+ }
+ return documento4;
+ }
+ return documento2;
+ });
+ return documento3;
+ }
+
+ public async Task<bool> ExcluirCritica(long id)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ CriticaApolice criticaApolouse = commited.get_CriticaApoliceRepository().FindByApolice(id);
+ if (criticaApolouse != null)
+ {
+ commited.get_CriticaApoliceRepository().Delete(criticaApolouse.get_Id());
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Tela(20);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(criticaApolouse, jsonSerializerSetting));
+ registroLog.set_EntidadeId(criticaApolouse.get_Id());
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_281 = ApoliceServico.u003cu003ec.u003cu003e9__28_1;
+ if (u003cu003e9_281 == null)
+ {
+ u003cu003e9_281 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__28_1 = u003cu003e9_281;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_281);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ else
+ {
+ flag = true;
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 25, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> ExcluirPagamento(List<VendedorParcela> pagamentos)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_VendedorParcelaRepository().DeleteRange(pagamentos);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (VendedorParcela pagamento in pagamentos)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(pagamento, jsonSerializerSetting));
+ registroLog.set_EntidadeId(pagamento.get_Parcela().get_Id());
+ registroLog.set_Tela(37);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_141 = ApoliceServico.u003cu003ec.u003cu003e9__14_1;
+ if (u003cu003e9_141 == null)
+ {
+ u003cu003e9_141 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_141);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ }
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 21, num, pagamentos, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ internal async Task ExcluirVinculo(long id)
+ {
+ await Task.Run(() => {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_VinculoDocumentoRepository().Delete(id);
+ commited.Commit();
+ }
+ }
+ catch (Exception exception)
+ {
+ }
+ });
+ }
+
+ public async Task<VendedorParcela> IncluirVendedor(VendedorParcela vendedor)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ VendedorParcela vendedorParcela1 = vendedor;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ VendedorParcela vendedorParcela2 = await Task.Run<VendedorParcela>(() => {
+ VendedorParcela vendedorParcela;
+ object obj;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ vendedorParcela1 = commited.get_VendedorParcelaRepository().SaveOrUpdate(vendedorParcela1);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(0);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] strArrays = new string[] { string.Format("O USUÁRIO {0} INCLUIU, EM {1}, O VENDEDOR DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", vendedor.get_Id()), string.Format(", VALOR DO PAGAMENTO: 'R${0}'", vendedor.get_ValorRepasse()), string.Format(", VALOR TOTAL: 'R${0}'", vendedor.get_ValorTotal()), ", DATA DO PAGAMENTO: '", null, null, null };
+ DateTime? dataPagamento = vendedor.get_DataPagamento();
+ if (!dataPagamento.HasValue)
+ {
+ obj = "";
+ }
+ else
+ {
+ dataPagamento = vendedor.get_DataPagamento();
+ obj = (dataPagamento.HasValue ? dataPagamento.GetValueOrDefault().ToShortDateString() : null) ?? "";
+ }
+ strArrays[5] = (string)obj;
+ strArrays[6] = "'";
+ strArrays[7] = string.Format(", PORCENTAGEM DO PAGAMENTO: '{0}%'.", vendedor.get_PorcentagemRepasse());
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(vendedor.get_Id());
+ registroLog.set_Tela(37);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_151 = ApoliceServico.u003cu003ec.u003cu003e9__15_1;
+ if (u003cu003e9_151 == null)
+ {
+ u003cu003e9_151 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_151);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ vendedorParcela = vendedorParcela1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 22, num, vendedor, true);
+ continue;
+ }
+ return vendedorParcela;
+ }
+ return vendedor;
+ });
+ return vendedorParcela2;
+ }
+
+ public async Task<List<VendedorParcela>> IncluirVendedores(List<VendedorParcela> repasses)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<VendedorParcela> vendedorParcelas1 = repasses;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<VendedorParcela> vendedorParcelas2 = await Task.Run<List<VendedorParcela>>(() => {
+ List<VendedorParcela> vendedorParcelas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ vendedorParcelas1 = commited.get_VendedorParcelaRepository().AddRange(vendedorParcelas1);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ vendedorParcelas1.ForEach((VendedorParcela x) => {
+ string str;
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(0);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting));
+ registroLog.set_EntidadeId(x.get_Parcela().get_Id());
+ registroLog.set_Tela(37);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_162 = ApoliceServico.u003cu003ec.u003cu003e9__16_2;
+ if (u003cu003e9_162 == null)
+ {
+ u003cu003e9_162 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__16_2 = u003cu003e9_162;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_162);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ });
+ vendedorParcelas = vendedorParcelas1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 22, num, repasses, true);
+ continue;
+ }
+ return vendedorParcelas;
+ }
+ return repasses;
+ });
+ return vendedorParcelas2;
+ }
+
+ public async Task<bool> Perdido(long id)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_DocumentoRepository().FindByControle(id).ForEach((Documento x) => {
+ string str;
+ x.set_SituacaoAnterior(new TipoSeguro?(x.get_Situacao()));
+ x.set_Situacao(6);
+ commited.get_DocumentoRepository().Merge(x);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting));
+ registroLog.set_EntidadeId(x.get_Id());
+ registroLog.set_Tela(2);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_252 = ApoliceServico.u003cu003ec.u003cu003e9__25_2;
+ if (u003cu003e9_252 == null)
+ {
+ u003cu003e9_252 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__25_2 = u003cu003e9_252;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_252);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 23, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> Prorrogar(long id, DateTime vigencia2)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_DocumentoRepository().FindByControle(id).ForEach((Documento x) => {
+ string str;
+ if (!x.get_NegocioCorretora().HasValue)
+ {
+ x.set_NegocioCorretora(new NegocioCorretora?((!x.get_Negocio().HasValue || x.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1)));
+ }
+ x.set_Vigencia2(new DateTime?(vigencia2));
+ commited.get_DocumentoRepository().Merge(x);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting));
+ registroLog.set_EntidadeId(x.get_Id());
+ registroLog.set_Tela(2);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_232 = ApoliceServico.u003cu003ec.u003cu003e9__23_2;
+ if (u003cu003e9_232 == null)
+ {
+ u003cu003e9_232 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__23_2 = u003cu003e9_232;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_232);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 23, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> Reabilitar(long id)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_DocumentoRepository().FindByControle(id).ForEach((Documento x) => {
+ string str;
+ if (x.get_TipoEndosso().HasValue && x.get_TipoEndosso().GetValueOrDefault() == 2)
+ {
+ return;
+ }
+ x.set_Situacao(4);
+ commited.get_DocumentoRepository().Merge(x);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(x, jsonSerializerSetting));
+ registroLog.set_EntidadeId(x.get_Id());
+ registroLog.set_Tela(2);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_242 = ApoliceServico.u003cu003ec.u003cu003e9__24_2;
+ if (u003cu003e9_242 == null)
+ {
+ u003cu003e9_242 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ApoliceServico.u003cu003ec.u003cu003e9__24_2 = u003cu003e9_242;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_242);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 23, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task SalvarAssistencia(string id, long controleId)
+ {
+ await Task.Run(() => {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_DocumentoRepository().SalvarAssistencia(id, controleId);
+ commited.Commit();
+ }
+ }
+ catch (Exception exception)
+ {
+ }
+ });
+ }
+
+ public async Task Save(Controle controle, Cliente cliente)
+ {
+ int num = 3;
+ await Task.Run(() => {
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ List<RegistroLog> registroLogs1 = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ List<Diferenca> diferencas = new List<Diferenca>();
+ List<Diferenca> diferencas1 = new List<Diferenca>();
+ List<Diferenca> diferencas2 = diferencas;
+ Diferenca diferenca = new Diferenca();
+ diferenca.set_Campo("Cliente");
+ diferenca.set_Descricao("NOME");
+ diferenca.set_ValorAtual(cliente.get_Nome());
+ diferenca.set_ValorAnterior(controle.get_Cliente().get_Nome());
+ diferencas2.Insert(0, diferenca);
+ List<Diferenca> diferencas3 = diferencas1;
+ Diferenca diferenca1 = new Diferenca();
+ diferenca1.set_Campo("Cliente");
+ diferenca1.set_Descricao("APÓLICE TROCADA DE CLIENTE");
+ diferenca1.set_ValorAtual(cliente.get_Nome());
+ diferenca1.set_ValorAnterior(controle.get_Cliente().get_Nome());
+ diferencas3.Insert(0, diferenca1);
+ ExtensionMethods.ForEach<Documento>(controle.get_Documentos(), (Documento x) => {
+ registroLogs.Add(base.CreateLog(x.get_Id(), diferencas, 2));
+ registroLogs1.Add(base.CreateLog(x.get_Id(), diferencas1, 41));
+ });
+ commited.get_DocumentoRepository().TrocarCliente(controle, cliente);
+ base.SaveLog(registroLogs, commited);
+ base.SaveLog(registroLogs1, commited);
+ commited.Commit();
+ break;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 325, num, controle, true);
+ }
+ }
+ });
+ }
+
+ public async Task<Documento> Save(Documento documento, bool updateParcelas, bool criarParcelas)
+ {
+ Action<Parcela> action4 = null;
+ Action<VendedorParcela> action5 = null;
+ int num = 3;
+ base.Sucesso = true;
+ Documento documento1 = documento;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ Documento documento2 = await Task.Run<Documento>(() => {
+ Documento documento3;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ documento.get_Id();
+ bool id = documento.get_Id() == (long)0;
+ Controle controle = documento.get_Controle();
+ ObservableCollection<Parcela> parcelas = documento.get_Parcelas();
+ if (!id)
+ {
+ if (controle != null)
+ {
+ if ((controle != null ? controle.get_Seguradora() : false))
+ {
+ goto Label0;
+ }
+ }
+ controle = commited.get_DocumentoRepository().FindById(documento.get_Id(), false, false).get_Controle();
+ documento.set_Controle(controle);
+ Label0:
+ registroLogs.Add(base.CreateLog(documento.get_Id(), documento, 2));
+ documento = commited.get_DocumentoRepository().Merge(documento);
+ if (documento.get_TipoRecebimento().GetValueOrDefault() == 1)
+ {
+ if (criarParcelas)
+ {
+ List<Parcela> parcelas1 = commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id());
+ if (parcelas1 != null)
+ {
+ Action<Parcela> u003cu003e9_3 = action4;
+ if (u003cu003e9_3 == null)
+ {
+ Action<Parcela> action = (Parcela pa) => registroLogs.Add(base.CreateLog(documento.get_Id(), pa.GetValorOriginal(), 5, 2));
+ Action<Parcela> action1 = action;
+ action4 = action;
+ u003cu003e9_3 = action1;
+ }
+ parcelas1.ForEach(u003cu003e9_3);
+ }
+ else
+ {
+ }
+ List<VendedorParcela> vendedorParcelas = commited.get_VendedorParcelaRepository().FindByDocumentId(documento.get_Id());
+ if (vendedorParcelas != null)
+ {
+ Action<VendedorParcela> u003cu003e9_4 = action5;
+ if (u003cu003e9_4 == null)
+ {
+ Action<VendedorParcela> action2 = (VendedorParcela pa) => registroLogs.Add(base.CreateLog(pa.get_Parcela().get_Id(), pa.GetValorOriginal(), 37, 2));
+ Action<VendedorParcela> action3 = action2;
+ action5 = action2;
+ u003cu003e9_4 = action3;
+ }
+ vendedorParcelas.ForEach(u003cu003e9_4);
+ }
+ else
+ {
+ }
+ commited.get_VendedorParcelaRepository().DeleteRange(documento.get_Id());
+ commited.get_ParcelaRepository().DeleteRange(documento.get_Id());
+ parcelas.ToList<Parcela>().ForEach((Parcela p) => {
+ Parcela parcela = p;
+ ObservableCollection<VendedorParcela> vendedores = parcela.get_Vendedores();
+ parcela.set_Documento(documento);
+ parcela.set_IdEmpresa(documento.get_Controle().get_IdEmpresa());
+ parcela = commited.get_ParcelaRepository().SaveOrUpdate(parcela);
+ vendedores.ToList<VendedorParcela>().ForEach((VendedorParcela v) => {
+ v.set_Documento(documento);
+ v.set_Parcela(parcela);
+ if (v.get_Repasse() != null)
+ {
+ BaseRepasse? @base = v.get_Repasse().get_Base();
+ if (@base.HasValue)
+ {
+ switch (@base.GetValueOrDefault())
+ {
+ case 1:
+ {
+ v.set_DataPrePagamento(new DateTime?(documento.get_Vigencia1()));
+ break;
+ }
+ case 2:
+ {
+ v.set_DataPrePagamento(new DateTime?(networkTime));
+ break;
+ }
+ case 3:
+ {
+ v.set_DataPrePagamento(new DateTime?(parcela.get_Vencimento()));
+ break;
+ }
+ case 4:
+ {
+ v.set_DataPrePagamento(documento.get_Emissao());
+ break;
+ }
+ case 5:
+ {
+ v.set_DataPrePagamento(documento.get_Remessa());
+ break;
+ }
+ }
+ }
+ }
+ v = commited.get_VendedorParcelaRepository().SaveOrUpdate(v);
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), v.GetValorOriginal(), 37, 0));
+ });
+ parcela.set_Vendedores(vendedores);
+ registroLogs.Add(base.CreateLog(documento.get_Id(), parcela.GetValorOriginal(), 5, 0));
+ });
+ }
+ if (updateParcelas && !criarParcelas)
+ {
+ List<Parcela> parcelas2 = commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id());
+ List<VendedorParcela> vendedorParcelas1 = commited.get_VendedorParcelaRepository().FindByDocumentId(documento.get_Id());
+ parcelas.ToList<Parcela>().ForEach((Parcela p) => {
+ Parcela parcela = p;
+ ObservableCollection<VendedorParcela> vendedores = parcela.get_Vendedores();
+ parcela.set_Documento(documento);
+ parcela = commited.get_ParcelaRepository().Merge(parcela);
+ vendedores.ToList<VendedorParcela>().ForEach((VendedorParcela v) => {
+ bool flag;
+ VendedorParcela vendedorParcela = v;
+ vendedorParcela.set_Documento(documento);
+ vendedorParcela.set_Parcela(parcela);
+ flag = (vendedorParcela.get_Id() > (long)0 ? false : true);
+ vendedorParcela = (vendedorParcela.get_Id() > (long)0 ? commited.get_VendedorParcelaRepository().Merge(vendedorParcela) : commited.get_VendedorParcelaRepository().SaveOrUpdate(vendedorParcela));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), vendedorParcela.GetValorOriginal(), 37, 0));
+ }
+ VendedorParcela vendedorParcela1 = vendedorParcelas1.FirstOrDefault<VendedorParcela>((VendedorParcela pa) => vendedorParcela.get_Id() == pa.get_Id());
+ if (vendedorParcela1 == null)
+ {
+ return;
+ }
+ List<Diferenca> diferencas = vendedorParcela.Compare(vendedorParcela1.GetValorOriginal());
+ if (diferencas.Count > 0)
+ {
+ Diferenca diferenca = new Diferenca();
+ diferenca.set_Campo("Vendedor");
+ diferenca.set_Descricao("VENDEDOR");
+ diferenca.set_ValorAtual(vendedorParcela.get_Vendedor().get_Nome());
+ diferenca.set_ValorAnterior(vendedorParcela.get_Vendedor().get_Nome());
+ diferencas.Insert(0, diferenca);
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), diferencas, 37));
+ }
+ });
+ parcela.set_Vendedores(vendedores);
+ Parcela parcela1 = parcelas2.FirstOrDefault<Parcela>((Parcela pa) => parcela.get_Id() == pa.get_Id());
+ if (parcela1 == null)
+ {
+ return;
+ }
+ List<Diferenca> diferencas1 = parcela.Compare(parcela1.GetValorOriginal());
+ if (diferencas1.Count > 0)
+ {
+ Diferenca diferenca1 = new Diferenca();
+ diferenca1.set_Campo("Parcela");
+ diferenca1.set_Descricao("PARCELA");
+ int numeroParcela = parcela.get_NumeroParcela();
+ diferenca1.set_ValorAtual(numeroParcela.ToString());
+ numeroParcela = parcela.get_NumeroParcela();
+ diferenca1.set_ValorAnterior(numeroParcela.ToString());
+ diferencas1.Insert(0, diferenca1);
+ registroLogs.Add(base.CreateLog(documento.get_Id(), diferencas1, 5));
+ }
+ });
+ }
+ }
+ documento.set_Controle(commited.get_ControleRepository().Merge(controle));
+ }
+ else
+ {
+ controle = (documento.get_Tipo() <= 0 || controle.get_Id() <= (long)0 ? commited.get_ControleRepository().SaveOrUpdate(controle) : controle);
+ documento.set_Controle(controle);
+ documento = commited.get_DocumentoRepository().SaveOrUpdate(documento);
+ registroLogs.Add(base.CreateLog(documento.get_Id(), documento.GetValorOriginal(), 2, 0));
+ if (parcelas != null)
+ {
+ parcelas.ToList<Parcela>().ForEach((Parcela p) => {
+ Parcela parcela = p;
+ ObservableCollection<VendedorParcela> vendedores = parcela.get_Vendedores();
+ parcela.set_Documento(documento);
+ parcela.set_IdEmpresa(documento.get_Controle().get_IdEmpresa());
+ parcela = commited.get_ParcelaRepository().SaveOrUpdate(parcela);
+ registroLogs.Add(base.CreateLog(documento.get_Id(), parcela.GetValorOriginal(), 5, 0));
+ vendedores.ToList<VendedorParcela>().ForEach((VendedorParcela v) => {
+ v.set_Documento(documento);
+ v.set_Parcela(parcela);
+ if (v.get_Repasse() != null)
+ {
+ BaseRepasse? @base = v.get_Repasse().get_Base();
+ if (@base.HasValue)
+ {
+ switch (@base.GetValueOrDefault())
+ {
+ case 1:
+ {
+ v.set_DataPrePagamento(new DateTime?(documento.get_Vigencia1()));
+ break;
+ }
+ case 2:
+ {
+ v.set_DataPrePagamento(new DateTime?(networkTime));
+ break;
+ }
+ case 3:
+ {
+ v.set_DataPrePagamento(new DateTime?(parcela.get_Vencimento()));
+ break;
+ }
+ case 4:
+ {
+ v.set_DataPrePagamento(documento.get_Emissao());
+ break;
+ }
+ case 5:
+ {
+ v.set_DataPrePagamento(documento.get_Remessa());
+ break;
+ }
+ }
+ }
+ }
+ v = commited.get_VendedorParcelaRepository().SaveOrUpdate(v);
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), v.GetValorOriginal(), 37, 0));
+ });
+ parcela.set_Vendedores(vendedores);
+ });
+ }
+ }
+ documento.set_Parcelas(parcelas);
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ documento3 = documento;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 18, num, new { documentoOriginal = documento1, updateParcelas = updateParcelas, criarParcelas = criarParcelas }, true);
+ continue;
+ }
+ return documento3;
+ }
+ return documento1;
+ });
+ return documento2;
+ }
+
+ public async Task<string> Save(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)
+ {
+ Documento documento = commited.get_DocumentoRepository().FindById(id, false, false);
+ documento.Initialize();
+ documento.set_Observacao(observacao);
+ registroLogs.Add(base.CreateLog(documento.get_Id(), documento, 2));
+ commited.get_DocumentoRepository().Merge(documento);
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ }
+ str = observacao;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 18, num, new { id = id, observacao = observacao }, true);
+ continue;
+ }
+ return str;
+ }
+ return "";
+ });
+ return str1;
+ }
+
+ public async Task<bool> UpdateRange(Controle controle)
+ {
+ int num = 3;
+ Controle controle1 = controle;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ controle1 = commited.get_ControleRepository().Merge(controle1);
+ controle1.get_Documentos().ToList<Documento>().ForEach((Documento x) => x = commited.get_DocumentoRepository().Merge(x));
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 19, num, controle, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs new file mode 100644 index 0000000..bec5089 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/AtividadeServico.cs @@ -0,0 +1,78 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class AtividadeServico : BaseServico
+ {
+ public AtividadeServico()
+ {
+ }
+
+ public async Task<long> FindLastId()
+ {
+ int num1 = 3;
+ long num2 = await Task.Run<long>(() => {
+ long num;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ num = read.get_AtividadeRepository().FindLastId();
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 17, num1, null, true);
+ continue;
+ }
+ return num;
+ }
+ return (long)0;
+ });
+ return num2;
+ }
+
+ public async Task<Atividade> Save(Atividade atividade)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Atividade atividade1 = atividade;
+ Atividade atividade2 = await Task.Run<Atividade>(() => {
+ Atividade atividade3;
+ while (num > 0)
+ {
+ atividade = atividade1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ atividade = (atividade.get_Id() == (long)0 ? commited.get_AtividadeRepository().SaveOrUpdate(atividade) : commited.get_AtividadeRepository().Merge(atividade));
+ commited.Commit();
+ atividade3 = atividade;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 211, num, atividade, true);
+ continue;
+ }
+ return atividade3;
+ }
+ return atividade1;
+ });
+ return atividade2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs new file mode 100644 index 0000000..db5c9d2 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ClienteServico.cs @@ -0,0 +1,1194 @@ +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 diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs new file mode 100644 index 0000000..67d9e1f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/CriticaApoliceServico.cs @@ -0,0 +1,321 @@ +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.Configuracoes;
+using Gestor.Model.Domain.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class CriticaApoliceServico : BaseServico
+ {
+ private bool _carregando;
+
+ public CriticaApoliceServico()
+ {
+ }
+
+ internal async Task<Cliente> BuscarCliente(long id)
+ {
+ int num = 3;
+ Cliente cliente1 = await Task.Run<Cliente>(() => {
+ Cliente cliente;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ cliente = read.get_ClienteRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 27, num, id, true);
+ continue;
+ }
+ return cliente;
+ }
+ return new Cliente();
+ });
+ return cliente1;
+ }
+
+ public async Task<List<CriticaApolice>> BuscarCritica(long usuario, DateTime inicio, DateTime fim, long id = 0L, bool criticado = false, List<VendedorUsuario> vinculos = null)
+ {
+ List<CriticaApolice> criticaApolices1;
+ if (!this._carregando)
+ {
+ int num3 = 3;
+ criticaApolices1 = await Task.Run<List<CriticaApolice>>(() => {
+ List<CriticaApolice> criticaApolices;
+ long num;
+ while (num3 > 0)
+ {
+ try
+ {
+ this._carregando = true;
+ using (UnitOfWork read = Instancia.Read)
+ {
+ id = read.get_VendedorRepository().FindCorretora().get_Id();
+ ICriticaApoliceRepository criticaApoliceRepository = read.get_CriticaApoliceRepository();
+ long num1 = usuario;
+ DateTime dateTime = inicio;
+ DateTime dateTime1 = fim;
+ long num2 = id;
+ bool flag = criticado;
+ num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa());
+ List<VendedorUsuario> vendedorUsuarios = vinculos;
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ Func<ConfiguracaoSistema, bool> u003cu003e9_21 = CriticaApoliceServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (ConfiguracaoSistema x) => x.get_Configuracao() == 43;
+ CriticaApoliceServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ bool flag1 = configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_21);
+ List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
+ Func<ConfiguracaoSistema, bool> u003cu003e9_22 = CriticaApoliceServico.u003cu003ec.u003cu003e9__2_2;
+ if (u003cu003e9_22 == null)
+ {
+ u003cu003e9_22 = (ConfiguracaoSistema x) => x.get_Configuracao() == 38;
+ CriticaApoliceServico.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22;
+ }
+ this._carregando = false;
+ criticaApolices = criticaApoliceRepository.Find(num1, dateTime, dateTime1, num2, flag, num, vendedorUsuarios, flag1, configuracaoSistemas.Any<ConfiguracaoSistema>(u003cu003e9_22));
+ }
+ }
+ catch (Exception exception)
+ {
+ num3 = base.Registrar(exception, 43, num3, new { usuario = usuario, inicio = inicio, fim = fim, criticado = criticado }, true);
+ continue;
+ }
+ return criticaApolices;
+ }
+ this._carregando = false;
+ return new List<CriticaApolice>();
+ });
+ }
+ else
+ {
+ criticaApolices1 = new List<CriticaApolice>();
+ }
+ return criticaApolices1;
+ }
+
+ public async Task<List<CriticaApolice>> BuscarCritica(DateTime inicio, DateTime fim)
+ {
+ int num = 3;
+ List<CriticaApolice> criticaApolices1 = await Task.Run<List<CriticaApolice>>(() => {
+ List<CriticaApolice> criticaApolices;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ criticaApolices = read.get_CriticaApoliceRepository().Find(inicio, fim, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 43, num, new { inicio = inicio, fim = fim }, true);
+ continue;
+ }
+ return criticaApolices;
+ }
+ return new List<CriticaApolice>();
+ });
+ return criticaApolices1;
+ }
+
+ public async Task<List<CriticaApolice>> BuscarCritica(long id)
+ {
+ int num = 3;
+ List<CriticaApolice> criticaApolices1 = await Task.Run<List<CriticaApolice>>(() => {
+ List<CriticaApolice> criticaApolices;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ criticaApolices = read.get_CriticaApoliceRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 44, num, id, true);
+ continue;
+ }
+ return criticaApolices;
+ }
+ return new List<CriticaApolice>();
+ });
+ return criticaApolices1;
+ }
+
+ public async Task<List<CriticaApolice>> BuscarImportacao(long id)
+ {
+ int num = 3;
+ List<CriticaApolice> criticaApolices1 = await Task.Run<List<CriticaApolice>>(() => {
+ List<CriticaApolice> criticaApolices;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ criticaApolices = read.get_CriticaApoliceRepository().FindImport(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 45, num, id, true);
+ continue;
+ }
+ return criticaApolices;
+ }
+ return new List<CriticaApolice>();
+ });
+ return criticaApolices1;
+ }
+
+ public async Task<List<CriticaApolice>> BuscarSeguroCombinado(long id, DateTime vigencia)
+ {
+ int num = 3;
+ List<CriticaApolice> criticaApolices1 = await Task.Run<List<CriticaApolice>>(() => {
+ List<CriticaApolice> criticaApolices;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ criticaApolices = read.get_CriticaApoliceRepository().FindDuo(id, vigencia);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 44, num, id, true);
+ continue;
+ }
+ return criticaApolices;
+ }
+ return new List<CriticaApolice>();
+ });
+ return criticaApolices1;
+ }
+
+ public async Task<List<Usuario>> BuscarUsuarioCritica(DateTime inicio, DateTime fim, bool criticado = false)
+ {
+ int num = 3;
+ List<Usuario> usuarios1 = await Task.Run<List<Usuario>>(() => {
+ List<Usuario> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Usuario> usuarios = read.get_CriticaApoliceRepository().BuscarUsuarioCritica(inicio, fim, criticado, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ Func<Usuario, string> u003cu003e9_41 = CriticaApoliceServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = (Usuario x) => x.get_Nome();
+ CriticaApoliceServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ list = usuarios.OrderBy<Usuario, string>(u003cu003e9_41).ToList<Usuario>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 43, num, new { inicio = inicio, fim = fim, criticado = criticado }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Usuario>();
+ });
+ return usuarios1;
+ }
+
+ public async Task<CriticaApolice> Save(CriticaApolice critica)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ CriticaApolice criticaApolouse2 = critica;
+ CriticaApolice criticaApolouse3 = await Task.Run<CriticaApolice>(() => {
+ CriticaApolice criticaApolouse;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (criticaApolouse2.get_Id() == 0 ? 0 : 1);
+ criticaApolouse2 = commited.get_CriticaApoliceRepository().Merge(criticaApolouse2);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ CriticaApolice criticaApolouse1 = criticaApolouse2;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(criticaApolouse1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(criticaApolouse2.get_Id());
+ registroLog.set_Tela(20);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_81 = CriticaApoliceServico.u003cu003ec.u003cu003e9__8_1;
+ if (u003cu003e9_81 == null)
+ {
+ u003cu003e9_81 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ CriticaApoliceServico.u003cu003ec.u003cu003e9__8_1 = u003cu003e9_81;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_81);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ criticaApolouse = criticaApolouse2;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 173, num, critica, true);
+ continue;
+ }
+ return criticaApolouse;
+ }
+ return critica;
+ });
+ return criticaApolouse3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs new file mode 100644 index 0000000..47fb942 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ExpedicaoServico.cs @@ -0,0 +1,192 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ public class ExpedicaoServico : BaseServico
+ {
+ public ExpedicaoServico()
+ {
+ }
+
+ public async Task<List<Expedicao>> BuscarExpedicoes(Documento documento)
+ {
+ int num = 3;
+ List<Expedicao> expedicaos1 = await Task.Run<List<Expedicao>>(() => {
+ List<Expedicao> expedicaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ expedicaos = read.get_ExpedicaoRepository().FindByIdDocumento(documento.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 289, num, documento, true);
+ continue;
+ }
+ return expedicaos;
+ }
+ return new List<Expedicao>();
+ });
+ return expedicaos1;
+ }
+
+ public async Task<bool> Delete(Expedicao expedicao)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_ExpedicaoRepository().Delete(expedicao.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ registroLog.set_Descricao(string.Concat(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A EXPEDIÇÃO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", expedicao.get_Id()), ", DOCUMENTO: '", expedicao.get_Documento(), "', DESTINO: '", expedicao.get_Destino(), "'", string.Format(", DATA ENVIO: '{0}'", expedicao.get_DataEnvio()), string.Format(", DATA RECEBIMENTO: '{0}'", expedicao.get_DataRecebimento()), ", RESPONSÁVEL: 'R$", expedicao.get_Responsavel(), "'." }));
+ registroLog.set_EntidadeId(expedicao.get_Id());
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_Tela(46);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog1 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = ExpedicaoServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ExpedicaoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_21);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 291, num, expedicao, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Expedicao> Save(Expedicao expedicao)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Expedicao expedicao2 = expedicao;
+ Expedicao expedicao3 = await Task.Run<Expedicao>(() => {
+ Expedicao expedicao4;
+ string str;
+ while (num > 0)
+ {
+ expedicao = expedicao2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (expedicao.get_Id() == 0 ? 0 : 1);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ if (expedicao.get_Id() != 0)
+ {
+ expedicao.set_UsuarioAlteracao(new long?(Recursos.Usuario.get_Id()));
+ expedicao.set_DataAlteracao(new DateTime?(networkTime));
+ expedicao = commited.get_ExpedicaoRepository().Merge(expedicao);
+ }
+ else
+ {
+ expedicao.set_UsuarioCriacao(new long?(Recursos.Usuario.get_Id()));
+ expedicao.set_DataCriacao(new DateTime?(networkTime));
+ expedicao = commited.get_ExpedicaoRepository().SaveOrUpdate(expedicao);
+ }
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Expedicao expedicao1 = expedicao;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(expedicao1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(expedicao.get_Id());
+ registroLog.set_Tela(46);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = ExpedicaoServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ExpedicaoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ expedicao4 = expedicao;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 290, num, expedicao, true);
+ continue;
+ }
+ return expedicao4;
+ }
+ return expedicao2;
+ });
+ return expedicao3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs new file mode 100644 index 0000000..11c0f6f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AeronauticoServico.cs @@ -0,0 +1,121 @@ +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.Domain.Common;
+using Gestor.Model.Domain.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class AeronauticoServico : BaseServico
+ {
+ public AeronauticoServico()
+ {
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_Aeronautico() != null && item.get_Aeronautico().get_Id() > (long)0)
+ {
+ commited.get_AeronauticoRepository().Delete(item.get_Aeronautico().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ Aeronautico aeronautico = item.get_Aeronautico();
+ id = (aeronautico != null ? aeronautico.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = AeronauticoServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AeronauticoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 203, num, item, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Aeronautico> Save(Aeronautico aeronautico)
+ {
+ Aeronautico aeronautico1 = await Task.Run<Aeronautico>(() => {
+ Aeronautico aeronautico2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ aeronautico = (aeronautico.get_Id() == 0 ? commited.get_AeronauticoRepository().SaveOrUpdate(aeronautico) : commited.get_AeronauticoRepository().Merge(aeronautico));
+ commited.Commit();
+ aeronautico2 = aeronautico;
+ }
+ }
+ catch (Exception exception)
+ {
+ aeronautico2 = null;
+ }
+ return aeronautico2;
+ });
+ return aeronautico1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs new file mode 100644 index 0000000..ba8eb2f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/AutoServico.cs @@ -0,0 +1,262 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class AutoServico : BaseServico
+ {
+ public AutoServico()
+ {
+ }
+
+ internal async Task<Documento> BuscarAuto(string value, long id, DateTime vigencia1, DateTime? vigencia2, long idSeguradora)
+ {
+ int num = 3;
+ Documento documento1 = await Task.Run<Documento>(() => {
+ Documento documento;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documento = read.get_AutoRepository().FindByChassi(value, id, vigencia1, vigencia2, idSeguradora);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 50, num, new { @value = value, id = id }, true);
+ continue;
+ }
+ return documento;
+ }
+ return new Documento();
+ });
+ return documento1;
+ }
+
+ internal async Task<List<PesquisaAvancada>> BuscarChassi(string chassi, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, bool tipobusca = false)
+ {
+ List<PesquisaAvancada> pesquisaAvancadas1 = await Task.Run<List<PesquisaAvancada>>(() => {
+ List<PesquisaAvancada> pesquisaAvancadas;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ pesquisaAvancadas = read.get_AutoRepository().FindAuto(chassi, status, vendedorVinculado, 0, tipobusca);
+ }
+ }
+ catch (Exception exception)
+ {
+ pesquisaAvancadas = null;
+ }
+ return pesquisaAvancadas;
+ });
+ return pesquisaAvancadas1;
+ }
+
+ public async Task<string> BuscarChassi(long id)
+ {
+ string str1 = await Task.Run<string>(() => {
+ string str;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ str = read.get_AutoRepository().FindChassi(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ str = null;
+ }
+ return str;
+ });
+ return str1;
+ }
+
+ public async Task<List<PesquisaAvancada>> BuscarItem(string item, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, bool tipobusca = false)
+ {
+ List<PesquisaAvancada> pesquisaAvancadas1 = await Task.Run<List<PesquisaAvancada>>(() => {
+ List<PesquisaAvancada> pesquisaAvancadas;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ pesquisaAvancadas = read.get_AutoRepository().FindAuto(item, status, vendedorVinculado, 6, tipobusca);
+ }
+ }
+ catch (Exception exception)
+ {
+ pesquisaAvancadas = null;
+ }
+ return pesquisaAvancadas;
+ });
+ return pesquisaAvancadas1;
+ }
+
+ internal async Task<List<PesquisaAvancada>> BuscarPlaca(string placa, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, bool tipobusca = false)
+ {
+ List<PesquisaAvancada> pesquisaAvancadas1 = await Task.Run<List<PesquisaAvancada>>(() => {
+ List<PesquisaAvancada> pesquisaAvancadas;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ pesquisaAvancadas = read.get_AutoRepository().FindAuto(placa, status, vendedorVinculado, 14, tipobusca);
+ }
+ }
+ catch (Exception exception)
+ {
+ pesquisaAvancadas = null;
+ }
+ return pesquisaAvancadas;
+ });
+ return pesquisaAvancadas1;
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_Auto() != null && item.get_Auto().get_Id() > (long)0)
+ {
+ commited.get_AutoRepository().Delete(item.get_Auto().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ Auto auto = item.get_Auto();
+ id = (auto != null ? auto.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = AutoServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AutoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_21);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 205, num, item, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Auto> Save(Auto auto)
+ {
+ Auto auto2 = await Task.Run<Auto>(() => {
+ Auto auto3;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (auto.get_Id() == 0 ? 0 : 1);
+ auto = (auto.get_Id() == 0 ? commited.get_AutoRepository().SaveOrUpdate(auto) : commited.get_AutoRepository().Merge(auto));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Auto auto1 = auto;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(auto1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(auto.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = AutoServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AutoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ auto3 = auto;
+ }
+ }
+ catch (Exception exception)
+ {
+ auto3 = null;
+ }
+ return auto3;
+ });
+ return auto2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs new file mode 100644 index 0000000..2c981c8 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ConsorcioServico.cs @@ -0,0 +1,156 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class ConsorcioServico : BaseServico
+ {
+ public ConsorcioServico()
+ {
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_Consorcio() != null && item.get_Consorcio().get_Id() > (long)0)
+ {
+ commited.get_ConsorcioRepository().Delete(item.get_Consorcio().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ Consorcio consorcio = item.get_Consorcio();
+ id = (consorcio != null ? consorcio.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = ConsorcioServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConsorcioServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 332, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Gestor.Model.Domain.Seguros.Consorcio> Save(Gestor.Model.Domain.Seguros.Consorcio Consorcio)
+ {
+ Gestor.Model.Domain.Seguros.Consorcio consorcio2 = await Task.Run<Gestor.Model.Domain.Seguros.Consorcio>(() => {
+ Gestor.Model.Domain.Seguros.Consorcio consorcio;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (Consorcio.get_Id() == 0 ? 0 : 1);
+ Consorcio = (Consorcio.get_Id() == 0 ? commited.get_ConsorcioRepository().SaveOrUpdate(Consorcio) : commited.get_ConsorcioRepository().Merge(Consorcio));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Gestor.Model.Domain.Seguros.Consorcio consorcio1 = Consorcio;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(consorcio1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(Consorcio.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = ConsorcioServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConsorcioServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_01);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ consorcio = Consorcio;
+ }
+ }
+ catch (Exception exception)
+ {
+ consorcio = null;
+ }
+ return consorcio;
+ });
+ return consorcio2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs new file mode 100644 index 0000000..054685c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/GranizoServico.cs @@ -0,0 +1,156 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class GranizoServico : BaseServico
+ {
+ public GranizoServico()
+ {
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_Granizo() != null && item.get_Granizo().get_Id() > (long)0)
+ {
+ commited.get_GranizoRepository().Delete(item.get_Granizo().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ Granizo granizo = item.get_Granizo();
+ id = (granizo != null ? granizo.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = GranizoServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ GranizoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 207, num, item, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Granizo> Save(Granizo granizo)
+ {
+ Granizo granizo2 = await Task.Run<Granizo>(() => {
+ Granizo granizo3;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (granizo.get_Id() == 0 ? 0 : 1);
+ granizo = (granizo.get_Id() == 0 ? commited.get_GranizoRepository().SaveOrUpdate(granizo) : commited.get_GranizoRepository().Merge(granizo));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Granizo granizo1 = granizo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(granizo1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(granizo.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = GranizoServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ GranizoServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_01);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ granizo3 = granizo;
+ }
+ }
+ catch (Exception exception)
+ {
+ granizo3 = null;
+ }
+ return granizo3;
+ });
+ return granizo2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs new file mode 100644 index 0000000..a666367 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs @@ -0,0 +1,1900 @@ +using Agger.Registro;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+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.Generic;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ public class ItemServico : BaseServico
+ {
+ private const string GuidGestorFipe = "bbbf4f03-01fc-4300-b430-33e007753578";
+
+ public ItemServico()
+ {
+ }
+
+ public async Task<Aeronautico> BuscaAeronautico(long id)
+ {
+ int num = 3;
+ Aeronautico aeronautico1 = await Task.Run<Aeronautico>(() => {
+ Aeronautico aeronautico;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ aeronautico = read.get_AeronauticoRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 63, num, id, true);
+ continue;
+ }
+ return aeronautico;
+ }
+ return new Aeronautico();
+ });
+ return aeronautico1;
+ }
+
+ internal async Task<Auto> BuscaAuto(long id)
+ {
+ int num = 3;
+ Auto auto1 = await Task.Run<Auto>(() => {
+ Auto auto;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ auto = read.get_AutoRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 55, num, id, true);
+ continue;
+ }
+ return auto;
+ }
+ return new Auto();
+ });
+ return auto1;
+ }
+
+ public async Task<Consorcio> BuscaConsorcio(long id)
+ {
+ int num = 3;
+ Consorcio consorcio1 = await Task.Run<Consorcio>(() => {
+ Consorcio consorcio;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ consorcio = read.get_ConsorcioRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 330, num, id, true);
+ continue;
+ }
+ return consorcio;
+ }
+ return new Consorcio();
+ });
+ return consorcio1;
+ }
+
+ internal async Task<Granizo> BuscaGranizo(long id)
+ {
+ int num = 3;
+ Granizo granizo1 = await Task.Run<Granizo>(() => {
+ Granizo granizo;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ granizo = read.get_GranizoRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 56, num, id, true);
+ continue;
+ }
+ return granizo;
+ }
+ return new Granizo();
+ });
+ return granizo1;
+ }
+
+ internal async Task<List<PesquisaAvancada>> BuscaItensPorObs(string observacao, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, bool tipobusca = false)
+ {
+ List<PesquisaAvancada> pesquisaAvancadas1 = await Task.Run<List<PesquisaAvancada>>(async () => {
+ List<PesquisaAvancada> pesquisaAvancadas;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ pesquisaAvancadas = await read.get_ItemRepository().BuscaItensPorObs(observacao, status, vendedorVinculado, 18, tipobusca);
+ }
+ }
+ catch (Exception exception)
+ {
+ pesquisaAvancadas = null;
+ }
+ return pesquisaAvancadas;
+ });
+ return pesquisaAvancadas1;
+ }
+
+ public async Task<Patrimonial> BuscaPatrimonial(long id)
+ {
+ int num = 3;
+ Patrimonial patrimonial1 = await Task.Run<Patrimonial>(() => {
+ Patrimonial patrimonial;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ patrimonial = read.get_PatrimonialRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 59, num, id, true);
+ continue;
+ }
+ return patrimonial;
+ }
+ return new Patrimonial();
+ });
+ return patrimonial1;
+ }
+
+ public async Task<Cliente> BuscarCliente(long id)
+ {
+ int num = 3;
+ Cliente cliente1 = await Task.Run<Cliente>(() => {
+ Cliente cliente;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ cliente = read.get_ItemRepository().BuscarCliente(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 27, num, id, true);
+ continue;
+ }
+ return cliente;
+ }
+ return new Cliente();
+ });
+ return cliente1;
+ }
+
+ internal async Task<ObservableCollection<Cobertura>> BuscarCoberturasPorItemAsync(long id)
+ {
+ int num = 3;
+ ObservableCollection<Cobertura> observableCollection1 = await Task.Run<ObservableCollection<Cobertura>>(() => {
+ ObservableCollection<Cobertura> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<Cobertura>(read.get_CoberturaRepository().FindByItemId(id));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 57, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Cobertura>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<RiscosDiversos> BuscaRiscosDiversos(long id)
+ {
+ int num = 3;
+ RiscosDiversos riscosDiverso1 = await Task.Run<RiscosDiversos>(() => {
+ RiscosDiversos riscosDiverso;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ riscosDiverso = read.get_RiscosDiversosRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 62, num, id, true);
+ continue;
+ }
+ return riscosDiverso;
+ }
+ return new RiscosDiversos();
+ });
+ return riscosDiverso1;
+ }
+
+ internal async Task<Item> BuscarItemPorIdAsync(long id)
+ {
+ int num = 3;
+ Item item1 = await Task.Run<Item>(() => {
+ Item item;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ item = read.get_ItemRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 51, num, id, true);
+ continue;
+ }
+ return item;
+ }
+ return new Item();
+ });
+ return item1;
+ }
+
+ internal async Task<ObservableCollection<Item>> BuscarItems(long id, StatusItem status = 2, bool sinsitroCompleto = false)
+ {
+ int num = 3;
+ ObservableCollection<Item> observableCollection1 = await Task.Run<ObservableCollection<Item>>(() => {
+ ObservableCollection<Item> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<Item>(read.get_ItemRepository().FindByDocumentsIds(id, status, sinsitroCompleto));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 52, num, new { id = id, status = status }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Item>();
+ });
+ return observableCollection1;
+ }
+
+ internal async Task<List<Item>> BuscarItems(List<long> ids)
+ {
+ int num = 3;
+ List<Item> items1 = await Task.Run<List<Item>>(() => {
+ List<Item> items;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ items = read.get_ItemRepository().FindByIds(ids);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 52, num, ids, true);
+ continue;
+ }
+ return items;
+ }
+ return new List<Item>();
+ });
+ return items1;
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(List<long> ids)
+ {
+ int num = 3;
+ ObservableCollection<Item> observableCollection1 = await Task.Run<ObservableCollection<Item>>(() => {
+ ObservableCollection<Item> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Item> items = read.get_ItemRepository().FindItens(ids);
+ if (items != null)
+ {
+ List<Item> items1 = items;
+ Func<Item, int?> u003cu003e9_281 = ItemServico.u003cu003ec.u003cu003e9__28_1;
+ if (u003cu003e9_281 == null)
+ {
+ u003cu003e9_281 = (Item x) => x.get_Ordem();
+ ItemServico.u003cu003ec.u003cu003e9__28_1 = u003cu003e9_281;
+ }
+ IOrderedEnumerable<Item> items2 = items1.OrderBy<Item, int?>(u003cu003e9_281);
+ Func<Item, string> u003cu003e9_282 = ItemServico.u003cu003ec.u003cu003e9__28_2;
+ if (u003cu003e9_282 == null)
+ {
+ u003cu003e9_282 = (Item x) => x.get_Descricao();
+ ItemServico.u003cu003ec.u003cu003e9__28_2 = u003cu003e9_282;
+ }
+ observableCollection = new ObservableCollection<Item>(items2.ThenBy<Item, string>(u003cu003e9_282));
+ return observableCollection;
+ }
+ }
+ continue;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 52, num, ids, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Item>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(long id, StatusItem status)
+ {
+ int num = 3;
+ ObservableCollection<Item> observableCollection1 = await Task.Run<ObservableCollection<Item>>(() => {
+ ObservableCollection<Item> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Item> items = read.get_ItemRepository().FindItens(id, status);
+ if (items != null)
+ {
+ List<Item> items1 = items;
+ Func<Item, int?> u003cu003e9_291 = ItemServico.u003cu003ec.u003cu003e9__29_1;
+ if (u003cu003e9_291 == null)
+ {
+ u003cu003e9_291 = (Item x) => x.get_Ordem();
+ ItemServico.u003cu003ec.u003cu003e9__29_1 = u003cu003e9_291;
+ }
+ IOrderedEnumerable<Item> items2 = items1.OrderBy<Item, int?>(u003cu003e9_291);
+ Func<Item, string> u003cu003e9_292 = ItemServico.u003cu003ec.u003cu003e9__29_2;
+ if (u003cu003e9_292 == null)
+ {
+ u003cu003e9_292 = (Item x) => x.get_Descricao();
+ ItemServico.u003cu003ec.u003cu003e9__29_2 = u003cu003e9_292;
+ }
+ observableCollection = new ObservableCollection<Item>(items2.ThenBy<Item, string>(u003cu003e9_292));
+ return observableCollection;
+ }
+ }
+ continue;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 53, num, new { id = id, status = status }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Item>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(List<Documento> documento)
+ {
+ int num = 3;
+ ObservableCollection<Item> observableCollection1 = await Task.Run<ObservableCollection<Item>>(() => {
+ ObservableCollection<Item> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Item> items = read.get_ItemRepository().FindItens(documento);
+ if (items != null)
+ {
+ List<Item> items1 = items;
+ Func<Item, int?> u003cu003e9_301 = ItemServico.u003cu003ec.u003cu003e9__30_1;
+ if (u003cu003e9_301 == null)
+ {
+ u003cu003e9_301 = (Item x) => x.get_Ordem();
+ ItemServico.u003cu003ec.u003cu003e9__30_1 = u003cu003e9_301;
+ }
+ IOrderedEnumerable<Item> items2 = items1.OrderBy<Item, int?>(u003cu003e9_301);
+ Func<Item, string> u003cu003e9_302 = ItemServico.u003cu003ec.u003cu003e9__30_2;
+ if (u003cu003e9_302 == null)
+ {
+ u003cu003e9_302 = (Item x) => x.get_Descricao();
+ ItemServico.u003cu003ec.u003cu003e9__30_2 = u003cu003e9_302;
+ }
+ observableCollection = new ObservableCollection<Item>(items2.ThenBy<Item, string>(u003cu003e9_302));
+ return observableCollection;
+ }
+ }
+ continue;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 305, num, documento, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Item>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(long id)
+ {
+ int num = 3;
+ ObservableCollection<Item> observableCollection1 = await Task.Run<ObservableCollection<Item>>(() => {
+ ObservableCollection<Item> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Item> items = read.get_ItemRepository().FindItens(id);
+ if (items != null)
+ {
+ List<Item> items1 = items;
+ Func<Item, int?> u003cu003e9_311 = ItemServico.u003cu003ec.u003cu003e9__31_1;
+ if (u003cu003e9_311 == null)
+ {
+ u003cu003e9_311 = (Item x) => x.get_Ordem();
+ ItemServico.u003cu003ec.u003cu003e9__31_1 = u003cu003e9_311;
+ }
+ IOrderedEnumerable<Item> items2 = items1.OrderBy<Item, int?>(u003cu003e9_311);
+ Func<Item, string> u003cu003e9_312 = ItemServico.u003cu003ec.u003cu003e9__31_2;
+ if (u003cu003e9_312 == null)
+ {
+ u003cu003e9_312 = (Item x) => x.get_Descricao();
+ ItemServico.u003cu003ec.u003cu003e9__31_2 = u003cu003e9_312;
+ }
+ observableCollection = new ObservableCollection<Item>(items2.ThenBy<Item, string>(u003cu003e9_312));
+ return observableCollection;
+ }
+ }
+ continue;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 53, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Item>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<Fipe> BuscarModelo(string fipe)
+ {
+ Fipe fipe1;
+ try
+ {
+ fipe1 = await this.FipeCode(fipe);
+ }
+ catch (Exception exception)
+ {
+ fipe1 = null;
+ }
+ return fipe1;
+ }
+
+ public async Task<List<Fipe>> BuscarPorModelo(string modelo)
+ {
+ List<Fipe> fipes;
+ try
+ {
+ fipes = await this.FipeModel(modelo);
+ }
+ catch (Exception exception)
+ {
+ fipes = null;
+ }
+ return fipes;
+ }
+
+ public async Task<int> BuscarProximoItem(long id)
+ {
+ int num1 = 3;
+ int num2 = await Task.Run<int>(() => {
+ int num;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ num = read.get_ItemRepository().FindNextItem(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 54, num1, id, true);
+ continue;
+ }
+ return num;
+ }
+ return 0;
+ });
+ return num2;
+ }
+
+ public async Task<List<TitularesVida>> BuscaTitularesVida(long id)
+ {
+ int num = 3;
+ List<TitularesVida> titularesVidas1 = await Task.Run<List<TitularesVida>>(() => {
+ List<TitularesVida> titularesVidas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ titularesVidas = read.get_TitularesVidaRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 61, num, id, true);
+ continue;
+ }
+ return titularesVidas;
+ }
+ return new List<TitularesVida>();
+ });
+ return titularesVidas1;
+ }
+
+ public async Task<Vida> BuscaVida(long id)
+ {
+ int num = 3;
+ Vida vida1 = await Task.Run<Vida>(() => {
+ Vida vida;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ vida = read.get_VidaRepository().Find(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 60, num, id, true);
+ continue;
+ }
+ return vida;
+ }
+ return new Vida();
+ });
+ return vida1;
+ }
+
+ public async Task<Item> Cancelar(Item item, string descricao, long idDocumento)
+ {
+ Item item1 = await Task.Run<Item>(() => {
+ Item item2;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ item = commited.get_ItemRepository().FindById(item.get_Id());
+ item.set_Cancelado(true);
+ item.set_Status(descricao);
+ item.set_IdDocumentoCancelado(new long?(idDocumento));
+ item = commited.get_ItemRepository().Merge(item);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] strArrays = new string[] { string.Format("O USUÁRIO {0} CANCELOU, EM {1}, O ITEM DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? "");
+ strArrays[4] = "', OBSERVAÇÃO: '";
+ strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? "");
+ strArrays[6] = "', STATUS: '";
+ strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? "");
+ strArrays[8] = "' - ";
+ strArrays[9] = descricao;
+ strArrays[10] = ".";
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(item.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_201 = ItemServico.u003cu003ec.u003cu003e9__20_1;
+ if (u003cu003e9_201 == null)
+ {
+ u003cu003e9_201 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__20_1 = u003cu003e9_201;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_201);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ item2 = item;
+ }
+ }
+ catch (Exception exception)
+ {
+ item2 = null;
+ }
+ return item2;
+ });
+ return item1;
+ }
+
+ public async Task<int> ChecarQuantidade(long idDocumento)
+ {
+ int num1 = await Task.Run<int>(() => {
+ int num;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ num = read.get_ItemRepository().ChecarQuantidade(idDocumento);
+ }
+ }
+ catch
+ {
+ num = 0;
+ }
+ return num;
+ });
+ return num1;
+ }
+
+ public async Task Delete(Item item)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ await Task.Run(() => {
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().Delete(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] strArrays = new string[] { string.Format("O USUÁRIO {0} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? "");
+ strArrays[4] = "', OBSERVAÇÃO: '";
+ strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? "");
+ strArrays[6] = "', STATUS: '";
+ strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? "");
+ strArrays[8] = "'.";
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(item.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_241 = ItemServico.u003cu003ec.u003cu003e9__24_1;
+ if (u003cu003e9_241 == null)
+ {
+ u003cu003e9_241 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__24_1 = u003cu003e9_241;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_241);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 274, num, item, true);
+ }
+ }
+ });
+ }
+
+ public async Task DeleteRange(List<Item> itens, long ramo)
+ {
+ if (itens != null && itens.Count != 0)
+ {
+ int num2 = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ await Task.Run(() => {
+ TipoTela tipoTela;
+ string str;
+ while (num2 > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ICoberturaRepository coberturaRepository = commited.get_CoberturaRepository();
+ List<Item> items = itens;
+ Func<Item, long> u003cu003e9_251 = ItemServico.u003cu003ec.u003cu003e9__25_1;
+ if (u003cu003e9_251 == null)
+ {
+ u003cu003e9_251 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_1 = u003cu003e9_251;
+ }
+ coberturaRepository.DeleteRange(items.Select<Item, long>(u003cu003e9_251).ToList<long>());
+ IControleSinistroRepository controleSinistroRepository = commited.get_ControleSinistroRepository();
+ List<Item> items1 = itens;
+ Func<Item, long> u003cu003e9_252 = ItemServico.u003cu003ec.u003cu003e9__25_2;
+ if (u003cu003e9_252 == null)
+ {
+ u003cu003e9_252 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_2 = u003cu003e9_252;
+ }
+ controleSinistroRepository.DeleteRange(items1.Select<Item, long>(u003cu003e9_252).ToList<long>());
+ long num = ramo;
+ if (num > (long)36)
+ {
+ if (num == (long)37)
+ {
+ goto Label0;
+ }
+ if (num == (long)53)
+ {
+ goto Label1;
+ }
+ }
+ else
+ {
+ long num1 = num - (long)1;
+ if (num1 <= (long)19)
+ {
+ switch ((uint)num1)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 14:
+ case 17:
+ {
+ IPatrimonialRepository patrimonialRepository = commited.get_PatrimonialRepository();
+ List<Item> items2 = itens;
+ Func<Item, long> u003cu003e9_254 = ItemServico.u003cu003ec.u003cu003e9__25_4;
+ if (u003cu003e9_254 == null)
+ {
+ u003cu003e9_254 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_4 = u003cu003e9_254;
+ }
+ patrimonialRepository.DeleteRange(items2.Select<Item, long>(u003cu003e9_254).ToList<long>());
+ tipoTela = 3;
+ goto Label2;
+ }
+ case 3:
+ case 7:
+ case 10:
+ case 11:
+ case 13:
+ case 15:
+ case 16:
+ case 18:
+ {
+ goto Label3;
+ }
+ case 4:
+ {
+ goto Label0;
+ }
+ case 5:
+ case 6:
+ case 8:
+ case 9:
+ {
+ goto Label1;
+ }
+ case 12:
+ {
+ IAeronauticoRepository aeronauticoRepository = commited.get_AeronauticoRepository();
+ List<Item> items3 = itens;
+ Func<Item, long> u003cu003e9_255 = ItemServico.u003cu003ec.u003cu003e9__25_5;
+ if (u003cu003e9_255 == null)
+ {
+ u003cu003e9_255 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_5 = u003cu003e9_255;
+ }
+ aeronauticoRepository.DeleteRange(items3.Select<Item, long>(u003cu003e9_255).ToList<long>());
+ tipoTela = 3;
+ goto Label2;
+ }
+ case 19:
+ {
+ IGranizoRepository granizoRepository = commited.get_GranizoRepository();
+ List<Item> items4 = itens;
+ Func<Item, long> u003cu003e9_256 = ItemServico.u003cu003ec.u003cu003e9__25_6;
+ if (u003cu003e9_256 == null)
+ {
+ u003cu003e9_256 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_6 = u003cu003e9_256;
+ }
+ granizoRepository.DeleteRange(items4.Select<Item, long>(u003cu003e9_256).ToList<long>());
+ tipoTela = 3;
+ goto Label2;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (num != (long)36)
+ {
+ goto Label3;
+ }
+ IConsorcioRepository consorcioRepository = commited.get_ConsorcioRepository();
+ List<Item> items5 = itens;
+ Func<Item, long> u003cu003e9_258 = ItemServico.u003cu003ec.u003cu003e9__25_8;
+ if (u003cu003e9_258 == null)
+ {
+ u003cu003e9_258 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_8 = u003cu003e9_258;
+ }
+ consorcioRepository.DeleteRange(items5.Select<Item, long>(u003cu003e9_258).ToList<long>());
+ tipoTela = 3;
+ goto Label2;
+ }
+ Label3:
+ IRiscosDiversosRepository riscosDiversosRepository = commited.get_RiscosDiversosRepository();
+ List<Item> items6 = itens;
+ Func<Item, long> u003cu003e9_259 = ItemServico.u003cu003ec.u003cu003e9__25_9;
+ if (u003cu003e9_259 == null)
+ {
+ u003cu003e9_259 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_9 = u003cu003e9_259;
+ }
+ riscosDiversosRepository.DeleteRange(items6.Select<Item, long>(u003cu003e9_259).ToList<long>());
+ tipoTela = 3;
+ Label2:
+ IItemRepository itemRepository = commited.get_ItemRepository();
+ List<Item> items7 = itens;
+ Func<Item, long> u003cu003e9_2510 = ItemServico.u003cu003ec.u003cu003e9__25_10;
+ if (u003cu003e9_2510 == null)
+ {
+ u003cu003e9_2510 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_10 = u003cu003e9_2510;
+ }
+ itemRepository.DeleteRange(items7.Select<Item, long>(u003cu003e9_2510).ToList<long>());
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ List<Item>.Enumerator enumerator = itens.GetEnumerator();
+ try
+ {
+ if (enumerator.MoveNext())
+ {
+ Item current = enumerator.Current;
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] strArrays = new string[] { string.Format("O USUÁRIO {0} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", current.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(current.get_Descricao()) ? "" : current.get_Descricao() ?? "");
+ strArrays[4] = "', OBSERVAÇÃO: '";
+ strArrays[5] = (string.IsNullOrWhiteSpace(current.get_Observacao()) ? "" : current.get_Observacao() ?? "");
+ strArrays[6] = "', STATUS: '";
+ strArrays[7] = (string.IsNullOrWhiteSpace(current.get_Status()) ? "" : current.get_Status() ?? "");
+ strArrays[8] = "'";
+ strArrays[9] = string.Format(", RAMO: '{0}'.", ramo);
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(current.get_Id());
+ registroLog.set_Tela(tipoTela);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_2511 = ItemServico.u003cu003ec.u003cu003e9__25_11;
+ if (u003cu003e9_2511 == null)
+ {
+ u003cu003e9_2511 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__25_11 = u003cu003e9_2511;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_2511);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ break;
+ }
+ }
+ finally
+ {
+ ((IDisposable)enumerator).Dispose();
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ num2 = base.Registrar(exception, 275, num2, itens, true);
+ }
+ }
+ return;
+ Label0:
+ IAutoRepository autoRepository = commited.get_AutoRepository();
+ List<Item> items8 = itens;
+ Func<Item, long> u003cu003e9_253 = ItemServico.u003cu003ec.u003cu003e9__25_3;
+ if (u003cu003e9_253 == null)
+ {
+ u003cu003e9_253 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_3 = u003cu003e9_253;
+ }
+ autoRepository.DeleteRange(items8.Select<Item, long>(u003cu003e9_253).ToList<long>());
+ tipoTela = 3;
+ goto Label2;
+ Label1:
+ IVidaRepository vidaRepository = commited.get_VidaRepository();
+ List<Item> items9 = itens;
+ Func<Item, long> u003cu003e9_257 = ItemServico.u003cu003ec.u003cu003e9__25_7;
+ if (u003cu003e9_257 == null)
+ {
+ u003cu003e9_257 = (Item x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__25_7 = u003cu003e9_257;
+ }
+ vidaRepository.DeleteRange(items9.Select<Item, long>(u003cu003e9_257).ToList<long>());
+ tipoTela = 3;
+ goto Label2;
+ });
+ }
+ }
+
+ public async Task<bool> DeleteTitulares(List<TitularesVida> titularesVidas)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ITitularesVidaRepository titularesVidaRepository = commited.get_TitularesVidaRepository();
+ List<TitularesVida> titularesVidas1 = titularesVidas;
+ Func<TitularesVida, long> u003cu003e9_331 = ItemServico.u003cu003ec.u003cu003e9__33_1;
+ if (u003cu003e9_331 == null)
+ {
+ u003cu003e9_331 = (TitularesVida x) => x.get_Id();
+ ItemServico.u003cu003ec.u003cu003e9__33_1 = u003cu003e9_331;
+ }
+ titularesVidaRepository.DeleteRange(titularesVidas1.Select<TitularesVida, long>(u003cu003e9_331).ToList<long>());
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 276, num, titularesVidas, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ private async Task<string> FipeAuthentication()
+ {
+ string str;
+ string empty;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string str1 = DateTime.Now.ToString("yyyy-MM-dd");
+ string base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}", ApplicationHelper.IdFornecedor, "bbbf4f03-01fc-4300-b430-33e007753578", str1)));
+ Uri apiFipe = Address.get_ApiFipe();
+ string[] strArrays = new string[] { "api" };
+ Uri uri = apiFipe.Append(strArrays);
+ string[] strArrays1 = new string[] { "auth" };
+ Uri uri1 = uri.Append(strArrays1);
+ HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(uri1, base64String.ToHttpContent<string>(null, "application/json"));
+ if (httpResponseMessage.get_IsSuccessStatusCode())
+ {
+ JToken item = httpResponseMessage.get_Content().ToJObject().get_Item("token");
+ if (item != null)
+ {
+ empty = item.ToString();
+ }
+ else
+ {
+ empty = null;
+ }
+ }
+ else
+ {
+ empty = string.Empty;
+ }
+ str = empty;
+ }
+ return str;
+ }
+
+ private async Task<Fipe> FipeCode(string code)
+ {
+ Fipe fipe;
+ Fipe fipe1;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string str = await this.FipeAuthentication();
+ if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str))
+ {
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str));
+ }
+ Uri apiFipe = Address.get_ApiFipe();
+ string[] strArrays = new string[] { "v1" };
+ Uri uri = apiFipe.Append(strArrays);
+ string[] strArrays1 = new string[] { "fipe" };
+ Uri uri1 = uri.Append(strArrays1).AddQuery<string>("fipeCode", code);
+ HttpResponseMessage async = await httpClient.GetAsync(uri1);
+ fipe1 = (!async.get_IsSuccessStatusCode() ? new Fipe() : JsonConvert.DeserializeObject<Fipe>(await async.get_Content().ReadAsStringAsync()));
+ fipe = fipe1;
+ }
+ return fipe;
+ }
+
+ private async Task<List<Fipe>> FipeModel(string model)
+ {
+ List<Fipe> fipes;
+ List<Fipe> fipes1;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string str = await this.FipeAuthentication();
+ if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str))
+ {
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str));
+ }
+ Uri apiFipe = Address.get_ApiFipe();
+ string[] strArrays = new string[] { "v1" };
+ Uri uri = apiFipe.Append(strArrays);
+ string[] strArrays1 = new string[] { "fipe" };
+ Uri uri1 = uri.Append(strArrays1);
+ string[] strArrays2 = new string[] { "modelo" };
+ Uri uri2 = uri1.Append(strArrays2);
+ string[] strArrays3 = new string[] { model };
+ Uri uri3 = uri2.Append(strArrays3);
+ HttpResponseMessage async = await httpClient.GetAsync(uri3);
+ fipes1 = (!async.get_IsSuccessStatusCode() ? new List<Fipe>() : JsonConvert.DeserializeObject<List<Fipe>>(await async.get_Content().ReadAsStringAsync()));
+ fipes = fipes1;
+ }
+ return fipes;
+ }
+
+ private static async Task<T> Get<T>(string command)
+ where T : class
+ {
+ Uri uri = new Uri(command);
+ ConfiguredTaskAwaitable<HttpResponseMessage> configuredTaskAwaitable = (new HttpClient()).GetAsync(uri).ConfigureAwait(false);
+ HttpResponseMessage httpResponseMessage = await configuredTaskAwaitable;
+ if (httpResponseMessage.get_StatusCode() != HttpStatusCode.OK)
+ {
+ throw new Exception(string.Concat("Api connection Error ", Environment.NewLine, " ", command), null);
+ }
+ T t = JsonConvert.DeserializeObject<T>(httpResponseMessage.get_Content().ReadAsStringAsync().Result);
+ return t;
+ }
+
+ public async Task<Item> Reativar(Item item, string descricao)
+ {
+ Item item1 = await Task.Run<Item>(() => {
+ Item item2;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ item = commited.get_ItemRepository().FindById(item.get_Id());
+ item.set_Cancelado(false);
+ long? nullable = null;
+ item.set_Substituido(nullable);
+ nullable = null;
+ item.set_IdDocumentoCancelado(nullable);
+ item.set_Status(descricao);
+ item = commited.get_ItemRepository().Merge(item);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] strArrays = new string[] { string.Format("O USUÁRIO {0} REATIVOU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? "");
+ strArrays[4] = "', OBSERVAÇÃO: '";
+ strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? "");
+ strArrays[6] = "', STATUS: '";
+ strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? "");
+ strArrays[8] = "' - ";
+ strArrays[9] = descricao;
+ strArrays[10] = ".";
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(item.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_211 = ItemServico.u003cu003ec.u003cu003e9__21_1;
+ if (u003cu003e9_211 == null)
+ {
+ u003cu003e9_211 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_211);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ item2 = item;
+ }
+ }
+ catch (Exception exception)
+ {
+ item2 = null;
+ }
+ return item2;
+ });
+ return item1;
+ }
+
+ public async Task<Item> Save(Item item)
+ {
+ Action<Cobertura> action3 = null;
+ Action<Cobertura> action4 = null;
+ int num3 = 3;
+ Item item2 = item;
+ base.Sucesso = true;
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Item item3 = await Task.Run<Item>(() => {
+ bool id;
+ Auto auto;
+ Vida vida;
+ RiscosDiversos riscosDiversos;
+ Action<Cobertura> action;
+ Item item4;
+ string str1;
+ TipoTela tipoTela;
+ Label5:
+ while (num3 > 0)
+ {
+ item = item2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ id = item.get_Id() == (long)0;
+ auto = item.get_Auto();
+ Patrimonial patrimonial = item.get_Patrimonial();
+ Granizo granizo = item.get_Granizo();
+ Aeronautico aeronautico = item.get_Aeronautico();
+ vida = item.get_Vida();
+ riscosDiversos = item.get_RiscosDiversos();
+ Consorcio consorcio = item.get_Consorcio();
+ tipoTela = 3;
+ IList<Cobertura> coberturas = item.get_Coberturas();
+ item.set_StatusInclusao((item.get_Documento().get_Tipo() == 0 ? "ITEM DA APÓLICE" : "ITEM DO ENDOSSO"));
+ if (id)
+ {
+ item.set_Coberturas(null);
+ }
+ if (!id && coberturas != null && coberturas.Count > 0)
+ {
+ try
+ {
+ List<Cobertura> list = coberturas.ToList<Cobertura>();
+ Action<Cobertura> u003cu003e9_2 = action3;
+ if (u003cu003e9_2 == null)
+ {
+ Action<Cobertura> action1 = (Cobertura x) => x.set_Item(item);
+ action = action1;
+ action3 = action1;
+ u003cu003e9_2 = action;
+ }
+ list.ForEach(u003cu003e9_2);
+ IList<Cobertura> coberturas1 = coberturas;
+ Func<Cobertura, bool> u003cu003e9_233 = ItemServico.u003cu003ec.u003cu003e9__23_3;
+ if (u003cu003e9_233 == null)
+ {
+ u003cu003e9_233 = (Cobertura c) => c.get_Id() == (long)0;
+ ItemServico.u003cu003ec.u003cu003e9__23_3 = u003cu003e9_233;
+ }
+ List<Cobertura> list1 = coberturas1.Where<Cobertura>(u003cu003e9_233).ToList<Cobertura>();
+ if (list1.Count > 0)
+ {
+ list1 = commited.get_CoberturaRepository().AddRange(list1.ToList<Cobertura>());
+ list1.ForEach((Cobertura c) => {
+ string str;
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(0);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(c, jsonSerializerSetting));
+ registroLog.set_EntidadeId(c.get_Id());
+ registroLog.set_Tela(tipoTela);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_237 = ItemServico.u003cu003ec.u003cu003e9__23_7;
+ if (u003cu003e9_237 == null)
+ {
+ u003cu003e9_237 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__23_7 = u003cu003e9_237;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_237);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ }
+ IList<Cobertura> coberturas2 = coberturas;
+ Func<Cobertura, bool> u003cu003e9_235 = ItemServico.u003cu003ec.u003cu003e9__23_5;
+ if (u003cu003e9_235 == null)
+ {
+ u003cu003e9_235 = (Cobertura c) => c.get_Id() > (long)0;
+ ItemServico.u003cu003ec.u003cu003e9__23_5 = u003cu003e9_235;
+ }
+ List<Cobertura> list2 = coberturas2.Where<Cobertura>(u003cu003e9_235).ToList<Cobertura>();
+ if (list2.Count > 0)
+ {
+ list2 = commited.get_CoberturaRepository().MergeRange(list2);
+ list2.ForEach((Cobertura c) => {
+ string str;
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(c, jsonSerializerSetting));
+ registroLog.set_EntidadeId(c.get_Id());
+ registroLog.set_Tela(tipoTela);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_238 = ItemServico.u003cu003ec.u003cu003e9__23_8;
+ if (u003cu003e9_238 == null)
+ {
+ u003cu003e9_238 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__23_8 = u003cu003e9_238;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_238);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ }
+ list2.AddRange(list1);
+ item.set_Coberturas(list2);
+ }
+ catch (Exception exception)
+ {
+ num3 = base.Registrar(exception, 208, num3, coberturas, true);
+ continue;
+ }
+ }
+ if (!item.get_Documento().get_Sinistro() && item.get_Sinistrado() && item.get_Documento().get_Situacao() == 2 && item.get_Status() != null && !item.get_Status().Contains("ALTERADO"))
+ {
+ item.set_Sinistrado(false);
+ }
+ item = (id ? commited.get_ItemRepository().SaveOrUpdate(item) : commited.get_ItemRepository().Merge(item));
+ long num = item.get_Documento().get_Controle().get_Ramo().get_Id();
+ if (num > (long)38)
+ {
+ if (num == (long)47 || num == (long)53 || num == (long)66)
+ {
+ goto Label0;
+ }
+ goto Label1;
+ }
+ else
+ {
+ long num1 = num - (long)1;
+ if (num1 <= (long)19)
+ {
+ switch ((uint)num1)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 14:
+ case 17:
+ {
+ goto Label3;
+ }
+ case 3:
+ case 7:
+ case 10:
+ case 11:
+ case 13:
+ case 15:
+ case 16:
+ case 18:
+ {
+ goto Label1;
+ }
+ case 4:
+ {
+ goto Label4;
+ }
+ case 5:
+ case 6:
+ case 8:
+ case 9:
+ {
+ goto Label0;
+ }
+ case 12:
+ {
+ try
+ {
+ if (aeronautico != null)
+ {
+ aeronautico.set_Item(item);
+ aeronautico = (id ? commited.get_AeronauticoRepository().SaveOrUpdate(aeronautico) : commited.get_AeronauticoRepository().Merge(aeronautico));
+ item.set_Aeronautico(aeronautico);
+ tipoTela = 3;
+ goto Label2;
+ }
+ else
+ {
+ goto Label2;
+ }
+ }
+ catch (Exception exception1)
+ {
+ num3 = base.Registrar(exception1, 202, num3, aeronautico, true);
+ continue;
+ }
+ break;
+ }
+ case 19:
+ {
+ try
+ {
+ if (granizo != null)
+ {
+ granizo.set_Item(item);
+ granizo = (id ? commited.get_GranizoRepository().SaveOrUpdate(granizo) : commited.get_GranizoRepository().Merge(granizo));
+ item.set_Granizo(granizo);
+ tipoTela = 3;
+ goto Label2;
+ }
+ else
+ {
+ goto Label2;
+ }
+ }
+ catch (Exception exception2)
+ {
+ num3 = base.Registrar(exception2, 206, num3, granizo, true);
+ continue;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (num != (long)30)
+ {
+ long num2 = num - (long)36;
+ if (num2 <= (long)2)
+ {
+ switch ((uint)num2)
+ {
+ case 0:
+ {
+ try
+ {
+ if (consorcio != null)
+ {
+ consorcio.set_Item(item);
+ consorcio = (id ? commited.get_ConsorcioRepository().SaveOrUpdate(consorcio) : commited.get_ConsorcioRepository().Merge(consorcio));
+ item.set_Consorcio(consorcio);
+ tipoTela = 3;
+ goto Label2;
+ }
+ else
+ {
+ goto Label2;
+ }
+ }
+ catch (Exception exception3)
+ {
+ num3 = base.Registrar(exception3, 331, num3, consorcio, true);
+ continue;
+ }
+ break;
+ }
+ case 1:
+ {
+ goto Label4;
+ }
+ case 2:
+ {
+ break;
+ }
+ default:
+ {
+ goto Label1;
+ }
+ }
+ }
+ else
+ {
+ goto Label1;
+ }
+ }
+ Label3:
+ try
+ {
+ if (patrimonial != null)
+ {
+ patrimonial.set_Item(item);
+ patrimonial = (id ? commited.get_PatrimonialRepository().SaveOrUpdate(patrimonial) : commited.get_PatrimonialRepository().Merge(patrimonial));
+ item.set_Patrimonial(patrimonial);
+ tipoTela = 3;
+ }
+ }
+ catch (Exception exception4)
+ {
+ num3 = base.Registrar(exception4, 196, num3, patrimonial, true);
+ continue;
+ }
+ }
+ Label2:
+ if (id && coberturas != null && coberturas.Count > 0)
+ {
+ try
+ {
+ item.set_Coberturas(new List<Cobertura>());
+ List<Cobertura> list3 = coberturas.ToList<Cobertura>();
+ Action<Cobertura> u003cu003e9_1 = action4;
+ if (u003cu003e9_1 == null)
+ {
+ Action<Cobertura> action2 = (Cobertura x) => {
+ x.set_Id((long)0);
+ x.set_Item(item);
+ };
+ action = action2;
+ action4 = action2;
+ u003cu003e9_1 = action;
+ }
+ list3.ForEach(u003cu003e9_1);
+ coberturas = commited.get_CoberturaRepository().AddRange(coberturas.ToList<Cobertura>());
+ item.set_Coberturas(coberturas);
+ }
+ catch (Exception exception5)
+ {
+ num3 = base.Registrar(exception5, 208, num3, coberturas, true);
+ continue;
+ }
+ }
+ TipoAcao tipoAcao = (id ? 0 : 1);
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(tipoAcao);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings();
+ jsonSerializerSetting1.set_ReferenceLoopHandling(1);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting1));
+ registroLog1.set_EntidadeId(item.get_Id());
+ registroLog1.set_Tela(tipoTela);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] pAddressArray = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_239 = ItemServico.u003cu003ec.u003cu003e9__23_9;
+ if (u003cu003e9_239 == null)
+ {
+ u003cu003e9_239 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__23_9 = u003cu003e9_239;
+ }
+ IPAddress pAddress1 = ((IEnumerable<IPAddress>)pAddressArray).FirstOrDefault<IPAddress>(u003cu003e9_239);
+ if (pAddress1 != null)
+ {
+ str1 = pAddress1.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog1.set_Ip(str1);
+ base.SaveLog(registroLog1, commited);
+ commited.Commit();
+ item4 = item;
+ }
+ }
+ catch (Exception exception6)
+ {
+ num3 = base.Registrar(exception6, 195, num3, item, true);
+ continue;
+ }
+ return item4;
+ }
+ return item2;
+ Label0:
+ try
+ {
+ if (vida != null)
+ {
+ vida.set_Item(item);
+ vida = (id ? commited.get_VidaRepository().SaveOrUpdate(vida) : commited.get_VidaRepository().Merge(vida));
+ item.set_Vida(vida);
+ tipoTela = 3;
+ goto Label2;
+ }
+ else
+ {
+ goto Label2;
+ }
+ }
+ catch (Exception exception7)
+ {
+ num3 = base.Registrar(exception7, 200, num3, vida, true);
+ goto Label5;
+ }
+ Label1:
+ try
+ {
+ if (riscosDiversos != null)
+ {
+ riscosDiversos.set_Item(item);
+ riscosDiversos = (id ? commited.get_RiscosDiversosRepository().SaveOrUpdate(riscosDiversos) : commited.get_RiscosDiversosRepository().Merge(riscosDiversos));
+ item.set_RiscosDiversos(riscosDiversos);
+ tipoTela = 3;
+ goto Label2;
+ }
+ else
+ {
+ goto Label2;
+ }
+ }
+ catch (Exception exception8)
+ {
+ num3 = base.Registrar(exception8, 198, num3, riscosDiversos, true);
+ goto Label5;
+ }
+ Label4:
+ try
+ {
+ if (auto != null)
+ {
+ auto.set_Item(item);
+ auto = (id ? commited.get_AutoRepository().SaveOrUpdate(auto) : commited.get_AutoRepository().Merge(auto));
+ item.set_Auto(auto);
+ tipoTela = 3;
+ goto Label2;
+ }
+ else
+ {
+ goto Label2;
+ }
+ }
+ catch (Exception exception9)
+ {
+ num3 = base.Registrar(exception9, 204, num3, auto, true);
+ goto Label5;
+ }
+ });
+ return item3;
+ }
+
+ public async Task SaveRange(List<Item> itens)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ await Task.Run(() => {
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ itens.ForEach((Item x) => commited.get_ItemRepository().Merge(x));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (Item iten in itens)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(iten, jsonSerializerSetting));
+ registroLog.set_EntidadeId(iten.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_272 = ItemServico.u003cu003ec.u003cu003e9__27_2;
+ if (u003cu003e9_272 == null)
+ {
+ u003cu003e9_272 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__27_2 = u003cu003e9_272;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_272);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ commited.Commit();
+ this.Sucesso = true;
+ break;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 276, num, itens, true);
+ }
+ }
+ });
+ }
+
+ public async Task<List<TitularesVida>> SaveTitulares(List<TitularesVida> titularesVidas)
+ {
+ int num = 3;
+ List<TitularesVida> titularesVidas5 = await Task.Run<List<TitularesVida>>(() => {
+ List<TitularesVida> titularesVidas6;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ List<TitularesVida> titularesVidas1 = titularesVidas;
+ Action<TitularesVida> u003cu003e9_321 = ItemServico.u003cu003ec.u003cu003e9__32_1;
+ if (u003cu003e9_321 == null)
+ {
+ u003cu003e9_321 = (TitularesVida x) => {
+ if (x.get_Tipo().GetValueOrDefault() != 2 && x.get_Dependente() != null)
+ {
+ x.set_Dependente(null);
+ }
+ };
+ ItemServico.u003cu003ec.u003cu003e9__32_1 = u003cu003e9_321;
+ }
+ titularesVidas1.ForEach(u003cu003e9_321);
+ List<TitularesVida> titularesVidas2 = titularesVidas;
+ Func<TitularesVida, bool> u003cu003e9_322 = ItemServico.u003cu003ec.u003cu003e9__32_2;
+ if (u003cu003e9_322 == null)
+ {
+ u003cu003e9_322 = (TitularesVida x) => {
+ if (x.get_Id() != 0)
+ {
+ return false;
+ }
+ return x.get_Tipo().GetValueOrDefault() != 2;
+ };
+ ItemServico.u003cu003ec.u003cu003e9__32_2 = u003cu003e9_322;
+ }
+ titularesVidas2.Where<TitularesVida>(u003cu003e9_322).ToList<TitularesVida>().ForEach((TitularesVida x) => titularesVidas.First<TitularesVida>((TitularesVida y) => (object)y == (object)x).set_Id(commited.get_TitularesVidaRepository().SaveOrUpdate(x).get_Id()));
+ List<TitularesVida> titularesVidas3 = titularesVidas;
+ Func<TitularesVida, bool> u003cu003e9_324 = ItemServico.u003cu003ec.u003cu003e9__32_4;
+ if (u003cu003e9_324 == null)
+ {
+ u003cu003e9_324 = (TitularesVida x) => {
+ if (x.get_Id() != 0)
+ {
+ return false;
+ }
+ return x.get_Tipo().GetValueOrDefault() == 2;
+ };
+ ItemServico.u003cu003ec.u003cu003e9__32_4 = u003cu003e9_324;
+ }
+ titularesVidas3.Where<TitularesVida>(u003cu003e9_324).ToList<TitularesVida>().ForEach((TitularesVida x) => titularesVidas.First<TitularesVida>((TitularesVida y) => (object)y == (object)x).set_Id(commited.get_TitularesVidaRepository().SaveOrUpdate(x).get_Id()));
+ List<TitularesVida> titularesVidas4 = titularesVidas;
+ Func<TitularesVida, bool> u003cu003e9_326 = ItemServico.u003cu003ec.u003cu003e9__32_6;
+ if (u003cu003e9_326 == null)
+ {
+ u003cu003e9_326 = (TitularesVida x) => x.get_Id() > (long)0;
+ ItemServico.u003cu003ec.u003cu003e9__32_6 = u003cu003e9_326;
+ }
+ titularesVidas4.Where<TitularesVida>(u003cu003e9_326).ToList<TitularesVida>().ForEach((TitularesVida x) => commited.get_TitularesVidaRepository().Merge(x));
+ commited.Commit();
+ this.Sucesso = true;
+ titularesVidas6 = titularesVidas;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 276, num, titularesVidas, true);
+ continue;
+ }
+ return titularesVidas6;
+ }
+ return new List<TitularesVida>();
+ });
+ return titularesVidas5;
+ }
+
+ public async Task<Item> Substituir(Item item, long substituido, string descricao)
+ {
+ Item item1 = await Task.Run<Item>(() => {
+ Item item2;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ item = commited.get_ItemRepository().FindById(item.get_Id());
+ item.set_Substituido(new long?(substituido));
+ item.set_Status(descricao);
+ item = commited.get_ItemRepository().Merge(item);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] strArrays = new string[] { string.Format("O USUÁRIO {0} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? "");
+ strArrays[4] = "', OBSERVAÇÃO: '";
+ strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? "");
+ strArrays[6] = "', STATUS: '";
+ strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? "");
+ strArrays[8] = "' - ";
+ strArrays[9] = descricao;
+ strArrays[10] = ".";
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(item.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_221 = ItemServico.u003cu003ec.u003cu003e9__22_1;
+ if (u003cu003e9_221 == null)
+ {
+ u003cu003e9_221 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ItemServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_221);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ item2 = item;
+ }
+ }
+ catch (Exception exception)
+ {
+ item2 = null;
+ }
+ return item2;
+ });
+ return item1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs new file mode 100644 index 0000000..2bd46f5 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/PatrimonialServico.cs @@ -0,0 +1,196 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class PatrimonialServico : BaseServico
+ {
+ public PatrimonialServico()
+ {
+ }
+
+ public async Task<List<PesquisaAvancada>> BuscarImobiliaria(string imobiliaria, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado)
+ {
+ List<PesquisaAvancada> pesquisaAvancadas1 = await Task.Run<List<PesquisaAvancada>>(() => {
+ List<PesquisaAvancada> pesquisaAvancadas;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ pesquisaAvancadas = read.get_PatrimonialRepository().FindImobiliaria(imobiliaria, status, vendedorVinculado);
+ }
+ }
+ catch (Exception exception)
+ {
+ pesquisaAvancadas = null;
+ }
+ return pesquisaAvancadas;
+ });
+ return pesquisaAvancadas1;
+ }
+
+ public async Task<List<PesquisaAvancada>> BuscarLocatario(string locatario, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado)
+ {
+ List<PesquisaAvancada> pesquisaAvancadas1 = await Task.Run<List<PesquisaAvancada>>(() => {
+ List<PesquisaAvancada> pesquisaAvancadas;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ pesquisaAvancadas = read.get_PatrimonialRepository().Findlocatario(locatario, status, vendedorVinculado);
+ }
+ }
+ catch (Exception exception)
+ {
+ pesquisaAvancadas = null;
+ }
+ return pesquisaAvancadas;
+ });
+ return pesquisaAvancadas1;
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_Patrimonial() != null && item.get_Patrimonial().get_Id() > (long)0)
+ {
+ commited.get_PatrimonialRepository().Delete(item.get_Patrimonial().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ Patrimonial patrimonial = item.get_Patrimonial();
+ id = (patrimonial != null ? patrimonial.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = PatrimonialServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PatrimonialServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 197, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Patrimonial> Save(Patrimonial patrimonial)
+ {
+ Patrimonial patrimonial2 = await Task.Run<Patrimonial>(() => {
+ Patrimonial patrimonial3;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (patrimonial.get_Id() == 0 ? 0 : 1);
+ patrimonial = (patrimonial.get_Id() == 0 ? commited.get_PatrimonialRepository().SaveOrUpdate(patrimonial) : commited.get_PatrimonialRepository().Merge(patrimonial));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Patrimonial patrimonial1 = patrimonial;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(patrimonial1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(patrimonial.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = PatrimonialServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PatrimonialServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_01);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ patrimonial3 = patrimonial;
+ }
+ }
+ catch (Exception exception)
+ {
+ patrimonial3 = null;
+ }
+ return patrimonial3;
+ });
+ return patrimonial2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs new file mode 100644 index 0000000..77873c3 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/RiscosDiversosServico.cs @@ -0,0 +1,156 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class RiscosDiversosServico : BaseServico
+ {
+ public RiscosDiversosServico()
+ {
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_RiscosDiversos() != null && item.get_RiscosDiversos().get_Id() > (long)0)
+ {
+ commited.get_RiscosDiversosRepository().Delete(item.get_RiscosDiversos().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ RiscosDiversos riscosDiversos = item.get_RiscosDiversos();
+ id = (riscosDiversos != null ? riscosDiversos.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = RiscosDiversosServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ RiscosDiversosServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 199, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<RiscosDiversos> Save(RiscosDiversos riscosdiversos)
+ {
+ RiscosDiversos riscosDiverso2 = await Task.Run<RiscosDiversos>(() => {
+ RiscosDiversos riscosDiverso;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (riscosdiversos.get_Id() == 0 ? 0 : 1);
+ riscosdiversos = (riscosdiversos.get_Id() == 0 ? commited.get_RiscosDiversosRepository().SaveOrUpdate(riscosdiversos) : commited.get_RiscosDiversosRepository().Merge(riscosdiversos));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ RiscosDiversos riscosDiverso1 = riscosdiversos;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(riscosDiverso1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(riscosdiversos.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = RiscosDiversosServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ RiscosDiversosServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_01);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ riscosDiverso = riscosdiversos;
+ }
+ }
+ catch (Exception exception)
+ {
+ riscosDiverso = null;
+ }
+ return riscosDiverso;
+ });
+ return riscosDiverso2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs new file mode 100644 index 0000000..3e03bfb --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/Itens/VidaServico.cs @@ -0,0 +1,156 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens
+{
+ internal class VidaServico : BaseServico
+ {
+ public VidaServico()
+ {
+ }
+
+ public async Task<bool> Delete(Item item)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ long id;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (item.get_Vida() != null && item.get_Vida().get_Id() > (long)0)
+ {
+ commited.get_VidaRepository().Delete(item.get_Vida().get_Id());
+ }
+ commited.get_CoberturaRepository().DeletebyItem(item.get_Id());
+ commited.get_ControleSinistroRepository().DeleteByItem(item.get_Id());
+ commited.get_ItemRepository().Delete(item.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Item item1 = item;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting));
+ Vida vida = item.get_Vida();
+ id = (vida != null ? vida.get_Id() : (long)0);
+ registroLog.set_EntidadeId(id);
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = VidaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VidaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 201, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Vida> Save(Vida vida)
+ {
+ Vida vida2 = await Task.Run<Vida>(() => {
+ Vida vida3;
+ string str;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (vida.get_Id() == 0 ? 0 : 1);
+ vida = (vida.get_Id() == 0 ? commited.get_VidaRepository().SaveOrUpdate(vida) : commited.get_VidaRepository().Merge(vida));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Vida vida1 = vida;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(vida1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(vida.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = VidaServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VidaServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_01);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ vida3 = vida;
+ }
+ }
+ catch (Exception exception)
+ {
+ vida3 = null;
+ }
+ return vida3;
+ });
+ return vida2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs new file mode 100644 index 0000000..21aa774 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilEmpresaServico.cs @@ -0,0 +1,179 @@ +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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class PerfilEmpresaServico : BaseServico
+ {
+ public PerfilEmpresaServico()
+ {
+ }
+
+ internal async Task<PerfilEmpresa> BuscarPerfis(long controleId)
+ {
+ int num = 3;
+ PerfilEmpresa perfilEmpresa1 = await Task.Run<PerfilEmpresa>(() => {
+ PerfilEmpresa perfilEmpresa;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ perfilEmpresa = read.get_PerfilEmpresaRepository().FindByControleId(controleId);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 46, num, controleId, true);
+ continue;
+ }
+ return perfilEmpresa;
+ }
+ return new PerfilEmpresa();
+ });
+ return perfilEmpresa1;
+ }
+
+ public async Task<bool> Delete(PerfilEmpresa perfil)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_PerfilEmpresaRepository().Delete(perfil.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ registroLog.set_Descricao(string.Concat(string.Format("O USUÁRIO {0} EXCLUIU O PERFIL, EM {1}, DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", perfil.get_Id())));
+ registroLog.set_EntidadeId(perfil.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = PerfilEmpresaServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PerfilEmpresaServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_21);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 213, num, perfil, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<PerfilEmpresa> Save(PerfilEmpresa perfil)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ PerfilEmpresa perfilEmpresa2 = perfil;
+ PerfilEmpresa perfilEmpresa3 = await Task.Run<PerfilEmpresa>(() => {
+ PerfilEmpresa perfilEmpresa;
+ string str;
+ while (num > 0)
+ {
+ perfil = perfilEmpresa2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (perfil.get_Id() == 0 ? 0 : 1);
+ perfil = (perfil.get_Id() == 0 ? commited.get_PerfilEmpresaRepository().SaveOrUpdate(perfil) : commited.get_PerfilEmpresaRepository().Merge(perfil));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ PerfilEmpresa perfilEmpresa1 = perfil;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(perfilEmpresa1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(perfil.get_Id());
+ registroLog.set_Tela(32);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = PerfilEmpresaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PerfilEmpresaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ perfilEmpresa = perfil;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 212, num, perfil, true);
+ continue;
+ }
+ return perfilEmpresa;
+ }
+ return perfilEmpresa2;
+ });
+ return perfilEmpresa3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs new file mode 100644 index 0000000..293af5c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/PerfilServico.cs @@ -0,0 +1,241 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+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.Generic;
+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;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class PerfilServico : BaseServico
+ {
+ public PerfilServico()
+ {
+ }
+
+ internal async Task<List<Perfil>> BuscarPerfis(long controleId)
+ {
+ int num = 3;
+ List<Perfil> perfils1 = await Task.Run<List<Perfil>>(() => {
+ List<Perfil> perfils;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ perfils = read.get_PerfilRepository().FindByControleId(controleId);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 46, num, controleId, true);
+ continue;
+ }
+ return perfils;
+ }
+ return new List<Perfil>();
+ });
+ return perfils1;
+ }
+
+ public async Task<bool> Delete(Perfil perfil)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ object obj;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_PerfilRepository().Delete(perfil.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ RegistroLog registroLog1 = registroLog;
+ string[] description = new string[47];
+ description[0] = string.Format("O USUÁRIO {0} EXCLUIU O PERFIL, EM {1}, DE ", Recursos.Usuario.get_Nome(), networkTime);
+ description[1] = string.Format("ID: '{0}'", perfil.get_Id());
+ description[2] = ", NOME: '";
+ description[3] = (string.IsNullOrWhiteSpace(perfil.get_Nome()) ? "" : perfil.get_Nome() ?? "");
+ description[4] = "', CPF: '";
+ description[5] = (string.IsNullOrWhiteSpace(perfil.get_Cpf()) ? "" : perfil.get_Cpf() ?? "");
+ description[6] = "', HABILITAÇÃO: '";
+ description[7] = (string.IsNullOrWhiteSpace(perfil.get_Habilitacao()) ? "" : perfil.get_Habilitacao() ?? "");
+ description[8] = "', TEMPO DE HABILITAÇÃO: '";
+ description[9] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_TempoHabilitacao());
+ description[10] = "', NASCIMENTO: '";
+ DateTime? nascimento = perfil.get_Nascimento();
+ if (!nascimento.HasValue)
+ {
+ obj = "";
+ }
+ else
+ {
+ nascimento = perfil.get_Nascimento();
+ obj = (nascimento.HasValue ? nascimento.GetValueOrDefault().ToShortDateString() : null) ?? "";
+ }
+ description[11] = (string)obj;
+ description[12] = "', SEXO: '";
+ description[13] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_Sexo());
+ description[14] = "', ESTADO CIVIL: '";
+ description[15] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_EstadoCivil());
+ description[16] = "', OCUPAÇÃO: '";
+ description[17] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_Ocupacao());
+ description[18] = "', RELAÇÃOO: '";
+ description[19] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_Relacao());
+ description[20] = "', DISTÂNCIA DO TRABALHO: '";
+ description[21] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_DistanciaResidenciaTrabalho());
+ description[22] = "', USO POR DEPENDENTES: '";
+ description[23] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_UsoDependentes());
+ description[24] = "', TIPO DE RESIDÊNCIA: '";
+ description[25] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_TipoResidencia());
+ description[26] = "', GARAGEM NA RESIDÊNCIA: '";
+ description[27] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_GaragemResidencia());
+ description[28] = "', GARAGEM NO TRABALHO: '";
+ description[29] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_GaragemTrabalho());
+ description[30] = "', GARAGEM NO ESTUDO: '";
+ description[31] = Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_GaragemEstudo());
+ description[32] = "', VEÍCULOS NA RESIDÊNCIA: '";
+ description[33] = (!perfil.get_VeiculoResidencia().HasValue ? "" : string.Format("{0}", perfil.get_VeiculoResidencia()));
+ description[34] = "', ANTFURTO: '";
+ description[35] = (!perfil.get_AntiFurto().HasValue ? "" : Gestor.Common.Validation.ValidationHelper.GetDescription(perfil.get_AntiFurto()));
+ description[36] = "', SEGURO DE VIDA: '";
+ description[37] = (!perfil.get_SeguroVida().HasValue ? "" : (perfil.get_SeguroVida().Value ? "SIM" : "NÃO"));
+ description[38] = "', USO PROFISSIONAL: '";
+ description[39] = (!perfil.get_UsoProfissional().HasValue ? "" : (perfil.get_UsoProfissional().Value ? "SIM" : "NÃO"));
+ description[40] = "', COBERTURA ESTENDIDA: '";
+ description[41] = (!perfil.get_EstenderCobertura().HasValue ? "" : (perfil.get_EstenderCobertura().Value ? "SIM" : "NÃO"));
+ description[42] = "', CEP CIRCULAÇÃO: '";
+ description[43] = (string.IsNullOrWhiteSpace(perfil.get_CepCirculacao()) ? "" : perfil.get_CepCirculacao() ?? "");
+ description[44] = "', CEP PERNOITE: '";
+ description[45] = (string.IsNullOrWhiteSpace(perfil.get_CepPernoite()) ? "" : perfil.get_CepPernoite() ?? "");
+ description[46] = "'.";
+ registroLog1.set_Descricao(string.Concat(description));
+ registroLog.set_EntidadeId(perfil.get_Id());
+ registroLog.set_Tela(3);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = PerfilServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PerfilServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_21);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 213, num, perfil, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Perfil> Save(Perfil perfil)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Perfil perfil2 = perfil;
+ Perfil perfil3 = await Task.Run<Perfil>(() => {
+ Perfil perfil4;
+ string str;
+ while (num > 0)
+ {
+ perfil = perfil2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (perfil.get_Id() == 0 ? 0 : 1);
+ perfil = (perfil.get_Id() == 0 ? commited.get_PerfilRepository().SaveOrUpdate(perfil) : commited.get_PerfilRepository().Merge(perfil));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Perfil perfil1 = perfil;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(perfil1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(perfil.get_Id());
+ registroLog.set_Tela(32);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = PerfilServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PerfilServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ perfil4 = perfil;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 212, num, perfil, true);
+ continue;
+ }
+ return perfil4;
+ }
+ return perfil2;
+ });
+ return perfil3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs new file mode 100644 index 0000000..f528fcb --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/ProfissaoServico.cs @@ -0,0 +1,78 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class ProfissaoServico : BaseServico
+ {
+ public ProfissaoServico()
+ {
+ }
+
+ public async Task<long> FindLastId()
+ {
+ int num1 = 3;
+ long num2 = await Task.Run<long>(() => {
+ long num;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ num = read.get_ProfissaoRepository().FindLastId();
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 17, num1, null, true);
+ continue;
+ }
+ return num;
+ }
+ return (long)0;
+ });
+ return num2;
+ }
+
+ public async Task<Profissao> Save(Profissao profissao)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Profissao profissao1 = profissao;
+ Profissao profissao2 = await Task.Run<Profissao>(() => {
+ Profissao profissao3;
+ while (num > 0)
+ {
+ profissao = profissao1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ profissao = (profissao.get_Id() == (long)0 ? commited.get_ProfissaoRepository().SaveOrUpdate(profissao) : commited.get_ProfissaoRepository().Merge(profissao));
+ commited.Commit();
+ profissao3 = profissao;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 214, num, profissao, true);
+ continue;
+ }
+ return profissao3;
+ }
+ return profissao1;
+ });
+ return profissao2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs b/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs new file mode 100644 index 0000000..19049b1 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Seguros/SinistroServico.cs @@ -0,0 +1,400 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Seguros
+{
+ internal class SinistroServico : BaseServico
+ {
+ public SinistroServico()
+ {
+ }
+
+ internal async Task<List<ControleSinistro>> BuscarControles(long id)
+ {
+ int num = 3;
+ List<ControleSinistro> controleSinistros1 = await Task.Run<List<ControleSinistro>>(() => {
+ List<ControleSinistro> controleSinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ controleSinistros = read.get_ControleSinistroRepository().FindByIdItem(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 48, num, id, true);
+ continue;
+ }
+ return controleSinistros;
+ }
+ return new List<ControleSinistro>();
+ });
+ return controleSinistros1;
+ }
+
+ public async Task<Sinistro> BuscarSinistro(long id)
+ {
+ int num = 3;
+ Sinistro sinistro1 = await Task.Run<Sinistro>(() => {
+ Sinistro sinistro;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistro = read.get_SinistroRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 49, num, id, true);
+ continue;
+ }
+ return sinistro;
+ }
+ return new Sinistro();
+ });
+ return sinistro1;
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistro(Filtros filtro)
+ {
+ int num = 3;
+ List<Sinistro> sinistros1 = await Task.Run<List<Sinistro>>(() => {
+ List<Sinistro> sinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistros = read.get_SinistroRepository().FindByData(filtro, false);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 176, num, filtro, true);
+ continue;
+ }
+ return sinistros;
+ }
+ return new List<Sinistro>();
+ });
+ return sinistros1;
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistroPendente(Filtros filtro)
+ {
+ int num = 3;
+ List<Sinistro> sinistros1 = await Task.Run<List<Sinistro>>(() => {
+ List<Sinistro> sinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistros = read.get_SinistroRepository().FindByData(filtro, true);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 176, num, filtro, true);
+ continue;
+ }
+ return sinistros;
+ }
+ return new List<Sinistro>();
+ });
+ return sinistros1;
+ }
+
+ public async Task<List<Sinistro>> BuscarSinistros(string numero)
+ {
+ int num = 3;
+ List<Sinistro> sinistros1 = await Task.Run<List<Sinistro>>(() => {
+ List<Sinistro> sinistros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ sinistros = read.get_SinistroRepository().FindNumeroSinistro(numero);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 177, num, numero, true);
+ continue;
+ }
+ return sinistros;
+ }
+ return new List<Sinistro>();
+ });
+ return sinistros1;
+ }
+
+ public async Task<bool> Delete(Sinistro sinistro)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ 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(sinistro.get_Id(), sinistro.GetValorOriginal(), 26, 2));
+ SinistroAuto sinistroAuto = commited.get_SinistroAutoRepository().FindBySinistroId(sinistro.get_Id());
+ SinistroVida sinistroVida = commited.get_SinistroVidaRepository().FindBySinistroId(sinistro.get_Id());
+ if (sinistroAuto != null)
+ {
+ commited.get_SinistroAutoRepository().Delete(sinistroAuto.get_Id());
+ }
+ if (sinistroVida != null)
+ {
+ commited.get_SinistroVidaRepository().Delete(sinistroVida.get_Id());
+ }
+ commited.get_SinistroRepository().Delete(sinistro.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 174, num, sinistro, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> DeleteControle(ControleSinistro controle, bool atualizarItem)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ bool flag1 = await Task.Run<bool>(async () => {
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (atualizarItem)
+ {
+ Item item = commited.get_ItemRepository().FindById(controle.get_Item().get_Id());
+ item.set_Sinistrado(false);
+ commited.get_ItemRepository().Merge(item);
+ }
+ foreach (Sinistro sinistro in commited.get_SinistroRepository().FindByControleId(controle.get_Id()))
+ {
+ registroLogs.Add(base.CreateLog(sinistro.get_Id(), sinistro.GetValorOriginal(), 26, 2));
+ if (await this.Delete(sinistro))
+ {
+ continue;
+ }
+ flag = false;
+ return flag;
+ }
+ commited.get_ControleSinistroRepository().Delete(controle.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ return flag;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 174, num, controle, true);
+ }
+ registroLogs = null;
+ }
+ flag = false;
+ return flag;
+ });
+ return flag1;
+ }
+
+ public async Task<Sinistro> Save(Sinistro sinistro, long idramo)
+ {
+ int num3 = 3;
+ base.Sucesso = true;
+ Sinistro sinistro1 = sinistro;
+ Funcoes.GetNetworkTime();
+ Sinistro sinistro2 = await Task.Run<Sinistro>(() => {
+ SinistroVida sinistroVida;
+ long num;
+ Sinistro sinistro3;
+ while (num3 > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ Item item = commited.get_ItemRepository().FindById(sinistro.get_ControleSinistro().get_Item().get_Id());
+ item.set_Sinistrado(true);
+ sinistro1.get_ControleSinistro().set_Item(commited.get_ItemRepository().Merge(item));
+ bool id = sinistro1.get_ControleSinistro().get_Id() == (long)0;
+ SinistroAuto sinistroAuto = sinistro1.get_SinistroAuto();
+ sinistroVida = sinistro1.get_SinistroVida();
+ if (!id)
+ {
+ registroLogs.Add(base.CreateLog(sinistro1.get_Id(), sinistro1, 7));
+ sinistro1.set_ControleSinistro(commited.get_ControleSinistroRepository().Merge(sinistro1.get_ControleSinistro()));
+ sinistro1 = (sinistro1.get_Id() == 0 ? commited.get_SinistroRepository().SaveOrUpdate(sinistro1) : commited.get_SinistroRepository().Merge(sinistro1));
+ num = idramo;
+ long num1 = num - (long)5;
+ if (num1 <= (long)5)
+ {
+ switch ((uint)num1)
+ {
+ case 0:
+ {
+ goto Label0;
+ }
+ case 1:
+ case 2:
+ case 4:
+ case 5:
+ {
+ goto Label1;
+ }
+ case 3:
+ {
+ goto Label2;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (num != (long)37)
+ {
+ goto Label3;
+ }
+ Label0:
+ if (sinistroAuto != null)
+ {
+ sinistroAuto.set_Sinistro(sinistro1);
+ sinistroAuto = (sinistroAuto.get_Id() == 0 ? commited.get_SinistroAutoRepository().SaveOrUpdate(sinistroAuto) : commited.get_SinistroAutoRepository().Merge(sinistroAuto));
+ sinistro1.set_SinistroAuto(sinistroAuto);
+ }
+ }
+ else
+ {
+ sinistro1.set_ControleSinistro(commited.get_ControleSinistroRepository().SaveOrUpdate(sinistro1.get_ControleSinistro()));
+ sinistro1 = commited.get_SinistroRepository().SaveOrUpdate(sinistro1);
+ registroLogs.Add(base.CreateLog(sinistro1.get_Id(), sinistro1.GetValorOriginal(), 7, 0));
+ num = idramo;
+ long num2 = num - (long)5;
+ if (num2 <= (long)5)
+ {
+ switch ((uint)num2)
+ {
+ case 0:
+ {
+ goto Label4;
+ }
+ case 1:
+ case 2:
+ case 4:
+ case 5:
+ {
+ goto Label5;
+ }
+ case 3:
+ {
+ goto Label2;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (num != (long)37)
+ {
+ goto Label6;
+ }
+ Label4:
+ sinistroAuto.set_Sinistro(sinistro1);
+ sinistroAuto = commited.get_SinistroAutoRepository().SaveOrUpdate(sinistroAuto);
+ sinistro1.set_SinistroAuto(sinistroAuto);
+ }
+ Label2:
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ sinistro3 = sinistro1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num3 = base.Registrar(exception, 175, num3, sinistro, true);
+ continue;
+ }
+ return sinistro3;
+ }
+ return sinistro;
+ Label1:
+ if (sinistroVida == null)
+ {
+ sinistroVida = new SinistroVida();
+ }
+ sinistroVida.set_Sinistro(sinistro1);
+ sinistroVida = (sinistroVida.get_Id() == 0 ? commited.get_SinistroVidaRepository().SaveOrUpdate(sinistroVida) : commited.get_SinistroVidaRepository().Merge(sinistroVida));
+ sinistro1.set_SinistroVida(sinistroVida);
+ goto Label2;
+ Label3:
+ if (num != (long)53)
+ {
+ goto Label2;
+ }
+ else
+ {
+ goto Label1;
+ }
+ Label5:
+ sinistroVida.set_Sinistro(sinistro1);
+ sinistroVida = commited.get_SinistroVidaRepository().SaveOrUpdate(sinistroVida);
+ sinistro1.set_SinistroVida(sinistroVida);
+ goto Label2;
+ Label6:
+ if (num != (long)53)
+ {
+ goto Label2;
+ }
+ else
+ {
+ goto Label5;
+ }
+ });
+ return sinistro2;
+ }
+ }
+}
\ No newline at end of file |