From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Servicos/Seguros/ApoliceServico.cs | 1848 -------------------- 1 file changed, 1848 deletions(-) delete mode 100644 Gestor.Application/Servicos/Seguros/ApoliceServico.cs (limited to 'Gestor.Application/Servicos/Seguros/ApoliceServico.cs') diff --git a/Gestor.Application/Servicos/Seguros/ApoliceServico.cs b/Gestor.Application/Servicos/Seguros/ApoliceServico.cs deleted file mode 100644 index 0aae6a5..0000000 --- a/Gestor.Application/Servicos/Seguros/ApoliceServico.cs +++ /dev/null @@ -1,1848 +0,0 @@ -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 AtualizarNumero(long id, string numero, string endosso, int tipoDocumento) - { - bool flag2 = await Task.Run(() => { - 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> Auditoria(Filtros filtro) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - public async Task BaixarParcelasCancelamento(Documento documento, bool estorno) - { - int num1 = 3; - base.Sucesso = true; - DateTime networkTime = Funcoes.GetNetworkTime(); - bool flag1 = await Task.Run(() => { - bool flag; - string str1; - Action action3 = null; - Action action4 = null; - while (num1 > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()).ToList().ForEach((Parcela x) => { - Action action; - List vendedorParcelas = commited.get_VendedorParcelaRepository().FindByParcela(x.get_Id()); - if (vendedorParcelas.Count > 0) - { - if (!estorno) - { - List vendedorParcelas1 = vendedorParcelas; - Func 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 list = vendedorParcelas1.Where(u003cu003e9_302).ToList(); - Action u003cu003e9_3 = action4; - if (u003cu003e9_3 == null) - { - Action 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 vendedorParcelas2 = vendedorParcelas; - Func 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 vendedorParcelas3 = vendedorParcelas2.Where(u003cu003e9_304); - Func 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 adiantamentos = vendedorParcelas3.GroupBy(u003cu003e9_305).Select, Adiantamento>((IGrouping v) => { - Adiantamento adiantamento = new Adiantamento(); - adiantamento.set_Vendedor(v.First().get_Vendedor()); - adiantamento.set_Data(new DateTime?(networkTime)); - IGrouping nums = v; - Func 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(u003cu003e9_309).Sum((VendedorParcela s) => { - decimal? nullable; - decimal? nullable1; - decimal? valorRepasse = s.get_ValorRepasse(); - decimal value = valorRepasse.Value; - decimal num = 1; - valorRepasse = v.First().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(); - commited.get_AdiantamentoRepository().AddRange(adiantamentos); - List vendedorParcelas4 = vendedorParcelas; - Func 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 list1 = vendedorParcelas4.Where(u003cu003e9_307).ToList(); - Action u003cu003e9_8 = action3; - if (u003cu003e9_8 == null) - { - Action 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 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)addressList).FirstOrDefault(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> BuscarApolice(string pesquisa, FiltroStatusDocumento status, List vendedorVinculado, string campo = "Apolice", bool tipobusca = false) - { - int num1 = 3; - List documentos1 = await Task.Run>(() => { - List documentos; - long num; - while (num1 > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - IDocumentoRepository documentoRepository = read.get_DocumentoRepository(); - string str = pesquisa; - FiltroStatusDocumento filtroStatusDocumento = status; - List vendedorUsuarios = vendedorVinculado; - string str1 = campo; - num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); - List configuracoes = Recursos.Configuracoes; - Func 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(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(); - }); - return documentos1; - } - - public async Task BuscarApoliceAsync(long id, bool itens = false, bool sinistrosPorControle = false) - { - int num = 3; - Documento documento1 = await Task.Run(() => { - 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> BuscarApolices(Filtros filtro, bool buscarAssinatura = false, bool painelBi = false) - { - int num = 3; - List documentos1 = await Task.Run>(async () => { - List 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(); - return documentos; - }); - return documentos1; - } - - internal async Task> BuscarApolicesAsync(long id, FiltroStatusDocumento status = 0, List vendedorVinculado = null) - { - ObservableCollection observableCollection1; - if (!this._carregando) - { - int num1 = 3; - observableCollection1 = await Task.Run>(() => { - ObservableCollection 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 vendedorUsuarios = vendedorVinculado; - List produtos = LicenseHelper.Produtos; - bool flag1 = Recursos.Usuario.get_Id() == (long)0; - List configuracoes = Recursos.Configuracoes; - Func 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(documentoRepository.FindApoliceByCustomer(num, filtroStatusDocumento, vendedorUsuarios, produtos, false, flag1, configuracoes.Any(u003cu003e9_11))); - } - } - catch (Exception exception1) - { - Exception exception = exception1; - List licencas = LicenseHelper.Produtos; - Func 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(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(); - }); - } - else - { - observableCollection1 = new ObservableCollection(); - } - return observableCollection1; - } - - internal async Task> BuscarApolicesComissao(long id, FiltroStatusDocumento status = 0) - { - int num = 3; - ObservableCollection observableCollection1 = await Task.Run>(() => { - ObservableCollection observableCollection; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - observableCollection = new ObservableCollection(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(); - }); - return observableCollection1; - } - - public async Task> BuscarApolicesPendentes(Filtros filtro) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - public async Task> BuscarApolicesPorId(List ids) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - public async Task> BuscarApolicesPorIdParcela(List ids) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - public async Task> BuscarApolicesVigenciaFinal(Filtros filtro, bool somarPremios = false) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - internal async Task BuscarCodDocumento(long pesquisa, List vendedorVinculado) - { - int num = 3; - Documento documento1 = await Task.Run(() => { - 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 BuscarControleAsync(long id) - { - int num = 3; - Controle controle1 = await Task.Run(() => { - 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> BuscarEndossos(Filtros filtro, bool buscarAssinatura = false) - { - int num = 3; - List documentos1 = await Task.Run>(async () => { - List 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(); - return documentos; - }); - return documentos1; - } - - public async Task> BuscarFechamento(Filtros filtro) - { - int num = 3; - List fechamentos1 = await Task.Run>(async () => { - List 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(); - return fechamentos; - }); - return fechamentos1; - } - - public async Task> BuscarLicenciamentos(Filtros filtro) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - public async Task BuscarLogAntigo(long id) - { - int num = 3; - string str1 = await Task.Run(() => { - 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> BuscarPlacas(Filtros filtro) - { - int num = 3; - List documentos1 = await Task.Run>(() => { - List 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(); - }); - return documentos1; - } - - public async Task> BuscarPlanilhaCompleta(List ids, bool configFranquia, bool configPremio) - { - int num = 3; - List planilhaCompletas1 = await Task.Run>(() => { - List 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> BuscarPlanilhaCompletaFatura(List ids, Relatorio relatorio, DateTime inicio, DateTime fim, bool configFranquia, bool configPremio) - { - int num = 3; - List planilhaCompletas1 = await Task.Run>(() => { - List 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> BuscarPlanilhaCompletaProspeccao(List ids) - { - int num = 3; - List planilhaCompletas1 = await Task.Run>(() => { - List 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> BuscarTarefas(Filtros filtro) - { - int num = 3; - List tarefas1 = await Task.Run>(() => { - List 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(); - }); - return tarefas1; - } - - public async Task BuscarVendedorPrincipal(long id) - { - int num = 3; - Vendedor vendedor1 = await Task.Run(() => { - 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 Cotacoes(Filtros filtro) - { - int num1 = 3; - int num2 = await Task.Run(() => { - 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 Excluir(Documento documento) - { - int num = 3; - base.Sucesso = true; - Documento documento2 = documento; - DateTime networkTime = Funcoes.GetNetworkTime(); - Documento documento3 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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 ExcluirCritica(long id) - { - int num = 3; - base.Sucesso = true; - DateTime networkTime = Funcoes.GetNetworkTime(); - bool flag1 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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 ExcluirPagamento(List pagamentos) - { - int num = 3; - base.Sucesso = true; - DateTime networkTime = Funcoes.GetNetworkTime(); - bool flag1 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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 IncluirVendedor(VendedorParcela vendedor) - { - int num = 3; - base.Sucesso = true; - VendedorParcela vendedorParcela1 = vendedor; - DateTime networkTime = Funcoes.GetNetworkTime(); - VendedorParcela vendedorParcela2 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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> IncluirVendedores(List repasses) - { - int num = 3; - base.Sucesso = true; - List vendedorParcelas1 = repasses; - DateTime networkTime = Funcoes.GetNetworkTime(); - List vendedorParcelas2 = await Task.Run>(() => { - List 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 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)addressList).FirstOrDefault(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 Perdido(long id) - { - int num = 3; - base.Sucesso = true; - DateTime networkTime = Funcoes.GetNetworkTime(); - bool flag1 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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 Prorrogar(long id, DateTime vigencia2) - { - int num = 3; - base.Sucesso = true; - DateTime networkTime = Funcoes.GetNetworkTime(); - bool flag1 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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 Reabilitar(long id) - { - int num = 3; - base.Sucesso = true; - DateTime networkTime = Funcoes.GetNetworkTime(); - bool flag1 = await Task.Run(() => { - 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 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)addressList).FirstOrDefault(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 registroLogs = new List(); - List registroLogs1 = new List(); - try - { - using (UnitOfWork commited = Instancia.Commited) - { - List diferencas = new List(); - List diferencas1 = new List(); - List 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 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(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 Save(Documento documento, bool updateParcelas, bool criarParcelas) - { - Action action4 = null; - Action action5 = null; - int num = 3; - base.Sucesso = true; - Documento documento1 = documento; - DateTime networkTime = Funcoes.GetNetworkTime(); - List registroLogs = new List(); - Documento documento2 = await Task.Run(() => { - 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 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 parcelas1 = commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()); - if (parcelas1 != null) - { - Action u003cu003e9_3 = action4; - if (u003cu003e9_3 == null) - { - Action action = (Parcela pa) => registroLogs.Add(base.CreateLog(documento.get_Id(), pa.GetValorOriginal(), 5, 2)); - Action action1 = action; - action4 = action; - u003cu003e9_3 = action1; - } - parcelas1.ForEach(u003cu003e9_3); - } - else - { - } - List vendedorParcelas = commited.get_VendedorParcelaRepository().FindByDocumentId(documento.get_Id()); - if (vendedorParcelas != null) - { - Action u003cu003e9_4 = action5; - if (u003cu003e9_4 == null) - { - Action action2 = (VendedorParcela pa) => registroLogs.Add(base.CreateLog(pa.get_Parcela().get_Id(), pa.GetValorOriginal(), 37, 2)); - Action 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().ForEach((Parcela p) => { - Parcela parcela = p; - ObservableCollection vendedores = parcela.get_Vendedores(); - parcela.set_Documento(documento); - parcela.set_IdEmpresa(documento.get_Controle().get_IdEmpresa()); - parcela = commited.get_ParcelaRepository().SaveOrUpdate(parcela); - vendedores.ToList().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 parcelas2 = commited.get_ParcelaRepository().FindByDocumentId(documento.get_Id()); - List vendedorParcelas1 = commited.get_VendedorParcelaRepository().FindByDocumentId(documento.get_Id()); - parcelas.ToList().ForEach((Parcela p) => { - Parcela parcela = p; - ObservableCollection vendedores = parcela.get_Vendedores(); - parcela.set_Documento(documento); - parcela = commited.get_ParcelaRepository().Merge(parcela); - vendedores.ToList().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 pa) => vendedorParcela.get_Id() == pa.get_Id()); - if (vendedorParcela1 == null) - { - return; - } - List 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 pa) => parcela.get_Id() == pa.get_Id()); - if (parcela1 == null) - { - return; - } - List 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().ForEach((Parcela p) => { - Parcela parcela = p; - ObservableCollection 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().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 Save(long id, string observacao) - { - int num = 3; - base.Sucesso = true; - Funcoes.GetNetworkTime(); - string str1 = await Task.Run(() => { - string str; - while (num > 0) - { - List registroLogs = new List(); - 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 UpdateRange(Controle controle) - { - int num = 3; - Controle controle1 = controle; - bool flag1 = await Task.Run(() => { - bool flag; - while (num > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - controle1 = commited.get_ControleRepository().Merge(controle1); - controle1.get_Documentos().ToList().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 -- cgit v1.2.3