diff options
Diffstat (limited to 'Codemerx/Gestor.Application/Servicos')
61 files changed, 21261 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs b/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs new file mode 100644 index 0000000..30e8886 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ajuda/AjudaServico.cs @@ -0,0 +1,129 @@ +using CsQuery.ExtensionMethods.Internal;
+using Gestor.Application.Helpers;
+using Gestor.Application.Model.Ajuda;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Model.License;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ajuda
+{
+ public class AjudaServico : BaseServico
+ {
+ public AjudaServico()
+ {
+ }
+
+ internal async Task<ObservableCollection<Atendimento>> BuscarAtendimentos(string status)
+ {
+ ObservableCollection<Atendimento> observableCollection = await Task.Run<ObservableCollection<Atendimento>>(() => {
+ ObservableCollection<Atendimento> result;
+ try
+ {
+ result = Connection.Get<ObservableCollection<Atendimento>>(string.Format("Attendance/{0}", (status == "PENDENTES" ? 1 : 2)), true, false).Result;
+ }
+ catch (Exception exception)
+ {
+ result = null;
+ }
+ return result;
+ });
+ return observableCollection;
+ }
+
+ internal async Task<List<Boleto>> BuscarBoletosNotas(string status)
+ {
+ List<Boleto> boletos = await Task.Run<List<Boleto>>(() => {
+ List<Boleto> result;
+ try
+ {
+ result = Connection.Get<List<Boleto>>(string.Format("Billet/{0}", status == "BAIXADOS"), true, false).Result;
+ }
+ catch (Exception exception)
+ {
+ result = null;
+ }
+ return result;
+ });
+ return boletos;
+ }
+
+ internal async Task<Contrato> BuscarContrato(Produto produto)
+ {
+ Contrato contrato = await Task.Run<Contrato>(() => {
+ Contrato result;
+ try
+ {
+ result = Connection.Get<Contrato>(string.Format("Contract/{0}", ExtensionMethods.GetValue(produto)), true, false).Result;
+ }
+ catch (Exception exception)
+ {
+ result = null;
+ }
+ return result;
+ });
+ return contrato;
+ }
+
+ internal async Task<string> BuscarCorpoAtendimentos(long id)
+ {
+ string str = await Task.Run<string>(() => {
+ string result;
+ try
+ {
+ result = Connection.Get<string>(string.Format("Attendance/Body/{0}", id), true, false).Result;
+ }
+ catch (Exception exception)
+ {
+ result = null;
+ }
+ return result;
+ });
+ return str;
+ }
+
+ internal async Task<ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao>> BuscarLicencas()
+ {
+ ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao> observableCollection = await Task.Run<ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao>>(() => {
+ ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao> result;
+ try
+ {
+ result = Connection.Get<ObservableCollection<Gestor.Application.Model.Ajuda.Instalacao>>(string.Format("License/{0}", ApplicationHelper.IdFornecedor), true, false).Result;
+ }
+ catch (Exception exception)
+ {
+ result = null;
+ }
+ return result;
+ });
+ return observableCollection;
+ }
+
+ internal async Task<bool> ExcluirInstalacao(long id)
+ {
+ int num = 3;
+ bool flag = await Task.Run<bool>(() => {
+ bool result;
+ while (num > 0)
+ {
+ try
+ {
+ result = Connection.Delete(string.Format("License/{0}", id)).Result;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 273, num, id, true);
+ continue;
+ }
+ return result;
+ }
+ return false;
+ });
+ return flag;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs b/Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs new file mode 100644 index 0000000..fdeae7d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ArquivoDigitalServico.cs @@ -0,0 +1,538 @@ +using ArquivoDigital.Infrastructure.Repository.Interface;
+using ArquivoDigital.Infrastructure.UnitOfWork.Generic;
+using ArquivoDigital.Infrastructure.UnitOfWork.Logic;
+using CsQuery.ExtensionMethods.Internal;
+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.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Aggilizador;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.License;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class ArquivoDigitalServico : BaseServico
+ {
+ public ArquivoDigitalServico()
+ {
+ }
+
+ public async Task<List<ArquivoVinculo>> BaixarArquivosPendentes(List<ArquivoVinculo> arquivos)
+ {
+ string banco = Gestor.Application.Helpers.ArquivoDigital.Banco;
+ int num = 3;
+ List<ArquivoVinculo> arquivoVinculos1 = await Task.Run<List<ArquivoVinculo>>(() => {
+ List<ArquivoVinculo> arquivoVinculos;
+ while (num > 0)
+ {
+ try
+ {
+ using (Gestor.Application.Helpers.ArquivoDigital.Read)
+ {
+ foreach (ArquivoVinculo arquivo in arquivos)
+ {
+ if (arquivo.get_Arquivo() != null || ExtensionMethods.IsNullOrEmpty<char>(arquivo.get_Chave()))
+ {
+ continue;
+ }
+ byte[] result = Connection.DownloadFile(arquivo.get_Storage(), arquivo.get_Ano(), Guid.Parse(arquivo.get_Chave()), ".pdf", "aggilizador", false).Result;
+ if (result == null)
+ {
+ continue;
+ }
+ arquivo.set_Arquivo(result);
+ }
+ arquivoVinculos = arquivos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 65, num, new { arquivos = arquivos, banco = banco }, true);
+ continue;
+ }
+ return arquivoVinculos;
+ }
+ return null;
+ });
+ return arquivoVinculos1;
+ }
+
+ public async Task<List<Gestor.Model.Domain.Common.ArquivoDigital>> Buscar(List<IndiceArquivoDigital> ids)
+ {
+ int num = 3;
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals4 = await Task.Run<List<Gestor.Model.Domain.Common.ArquivoDigital>>(() => {
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals2;
+ while (num > 0)
+ {
+ try
+ {
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals3 = new List<Gestor.Model.Domain.Common.ArquivoDigital>();
+ List<IndiceArquivoDigital> indiceArquivoDigitals2 = ids;
+ Func<IndiceArquivoDigital, string> u003cu003e9_61 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_1;
+ if (u003cu003e9_61 == null)
+ {
+ u003cu003e9_61 = (IndiceArquivoDigital x) => x.get_Bd();
+ ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61;
+ }
+ indiceArquivoDigitals2.GroupBy<IndiceArquivoDigital, string>(u003cu003e9_61).ToList<IGrouping<string, IndiceArquivoDigital>>().ForEach((IGrouping<string, IndiceArquivoDigital> x) => {
+ Gestor.Application.Helpers.ArquivoDigital.SetConnection(x.Key);
+ IGrouping<string, IndiceArquivoDigital> strs = x;
+ Func<IndiceArquivoDigital, bool> u003cu003e9_63 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_3;
+ if (u003cu003e9_63 == null)
+ {
+ u003cu003e9_63 = (IndiceArquivoDigital l) => !l.get_Assinado();
+ ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_3 = u003cu003e9_63;
+ }
+ IEnumerable<IndiceArquivoDigital> indiceArquivoDigitals = strs.Where<IndiceArquivoDigital>(u003cu003e9_63);
+ Func<IndiceArquivoDigital, long> u003cu003e9_64 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_4;
+ if (u003cu003e9_64 == null)
+ {
+ u003cu003e9_64 = (IndiceArquivoDigital l) => l.get_IdArquivoDigital();
+ ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_4 = u003cu003e9_64;
+ }
+ List<long> list = indiceArquivoDigitals.Select<IndiceArquivoDigital, long>(u003cu003e9_64).ToList<long>();
+ IGrouping<string, IndiceArquivoDigital> strs1 = x;
+ Func<IndiceArquivoDigital, bool> u003cu003e9_65 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_5;
+ if (u003cu003e9_65 == null)
+ {
+ u003cu003e9_65 = (IndiceArquivoDigital l) => l.get_Assinado();
+ ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_5 = u003cu003e9_65;
+ }
+ IEnumerable<IndiceArquivoDigital> indiceArquivoDigitals1 = strs1.Where<IndiceArquivoDigital>(u003cu003e9_65);
+ Func<IndiceArquivoDigital, long> u003cu003e9_66 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_6;
+ if (u003cu003e9_66 == null)
+ {
+ u003cu003e9_66 = (IndiceArquivoDigital l) => l.get_Id();
+ ArquivoDigitalServico.u003cu003ec.u003cu003e9__6_6 = u003cu003e9_66;
+ }
+ List<long> nums = indiceArquivoDigitals1.Select<IndiceArquivoDigital, long>(u003cu003e9_66).ToList<long>();
+ if (nums.Any<long>())
+ {
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals = new List<Gestor.Model.Domain.Common.ArquivoDigital>();
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ nums.ForEach((long a) => {
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital = read.get_IndiceArquivoDigitalRepository().FindAssinatura(a);
+ if (arquivoDigital.get_AzureGuid().HasValue)
+ {
+ arquivoDigital.set_Arquivo(Connection.DownloadFile(arquivoDigital.get_AzureStorage(), arquivoDigital.get_DataCriacao().Value.Year, arquivoDigital.get_AzureGuid().Value, Path.GetExtension(arquivoDigital.get_Descricao()), "siggner", false).Result);
+ }
+ if (arquivoDigital.get_Arquivo() != null)
+ {
+ arquivoDigitals.Add(arquivoDigital);
+ }
+ });
+ }
+ arquivoDigitals3.AddRange(arquivoDigitals);
+ }
+ if (list.Any<long>())
+ {
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals1 = new List<Gestor.Model.Domain.Common.ArquivoDigital>();
+ using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Gestor.Application.Helpers.ArquivoDigital.Read)
+ {
+ list.ForEach((long a) => {
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital = unitOfWork.get_ArquivoDigitalRepository().FindById(a, true);
+ if (arquivoDigital.get_AzureGuid().HasValue)
+ {
+ arquivoDigital.set_Arquivo(Connection.DownloadFile(arquivoDigital.get_AzureStorage(), arquivoDigital.get_DataCriacao().Value.Year, arquivoDigital.get_AzureGuid().Value, arquivoDigital.get_Extensao(), "ad", false).Result);
+ }
+ if (arquivoDigital.get_Arquivo() != null)
+ {
+ arquivoDigitals1.Add(arquivoDigital);
+ }
+ });
+ }
+ arquivoDigitals3.AddRange(arquivoDigitals1);
+ }
+ });
+ arquivoDigitals2 = arquivoDigitals3;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 66, num, ids, true);
+ continue;
+ }
+ return arquivoDigitals2;
+ }
+ return new List<Gestor.Model.Domain.Common.ArquivoDigital>();
+ });
+ return arquivoDigitals4;
+ }
+
+ public async Task<Gestor.Model.Domain.Common.ArquivoDigital> BuscarPorId(long id, string banco)
+ {
+ int num = 3;
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital2 = await Task.Run<Gestor.Model.Domain.Common.ArquivoDigital>(() => {
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital;
+ while (num > 0)
+ {
+ try
+ {
+ Gestor.Application.Helpers.ArquivoDigital.SetConnection(banco);
+ if (string.IsNullOrEmpty(banco))
+ {
+ banco = Gestor.Application.Helpers.ArquivoDigital.Banco;
+ }
+ using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read)
+ {
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital1 = read.get_ArquivoDigitalRepository().FindById(id, true);
+ if (arquivoDigital1 != null)
+ {
+ if (arquivoDigital1.get_AzureGuid().HasValue)
+ {
+ byte[] result = Connection.DownloadFile(arquivoDigital1.get_AzureStorage(), arquivoDigital1.get_DataCriacao().Value.Year, arquivoDigital1.get_AzureGuid().Value, arquivoDigital1.get_Extensao(), "ad", false).Result;
+ if (result != null)
+ {
+ arquivoDigital1.set_Arquivo(result);
+ }
+ else
+ {
+ arquivoDigital = null;
+ return arquivoDigital;
+ }
+ }
+ arquivoDigital = arquivoDigital1;
+ }
+ else
+ {
+ arquivoDigital = null;
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 65, num, new { id = id, banco = banco }, true);
+ continue;
+ }
+ return arquivoDigital;
+ }
+ return null;
+ });
+ return arquivoDigital2;
+ }
+
+ public async Task<Gestor.Model.Domain.Common.ArquivoDigital> BuscarPorId(long id)
+ {
+ int num = 3;
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital2 = await Task.Run<Gestor.Model.Domain.Common.ArquivoDigital>(() => {
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital;
+ while (num > 0)
+ {
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital1 = read.get_IndiceArquivoDigitalRepository().FindAssinatura(id);
+ if (arquivoDigital1.get_AzureGuid().HasValue)
+ {
+ byte[] result = Connection.DownloadFile(arquivoDigital1.get_AzureStorage(), arquivoDigital1.get_DataCriacao().Value.Year, arquivoDigital1.get_AzureGuid().Value, Path.GetExtension(arquivoDigital1.get_Descricao()), "siggner", false).Result;
+ if (result != null)
+ {
+ arquivoDigital1.set_Arquivo(result);
+ }
+ else
+ {
+ arquivoDigital = null;
+ return arquivoDigital;
+ }
+ }
+ arquivoDigital = arquivoDigital1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 64, num, id, true);
+ continue;
+ }
+ return arquivoDigital;
+ }
+ return null;
+ });
+ return arquivoDigital2;
+ }
+
+ public async Task<List<IndiceArquivoDigital>> BuscarPorTipo(TipoArquivoDigital tipo, long id)
+ {
+ int num2 = 3;
+ long num3 = Recursos.Usuario.get_Id();
+ List<IndiceArquivoDigital> indiceArquivoDigitals1 = await Task.Run<List<IndiceArquivoDigital>>(() => {
+ List<IndiceArquivoDigital> indiceArquivoDigitals;
+ while (num2 > 0)
+ {
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ IIndiceArquivoDigitalRepository indiceArquivoDigitalRepository = read.get_IndiceArquivoDigitalRepository();
+ TipoArquivoDigital tipoArquivoDigital = tipo;
+ long num = id;
+ long num1 = num3;
+ List<Licenca> produtos = LicenseHelper.Produtos;
+ Func<Licenca, bool> u003cu003e9_01 = ArquivoDigitalServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (Licenca x) => {
+ if (x.get_Produto() != 86)
+ {
+ return false;
+ }
+ return x.get_Status() != 3;
+ };
+ ArquivoDigitalServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ indiceArquivoDigitals = indiceArquivoDigitalRepository.Find(tipoArquivoDigital, num, num1, produtos.Any<Licenca>(u003cu003e9_01));
+ }
+ }
+ catch (Exception exception)
+ {
+ num2 = base.Registrar(exception, 64, num2, new { tipo = tipo, id = id }, true);
+ continue;
+ }
+ return indiceArquivoDigitals;
+ }
+ return new List<IndiceArquivoDigital>();
+ });
+ return indiceArquivoDigitals1;
+ }
+
+ public async Task Criar()
+ {
+ int num = 3;
+ await Task.Run(() => {
+ while (num > 0)
+ {
+ try
+ {
+ using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Gestor.Application.Helpers.ArquivoDigital.Read)
+ {
+ read.get_ArquivoDigitalRepository().FindById((long)1, false);
+ break;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 288, num, null, true);
+ }
+ }
+ });
+ }
+
+ public async Task<bool> DeleteAttachment(IndiceArquivoDigital indice)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited)
+ {
+ indice.set_Excluido(true);
+ List<Diferenca> diferencas = new List<Diferenca>();
+ Diferenca diferenca = new Diferenca();
+ diferenca.set_Campo("Id");
+ diferenca.set_Descricao("ID");
+ diferenca.set_ValorAtual(indice.get_Id().ToString());
+ diferencas.Add(diferenca);
+ Diferenca diferenca1 = new Diferenca();
+ diferenca1.set_Campo("Descricao");
+ diferenca1.set_Descricao("DESCRIÇÃO");
+ diferenca1.set_ValorAtual(indice.get_Descricao());
+ diferencas.Add(diferenca1);
+ List<Diferenca> diferencas1 = diferencas;
+ if (indice.get_AzureGuid().HasValue && Connection.DeleteFile(indice.get_AzureStorage(), indice.get_DataCriacao().Value.Year, indice.get_AzureGuid().Value, indice.get_Extensao(), "ad").Result)
+ {
+ Diferenca diferenca2 = new Diferenca();
+ diferenca2.set_Campo("AzureGuid");
+ diferenca2.set_Descricao("AzureGuid");
+ diferenca2.set_ValorAtual(indice.get_AzureGuid().ToString());
+ diferencas1.Add(diferenca2);
+ }
+ registroLogs.Add(base.CreateLog(indice.get_Id(), diferencas1, 6, 2));
+ indice.set_DataAtualizacao(new DateTime?(networkTime));
+ if (!indice.get_DataCriacao().HasValue || indice.get_DataCriacao().Value.Year < 1754)
+ {
+ indice.set_DataCriacao(new DateTime?(networkTime));
+ }
+ commited.get_IndiceArquivoDigitalRepository().Merge(indice);
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 253, num, indice, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<List<IndiceArquivoDigital>> Insert(List<Gestor.Model.Domain.Common.ArquivoDigital> files)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals = files;
+ List<IndiceArquivoDigital> indiceArquivoDigitals2 = await Task.Run<List<IndiceArquivoDigital>>(() => {
+ List<IndiceArquivoDigital> indiceArquivoDigitals;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ files = arquivoDigitals;
+ try
+ {
+ List<IndiceArquivoDigital> indiceArquivoDigitals1 = new List<IndiceArquivoDigital>();
+ files.ForEach((Gestor.Model.Domain.Common.ArquivoDigital file) => {
+ file.set_UsuarioCriacao(Recursos.Usuario.get_Id());
+ file.set_DataCriacao(new DateTime?(networkTime));
+ file.set_DataAtualizacao(null);
+ UploadFile uploadFile = new UploadFile();
+ uploadFile.set_Ano(networkTime.Year);
+ uploadFile.set_Id(Guid.NewGuid());
+ uploadFile.set_Extensao(file.get_Extensao().Replace(".", string.Empty));
+ uploadFile.set_Arquivo(file.get_Arquivo());
+ UploadFile uploadFile1 = uploadFile;
+ if (Connection.ConnectionAddress.get_UsaAzureStorage() && Connection.UploadFile(uploadFile1, "ad").Result)
+ {
+ file.set_AzureGuid(new Guid?(uploadFile1.get_Id()));
+ file.set_Arquivo(null);
+ file.set_AzureStorage(Connection.ConnectionAddress.get_AzureStorage());
+ }
+ IndiceArquivoDigital indiceArquivoDigital = new IndiceArquivoDigital();
+ indiceArquivoDigital.set_Descricao(file.get_Descricao());
+ indiceArquivoDigital.set_Bd(Gestor.Application.Helpers.ArquivoDigital.Banco);
+ indiceArquivoDigital.set_Extensao(file.get_Extensao());
+ indiceArquivoDigital.set_IdCliente(file.get_IdCliente());
+ indiceArquivoDigital.set_IdDocumento(file.get_IdDocumento());
+ indiceArquivoDigital.set_IdEmpresa(file.get_IdEmpresa());
+ indiceArquivoDigital.set_IdParcela(file.get_IdParcela());
+ indiceArquivoDigital.set_IdItem(file.get_IdItem());
+ indiceArquivoDigital.set_IdExtrato(file.get_IdExtrato());
+ indiceArquivoDigital.set_IdSinistro(file.get_IdSinistro());
+ indiceArquivoDigital.set_IdSeguradora(file.get_IdSeguradora());
+ indiceArquivoDigital.set_IdVendedor(file.get_IdVendedor());
+ indiceArquivoDigital.set_IdUsuario(file.get_IdUsuario());
+ indiceArquivoDigital.set_IdLancamento(file.get_IdLancamento());
+ indiceArquivoDigital.set_IdFornecedor(file.get_IdFornecedor());
+ indiceArquivoDigital.set_IdProspeccao(file.get_IdProspeccao());
+ indiceArquivoDigital.set_IdSocio(file.get_IdSocio());
+ indiceArquivoDigital.set_IdTarefa(file.get_IdTarefa());
+ indiceArquivoDigital.set_IdNotaFiscal(file.get_IdNotaFiscal());
+ indiceArquivoDigital.set_IdEstipulante(file.get_IdEstipulante());
+ indiceArquivoDigital.set_Excluido(file.get_Excluido());
+ indiceArquivoDigital.set_UsuarioCriacao(file.get_UsuarioCriacao());
+ indiceArquivoDigital.set_DataCriacao(file.get_DataCriacao());
+ indiceArquivoDigital.set_DataAtualizacao(file.get_DataAtualizacao());
+ indiceArquivoDigital.set_AzureGuid(file.get_AzureGuid());
+ indiceArquivoDigital.set_AzureStorage(file.get_AzureStorage());
+ IndiceArquivoDigital indiceArquivoDigital1 = indiceArquivoDigital;
+ Gestor.Application.Helpers.ArquivoDigital.SetConnection("");
+ indiceArquivoDigital1.set_Bd(Gestor.Application.Helpers.ArquivoDigital.Banco);
+ using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Gestor.Application.Helpers.ArquivoDigital.Commited)
+ {
+ file = commited.get_ArquivoDigitalRepository().SaveOrUpdate(file);
+ indiceArquivoDigital1.set_IdArquivoDigital(file.get_Id());
+ commited.Commit();
+ }
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Instancia.Commited)
+ {
+ indiceArquivoDigital1 = unitOfWork.get_IndiceArquivoDigitalRepository().SaveOrUpdate(indiceArquivoDigital1);
+ List<Diferenca> diferencas = new List<Diferenca>();
+ Diferenca diferenca = new Diferenca();
+ diferenca.set_Campo("Descricao");
+ diferenca.set_Descricao("DESCRIÇÃO");
+ diferenca.set_ValorAtual(indiceArquivoDigital1.get_Descricao());
+ diferencas.Add(diferenca);
+ registroLogs.Add(base.CreateLog(indiceArquivoDigital1.get_Id(), diferencas, 6, 0));
+ base.SaveLog(registroLogs, unitOfWork);
+ unitOfWork.Commit();
+ }
+ indiceArquivoDigitals1.Add(indiceArquivoDigital1);
+ });
+ indiceArquivoDigitals = indiceArquivoDigitals1;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 252, num, files, true);
+ continue;
+ }
+ return indiceArquivoDigitals;
+ }
+ return new List<IndiceArquivoDigital>();
+ });
+ return indiceArquivoDigitals2;
+ }
+
+ public async Task<IndiceArquivoDigital> Save(IndiceArquivoDigital indice)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ IndiceArquivoDigital indiceArquivoDigital1 = indice;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IndiceArquivoDigital indiceArquivoDigital2 = await Task.Run<IndiceArquivoDigital>(() => {
+ IndiceArquivoDigital indiceArquivoDigital;
+ while (num > 0)
+ {
+ indice = indiceArquivoDigital1;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (indice.get_Id() == 0 ? 0 : 1);
+ indice.set_DataAtualizacao(new DateTime?(networkTime));
+ indice.set_UsuarioAtualizacao(Recursos.Usuario.get_Id());
+ indice.set_Excluido(false);
+ if (tipoAcao == 1)
+ {
+ registroLogs.Add(base.CreateLog(indice.get_Id(), indice, 6));
+ }
+ indice = (tipoAcao == 1 ? commited.get_IndiceArquivoDigitalRepository().Merge(indice) : commited.get_IndiceArquivoDigitalRepository().SaveOrUpdate(indice));
+ if (tipoAcao != 1)
+ {
+ List<Diferenca> diferencas = new List<Diferenca>();
+ Diferenca diferenca = new Diferenca();
+ diferenca.set_Campo("Descricao");
+ diferenca.set_Descricao("DESCRIÇÃO");
+ diferenca.set_ValorAtual(indice.get_Descricao());
+ diferencas.Add(diferenca);
+ registroLogs.Add(base.CreateLog(indice.get_Id(), diferencas, 6, tipoAcao));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ }
+ indiceArquivoDigital = indice;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 252, num, indice, true);
+ continue;
+ }
+ return indiceArquivoDigital;
+ }
+ return indiceArquivoDigital1;
+ });
+ return indiceArquivoDigital2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs b/Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs new file mode 100644 index 0000000..2151fd9 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/AssinaturaServico.cs @@ -0,0 +1,178 @@ +using Assinador.Infrastructure.Repository.Interface;
+using Assinador.Infrastructure.UnitOfWork.Generic;
+using Assinador.Infrastructure.UnitOfWork.Logic;
+using Assinador.Model.Domain;
+using Assinador.Model.Generic;
+using Assinador.Modelos;
+using Assinador.Processos;
+using Gestor.Application.Helpers;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Newtonsoft.Json;
+using Sign.Modelos;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class AssinaturaServico
+ {
+ public AssinaturaServico()
+ {
+ }
+
+ public async Task<ArquivoParaAssinaturaAssinador> Assinar(Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital, ApoliceAssinador apolice)
+ {
+ AggerSigner aggerSigner = new AggerSigner(AssinadorHelper.Remetente);
+ ArquivoAssinatura arquivoAssinatura = new ArquivoAssinatura();
+ arquivoAssinatura.set_Bytes(arquivoDigital.get_Arquivo());
+ arquivoAssinatura.set_Nome(string.Concat(arquivoDigital.get_Descricao(), arquivoDigital.get_Extensao().ToLower()));
+ ArquivoAssinatura arquivoAssinatura1 = arquivoAssinatura;
+ List<Destinatario> destinatarios = new List<Destinatario>();
+ Destinatario destinatario = new Destinatario();
+ destinatario.set_Email(apolice.get_Email());
+ destinatario.set_Nome(apolice.get_Cliente());
+ destinatario.set_Documento(apolice.get_Documento());
+ destinatarios.Add(destinatario);
+ arquivoAssinatura1.set_Destinatarios(destinatarios);
+ ArquivoCriado arquivoCriado = await aggerSigner.EnviarParaAssinatura(arquivoAssinatura1);
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador = new ArquivoParaAssinaturaAssinador();
+ arquivoParaAssinaturaAssinador.set_AssinaturaId(arquivoCriado.get_Id());
+ arquivoParaAssinaturaAssinador.set_Chave(arquivoCriado.get_Chave());
+ arquivoParaAssinaturaAssinador.set_DocumentoId(apolice.get_Id());
+ arquivoParaAssinaturaAssinador.set_ClienteId(apolice.get_ClienteId());
+ arquivoParaAssinaturaAssinador.set_IndiceId(apolice.get_ArquivoId());
+ arquivoParaAssinaturaAssinador.set_UrlAssinatura(arquivoCriado.get_Url());
+ arquivoParaAssinaturaAssinador.set_Enviado(Funcoes.GetNetworkTime());
+ arquivoParaAssinaturaAssinador.set_UsuarioId(Recursos.Usuario.get_Id());
+ return arquivoParaAssinaturaAssinador;
+ }
+
+ public static async Task<ParametrosAssinaturaAssinador> BuscarParametrosAssinatura(long id)
+ {
+ ParametrosAssinaturaAssinador parametrosAssinaturaAssinador1 = await Task.Run<ParametrosAssinaturaAssinador>(() => {
+ ParametrosAssinaturaAssinador parametrosAssinaturaAssinador;
+ try
+ {
+ using (UnitOfWork read = InstanciaAssinador.Read)
+ {
+ parametrosAssinaturaAssinador = read.get_EmpresaRepository().FindByEmpresa(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ parametrosAssinaturaAssinador = null;
+ }
+ return parametrosAssinaturaAssinador;
+ });
+ return parametrosAssinaturaAssinador1;
+ }
+
+ public async Task<ArquivoParaAssinaturaAssinador> Reenviar(long indice)
+ {
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador;
+ AggerSigner aggerSigner = new AggerSigner(AssinadorHelper.Remetente);
+ using (UnitOfWork commited = InstanciaAssinador.Commited)
+ {
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador1 = commited.get_ArquivoParaAssinaturaRepository().FindByIndice(indice);
+ List<int> nums = new List<int>()
+ {
+ arquivoParaAssinaturaAssinador1.get_AssinaturaId()
+ };
+ await aggerSigner.ReenviarParaAssinatura(nums, null);
+ AssinaturaLogAssinador assinaturaLogAssinador = new AssinaturaLogAssinador();
+ assinaturaLogAssinador.set_Acao(1);
+ assinaturaLogAssinador.set_EntidadeId(arquivoParaAssinaturaAssinador1.get_Id());
+ assinaturaLogAssinador.set_DataHora(Funcoes.GetNetworkTime());
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador2 = arquivoParaAssinaturaAssinador1;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ assinaturaLogAssinador.set_Descricao(JsonConvert.SerializeObject(arquivoParaAssinaturaAssinador2, jsonSerializerSetting));
+ assinaturaLogAssinador.set_UsuarioId(Recursos.Usuario.get_Id());
+ assinaturaLogAssinador.set_Versao(ApplicationHelper.Versao.ToString());
+ this.SaveLog(assinaturaLogAssinador, commited);
+ arquivoParaAssinaturaAssinador = arquivoParaAssinaturaAssinador1;
+ }
+ return arquivoParaAssinaturaAssinador;
+ }
+
+ public async Task<ArquivoParaAssinaturaAssinador> Save(ArquivoParaAssinaturaAssinador arquivo)
+ {
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador2 = await Task.Run<ArquivoParaAssinaturaAssinador>(() => {
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador;
+ try
+ {
+ using (UnitOfWork commited = InstanciaAssinador.Commited)
+ {
+ arquivo = (arquivo.get_Id() == 0 ? commited.get_ArquivoParaAssinaturaRepository().SaveOrUpdate(arquivo) : commited.get_ArquivoParaAssinaturaRepository().Merge(arquivo));
+ AssinaturaLogAssinador assinaturaLogAssinador = new AssinaturaLogAssinador();
+ assinaturaLogAssinador.set_Acao(0);
+ assinaturaLogAssinador.set_EntidadeId(arquivo.get_Id());
+ assinaturaLogAssinador.set_DataHora(Funcoes.GetNetworkTime());
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador1 = arquivo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ assinaturaLogAssinador.set_Descricao(JsonConvert.SerializeObject(arquivoParaAssinaturaAssinador1, jsonSerializerSetting));
+ assinaturaLogAssinador.set_UsuarioId(Recursos.Usuario.get_Id());
+ assinaturaLogAssinador.set_Versao(ApplicationHelper.Versao.ToString());
+ this.SaveLog(assinaturaLogAssinador, commited);
+ commited.Commit();
+ arquivoParaAssinaturaAssinador = arquivo;
+ }
+ }
+ catch (Exception exception)
+ {
+ arquivoParaAssinaturaAssinador = null;
+ }
+ return arquivoParaAssinaturaAssinador;
+ });
+ return arquivoParaAssinaturaAssinador2;
+ }
+
+ internal async void SaveLog(AssinaturaLogAssinador keyValues, UnitOfWork unitOfWork)
+ {
+ if (keyValues != null)
+ {
+ try
+ {
+ unitOfWork.get_AssinaturaLogRepository().SaveOrUpdate(keyValues);
+ unitOfWork.Commit();
+ }
+ catch (Exception exception)
+ {
+ }
+ }
+ }
+
+ public async Task<bool> VerificarAssinado(long id)
+ {
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ using (UnitOfWork read = InstanciaAssinador.Read)
+ {
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador = read.get_ArquivoParaAssinaturaRepository().FindByIndice(id);
+ flag = (arquivoParaAssinaturaAssinador == null ? false : (arquivoParaAssinaturaAssinador.get_Status() == 1 ? true : arquivoParaAssinaturaAssinador.get_Status() == 2));
+ }
+ return flag;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> VerificarEnviado(long id)
+ {
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ using (UnitOfWork read = InstanciaAssinador.Read)
+ {
+ ArquivoParaAssinaturaAssinador arquivoParaAssinaturaAssinador = read.get_ArquivoParaAssinaturaRepository().FindByIndice(id);
+ flag = (arquivoParaAssinaturaAssinador == null ? false : arquivoParaAssinaturaAssinador.get_Status() == 0);
+ }
+ return flag;
+ });
+ return flag1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/CepService.cs b/Codemerx/Gestor.Application/Servicos/CepService.cs new file mode 100644 index 0000000..f33d711 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/CepService.cs @@ -0,0 +1,161 @@ +using Agger.Registro;
+using Gestor.Application.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Helper;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Diagnostics;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class CepService
+ {
+ private const string GuidGestor = "bbbf4f03-01fc-4300-b430-33e007753578";
+
+ public CepService()
+ {
+ }
+
+ private static async Task<string> Authorization()
+ {
+ 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 apiCep = Address.get_ApiCep();
+ string[] strArrays = new string[] { "/auth" };
+ Uri uri = apiCep.Append(strArrays);
+ HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(uri, 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;
+ }
+
+ public async Task<EnderecoBase> SearchDirect(string cep)
+ {
+ return await this.SearchDirectApiAgger(cep);
+ }
+
+ public async Task<EnderecoBase> SearchDirectApiAgger(string cep)
+ {
+ EnderecoBase enderecoBase;
+ string upper;
+ string str;
+ string upper1;
+ string str1;
+ string upper2;
+ try
+ {
+ string str2 = Gestor.Model.Helper.ValidationHelper.OnlyNumber(cep);
+ if (!Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(str2))
+ {
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string str3 = await CepService.Authorization();
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str3));
+ Uri apiCep = Address.get_ApiCep();
+ string[] strArrays = new string[] { str2 };
+ Uri uri = apiCep.Append(strArrays);
+ string str4 = await await httpClient.GetAsync(uri).get_Content().ReadAsStringAsync();
+ JObject jObject = JObject.Parse(str4);
+ if (jObject == null || str4.Equals("Endereço não encontrado"))
+ {
+ enderecoBase = null;
+ }
+ else
+ {
+ EnderecoBase enderecoBase1 = new EnderecoBase();
+ JToken item = jObject.get_Item("logradouro");
+ if (item != null)
+ {
+ upper = item.ToString().ToUpper();
+ }
+ else
+ {
+ upper = null;
+ }
+ enderecoBase1.set_Endereco(upper);
+ JToken jToken = jObject.get_Item("bairro");
+ if (jToken != null)
+ {
+ str = jToken.ToString().ToUpper();
+ }
+ else
+ {
+ str = null;
+ }
+ enderecoBase1.set_Bairro(str);
+ JToken item1 = jObject.get_Item("cidade");
+ if (item1 != null)
+ {
+ upper1 = item1.ToString().ToUpper();
+ }
+ else
+ {
+ upper1 = null;
+ }
+ enderecoBase1.set_Cidade(upper1);
+ JToken jToken1 = jObject.get_Item("estado");
+ if (jToken1 != null)
+ {
+ str1 = jToken1.ToString().ToUpper();
+ }
+ else
+ {
+ str1 = null;
+ }
+ enderecoBase1.set_Estado(str1);
+ JToken item2 = jObject.get_Item("cep");
+ if (item2 != null)
+ {
+ upper2 = item2.ToString().ToUpper();
+ }
+ else
+ {
+ upper2 = null;
+ }
+ enderecoBase1.set_Cep(upper2);
+ enderecoBase = enderecoBase1;
+ }
+ }
+ }
+ else
+ {
+ enderecoBase = null;
+ }
+ }
+ catch (Exception exception)
+ {
+ enderecoBase = null;
+ }
+ return enderecoBase;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs b/Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs new file mode 100644 index 0000000..d61518e --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Configuracoes/ConfuguracoesServico.cs @@ -0,0 +1,464 @@ +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.Seguros;
+using Gestor.Model.Validation;
+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.Configuracoes
+{
+ public class ConfuguracoesServico : BaseServico
+ {
+ public ConfuguracoesServico()
+ {
+ }
+
+ public async Task<List<ConfiguracaoSistema>> Buscar()
+ {
+ int num = 3;
+ List<ConfiguracaoSistema> configuracaoSistemas1 = await Task.Run<List<ConfiguracaoSistema>>(() => {
+ List<ConfiguracaoSistema> configuracaoSistemas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ configuracaoSistemas = read.get_ConfiguracaoRepository().BuscarConfiguracoes();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 297, num, null, true);
+ continue;
+ }
+ return configuracaoSistemas;
+ }
+ return null;
+ });
+ return configuracaoSistemas1;
+ }
+
+ public async Task<List<ParametrosRelatorio>> BuscarParametros(Relatorio relatorio)
+ {
+ int num = 3;
+ List<ParametrosRelatorio> parametrosRelatorios1 = await Task.Run<List<ParametrosRelatorio>>(() => {
+ List<ParametrosRelatorio> parametrosRelatorios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parametrosRelatorios = read.get_ParametrosRelatorioRepository().Find(Recursos.Usuario.get_Id(), relatorio);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 301, num, new { Id = Recursos.Usuario.get_Id(), relatorio = relatorio }, true);
+ continue;
+ }
+ return parametrosRelatorios;
+ }
+ return null;
+ });
+ return parametrosRelatorios1;
+ }
+
+ public List<ParametrosTotalizacao> BuscarParametroTotalizacao(Relatorio relatorio)
+ {
+ List<ParametrosTotalizacao> parametrosTotalizacaos;
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parametrosTotalizacaos = read.get_ParametrosTotalizacaoRepository().Find(Recursos.Usuario.get_Id(), relatorio);
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ num = base.Registrar(exception, 302, num, new { Id = Recursos.Usuario.get_Id(), relatorio = relatorio }, true);
+ continue;
+ }
+ return parametrosTotalizacaos;
+ }
+ return null;
+ }
+
+ public async Task<List<ParametrosTotalizacao>> BuscarParametroTotalizacaoAsync(Relatorio relatorio)
+ {
+ int num = 3;
+ List<ParametrosTotalizacao> parametrosTotalizacaos1 = await Task.Run<List<ParametrosTotalizacao>>(() => {
+ List<ParametrosTotalizacao> parametrosTotalizacaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parametrosTotalizacaos = read.get_ParametrosTotalizacaoRepository().Find(Recursos.Usuario.get_Id(), relatorio);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 302, num, new { Id = Recursos.Usuario.get_Id(), relatorio = relatorio }, true);
+ continue;
+ }
+ return parametrosTotalizacaos;
+ }
+ return null;
+ });
+ return parametrosTotalizacaos1;
+ }
+
+ public async Task<bool> Excluir(ConfiguracaoSistema configuracao)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_ConfiguracaoRepository().Delete(configuracao.get_Id());
+ DateTime networkTime = Gestor.Application.Helpers.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.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A CONFIGURAÇÃO {2} ", Recursos.Usuario.get_Nome(), networkTime, Gestor.Model.Validation.Funcoes.GetDescription(configuracao.get_Configuracao())));
+ registroLog.set_EntidadeId(configuracao.get_Id());
+ registroLog.set_Tela(50);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = ConfuguracoesServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConfuguracoesServico.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, 298, num, configuracao, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<ConfiguracaoSistema> Salvar(ConfiguracaoSistema configuracao)
+ {
+ int num = 3;
+ ConfiguracaoSistema configuracaoSistema2 = await Task.Run<ConfiguracaoSistema>(() => {
+ ConfiguracaoSistema configuracaoSistema;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ConfiguracaoSistema configuracaoSistema1 = commited.get_ConfiguracaoRepository().SaveOrUpdate(configuracao);
+ DateTime networkTime = Gestor.Application.Helpers.Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(0);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ registroLog.set_Descricao(string.Format("O USUÁRIO {0} ADICIONOU, EM {1}, A CONFIGURAÇÃO {2} ", Recursos.Usuario.get_Nome(), networkTime, Gestor.Model.Validation.Funcoes.GetDescription(configuracaoSistema1.get_Configuracao())));
+ registroLog.set_EntidadeId(configuracaoSistema1.get_Id());
+ registroLog.set_Tela(50);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = ConfuguracoesServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConfuguracoesServico.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();
+ configuracaoSistema = configuracaoSistema1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 298, num, configuracao, true);
+ continue;
+ }
+ return configuracaoSistema;
+ }
+ return configuracao;
+ });
+ return configuracaoSistema2;
+ }
+
+ public async Task<bool> Salvar(List<ParametrosRelatorio> parametrosSalvar, List<ParametrosRelatorio> parametrosDelete)
+ {
+ int num = 3;
+ DateTime networkTime = Gestor.Application.Helpers.Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ string str1;
+ while (num > 0)
+ {
+ try
+ {
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ foreach (ParametrosRelatorio parametrosRelatorio in parametrosSalvar)
+ {
+ if (parametrosRelatorio.get_IdUsuario() == 0)
+ {
+ parametrosRelatorio.set_Id((long)0);
+ parametrosRelatorio.set_IdUsuario(Recursos.Usuario.get_Id());
+ }
+ parametrosRelatorio.set_Ordem(parametrosSalvar.IndexOf(parametrosRelatorio));
+ TipoAcao tipoAcao = (parametrosRelatorio.get_Id() == 0 ? 0 : 1);
+ ParametrosRelatorio parametrosRelatorio1 = (parametrosRelatorio.get_Id() == 0 ? commited.get_ParametrosRelatorioRepository().SaveOrUpdate(parametrosRelatorio) : commited.get_ParametrosRelatorioRepository().Merge(parametrosRelatorio));
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(parametrosRelatorio1));
+ registroLog.set_EntidadeId(parametrosRelatorio1.get_Id());
+ registroLog.set_Tela(50);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_61 = ConfuguracoesServico.u003cu003ec.u003cu003e9__6_1;
+ if (u003cu003e9_61 == null)
+ {
+ u003cu003e9_61 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConfuguracoesServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_61);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ foreach (ParametrosRelatorio parametrosRelatorio2 in parametrosDelete)
+ {
+ if (parametrosRelatorio2.get_Id() == 0)
+ {
+ continue;
+ }
+ commited.get_ParametrosRelatorioRepository().Delete(parametrosRelatorio2.get_Id());
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(2);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(parametrosRelatorio2));
+ registroLog1.set_EntidadeId(parametrosRelatorio2.get_Id());
+ registroLog1.set_Tela(50);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] pAddressArray = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_62 = ConfuguracoesServico.u003cu003ec.u003cu003e9__6_2;
+ if (u003cu003e9_62 == null)
+ {
+ u003cu003e9_62 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConfuguracoesServico.u003cu003ec.u003cu003e9__6_2 = u003cu003e9_62;
+ }
+ IPAddress pAddress1 = ((IEnumerable<IPAddress>)pAddressArray).FirstOrDefault<IPAddress>(u003cu003e9_62);
+ if (pAddress1 != null)
+ {
+ str1 = pAddress1.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog1.set_Ip(str1);
+ base.SaveLog(registroLog1, commited);
+ }
+ commited.Commit();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 303, num, parametrosSalvar, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> SalvarTotalizacoes(List<ParametrosTotalizacao> parametrosSalvar, List<ParametrosTotalizacao> parametrosDeletar)
+ {
+ int num = 3;
+ DateTime networkTime = Gestor.Application.Helpers.Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ string str1;
+ while (num > 0)
+ {
+ try
+ {
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ foreach (ParametrosTotalizacao parametrosTotalizacao in parametrosSalvar)
+ {
+ if (parametrosTotalizacao.get_IdUsuario() == 0)
+ {
+ parametrosTotalizacao.set_Id((long)0);
+ parametrosTotalizacao.set_IdUsuario(Recursos.Usuario.get_Id());
+ }
+ parametrosTotalizacao.set_Ativa(true);
+ TipoAcao tipoAcao = (parametrosTotalizacao.get_Id() == 0 ? 0 : 1);
+ ParametrosTotalizacao parametrosTotalizacao1 = (parametrosTotalizacao.get_Id() == 0 ? commited.get_ParametrosTotalizacaoRepository().SaveOrUpdate(parametrosTotalizacao) : commited.get_ParametrosTotalizacaoRepository().Merge(parametrosTotalizacao));
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(parametrosTotalizacao1));
+ registroLog.set_EntidadeId(parametrosTotalizacao1.get_Id());
+ registroLog.set_Tela(50);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_71 = ConfuguracoesServico.u003cu003ec.u003cu003e9__7_1;
+ if (u003cu003e9_71 == null)
+ {
+ u003cu003e9_71 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConfuguracoesServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_71);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ foreach (ParametrosTotalizacao parametrosTotalizacao2 in parametrosDeletar)
+ {
+ if (parametrosTotalizacao2.get_Id() == 0)
+ {
+ continue;
+ }
+ commited.get_ParametrosTotalizacaoRepository().Delete(parametrosTotalizacao2.get_Id());
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(2);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(parametrosTotalizacao2));
+ registroLog1.set_EntidadeId(parametrosTotalizacao2.get_Id());
+ registroLog1.set_Tela(50);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] pAddressArray = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_72 = ConfuguracoesServico.u003cu003ec.u003cu003e9__7_2;
+ if (u003cu003e9_72 == null)
+ {
+ u003cu003e9_72 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ConfuguracoesServico.u003cu003ec.u003cu003e9__7_2 = u003cu003e9_72;
+ }
+ IPAddress pAddress1 = ((IEnumerable<IPAddress>)pAddressArray).FirstOrDefault<IPAddress>(u003cu003e9_72);
+ if (pAddress1 != null)
+ {
+ str1 = pAddress1.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog1.set_Ip(str1);
+ base.SaveLog(registroLog1, commited);
+ }
+ commited.Commit();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 304, num, parametrosSalvar, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs new file mode 100644 index 0000000..24289ac --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs @@ -0,0 +1,281 @@ +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.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ public class AdiantamentoServico : BaseServico
+ {
+ public AdiantamentoServico()
+ {
+ }
+
+ public async Task<List<Adiantamento>> BuscarAdiantamentos(long id, bool concluido)
+ {
+ int num = 3;
+ List<Adiantamento> adiantamentos1 = await Task.Run<List<Adiantamento>>(() => {
+ List<Adiantamento> adiantamentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ adiantamentos = read.get_AdiantamentoRepository().BuscarAdiantamentos(id, concluido);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 16, num, new { id = id, concluido = concluido }, true);
+ continue;
+ }
+ return adiantamentos;
+ }
+ return new List<Adiantamento>();
+ });
+ return adiantamentos1;
+ }
+
+ public async Task<List<Adiantamento>> BuscarPorData(Filtros filtro, bool segundavia = false)
+ {
+ int num = 3;
+ List<Adiantamento> adiantamentos1 = await Task.Run<List<Adiantamento>>(() => {
+ List<Adiantamento> adiantamentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ adiantamentos = read.get_AdiantamentoRepository().FindByDate(filtro.get_Inicio(), filtro.get_Fim(), filtro.get_Vendedores(), segundavia);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 15, num, filtro, true);
+ continue;
+ }
+ return adiantamentos;
+ }
+ return new List<Adiantamento>();
+ });
+ return adiantamentos1;
+ }
+
+ public async Task<bool> Delete(Adiantamento adiantamento)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ object obj;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_AdiantamentoRepository().Delete(adiantamento.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} EXCLUIU, EM {1}, O PARCEIRO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", adiantamento.get_Id()), ", HISTÓRICO: '", null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(adiantamento.get_Historico()) ? "" : adiantamento.get_Historico() ?? "");
+ strArrays[4] = "', DATA DO ADIANTAMENTO: '";
+ DateTime? data = adiantamento.get_Data();
+ if (!data.HasValue)
+ {
+ obj = "";
+ }
+ else
+ {
+ data = adiantamento.get_Data();
+ obj = (data.HasValue ? data.GetValueOrDefault().ToShortDateString() : null) ?? "";
+ }
+ strArrays[5] = (string)obj;
+ strArrays[6] = "'";
+ strArrays[7] = string.Format(", VALOR DO ADIANTAMENTO: 'R${0}'.", adiantamento.get_Valor());
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(adiantamento.get_Id());
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_Tela(36);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog2 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = AdiantamentoServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AdiantamentoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ 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, 210, num, adiantamento, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task GerarPagamento(List<Adiantamento> adiantamentos)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ await Task.Run(() => {
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ adiantamentos.ForEach((Adiantamento x) => {
+ string str;
+ Adiantamento adiantamento = commited.get_AdiantamentoRepository().FindById(x.get_Id());
+ adiantamento.set_Pago(true);
+ adiantamento.set_Pagamento(new DateTime?(networkTime));
+ adiantamento = commited.get_AdiantamentoRepository().Merge(adiantamento);
+ 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(adiantamento, jsonSerializerSetting));
+ registroLog.set_EntidadeId(adiantamento.get_Id());
+ registroLog.set_Tela(36);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_42 = AdiantamentoServico.u003cu003ec.u003cu003e9__4_2;
+ if (u003cu003e9_42 == null)
+ {
+ u003cu003e9_42 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AdiantamentoServico.u003cu003ec.u003cu003e9__4_2 = u003cu003e9_42;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_42);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ commited.Commit();
+ break;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 194, num, adiantamentos, true);
+ }
+ }
+ });
+ }
+
+ public async Task<Adiantamento> Save(Adiantamento adiatamento)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Adiantamento adiantamento2 = adiatamento;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Adiantamento adiantamento3 = await Task.Run<Adiantamento>(() => {
+ Adiantamento adiantamento;
+ string str;
+ while (num > 0)
+ {
+ adiatamento = adiantamento2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (adiatamento.get_Id() == 0 ? 0 : 1);
+ adiatamento.set_Pagamento((adiatamento.get_Pago() ? new DateTime?(networkTime) : null));
+ adiatamento = (adiatamento.get_Id() == 0 ? commited.get_AdiantamentoRepository().SaveOrUpdate(adiatamento) : commited.get_AdiantamentoRepository().Merge(adiatamento));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Adiantamento adiantamento1 = adiatamento;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(adiantamento1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(adiatamento.get_Id());
+ registroLog.set_Tela(36);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = AdiantamentoServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AdiantamentoServico.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();
+ adiantamento = adiatamento;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 209, num, adiatamento, true);
+ continue;
+ }
+ return adiantamento;
+ }
+ return adiantamento2;
+ });
+ return adiantamento3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs new file mode 100644 index 0000000..d52af23 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs @@ -0,0 +1,257 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+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.Ferramentas
+{
+ internal class AgendaServico : BaseServico
+ {
+ public AgendaServico()
+ {
+ }
+
+ internal async Task<ObservableCollection<AgendaEmail>> BuscarEmailsAsync(long id)
+ {
+ int num = 3;
+ ObservableCollection<AgendaEmail> observableCollection1 = await Task.Run<ObservableCollection<AgendaEmail>>(() => {
+ ObservableCollection<AgendaEmail> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<AgendaEmail>(read.get_AgendaEmailRepository().FindByAgendaId(id));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 108, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<AgendaEmail>();
+ });
+ return observableCollection1;
+ }
+
+ internal async Task<ObservableCollection<AgendaTelefone>> BuscarTelefonesAsync(long id)
+ {
+ int num = 3;
+ ObservableCollection<AgendaTelefone> observableCollection1 = await Task.Run<ObservableCollection<AgendaTelefone>>(() => {
+ ObservableCollection<AgendaTelefone> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<AgendaTelefone>(read.get_AgendaTelefoneRepository().FindByAgendaId(id));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 107, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<AgendaTelefone>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<bool> Delete(Agenda agenda)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_AgendaRepository().Delete(agenda.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}, O CONTATO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", agenda.get_Id()), ", NOME: '", (string.IsNullOrWhiteSpace(agenda.get_Nome()) ? "" : agenda.get_Nome() ?? ""), "', ENDEREÇO: '", agenda.get_Endereco(), ", ", agenda.get_Numero(), ", ", (string.IsNullOrWhiteSpace(agenda.get_Complemento()) ? "-" : agenda.get_Complemento() ?? ""), ", ", agenda.get_Bairro(), ", ", agenda.get_Cidade(), "/", agenda.get_Estado(), " - ", agenda.get_Cep(), "', OBSERVAÇÃO: '", (string.IsNullOrWhiteSpace(agenda.get_Observacao()) ? "" : agenda.get_Observacao() ?? ""), "'." }));
+ registroLog.set_EntidadeId(agenda.get_Id());
+ registroLog.set_Tela(34);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog1 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = AgendaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AgendaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ 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, 216, num, agenda, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Agenda> Save(Agenda agenda)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Agenda agenda2 = agenda;
+ Agenda agenda3 = await Task.Run<Agenda>(() => {
+ Agenda agenda4;
+ List<AgendaTelefone> list;
+ List<AgendaEmail> agendaEmails;
+ string str;
+ while (num > 0)
+ {
+ agenda = agenda2;
+ try
+ {
+ TipoAcao tipoAcao = (agenda.get_Id() == 0 ? 0 : 1);
+ ObservableCollection<AgendaTelefone> telefones = agenda.get_Telefones();
+ if (telefones != null)
+ {
+ list = telefones.ToList<AgendaTelefone>();
+ }
+ else
+ {
+ list = null;
+ }
+ List<AgendaTelefone> agendaTelefones = list;
+ ObservableCollection<AgendaEmail> emails = agenda.get_Emails();
+ if (emails != null)
+ {
+ agendaEmails = emails.ToList<AgendaEmail>();
+ }
+ else
+ {
+ agendaEmails = null;
+ }
+ List<AgendaEmail> agendaEmails1 = agendaEmails;
+ agenda.set_Telefones(null);
+ agenda.set_Emails(null);
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (agenda.get_Id() != (long)0)
+ {
+ if (agendaTelefones != null)
+ {
+ agendaTelefones = commited.get_AgendaTelefoneRepository().Merge(agendaTelefones, agenda);
+ }
+ if (agendaEmails1 != null)
+ {
+ agendaEmails1 = commited.get_AgendaEmailRepository().Merge(agendaEmails1, agenda);
+ }
+ agenda = commited.get_AgendaRepository().Merge(agenda);
+ }
+ else
+ {
+ agenda = commited.get_AgendaRepository().SaveOrUpdate(agenda);
+ if (agendaTelefones != null)
+ {
+ agendaTelefones = commited.get_AgendaTelefoneRepository().Inserir(agendaTelefones, agenda);
+ }
+ if (agendaEmails1 != null)
+ {
+ agendaEmails1 = commited.get_AgendaEmailRepository().Inserir(agendaEmails1, agenda);
+ }
+ }
+ agenda.set_Telefones((agendaTelefones == null ? null : new ObservableCollection<AgendaTelefone>(agendaTelefones)));
+ agenda.set_Emails((agendaEmails1 == null ? null : new ObservableCollection<AgendaEmail>(agendaEmails1)));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Agenda agenda1 = agenda;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(agenda1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(agenda.get_Id());
+ registroLog.set_Tela(34);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = AgendaServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ AgendaServico.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();
+ agenda4 = agenda;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 215, num, agenda, true);
+ continue;
+ }
+ return agenda4;
+ }
+ return agenda2;
+ });
+ return agenda3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs new file mode 100644 index 0000000..2e8887d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs @@ -0,0 +1,127 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Common.Helpers;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+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.Ferramentas
+{
+ internal class EmailServico : BaseServico
+ {
+ public EmailServico()
+ {
+ }
+
+ internal async Task<List<ClienteEmail>> BuscarEmail(string email)
+ {
+ 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().FindEmailCliente(email, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 109, num, email, true);
+ continue;
+ }
+ return clienteEmails;
+ }
+ return new List<ClienteEmail>();
+ });
+ return clienteEmails1;
+ }
+
+ public async Task<bool> Delete(Credencial email)
+ {
+ 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(email.get_Id(), email.GetValorOriginal(), 17, 2));
+ commited.get_CredencialRepository().Delete(email.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 218, num, email, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Credencial> Save(Credencial credencial)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Credencial credencial1 = credencial;
+ Credencial credencial2 = await Task.Run<Credencial>(() => {
+ Credencial credencial3;
+ bool flag;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ credencial = credencial1;
+ while (num > 0)
+ {
+ credencial = credencial1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (credencial.get_Id() == 0 ? false : true);
+ credencial.set_Senha(EncryptionHelper.Encrypt(credencial.get_Senha()));
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(credencial.get_Id(), credencial, 17));
+ }
+ credencial = (credencial.get_Id() == 0 ? commited.get_CredencialRepository().SaveOrUpdate(credencial) : commited.get_CredencialRepository().Merge(credencial));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(credencial.get_Id(), credencial.GetValorOriginal(), 17, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ credencial3 = credencial;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 217, num, credencial, true);
+ continue;
+ }
+ return credencial3;
+ }
+ return credencial1;
+ });
+ return credencial2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs new file mode 100644 index 0000000..4d6d354 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs @@ -0,0 +1,287 @@ +using ArquivoDigital.Infrastructure.Repository.Interface;
+using ArquivoDigital.Infrastructure.UnitOfWork.Logic;
+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.API;
+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.Ferramentas
+{
+ internal class EmpresaServico : BaseServico
+ {
+ public EmpresaServico()
+ {
+ }
+
+ public async void AtualizarLogoId(long id, string idLogo)
+ {
+ await Task.Run(() => {
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited)
+ {
+ Empresa empresa = commited.get_EmpresaRepository().FindById(id);
+ empresa.set_LogoId(idLogo);
+ commited.get_EmpresaRepository().Merge(empresa);
+ commited.Commit();
+ }
+ }
+ catch (Exception exception)
+ {
+ }
+ });
+ }
+
+ internal async Task<Empresa> BuscarEmpresaPorId(long id)
+ {
+ int num = 3;
+ Empresa empresa1 = await Task.Run<Empresa>(() => {
+ Empresa empresa;
+ while (num > 0)
+ {
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ empresa = read.get_EmpresaRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 114, num, id, true);
+ continue;
+ }
+ return empresa;
+ }
+ return new Empresa();
+ });
+ return empresa1;
+ }
+
+ internal async Task<List<Empresa>> BuscarEmpresas()
+ {
+ int num = 3;
+ List<Empresa> empresas1 = await Task.Run<List<Empresa>>(() => {
+ List<Empresa> empresas;
+ while (num > 0)
+ {
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ empresas = read.get_EmpresaRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 113, num, null, true);
+ continue;
+ }
+ return empresas;
+ }
+ return new List<Empresa>();
+ });
+ return empresas1;
+ }
+
+ public string BuscarSenhaAdm()
+ {
+ string str;
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ str = read.get_EmpresaRepository().BuscarSenhaAdm((long)1);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 115, num, null, true);
+ continue;
+ }
+ return str;
+ }
+ return null;
+ }
+
+ public async Task<double> ConsultaEspacoBancoInGb()
+ {
+ double num3 = await Task.Run<double>(() => {
+ double num;
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read)
+ {
+ double num1 = read.get_EmpresaRepository().ConsultaEspacoBancoInGb();
+ double num2 = 0;
+ try
+ {
+ foreach (ControleArquivoDigital controleArquivoDigital in read.get_IndiceArquivoDigitalRepository().BuscarBancos())
+ {
+ if (controleArquivoDigital.get_Tabela().ToLower() == "arquivos")
+ {
+ continue;
+ }
+ try
+ {
+ Gestor.Application.Helpers.ArquivoDigital.SetConnection(controleArquivoDigital.get_Catalogo());
+ using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Gestor.Application.Helpers.ArquivoDigital.Read)
+ {
+ num2 += unitOfWork.get_ArquivoDigitalRepository().ConsultaEspacoBancoInGb();
+ }
+ }
+ catch
+ {
+ }
+ }
+ }
+ catch
+ {
+ }
+ num = num1 + num2;
+ }
+ }
+ catch (Exception exception)
+ {
+ return 0;
+ }
+ return num;
+ });
+ return num3;
+ }
+
+ internal async Task<Customer> Save(Customer customer)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Customer customer1 = customer;
+ Customer customer2 = await Task.Run<Customer>(() => {
+ Customer customer3;
+ while (num > 0)
+ {
+ customer = customer1;
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited)
+ {
+ Empresa empresa = new Empresa();
+ empresa.set_Nome(customer.get_Name());
+ empresa.set_Documento(customer.get_Document());
+ empresa.set_Bairro(customer.get_District());
+ empresa.set_Cidade(customer.get_City());
+ empresa.set_Complemento(customer.get_Adjunct());
+ empresa.set_Numero(customer.get_Number());
+ empresa.set_Cep(customer.get_PostCode());
+ empresa.set_Estado(customer.get_State());
+ empresa.set_Email(customer.get_Mail());
+ empresa.set_PrimeiroPrefixo(customer.get_AreaCode());
+ empresa.set_PrimeiroTelefone(customer.get_Phone());
+ empresa.set_SegundoPrefixo(customer.get_SecondAreaCode());
+ empresa.set_SegundoTelefone(customer.get_SecondPhone());
+ empresa.set_Serial(ApplicationHelper.NumeroSerial);
+ empresa.set_Site(customer.get_Site());
+ commited.get_EmpresaRepository().SaveOrUpdate(empresa);
+ commited.Commit();
+ customer3 = customer;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 277, num, customer, true);
+ continue;
+ }
+ return customer3;
+ }
+ return customer1;
+ });
+ return customer2;
+ }
+
+ public async Task<Empresa> Save(Empresa empresa)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Empresa empresa2 = empresa;
+ Empresa empresa3 = await Task.Run<Empresa>(() => {
+ Empresa empresa4;
+ string str;
+ while (num > 0)
+ {
+ empresa = empresa2;
+ try
+ {
+ using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (empresa.get_Id() == 0 ? 0 : 1);
+ empresa = (empresa.get_Id() == 0 ? commited.get_EmpresaRepository().SaveOrUpdate(empresa) : commited.get_EmpresaRepository().Merge(empresa));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ if (Recursos.Usuario.get_Id() != 0)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Empresa empresa1 = empresa;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(empresa1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(empresa.get_Id());
+ registroLog.set_Tela(18);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_31 = EmpresaServico.u003cu003ec.u003cu003e9__3_1;
+ if (u003cu003e9_31 == null)
+ {
+ u003cu003e9_31 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ EmpresaServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_31);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ commited.Commit();
+ empresa4 = empresa;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 277, num, empresa, true);
+ continue;
+ }
+ return empresa4;
+ }
+ return empresa2;
+ });
+ return empresa3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs new file mode 100644 index 0000000..413a361 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs @@ -0,0 +1,124 @@ +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.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class EstipulanteServico : BaseServico
+ {
+ public EstipulanteServico()
+ {
+ }
+
+ internal async Task<Estipulante> BuscarEstipulantePorId(long id)
+ {
+ int num = 3;
+ Estipulante estipulante1 = await Task.Run<Estipulante>(() => {
+ Estipulante estipulante;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ estipulante = read.get_EstipulanteRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 110, num, id, true);
+ continue;
+ }
+ return estipulante;
+ }
+ return new Estipulante();
+ });
+ return estipulante1;
+ }
+
+ public async Task<bool> Delete(Estipulante estipulante)
+ {
+ 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(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 2));
+ commited.get_EstipulanteRepository().Delete(estipulante.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 220, num, estipulante, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Estipulante> Save(Estipulante estipulante)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Estipulante estipulante1 = estipulante;
+ Estipulante estipulante2 = await Task.Run<Estipulante>(() => {
+ Estipulante estipulante3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ estipulante = estipulante1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ estipulante.set_IdEmpresa(Recursos.Empresa.get_Id());
+ flag = (estipulante.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante, 9));
+ }
+ estipulante = (estipulante.get_Id() == 0 ? commited.get_EstipulanteRepository().SaveOrUpdate(estipulante) : commited.get_EstipulanteRepository().Merge(estipulante));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ estipulante3 = estipulante;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 219, num, estipulante, true);
+ continue;
+ }
+ return estipulante3;
+ }
+ return estipulante1;
+ });
+ return estipulante2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs new file mode 100644 index 0000000..ac8cd9f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs @@ -0,0 +1,171 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using 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.Ferramentas
+{
+ public class ImpostoServico : BaseServico
+ {
+ public ImpostoServico()
+ {
+ }
+
+ public async Task<List<Imposto>> Buscar(bool? ativo)
+ {
+ int num = 3;
+ List<Imposto> impostos1 = await Task.Run<List<Imposto>>(() => {
+ List<Imposto> impostos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ impostos = read.get_ImpostoRepository().DefaultSelect(ativo);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 317, num, ativo, true);
+ continue;
+ }
+ return impostos;
+ }
+ return new List<Imposto>();
+ });
+ return impostos1;
+ }
+
+ public async Task<List<Imposto>> BuscarPorRamo(long id)
+ {
+ int num = 3;
+ List<Imposto> impostos1 = await Task.Run<List<Imposto>>(() => {
+ List<Imposto> impostos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ impostos = read.get_ImpostoRepository().FindByRamo(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 317, num, id, true);
+ continue;
+ }
+ return impostos;
+ }
+ return new List<Imposto>();
+ });
+ return impostos1;
+ }
+
+ public async Task<List<Imposto>> BuscarPorSeguradora(long id)
+ {
+ int num = 3;
+ List<Imposto> impostos1 = await Task.Run<List<Imposto>>(() => {
+ List<Imposto> impostos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ impostos = read.get_ImpostoRepository().FindBySeguradora(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 317, num, id, true);
+ continue;
+ }
+ return impostos;
+ }
+ return new List<Imposto>();
+ });
+ return impostos1;
+ }
+
+ public async Task<Imposto> Salvar(Imposto imposto)
+ {
+ int num = 3;
+ Imposto imposto2 = await Task.Run<Imposto>(() => {
+ Imposto imposto3;
+ string str;
+ while (num > 0)
+ {
+ this.Sucesso = true;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (imposto.get_Id() == 0 ? 0 : 1);
+ Imposto imposto1 = (tipoAcao == null ? commited.get_ImpostoRepository().SaveOrUpdate(imposto) : commited.get_ImpostoRepository().Merge(imposto));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(imposto1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(imposto1.get_Id());
+ registroLog.set_Tela(56);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_31 = ImpostoServico.u003cu003ec.u003cu003e9__3_1;
+ if (u003cu003e9_31 == null)
+ {
+ u003cu003e9_31 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ImpostoServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_31);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ imposto3 = imposto1;
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ this.Sucesso = false;
+ num = base.Registrar(exception, 318, num, imposto, false);
+ continue;
+ }
+ return imposto3;
+ }
+ return imposto;
+ });
+ return imposto2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs new file mode 100644 index 0000000..3cac6b8 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs @@ -0,0 +1,182 @@ +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.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class MetaSeguradoraServico : BaseServico
+ {
+ public MetaSeguradoraServico()
+ {
+ }
+
+ public async Task<List<MetaSeguradora>> BuscarMetasSeguradoras(Filtros filtro)
+ {
+ int num = 3;
+ List<MetaSeguradora> metaSeguradoras1 = await Task.Run<List<MetaSeguradora>>(() => {
+ List<MetaSeguradora> metaSeguradoras;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ metaSeguradoras = read.get_MetaSeguradoraRepository().FindByMeta(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 284, num, filtro, true);
+ continue;
+ }
+ return metaSeguradoras;
+ }
+ return new List<MetaSeguradora>();
+ });
+ return metaSeguradoras1;
+ }
+
+ public async Task<bool> Delete(MetaSeguradora meta)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_MetaSeguradoraRepository().Delete(meta.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 META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) }));
+ registroLog.set_EntidadeId(meta.get_Id());
+ registroLog.set_Tela(31);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog1 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ 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, 223, num, meta, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<MetaSeguradora> Save(MetaSeguradora metaSeguradora)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ MetaSeguradora metaSeguradora2 = metaSeguradora;
+ MetaSeguradora metaSeguradora3 = await Task.Run<MetaSeguradora>(() => {
+ MetaSeguradora metaSeguradora4;
+ string str;
+ while (num > 0)
+ {
+ metaSeguradora = metaSeguradora2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (metaSeguradora.get_Id() == 0 ? 0 : 1);
+ metaSeguradora = (metaSeguradora.get_Id() == 0 ? commited.get_MetaSeguradoraRepository().SaveOrUpdate(metaSeguradora) : commited.get_MetaSeguradoraRepository().Merge(metaSeguradora));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ MetaSeguradora metaSeguradora1 = metaSeguradora;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(metaSeguradora1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(metaSeguradora.get_Id());
+ registroLog.set_Tela(31);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MetaSeguradoraServico.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();
+ metaSeguradora4 = metaSeguradora;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 222, num, metaSeguradora, true);
+ continue;
+ }
+ return metaSeguradora4;
+ }
+ return metaSeguradora2;
+ });
+ return metaSeguradora3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs new file mode 100644 index 0000000..5e30a23 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs @@ -0,0 +1,182 @@ +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.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class MetaVendedorServico : BaseServico
+ {
+ public MetaVendedorServico()
+ {
+ }
+
+ public async Task<List<MetaVendedor>> BuscarMetasVendedores(Filtros filtro)
+ {
+ int num = 3;
+ List<MetaVendedor> metaVendedors1 = await Task.Run<List<MetaVendedor>>(() => {
+ List<MetaVendedor> metaVendedors;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ metaVendedors = read.get_MetaVendedorRepository().FindByMeta(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 285, num, filtro, true);
+ continue;
+ }
+ return metaVendedors;
+ }
+ return new List<MetaVendedor>();
+ });
+ return metaVendedors1;
+ }
+
+ public async Task<bool> Delete(MetaVendedor meta)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_MetaVendedorRepository().Delete(meta.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 META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) }));
+ registroLog.set_EntidadeId(meta.get_Id());
+ registroLog.set_Tela(30);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog1 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = MetaVendedorServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MetaVendedorServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ 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, 225, num, meta, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<MetaVendedor> Save(MetaVendedor metaVendedor)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ MetaVendedor metaVendedor2 = metaVendedor;
+ MetaVendedor metaVendedor3 = await Task.Run<MetaVendedor>(() => {
+ MetaVendedor metaVendedor4;
+ string str;
+ while (num > 0)
+ {
+ metaVendedor = metaVendedor2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (metaVendedor.get_Id() == 0 ? 0 : 1);
+ metaVendedor = (metaVendedor.get_Id() == 0 ? commited.get_MetaVendedorRepository().SaveOrUpdate(metaVendedor) : commited.get_MetaVendedorRepository().Merge(metaVendedor));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ MetaVendedor metaVendedor1 = metaVendedor;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(metaVendedor1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(metaVendedor.get_Id());
+ registroLog.set_Tela(30);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = MetaVendedorServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MetaVendedorServico.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();
+ metaVendedor4 = metaVendedor;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 224, num, metaVendedor, true);
+ continue;
+ }
+ return metaVendedor4;
+ }
+ return metaVendedor2;
+ });
+ return metaVendedor3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs new file mode 100644 index 0000000..9ea8485 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs @@ -0,0 +1,176 @@ +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.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class NotaFiscalServico : BaseServico
+ {
+ public NotaFiscalServico()
+ {
+ }
+
+ internal async Task<List<NotaFiscal>> BuscarNotasFiscais()
+ {
+ int num = 3;
+ List<NotaFiscal> notaFiscals1 = await Task.Run<List<NotaFiscal>>(() => {
+ List<NotaFiscal> notaFiscals;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ notaFiscals = read.get_NotaFiscalRepository().FindAll();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 312, num, null, true);
+ continue;
+ }
+ return notaFiscals;
+ }
+ return new List<NotaFiscal>();
+ });
+ return notaFiscals1;
+ }
+
+ public async Task<List<NotaFiscal>> BuscarNotasFiscais(Filtros filtro)
+ {
+ int num = 3;
+ List<NotaFiscal> notaFiscals1 = await Task.Run<List<NotaFiscal>>(() => {
+ List<NotaFiscal> notaFiscals;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ notaFiscals = read.get_NotaFiscalRepository().FindByDatas(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 315, num, filtro, true);
+ continue;
+ }
+ return notaFiscals;
+ }
+ return new List<NotaFiscal>();
+ });
+ return notaFiscals1;
+ }
+
+ internal async Task<bool> Cadatrada(long idExtrato)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_NotaFiscalRepository().FindByExtrato(idExtrato);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 315, num, idExtrato, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> Delete(NotaFiscal notaFiscal)
+ {
+ 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(notaFiscal.get_Id(), notaFiscal.GetValorOriginal(), 55, 2));
+ commited.get_NotaFiscalRepository().Delete(notaFiscal.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 314, num, notaFiscal, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ internal async Task<NotaFiscal> Save(NotaFiscal notaFiscal)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ NotaFiscal notaFiscal1 = notaFiscal;
+ NotaFiscal notaFiscal2 = await Task.Run<NotaFiscal>(() => {
+ NotaFiscal notaFiscal3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ notaFiscal = notaFiscal1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (notaFiscal.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(notaFiscal.get_Id(), notaFiscal, 55));
+ }
+ notaFiscal = (notaFiscal.get_Id() == 0 ? commited.get_NotaFiscalRepository().SaveOrUpdate(notaFiscal) : commited.get_NotaFiscalRepository().Merge(notaFiscal));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(notaFiscal.get_Id(), notaFiscal.GetValorOriginal(), 55, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ notaFiscal3 = notaFiscal;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 313, num, notaFiscal, true);
+ continue;
+ }
+ return notaFiscal3;
+ }
+ return notaFiscal1;
+ });
+ return notaFiscal2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs new file mode 100644 index 0000000..76fd16d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs @@ -0,0 +1,92 @@ +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.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class ProdutoServico : BaseServico
+ {
+ public ProdutoServico()
+ {
+ }
+
+ internal async Task<Produto> BuscarProdutoPorId(long id)
+ {
+ int num = 3;
+ Produto produto1 = await Task.Run<Produto>(() => {
+ Produto produto;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ produto = read.get_ProdutoRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 116, num, id, true);
+ continue;
+ }
+ return produto;
+ }
+ return new Produto();
+ });
+ return produto1;
+ }
+
+ public async Task<Produto> Save(Produto produto)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Produto produto1 = produto;
+ Produto produto2 = await Task.Run<Produto>(() => {
+ Produto produto3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ produto = produto1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (produto.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(produto.get_Id(), produto, 10));
+ }
+ produto = (produto.get_Id() == 0 ? commited.get_ProdutoRepository().SaveOrUpdate(produto) : commited.get_ProdutoRepository().Merge(produto));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(produto.get_Id(), produto.GetValorOriginal(), 10, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ produto3 = produto;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 226, num, produto, true);
+ continue;
+ }
+ return produto3;
+ }
+ return produto1;
+ });
+ return produto2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs new file mode 100644 index 0000000..5d7507b --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs @@ -0,0 +1,57 @@ +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.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class QualificacaoServico : BaseServico
+ {
+ public QualificacaoServico()
+ {
+ }
+
+ internal async Task<Qualificacao> Save(Qualificacao qualificacao)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Qualificacao qualificacao2 = qualificacao;
+ Qualificacao qualificacao3 = await Task.Run<Qualificacao>(() => {
+ Qualificacao qualificacao4;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ qualificacao = qualificacao2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ registroLogs.Add(base.CreateLog(qualificacao.get_Id(), qualificacao, 48));
+ Qualificacao qualificacao1 = commited.get_QualificacaoRepository().SaveOrUpdate(qualificacao);
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ qualificacao4 = qualificacao1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 229, num, qualificacao, true);
+ continue;
+ }
+ return qualificacao4;
+ }
+ return qualificacao2;
+ });
+ return qualificacao3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs new file mode 100644 index 0000000..a347e2c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.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.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.Ferramentas
+{
+ internal class RamoServico : BaseServico
+ {
+ public RamoServico()
+ {
+ }
+
+ public async Task<List<Ramo>> BuscarRamos()
+ {
+ int num = 3;
+ List<Ramo> ramos1 = await Task.Run<List<Ramo>>(() => {
+ List<Ramo> ramos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ramos = commited.get_RamoRepository().Find();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 169, num, null, true);
+ continue;
+ }
+ return ramos;
+ }
+ return null;
+ });
+ return ramos1;
+ }
+
+ public async Task<Ramo> Insert(Ramo ramo)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Ramo ramo2 = ramo;
+ Ramo ramo3 = await Task.Run<Ramo>(() => {
+ Ramo ramo4;
+ string str;
+ while (num > 0)
+ {
+ ramo = ramo2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ramo = commited.get_RamoRepository().SaveOrUpdate(ramo);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(0);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Ramo ramo1 = ramo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(ramo1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(ramo.get_Id());
+ registroLog.set_Tela(12);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = RamoServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ RamoServico.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();
+ ramo4 = ramo;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 230, num, ramo, true);
+ continue;
+ }
+ return ramo4;
+ }
+ return ramo2;
+ });
+ return ramo3;
+ }
+
+ internal async Task<Ramo> Save(Ramo ramo, List<CoberturaPadrao> coberturas)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Ramo ramo3 = ramo;
+ Ramo ramo4 = await Task.Run<Ramo>(() => {
+ Ramo ramo5;
+ string str;
+ while (num > 0)
+ {
+ ramo = ramo3;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ Ramo ramo1 = commited.get_RamoRepository().SaveOrUpdate(ramo);
+ List<CoberturaPadrao> coberturaPadraos = coberturas;
+ if (coberturaPadraos != null)
+ {
+ coberturaPadraos.ForEach((CoberturaPadrao x) => commited.get_CoberturaPadraoRepository().Merge(x));
+ }
+ else
+ {
+ }
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Ramo ramo2 = ramo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(ramo2, jsonSerializerSetting));
+ registroLog.set_EntidadeId(ramo.get_Id());
+ registroLog.set_Tela(12);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_02 = RamoServico.u003cu003ec.u003cu003e9__0_2;
+ if (u003cu003e9_02 == null)
+ {
+ u003cu003e9_02 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ RamoServico.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_02);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ ramo5 = ramo1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 228, num, new { ramo = ramo, coberturas = coberturas }, true);
+ continue;
+ }
+ return ramo5;
+ }
+ return ramo3;
+ });
+ return ramo4;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs new file mode 100644 index 0000000..ceee657 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs @@ -0,0 +1,123 @@ +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.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class ReciboServico : BaseServico
+ {
+ public ReciboServico()
+ {
+ }
+
+ internal async Task<List<Recibo>> BuscarRecibos()
+ {
+ int num = 3;
+ List<Recibo> recibos1 = await Task.Run<List<Recibo>>(() => {
+ List<Recibo> recibos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ recibos = read.get_ReciboRepository().BuscarRecibos();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 123, num, null, true);
+ continue;
+ }
+ return recibos;
+ }
+ return new List<Recibo>();
+ });
+ return recibos1;
+ }
+
+ public async Task<bool> Delete(Recibo recibo)
+ {
+ 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(recibo.get_Id(), recibo.GetValorOriginal(), 42, 2));
+ commited.get_ReciboRepository().Delete(recibo.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 232, num, recibo, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Recibo> Save(Recibo recibo)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Recibo recibo1 = recibo;
+ Recibo recibo2 = await Task.Run<Recibo>(() => {
+ Recibo recibo3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ recibo = recibo1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (recibo.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(recibo.get_Id(), recibo, 42));
+ }
+ recibo = (recibo.get_Id() == 0 ? commited.get_ReciboRepository().SaveOrUpdate(recibo) : commited.get_ReciboRepository().Merge(recibo));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(recibo.get_Id(), recibo.GetValorOriginal(), 42, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ recibo3 = recibo;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 231, num, recibo, true);
+ continue;
+ }
+ return recibo3;
+ }
+ return recibo1;
+ });
+ return recibo2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs new file mode 100644 index 0000000..fe44719 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs @@ -0,0 +1,372 @@ +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.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.Ferramentas
+{
+ internal class SeguradoraServico : BaseServico
+ {
+ public SeguradoraServico()
+ {
+ }
+
+ public async Task<List<SeguradoraContato>> BuscarAssistencias(long id)
+ {
+ int num = 3;
+ List<SeguradoraContato> seguradoraContatos1 = await Task.Run<List<SeguradoraContato>>(() => {
+ List<SeguradoraContato> seguradoraContatos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ seguradoraContatos = read.get_SeguradoraContatoRepository().FindAssistencia(Recursos.Empresa.get_Id(), id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true);
+ continue;
+ }
+ return seguradoraContatos;
+ }
+ return new List<SeguradoraContato>();
+ });
+ return seguradoraContatos1;
+ }
+
+ internal async Task<List<ConfigExtratoImport>> BuscarConfig(long id)
+ {
+ int num = 3;
+ List<ConfigExtratoImport> configExtratoImports1 = await Task.Run<List<ConfigExtratoImport>>(() => {
+ List<ConfigExtratoImport> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<ConfigExtratoImport> configExtratoImports = read.get_ConfigExtratoImportRepository().FindBySeguradora(id);
+ Func<ConfigExtratoImport, string> u003cu003e9_21 = SeguradoraServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (ConfigExtratoImport x) => x.get_Descricao();
+ SeguradoraServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ list = configExtratoImports.OrderBy<ConfigExtratoImport, string>(u003cu003e9_21).ToList<ConfigExtratoImport>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 124, num, id, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<ConfigExtratoImport>();
+ });
+ return configExtratoImports1;
+ }
+
+ public async Task<ObservableCollection<SeguradoraContato>> BuscarContatos(long id)
+ {
+ int num = 3;
+ ObservableCollection<SeguradoraContato> observableCollection1 = await Task.Run<ObservableCollection<SeguradoraContato>>(() => {
+ ObservableCollection<SeguradoraContato> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<SeguradoraContato> seguradoraContatos = read.get_SeguradoraContatoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id);
+ Func<SeguradoraContato, string> u003cu003e9_31 = SeguradoraServico.u003cu003ec.u003cu003e9__3_1;
+ if (u003cu003e9_31 == null)
+ {
+ u003cu003e9_31 = (SeguradoraContato x) => x.get_NomeContato();
+ SeguradoraServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31;
+ }
+ observableCollection = new ObservableCollection<SeguradoraContato>(seguradoraContatos.OrderBy<SeguradoraContato, string>(u003cu003e9_31));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<SeguradoraContato>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<SeguradoraEndereco>> BuscarEnderecos(long id)
+ {
+ int num = 3;
+ ObservableCollection<SeguradoraEndereco> observableCollection1 = await Task.Run<ObservableCollection<SeguradoraEndereco>>(() => {
+ ObservableCollection<SeguradoraEndereco> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<SeguradoraEndereco> seguradoraEnderecos = read.get_SeguradoraEnderecoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id);
+ Func<SeguradoraEndereco, long> u003cu003e9_41 = SeguradoraServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = (SeguradoraEndereco x) => x.get_Id();
+ SeguradoraServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ observableCollection = new ObservableCollection<SeguradoraEndereco>(seguradoraEnderecos.OrderBy<SeguradoraEndereco, long>(u003cu003e9_41));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 126, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<SeguradoraEndereco>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<Seguradora> BuscarSeguradora(long id)
+ {
+ int num = 3;
+ Seguradora seguradora1 = await Task.Run<Seguradora>(() => {
+ Seguradora seguradora;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ seguradora = read.get_SeguradoraRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 128, num, null, true);
+ continue;
+ }
+ return seguradora;
+ }
+ return new Seguradora();
+ });
+ return seguradora1;
+ }
+
+ public async Task<List<Seguradora>> BuscarSeguradoras()
+ {
+ int num = 3;
+ List<Seguradora> seguradoras1 = await Task.Run<List<Seguradora>>(() => {
+ List<Seguradora> seguradoras;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ seguradoras = read.get_SeguradoraRepository().Find();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 127, num, null, true);
+ continue;
+ }
+ return seguradoras;
+ }
+ return new List<Seguradora>();
+ });
+ return seguradoras1;
+ }
+
+ public async Task<Seguradora> Insert(Seguradora seguradora)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Seguradora seguradora2 = seguradora;
+ Seguradora seguradora3 = await Task.Run<Seguradora>(() => {
+ Seguradora seguradora4;
+ string str;
+ while (num > 0)
+ {
+ seguradora = seguradora2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ seguradora = commited.get_SeguradoraRepository().SaveOrUpdate(seguradora);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(0);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Seguradora seguradora1 = seguradora;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(seguradora.get_Id());
+ registroLog.set_Tela(13);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = SeguradoraServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ SeguradoraServico.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();
+ seguradora4 = seguradora;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 234, num, seguradora, true);
+ continue;
+ }
+ return seguradora4;
+ }
+ return seguradora2;
+ });
+ return seguradora3;
+ }
+
+ public async Task<Seguradora> Save(Seguradora seguradora, List<ConfigExtratoImport> config, bool primeiroAcesso = false)
+ {
+ Action<SeguradoraContato> action2 = null;
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Seguradora seguradora2 = seguradora;
+ Seguradora seguradora3 = await Task.Run<Seguradora>(() => {
+ Seguradora seguradora4;
+ string str;
+ while (num > 0)
+ {
+ seguradora = seguradora2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (seguradora.get_Id() == 0 ? 0 : 1);
+ List<SeguradoraContato> contatos = seguradora.get_Contatos();
+ if (contatos != null)
+ {
+ List<SeguradoraContato> seguradoraContatos = contatos;
+ Action<SeguradoraContato> u003cu003e9_1 = action2;
+ if (u003cu003e9_1 == null)
+ {
+ Action<SeguradoraContato> action = (SeguradoraContato x) => x.set_Seguradora(seguradora);
+ Action<SeguradoraContato> action1 = action;
+ action2 = action;
+ u003cu003e9_1 = action1;
+ }
+ seguradoraContatos.ForEach(u003cu003e9_1);
+ contatos = commited.get_SeguradoraContatoRepository().Merge(contatos, seguradora, Recursos.Empresa.get_Id());
+ }
+ List<SeguradoraEndereco> enderecos = seguradora.get_Enderecos();
+ if (contatos != null)
+ {
+ enderecos = commited.get_SeguradoraEnderecoRepository().Merge(enderecos, seguradora, Recursos.Empresa.get_Id());
+ }
+ if (contatos != null | primeiroAcesso)
+ {
+ seguradora = commited.get_SeguradoraRepository().Merge(seguradora);
+ }
+ seguradora.set_Contatos(contatos);
+ seguradora.set_Enderecos(enderecos);
+ List<ConfigExtratoImport> configExtratoImports = config;
+ if (configExtratoImports != null)
+ {
+ configExtratoImports.ForEach((ConfigExtratoImport x) => commited.get_ConfigExtratoImportRepository().Merge(x));
+ }
+ else
+ {
+ }
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Seguradora seguradora1 = seguradora;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(seguradora.get_Id());
+ registroLog.set_Tela(13);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_03 = SeguradoraServico.u003cu003ec.u003cu003e9__0_3;
+ if (u003cu003e9_03 == null)
+ {
+ u003cu003e9_03 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ SeguradoraServico.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_03);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ seguradora4 = seguradora;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 233, num, new { seguradora = seguradora, config = config }, true);
+ continue;
+ }
+ return seguradora4;
+ }
+ return seguradora2;
+ });
+ return seguradora3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs new file mode 100644 index 0000000..9b46d97 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs @@ -0,0 +1,97 @@ +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.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class SocioServico : BaseServico
+ {
+ public SocioServico()
+ {
+ }
+
+ public async Task<bool> Delete(Socio socio)
+ {
+ 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(socio.get_Id(), socio.GetValorOriginal(), 19, 2));
+ commited.get_SocioRepository().Delete(socio.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 236, num, socio, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Socio> Save(Socio socio)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Socio socio1 = socio;
+ Socio socio2 = await Task.Run<Socio>(() => {
+ Socio socio3;
+ bool flag;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ socio = socio1;
+ while (num > 0)
+ {
+ socio = socio1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (socio.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(socio.get_Id(), socio, 19));
+ }
+ socio = (socio.get_Id() == 0 ? commited.get_SocioRepository().SaveOrUpdate(socio) : commited.get_SocioRepository().Merge(socio));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(socio.get_Id(), socio.GetValorOriginal(), 19, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ socio3 = socio;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 235, num, socio, true);
+ continue;
+ }
+ return socio3;
+ }
+ return socio1;
+ });
+ return socio2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs new file mode 100644 index 0000000..1af6770 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs @@ -0,0 +1,93 @@ +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.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class StatusProspeccaoServico : BaseServico
+ {
+ public StatusProspeccaoServico()
+ {
+ }
+
+ internal async Task<List<StatusDeProspeccao>> BuscarProspeccoes()
+ {
+ int num = 3;
+ List<StatusDeProspeccao> statusDeProspeccaos1 = await Task.Run<List<StatusDeProspeccao>>(() => {
+ List<StatusDeProspeccao> statusDeProspeccaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ statusDeProspeccaos = read.get_StatusProspeccaoRepository().FindAll();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 308, num, null, true);
+ continue;
+ }
+ return statusDeProspeccaos;
+ }
+ return new List<StatusDeProspeccao>();
+ });
+ return statusDeProspeccaos1;
+ }
+
+ internal async Task<StatusDeProspeccao> Save(StatusDeProspeccao statusProspeccao)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ StatusDeProspeccao statusDeProspeccao1 = statusProspeccao;
+ StatusDeProspeccao statusDeProspeccao2 = await Task.Run<StatusDeProspeccao>(() => {
+ StatusDeProspeccao statusDeProspeccao;
+ bool flag;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ statusProspeccao = statusDeProspeccao1;
+ while (num > 0)
+ {
+ statusProspeccao = statusDeProspeccao1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (statusProspeccao.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(statusProspeccao.get_Id(), statusProspeccao, 57));
+ }
+ statusProspeccao = (statusProspeccao.get_Id() == 0 ? commited.get_StatusProspeccaoRepository().SaveOrUpdate(statusProspeccao) : commited.get_StatusProspeccaoRepository().Merge(statusProspeccao));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(statusProspeccao.get_Id(), statusProspeccao.GetValorOriginal(), 57, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ statusDeProspeccao = statusProspeccao;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 307, num, statusProspeccao, true);
+ continue;
+ }
+ return statusDeProspeccao;
+ }
+ return statusDeProspeccao1;
+ });
+ return statusDeProspeccao2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs new file mode 100644 index 0000000..88b146c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs @@ -0,0 +1,124 @@ +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.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class StatusServico : BaseServico
+ {
+ public StatusServico()
+ {
+ }
+
+ internal async Task<Status> BuscarStatusPorId(long id)
+ {
+ int num = 3;
+ Status statu1 = await Task.Run<Status>(() => {
+ Status statu;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ statu = read.get_StatusRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 119, num, id, true);
+ continue;
+ }
+ return statu;
+ }
+ return new Status();
+ });
+ return statu1;
+ }
+
+ public async Task<bool> Delete(Status status)
+ {
+ 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(status.get_Id(), status.GetValorOriginal(), 11, 2));
+ commited.get_StatusRepository().Delete(status.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 221, num, status, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Status> Save(Status status)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Status statu1 = status;
+ Status statu2 = await Task.Run<Status>(() => {
+ Status statu;
+ bool flag;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ status = statu1;
+ while (num > 0)
+ {
+ status = statu1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (status.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(status.get_Id(), status, 11));
+ }
+ status = (status.get_Id() == 0 ? commited.get_StatusRepository().SaveOrUpdate(status) : commited.get_StatusRepository().Merge(status));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(status.get_Id(), status.GetValorOriginal(), 11, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ statu = status;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 227, num, status, true);
+ continue;
+ }
+ return statu;
+ }
+ return statu1;
+ });
+ return statu2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs new file mode 100644 index 0000000..fa7c297 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs @@ -0,0 +1,93 @@ +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.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class TipoTarefaServico : BaseServico
+ {
+ public TipoTarefaServico()
+ {
+ }
+
+ internal async Task<List<TipoDeTarefa>> BuscarTarefas()
+ {
+ int num = 3;
+ List<TipoDeTarefa> tipoDeTarefas1 = await Task.Run<List<TipoDeTarefa>>(() => {
+ List<TipoDeTarefa> tipoDeTarefas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tipoDeTarefas = read.get_TipoTarefaRepository().FindAll();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 308, num, null, true);
+ continue;
+ }
+ return tipoDeTarefas;
+ }
+ return new List<TipoDeTarefa>();
+ });
+ return tipoDeTarefas1;
+ }
+
+ internal async Task<TipoDeTarefa> Save(TipoDeTarefa tipoTarefa)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ TipoDeTarefa tipoDeTarefa1 = tipoTarefa;
+ TipoDeTarefa tipoDeTarefa2 = await Task.Run<TipoDeTarefa>(() => {
+ TipoDeTarefa tipoDeTarefa;
+ bool flag;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ tipoTarefa = tipoDeTarefa1;
+ while (num > 0)
+ {
+ tipoTarefa = tipoDeTarefa1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (tipoTarefa.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(tipoTarefa.get_Id(), tipoTarefa, 52));
+ }
+ tipoTarefa = (tipoTarefa.get_Id() == 0 ? commited.get_TipoTarefaRepository().SaveOrUpdate(tipoTarefa) : commited.get_TipoTarefaRepository().Merge(tipoTarefa));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(tipoTarefa.get_Id(), tipoTarefa.GetValorOriginal(), 52, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ tipoDeTarefa = tipoTarefa;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 306, num, tipoTarefa, true);
+ continue;
+ }
+ return tipoDeTarefa;
+ }
+ return tipoDeTarefa1;
+ });
+ return tipoDeTarefa2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs new file mode 100644 index 0000000..0757820 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs @@ -0,0 +1,131 @@ +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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+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.Ferramentas
+{
+ internal class TipoVendedorServico : BaseServico
+ {
+ public TipoVendedorServico()
+ {
+ }
+
+ public async Task<bool> Delete(TipoVendedor tipoVendedor)
+ {
+ 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(tipoVendedor.get_Id(), tipoVendedor.GetValorOriginal(), 14, 2));
+ commited.get_TipoVendedorRepository().Delete(tipoVendedor.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 238, num, tipoVendedor, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ 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_TipoVendedorRepository().FindLastId();
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 17, num1, null, true);
+ continue;
+ }
+ return num;
+ }
+ return (long)0;
+ });
+ return num2;
+ }
+
+ internal async Task<TipoVendedor> Save(TipoVendedor tipoVendedor)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ TipoVendedor tipoVendedor2 = tipoVendedor;
+ TipoVendedor tipoVendedor3 = await Task.Run<TipoVendedor>(async () => {
+ TipoVendedor tipoVendedor4;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ tipoVendedor = tipoVendedor2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (tipoVendedor.get_Id() == 0 ? 0 : 1);
+ if (tipoVendedor.get_Id() == 0)
+ {
+ TipoVendedor tipoVendedor1 = tipoVendedor;
+ tipoVendedor1.set_Id(await this.FindLastId() + (long)1);
+ tipoVendedor1 = null;
+ }
+ TipoAcao tipoAcao1 = tipoAcao;
+ if (tipoAcao1 == null)
+ {
+ registroLogs.Add(base.CreateLog(tipoVendedor.get_Id(), tipoVendedor.GetValorOriginal(), 14, 0));
+ }
+ else if (tipoAcao1 == 1)
+ {
+ registroLogs.Add(base.CreateLog(tipoVendedor.get_Id(), tipoVendedor, 14));
+ }
+ tipoVendedor = (tipoAcao == null ? commited.get_TipoVendedorRepository().SaveOrUpdate(tipoVendedor) : commited.get_TipoVendedorRepository().Merge(tipoVendedor));
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ tipoVendedor4 = tipoVendedor;
+ return tipoVendedor4;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 237, num, tipoVendedor, true);
+ }
+ registroLogs = null;
+ }
+ tipoVendedor4 = tipoVendedor2;
+ return tipoVendedor4;
+ });
+ return tipoVendedor3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs new file mode 100644 index 0000000..5b04623 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs @@ -0,0 +1,303 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Common.Security;
+using Gestor.Common.Validation;
+using Gestor.Infrastructure.Mappers;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+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.Ferramentas
+{
+ internal class UsuarioServico : BaseServico
+ {
+ public UsuarioServico()
+ {
+ }
+
+ 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<Usuario> BuscarLogin(string login)
+ {
+ int num = 3;
+ Usuario usuario2 = await Task.Run<Usuario>(() => {
+ Usuario usuario;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial);
+ AuthSso result = base.VerificaUsuarioSso(login, empresa.get_Documento()).Result;
+ if (result == null || result.get_Code() == 401)
+ {
+ usuario = new Usuario();
+ }
+ else
+ {
+ Usuario usuario1 = read.get_UsuarioRepository().FindUsuario(login);
+ usuario = (result.get_Code() == 404 ? usuario1 : CustomMap.FromUserSso(usuario1, result.get_Data().get_User()));
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 134, num, login, true);
+ continue;
+ }
+ return usuario;
+ }
+ return new Usuario();
+ });
+ return usuario2;
+ }
+
+ public async Task<List<PermissaoAggilizador>> BuscarPermissaoAggilizador()
+ {
+ List<PermissaoAggilizador> permissaoAggilizadors2 = await Task.Run<List<PermissaoAggilizador>>(() => {
+ List<PermissaoAggilizador> permissaoAggilizadors;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ permissaoAggilizadors = read.get_UsuarioRepository().PermissaoAggilizador();
+ }
+ }
+ catch (Exception exception)
+ {
+ List<PermissaoAggilizador> permissaoAggilizadors1 = new List<PermissaoAggilizador>();
+ PermissaoAggilizador permissaoAggilizador = new PermissaoAggilizador();
+ permissaoAggilizador.set_Id((long)1);
+ permissaoAggilizador.set_Descricao("ADMINISTRADOR");
+ permissaoAggilizadors1.Add(permissaoAggilizador);
+ PermissaoAggilizador permissaoAggilizador1 = new PermissaoAggilizador();
+ permissaoAggilizador1.set_Id((long)2);
+ permissaoAggilizador1.set_Descricao("NORMAL");
+ permissaoAggilizadors1.Add(permissaoAggilizador1);
+ PermissaoAggilizador permissaoAggilizador2 = new PermissaoAggilizador();
+ permissaoAggilizador2.set_Id((long)3);
+ permissaoAggilizador2.set_Descricao("LIMITADO");
+ permissaoAggilizadors1.Add(permissaoAggilizador2);
+ permissaoAggilizadors = permissaoAggilizadors1;
+ }
+ return permissaoAggilizadors;
+ });
+ return permissaoAggilizadors2;
+ }
+
+ internal async Task<Usuario> BuscarUsuarioPorId(long id)
+ {
+ int num = 3;
+ Usuario usuario1 = await Task.Run<Usuario>(() => {
+ Usuario usuario;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ usuario = read.get_UsuarioRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 130, num, id, true);
+ continue;
+ }
+ return usuario;
+ }
+ return new Usuario();
+ });
+ return usuario1;
+ }
+
+ public async Task<Usuario> BuscaUsuarioInicial(string usuario, string senha)
+ {
+ Usuario usuario2 = await Task.Run<Usuario>(() => {
+ Usuario usuario3;
+ using (UnitOfWork read = Instancia.Read)
+ {
+ Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial);
+ string str = (new Token()).AggerEncrypt(senha);
+ AuthSso result = base.BuscaUsuarioSso(usuario, str, empresa.get_Documento()).Result;
+ if (result.get_Code() != 401)
+ {
+ Usuario usuario1 = read.get_UsuarioRepository().FindUsuario(usuario);
+ usuario3 = (result.get_Code() != 404 || usuario1 != null ? (result.get_Data() != null || usuario1 == null ? (usuario1 != null || result.get_Data() == null ? usuario1 : CustomMap.ToUsuario(result.get_Data().get_User(), empresa.get_Id())) : usuario1) : new Usuario());
+ }
+ else
+ {
+ usuario3 = null;
+ }
+ }
+ return usuario3;
+ });
+ return usuario2;
+ }
+
+ public async Task<bool> Delete(Usuario usuario)
+ {
+ 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(usuario.get_Id(), usuario.GetValorOriginal(), 16, 2));
+ commited.get_UsuarioRepository().Delete(usuario.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ usuario.set_TokenSso(Recursos.Usuario.get_TokenSso());
+ base.DeleteUsuarioSso(usuario, Recursos.Empresa.get_Documento()).Wait();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 240, num, usuario, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Usuario> Save(Usuario usuario)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Usuario usuario5 = usuario;
+ Usuario usuario6 = await Task.Run<Usuario>(() => {
+ Usuario usuario7;
+ long? nullable;
+ string tokenSso;
+ string documento;
+ long? nullable1;
+ bool flag;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ while (num > 0)
+ {
+ usuario = usuario5;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ Usuario usuario1 = Recursos.Usuario;
+ if (usuario1 != null)
+ {
+ tokenSso = usuario1.get_TokenSso();
+ }
+ else
+ {
+ tokenSso = null;
+ }
+ string token = tokenSso;
+ Empresa empresa = Recursos.Empresa;
+ if (empresa != null)
+ {
+ documento = empresa.get_Documento();
+ }
+ else
+ {
+ documento = null;
+ }
+ string str = documento;
+ if (ValidationHelper.IsNullOrEmpty(token))
+ {
+ Empresa empresa1 = commited.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial);
+ string senha = usuario.get_Senha();
+ if (ValidationHelper.IsNotNullOrEmpty(usuario.get_SenhaAnterior()))
+ {
+ if ((new Token()).AggerDecrypt(usuario.get_SenhaAnterior()).ToUpper().Contains("AGGER@"))
+ {
+ Usuario result = this.BuscarLogin(usuario.get_Login()).Result;
+ usuario.set_SenhaAnterior(result.get_Senha());
+ }
+ senha = usuario.get_SenhaAnterior();
+ }
+ AuthSso authSso = base.BuscaUsuarioSso(usuario.get_Login(), senha, empresa1.get_Documento()).Result;
+ if (authSso == null || authSso.get_Code() == 401)
+ {
+ this.Sucesso = false;
+ usuario7 = usuario5;
+ return usuario7;
+ }
+ else
+ {
+ token = authSso.get_Data().get_Token();
+ str = empresa1.get_Documento();
+ }
+ }
+ Usuario usuario2 = usuario;
+ if (!usuario.get_PermissaoAggilizador().HasValue)
+ {
+ Usuario usuario3 = usuario;
+ long? nullable2 = new long?((long)2);
+ nullable = nullable2;
+ usuario3.set_PermissaoAggilizador(nullable2);
+ nullable1 = nullable;
+ }
+ else
+ {
+ Usuario usuario4 = usuario;
+ long? permissaoAggilizador = usuario.get_PermissaoAggilizador();
+ nullable = permissaoAggilizador;
+ usuario4.set_PermissaoAggilizador(permissaoAggilizador);
+ nullable1 = nullable;
+ }
+ usuario2.set_PermissaoAggilizador(nullable1);
+ flag = (usuario.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(usuario.get_Id(), usuario, 16));
+ }
+ usuario = (usuario.get_Id() == 0 ? commited.get_UsuarioRepository().SaveOrUpdate(usuario) : commited.get_UsuarioRepository().Merge(usuario));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(usuario.get_Id(), usuario.GetValorOriginal(), 16, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ usuario.set_TokenSso(token);
+ base.AddOrUpdateUsuarioSso(usuario, str, usuario.get_SsoId()).Wait();
+ usuario7 = usuario;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 239, num, usuario, true);
+ continue;
+ }
+ return usuario7;
+ }
+ return usuario5;
+ });
+ return usuario6;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs new file mode 100644 index 0000000..9c81d34 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs @@ -0,0 +1,851 @@ +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.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.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.Ferramentas
+{
+ public class VendedorServico : BaseServico
+ {
+ public VendedorServico()
+ {
+ }
+
+ public async Task<Vendedor> BuscarCorretora()
+ {
+ Vendedor vendedor1 = await Task.Run<Vendedor>(() => {
+ Vendedor vendedor;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ vendedor = read.get_VendedorRepository().FindCorretora();
+ }
+ }
+ catch (Exception exception)
+ {
+ vendedor = null;
+ }
+ return vendedor;
+ });
+ return vendedor1;
+ }
+
+ public async Task<List<VendedorParcela>> BuscaRepasse(long id)
+ {
+ int num = 3;
+ List<VendedorParcela> vendedorParcelas1 = await Task.Run<List<VendedorParcela>>(() => {
+ List<VendedorParcela> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<VendedorParcela> vendedorParcelas = read.get_VendedorParcelaRepository().FindByDocumentId(id);
+ Func<VendedorParcela, long> u003cu003e9_31 = VendedorServico.u003cu003ec.u003cu003e9__3_1;
+ if (u003cu003e9_31 == null)
+ {
+ u003cu003e9_31 = (VendedorParcela x) => x.get_TipoVendedor().get_Id();
+ VendedorServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31;
+ }
+ list = vendedorParcelas.OrderBy<VendedorParcela, long>(u003cu003e9_31).ToList<VendedorParcela>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 136, num, id, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<VendedorParcela>();
+ });
+ return vendedorParcelas1;
+ }
+
+ public async Task<List<VendedorParcela>> BuscaRepasseParcela(long id)
+ {
+ int num = 3;
+ List<VendedorParcela> vendedorParcelas1 = await Task.Run<List<VendedorParcela>>(() => {
+ List<VendedorParcela> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<VendedorParcela> vendedorParcelas = read.get_VendedorParcelaRepository().FindByParcela(id);
+ Func<VendedorParcela, long?> u003cu003e9_41 = VendedorServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = (VendedorParcela x) => {
+ TipoVendedor tipoVendedor = x.get_TipoVendedor();
+ if (tipoVendedor != null)
+ {
+ return new long?(tipoVendedor.get_Id());
+ }
+ return null;
+ };
+ VendedorServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ list = vendedorParcelas.OrderBy<VendedorParcela, long?>(u003cu003e9_41).ToList<VendedorParcela>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 137, num, id, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<VendedorParcela>();
+ });
+ return vendedorParcelas1;
+ }
+
+ public async Task<List<Repasse>> BuscaRepasses()
+ {
+ int num = 3;
+ List<Repasse> repasses1 = await Task.Run<List<Repasse>>(() => {
+ List<Repasse> repasses;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ repasses = read.get_RepasseRepository().DefaultSelect((long)0);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 142, num, null, true);
+ continue;
+ }
+ return repasses;
+ }
+ return new List<Repasse>();
+ });
+ return repasses1;
+ }
+
+ public async Task<ObservableCollection<Repasse>> BuscaRepassesPorIdVendedor(long id)
+ {
+ int num = 3;
+ ObservableCollection<Repasse> observableCollection1 = await Task.Run<ObservableCollection<Repasse>>(() => {
+ ObservableCollection<Repasse> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<Repasse>(read.get_RepasseRepository().FindByIdVendedor(id));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 143, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Repasse>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<List<ManutencaoPagamentos>> BuscarPagos(Filtros filtro)
+ {
+ int num = 3;
+ List<ManutencaoPagamentos> manutencaoPagamentos = await Task.Run<List<ManutencaoPagamentos>>(() => {
+ List<ManutencaoPagamentos> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ list = read.get_VendedorParcelaRepository().FindByDate(filtro).ToList<ManutencaoPagamentos>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 80, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<ManutencaoPagamentos>();
+ });
+ return manutencaoPagamentos;
+ }
+
+ internal async Task<ObservableCollection<VendedorTelefone>> BuscarTelefonesAsync(long id)
+ {
+ int num = 3;
+ ObservableCollection<VendedorTelefone> observableCollection1 = await Task.Run<ObservableCollection<VendedorTelefone>>(() => {
+ ObservableCollection<VendedorTelefone> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<VendedorTelefone> vendedorTelefones = read.get_VendedorTelefoneRepository().FindByVendedorId(id);
+ Func<VendedorTelefone, string> u003cu003e9_51 = VendedorServico.u003cu003ec.u003cu003e9__5_1;
+ if (u003cu003e9_51 == null)
+ {
+ u003cu003e9_51 = (VendedorTelefone x) => x.get_Nome();
+ VendedorServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51;
+ }
+ observableCollection = new ObservableCollection<VendedorTelefone>(vendedorTelefones.OrderBy<VendedorTelefone, string>(u003cu003e9_51));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 138, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<VendedorTelefone>();
+ });
+ return observableCollection1;
+ }
+
+ internal async Task<List<Vendedor>> BuscarVendedoresAtivosAsync()
+ {
+ int num = 3;
+ List<Vendedor> vendedors2 = await Task.Run<List<Vendedor>>(() => {
+ List<Vendedor> vendedors;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Vendedor> vendedors1 = read.get_VendedorRepository().Find(true, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ Func<Vendedor, string> u003cu003e9_01 = VendedorServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (Vendedor x) => x.get_Nome();
+ VendedorServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ vendedors = new List<Vendedor>(vendedors1.OrderBy<Vendedor, string>(u003cu003e9_01));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 135, num, null, true);
+ continue;
+ }
+ return vendedors;
+ }
+ return new List<Vendedor>();
+ });
+ return vendedors2;
+ }
+
+ public async Task<List<VendedorParcela>> BuscarVendedorParcela(long id)
+ {
+ int num = 3;
+ List<VendedorParcela> vendedorParcelas1 = await Task.Run<List<VendedorParcela>>(() => {
+ List<VendedorParcela> vendedorParcelas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ vendedorParcelas = read.get_RepasseRepository().FindByIdRepasse(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 143, num, id, true);
+ continue;
+ }
+ return vendedorParcelas;
+ }
+ return new List<VendedorParcela>();
+ });
+ return vendedorParcelas1;
+ }
+
+ public async Task<VendedorParcela> BuscarVendedorParcelaCompleto(long id)
+ {
+ int num = 3;
+ VendedorParcela vendedorParcela1 = await Task.Run<VendedorParcela>(() => {
+ VendedorParcela vendedorParcela;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ vendedorParcela = read.get_VendedorParcelaRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 81, num, null, true);
+ continue;
+ }
+ return vendedorParcela;
+ }
+ return new VendedorParcela();
+ });
+ return vendedorParcela1;
+ }
+
+ internal async Task<Vendedor> BuscarVendedorPorId(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_VendedorRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 139, num, id, true);
+ continue;
+ }
+ return vendedor;
+ }
+ return new Vendedor();
+ });
+ return vendedor1;
+ }
+
+ public async Task<List<Vendedor>> BuscarVinculosCliente(long idCliente)
+ {
+ int num = 3;
+ List<Vendedor> vendedors1 = await Task.Run<List<Vendedor>>(() => {
+ List<Vendedor> vendedors;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ if (Recursos.Usuario.get_IdEmpresa() != (long)1)
+ {
+ Recursos.Usuario.get_IdEmpresa();
+ }
+ vendedors = read.get_VendedorParcelaRepository().FindVinculoByIdCliente(idCliente);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 143, num, null, true);
+ continue;
+ }
+ return vendedors;
+ }
+ return null;
+ });
+ return vendedors1;
+ }
+
+ public async Task<bool> Delete(VinculoRepasse vinculo)
+ {
+ 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_RepasseRepository().DeleteVinculo(vinculo.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);
+ VinculoRepasse vinculoRepasse = vinculo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse, jsonSerializerSetting));
+ registroLog.set_EntidadeId(vinculo.get_Id());
+ registroLog.set_Tela(53);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_101 = VendedorServico.u003cu003ec.u003cu003e9__10_1;
+ if (u003cu003e9_101 == null)
+ {
+ u003cu003e9_101 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VendedorServico.u003cu003ec.u003cu003e9__10_1 = u003cu003e9_101;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_101);
+ 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, 311, num, vinculo, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> Delete(Vendedor vendedor)
+ {
+ int num = 3;
+ 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_VendedorRepository().Delete(vendedor.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} EXCLUIU, EM {1}, O VENDEDOR DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", vendedor.get_Id()), ", NOME: '", null, null, null, null, null, null, null, null };
+ strArrays[3] = (string.IsNullOrWhiteSpace(vendedor.get_Nome()) ? "" : vendedor.get_Nome() ?? "");
+ strArrays[4] = "', DOCUMENTO: '";
+ strArrays[5] = (string.IsNullOrWhiteSpace(vendedor.get_Documento()) ? "" : vendedor.get_Documento() ?? "");
+ strArrays[6] = "', BANCO: '";
+ strArrays[7] = (vendedor.get_Banco() == null ? "" : vendedor.get_Banco().get_Nome() ?? "");
+ strArrays[8] = "', CONTA: '";
+ strArrays[9] = (string.IsNullOrWhiteSpace(vendedor.get_Conta()) ? "" : vendedor.get_Conta() ?? "");
+ strArrays[10] = "'.";
+ registroLog1.set_Descricao(string.Concat(strArrays));
+ registroLog.set_EntidadeId(vendedor.get_Id());
+ registroLog.set_Tela(15);
+ 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_131 = VendedorServico.u003cu003ec.u003cu003e9__13_1;
+ if (u003cu003e9_131 == null)
+ {
+ u003cu003e9_131 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VendedorServico.u003cu003ec.u003cu003e9__13_1 = u003cu003e9_131;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_131);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog2.set_Ip(str);
+ RegistroLog registroLog3 = registroLog;
+ if (vendedor.get_Telefones() != null && vendedor.get_Telefones().Count != 0)
+ {
+ foreach (VendedorTelefone telefone in vendedor.get_Telefones())
+ {
+ RegistroLog registroLog4 = registroLog3;
+ string descricao = registroLog4.get_Descricao();
+ object[] objArray = new object[] { vendedor.get_Telefones().IndexOf(telefone), null, null, null };
+ objArray[1] = (!telefone.get_Tipo().HasValue ? "-" : Gestor.Common.Validation.ValidationHelper.GetDescription(telefone.get_Tipo()));
+ objArray[2] = (string.IsNullOrWhiteSpace(telefone.get_Prefixo()) ? "" : telefone.get_Prefixo() ?? "");
+ objArray[3] = (string.IsNullOrWhiteSpace(telefone.get_Numero()) ? "" : telefone.get_Numero() ?? "");
+ registroLog4.set_Descricao(string.Concat(descricao, string.Format(", TELEFONE {0}: {1} ({2}) {3}", objArray)));
+ }
+ }
+ RegistroLog registroLog5 = registroLog3;
+ registroLog5.set_Descricao(string.Concat(registroLog5.get_Descricao(), "."));
+ base.SaveLog(registroLog3, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 242, num, vendedor, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Vendedor> Save(Vendedor vendedor, Repasse repasse)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Vendedor vendedor1 = vendedor;
+ Vendedor vendedor2 = await Task.Run<Vendedor>(() => {
+ Vendedor vendedor3;
+ while (num > 0)
+ {
+ vendedor = vendedor1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa()));
+ vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor);
+ repasse.set_Vendedor(vendedor);
+ repasse = commited.get_RepasseRepository().SaveOrUpdate(repasse);
+ commited.Commit();
+ vendedor3 = vendedor;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasse = repasse }, true);
+ continue;
+ }
+ return vendedor3;
+ }
+ return vendedor1;
+ });
+ return vendedor2;
+ }
+
+ public async Task<VinculoRepasse> Save(VinculoRepasse vinculo)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ VinculoRepasse vinculoRepasse2 = await Task.Run<VinculoRepasse>(() => {
+ VinculoRepasse vinculoRepasse;
+ string str;
+ while (num > 0)
+ {
+ VinculoRepasse vinculoRepasse1 = vinculo;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (vinculoRepasse1.get_Id() == 0 ? 0 : 1);
+ vinculoRepasse1 = (tipoAcao == null ? commited.get_RepasseRepository().SaveOrUpdate(vinculoRepasse1) : commited.get_RepasseRepository().Merge(vinculoRepasse1));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(vinculoRepasse1.get_Id());
+ registroLog.set_Tela(53);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_91 = VendedorServico.u003cu003ec.u003cu003e9__9_1;
+ if (u003cu003e9_91 == null)
+ {
+ u003cu003e9_91 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VendedorServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_91);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ vinculoRepasse = vinculoRepasse1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 311, num, vinculo, true);
+ continue;
+ }
+ return vinculoRepasse;
+ }
+ return vinculo;
+ });
+ return vinculoRepasse2;
+ }
+
+ public async Task<Vendedor> Save(Vendedor vendedor, List<Repasse> repasses)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Vendedor vendedor2 = vendedor;
+ Vendedor vendedor3 = await Task.Run<Vendedor>(() => {
+ Vendedor vendedor4;
+ string str;
+ string str1;
+ while (num > 0)
+ {
+ vendedor = vendedor2;
+ try
+ {
+ List<VendedorTelefone> telefones = vendedor.get_Telefones();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ List<Repasse> repasses1 = repasses;
+ Func<Repasse, bool> u003cu003e9_111 = VendedorServico.u003cu003ec.u003cu003e9__11_1;
+ if (u003cu003e9_111 == null)
+ {
+ u003cu003e9_111 = (Repasse r) => {
+ Ramo ramo = r.get_Ramo();
+ if (ramo == null)
+ {
+ return false;
+ }
+ return ramo.get_Id() == (long)0;
+ };
+ VendedorServico.u003cu003ec.u003cu003e9__11_1 = u003cu003e9_111;
+ }
+ foreach (Repasse repasse in repasses1.Where<Repasse>(u003cu003e9_111))
+ {
+ repasse.set_Ramo(null);
+ }
+ bool id = vendedor.get_Id() == (long)0;
+ vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa()));
+ TipoAcao tipoAcao = (vendedor.get_Id() == 0 ? 0 : 1);
+ if (!id)
+ {
+ vendedor = commited.get_VendedorRepository().Merge(vendedor);
+ if (telefones != null)
+ {
+ telefones = commited.get_VendedorTelefoneRepository().Merge(telefones, vendedor);
+ }
+ if (repasses != null && repasses.Count > 0)
+ {
+ foreach (Repasse repass in repasses)
+ {
+ if (repass.get_Id() != 0)
+ {
+ commited.get_RepasseRepository().Merge(repass);
+ }
+ else
+ {
+ commited.get_RepasseRepository().SaveOrUpdate(repass);
+ }
+ }
+ }
+ }
+ else
+ {
+ vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor);
+ if (telefones != null)
+ {
+ telefones = commited.get_VendedorTelefoneRepository().Inserir(telefones, vendedor);
+ }
+ if (repasses != null && repasses.Count > 0)
+ {
+ foreach (Repasse repass1 in repasses)
+ {
+ repass1.set_Vendedor(vendedor);
+ commited.get_RepasseRepository().SaveOrUpdate(repass1);
+ }
+ }
+ }
+ vendedor.set_Telefones(telefones);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ if (Recursos.Usuario.get_Id() != 0)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Vendedor vendedor1 = vendedor;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(vendedor1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(vendedor.get_Id());
+ registroLog.set_Tela(15);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_112 = VendedorServico.u003cu003ec.u003cu003e9__11_2;
+ if (u003cu003e9_112 == null)
+ {
+ u003cu003e9_112 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VendedorServico.u003cu003ec.u003cu003e9__11_2 = u003cu003e9_112;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_112);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ foreach (Repasse repasse1 in repasses)
+ {
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(tipoAcao);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings();
+ jsonSerializerSetting1.set_ReferenceLoopHandling(1);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting1));
+ registroLog1.set_EntidadeId(repasse1.get_Id());
+ registroLog1.set_Tela(54);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] pAddressArray = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_113 = VendedorServico.u003cu003ec.u003cu003e9__11_3;
+ if (u003cu003e9_113 == null)
+ {
+ u003cu003e9_113 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VendedorServico.u003cu003ec.u003cu003e9__11_3 = u003cu003e9_113;
+ }
+ IPAddress pAddress1 = ((IEnumerable<IPAddress>)pAddressArray).FirstOrDefault<IPAddress>(u003cu003e9_113);
+ if (pAddress1 != null)
+ {
+ str1 = pAddress1.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog1.set_Ip(str1);
+ base.SaveLog(registroLog1, commited);
+ }
+ }
+ commited.Commit();
+ vendedor4 = vendedor;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasses = repasses }, true);
+ continue;
+ }
+ return vendedor4;
+ }
+ return vendedor2;
+ });
+ return vendedor3;
+ }
+
+ public async Task<Repasse> Save(Repasse repasse)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Repasse repasse2 = repasse;
+ Repasse repasse3 = await Task.Run<Repasse>(() => {
+ Repasse repasse4;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ repasse2 = commited.get_RepasseRepository().Merge(repasse2);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Repasse repasse1 = repasse;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(repasse.get_Id());
+ registroLog.set_Tela(54);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_121 = VendedorServico.u003cu003ec.u003cu003e9__12_1;
+ if (u003cu003e9_121 == null)
+ {
+ u003cu003e9_121 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ VendedorServico.u003cu003ec.u003cu003e9__12_1 = u003cu003e9_121;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_121);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ repasse4 = repasse2;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 241, num, new { repasse = repasse }, true);
+ continue;
+ }
+ return repasse4;
+ }
+ return repasse;
+ });
+ return repasse3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs new file mode 100644 index 0000000..68c9a50 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs @@ -0,0 +1,362 @@ +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.Financeiro;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Financeiro
+{
+ internal class BancosContasServico : BaseServico
+ {
+ public BancosContasServico()
+ {
+ }
+
+ public async Task<List<BancosContas>> BuscarBancos()
+ {
+ int num = 3;
+ List<BancosContas> bancosContas1 = await Task.Run<List<BancosContas>>(() => {
+ List<BancosContas> bancosContas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ bancosContas = read.get_BancosContasRepository().Find();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 145, num, null, true);
+ continue;
+ }
+ return bancosContas;
+ }
+ return new List<BancosContas>();
+ });
+ return bancosContas1;
+ }
+
+ public async Task<Saldo> BuscarSaldo(DateTime inicio, long id)
+ {
+ int num = 3;
+ Saldo saldo1 = await Task.Run<Saldo>(() => {
+ Saldo saldo;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ saldo = read.get_SaldoRepository().BuscarPorData(inicio, id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 151, num, new { inicio = inicio, id = id }, true);
+ continue;
+ }
+ return saldo;
+ }
+ return new Saldo();
+ });
+ return saldo1;
+ }
+
+ public async Task<Saldo> BuscarSaldoAberto(long id)
+ {
+ int num = 3;
+ Saldo saldo1 = await Task.Run<Saldo>(() => {
+ Saldo saldo;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ saldo = read.get_SaldoRepository().BuscarAberto(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 147, num, id, true);
+ continue;
+ }
+ return saldo;
+ }
+ return new Saldo();
+ });
+ return saldo1;
+ }
+
+ public async Task<List<Saldo>> BuscarSaldoAberto(List<long> ids)
+ {
+ int num = 3;
+ List<Saldo> saldos2 = await Task.Run<List<Saldo>>(() => {
+ List<Saldo> saldos;
+ while (num > 0)
+ {
+ try
+ {
+ List<Saldo> saldos1 = new List<Saldo>();
+ using (UnitOfWork read = Instancia.Read)
+ {
+ ids.ForEach((long id) => {
+ Saldo saldo = read.get_SaldoRepository().BuscarAberto(id);
+ if (saldo == null)
+ {
+ return;
+ }
+ saldos1.Add(saldo);
+ });
+ }
+ saldos = saldos1;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 148, num, ids, true);
+ continue;
+ }
+ return saldos;
+ }
+ return new List<Saldo>();
+ });
+ return saldos2;
+ }
+
+ public async Task<Saldo> BuscarSaldoInicial(long id)
+ {
+ int num = 3;
+ Saldo saldo1 = await Task.Run<Saldo>(() => {
+ Saldo saldo;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ saldo = read.get_SaldoRepository().BuscarPorMenorData(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 151, num, new { id = id }, true);
+ continue;
+ }
+ return saldo;
+ }
+ return new Saldo();
+ });
+ return saldo1;
+ }
+
+ public async Task<List<Saldo>> BuscarSaldos(long id)
+ {
+ int num = 3;
+ List<Saldo> saldos1 = await Task.Run<List<Saldo>>(() => {
+ List<Saldo> saldos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ saldos = read.get_SaldoRepository().BuscarPorConta(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 150, num, id, true);
+ continue;
+ }
+ return saldos;
+ }
+ return new List<Saldo>();
+ });
+ return saldos1;
+ }
+
+ public async Task<bool> Delete(BancosContas bancosContas)
+ {
+ 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(bancosContas.get_Id(), bancosContas.GetValorOriginal(), 26, 2));
+ commited.get_BancosContasRepository().Delete(bancosContas.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 246, num, bancosContas, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> DeleteSaldo(Saldo saldo)
+ {
+ 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(saldo.get_Id(), saldo.GetValorOriginal(), 26, 2));
+ commited.get_SaldoRepository().Delete(saldo.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 248, num, saldo, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Saldo> FecharSaldo(Saldo saldo)
+ {
+ int num = 3;
+ Saldo saldo1 = await Task.Run<Saldo>(() => {
+ Saldo saldo2;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ saldo2 = read.get_LancamentoRepository().FecharSaldo(saldo);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 149, num, saldo, true);
+ continue;
+ }
+ return saldo2;
+ }
+ return new Saldo();
+ });
+ return saldo1;
+ }
+
+ public async Task<BancosContas> Save(BancosContas bancosContas)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ BancosContas bancosConta1 = bancosContas;
+ BancosContas bancosConta2 = await Task.Run<BancosContas>(() => {
+ BancosContas bancosConta;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ bancosContas = bancosConta1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (bancosContas.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas, 26));
+ }
+ bancosContas = (bancosContas.get_Id() == 0 ? commited.get_BancosContasRepository().SaveOrUpdate(bancosContas) : commited.get_BancosContasRepository().Merge(bancosContas));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas.GetValorOriginal(), 26, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ bancosConta = bancosContas;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 245, num, bancosContas, true);
+ continue;
+ }
+ return bancosConta;
+ }
+ return bancosConta1;
+ });
+ return bancosConta2;
+ }
+
+ public async Task<Saldo> Save(Saldo saldo)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Saldo saldo1 = saldo;
+ Saldo saldo2 = await Task.Run<Saldo>(() => {
+ Saldo saldo3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ saldo = saldo1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (saldo.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(saldo.get_Conta().get_Id(), saldo, 26));
+ }
+ saldo = (saldo.get_Id() == 0 ? commited.get_SaldoRepository().SaveOrUpdate(saldo) : commited.get_SaldoRepository().Merge(saldo));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(saldo.get_Conta().get_Id(), saldo.GetValorOriginal(), 26, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ saldo3 = saldo;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 247, num, saldo, true);
+ continue;
+ }
+ return saldo3;
+ }
+ return saldo1;
+ });
+ return saldo2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs new file mode 100644 index 0000000..7d16a58 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/CentroServico.cs @@ -0,0 +1,92 @@ +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.Financeiro;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Financeiro
+{
+ internal class CentroServico : BaseServico
+ {
+ public CentroServico()
+ {
+ }
+
+ public async Task<List<Centro>> BuscarCentros()
+ {
+ int num = 3;
+ List<Centro> centros1 = await Task.Run<List<Centro>>(() => {
+ List<Centro> centros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ centros = read.get_CentroRepository().Find();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 153, num, null, true);
+ continue;
+ }
+ return centros;
+ }
+ return new List<Centro>();
+ });
+ return centros1;
+ }
+
+ public async Task<Centro> Save(Centro centro)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Centro centro1 = centro;
+ Centro centro2 = await Task.Run<Centro>(() => {
+ Centro centro3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ centro = centro1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (centro.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(centro.get_Id(), centro, 29));
+ }
+ centro = (centro.get_Id() == 0 ? commited.get_CentroRepository().SaveOrUpdate(centro) : commited.get_CentroRepository().Merge(centro));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(centro.get_Id(), centro.GetValorOriginal(), 29, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ centro3 = centro;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 249, num, centro, true);
+ continue;
+ }
+ return centro3;
+ }
+ return centro1;
+ });
+ return centro2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs new file mode 100644 index 0000000..817dca0 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs @@ -0,0 +1,738 @@ +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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Financeiro.Relatorios;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Financeiro
+{
+ public class FinanceiroServico : BaseServico
+ {
+ public FinanceiroServico()
+ {
+ }
+
+ public async Task<List<Lancamento>> AddRange(List<Lancamento> lancamentos)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<Lancamento> lancamentos1 = lancamentos;
+ List<Lancamento> lancamentos2 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> lancamentos3;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ lancamentos = lancamentos1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ControleFinanceiro controle = lancamentos.First<Lancamento>().get_Controle();
+ controle = (controle.get_Id() == 0 ? commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle) : commited.get_ControleFinanceiroRepository().Merge(controle));
+ lancamentos.ForEach((Lancamento x) => {
+ x.set_Controle(controle);
+ x.set_DataLancamento(new DateTime?(networkTime));
+ });
+ lancamentos = commited.get_LancamentoRepository().AddRange(lancamentos);
+ lancamentos.ForEach((Lancamento x) => this.logs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 25, 0)));
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ lancamentos3 = lancamentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 279, num, lancamentos, true);
+ continue;
+ }
+ return lancamentos3;
+ }
+ return lancamentos1;
+ });
+ return lancamentos2;
+ }
+
+ public async Task<List<Lancamento>> Atualizar(List<Lancamento> lancamentos)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Funcoes.GetNetworkTime();
+ List<Lancamento> lancamentos1 = lancamentos;
+ List<Lancamento> lancamentos2 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> lancamentos3;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ lancamentos = lancamentos1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ lancamentos.ForEach((Lancamento lancamento) => {
+ registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento, 25));
+ lancamento.set_Controle(commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle()));
+ lancamento = commited.get_LancamentoRepository().Merge(lancamento);
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ lancamentos3 = lancamentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 280, num, lancamentos, true);
+ continue;
+ }
+ return lancamentos3;
+ }
+ return lancamentos1;
+ });
+ return lancamentos2;
+ }
+
+ public async Task<List<Lancamento>> BuscarFechamento(FiltroFinanceiro filtro)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> lancamentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ lancamentos = read.get_LancamentoRepository().Fechamento(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 294, num, filtro, true);
+ continue;
+ }
+ return lancamentos;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<Lancamento> BuscarLancamento(long id, int parcela)
+ {
+ int num = 3;
+ Lancamento lancamento1 = await Task.Run<Lancamento>(() => {
+ Lancamento lancamento;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ lancamento = read.get_LancamentoRepository().FindByControle(id, parcela);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 163, num, new { id = id, parcela = parcela }, true);
+ continue;
+ }
+ return lancamento;
+ }
+ return new Lancamento();
+ });
+ return lancamento1;
+ }
+
+ public async Task<Lancamento> BuscarLancamento(long id)
+ {
+ int num = 3;
+ Lancamento lancamento1 = await Task.Run<Lancamento>(() => {
+ Lancamento lancamento;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ lancamento = read.get_LancamentoRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 164, num, id, true);
+ continue;
+ }
+ return lancamento;
+ }
+ return new Lancamento();
+ });
+ return lancamento1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentos(DateTime inicio, DateTime fim, StatusLancamento status)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().Find(inicio, fim, status);
+ Func<Lancamento, DateTime> u003cu003e9_41 = FinanceiroServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = (Lancamento x) => x.get_Vencimento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime>(u003cu003e9_41).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 160, num, new { inicio = inicio, fim = fim, status = status }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentos(DateTime inicio, DateTime fim, long conta)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindLancamentosByConta(inicio, fim, conta);
+ Func<Lancamento, DateTime> u003cu003e9_61 = FinanceiroServico.u003cu003ec.u003cu003e9__6_1;
+ if (u003cu003e9_61 == null)
+ {
+ u003cu003e9_61 = (Lancamento x) => x.get_Vencimento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime>(u003cu003e9_61).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 165, num, new { inicio = inicio, fim = fim, conta = conta }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPersonalizados(DateTime inicio, DateTime fim, StatusLancamento status, FiltroLancamentoData filtrodata)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindPersonalizado(inicio, fim, status, filtrodata);
+ Func<Lancamento, DateTime> u003cu003e9_71 = FinanceiroServico.u003cu003ec.u003cu003e9__7_1;
+ if (u003cu003e9_71 == null)
+ {
+ u003cu003e9_71 = (Lancamento x) => x.get_Vencimento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime>(u003cu003e9_71).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 160, num, new { inicio = inicio, fim = fim, status = status }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPorBaixa(DateTime inicio, DateTime fim)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindByBaixa(inicio, fim);
+ Func<Lancamento, DateTime?> u003cu003e9_81 = FinanceiroServico.u003cu003ec.u003cu003e9__8_1;
+ if (u003cu003e9_81 == null)
+ {
+ u003cu003e9_81 = (Lancamento x) => x.get_Baixa();
+ FinanceiroServico.u003cu003ec.u003cu003e9__8_1 = u003cu003e9_81;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime?>(u003cu003e9_81).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 161, num, new { inicio = inicio, fim = fim }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<ExtratoConta>> BuscarLancamentosPorConta(DateTime inicio, DateTime fim, long id)
+ {
+ int num = 3;
+ List<ExtratoConta> extratoContas1 = await Task.Run<List<ExtratoConta>>(() => {
+ List<ExtratoConta> extratoContas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ extratoContas = read.get_LancamentoRepository().FindByConta(inicio, fim, id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 165, num, new { inicio = inicio, fim = fim, id = id }, true);
+ continue;
+ }
+ return extratoContas;
+ }
+ return new List<ExtratoConta>();
+ });
+ return extratoContas1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPorControle(long id)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> lancamentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ lancamentos = read.get_LancamentoRepository().FindByControle(id, 2);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 158, num, new { id = id }, true);
+ continue;
+ }
+ return lancamentos;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPorFornecedor(long id, StatusLancamento status)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindByFornecedor(id, status);
+ Func<Lancamento, DateTime> u003cu003e9_11 = FinanceiroServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (Lancamento x) => x.get_Vencimento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime>(u003cu003e9_11).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 157, num, new { id = id, status = status }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPorFornecedor(long id, DateTime date, Sinal sinal)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindByFornecedor(id, date, sinal);
+ Func<Lancamento, DateTime> u003cu003e9_21 = FinanceiroServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (Lancamento x) => x.get_Vencimento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime>(u003cu003e9_21).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 157, num, new { id = id, date = date }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPorLancamento(DateTime inicio, DateTime fim, StatusLancamento status)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindByLancamento(inicio, fim, status);
+ Func<Lancamento, DateTime?> u003cu003e9_51 = FinanceiroServico.u003cu003ec.u003cu003e9__5_1;
+ if (u003cu003e9_51 == null)
+ {
+ u003cu003e9_51 = (Lancamento x) => x.get_DataLancamento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51;
+ }
+ list = lancamentos.OrderByDescending<Lancamento, DateTime?>(u003cu003e9_51).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 329, num, new { inicio = inicio, fim = fim, status = status }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<List<Lancamento>> BuscarLancamentosPorPagamento(DateTime inicio, DateTime fim)
+ {
+ int num = 3;
+ List<Lancamento> lancamentos1 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Lancamento> lancamentos = read.get_LancamentoRepository().FindByPagamento(inicio, fim);
+ Func<Lancamento, DateTime?> u003cu003e9_91 = FinanceiroServico.u003cu003ec.u003cu003e9__9_1;
+ if (u003cu003e9_91 == null)
+ {
+ u003cu003e9_91 = (Lancamento x) => x.get_Pagamento();
+ FinanceiroServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91;
+ }
+ list = lancamentos.OrderBy<Lancamento, DateTime?>(u003cu003e9_91).ToList<Lancamento>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 162, num, new { inicio = inicio, fim = fim }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Lancamento>();
+ });
+ return lancamentos1;
+ }
+
+ public async Task<bool> Excluir(List<Lancamento> lancamentos)
+ {
+ int num = 3;
+ Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ lancamentos.ForEach((Lancamento x) => {
+ registroLogs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 25, 2));
+ if (commited.get_LancamentoRepository().FindByControle(x.get_Controle().get_Id(), 2).Count == 1)
+ {
+ commited.get_ControleFinanceiroRepository().Delete(x.get_Controle().get_Id());
+ return;
+ }
+ x.get_Controle().set_Parcelas(x.get_Controle().get_Parcelas() - 1);
+ commited.get_ControleFinanceiroRepository().Merge(x.get_Controle());
+ commited.get_LancamentoRepository().Delete(x.get_Id());
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 282, num, lancamentos, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> Excluir(Lancamento lancamento)
+ {
+ int num = 3;
+ Funcoes.GetNetworkTime();
+ 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(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 2));
+ if (commited.get_LancamentoRepository().FindByControle(lancamento.get_Controle().get_Id(), 2).Count != 1)
+ {
+ lancamento.get_Controle().set_Parcelas(lancamento.get_Controle().get_Parcelas() - 1);
+ commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle());
+ commited.get_LancamentoRepository().Delete(lancamento.get_Id());
+ }
+ else
+ {
+ commited.get_ControleFinanceiroRepository().Delete(lancamento.get_Controle().get_Id());
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 282, num, lancamento, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<List<Lancamento>> IncluirRange(List<Lancamento> lancamentos)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Funcoes.GetNetworkTime();
+ List<Lancamento> lancamentos1 = lancamentos;
+ List<Lancamento> lancamentos2 = await Task.Run<List<Lancamento>>(() => {
+ List<Lancamento> lancamentos3;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ lancamentos = lancamentos1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ lancamentos.ForEach((Lancamento lancamento) => {
+ lancamento.set_Controle(commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle()));
+ lancamento = commited.get_LancamentoRepository().SaveOrUpdate(lancamento);
+ registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 0));
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ lancamentos3 = lancamentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 281, num, lancamentos, true);
+ continue;
+ }
+ return lancamentos3;
+ }
+ return lancamentos1;
+ });
+ return lancamentos2;
+ }
+
+ public async Task<Lancamento> Save(Lancamento lancamento)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Lancamento lancamento1 = lancamento;
+ Lancamento lancamento2 = await Task.Run<Lancamento>(() => {
+ Lancamento lancamento3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ lancamento = lancamento1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (lancamento.get_Id() == 0 ? false : true);
+ if (!flag)
+ {
+ lancamento.set_DataLancamento(new DateTime?(networkTime));
+ }
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento, 25));
+ }
+ ControleFinanceiro controle = lancamento.get_Controle();
+ controle = (controle.get_Id() == 0 ? commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle) : commited.get_ControleFinanceiroRepository().Merge(controle));
+ lancamento.set_Controle(controle);
+ lancamento = (lancamento.get_Id() == 0 ? commited.get_LancamentoRepository().SaveOrUpdate(lancamento) : commited.get_LancamentoRepository().Merge(lancamento));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ lancamento3 = lancamento;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 279, num, lancamento, true);
+ continue;
+ }
+ return lancamento3;
+ }
+ return lancamento1;
+ });
+ return lancamento2;
+ }
+
+ public async Task<bool> TemLancamentosPorFornecedor(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_LancamentoRepository().HasByFornecedor(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 154, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> Transferir(Lancamento lancamentoOrigem, Lancamento lancamentoDestino)
+ {
+ int num = 3;
+ Lancamento lancamento = lancamentoOrigem;
+ Lancamento lancamento1 = lancamentoDestino;
+ Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ lancamentoOrigem = lancamento;
+ lancamentoDestino = lancamento1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ ControleFinanceiro controle = lancamentoOrigem.get_Controle();
+ controle = commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle);
+ lancamentoOrigem.set_Controle(controle);
+ lancamentoDestino.set_Controle(controle);
+ lancamentoOrigem = commited.get_LancamentoRepository().SaveOrUpdate(lancamentoOrigem);
+ lancamentoDestino = commited.get_LancamentoRepository().SaveOrUpdate(lancamentoDestino);
+ registroLogs.Add(base.CreateLog(lancamentoOrigem.get_Id(), lancamentoOrigem.GetValorOriginal(), 25, 0));
+ registroLogs.Add(base.CreateLog(lancamentoDestino.get_Id(), lancamentoDestino.GetValorOriginal(), 25, 0));
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 283, num, new { lancamentoOrigem = lancamentoOrigem, lancamentoDestino = lancamentoDestino }, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs new file mode 100644 index 0000000..674f46a --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs @@ -0,0 +1,123 @@ +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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Financeiro
+{
+ public class FornecedorServico : BaseServico
+ {
+ public FornecedorServico()
+ {
+ }
+
+ public async Task<List<Fornecedor>> BuscarFornecedores()
+ {
+ int num = 3;
+ List<Fornecedor> fornecedors1 = await Task.Run<List<Fornecedor>>(() => {
+ List<Fornecedor> fornecedors;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ fornecedors = read.get_FornecedorRepository().Find();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 166, num, null, true);
+ continue;
+ }
+ return fornecedors;
+ }
+ return new List<Fornecedor>();
+ });
+ return fornecedors1;
+ }
+
+ public async Task<bool> Delete(Fornecedor fornecedor)
+ {
+ 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(fornecedor.get_Id(), fornecedor.GetValorOriginal(), 24, 2));
+ commited.get_FornecedorRepository().Delete(fornecedor.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 244, num, fornecedor, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Fornecedor> Save(Fornecedor fornecedor)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Fornecedor fornecedor1 = fornecedor;
+ Fornecedor fornecedor2 = await Task.Run<Fornecedor>(() => {
+ Fornecedor fornecedor3;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ fornecedor = fornecedor1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (fornecedor.get_Id() == 0 ? 0 : 1);
+ if (tipoAcao == 1)
+ {
+ registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor, 24));
+ }
+ fornecedor = (tipoAcao == null ? commited.get_FornecedorRepository().SaveOrUpdate(fornecedor) : commited.get_FornecedorRepository().Merge(fornecedor));
+ if (tipoAcao == null)
+ {
+ registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor.GetValorOriginal(), 24, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ fornecedor3 = fornecedor;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 243, num, fornecedor, true);
+ continue;
+ }
+ return fornecedor3;
+ }
+ return fornecedor1;
+ });
+ return fornecedor2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs new file mode 100644 index 0000000..9fc078a --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanoServico.cs @@ -0,0 +1,120 @@ +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.Financeiro;
+using Gestor.Model.Domain.Generic;
+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.Financeiro
+{
+ internal class PlanoServico : BaseServico
+ {
+ public PlanoServico()
+ {
+ }
+
+ public async Task<List<Planos>> BuscarPlanos()
+ {
+ int num = 3;
+ List<Planos> planos1 = await Task.Run<List<Planos>>(() => {
+ List<Planos> planos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ planos = read.get_PlanosRepository().Find();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 167, num, null, true);
+ continue;
+ }
+ return planos;
+ }
+ return new List<Planos>();
+ });
+ return planos1;
+ }
+
+ public async Task<Plano> Save(Plano plano)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Plano plano2 = plano;
+ Plano plano3 = await Task.Run<Plano>(() => {
+ Plano plano4;
+ string str;
+ while (num > 0)
+ {
+ plano = plano2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (plano.get_Id() == 0 ? 0 : 1);
+ plano = (plano.get_Id() == 0 ? commited.get_PlanoRepository().SaveOrUpdate(plano) : commited.get_PlanoRepository().Merge(plano));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ Plano plano1 = plano;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(plano1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(plano.get_Id());
+ registroLog.set_Tela(27);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = PlanoServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ PlanoServico.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();
+ plano4 = plano;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 250, num, plano, true);
+ continue;
+ }
+ return plano4;
+ }
+ return plano2;
+ });
+ return plano3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs new file mode 100644 index 0000000..b00efbe --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Financeiro/PlanosServico.cs @@ -0,0 +1,93 @@ +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.Financeiro;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Financeiro
+{
+ internal class PlanosServico : BaseServico
+ {
+ public PlanosServico()
+ {
+ }
+
+ internal async Task<ObservableCollection<Planos>> BuscarPlanos()
+ {
+ int num = 3;
+ ObservableCollection<Planos> observableCollection1 = await Task.Run<ObservableCollection<Planos>>(() => {
+ ObservableCollection<Planos> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<Planos>(read.get_PlanosRepository().Find());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 168, num, null, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Planos>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<Planos> Save(Planos planos)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Planos plano1 = planos;
+ Planos plano2 = await Task.Run<Planos>(() => {
+ Planos plano;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ planos = plano1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (planos.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(planos.get_Id(), planos, 28));
+ }
+ planos = (planos.get_Id() == 0 ? commited.get_PlanosRepository().SaveOrUpdate(planos) : commited.get_PlanosRepository().Merge(planos));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(planos.get_Id(), planos.GetValorOriginal(), 28, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ plano = planos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 251, num, planos, true);
+ continue;
+ }
+ return plano;
+ }
+ return plano1;
+ });
+ return plano2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs b/Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs new file mode 100644 index 0000000..1570e96 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Generic/BaseServico.cs @@ -0,0 +1,2567 @@ +using Agger.Registro;
+using Gestor.Application.Helpers;
+using Gestor.Application.ViewModels;
+using Gestor.Common.Security;
+using Gestor.Common.Validation;
+using Gestor.Infrastructure.Helpers;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Aggilizador;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+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.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Generic
+{
+ public class BaseServico
+ {
+ private const int UnathorizedSsoCode = 401;
+
+ private const int NotFoundSsoCode = 404;
+
+ public bool Sucesso
+ {
+ get;
+ set;
+ }
+
+ public BaseServico()
+ {
+ }
+
+ internal async Task<UserSso> AddOrUpdateUsuarioSso(Usuario usuario, string documentoEmpresa, string ssoId = null)
+ {
+ UserSso userSso;
+ HttpResponseMessage httpResponseMessage;
+ UserSso userSso1;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ Uri apiSso = Address.get_ApiSso();
+ string[] strArrays = new string[] { "user" };
+ Uri uri = apiSso.Append(strArrays);
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", usuario.get_TokenSso()));
+ UserSso userSso2 = usuario.ToUserSso(ApplicationHelper.NumeroSerial, documentoEmpresa, ssoId);
+ httpResponseMessage = (userSso2.get_Id() != null ? await httpClient.PutAsync(uri, userSso2.ToHttpContent<UserSso>(null, "application/json")) : await httpClient.PostAsync(uri, userSso2.ToHttpContent<UserSso>(null, "application/json")));
+ HttpResponseMessage httpResponseMessage1 = httpResponseMessage;
+ if (!httpResponseMessage1.get_IsSuccessStatusCode())
+ {
+ userSso1 = null;
+ }
+ else
+ {
+ userSso1 = JsonConvert.DeserializeObject<UserSso>(await httpResponseMessage1.get_Content().ReadAsStringAsync());
+ }
+ userSso = userSso1;
+ }
+ return userSso;
+ }
+
+ public async Task<ControleArquivoDigital> ArquivoDigital()
+ {
+ int num = 3;
+ ControleArquivoDigital controleArquivoDigital1 = await Task.Run<ControleArquivoDigital>(() => {
+ ControleArquivoDigital controleArquivoDigital;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ controleArquivoDigital = read.get_IndiceArquivoDigitalRepository().BuscarBanco();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 188, num, null, true);
+ continue;
+ }
+ return controleArquivoDigital;
+ }
+ return new ControleArquivoDigital();
+ });
+ return controleArquivoDigital1;
+ }
+
+ public async Task<ControleArquivoDigital> ArquivoDigital(string banco)
+ {
+ int num = 3;
+ ControleArquivoDigital controleArquivoDigital1 = await Task.Run<ControleArquivoDigital>(() => {
+ ControleArquivoDigital controleArquivoDigital;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ controleArquivoDigital = read.get_IndiceArquivoDigitalRepository().ConsultarBanco(banco);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 188, num, banco, true);
+ continue;
+ }
+ return controleArquivoDigital;
+ }
+ return new ControleArquivoDigital();
+ });
+ return controleArquivoDigital1;
+ }
+
+ public async Task<List<ArquivoVinculo>> ArquivoVinculo(List<long> ids, TipoArquivoVinculo type)
+ {
+ int num = 3;
+ List<ArquivoVinculo> arquivoVinculos1 = await Task.Run<List<ArquivoVinculo>>(() => {
+ List<ArquivoVinculo> arquivoVinculos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ arquivoVinculos = read.get_VinculoDocumentoRepository().BuscarArquivos(ids, type);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 293, num, null, true);
+ continue;
+ }
+ return arquivoVinculos;
+ }
+ return null;
+ });
+ return arquivoVinculos1;
+ }
+
+ private async Task AtualizarUsuarios()
+ {
+ bool count;
+ try
+ {
+ if (!Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(Recursos.Usuario.get_TokenSso()))
+ {
+ List<UserSso> userSsos = await this.BuscarUsuariosSso();
+ List<UserSso> userSsos1 = userSsos;
+ if (userSsos1 != null)
+ {
+ count = userSsos1.Count == 0;
+ }
+ else
+ {
+ count = false;
+ }
+ if (count || userSsos == null)
+ {
+ return;
+ }
+ else
+ {
+ List<Usuario> usuarios = await this.BuscarUsuariosAsync();
+ foreach (UserSso userSso in userSsos)
+ {
+ Usuario usuario = usuarios.FirstOrDefault<Usuario>((Usuario u) => {
+ if (u.get_SsoId() != null)
+ {
+ return userSso.get_Id() == u.get_SsoId();
+ }
+ return u.get_Login() == userSso.get_Username();
+ });
+ if (usuario != null && (userSso.get_IsDeleted() != usuario.get_Excluido() || Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Password(), usuario.get_Senha()) || Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Name(), usuario.get_Nome()) || Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(userSso.get_Email()) && Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Email(), usuario.get_Email()) || Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(userSso.get_Document()) && Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Document(), usuario.get_Documento().Clear()) || Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(userSso.get_Phone()) && Gestor.Common.Validation.ValidationHelper.NotEquals(userSso.get_Phone(), string.Concat(usuario.get_Prefixo(), usuario.get_Telefone()).Clear()) || Gestor.Common.Validation.ValidationHelper.IsNullOrEmpty(usuario.get_SsoId())))
+ {
+ string phone = userSso.get_Phone();
+ usuario.set_Nome(userSso.get_Name());
+ usuario.set_Documento(userSso.get_Document());
+ if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(phone) && phone.Length > 3)
+ {
+ usuario.set_Prefixo(phone.Substring(0, 2));
+ usuario.set_Telefone(phone.Substring(2, phone.Length - 2));
+ }
+ usuario.set_Login(userSso.get_Username());
+ usuario.set_Senha(userSso.get_Password());
+ usuario.set_Email(userSso.get_Email());
+ usuario.set_Excluido(userSso.get_IsDeleted());
+ usuario.set_SsoId(userSso.get_Id());
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_UsuarioRepository().Merge(usuario);
+ commited.Commit();
+ }
+ }
+ if (usuario != null)
+ {
+ continue;
+ }
+ using (UnitOfWork read = Instancia.Read)
+ {
+ Empresa empresa = read.get_EmpresaRepository().FindByDocumento(userSso.get_CustomerDocument());
+ Usuario usuario1 = new Usuario();
+ usuario1.set_IdEmpresa(empresa.get_Id());
+ usuario1.set_Nome(userSso.get_Name());
+ usuario1.set_Documento(userSso.get_Document());
+ usuario1.set_Login(userSso.get_Username());
+ usuario1.set_Senha(userSso.get_Password());
+ usuario1.set_Email(userSso.get_Email());
+ usuario1.set_SsoId(userSso.get_Id());
+ usuario1.set_Excluido(userSso.get_IsDeleted());
+ usuario1.set_Administrador(false);
+ usuario1.set_PermissaoAggilizador(new long?((long)1));
+ usuario = usuario1;
+ string str = userSso.get_Phone();
+ if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str) && str.Length > 3)
+ {
+ usuario.set_Prefixo(str.Substring(0, 2));
+ usuario.set_Telefone(str.Substring(2, str.Length - 2));
+ }
+ }
+ using (UnitOfWork unitOfWork = Instancia.Commited)
+ {
+ unitOfWork.get_UsuarioRepository().SaveOrUpdate(usuario);
+ unitOfWork.Commit();
+ }
+ }
+ userSsos = null;
+ }
+ }
+ else
+ {
+ return;
+ }
+ }
+ catch (Exception exception)
+ {
+ this.Registrar(exception, 239, 1, null, true);
+ }
+ }
+
+ private static async Task AtualizaUsuariosSso(List<Usuario> usuarios)
+ {
+ List<Usuario> list;
+ List<Usuario> usuarios1 = usuarios;
+ IEnumerable<Usuario> excluido =
+ from usuario in usuarios1
+ where !usuario.get_Excluido()
+ select usuario;
+ if (excluido != null)
+ {
+ list = excluido.ToList<Usuario>();
+ }
+ else
+ {
+ list = null;
+ }
+ usuarios = list;
+ foreach (Usuario usuario1 in usuarios)
+ {
+ UserSso userSso = new UserSso();
+ userSso.set_Name(usuario1.get_Nome());
+ userSso.set_Username(usuario1.get_Login());
+ userSso.set_Password(usuario1.get_Senha());
+ userSso.set_Email(usuario1.get_Email());
+ userSso.set_Phone(usuario1.get_Telefone());
+ userSso.set_IsDeleted(usuario1.get_Excluido());
+ userSso.set_Id(usuario1.get_SsoId());
+ string documento = Recursos.Empresas.FirstOrDefault<Empresa>((Empresa x) => x.get_Id() == usuario1.get_IdEmpresa()).get_Documento();
+ await (new BaseServico()).AddOrUpdateUsuarioSso(usuario1, documento, usuario1.get_SsoId());
+ }
+ }
+
+ public async Task<bool> BancosContasUtilizado(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_LancamentoRepository().BancosContasUtilizado(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 155, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ internal async Task<List<CoberturaPadrao>> BuscaCoberturas()
+ {
+ int num = 3;
+ List<CoberturaPadrao> coberturaPadraos1 = await Task.Run<List<CoberturaPadrao>>(() => {
+ List<CoberturaPadrao> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<CoberturaPadrao> coberturaPadraos = read.get_CoberturaPadraoRepository().Find();
+ Func<CoberturaPadrao, string> u003cu003e9_511 = BaseServico.u003cu003ec.u003cu003e9__51_1;
+ if (u003cu003e9_511 == null)
+ {
+ u003cu003e9_511 = (CoberturaPadrao x) => x.get_Descricao();
+ BaseServico.u003cu003ec.u003cu003e9__51_1 = u003cu003e9_511;
+ }
+ list = coberturaPadraos.OrderBy<CoberturaPadrao, string>(u003cu003e9_511).ToList<CoberturaPadrao>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 58, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<CoberturaPadrao>();
+ });
+ return coberturaPadraos1;
+ }
+
+ public async Task<List<Adiantamento>> BuscarAdiantamentoAsync(Vendedor vendedor)
+ {
+ int num = 3;
+ List<Adiantamento> adiantamentos2 = await Task.Run<List<Adiantamento>>(() => {
+ List<Adiantamento> adiantamentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Adiantamento> adiantamentos1 = read.get_AdiantamentoRepository().Find(vendedor.get_Id());
+ Func<Adiantamento, long> u003cu003e9_371 = BaseServico.u003cu003ec.u003cu003e9__37_1;
+ if (u003cu003e9_371 == null)
+ {
+ u003cu003e9_371 = (Adiantamento x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__37_1 = u003cu003e9_371;
+ }
+ adiantamentos = new List<Adiantamento>(adiantamentos1.OrderBy<Adiantamento, long>(u003cu003e9_371));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 185, num, vendedor, true);
+ continue;
+ }
+ return adiantamentos;
+ }
+ return new List<Adiantamento>();
+ });
+ return adiantamentos2;
+ }
+
+ public async Task<List<Agenda>> BuscarAgendasAsync()
+ {
+ int num = 3;
+ List<Agenda> agendas2 = await Task.Run<List<Agenda>>(() => {
+ List<Agenda> agendas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Agenda> agendas1 = read.get_AgendaRepository().Find();
+ Func<Agenda, long> u003cu003e9_461 = BaseServico.u003cu003ec.u003cu003e9__46_1;
+ if (u003cu003e9_461 == null)
+ {
+ u003cu003e9_461 = (Agenda x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__46_1 = u003cu003e9_461;
+ }
+ agendas = new List<Agenda>(agendas1.OrderBy<Agenda, long>(u003cu003e9_461));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 129, num, null, true);
+ continue;
+ }
+ return agendas;
+ }
+ return new List<Agenda>();
+ });
+ return agendas2;
+ }
+
+ internal async Task<List<Atividade>> BuscarAtividade(string value)
+ {
+ int num = 3;
+ List<Atividade> atividades1 = await Task.Run<List<Atividade>>(() => {
+ List<Atividade> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Atividade> atividades = read.get_AtividadeRepository().Find(value);
+ Func<Atividade, string> u003cu003e9_161 = BaseServico.u003cu003ec.u003cu003e9__16_1;
+ if (u003cu003e9_161 == null)
+ {
+ u003cu003e9_161 = (Atividade x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__16_1 = u003cu003e9_161;
+ }
+ list = atividades.OrderBy<Atividade, string>(u003cu003e9_161).ToList<Atividade>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 181, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Atividade>();
+ });
+ return atividades1;
+ }
+
+ internal async Task<List<Banco>> BuscarBanco(string value)
+ {
+ int num = 3;
+ List<Banco> bancos1 = await Task.Run<List<Banco>>(() => {
+ List<Banco> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Banco> bancos = read.get_BancoRepository().Find(value);
+ Func<Banco, string> u003cu003e9_171 = BaseServico.u003cu003ec.u003cu003e9__17_1;
+ if (u003cu003e9_171 == null)
+ {
+ u003cu003e9_171 = (Banco x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__17_1 = u003cu003e9_171;
+ }
+ list = bancos.OrderBy<Banco, string>(u003cu003e9_171).ToList<Banco>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 144, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Banco>();
+ });
+ return bancos1;
+ }
+
+ internal async Task<List<BancosContas>> BuscarBancosContas(string value)
+ {
+ int num = 3;
+ List<BancosContas> bancosContas1 = await Task.Run<List<BancosContas>>(() => {
+ List<BancosContas> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<BancosContas> bancosContas = read.get_BancosContasRepository().Find(value);
+ Func<BancosContas, string> u003cu003e9_181 = BaseServico.u003cu003ec.u003cu003e9__18_1;
+ if (u003cu003e9_181 == null)
+ {
+ u003cu003e9_181 = (BancosContas x) => x.get_Descricao();
+ BaseServico.u003cu003ec.u003cu003e9__18_1 = u003cu003e9_181;
+ }
+ list = bancosContas.OrderBy<BancosContas, string>(u003cu003e9_181).ToList<BancosContas>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 146, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<BancosContas>();
+ });
+ return bancosContas1;
+ }
+
+ public async Task<List<Centro>> BuscarCentroAsync()
+ {
+ int num = 3;
+ List<Centro> centros1 = await Task.Run<List<Centro>>(() => {
+ List<Centro> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Centro> centros = read.get_CentroRepository().Find();
+ Func<Centro, string> u003cu003e9_601 = BaseServico.u003cu003ec.u003cu003e9__60_1;
+ if (u003cu003e9_601 == null)
+ {
+ u003cu003e9_601 = (Centro x) => x.get_Descricao();
+ BaseServico.u003cu003ec.u003cu003e9__60_1 = u003cu003e9_601;
+ }
+ list = centros.OrderBy<Centro, string>(u003cu003e9_601).ToList<Centro>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 153, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Centro>();
+ });
+ return centros1;
+ }
+
+ internal async Task<List<Cliente>> BuscarClienteEmpresa(string value)
+ {
+ List<Cliente> clientes3;
+ if (!string.IsNullOrWhiteSpace(value))
+ {
+ int num = 3;
+ clientes3 = await Task.Run<List<Cliente>>(() => {
+ List<Cliente> clientes;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Cliente> clientes1 = read.get_ClienteRepository().Find(value, (long)0, false, false);
+ Func<Cliente, string> u003cu003e9_731 = BaseServico.u003cu003ec.u003cu003e9__73_1;
+ if (u003cu003e9_731 == null)
+ {
+ u003cu003e9_731 = (Cliente x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__73_1 = u003cu003e9_731;
+ }
+ List<Cliente> list = clientes1.OrderBy<Cliente, string>(u003cu003e9_731).ToList<Cliente>();
+ List<Cliente> clientes2 = read.get_EmpresaRepository().FindAsCliente(value);
+ Func<Cliente, string> u003cu003e9_732 = BaseServico.u003cu003ec.u003cu003e9__73_2;
+ if (u003cu003e9_732 == null)
+ {
+ u003cu003e9_732 = (Cliente x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__73_2 = u003cu003e9_732;
+ }
+ list.AddRange(clientes2.OrderBy<Cliente, string>(u003cu003e9_732).ToList<Cliente>());
+ clientes = list;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 29, num, value, true);
+ continue;
+ }
+ return clientes;
+ }
+ return new List<Cliente>();
+ });
+ }
+ else
+ {
+ clientes3 = new List<Cliente>();
+ }
+ return clientes3;
+ }
+
+ public async Task<ControleArquivoDigital> BuscarControle()
+ {
+ ControleArquivoDigital controleArquivoDigital1 = await Task.Run<ControleArquivoDigital>(() => {
+ ControleArquivoDigital controleArquivoDigital;
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ controleArquivoDigital = read.get_IndiceArquivoDigitalRepository().BuscarBanco();
+ }
+ }
+ catch (Exception exception)
+ {
+ controleArquivoDigital = null;
+ }
+ return controleArquivoDigital;
+ });
+ return controleArquivoDigital1;
+ }
+
+ public async Task<List<Credencial>> BuscarCredenciais()
+ {
+ int num = 3;
+ List<Credencial> credencials1 = await Task.Run<List<Credencial>>(() => {
+ List<Credencial> credencials;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ credencials = read.get_CredencialRepository().Find(Recursos.Empresa.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 187, num, null, true);
+ continue;
+ }
+ return credencials;
+ }
+ return new List<Credencial>();
+ });
+ return credencials1;
+ }
+
+ public async Task<List<Documento>> BuscarDocumentosPorEstipulante(long id)
+ {
+ 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().BuscarDocumentoPorEstipulante(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 11, num, id, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Documento>> BuscarDocumentosPorStatus(long id)
+ {
+ 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().BuscarDocumentoPorStatus(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 12, num, id, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ internal Empresa BuscarEmpresa(long id)
+ {
+ Empresa empresa;
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ empresa = read.get_EmpresaRepository().FindById(id);
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ num = this.Registrar(exception, 114, num, id, true);
+ continue;
+ }
+ return empresa;
+ }
+ return new Empresa();
+ }
+
+ public async Task<List<Empresa>> BuscarEmpresasAsync()
+ {
+ int num = 3;
+ List<Empresa> empresas2 = await Task.Run<List<Empresa>>(() => {
+ List<Empresa> empresas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Empresa> empresas1 = read.get_EmpresaRepository().Find((long)0);
+ Func<Empresa, long> u003cu003e9_251 = BaseServico.u003cu003ec.u003cu003e9__25_1;
+ if (u003cu003e9_251 == null)
+ {
+ u003cu003e9_251 = (Empresa x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__25_1 = u003cu003e9_251;
+ }
+ empresas = new List<Empresa>(empresas1.OrderBy<Empresa, long>(u003cu003e9_251));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 113, num, null, true);
+ continue;
+ }
+ return empresas;
+ }
+ return new List<Empresa>();
+ });
+ return empresas2;
+ }
+
+ public async Task<List<Estipulante>> BuscarEstipulante(string value)
+ {
+ int num = 3;
+ List<Estipulante> estipulantes1 = await Task.Run<List<Estipulante>>(() => {
+ List<Estipulante> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Estipulante> estipulantes = read.get_EstipulanteRepository().Find(value, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ Func<Estipulante, string> u003cu003e9_221 = BaseServico.u003cu003ec.u003cu003e9__22_1;
+ if (u003cu003e9_221 == null)
+ {
+ u003cu003e9_221 = (Estipulante x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221;
+ }
+ list = estipulantes.OrderBy<Estipulante, string>(u003cu003e9_221).ToList<Estipulante>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 111, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Estipulante>();
+ });
+ return estipulantes1;
+ }
+
+ public async Task<List<Estipulante>> BuscarEstipulantes()
+ {
+ int num = 3;
+ List<Estipulante> estipulantes1 = await Task.Run<List<Estipulante>>(() => {
+ List<Estipulante> estipulantes;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ Recursos.Estipulantes = read.get_EstipulanteRepository().Find();
+ estipulantes = Recursos.Estipulantes;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 186, num, null, true);
+ continue;
+ }
+ return estipulantes;
+ }
+ return Recursos.Estipulantes;
+ });
+ return estipulantes1;
+ }
+
+ public async Task<List<Estipulante>> BuscarEstipulantesAsync()
+ {
+ int num = 3;
+ List<Estipulante> estipulantes2 = await Task.Run<List<Estipulante>>(() => {
+ List<Estipulante> estipulantes;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Estipulante> estipulantes1 = read.get_EstipulanteRepository().Find();
+ Func<Estipulante, long> u003cu003e9_231 = BaseServico.u003cu003ec.u003cu003e9__23_1;
+ if (u003cu003e9_231 == null)
+ {
+ u003cu003e9_231 = (Estipulante x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__23_1 = u003cu003e9_231;
+ }
+ estipulantes = new List<Estipulante>(estipulantes1.OrderBy<Estipulante, long>(u003cu003e9_231));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 112, num, null, true);
+ continue;
+ }
+ return estipulantes;
+ }
+ return new List<Estipulante>();
+ });
+ return estipulantes2;
+ }
+
+ internal async Task<List<Fabricante>> BuscarFabricante(string value)
+ {
+ int num = 3;
+ List<Fabricante> fabricantes1 = await Task.Run<List<Fabricante>>(() => {
+ List<Fabricante> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Fabricante> fabricantes = read.get_FabricanteRepository().Find(value);
+ Func<Fabricante, string> u003cu003e9_191 = BaseServico.u003cu003ec.u003cu003e9__19_1;
+ if (u003cu003e9_191 == null)
+ {
+ u003cu003e9_191 = (Fabricante x) => x.get_Descricao();
+ BaseServico.u003cu003ec.u003cu003e9__19_1 = u003cu003e9_191;
+ }
+ list = fabricantes.OrderBy<Fabricante, string>(u003cu003e9_191).ToList<Fabricante>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 182, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Fabricante>();
+ });
+ return fabricantes1;
+ }
+
+ public async Task<List<Fornecedor>> BuscarFornecedor(string value, bool ativo = false)
+ {
+ int num = 3;
+ List<Fornecedor> fornecedors1 = await Task.Run<List<Fornecedor>>(() => {
+ List<Fornecedor> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Fornecedor> fornecedors = read.get_FornecedorRepository().Find(value, ativo);
+ Func<Fornecedor, string> u003cu003e9_631 = BaseServico.u003cu003ec.u003cu003e9__63_1;
+ if (u003cu003e9_631 == null)
+ {
+ u003cu003e9_631 = (Fornecedor x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__63_1 = u003cu003e9_631;
+ }
+ list = fornecedors.OrderBy<Fornecedor, string>(u003cu003e9_631).ToList<Fornecedor>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 159, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Fornecedor>();
+ });
+ return fornecedors1;
+ }
+
+ public async Task<List<Fornecedor>> BuscarFornecedor()
+ {
+ int num = 3;
+ List<Fornecedor> fornecedors1 = await Task.Run<List<Fornecedor>>(() => {
+ List<Fornecedor> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Fornecedor> fornecedors = read.get_FornecedorRepository().Find();
+ Func<Fornecedor, string> u003cu003e9_641 = BaseServico.u003cu003ec.u003cu003e9__64_1;
+ if (u003cu003e9_641 == null)
+ {
+ u003cu003e9_641 = (Fornecedor x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__64_1 = u003cu003e9_641;
+ }
+ list = fornecedors.OrderBy<Fornecedor, string>(u003cu003e9_641).ToList<Fornecedor>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 166, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Fornecedor>();
+ });
+ return fornecedors1;
+ }
+
+ public async Task<List<MetaSeguradora>> BuscarMetaSeguradoraAsync(Seguradora seguradora)
+ {
+ int num = 3;
+ List<MetaSeguradora> metaSeguradoras2 = await Task.Run<List<MetaSeguradora>>(() => {
+ List<MetaSeguradora> metaSeguradoras;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<MetaSeguradora> metaSeguradoras1 = read.get_MetaSeguradoraRepository().Find(seguradora.get_Id());
+ Func<MetaSeguradora, long> u003cu003e9_381 = BaseServico.u003cu003ec.u003cu003e9__38_1;
+ if (u003cu003e9_381 == null)
+ {
+ u003cu003e9_381 = (MetaSeguradora x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__38_1 = u003cu003e9_381;
+ }
+ metaSeguradoras = new List<MetaSeguradora>(metaSeguradoras1.OrderBy<MetaSeguradora, long>(u003cu003e9_381));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 184, num, seguradora, true);
+ continue;
+ }
+ return metaSeguradoras;
+ }
+ return new List<MetaSeguradora>();
+ });
+ return metaSeguradoras2;
+ }
+
+ public async Task<List<MetaVendedor>> BuscarMetaVendedorAsync(Vendedor vendedor)
+ {
+ int num = 3;
+ List<MetaVendedor> metaVendedors2 = await Task.Run<List<MetaVendedor>>(() => {
+ List<MetaVendedor> metaVendedors;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<MetaVendedor> metaVendedors1 = read.get_MetaVendedorRepository().Find(vendedor.get_Id());
+ Func<MetaVendedor, long> u003cu003e9_361 = BaseServico.u003cu003ec.u003cu003e9__36_1;
+ if (u003cu003e9_361 == null)
+ {
+ u003cu003e9_361 = (MetaVendedor x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__36_1 = u003cu003e9_361;
+ }
+ metaVendedors = new List<MetaVendedor>(metaVendedors1.OrderBy<MetaVendedor, long>(u003cu003e9_361));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 183, num, vendedor, true);
+ continue;
+ }
+ return metaVendedors;
+ }
+ return new List<MetaVendedor>();
+ });
+ return metaVendedors2;
+ }
+
+ public async Task<List<Parceiro>> BuscarParceirosAsync()
+ {
+ int num = 3;
+ List<Parceiro> parceiros2 = await Task.Run<List<Parceiro>>(() => {
+ List<Parceiro> parceiros;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Parceiro> parceiros1 = read.get_ParceiroRepository().Find();
+ Func<Parceiro, long> u003cu003e9_351 = BaseServico.u003cu003ec.u003cu003e9__35_1;
+ if (u003cu003e9_351 == null)
+ {
+ u003cu003e9_351 = (Parceiro x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__35_1 = u003cu003e9_351;
+ }
+ parceiros = new List<Parceiro>(parceiros1.OrderBy<Parceiro, long>(u003cu003e9_351));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 72, num, null, true);
+ continue;
+ }
+ return parceiros;
+ }
+ return new List<Parceiro>();
+ });
+ return parceiros2;
+ }
+
+ public async Task<ParcelaPendente> BuscarParcelaPendente(long id)
+ {
+ int num = 3;
+ ParcelaPendente parcelaPendente1 = await Task.Run<ParcelaPendente>(() => {
+ ParcelaPendente parcelaPendente;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parcelaPendente = read.get_ParcelaRepository().BuscarPendencia(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 299, num, id, true);
+ continue;
+ }
+ return parcelaPendente;
+ }
+ return null;
+ });
+ return parcelaPendente1;
+ }
+
+ public async Task<List<Plano>> BuscarPlanoAsync()
+ {
+ int num = 3;
+ List<Plano> planos2 = await Task.Run<List<Plano>>(() => {
+ List<Plano> planos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Plano> planos1 = read.get_PlanoRepository().Find();
+ Func<Plano, string> u003cu003e9_611 = BaseServico.u003cu003ec.u003cu003e9__61_1;
+ if (u003cu003e9_611 == null)
+ {
+ u003cu003e9_611 = (Plano x) => x.get_Descricao();
+ BaseServico.u003cu003ec.u003cu003e9__61_1 = u003cu003e9_611;
+ }
+ planos = new List<Plano>(planos1.OrderBy<Plano, string>(u003cu003e9_611));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 167, num, null, true);
+ continue;
+ }
+ return planos;
+ }
+ return new List<Plano>();
+ });
+ return planos2;
+ }
+
+ public async Task<List<Planos>> BuscarPlanosAsync()
+ {
+ int num = 3;
+ List<Planos> planos1 = await Task.Run<List<Planos>>(() => {
+ List<Planos> planos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ planos = new List<Planos>(read.get_PlanosRepository().Find());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 168, num, null, true);
+ continue;
+ }
+ return planos;
+ }
+ return new List<Planos>();
+ });
+ return planos1;
+ }
+
+ public async Task<List<Produto>> BuscarProduto(string value)
+ {
+ int num = 3;
+ List<Produto> produtos1 = await Task.Run<List<Produto>>(() => {
+ List<Produto> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Produto> produtos = read.get_ProdutoRepository().Find(value);
+ Func<Produto, string> u003cu003e9_411 = BaseServico.u003cu003ec.u003cu003e9__41_1;
+ if (u003cu003e9_411 == null)
+ {
+ u003cu003e9_411 = (Produto x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__41_1 = u003cu003e9_411;
+ }
+ list = produtos.OrderBy<Produto, string>(u003cu003e9_411).ToList<Produto>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 117, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Produto>();
+ });
+ return produtos1;
+ }
+
+ public async Task<List<Produto>> BuscarProdutosAsync()
+ {
+ int num = 3;
+ List<Produto> produtos2 = await Task.Run<List<Produto>>(() => {
+ List<Produto> produtos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Produto> produtos1 = read.get_ProdutoRepository().Find();
+ Func<Produto, string> u003cu003e9_491 = BaseServico.u003cu003ec.u003cu003e9__49_1;
+ if (u003cu003e9_491 == null)
+ {
+ u003cu003e9_491 = (Produto x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__49_1 = u003cu003e9_491;
+ }
+ produtos = new List<Produto>(produtos1.OrderBy<Produto, string>(u003cu003e9_491));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 118, num, null, true);
+ continue;
+ }
+ return produtos;
+ }
+ return new List<Produto>();
+ });
+ return produtos2;
+ }
+
+ internal async Task<List<Profissao>> BuscarProfissao(string value)
+ {
+ int num = 3;
+ List<Profissao> profissaos1 = await Task.Run<List<Profissao>>(() => {
+ List<Profissao> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Profissao> profissaos = read.get_ProfissaoRepository().Find(value);
+ Func<Profissao, string> u003cu003e9_151 = BaseServico.u003cu003ec.u003cu003e9__15_1;
+ if (u003cu003e9_151 == null)
+ {
+ u003cu003e9_151 = (Profissao x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151;
+ }
+ list = profissaos.OrderBy<Profissao, string>(u003cu003e9_151).ToList<Profissao>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 180, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Profissao>();
+ });
+ return profissaos1;
+ }
+
+ public async Task<Qualificacao> BuscarQualificacaoAsync()
+ {
+ int num = 3;
+ Qualificacao qualificacao1 = await Task.Run<Qualificacao>(() => {
+ Qualificacao qualificacao;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ qualificacao = read.get_QualificacaoRepository().FindById((long)1);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 170, num, null, true);
+ continue;
+ }
+ return qualificacao;
+ }
+ return new Qualificacao();
+ });
+ return qualificacao1;
+ }
+
+ public async Task<List<Ramo>> BuscarRamosAsync()
+ {
+ int num = 3;
+ List<Ramo> ramos2 = await Task.Run<List<Ramo>>(() => {
+ List<Ramo> ramos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Ramo> ramos1 = read.get_RamoRepository().Find();
+ Func<Ramo, string> u003cu003e9_431 = BaseServico.u003cu003ec.u003cu003e9__43_1;
+ if (u003cu003e9_431 == null)
+ {
+ u003cu003e9_431 = (Ramo x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__43_1 = u003cu003e9_431;
+ }
+ ramos = new List<Ramo>(ramos1.OrderBy<Ramo, string>(u003cu003e9_431));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 169, num, null, true);
+ continue;
+ }
+ return ramos;
+ }
+ return new List<Ramo>();
+ });
+ return ramos2;
+ }
+
+ public async Task<List<Seguradora>> BuscarSeguradorasAsync()
+ {
+ int num = 3;
+ List<Seguradora> seguradoras2 = await Task.Run<List<Seguradora>>(() => {
+ List<Seguradora> seguradoras;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Seguradora> seguradoras1 = read.get_SeguradoraRepository().Find();
+ Func<Seguradora, long> u003cu003e9_451 = BaseServico.u003cu003ec.u003cu003e9__45_1;
+ if (u003cu003e9_451 == null)
+ {
+ u003cu003e9_451 = (Seguradora x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__45_1 = u003cu003e9_451;
+ }
+ seguradoras = new List<Seguradora>(seguradoras1.OrderBy<Seguradora, long>(u003cu003e9_451));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 127, num, null, true);
+ continue;
+ }
+ return seguradoras;
+ }
+ return new List<Seguradora>();
+ });
+ return seguradoras2;
+ }
+
+ public async Task<List<Socio>> BuscarSociosAsync(long id)
+ {
+ int num = 3;
+ List<Socio> socios1 = await Task.Run<List<Socio>>(() => {
+ List<Socio> socios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ socios = read.get_SocioRepository().FindByEmpresa(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 122, num, id, true);
+ continue;
+ }
+ return socios;
+ }
+ return new List<Socio>();
+ });
+ return socios1;
+ }
+
+ public async Task<List<Status>> BuscarStatus(string value)
+ {
+ int num = 3;
+ List<Status> statuses1 = await Task.Run<List<Status>>(() => {
+ List<Status> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Status> statuses = read.get_StatusRepository().Find(value);
+ Func<Status, string> u003cu003e9_421 = BaseServico.u003cu003ec.u003cu003e9__42_1;
+ if (u003cu003e9_421 == null)
+ {
+ u003cu003e9_421 = (Status x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__42_1 = u003cu003e9_421;
+ }
+ list = statuses.OrderBy<Status, string>(u003cu003e9_421).ToList<Status>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 120, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Status>();
+ });
+ return statuses1;
+ }
+
+ public async Task<List<Status>> BuscarStatusAsync()
+ {
+ int num = 3;
+ List<Status> statuses2 = await Task.Run<List<Status>>(() => {
+ List<Status> statuses;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Status> statuses1 = read.get_StatusRepository().Find();
+ Func<Status, string> u003cu003e9_501 = BaseServico.u003cu003ec.u003cu003e9__50_1;
+ if (u003cu003e9_501 == null)
+ {
+ u003cu003e9_501 = (Status x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__50_1 = u003cu003e9_501;
+ }
+ statuses = new List<Status>(statuses1.OrderBy<Status, string>(u003cu003e9_501));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 121, num, null, true);
+ continue;
+ }
+ return statuses;
+ }
+ return new List<Status>();
+ });
+ return statuses2;
+ }
+
+ public async Task<List<TipoVendedor>> BuscarTipoVendedoresAsync()
+ {
+ int num = 3;
+ List<TipoVendedor> tipoVendedors1 = await Task.Run<List<TipoVendedor>>(() => {
+ List<TipoVendedor> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<TipoVendedor> tipoVendedors = read.get_TipoVendedorRepository().Find();
+ Func<TipoVendedor, long> u003cu003e9_481 = BaseServico.u003cu003ec.u003cu003e9__48_1;
+ if (u003cu003e9_481 == null)
+ {
+ u003cu003e9_481 = (TipoVendedor x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__48_1 = u003cu003e9_481;
+ }
+ list = tipoVendedors.OrderBy<TipoVendedor, long>(u003cu003e9_481).ToList<TipoVendedor>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 141, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<TipoVendedor>();
+ });
+ return tipoVendedors1;
+ }
+
+ internal async Task<List<Usuario>> BuscarUsuario(string value)
+ {
+ 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_UsuarioRepository().Find(value, (long)0);
+ Func<Usuario, string> u003cu003e9_271 = BaseServico.u003cu003ec.u003cu003e9__27_1;
+ if (u003cu003e9_271 == null)
+ {
+ u003cu003e9_271 = (Usuario x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__27_1 = u003cu003e9_271;
+ }
+ list = usuarios.OrderBy<Usuario, string>(u003cu003e9_271).ToList<Usuario>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 132, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Usuario>();
+ });
+ return usuarios1;
+ }
+
+ internal async Task<Usuario> BuscarUsuario(string login, string password)
+ {
+ int num = 3;
+ string str = (new Token()).AggerEncrypt(password);
+ Usuario usuario2 = await Task.Run<Usuario>(() => {
+ Usuario usuario;
+ Usuario usuario1;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial);
+ AuthSso result = this.BuscaUsuarioSso(login, str, empresa.get_Documento()).Result;
+ if (result == null || result.get_Code() == 401)
+ {
+ usuario1 = null;
+ }
+ else if (result.get_Code() != 404)
+ {
+ usuario = read.get_UsuarioRepository().SsoId(result) ?? read.get_UsuarioRepository().FindFromSso(result.get_Data().get_User());
+ if (usuario != null)
+ {
+ if (usuario.get_Excluido())
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ usuario.set_Excluido(false);
+ commited.get_UsuarioRepository().Merge(usuario);
+ commited.Commit();
+ }
+ }
+ usuario.set_TokenSso(result.get_Data().get_Token());
+ if (!Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(usuario.get_SsoId()) || !usuario.get_SsoId().Equals(result.get_Data().get_User().get_Id()))
+ {
+ using (UnitOfWork unitOfWork = Instancia.Commited)
+ {
+ usuario.set_SsoId(result.get_Data().get_User().get_Id());
+ unitOfWork.get_UsuarioRepository().Merge(usuario);
+ unitOfWork.Commit();
+ }
+ usuario1 = usuario;
+ }
+ else
+ {
+ usuario1 = usuario;
+ }
+ }
+ else
+ {
+ using (UnitOfWork commited1 = Instancia.Commited)
+ {
+ usuario = commited1.get_UsuarioRepository().AddUsuarioFromSso(result.get_Data().get_User());
+ commited1.Commit();
+ }
+ usuario.set_TokenSso(result.get_Data().get_Token());
+ usuario1 = usuario;
+ }
+ }
+ else
+ {
+ usuario = read.get_UsuarioRepository().ValidateLogin(login, str);
+ if (usuario != null)
+ {
+ usuario.set_TokenSso(result.get_Data().get_Token());
+ UserSso userSso = this.AddOrUpdateUsuarioSso(usuario, empresa.get_Documento(), null).Result;
+ if (userSso != null)
+ {
+ using (UnitOfWork unitOfWork1 = Instancia.Commited)
+ {
+ usuario.set_SsoId(userSso.get_Id());
+ unitOfWork1.get_UsuarioRepository().Merge(usuario);
+ unitOfWork1.Commit();
+ }
+ usuario.set_TokenSso(this.BuscaUsuarioSso(login, str, empresa.get_Documento()).Result.get_Data().get_Token());
+ usuario1 = usuario;
+ }
+ else
+ {
+ usuario1 = usuario;
+ }
+ }
+ else
+ {
+ usuario1 = null;
+ }
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 134, num, null, true);
+ continue;
+ }
+ return usuario1;
+ }
+ return new Usuario();
+ });
+ return usuario2;
+ }
+
+ internal async Task<bool> BuscarUsuarioMesmoDocumento(string value, long id, long idempresa)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_UsuarioRepository().FindDocUsedByDocumento(value, id, idempresa);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 134, num, value, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ internal async Task<List<Usuario>> BuscarUsuarioPorLoginInteiro(string value)
+ {
+ 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_UsuarioRepository().FindByLoginInteiro(value);
+ Func<Usuario, string> u003cu003e9_391 = BaseServico.u003cu003ec.u003cu003e9__39_1;
+ if (u003cu003e9_391 == null)
+ {
+ u003cu003e9_391 = (Usuario x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__39_1 = u003cu003e9_391;
+ }
+ list = usuarios.OrderBy<Usuario, string>(u003cu003e9_391).ToList<Usuario>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 134, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Usuario>();
+ });
+ return usuarios1;
+ }
+
+ public async Task<List<Usuario>> BuscarUsuariosAsync()
+ {
+ int num = 3;
+ List<Usuario> usuarios2 = await Task.Run<List<Usuario>>(() => {
+ List<Usuario> usuarios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Usuario> usuarios1 = read.get_UsuarioRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ Func<Usuario, long> u003cu003e9_241 = BaseServico.u003cu003ec.u003cu003e9__24_1;
+ if (u003cu003e9_241 == null)
+ {
+ u003cu003e9_241 = (Usuario x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__24_1 = u003cu003e9_241;
+ }
+ usuarios = new List<Usuario>(usuarios1.OrderBy<Usuario, long>(u003cu003e9_241));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 131, num, null, true);
+ continue;
+ }
+ return usuarios;
+ }
+ return new List<Usuario>();
+ });
+ return usuarios2;
+ }
+
+ public async Task<List<UserSso>> BuscarUsuariosSso()
+ {
+ List<UserSso> userSsos;
+ List<UserSso> userSsos1;
+ try
+ {
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ Uri apiSso = Address.get_ApiSso();
+ string[] strArrays = new string[] { "user" };
+ Uri uri = apiSso.Append(strArrays);
+ string[] strArrays1 = new string[] { "onlyempresa" };
+ Uri uri1 = uri.Append(strArrays1);
+ string[] strArrays2 = new string[] { "list" };
+ Uri uri2 = uri1.Append(strArrays2);
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", Recursos.Usuario.get_TokenSso()));
+ HttpResponseMessage async = await httpClient.GetAsync(uri2);
+ if (!async.get_IsSuccessStatusCode())
+ {
+ userSsos1 = null;
+ }
+ else
+ {
+ userSsos1 = JsonConvert.DeserializeObject<List<UserSso>>(await async.get_Content().ReadAsStringAsync());
+ }
+ userSsos = userSsos1;
+ }
+ }
+ catch
+ {
+ userSsos = new List<UserSso>();
+ }
+ return userSsos;
+ }
+
+ internal async Task<List<Vendedor>> BuscarVendedor(string value)
+ {
+ int num = 3;
+ List<Vendedor> vendedors1 = await Task.Run<List<Vendedor>>(() => {
+ List<Vendedor> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Vendedor> vendedors = read.get_VendedorRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ Func<Vendedor, string> u003cu003e9_211 = BaseServico.u003cu003ec.u003cu003e9__21_1;
+ if (u003cu003e9_211 == null)
+ {
+ u003cu003e9_211 = (Vendedor x) => x.get_Nome();
+ BaseServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211;
+ }
+ list = vendedors.OrderBy<Vendedor, string>(u003cu003e9_211).ToList<Vendedor>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 140, num, value, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Vendedor>();
+ });
+ return vendedors1;
+ }
+
+ public async Task<List<Vendedor>> BuscarVendedoresAsync()
+ {
+ int num = 3;
+ List<Vendedor> vendedors2 = await Task.Run<List<Vendedor>>(() => {
+ List<Vendedor> vendedors;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Vendedor> vendedors1 = read.get_VendedorRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()));
+ Func<Vendedor, long> u003cu003e9_471 = BaseServico.u003cu003ec.u003cu003e9__47_1;
+ if (u003cu003e9_471 == null)
+ {
+ u003cu003e9_471 = (Vendedor x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__47_1 = u003cu003e9_471;
+ }
+ vendedors = new List<Vendedor>(vendedors1.OrderBy<Vendedor, long>(u003cu003e9_471));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 140, num, null, true);
+ continue;
+ }
+ return vendedors;
+ }
+ return new List<Vendedor>();
+ });
+ return vendedors2;
+ }
+
+ private async Task<bool> BuscaUsuarioByToken(Usuario usuario)
+ {
+ bool flag;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ Uri apiSso = Address.get_ApiSso();
+ string[] strArrays = new string[] { "user" };
+ Uri uri = apiSso.Append(strArrays);
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", usuario.get_TokenSso()));
+ JsonConvert.DeserializeObject<UserSso>(await await httpClient.GetAsync(uri).get_Content().ReadAsStringAsync());
+ flag = true;
+ }
+ return flag;
+ }
+
+ internal async Task<AuthSso> BuscaUsuarioSso(string login, string password, string documentoEmpresa)
+ {
+ AuthSso authSso;
+ AuthSso authSso1;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ Uri apiSso = Address.get_ApiSso();
+ string[] strArrays = new string[] { "auth" };
+ Uri uri = apiSso.Append(strArrays);
+ object[] ticks = new object[] { login, password, ApplicationHelper.NumeroSerial, documentoEmpresa, null };
+ DateTime universalTime = Funcoes.GetNetworkTime().ToUniversalTime();
+ ticks[4] = universalTime.Ticks;
+ string base64BasicEncode = string.Format("{0}:{1}:{2}:{3}:{4}", ticks).ToBase64BasicEncode();
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", base64BasicEncode);
+ HttpResponseMessage async = await httpClient.GetAsync(uri);
+ if (!async.get_IsSuccessStatusCode())
+ {
+ authSso1 = null;
+ }
+ else
+ {
+ authSso1 = JsonConvert.DeserializeObject<AuthSso>(await async.get_Content().ReadAsStringAsync());
+ }
+ authSso = authSso1;
+ }
+ return authSso;
+ }
+
+ public async Task<List<Usuario>> CarregarUsuarios()
+ {
+ await this.AtualizarUsuarios();
+ return await this.BuscarUsuariosAsync();
+ }
+
+ public RegistroLog CreateDynamicLog(long id, dynamic lista, TipoTela tela)
+ {
+ RegistroLog registroLog;
+ string str;
+ string str1;
+ string str2;
+ string str3;
+ try
+ {
+ List<Diferenca> diferencas = new List<Diferenca>();
+ List<ValorOriginal> valorOriginals = new List<ValorOriginal>();
+ foreach (dynamic listum in (IEnumerable)lista)
+ {
+ if (listum == (dynamic)null)
+ {
+ continue;
+ }
+ if (!listum.GetType().Name.ToUpper().StartsWith("LIST"))
+ {
+ try
+ {
+ diferencas.AddRange(this.DynamicObjeto(listum));
+ }
+ catch
+ {
+ }
+ }
+ else
+ {
+ foreach (dynamic obj1 in (IEnumerable)listum)
+ {
+ try
+ {
+ if (obj1.Id != 0)
+ {
+ diferencas.AddRange(this.DynamicObjeto(obj1));
+ }
+ else
+ {
+ valorOriginals.AddRange(obj1.GetValorOriginal());
+ }
+ }
+ catch
+ {
+ }
+ }
+ }
+ }
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ if (diferencas == null || diferencas.Count != 0)
+ {
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ str = JsonConvert.SerializeObject(diferencas, jsonSerializerSetting).Replace("]", ",").Replace("[", "");
+ }
+ else
+ {
+ str = "";
+ }
+ string str4 = str;
+ if (valorOriginals == null || valorOriginals.Count != 0)
+ {
+ JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings();
+ jsonSerializerSetting1.set_ReferenceLoopHandling(1);
+ str1 = JsonConvert.SerializeObject(valorOriginals, jsonSerializerSetting1).Replace("]", "").Replace("[", "");
+ }
+ else
+ {
+ str1 = "";
+ }
+ string str5 = str1;
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(1);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ if (!string.IsNullOrEmpty(str4) || !string.IsNullOrEmpty(str5))
+ {
+ str2 = string.Concat("[", str4, str5, "]");
+ }
+ else
+ {
+ str2 = null;
+ }
+ registroLog1.set_Descricao(str2);
+ registroLog1.set_EntidadeId(id);
+ registroLog1.set_Tela(tela);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress pAddress = ((IEnumerable<IPAddress>)Recursos.Host.AddressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
+ if (pAddress != null)
+ {
+ str3 = pAddress.ToString();
+ }
+ else
+ {
+ str3 = null;
+ }
+ registroLog1.set_Ip(str3);
+ registroLog1.set_ModeloNovo(true);
+ registroLog = registroLog1;
+ }
+ catch (Exception exception)
+ {
+ registroLog = null;
+ }
+ return registroLog;
+ }
+
+ public RegistroLog CreateLog(long id, dynamic obj, TipoTela tela)
+ {
+ RegistroLog registroLog;
+ string str;
+ string str1;
+ try
+ {
+ List<Diferenca> diferencas = (List<Diferenca>)obj.Compare();
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(1);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ if (diferencas == null || diferencas.Count != 0)
+ {
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ str = JsonConvert.SerializeObject(diferencas, jsonSerializerSetting);
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Descricao(str);
+ registroLog1.set_EntidadeId(id);
+ registroLog1.set_Tela(tela);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress pAddress = ((IEnumerable<IPAddress>)Recursos.Host.AddressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
+ if (pAddress != null)
+ {
+ str1 = pAddress.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog1.set_Ip(str1);
+ registroLog1.set_ModeloNovo(true);
+ registroLog = registroLog1;
+ }
+ catch (Exception exception)
+ {
+ registroLog = null;
+ }
+ return registroLog;
+ }
+
+ public RegistroLog CreateLog(long id, List<Diferenca> diferenca, TipoTela tela)
+ {
+ RegistroLog registroLog;
+ string str;
+ try
+ {
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(1);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(diferenca, jsonSerializerSetting));
+ registroLog1.set_EntidadeId(id);
+ registroLog1.set_Tela(tela);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress pAddress = ((IEnumerable<IPAddress>)Recursos.Host.AddressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Ip(str);
+ registroLog1.set_ModeloNovo(true);
+ registroLog = registroLog1;
+ }
+ catch (Exception exception)
+ {
+ registroLog = null;
+ }
+ return registroLog;
+ }
+
+ public RegistroLog CreateLog(long id, List<Diferenca> diferenca, TipoTela tela, TipoAcao acao)
+ {
+ RegistroLog registroLog;
+ string str;
+ try
+ {
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(acao);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(diferenca, jsonSerializerSetting));
+ registroLog1.set_EntidadeId(id);
+ registroLog1.set_Tela(tela);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress pAddress = ((IEnumerable<IPAddress>)Recursos.Host.AddressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Ip(str);
+ registroLog1.set_ModeloNovo(true);
+ registroLog = registroLog1;
+ }
+ catch (Exception exception)
+ {
+ registroLog = null;
+ }
+ return registroLog;
+ }
+
+ public RegistroLog CreateLog(long id, List<ValorOriginal> valor, TipoTela tela, TipoAcao acao)
+ {
+ RegistroLog registroLog;
+ string str;
+ try
+ {
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(acao);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(valor, jsonSerializerSetting));
+ registroLog1.set_EntidadeId(id);
+ registroLog1.set_Tela(tela);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress pAddress = ((IEnumerable<IPAddress>)Recursos.Host.AddressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Ip(str);
+ registroLog1.set_ModeloNovo(true);
+ registroLog = registroLog1;
+ }
+ catch (Exception exception)
+ {
+ registroLog = null;
+ }
+ return registroLog;
+ }
+
+ internal async Task<UserSso> DeleteUsuarioSso(Usuario usuario, string documentoEmpresa)
+ {
+ UserSso userSso;
+ UserSso userSso1;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ Uri apiSso = Address.get_ApiSso();
+ string[] strArrays = new string[] { "user" };
+ Uri uri = apiSso.Append(strArrays).AddQuery<string>("userId", usuario.get_SsoId());
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", usuario.get_TokenSso()));
+ HttpResponseMessage httpResponseMessage = await httpClient.DeleteAsync(uri);
+ if (!httpResponseMessage.get_IsSuccessStatusCode())
+ {
+ userSso1 = null;
+ }
+ else
+ {
+ userSso1 = JsonConvert.DeserializeObject<UserSso>(await httpResponseMessage.get_Content().ReadAsStringAsync());
+ }
+ userSso = userSso1;
+ }
+ return userSso;
+ }
+
+ public List<Diferenca> DynamicObjeto(dynamic objeto)
+ {
+ dynamic obj = objeto.Compare();
+ if (obj.Count <= 0)
+ {
+ return new List<Diferenca>();
+ }
+ return (List<Diferenca>)obj;
+ }
+
+ public async Task<bool> LoadInicialParameters()
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Parceiro> parceiros = read.get_ParceiroRepository().Find();
+ Func<Parceiro, long> u003cu003e9_521 = BaseServico.u003cu003ec.u003cu003e9__52_1;
+ if (u003cu003e9_521 == null)
+ {
+ u003cu003e9_521 = (Parceiro x) => x.get_Id();
+ BaseServico.u003cu003ec.u003cu003e9__52_1 = u003cu003e9_521;
+ }
+ Recursos.Parceiros = new List<Parceiro>(parceiros.OrderBy<Parceiro, long>(u003cu003e9_521));
+ List<Fabricante> fabricantes = read.get_FabricanteRepository().Select();
+ Func<Fabricante, string> u003cu003e9_522 = BaseServico.u003cu003ec.u003cu003e9__52_2;
+ if (u003cu003e9_522 == null)
+ {
+ u003cu003e9_522 = (Fabricante x) => x.get_Descricao();
+ BaseServico.u003cu003ec.u003cu003e9__52_2 = u003cu003e9_522;
+ }
+ Recursos.Fabricantes = fabricantes.OrderBy<Fabricante, string>(u003cu003e9_522).ToList<Fabricante>();
+ Recursos.Configuracoes = read.get_ConfiguracaoRepository().BuscarConfiguracoes();
+ read.CriarAuxiliar(false);
+ Recursos.Empresas = Auxiliar.get_Empresas();
+ Recursos.Ramos = Auxiliar.get_Ramos();
+ Recursos.Seguradoras = Auxiliar.get_Seguradoras();
+ Recursos.Produtos = Auxiliar.get_Produtos();
+ Recursos.Status = Auxiliar.get_StatusApolice();
+ Recursos.TipoVendedor = Auxiliar.get_TipoVendedores();
+ Recursos.Estipulantes = Auxiliar.get_Estipulantes();
+ Recursos.Vendedores = Auxiliar.get_Vendedores();
+ Recursos.Usuarios = Auxiliar.get_Usuarios();
+ Recursos.TiposTarefa = Auxiliar.get_TiposTarefa();
+ Recursos.StatusProspeccao = Auxiliar.get_StatusProspeccao();
+ Recursos.Coberturas = Auxiliar.get_CoberturasPadrao();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 186, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> ParceiroUtilizado(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_SinistroAutoRepository().ParceiroUtilizado(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 156, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public int Registrar(Exception e, TipoErro erro, int tries, object objeto = null, bool abrirTela = true)
+ {
+ string str;
+ string nome;
+ string nome1;
+ long id;
+ string str1;
+ tries--;
+ if (tries > 0)
+ {
+ return tries;
+ }
+ try
+ {
+ int fileLineNumber = (new StackTrace(e, true)).GetFrame(0).GetFileLineNumber();
+ if (objeto != null)
+ {
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ str = JsonConvert.SerializeObject(objeto, 1, jsonSerializerSetting);
+ }
+ else
+ {
+ str = null;
+ }
+ string str2 = str;
+ LogError logError = new LogError();
+ logError.set_IdFornecedor(ApplicationHelper.IdFornecedor);
+ Empresa empresa = Recursos.Empresa;
+ if (empresa != null)
+ {
+ nome = empresa.get_Nome();
+ }
+ else
+ {
+ nome = null;
+ }
+ logError.set_Fornecedor(nome);
+ Usuario usuario = Recursos.Usuario;
+ if (usuario != null)
+ {
+ nome1 = usuario.get_Nome();
+ }
+ else
+ {
+ nome1 = null;
+ }
+ logError.set_UsuarioLogado(nome1);
+ Usuario usuario1 = Recursos.Usuario;
+ if (usuario1 != null)
+ {
+ id = usuario1.get_Id();
+ }
+ else
+ {
+ id = (long)0;
+ }
+ logError.set_IdUsuarioLogado(id);
+ logError.set_Versao(ApplicationHelper.Versao.ToString());
+ logError.set_Data(Funcoes.GetNetworkTime());
+ logError.set_IdErro(erro);
+ logError.set_Erro(Gestor.Common.Validation.ValidationHelper.GetDescription(erro));
+ logError.set_HResult(e.HResult);
+ Exception innerException = e.InnerException;
+ if (innerException != null)
+ {
+ str1 = innerException.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ logError.set_InnerException(str1);
+ logError.set_HelpLink(e.HelpLink);
+ logError.set_Message(e.Message);
+ logError.set_Source(e.Source);
+ logError.set_StackTrace(e.StackTrace);
+ logError.set_Maquina(Environment.MachineName);
+ logError.set_UsuarioMaquina(Environment.UserName);
+ logError.set_Linha(fileLineNumber.ToString());
+ logError.set_Objeto(str2);
+ Erro.RegistrarErro(logError, abrirTela);
+ this.Sucesso = false;
+ }
+ catch (Exception exception)
+ {
+ }
+ return 0;
+ }
+
+ public async Task<bool> ReloadAuxiliar()
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ read.CriarAuxiliar(true);
+ Recursos.Empresas = Auxiliar.get_Empresas();
+ Recursos.Ramos = Auxiliar.get_Ramos();
+ Recursos.Seguradoras = Auxiliar.get_Seguradoras();
+ Recursos.Produtos = Auxiliar.get_Produtos();
+ Recursos.Status = Auxiliar.get_StatusApolice();
+ Recursos.TipoVendedor = Auxiliar.get_TipoVendedores();
+ Recursos.Estipulantes = Auxiliar.get_Estipulantes();
+ Recursos.Vendedores = Auxiliar.get_Vendedores();
+ Recursos.Usuarios = Auxiliar.get_Usuarios();
+ Recursos.TiposTarefa = Auxiliar.get_TiposTarefa();
+ Recursos.StatusProspeccao = Auxiliar.get_StatusProspeccao();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 186, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public void SalvarAcao(RegistroAcao log, object obs = null)
+ {
+ string str;
+ string str1;
+ if (log == null || Recursos.Usuario.get_Id() == 0)
+ {
+ return;
+ }
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ log.set_Usuario(Recursos.Usuario);
+ log.set_DataHora(Funcoes.GetNetworkTime());
+ log.set_Versao(LoginViewModel.VersaoAtual);
+ log.set_NomeMaquina(Environment.MachineName);
+ log.set_UsuarioMaquina(Environment.UserName);
+ RegistroAcao registroAcao = log;
+ IPAddress pAddress = ((IEnumerable<IPAddress>)Dns.GetHostEntry(Dns.GetHostName()).AddressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroAcao.set_Ip(str);
+ RegistroAcao registroAcao1 = log;
+ if (obs == null)
+ {
+ str1 = "";
+ }
+ else if (!(obs is string))
+ {
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ str1 = JsonConvert.SerializeObject(obs, jsonSerializerSetting);
+ }
+ else
+ {
+ str1 = obs.ToString();
+ }
+ registroAcao1.set_Observacao(str1);
+ commited.get_RegistroAcaoRepository().SaveOrUpdate(log);
+ commited.Commit();
+ }
+ }
+ catch (Exception exception)
+ {
+ this.Registrar(exception, 0, 3, log, true);
+ }
+ }
+
+ public async Task SalvarControle(ControleArquivoDigital controle)
+ {
+ int num = 3;
+ await Task.Run(() => {
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_IndiceArquivoDigitalRepository().SaveOrUpdate(controle);
+ commited.Commit();
+ }
+ break;
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 179, num, controle, true);
+ }
+ }
+ });
+ }
+
+ public void SaveLog(RegistroLog keyValues, UnitOfWork unitOfWork)
+ {
+ if (keyValues == null)
+ {
+ return;
+ }
+ try
+ {
+ unitOfWork.get_RegistroLogRepository().SaveOrUpdate(keyValues);
+ }
+ catch (Exception exception)
+ {
+ }
+ }
+
+ public void SaveLog(List<RegistroLog> keyValues, UnitOfWork unitOfWork)
+ {
+ if (keyValues == null)
+ {
+ return;
+ }
+ try
+ {
+ List<RegistroLog> list = keyValues.Where<RegistroLog>((RegistroLog x) => {
+ if (string.IsNullOrEmpty((x != null ? x.get_Descricao() : null)))
+ {
+ return false;
+ }
+ return !string.IsNullOrEmpty(x.get_Versao());
+ }).ToList<RegistroLog>();
+ unitOfWork.get_RegistroLogRepository().AddRange(list);
+ }
+ catch (Exception exception)
+ {
+ }
+ }
+
+ public async Task<int> Sincronizar(List<DadosVinculo> dados, Filtros filtros)
+ {
+ int num2 = 3;
+ int num3 = await Task.Run<int>(() => {
+ int num;
+ while (num2 > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ int num1 = commited.get_VinculoDocumentoRepository().Sincronize(filtros.get_Inicio(), dados);
+ commited.Commit();
+ num = num1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num2 = this.Registrar(exception, 293, num2, null, true);
+ continue;
+ }
+ return num;
+ }
+ return 0;
+ });
+ return num3;
+ }
+
+ public async Task<int[]> Sincronizar(DateTime data, List<long> ids = null)
+ {
+ int num = 3;
+ int[] numArray2 = await Task.Run<int[]>(() => {
+ int[] numArray;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ int[] numArray1 = commited.get_ParcelaRepository().SincronizarPendencia(data, ids);
+ commited.Commit();
+ numArray = numArray1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 300, num, false, true);
+ continue;
+ }
+ return numArray;
+ }
+ return new int[2];
+ });
+ return numArray2;
+ }
+
+ public async Task<bool> TipoVendedorUtilizado(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_VendedorParcelaRepository().TipoVendedorUtilizado(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = this.Registrar(exception, 155, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ internal async Task<AuthSso> VerificaUsuarioSso(string login, string documentoEmpresa)
+ {
+ AuthSso authSso;
+ AuthSso authSso1;
+ using (HttpClient httpClient = new HttpClient())
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ Uri apiSso = Address.get_ApiSso();
+ string[] strArrays = new string[] { "exist" };
+ Uri uri = apiSso.Append(strArrays);
+ object[] ticks = new object[] { login, login, ApplicationHelper.NumeroSerial, documentoEmpresa, null };
+ DateTime universalTime = Funcoes.GetNetworkTime().ToUniversalTime();
+ ticks[4] = universalTime.Ticks;
+ string base64BasicEncode = string.Format("{0}:{1}:{2}:{3}:{4}", ticks).ToBase64BasicEncode();
+ httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", base64BasicEncode);
+ HttpResponseMessage async = await httpClient.GetAsync(uri);
+ if (!async.get_IsSuccessStatusCode())
+ {
+ authSso1 = null;
+ }
+ else
+ {
+ authSso1 = JsonConvert.DeserializeObject<AuthSso>(await async.get_Content().ReadAsStringAsync());
+ }
+ authSso = authSso1;
+ }
+ return authSso;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/LogServico.cs b/Codemerx/Gestor.Application/Servicos/LogServico.cs new file mode 100644 index 0000000..bc61ed1 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/LogServico.cs @@ -0,0 +1,262 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Relatorios.LogsEnvio;
+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
+{
+ public class LogServico : BaseServico
+ {
+ public LogServico()
+ {
+ }
+
+ public async Task<ObservableCollection<RegistroLog>> BuscaLogParcelas(List<long> ids)
+ {
+ int num = 3;
+ ObservableCollection<RegistroLog> observableCollection1 = await Task.Run<ObservableCollection<RegistroLog>>(() => {
+ ObservableCollection<RegistroLog> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<RegistroLog> registroLogs = read.get_RegistroLogRepository().BuscaLogParcelas(ids);
+ Func<RegistroLog, DateTime> u003cu003e9_11 = LogServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (RegistroLog x) => x.get_DataHora();
+ LogServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ observableCollection = new ObservableCollection<RegistroLog>(registroLogs.OrderByDescending<RegistroLog, DateTime>(u003cu003e9_11));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 67, num, new { Parcela = 5, ids = ids }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<RegistroLog>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<List<RegistroAcao>> BuscarLogs(Filtros filtro)
+ {
+ int num = 3;
+ List<RegistroAcao> registroAcaos1 = await Task.Run<List<RegistroAcao>>(() => {
+ List<RegistroAcao> registroAcaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ registroAcaos = read.get_RegistroAcaoRepository().Find(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 321, num, filtro, true);
+ continue;
+ }
+ return registroAcaos;
+ }
+ return new List<RegistroAcao>();
+ });
+ return registroAcaos1;
+ }
+
+ public async Task<List<RegistroAcao>> BuscarLogsAntigos(Filtros filtro)
+ {
+ int num = 3;
+ List<RegistroAcao> registroAcaos1 = await Task.Run<List<RegistroAcao>>(() => {
+ List<RegistroAcao> registroAcaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ registroAcaos = read.get_RegistroAcaoRepository().FindOld(filtro, Connection.GetConnectionString());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 321, num, filtro, true);
+ continue;
+ }
+ return registroAcaos;
+ }
+ return new List<RegistroAcao>();
+ });
+ return registroAcaos1;
+ }
+
+ public async Task<List<LogsEnvio>> BuscarLogsEnvio(Filtros filtro)
+ {
+ int num = 3;
+ List<LogsEnvio> logsEnvios1 = await Task.Run<List<LogsEnvio>>(() => {
+ List<LogsEnvio> logsEnvios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ logsEnvios = read.get_RegistroLogRepository().LogsEnvio(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 9, num, filtro, true);
+ continue;
+ }
+ return logsEnvios;
+ }
+ return new List<LogsEnvio>();
+ });
+ return logsEnvios1;
+ }
+
+ public async Task<ObservableCollection<RegistroLog>> FindAllByEntityId(TipoTela tela, long id)
+ {
+ int num = 3;
+ ObservableCollection<RegistroLog> observableCollection1 = await Task.Run<ObservableCollection<RegistroLog>>(() => {
+ ObservableCollection<RegistroLog> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<RegistroLog> registroLogs = read.get_RegistroLogRepository().FindByEntityId(tela, id);
+ Func<RegistroLog, DateTime> u003cu003e9_41 = LogServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = (RegistroLog x) => x.get_DataHora();
+ LogServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ observableCollection = new ObservableCollection<RegistroLog>(registroLogs.OrderByDescending<RegistroLog, DateTime>(u003cu003e9_41));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 67, num, new { tela = tela, id = id }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<RegistroLog>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<LogEmail>> FindByEntity(TipoTela tela, long id)
+ {
+ int num = 3;
+ ObservableCollection<LogEmail> observableCollection1 = await Task.Run<ObservableCollection<LogEmail>>(() => {
+ ObservableCollection<LogEmail> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<LogEmail> logEmails = read.get_RegistroLogRepository().FindByEntity(tela, id);
+ Func<LogEmail, DateTime> u003cu003e9_21 = LogServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (LogEmail x) => x.get_Data();
+ LogServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ observableCollection = new ObservableCollection<LogEmail>(logEmails.OrderByDescending<LogEmail, DateTime>(u003cu003e9_21));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 68, num, new { tela = tela, id = id }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<LogEmail>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<RegistroLog>> FindByEntityId(TipoTela tela, long id)
+ {
+ int num = 3;
+ ObservableCollection<RegistroLog> observableCollection1 = await Task.Run<ObservableCollection<RegistroLog>>(() => {
+ ObservableCollection<RegistroLog> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<RegistroLog> registroLogs = read.get_RegistroLogRepository().FindByEntityId(tela, id);
+ Func<RegistroLog, DateTime> u003cu003e9_01 = LogServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (RegistroLog x) => x.get_DataHora();
+ LogServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ observableCollection = new ObservableCollection<RegistroLog>(registroLogs.OrderByDescending<RegistroLog, DateTime>(u003cu003e9_01));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 67, num, new { tela = tela, id = id }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<RegistroLog>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<ObservableCollection<LogEmail>> FindById(long id)
+ {
+ int num = 3;
+ ObservableCollection<LogEmail> observableCollection1 = await Task.Run<ObservableCollection<LogEmail>>(() => {
+ ObservableCollection<LogEmail> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ observableCollection = new ObservableCollection<LogEmail>(read.get_RegistroLogRepository().FindByIdSingle(id));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 69, num, new { id = id }, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<LogEmail>();
+ });
+ return observableCollection1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs b/Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs new file mode 100644 index 0000000..3eb72d5 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/MalaDiretaServico.cs @@ -0,0 +1,188 @@ +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.MalaDireta;
+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
+{
+ public class MalaDiretaServico : BaseServico
+ {
+ public MalaDiretaServico()
+ {
+ }
+
+ public async Task<List<ModeloMalaDireta>> BuscarModelos()
+ {
+ int num = 3;
+ List<ModeloMalaDireta> modeloMalaDiretas1 = await Task.Run<List<ModeloMalaDireta>>(() => {
+ List<ModeloMalaDireta> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<ModeloMalaDireta> modeloMalaDiretas = read.get_ModeloMalaDiretaRepository().Find();
+ Func<ModeloMalaDireta, string> u003cu003e9_01 = MalaDiretaServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (ModeloMalaDireta x) => x.get_Assunto();
+ MalaDiretaServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ list = modeloMalaDiretas.OrderBy<ModeloMalaDireta, string>(u003cu003e9_01).ToList<ModeloMalaDireta>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 70, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<ModeloMalaDireta>();
+ });
+ return modeloMalaDiretas1;
+ }
+
+ public async Task<bool> Delete(ModeloMalaDireta modelo)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_ModeloMalaDiretaRepository().Delete(modelo.get_Id());
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ ModeloMalaDireta modeloMalaDiretum = modelo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(modeloMalaDiretum, jsonSerializerSetting));
+ registroLog.set_EntidadeId(modelo.get_Id());
+ registroLog.set_Tela(39);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_21 = MalaDiretaServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MalaDiretaServico.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, 255, num, modelo, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<ModeloMalaDireta> Save(ModeloMalaDireta modelo)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ ModeloMalaDireta modeloMalaDiretum2 = modelo;
+ ModeloMalaDireta modeloMalaDiretum3 = await Task.Run<ModeloMalaDireta>(() => {
+ ModeloMalaDireta modeloMalaDiretum;
+ string str;
+ while (num > 0)
+ {
+ modelo = modeloMalaDiretum2;
+ try
+ {
+ TipoAcao tipoAcao = (modelo.get_Id() == 0 ? 0 : 1);
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ modelo = (tipoAcao == null ? commited.get_ModeloMalaDiretaRepository().SaveOrUpdate(modelo) : commited.get_ModeloMalaDiretaRepository().Merge(modelo));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ ModeloMalaDireta modeloMalaDiretum1 = modelo;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(modeloMalaDiretum1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(modelo.get_Id());
+ registroLog.set_Tela(39);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = MalaDiretaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MalaDiretaServico.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();
+ modeloMalaDiretum = modelo;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 254, num, modelo, true);
+ continue;
+ }
+ return modeloMalaDiretum;
+ }
+ return modeloMalaDiretum2;
+ });
+ return modeloMalaDiretum3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ParceiroServico.cs b/Codemerx/Gestor.Application/Servicos/ParceiroServico.cs new file mode 100644 index 0000000..b5b51f4 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ParceiroServico.cs @@ -0,0 +1,123 @@ +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.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ internal class ParceiroServico : BaseServico
+ {
+ public ParceiroServico()
+ {
+ }
+
+ internal async Task<Parceiro> BuscarParceiro(long id)
+ {
+ int num = 3;
+ Parceiro parceiro1 = await Task.Run<Parceiro>(() => {
+ Parceiro parceiro;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parceiro = read.get_ParceiroRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 71, num, id, true);
+ continue;
+ }
+ return parceiro;
+ }
+ return new Parceiro();
+ });
+ return parceiro1;
+ }
+
+ public async Task<bool> Delete(Parceiro parceiro)
+ {
+ 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(parceiro.get_Id(), parceiro.GetValorOriginal(), 22, 2));
+ commited.get_ParceiroRepository().Delete(parceiro.get_Id());
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 257, num, parceiro, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Parceiro> Save(Parceiro parceiro)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Parceiro parceiro1 = parceiro;
+ Parceiro parceiro2 = await Task.Run<Parceiro>(() => {
+ Parceiro parceiro3;
+ bool flag;
+ while (num > 0)
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ parceiro = parceiro1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ flag = (parceiro.get_Id() == 0 ? false : true);
+ if (flag)
+ {
+ registroLogs.Add(base.CreateLog(parceiro.get_Id(), parceiro, 22));
+ }
+ parceiro = (parceiro.get_Id() == 0 ? commited.get_ParceiroRepository().SaveOrUpdate(parceiro) : commited.get_ParceiroRepository().Merge(parceiro));
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(parceiro.get_Id(), parceiro.GetValorOriginal(), 22, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ parceiro3 = parceiro;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 256, num, parceiro, true);
+ continue;
+ }
+ return parceiro3;
+ }
+ return parceiro1;
+ });
+ return parceiro2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ParcelaServico.cs b/Codemerx/Gestor.Application/Servicos/ParcelaServico.cs new file mode 100644 index 0000000..fcb987e --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ParcelaServico.cs @@ -0,0 +1,1006 @@ +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.Configuracoes;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Relatorios.PrevisaoPagamentoComissao;
+using Gestor.Model.Domain.Seguros;
+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
+{
+ internal class ParcelaServico : BaseServico
+ {
+ public ParcelaServico()
+ {
+ }
+
+ public async Task<Documento> BuscarApolice(long id)
+ {
+ int num = 3;
+ Documento documento1 = await Task.Run<Documento>(() => {
+ Documento documento;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documento = read.get_ParcelaRepository().BuscarApolice(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 3, num, id, true);
+ continue;
+ }
+ return documento;
+ }
+ return new Documento();
+ });
+ return documento1;
+ }
+
+ public async Task<List<Documento>> BuscarFatura(string numero)
+ {
+ 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_ParcelaRepository().FindNumFatura(numero);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 322, num, numero, true);
+ continue;
+ }
+ return documentos;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Documento>> BuscarFaturas(Filtros filtro, bool buscaAssinaturas = 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_ParcelaRepository().BuscaDocumentosPorVigencia(filtro, buscaAssinaturas, painelBi);
+ return documentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 76, num, filtro, true);
+ }
+ if (num <= 0)
+ {
+ break;
+ }
+ }
+ documentos = new List<Documento>();
+ return documentos;
+ });
+ 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_ParcelaRepository().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<VendedorParcela>> BuscarPagamentoVendedor(Filtros filtro, bool reciboPagamento, bool segundaViaReciboPagamento)
+ {
+ int num = 3;
+ List<VendedorParcela> vendedorParcelas1 = await Task.Run<List<VendedorParcela>>(() => {
+ List<VendedorParcela> vendedorParcelas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ IParcelaRepository parcelaRepository = read.get_ParcelaRepository();
+ Filtros filtro1 = filtro;
+ bool flag = reciboPagamento;
+ bool flag1 = segundaViaReciboPagamento;
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ Func<ConfiguracaoSistema, bool> u003cu003e9_201 = ParcelaServico.u003cu003ec.u003cu003e9__20_1;
+ if (u003cu003e9_201 == null)
+ {
+ u003cu003e9_201 = (ConfiguracaoSistema x) => x.get_Configuracao() == 34;
+ ParcelaServico.u003cu003ec.u003cu003e9__20_1 = u003cu003e9_201;
+ }
+ vendedorParcelas = parcelaRepository.FindByPagamento(filtro1, flag, flag1, configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_201));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 80, num, filtro, true);
+ continue;
+ }
+ return vendedorParcelas;
+ }
+ return new List<VendedorParcela>();
+ });
+ return vendedorParcelas1;
+ }
+
+ public async Task<Parcela> BuscarParcela(long id)
+ {
+ int num = 3;
+ Parcela parcela1 = await Task.Run<Parcela>(() => {
+ Parcela parcela;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parcela = read.get_ParcelaRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 74, num, id, true);
+ continue;
+ }
+ return parcela;
+ }
+ return new Parcela();
+ });
+ return parcela1;
+ }
+
+ internal async Task<List<Parcela>> BuscarParcelas(long id)
+ {
+ int num = 3;
+ List<Parcela> parcelas1 = await Task.Run<List<Parcela>>(() => {
+ List<Parcela> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Parcela> parcelas = read.get_ParcelaRepository().FindByDocumentId(id);
+ Func<Parcela, int> u003cu003e9_31 = ParcelaServico.u003cu003ec.u003cu003e9__3_1;
+ if (u003cu003e9_31 == null)
+ {
+ u003cu003e9_31 = (Parcela x) => x.get_NumeroParcela();
+ ParcelaServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31;
+ }
+ list = parcelas.OrderBy<Parcela, int>(u003cu003e9_31).ToList<Parcela>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 73, num, id, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Parcela>();
+ });
+ return parcelas1;
+ }
+
+ internal async Task<List<Documento>> BuscarParcelas(string ids, List<Documento> documentos)
+ {
+ int num = 3;
+ List<Documento> documentos1 = await Task.Run<List<Documento>>(() => {
+ List<Documento> documentos2;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ documentos2 = read.get_ParcelaRepository().FindByDocumentIds(ids, documentos);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 75, num, null, true);
+ continue;
+ }
+ return documentos2;
+ }
+ return new List<Documento>();
+ });
+ return documentos1;
+ }
+
+ public async Task<List<Parcela>> BuscarParcelas(Filtros filtro, bool somenteAtivos = false)
+ {
+ int num = 3;
+ List<Parcela> parcelas1 = await Task.Run<List<Parcela>>(() => {
+ List<Parcela> parcelas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parcelas = read.get_ParcelaRepository().FindByPendente(filtro, false, somenteAtivos);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 79, num, filtro, true);
+ continue;
+ }
+ return parcelas;
+ }
+ return new List<Parcela>();
+ });
+ return parcelas1;
+ }
+
+ internal async Task<ObservableCollection<Parcela>> BuscarParcelasAsync(long id)
+ {
+ int num = 3;
+ ObservableCollection<Parcela> observableCollection1 = await Task.Run<ObservableCollection<Parcela>>(() => {
+ ObservableCollection<Parcela> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Parcela> parcelas = read.get_ParcelaRepository().FindByDocumentId(id);
+ Func<Parcela, int> u003cu003e9_01 = ParcelaServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (Parcela x) => x.get_NumeroParcela();
+ ParcelaServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ observableCollection = new ObservableCollection<Parcela>(parcelas.OrderBy<Parcela, int>(u003cu003e9_01));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 73, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Parcela>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<List<Parcela>> BuscarParcelasPendentes(Filtros filtro, bool somenteAtivos = false)
+ {
+ int num = 3;
+ List<Parcela> parcelas1 = await Task.Run<List<Parcela>>(() => {
+ List<Parcela> parcelas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parcelas = read.get_ParcelaRepository().FindByPendente(filtro, true, somenteAtivos);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 78, num, filtro, true);
+ continue;
+ }
+ return parcelas;
+ }
+ return new List<Parcela>();
+ });
+ return parcelas1;
+ }
+
+ internal async Task<ObservableCollection<Parcela>> BuscarParcelasPorDocumento(Documento documento)
+ {
+ int num = 3;
+ ObservableCollection<Parcela> observableCollection1 = await Task.Run<ObservableCollection<Parcela>>(() => {
+ ObservableCollection<Parcela> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Parcela> parcelas = read.get_ParcelaRepository().FindByDocumento(documento);
+ Func<Parcela, int> u003cu003e9_11 = ParcelaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (Parcela x) => x.get_NumeroParcela();
+ ParcelaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ observableCollection = new ObservableCollection<Parcela>(parcelas.OrderBy<Parcela, int>(u003cu003e9_11));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 73, num, documento.get_Id(), true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<Parcela>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<List<Parcela>> BuscarParcelasRecebimento(Filtros filtro)
+ {
+ int num = 3;
+ List<Parcela> parcelas1 = await Task.Run<List<Parcela>>(async () => {
+ List<Parcela> parcelas;
+ while (true)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parcelas = await read.get_ParcelaRepository().FindByRecebimento(filtro);
+ return parcelas;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 77, num, filtro, true);
+ }
+ if (num <= 0)
+ {
+ break;
+ }
+ }
+ parcelas = new List<Parcela>();
+ return parcelas;
+ });
+ return parcelas1;
+ }
+
+ public async Task<List<PrevisaoPagamento>> BuscarPrevisaoPagamentoComissao(Filtros filtro)
+ {
+ int num = 3;
+ List<PrevisaoPagamento> previsaoPagamentos1 = await Task.Run<List<PrevisaoPagamento>>(() => {
+ List<PrevisaoPagamento> previsaoPagamentos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ previsaoPagamentos = read.get_ParcelaRepository().PrevisaoPagamentoComissao(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 316, num, filtro, true);
+ continue;
+ }
+ return previsaoPagamentos;
+ }
+ return new List<PrevisaoPagamento>();
+ });
+ return previsaoPagamentos1;
+ }
+
+ internal async Task<List<Parcela>> BuscarTodasParcelas(List<long> ids)
+ {
+ int num = 3;
+ List<Parcela> parcelas1 = await Task.Run<List<Parcela>>(() => {
+ List<Parcela> parcelas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ parcelas = read.get_ParcelaRepository().FindByDocumentId(ids);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 73, num, ids, true);
+ continue;
+ }
+ return parcelas;
+ }
+ return new List<Parcela>();
+ });
+ return parcelas1;
+ }
+
+ internal async Task<List<Vendedor>> BuscarVendedores(long id)
+ {
+ int num = 3;
+ List<Vendedor> vendedors = await Task.Run<List<Vendedor>>(() => {
+ List<Vendedor> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<VendedorParcela> vendedorParcelas = read.get_VendedorParcelaRepository().FindByDocumentId(id);
+ Func<VendedorParcela, long> u003cu003e9_51 = ParcelaServico.u003cu003ec.u003cu003e9__5_1;
+ if (u003cu003e9_51 == null)
+ {
+ u003cu003e9_51 = (VendedorParcela x) => x.get_Vendedor().get_Id();
+ ParcelaServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51;
+ }
+ IEnumerable<IGrouping<long, VendedorParcela>> groupings = vendedorParcelas.GroupBy<VendedorParcela, long>(u003cu003e9_51);
+ Func<IGrouping<long, VendedorParcela>, Vendedor> u003cu003e9_52 = ParcelaServico.u003cu003ec.u003cu003e9__5_2;
+ if (u003cu003e9_52 == null)
+ {
+ u003cu003e9_52 = (IGrouping<long, VendedorParcela> x) => x.First<VendedorParcela>().get_Vendedor();
+ ParcelaServico.u003cu003ec.u003cu003e9__5_2 = u003cu003e9_52;
+ }
+ list = groupings.Select<IGrouping<long, VendedorParcela>, Vendedor>(u003cu003e9_52).ToList<Vendedor>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 140, num, null, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Vendedor>();
+ });
+ return vendedors;
+ }
+
+ public async Task<bool> Delete(Parcela parcela, List<Parcela> todas)
+ {
+ int num = 3;
+ Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_ParcelaRepository().Delete(parcela.get_Id());
+ List<RegistroLog> registroLogs = new List<RegistroLog>()
+ {
+ base.CreateLog(parcela.get_Id(), parcela.GetValorOriginal(), 5, 2)
+ };
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 190, num, parcela, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> DeletePagamentoRange(List<VendedorParcela> repasses)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_VendedorParcelaRepository().DeleteRange(repasses);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 21, num, repasses, false);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<List<Documento>> FaturaPendente(Filtros filtro)
+ {
+ 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_ParcelaRepository().FaturaPendente(filtro);
+ return documentos;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 83, num, filtro, true);
+ }
+ if (num <= 0)
+ {
+ break;
+ }
+ }
+ documentos = new List<Documento>();
+ return documentos;
+ });
+ return documentos1;
+ }
+
+ public async Task<bool> GerarPagamento(List<VendedorParcela> pagamentos)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ IVendedorParcelaRepository vendedorParcelaRepository = commited.get_VendedorParcelaRepository();
+ List<VendedorParcela> vendedorParcelas = pagamentos;
+ Func<VendedorParcela, long> u003cu003e9_221 = ParcelaServico.u003cu003ec.u003cu003e9__22_1;
+ if (u003cu003e9_221 == null)
+ {
+ u003cu003e9_221 = (VendedorParcela x) => x.get_Id();
+ ParcelaServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221;
+ }
+ if (vendedorParcelaRepository.GerarPagamento(vendedorParcelas.Select<VendedorParcela, long>(u003cu003e9_221).ToList<long>(), networkTime))
+ {
+ commited.Commit();
+ flag = true;
+ }
+ else
+ {
+ flag = false;
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 193, num, pagamentos, 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)
+ {
+ Parcela parcela = commited.get_ParcelaRepository().FindById(id);
+ parcela.Initialize();
+ parcela.set_Observacao(observacao);
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), parcela, 5));
+ commited.get_ParcelaRepository().Merge(parcela);
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ }
+ str = observacao;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 24, num, new { id = id, observacao = observacao }, true);
+ continue;
+ }
+ return str;
+ }
+ return "";
+ });
+ return str1;
+ }
+
+ public async Task<Parcela> Save(Parcela parcela, List<Parcela> todas, List<VendedorParcela> repasses = null, bool abrirTela = true)
+ {
+ Func<Parcela, bool> func1 = null;
+ int num = 3;
+ base.Sucesso = true;
+ Parcela parcela2 = parcela;
+ List<VendedorParcela> vendedorParcelas = repasses;
+ Funcoes.GetNetworkTime();
+ ObservableCollection<Parcela> observableCollection1 = await this.BuscarParcelasAsync(parcela.get_Documento().get_Id());
+ ObservableCollection<Parcela> observableCollection2 = observableCollection1;
+ Parcela parcela3 = await Task.Run<Parcela>(async () => {
+ Parcela parcela4;
+ while (num > 0)
+ {
+ try
+ {
+ ObservableCollection<Parcela> observableCollection = observableCollection2;
+ Func<Parcela, bool> u003cu003e9_1 = func1;
+ if (u003cu003e9_1 == null)
+ {
+ Func<Parcela, bool> id = (Parcela x) => x.get_Id() == parcela.get_Id();
+ Func<Parcela, bool> func = id;
+ func1 = id;
+ u003cu003e9_1 = func;
+ }
+ Parcela parcela1 = observableCollection.FirstOrDefault<Parcela>(u003cu003e9_1);
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ bool flag = parcela.get_Id() == (long)0;
+ parcela.set_IdEmpresa(parcela.get_Documento().get_Controle().get_IdEmpresa());
+ parcela = (flag ? commited.get_ParcelaRepository().SaveOrUpdate(parcela) : commited.get_ParcelaRepository().Merge(parcela));
+ if (repasses != null)
+ {
+ foreach (VendedorParcela repass in repasses)
+ {
+ repass.set_Documento(parcela.get_Documento());
+ repass.set_Parcela(parcela);
+ if (repass.get_Id() != 0)
+ {
+ commited.get_VendedorParcelaRepository().Merge(repass);
+ }
+ else
+ {
+ commited.get_VendedorParcelaRepository().SaveOrUpdate(repass);
+ }
+ }
+ parcela.set_Vendedores(new ObservableCollection<VendedorParcela>(repasses));
+ }
+ if (!flag)
+ {
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), parcela.Compare(parcela1.GetValorOriginal()), 5, 1));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(parcela.get_Id(), parcela.GetValorOriginal(), 5, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ parcela4 = parcela;
+ return parcela4;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 24, num, parcela2, abrirTela);
+ }
+ }
+ parcela2.set_Vendedores((vendedorParcelas != null ? new ObservableCollection<VendedorParcela>(vendedorParcelas) : null));
+ parcela4 = parcela2;
+ return parcela4;
+ });
+ return parcela3;
+ }
+
+ public async Task<VendedorParcela> Save(VendedorParcela pagamento)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Funcoes.GetNetworkTime();
+ VendedorParcela vendedorParcela2 = await Task.Run<VendedorParcela>(() => {
+ VendedorParcela vendedorParcela;
+ while (num > 0)
+ {
+ VendedorParcela vendedorParcela1 = pagamento;
+ try
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ vendedorParcela1 = (vendedorParcela1.get_Id() == 0 ? commited.get_VendedorParcelaRepository().SaveOrUpdate(vendedorParcela1) : commited.get_VendedorParcelaRepository().Merge(vendedorParcela1));
+ if (pagamento.get_Id() != 0)
+ {
+ registroLogs.Add(base.CreateLog(vendedorParcela1.get_Id(), vendedorParcela1.Compare(vendedorParcela1.GetValorOriginal()), 37, 1));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(vendedorParcela1.get_Id(), vendedorParcela1.GetValorOriginal(), 37, 0));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ vendedorParcela = vendedorParcela1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 189, num, pagamento, true);
+ continue;
+ }
+ return vendedorParcela;
+ }
+ return pagamento;
+ });
+ return vendedorParcela2;
+ }
+
+ public async Task<List<Parcela>> SaveRange(List<Parcela> parcela)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<Parcela> parcelas2 = await Task.Run<List<Parcela>>(() => {
+ List<Parcela> parcelas;
+ while (num > 0)
+ {
+ List<Parcela> parcelas1 = parcela;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ foreach (Parcela parcela1 in parcelas1)
+ {
+ if (parcela1.get_Id() != 0)
+ {
+ commited.get_ParcelaRepository().Merge(parcela1);
+ }
+ else
+ {
+ parcela1.set_IdEmpresa(parcela1.get_Documento().get_Controle().get_IdEmpresa());
+ commited.get_ParcelaRepository().SaveOrUpdate(parcela1);
+ }
+ }
+ commited.Commit();
+ parcelas = parcelas1;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 24, num, parcela, true);
+ continue;
+ }
+ return parcelas;
+ }
+ return parcela;
+ });
+ return parcelas2;
+ }
+
+ public async Task<bool> SaveRange(List<VendedorParcela> repasses)
+ {
+ int num = 3;
+ List<VendedorParcela> vendedorParcelas1 = repasses;
+ Funcoes.GetNetworkTime();
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ repasses = vendedorParcelas1;
+ try
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ List<VendedorParcela> vendedorParcelas = repasses;
+ if (vendedorParcelas != null)
+ {
+ vendedorParcelas.ForEach((VendedorParcela x) => {
+ x.get_Id();
+ x = (x.get_Id() == 0 ? commited.get_VendedorParcelaRepository().SaveOrUpdate(x) : commited.get_VendedorParcelaRepository().Merge(x));
+ if (x.get_Id() == 0)
+ {
+ registroLogs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 37, 0));
+ return;
+ }
+ registroLogs.Add(base.CreateLog(x.get_Id(), x.Compare(x.GetValorOriginal()), 37, 1));
+ });
+ }
+ else
+ {
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 189, num, repasses, false);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> TemPagamento(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_VendedorParcelaRepository().TemPagamentoParcela(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 82, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> UpdateDetalhes(List<DetalheExtrato> detalhes)
+ {
+ int num = 3;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ bool flag3 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ Func<ConfiguracaoSistema, bool> u003cu003e9_141 = ParcelaServico.u003cu003ec.u003cu003e9__14_1;
+ if (u003cu003e9_141 == null)
+ {
+ u003cu003e9_141 = (ConfiguracaoSistema x) => x.get_Configuracao() == 51;
+ ParcelaServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141;
+ }
+ bool flag1 = configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_141);
+ bool flag2 = commited.get_ParcelaRepository().Update(detalhes, flag1);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ detalhes.ForEach((DetalheExtrato x) => {
+ 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(x, jsonSerializerSetting));
+ registroLog.set_EntidadeId(x.get_Id());
+ registroLog.set_Tela(23);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_143 = ParcelaServico.u003cu003ec.u003cu003e9__14_3;
+ if (u003cu003e9_143 == null)
+ {
+ u003cu003e9_143 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ParcelaServico.u003cu003ec.u003cu003e9__14_3 = u003cu003e9_143;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_143);
+ str = (pAddress != null ? pAddress.ToString() : null);
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ });
+ commited.Commit();
+ flag = flag2;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 192, num, detalhes, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag3;
+ }
+
+ public async Task<List<Parcela>> UpdateRange(List<Parcela> parcelas)
+ {
+ base.Sucesso = true;
+ int num = 3;
+ List<Parcela> parcelas1 = parcelas;
+ Funcoes.GetNetworkTime();
+ List<Parcela> parcelas2 = await Task.Run<List<Parcela>>(() => {
+ List<Parcela> parcelas3;
+ while (num > 0)
+ {
+ parcelas = parcelas1;
+ try
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ parcelas = commited.get_ParcelaRepository().UpdateRange(parcelas);
+ parcelas.ForEach((Parcela x) => {
+ registroLogs.Add(base.CreateLog(x.get_Id(), x.Compare(x.GetValorOriginal()), 5, 1));
+ base.SaveLog(registroLogs, commited);
+ });
+ commited.Commit();
+ parcelas3 = parcelas;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 24, num, parcelas, false);
+ continue;
+ }
+ return parcelas3;
+ }
+ return parcelas1;
+ });
+ return parcelas2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs b/Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs new file mode 100644 index 0000000..525efc6 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/PermissaoArquivoDigitalServico.cs @@ -0,0 +1,167 @@ +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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class PermissaoArquivoDigitalServico : BaseServico
+ {
+ public PermissaoArquivoDigitalServico()
+ {
+ }
+
+ public PermissaoArquivoDigital BuscarPermissao(Usuario usuario, TipoArquivoDigital tela)
+ {
+ PermissaoArquivoDigital permissaoArquivoDigital;
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ PermissaoArquivoDigital permissaoArquivoDigital1 = read.get_PermissaoArquivoDigitalRepository().FindByPermissao(usuario.get_Id(), tela);
+ if (permissaoArquivoDigital1 != null)
+ {
+ permissaoArquivoDigital = permissaoArquivoDigital1;
+ }
+ else
+ {
+ PermissaoArquivoDigital permissaoArquivoDigital2 = new PermissaoArquivoDigital();
+ permissaoArquivoDigital2.set_Usuario(usuario);
+ permissaoArquivoDigital2.set_Tela(tela);
+ permissaoArquivoDigital2.set_Consultar(true);
+ permissaoArquivoDigital2.set_Excluir(true);
+ permissaoArquivoDigital2.set_Incluir(true);
+ permissaoArquivoDigital = permissaoArquivoDigital2;
+ }
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true);
+ continue;
+ }
+ return permissaoArquivoDigital;
+ }
+ return null;
+ }
+
+ public async Task<List<PermissaoArquivoDigital>> PermissArquivoDigital(Usuario usuario)
+ {
+ int num = 3;
+ List<PermissaoArquivoDigital> permissaoArquivoDigitals1 = await Task.Run<List<PermissaoArquivoDigital>>(() => {
+ List<PermissaoArquivoDigital> permissaoArquivoDigitals;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ permissaoArquivoDigitals = read.get_PermissaoArquivoDigitalRepository().FindByUsuario(usuario.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 84, num, usuario, true);
+ continue;
+ }
+ return permissaoArquivoDigitals;
+ }
+ return new List<PermissaoArquivoDigital>();
+ });
+ return permissaoArquivoDigitals1;
+ }
+
+ public async Task<List<PermissaoArquivoDigital>> SavePermiss(List<PermissaoArquivoDigital> permissao, List<PermissaoArquivoDigital> prev)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<PermissaoArquivoDigital> permissaoArquivoDigitals1 = permissao;
+ List<PermissaoArquivoDigital> permissaoArquivoDigitals2 = prev;
+ List<PermissaoArquivoDigital> permissaoArquivoDigitals3 = await Task.Run<List<PermissaoArquivoDigital>>(() => {
+ List<PermissaoArquivoDigital> permissaoArquivoDigitals;
+ while (num > 0)
+ {
+ permissao = permissaoArquivoDigitals1;
+ prev = permissaoArquivoDigitals2;
+ List<Diferenca> diferencas = new List<Diferenca>();
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ permissao.ForEach((PermissaoArquivoDigital x) => {
+ PermissaoArquivoDigital permissaoArquivoDigital = x;
+ PermissaoArquivoDigital permissaoArquivoDigital1 = prev.FirstOrDefault<PermissaoArquivoDigital>((PermissaoArquivoDigital y) => y.get_Id() == permissaoArquivoDigital.get_Id());
+ if (permissaoArquivoDigital1 != null && permissaoArquivoDigital1.get_Consultar() == permissaoArquivoDigital.get_Consultar() && permissaoArquivoDigital1.get_Excluir() == permissaoArquivoDigital.get_Excluir() && permissaoArquivoDigital1.get_Incluir() == permissaoArquivoDigital.get_Incluir())
+ {
+ return;
+ }
+ if (permissaoArquivoDigital1 != null)
+ {
+ registroLogs.Add(base.CreateLog(permissaoArquivoDigital.get_Usuario().get_Id(), permissaoArquivoDigital.Compare(permissaoArquivoDigital1.GetValorOriginal()), 43, 1));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(permissaoArquivoDigital.get_Usuario().get_Id(), permissaoArquivoDigital.GetValorOriginal(), 43, 0));
+ }
+ permissaoArquivoDigital = (permissaoArquivoDigital.get_Id() == 0 ? commited.get_PermissaoArquivoDigitalRepository().SaveOrUpdate(permissaoArquivoDigital) : commited.get_PermissaoArquivoDigitalRepository().Merge(permissaoArquivoDigital));
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ permissaoArquivoDigitals = permissao;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 258, num, new { permissao = permissao, prev = prev }, true);
+ continue;
+ }
+ return permissaoArquivoDigitals;
+ }
+ return permissaoArquivoDigitals1;
+ });
+ return permissaoArquivoDigitals3;
+ }
+
+ public async Task<PermissaoArquivoDigital> VerificarPermissao(Usuario usuario, TipoArquivoDigital tela)
+ {
+ int num = 3;
+ PermissaoArquivoDigital permissaoArquivoDigital1 = await Task.Run<PermissaoArquivoDigital>(() => {
+ PermissaoArquivoDigital permissaoArquivoDigital;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ permissaoArquivoDigital = read.get_PermissaoArquivoDigitalRepository().FindByPermissao(usuario.get_Id(), tela);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true);
+ continue;
+ }
+ return permissaoArquivoDigital;
+ }
+ return null;
+ });
+ return permissaoArquivoDigital1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs new file mode 100644 index 0000000..061797e --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/PermissaoUsuarioServico.cs @@ -0,0 +1,152 @@ +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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class PermissaoUsuarioServico : BaseServico
+ {
+ public PermissaoUsuarioServico()
+ {
+ }
+
+ public PermissaoUsuario BuscarPermissao(Usuario usuario, TipoTela tela)
+ {
+ PermissaoUsuario permissaoUsuario;
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ permissaoUsuario = read.get_PermissaoUsuarioRepository().FindByPermissao(usuario.get_Id(), tela);
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true);
+ continue;
+ }
+ return permissaoUsuario;
+ }
+ return null;
+ }
+
+ public async Task<List<PermissaoUsuario>> PermissUsuario(Usuario usuario)
+ {
+ int num = 3;
+ List<PermissaoUsuario> permissaoUsuarios1 = await Task.Run<List<PermissaoUsuario>>(() => {
+ List<PermissaoUsuario> permissaoUsuarios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ permissaoUsuarios = read.get_PermissaoUsuarioRepository().FindByUsuario(usuario.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 84, num, usuario, true);
+ continue;
+ }
+ return permissaoUsuarios;
+ }
+ return new List<PermissaoUsuario>();
+ });
+ return permissaoUsuarios1;
+ }
+
+ public async Task<List<PermissaoUsuario>> SavePermiss(List<PermissaoUsuario> permissao, List<PermissaoUsuario> prev)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<PermissaoUsuario> permissaoUsuarios1 = permissao;
+ List<PermissaoUsuario> permissaoUsuarios2 = prev;
+ List<PermissaoUsuario> permissaoUsuarios3 = await Task.Run<List<PermissaoUsuario>>(() => {
+ List<PermissaoUsuario> permissaoUsuarios;
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ while (num > 0)
+ {
+ permissao = permissaoUsuarios1;
+ prev = permissaoUsuarios2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ permissao.ForEach((PermissaoUsuario x) => {
+ PermissaoUsuario permissaoUsuario = x;
+ PermissaoUsuario permissaoUsuario1 = prev.FirstOrDefault<PermissaoUsuario>((PermissaoUsuario y) => y.get_Id() == permissaoUsuario.get_Id());
+ if (permissaoUsuario1 != null && permissaoUsuario1.get_Alterar() == permissaoUsuario.get_Alterar() && permissaoUsuario1.get_Consultar() == permissaoUsuario.get_Consultar() && permissaoUsuario1.get_Excluir() == permissaoUsuario.get_Excluir() && permissaoUsuario1.get_Incluir() == permissaoUsuario.get_Incluir())
+ {
+ return;
+ }
+ if (permissaoUsuario1 != null)
+ {
+ registroLogs.Add(base.CreateLog(permissaoUsuario.get_Usuario().get_Id(), permissaoUsuario.Compare(permissaoUsuario1.GetValorOriginal()), 43, 1));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(permissaoUsuario.get_Usuario().get_Id(), permissaoUsuario.GetValorOriginal(), 43, 0));
+ }
+ permissaoUsuario = (permissaoUsuario.get_Id() == 0 ? commited.get_PermissaoUsuarioRepository().SaveOrUpdate(permissaoUsuario) : commited.get_PermissaoUsuarioRepository().Merge(permissaoUsuario));
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ permissaoUsuarios = permissao;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 258, num, new { permissao = permissao, prev = prev }, true);
+ continue;
+ }
+ return permissaoUsuarios;
+ }
+ return permissaoUsuarios1;
+ });
+ return permissaoUsuarios3;
+ }
+
+ public async Task<PermissaoUsuario> VerificarPermissao(Usuario usuario, TipoTela tela)
+ {
+ int num = 3;
+ PermissaoUsuario permissaoUsuario1 = await Task.Run<PermissaoUsuario>(() => {
+ PermissaoUsuario permissaoUsuario;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ permissaoUsuario = read.get_PermissaoUsuarioRepository().FindByPermissao(usuario.get_Id(), tela);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 85, num, new { usuario = usuario, tela = tela }, true);
+ continue;
+ }
+ return permissaoUsuario;
+ }
+ return null;
+ });
+ return permissaoUsuario1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs b/Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs new file mode 100644 index 0000000..ab7ab6f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ProspeccaoServico.cs @@ -0,0 +1,338 @@ +using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+
+namespace Gestor.Application.Servicos
+{
+ public class ProspeccaoServico : BaseServico
+ {
+ public ProspeccaoServico()
+ {
+ }
+
+ public async Task<Prospeccao> BuscarProspeccao(long id)
+ {
+ int num = 3;
+ Prospeccao prospeccao1 = await Task.Run<Prospeccao>(() => {
+ Prospeccao prospeccao;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ prospeccao = read.get_ProspectRepository().FindById(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 87, num, id, true);
+ continue;
+ }
+ return prospeccao;
+ }
+ return new Prospeccao();
+ });
+ return prospeccao1;
+ }
+
+ internal async Task<List<Prospeccao>> BuscarProspeccoes(long id, DateTime inicio, DateTime fim, StatusProspeccao? status)
+ {
+ int num = 3;
+ List<Prospeccao> prospeccaos1 = await Task.Run<List<Prospeccao>>(() => {
+ List<Prospeccao> prospeccaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ prospeccaos = read.get_ProspectRepository().Find(Recursos.Empresa.get_Id(), id, inicio, fim, status);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 86, num, new { id = id, inicio = inicio, fim = fim, status = status }, true);
+ continue;
+ }
+ return prospeccaos;
+ }
+ return new List<Prospeccao>();
+ });
+ return prospeccaos1;
+ }
+
+ public async Task<List<Prospeccao>> BuscarProspeccoes(Filtros filtro)
+ {
+ int num = 3;
+ List<Prospeccao> prospeccaos1 = await Task.Run<List<Prospeccao>>(() => {
+ List<Prospeccao> prospeccaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ prospeccaos = read.get_ProspectRepository().Find(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 88, num, filtro, true);
+ continue;
+ }
+ return prospeccaos;
+ }
+ return new List<Prospeccao>();
+ });
+ return prospeccaos1;
+ }
+
+ public async Task<List<Prospeccao>> BuscarProspeccoesPorStatus(StatusDeProspeccao statusProspeccao)
+ {
+ int num = 3;
+ List<Prospeccao> prospeccaos1 = await Task.Run<List<Prospeccao>>(() => {
+ List<Prospeccao> prospeccaos;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ prospeccaos = read.get_ProspectRepository().FindByStatusPersonalizado(statusProspeccao.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 310, num, new { statusProspeccao = statusProspeccao }, true);
+ continue;
+ }
+ return prospeccaos;
+ }
+ return new List<Prospeccao>();
+ });
+ return prospeccaos1;
+ }
+
+ public async Task<bool> Delete(Prospeccao prospeccao)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ string str1;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ if (prospeccao.get_Tarefa() != null)
+ {
+ commited.get_TarefaRepository().Excluir(prospeccao.get_Tarefa().get_Id());
+ }
+ commited.get_ProspectRepository().Delete(prospeccao.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ if (prospeccao.get_Tarefa() != null)
+ {
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Tarefa tarefa = prospeccao.get_Tarefa();
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting));
+ registroLog.set_EntidadeId(prospeccao.get_Tarefa().get_Id());
+ registroLog.set_Tela(38);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_22 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_2;
+ if (u003cu003e9_22 == null)
+ {
+ u003cu003e9_22 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ProspeccaoServico.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_22);
+ if (pAddress != null)
+ {
+ str1 = pAddress.ToString();
+ }
+ else
+ {
+ str1 = null;
+ }
+ registroLog.set_Ip(str1);
+ base.SaveLog(registroLog, commited);
+ }
+ RegistroLog registroLog1 = new RegistroLog();
+ registroLog1.set_Acao(2);
+ registroLog1.set_Usuario(Recursos.Usuario);
+ registroLog1.set_DataHora(networkTime);
+ Prospeccao prospeccao1 = prospeccao;
+ JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings();
+ jsonSerializerSetting1.set_ReferenceLoopHandling(1);
+ registroLog1.set_Descricao(JsonConvert.SerializeObject(prospeccao1, jsonSerializerSetting1));
+ registroLog1.set_EntidadeId(prospeccao.get_Id());
+ registroLog1.set_Tela(33);
+ registroLog1.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog1.set_NomeMaquina(Environment.MachineName);
+ registroLog1.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] pAddressArray = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_23 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_3;
+ if (u003cu003e9_23 == null)
+ {
+ u003cu003e9_23 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ProspeccaoServico.u003cu003ec.u003cu003e9__2_3 = u003cu003e9_23;
+ }
+ IPAddress pAddress1 = ((IEnumerable<IPAddress>)pAddressArray).FirstOrDefault<IPAddress>(u003cu003e9_23);
+ if (pAddress1 != null)
+ {
+ str = pAddress1.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Ip(str);
+ base.SaveLog(registroLog1, commited);
+ commited.Commit();
+ }
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_21 = ProspeccaoServico.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ ProspeccaoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ dispatcher.Invoke(u003cu003e9_21);
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 260, num, prospeccao, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<Prospeccao> Salvar(Prospeccao prospecao)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Prospeccao prospeccao2 = prospecao;
+ Prospeccao prospeccao3 = await Task.Run<Prospeccao>(() => {
+ Prospeccao prospeccao;
+ string str;
+ while (num > 0)
+ {
+ prospecao = prospeccao2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ TipoAcao tipoAcao = (prospecao.get_Id() == 0 ? 0 : 1);
+ prospecao.set_IdEmpresa(Recursos.Usuario.get_IdEmpresa());
+ if (!prospecao.get_DataCriacao().HasValue)
+ {
+ prospecao.set_DataCriacao(new DateTime?(networkTime));
+ }
+ if (prospecao.get_UsuarioCriacao() == 0)
+ {
+ prospecao.set_UsuarioCriacao(Recursos.Usuario.get_Id());
+ }
+ Tarefa tarefa = prospecao.get_Tarefa();
+ tarefa = (!prospecao.get_CriarTarefa() ? null : (tarefa.get_Id() == 0 ? commited.get_TarefaRepository().Salvar(tarefa) : commited.get_TarefaRepository().Atualizar(tarefa)));
+ prospecao.set_Tarefa(tarefa);
+ prospecao = (prospecao.get_Id() == 0 ? commited.get_ProspectRepository().SaveOrUpdate(prospecao) : commited.get_ProspectRepository().Merge(prospecao));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ if (prospecao.get_Tarefa() != null)
+ {
+ prospecao.get_Tarefa().set_IdEntidade(prospecao.get_Id());
+ prospecao.set_Tarefa(commited.get_TarefaRepository().Atualizar(prospecao.get_Tarefa()));
+ }
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Prospeccao prospeccao1 = prospecao;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(prospeccao1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(prospecao.get_Id());
+ registroLog.set_Tela(33);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_12 = ProspeccaoServico.u003cu003ec.u003cu003e9__1_2;
+ if (u003cu003e9_12 == null)
+ {
+ u003cu003e9_12 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ ProspeccaoServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_12);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_11 = ProspeccaoServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ ProspeccaoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ dispatcher.Invoke(u003cu003e9_11);
+ prospeccao = prospecao;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 259, num, prospecao, true);
+ continue;
+ }
+ return prospeccao;
+ }
+ return prospeccao2;
+ });
+ return prospeccao3;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs new file mode 100644 index 0000000..c9cbe35 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/RestricaoUsuarioServico.cs @@ -0,0 +1,221 @@ +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.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class RestricaoUsuarioServico : BaseServico
+ {
+ public RestricaoUsuarioServico()
+ {
+ }
+
+ public RestricaoUsuario BuscarRestricao(Usuario usuario, TipoRestricao restricao)
+ {
+ RestricaoUsuario restricaoUsuario;
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ restricaoUsuario = read.get_RestricaoUsuarioRepository().FindRestricao(usuario.get_Id(), restricao);
+ }
+ }
+ catch (Exception exception1)
+ {
+ Exception exception = exception1;
+ num = base.Registrar(exception, 89, num, new { usuario = usuario, restricao = restricao }, true);
+ continue;
+ }
+ return restricaoUsuario;
+ }
+ return null;
+ }
+
+ public async Task<List<RestricaoUsuario>> BuscarRestricoes(long id)
+ {
+ int num = 3;
+ List<RestricaoUsuario> restricaoUsuarios1 = await Task.Run<List<RestricaoUsuario>>(() => {
+ List<RestricaoUsuario> restricaoUsuarios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ restricaoUsuarios = read.get_RestricaoUsuarioRepository().FindByUsuario(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 90, num, id, true);
+ continue;
+ }
+ return restricaoUsuarios;
+ }
+ return new List<RestricaoUsuario>();
+ });
+ return restricaoUsuarios1;
+ }
+
+ public async Task<List<RestricaoUsuarioCamposRelatorios>> BuscarRestricoesCamposRelatorios(long id)
+ {
+ int num = 3;
+ List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios1 = await Task.Run<List<RestricaoUsuarioCamposRelatorios>>(() => {
+ List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ restricaoUsuarioCamposRelatorios = read.get_RestricaoUsuarioCamposRelatoriosRepository().FindByUsuario(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 90, num, id, true);
+ continue;
+ }
+ return restricaoUsuarioCamposRelatorios;
+ }
+ return new List<RestricaoUsuarioCamposRelatorios>();
+ });
+ return restricaoUsuarioCamposRelatorios1;
+ }
+
+ public async Task<List<RestricaoUsuario>> SaveRestri(List<RestricaoUsuario> restricoes, List<RestricaoUsuario> prev)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<RestricaoUsuario> restricaoUsuarios1 = restricoes;
+ List<RestricaoUsuario> restricaoUsuarios2 = prev;
+ List<RestricaoUsuario> restricaoUsuarios3 = await Task.Run<List<RestricaoUsuario>>(() => {
+ List<RestricaoUsuario> restricaoUsuarios;
+ while (num > 0)
+ {
+ List<Diferenca> diferencas = new List<Diferenca>();
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ restricoes = restricaoUsuarios1;
+ prev = restricaoUsuarios2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ restricoes.ForEach((RestricaoUsuario x) => {
+ RestricaoUsuario restricaoUsuario = x;
+ RestricaoUsuario restricaoUsuario1 = prev.FirstOrDefault<RestricaoUsuario>((RestricaoUsuario y) => {
+ if (restricaoUsuario.get_Id() != 0)
+ {
+ return y.get_Id() == restricaoUsuario.get_Id();
+ }
+ return y.get_Tipo() == restricaoUsuario.get_Tipo();
+ });
+ if (restricaoUsuario1 != null && restricaoUsuario1.get_Restricao() == restricaoUsuario.get_Restricao())
+ {
+ return;
+ }
+ if (restricaoUsuario1 != null)
+ {
+ registroLogs.Add(base.CreateLog(restricaoUsuario.get_Usuario().get_Id(), restricaoUsuario.Compare(restricaoUsuario1.GetValorOriginal()), 43, 1));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(restricaoUsuario.get_Usuario().get_Id(), restricaoUsuario.GetValorOriginal(), 43, 0));
+ }
+ restricaoUsuario = (restricaoUsuario.get_Id() == 0 ? commited.get_RestricaoUsuarioRepository().SaveOrUpdate(restricaoUsuario) : commited.get_RestricaoUsuarioRepository().Merge(restricaoUsuario));
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ restricaoUsuarios = restricoes;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 261, num, new { restricoes = restricoes, prev = prev }, true);
+ continue;
+ }
+ return restricaoUsuarios;
+ }
+ return restricaoUsuarios1;
+ });
+ return restricaoUsuarios3;
+ }
+
+ public async Task<List<RestricaoUsuarioCamposRelatorios>> SaveRestriCamposRelatorios(List<RestricaoUsuarioCamposRelatorios> restricoes, List<RestricaoUsuarioCamposRelatorios> prev)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios1 = restricoes;
+ List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios2 = prev;
+ List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios3 = await Task.Run<List<RestricaoUsuarioCamposRelatorios>>(() => {
+ List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios;
+ while (num > 0)
+ {
+ List<Diferenca> diferencas = new List<Diferenca>();
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ restricoes = restricaoUsuarioCamposRelatorios1;
+ prev = restricaoUsuarioCamposRelatorios2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ restricoes.ForEach((RestricaoUsuarioCamposRelatorios x) => {
+ RestricaoUsuarioCamposRelatorios restricaoUsuarioCamposRelatorio = x;
+ RestricaoUsuarioCamposRelatorios restricaoUsuarioCamposRelatorio1 = prev.FirstOrDefault<RestricaoUsuarioCamposRelatorios>((RestricaoUsuarioCamposRelatorios y) => {
+ if (y.get_Id() != 0)
+ {
+ return y.get_Id() == restricaoUsuarioCamposRelatorio.get_Id();
+ }
+ if (y.get_Campo() != restricaoUsuarioCamposRelatorio.get_Campo())
+ {
+ return false;
+ }
+ return y.get_Relatorio() == restricaoUsuarioCamposRelatorio.get_Relatorio();
+ });
+ if (restricaoUsuarioCamposRelatorio1 != null && restricaoUsuarioCamposRelatorio1.get_Restricao() == restricaoUsuarioCamposRelatorio.get_Restricao())
+ {
+ return;
+ }
+ if (restricaoUsuarioCamposRelatorio1 != null)
+ {
+ registroLogs.Add(base.CreateLog(restricaoUsuarioCamposRelatorio.get_Usuario().get_Id(), restricaoUsuarioCamposRelatorio.Compare(restricaoUsuarioCamposRelatorio1.GetValorOriginal()), 43, 1));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(restricaoUsuarioCamposRelatorio.get_Usuario().get_Id(), restricaoUsuarioCamposRelatorio.GetValorOriginal(), 43, 0));
+ }
+ restricaoUsuarioCamposRelatorio = (restricaoUsuarioCamposRelatorio.get_Id() == 0 ? commited.get_RestricaoUsuarioCamposRelatoriosRepository().SaveOrUpdate(restricaoUsuarioCamposRelatorio) : commited.get_RestricaoUsuarioCamposRelatoriosRepository().Merge(restricaoUsuarioCamposRelatorio));
+ });
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ restricaoUsuarioCamposRelatorios = restricoes;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 261, num, new { restricoes = restricoes, prev = prev }, true);
+ continue;
+ }
+ return restricaoUsuarioCamposRelatorios;
+ }
+ return restricaoUsuarioCamposRelatorios1;
+ });
+ return restricaoUsuarioCamposRelatorios3;
+ }
+ }
+}
\ No newline at end of file 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 diff --git a/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs b/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs new file mode 100644 index 0000000..a2742e4 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs @@ -0,0 +1,335 @@ +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.Common;
+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.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ internal class ServicoExtrato : BaseServico
+ {
+ public ServicoExtrato()
+ {
+ }
+
+ internal async Task<ObservableCollection<DetalheExtrato>> BuscarDetalhes(long id)
+ {
+ int num = 3;
+ ObservableCollection<DetalheExtrato> observableCollection1 = await Task.Run<ObservableCollection<DetalheExtrato>>(() => {
+ ObservableCollection<DetalheExtrato> observableCollection;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<DetalheExtrato> detalheExtratos = read.get_DetalheExtratoRepository().Find(id);
+ Func<DetalheExtrato, string> u003cu003e9_01 = ServicoExtrato.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (DetalheExtrato x) => x.get_Cliente();
+ ServicoExtrato.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IOrderedEnumerable<DetalheExtrato> detalheExtratos1 = detalheExtratos.OrderBy<DetalheExtrato, string>(u003cu003e9_01);
+ Func<DetalheExtrato, string> u003cu003e9_02 = ServicoExtrato.u003cu003ec.u003cu003e9__0_2;
+ if (u003cu003e9_02 == null)
+ {
+ u003cu003e9_02 = (DetalheExtrato x) => x.get_Apolice();
+ ServicoExtrato.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02;
+ }
+ IOrderedEnumerable<DetalheExtrato> detalheExtratos2 = detalheExtratos1.ThenBy<DetalheExtrato, string>(u003cu003e9_02);
+ Func<DetalheExtrato, string> u003cu003e9_03 = ServicoExtrato.u003cu003ec.u003cu003e9__0_3;
+ if (u003cu003e9_03 == null)
+ {
+ u003cu003e9_03 = (DetalheExtrato x) => x.get_Endosso();
+ ServicoExtrato.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03;
+ }
+ IOrderedEnumerable<DetalheExtrato> detalheExtratos3 = detalheExtratos2.ThenBy<DetalheExtrato, string>(u003cu003e9_03);
+ Func<DetalheExtrato, string> u003cu003e9_04 = ServicoExtrato.u003cu003ec.u003cu003e9__0_4;
+ if (u003cu003e9_04 == null)
+ {
+ u003cu003e9_04 = (DetalheExtrato x) => x.get_NumeroParcela();
+ ServicoExtrato.u003cu003ec.u003cu003e9__0_4 = u003cu003e9_04;
+ }
+ observableCollection = new ObservableCollection<DetalheExtrato>(detalheExtratos3.ThenBy<DetalheExtrato, string>(u003cu003e9_04));
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 91, num, id, true);
+ continue;
+ }
+ return observableCollection;
+ }
+ return new ObservableCollection<DetalheExtrato>();
+ });
+ return observableCollection1;
+ }
+
+ public async Task<List<Extrato>> BuscarExtrato(long id, long idusuario, StatusExtrato status, DateTime inicio, DateTime fim)
+ {
+ int num = 3;
+ List<Extrato> extratos2 = await Task.Run<List<Extrato>>(() => {
+ List<Extrato> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Extrato> extratos = read.get_ExtratoRepository().FindBySeguradora(id, idusuario, Recursos.Empresa.get_Id(), inicio, fim, new StatusExtrato?(status));
+ Func<Extrato, string> u003cu003e9_21 = ServicoExtrato.u003cu003ec.u003cu003e9__2_1;
+ if (u003cu003e9_21 == null)
+ {
+ u003cu003e9_21 = (Extrato x) => x.get_Numero();
+ ServicoExtrato.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
+ }
+ IOrderedEnumerable<Extrato> extratos1 = extratos.OrderBy<Extrato, string>(u003cu003e9_21);
+ Func<Extrato, DateTime?> u003cu003e9_22 = ServicoExtrato.u003cu003ec.u003cu003e9__2_2;
+ if (u003cu003e9_22 == null)
+ {
+ u003cu003e9_22 = (Extrato x) => x.get_Data();
+ ServicoExtrato.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22;
+ }
+ list = extratos1.ThenByDescending<Extrato, DateTime?>(u003cu003e9_22).ToList<Extrato>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 92, num, new { id = id, status = status, inicio = inicio, fim = fim }, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Extrato>();
+ });
+ return extratos2;
+ }
+
+ public async Task<List<Extrato>> BuscarExtratoPorData(Filtros filtros)
+ {
+ int num = 3;
+ List<Extrato> extratos1 = await Task.Run<List<Extrato>>(() => {
+ List<Extrato> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ List<Extrato> extratos = read.get_ExtratoRepository().FindByData(filtros);
+ Func<Extrato, DateTime?> u003cu003e9_31 = ServicoExtrato.u003cu003ec.u003cu003e9__3_1;
+ if (u003cu003e9_31 == null)
+ {
+ u003cu003e9_31 = (Extrato x) => x.get_Data();
+ ServicoExtrato.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31;
+ }
+ list = extratos.OrderBy<Extrato, DateTime?>(u003cu003e9_31).ToList<Extrato>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 93, num, filtros, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<Extrato>();
+ });
+ return extratos1;
+ }
+
+ internal async Task<string> BuscarNumExtrato(long? id)
+ {
+ string str1;
+ if (id.HasValue)
+ {
+ long? nullable = id;
+ long num = (long)0;
+ if (!(nullable.GetValueOrDefault() <= num & nullable.HasValue))
+ {
+ string str2 = "";
+ int num1 = 3;
+ str1 = await Task.Run<string>(() => {
+ string str;
+ while (num1 > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ DetalheExtrato detalheExtrato = read.get_DetalheExtratoRepository().FindByLongId(id).FirstOrDefault<DetalheExtrato>();
+ str2 = (detalheExtrato == null || detalheExtrato.get_Id() <= (long)0 ? "" : detalheExtrato.get_Extrato().get_Numero());
+ str = str2;
+ }
+ }
+ catch (Exception exception)
+ {
+ num1 = base.Registrar(exception, 91, num1, id, true);
+ continue;
+ }
+ return str;
+ }
+ return "";
+ });
+ return str1;
+ }
+ }
+ str1 = "";
+ return str1;
+ }
+
+ public async Task<bool> Delete(Extrato extrato)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_ExtratoRepository().Delete(extrato.get_Id());
+ registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.GetValorOriginal(), 1, 2));
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 264, num, extrato, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<DetalheExtrato> FindByParcelaId(long id)
+ {
+ int num = 3;
+ DetalheExtrato detalheExtrato1 = await Task.Run<DetalheExtrato>(() => {
+ DetalheExtrato detalheExtrato;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ detalheExtrato = read.get_DetalheExtratoRepository().FindByParcelaId(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 74, num, id, true);
+ continue;
+ }
+ return detalheExtrato;
+ }
+ return new DetalheExtrato();
+ });
+ return detalheExtrato1;
+ }
+
+ public async Task<DetalheExtrato> Save(DetalheExtrato detalhe)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DetalheExtrato detalheExtrato1 = detalhe;
+ DetalheExtrato detalheExtrato2 = await Task.Run<DetalheExtrato>(() => {
+ DetalheExtrato detalheExtrato;
+ while (num > 0)
+ {
+ detalhe = detalheExtrato1;
+ try
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (detalhe.get_Id() == 0 ? 0 : 1);
+ commited.get_DetalheExtratoRepository().Merge(detalhe);
+ if (tipoAcao != 1)
+ {
+ registroLogs.Add(base.CreateLog(detalhe.get_Id(), detalhe.Compare(detalheExtrato1.GetValorOriginal()), 23, tipoAcao));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(detalhe.get_Id(), detalhe.GetValorOriginal(), 23, tipoAcao));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ detalheExtrato = detalhe;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 262, num, detalhe, true);
+ continue;
+ }
+ return detalheExtrato;
+ }
+ return detalheExtrato1;
+ });
+ return detalheExtrato2;
+ }
+
+ public async Task<Extrato> Save(Extrato extrato)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Extrato extrato1 = extrato;
+ Extrato extrato2 = await Task.Run<Extrato>(() => {
+ Extrato extrato3;
+ while (num > 0)
+ {
+ extrato = extrato1;
+ try
+ {
+ List<RegistroLog> registroLogs = new List<RegistroLog>();
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (extrato.get_Id() == 0 ? 0 : 1);
+ commited.get_ExtratoRepository().Merge(extrato);
+ if (tipoAcao != 1)
+ {
+ registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.Compare(extrato1.GetValorOriginal()), 23, tipoAcao));
+ }
+ else
+ {
+ registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.GetValorOriginal(), 23, tipoAcao));
+ }
+ base.SaveLog(registroLogs, commited);
+ commited.Commit();
+ }
+ extrato3 = extrato;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 263, num, extrato, true);
+ continue;
+ }
+ return extrato3;
+ }
+ return extrato1;
+ });
+ return extrato2;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/TarefaServico.cs b/Codemerx/Gestor.Application/Servicos/TarefaServico.cs new file mode 100644 index 0000000..792aea6 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/TarefaServico.cs @@ -0,0 +1,795 @@ +using Gestor.Application.Actions;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+
+namespace Gestor.Application.Servicos
+{
+ public class TarefaServico : BaseServico
+ {
+ public TarefaServico()
+ {
+ }
+
+ public async Task<int[]> AtualizarNotasTarefas()
+ {
+ int num = 3;
+ int[] numArray1 = await Task.Run<int[]>(() => {
+ int[] numArray;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ numArray = read.get_TarefaRepository().ContarTarefas(Recursos.Usuario.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 100, num, Recursos.Usuario.get_Id(), true);
+ continue;
+ }
+ return numArray;
+ }
+ return new int[1];
+ });
+ return numArray1;
+ }
+
+ public async Task<List<Fase>> BuscarFases(long id)
+ {
+ int num = 3;
+ List<Fase> fases1 = await Task.Run<List<Fase>>(() => {
+ List<Fase> fases;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ fases = read.get_TarefaRepository().BuscarFases(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 102, num, id, true);
+ continue;
+ }
+ return fases;
+ }
+ return new List<Fase>();
+ });
+ return fases1;
+ }
+
+ public async Task<List<Tarefa>> BuscarNotas(long id)
+ {
+ 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().BuscarTarefaPorUsuario(id, 1);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 98, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarNotasConcluidas(long id)
+ {
+ 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().BuscarTarefaConcluidaPorUsuario(id, 1);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 99, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<Tarefa> BuscarTarefa(long id)
+ {
+ int num = 3;
+ Tarefa tarefa1 = await Task.Run<Tarefa>(() => {
+ Tarefa tarefa;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefa = read.get_TarefaRepository().BuscarTarefa(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 105, num, id, true);
+ continue;
+ }
+ return tarefa;
+ }
+ return new Tarefa();
+ });
+ return tarefa1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(TipoTarefa entidade, long id, bool? concluido)
+ {
+ 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().BuscarTarefa(entidade, id, concluido);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 94, num, new { entidade = entidade, id = id, concluido = concluido }, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(long id, DateTime inicio, DateTime fim, bool? concluido)
+ {
+ 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().BuscarTarefaPorUsuario(id, inicio, fim, concluido);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 95, num, new { id = id, inicio = inicio, fim = fim, concluido = concluido }, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefas(long id)
+ {
+ 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().BuscarTarefaPorTrilha(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 101, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefasCliente(long id)
+ {
+ 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().BuscarTarefaPorCliente(id);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 96, num, id, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Tarefa>> BuscarTarefasPorTipo(TipoDeTarefa tipoTarefa)
+ {
+ 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().BuscarTarefasPorTipo(tipoTarefa.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 309, num, new { tipoTarefa = tipoTarefa }, true);
+ continue;
+ }
+ return tarefas;
+ }
+ return new List<Tarefa>();
+ });
+ return tarefas1;
+ }
+
+ public async Task<List<Trilha>> BuscarTrilhas()
+ {
+ int num = 3;
+ List<Trilha> trilhas1 = await Task.Run<List<Trilha>>(() => {
+ List<Trilha> trilhas;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ trilhas = read.get_TarefaRepository().BuscarTrilhas(true);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 104, num, null, true);
+ continue;
+ }
+ return trilhas;
+ }
+ return new List<Trilha>();
+ });
+ return trilhas1;
+ }
+
+ private static void CleanWebEditor(Tarefa tarefa)
+ {
+ if (tarefa.get_Descricao() != null)
+ {
+ tarefa.set_Descricao(TarefaServico.RemoveXml(tarefa.get_Descricao()));
+ }
+ if (tarefa.get_DescricaoInterna() != null)
+ {
+ tarefa.set_DescricaoInterna(TarefaServico.RemoveXml(tarefa.get_DescricaoInterna()));
+ }
+ }
+
+ public async Task<bool> Excluir(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_TarefaRepository().Excluir(id);
+ commited.Commit();
+ }
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_51 = TarefaServico.u003cu003ec.u003cu003e9__5_1;
+ if (u003cu003e9_51 == null)
+ {
+ u003cu003e9_51 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51;
+ }
+ dispatcher.Invoke(u003cu003e9_51);
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 268, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> ExcluirTarefasDocumento(long id)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ List<Tarefa> tarefas = new List<Tarefa>();
+ using (UnitOfWork read = Instancia.Read)
+ {
+ tarefas = read.get_TarefaRepository().BuscarTarefa(0, id, new bool?(false));
+ }
+ foreach (Tarefa tarefa in tarefas)
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_TarefaRepository().Excluir(tarefa.get_Id());
+ commited.Commit();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(DateTime.Now);
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa, jsonSerializerSetting));
+ registroLog.set_EntidadeId(tarefa.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_192 = TarefaServico.u003cu003ec.u003cu003e9__19_2;
+ if (u003cu003e9_192 == null)
+ {
+ u003cu003e9_192 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__19_2 = u003cu003e9_192;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_192);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ }
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_191 = TarefaServico.u003cu003ec.u003cu003e9__19_1;
+ if (u003cu003e9_191 == null)
+ {
+ u003cu003e9_191 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__19_1 = u003cu003e9_191;
+ }
+ dispatcher.Invoke(u003cu003e9_191);
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 268, num, id, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public static string RemoveXml(string description)
+ {
+ try
+ {
+ List<string> strs = new List<string>();
+ string[] strArrays = description.Split(new char[] { '<' });
+ for (int i = 0; i < (int)strArrays.Length; i++)
+ {
+ string str = strArrays[i];
+ if (str.Contains("?xml") || str.Contains("o:p"))
+ {
+ strs.Add(string.Concat("<", str));
+ }
+ }
+ foreach (string str1 in strs)
+ {
+ description = description.Replace(str1, "");
+ }
+ }
+ catch (Exception exception)
+ {
+ throw exception;
+ }
+ return description;
+ }
+
+ public async Task<Tarefa> Salvar(Tarefa tarefa)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Tarefa tarefa2 = tarefa;
+ Tarefa tarefa3 = await Task.Run<Tarefa>(() => {
+ Tarefa tarefa4;
+ string str;
+ while (num > 0)
+ {
+ tarefa = tarefa2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TarefaServico.CleanWebEditor(tarefa);
+ if (tarefa.get_Entidade() == 1)
+ {
+ tarefa.set_Descricao((!string.IsNullOrWhiteSpace(tarefa.get_Anotacoes()) ? tarefa.get_Anotacoes() : tarefa.get_Descricao()));
+ }
+ tarefa = (tarefa.get_Id() == (long)0 ? commited.get_TarefaRepository().Salvar(tarefa) : commited.get_TarefaRepository().Atualizar(tarefa));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Tarefa tarefa1 = tarefa;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(tarefa1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(tarefa.get_Id());
+ registroLog.set_Tela(38);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_12 = TarefaServico.u003cu003ec.u003cu003e9__1_2;
+ if (u003cu003e9_12 == null)
+ {
+ u003cu003e9_12 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__1_2 = u003cu003e9_12;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_12);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_11 = TarefaServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ dispatcher.Invoke(u003cu003e9_11);
+ tarefa4 = tarefa;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 265, num, tarefa, true);
+ continue;
+ }
+ return tarefa4;
+ }
+ return tarefa2;
+ });
+ return tarefa3;
+ }
+
+ public async Task<Trilha> Salvar(Trilha trilha)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ Trilha trilha2 = trilha;
+ Trilha trilha3 = await Task.Run<Trilha>(() => {
+ Trilha trilha4;
+ string str;
+ while (num > 0)
+ {
+ trilha = trilha2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ trilha = (trilha.get_Id() == (long)0 ? commited.get_TarefaRepository().Salvar(trilha) : commited.get_TarefaRepository().Atualizar(trilha));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(1);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ Trilha trilha1 = trilha;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(trilha1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(trilha.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_42 = TarefaServico.u003cu003ec.u003cu003e9__4_2;
+ if (u003cu003e9_42 == null)
+ {
+ u003cu003e9_42 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__4_2 = u003cu003e9_42;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_42);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_41 = TarefaServico.u003cu003ec.u003cu003e9__4_1;
+ if (u003cu003e9_41 == null)
+ {
+ u003cu003e9_41 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41;
+ }
+ dispatcher.Invoke(u003cu003e9_41);
+ trilha4 = trilha;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 267, num, trilha, true);
+ continue;
+ }
+ return trilha4;
+ }
+ return trilha2;
+ });
+ return trilha3;
+ }
+
+ public async Task<List<Fase>> Salvar(List<Fase> fases)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<Fase> fases1 = fases;
+ List<Fase> fases2 = await Task.Run<List<Fase>>(() => {
+ List<Fase> fases3;
+ string str;
+ while (num > 0)
+ {
+ fases = fases1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ fases = commited.get_TarefaRepository().Salvar(fases);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (Fase fase in fases)
+ {
+ 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(fase, jsonSerializerSetting));
+ registroLog.set_EntidadeId(fase.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_142 = TarefaServico.u003cu003ec.u003cu003e9__14_2;
+ if (u003cu003e9_142 == null)
+ {
+ u003cu003e9_142 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__14_2 = u003cu003e9_142;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_142);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_141 = TarefaServico.u003cu003ec.u003cu003e9__14_1;
+ if (u003cu003e9_141 == null)
+ {
+ u003cu003e9_141 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__14_1 = u003cu003e9_141;
+ }
+ dispatcher.Invoke(u003cu003e9_141);
+ fases3 = fases;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 269, num, fases, true);
+ continue;
+ }
+ return fases3;
+ }
+ return fases1;
+ });
+ return fases2;
+ }
+
+ public async Task<List<Tarefa>> Salvar(List<Tarefa> tarefas)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<Tarefa> tarefas1 = tarefas;
+ List<Tarefa> tarefas2 = await Task.Run<List<Tarefa>>(() => {
+ List<Tarefa> tarefas3;
+ string str;
+ while (num > 0)
+ {
+ tarefas = tarefas1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ tarefas = commited.get_TarefaRepository().Salvar(tarefas);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (Tarefa tarefa in tarefas)
+ {
+ 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(tarefa, jsonSerializerSetting));
+ registroLog.set_EntidadeId(tarefa.get_Id());
+ registroLog.set_Tela(4);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_152 = TarefaServico.u003cu003ec.u003cu003e9__15_2;
+ if (u003cu003e9_152 == null)
+ {
+ u003cu003e9_152 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ TarefaServico.u003cu003ec.u003cu003e9__15_2 = u003cu003e9_152;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_152);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ }
+ commited.Commit();
+ Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
+ Action u003cu003e9_151 = TarefaServico.u003cu003ec.u003cu003e9__15_1;
+ if (u003cu003e9_151 == null)
+ {
+ u003cu003e9_151 = () => Gestor.Application.Actions.Actions.AtualizaBadges();
+ TarefaServico.u003cu003ec.u003cu003e9__15_1 = u003cu003e9_151;
+ }
+ dispatcher.Invoke(u003cu003e9_151);
+ tarefas3 = tarefas;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 265, num, tarefas, true);
+ continue;
+ }
+ return tarefas3;
+ }
+ return tarefas1;
+ });
+ return tarefas2;
+ }
+
+ public async Task<List<long>> Validar(List<long> ids, long trilhaId)
+ {
+ int num = 3;
+ List<long> nums1 = await Task.Run<List<long>>(() => {
+ List<long> nums;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ nums = commited.get_TarefaRepository().Validar(ids, trilhaId);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 266, num, new { ids = ids, trilhaId = trilhaId }, true);
+ continue;
+ }
+ return nums;
+ }
+ return null;
+ });
+ return nums1;
+ }
+ }
+}
\ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs new file mode 100644 index 0000000..4804dac --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/VendedorUsuarioServico.cs @@ -0,0 +1,160 @@ +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.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos
+{
+ public class VendedorUsuarioServico : BaseServico
+ {
+ public VendedorUsuarioServico()
+ {
+ }
+
+ public async Task<bool> Delete(List<VendedorUsuario> vinculo)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ vinculo.ForEach((VendedorUsuario x) => commited.get_VendedorUsuarioRepository().Delete(x.get_Id()));
+ commited.Commit();
+ }
+ flag = true;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 272, num, vinculo, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<List<VendedorUsuario>> FindByVinculo(Usuario usuario)
+ {
+ int num = 3;
+ List<VendedorUsuario> vendedorUsuarios = await Task.Run<List<VendedorUsuario>>(() => {
+ List<VendedorUsuario> list;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ list = read.get_VendedorUsuarioRepository().FindByVinculo(usuario.get_Id()).ToList<VendedorUsuario>();
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 106, num, usuario, true);
+ continue;
+ }
+ return list;
+ }
+ return new List<VendedorUsuario>();
+ });
+ return vendedorUsuarios;
+ }
+
+ public async Task<bool> FindVinculo(Vendedor vendedor)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_VendedorUsuarioRepository().Exist(vendedor.get_Id());
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 271, num, vendedor, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<bool> FindVinculoByUsuario(long idusuario)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ flag = read.get_VendedorUsuarioRepository().ExistVinculoUsuario(idusuario);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 106, num, null, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<List<VendedorUsuario>> SaveOrUpdate(List<VendedorUsuario> vinculo)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ List<VendedorUsuario> vendedorUsuarios1 = vinculo;
+ List<VendedorUsuario> vendedorUsuarios2 = await Task.Run<List<VendedorUsuario>>(() => {
+ List<VendedorUsuario> vendedorUsuarios;
+ while (num > 0)
+ {
+ vinculo = vendedorUsuarios1;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ vinculo.ForEach((VendedorUsuario x) => commited.get_VendedorUsuarioRepository().SaveOrUpdate(x));
+ commited.Commit();
+ }
+ vendedorUsuarios = vinculo;
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 271, num, vinculo, true);
+ continue;
+ }
+ return vendedorUsuarios;
+ }
+ return vendedorUsuarios1;
+ });
+ return vendedorUsuarios2;
+ }
+ }
+}
\ No newline at end of file |