From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../ExtratosViewModel.cs | 2773 ++++++++++++++++++++ 1 file changed, 2773 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs') diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs new file mode 100644 index 0000000..c04d349 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs @@ -0,0 +1,2773 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Seguros; +using NReco.PdfGenerator; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ExtratosViewModel : BaseSegurosViewModel +{ + private readonly ClienteServico _clienteServico = new ClienteServico(); + + private List _documentos; + + private List _prospeccoes; + + private List _clientes; + + private bool _tipoExtratoEnabled = true; + + private bool _extratoResumido; + + private bool _segurosVigentes; + + private Visibility _clientePorPaginaVisibility; + + private bool _clientePorPagina; + + private bool _extratoPorPagina; + + private bool _clientePorPaginaEnabled = true; + + private bool _obsCliente; + + private bool _comissaoDocumento; + + private bool _premioParcela; + + private bool _obsApolice; + + private bool _beneficiariosItens; + + private bool _selecionarItens; + + private bool _endossos; + + private bool _somenteEndosso; + + private Visibility _selecionarItensVisibility; + + private Visibility _endossoVisibility; + + private Visibility _obsDocVisibility; + + private Visibility _segurosVigentesVisibility; + + private bool _obsItem; + + private bool _separarPagina; + + private bool _perfilCondutor; + + private bool _obsClienteEnabled = true; + + private bool _comissaoDocumentoEnabled; + + private bool _obsApoliceEnabled; + + private bool _beneficiariosItensEnabled; + + private bool _obsItemEnabled; + + private bool _separarPaginaEnabled; + + private bool _coberturasEnabled; + + private bool _coberturas; + + private bool _perfilCondutorEnabled; + + private bool _endossoEnabled; + + private bool _esconderResumido; + + private bool _clienteVisibility; + + private bool _documentoVisibility; + + private bool _itemVisibility; + + private bool _perfilVisibility; + + private TipoExtrato _selectedTipoExtrato; + + private bool _carregando; + + private List _itensSelecionados; + + internal Relatorio? TipoDeRelatorio; + + public List Documentos + { + get + { + return _documentos; + } + set + { + _documentos = value; + OnPropertyChanged("Documentos"); + } + } + + public List Prospeccoes + { + get + { + return _prospeccoes; + } + set + { + _prospeccoes = value; + OnPropertyChanged("Prospeccoes"); + } + } + + public List Clientes + { + get + { + return _clientes; + } + set + { + _clientes = value; + OnPropertyChanged("Clientes"); + } + } + + public bool TipoExtratoEnabled + { + get + { + return _tipoExtratoEnabled; + } + set + { + _tipoExtratoEnabled = value; + OnPropertyChanged("TipoExtratoEnabled"); + } + } + + public bool ExtratoResumido + { + get + { + return _extratoResumido; + } + set + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + _extratoResumido = value; + if (value) + { + ClienteVisibility = false; + DocumentoVisibility = false; + ItemVisibility = CoberturasEnabled; + SelecionarItensVisibility = (Visibility)2; + BeneficiariosItensEnabled = false; + ObsItemEnabled = false; + SepararPaginaEnabled = false; + } + else + { + ClienteVisibility = true; + DocumentoVisibility = true; + ItemVisibility = true; + AjustaTipoSelecionado(SelectedTipoExtrato); + } + OnPropertyChanged("ExtratoResumido"); + } + } + + public bool SegurosVigentes + { + get + { + return _segurosVigentes; + } + set + { + _segurosVigentes = value; + OnPropertyChanged("SegurosVigentes"); + } + } + + public Visibility ClientePorPaginaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _clientePorPaginaVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _clientePorPaginaVisibility = value; + OnPropertyChanged("ClientePorPaginaVisibility"); + } + } + + public bool ClientePorPagina + { + get + { + return _clientePorPagina; + } + set + { + _clientePorPagina = value; + OnPropertyChanged("ClientePorPagina"); + } + } + + public bool ExtratoPorPagina + { + get + { + return _extratoPorPagina; + } + set + { + _extratoPorPagina = value; + OnPropertyChanged("ExtratoPorPagina"); + } + } + + public bool ClientePorPaginaEnabled + { + get + { + return _clientePorPaginaEnabled; + } + set + { + _clientePorPaginaEnabled = value; + OnPropertyChanged("ClientePorPaginaEnabled"); + } + } + + public bool ObsCliente + { + get + { + return _obsCliente; + } + set + { + _obsCliente = value; + OnPropertyChanged("ObsCliente"); + } + } + + public bool ComissaoDocumento + { + get + { + return _comissaoDocumento; + } + set + { + _comissaoDocumento = value; + OnPropertyChanged("ComissaoDocumento"); + } + } + + public bool PremioParcela + { + get + { + return _premioParcela; + } + set + { + _premioParcela = value; + OnPropertyChanged("PremioParcela"); + } + } + + public bool ObsApolice + { + get + { + return _obsApolice; + } + set + { + _obsApolice = value; + OnPropertyChanged("ObsApolice"); + } + } + + public bool BeneficiariosItens + { + get + { + return _beneficiariosItens; + } + set + { + _beneficiariosItens = value; + OnPropertyChanged("BeneficiariosItens"); + } + } + + public bool SelecionarItens + { + get + { + return _selecionarItens; + } + set + { + _selecionarItens = value; + if (!value) + { + _itensSelecionados = new List(); + } + OnPropertyChanged("SelecionarItens"); + } + } + + public bool Endossos + { + get + { + return _endossos; + } + set + { + _endossos = value; + if (SomenteEndossos != !value) + { + SomenteEndossos = !value; + } + OnPropertyChanged("Endossos"); + } + } + + public bool SomenteEndossos + { + get + { + return _somenteEndosso; + } + set + { + _somenteEndosso = value; + if (Endossos != !value) + { + Endossos = !value; + } + OnPropertyChanged("SomenteEndossos"); + } + } + + public Visibility SelecionarItensVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selecionarItensVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _selecionarItensVisibility = value; + OnPropertyChanged("SelecionarItensVisibility"); + } + } + + public Visibility EndossoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _endossoVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _endossoVisibility = value; + OnPropertyChanged("EndossoVisibility"); + } + } + + public Visibility ObsDocVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _obsDocVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _obsDocVisibility = value; + OnPropertyChanged("ObsDocVisibility"); + } + } + + public Visibility SegurosVigentesVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _segurosVigentesVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _segurosVigentesVisibility = value; + OnPropertyChanged("SegurosVigentesVisibility"); + } + } + + public bool ObsItem + { + get + { + return _obsItem; + } + set + { + _obsItem = value; + OnPropertyChanged("ObsItem"); + } + } + + public bool SepararPagina + { + get + { + return _separarPagina; + } + set + { + _separarPagina = value; + OnPropertyChanged("SepararPagina"); + } + } + + public bool PerfilCondutor + { + get + { + return _perfilCondutor; + } + set + { + _perfilCondutor = value; + OnPropertyChanged("PerfilCondutor"); + } + } + + public bool ObsClienteEnabled + { + get + { + return _obsClienteEnabled; + } + set + { + _obsClienteEnabled = value; + OnPropertyChanged("ObsClienteEnabled"); + } + } + + public bool ComissaoDocumentoEnabled + { + get + { + return _comissaoDocumentoEnabled; + } + set + { + _comissaoDocumentoEnabled = value; + OnPropertyChanged("ComissaoDocumentoEnabled"); + } + } + + public bool ObsApoliceEnabled + { + get + { + return _obsApoliceEnabled; + } + set + { + _obsApoliceEnabled = value; + OnPropertyChanged("ObsApoliceEnabled"); + } + } + + public bool BeneficiariosItensEnabled + { + get + { + return _beneficiariosItensEnabled; + } + set + { + _beneficiariosItensEnabled = value; + OnPropertyChanged("BeneficiariosItensEnabled"); + } + } + + public bool ObsItemEnabled + { + get + { + return _obsItemEnabled; + } + set + { + _obsItemEnabled = value; + OnPropertyChanged("ObsItemEnabled"); + } + } + + public bool SepararPaginaEnabled + { + get + { + return _separarPaginaEnabled; + } + set + { + _separarPaginaEnabled = value; + OnPropertyChanged("SepararPaginaEnabled"); + } + } + + public bool CoberturasEnabled + { + get + { + return _coberturasEnabled; + } + set + { + _coberturasEnabled = value; + OnPropertyChanged("CoberturasEnabled"); + } + } + + public bool Coberturas + { + get + { + return _coberturas; + } + set + { + _coberturas = value; + OnPropertyChanged("Coberturas"); + } + } + + public bool PerfilCondutorEnabled + { + get + { + return _perfilCondutorEnabled; + } + set + { + _perfilCondutorEnabled = value; + OnPropertyChanged("PerfilCondutorEnabled"); + } + } + + public bool EndossoEnabled + { + get + { + return _endossoEnabled; + } + set + { + _endossoEnabled = value; + OnPropertyChanged("EndossoEnabled"); + } + } + + public bool EsconderResumido + { + get + { + return _esconderResumido; + } + set + { + _esconderResumido = value; + OnPropertyChanged("EsconderResumido"); + } + } + + public bool ClienteVisibility + { + get + { + return _clienteVisibility; + } + set + { + _clienteVisibility = value; + OnPropertyChanged("ClienteVisibility"); + } + } + + public bool DocumentoVisibility + { + get + { + return _documentoVisibility; + } + set + { + _documentoVisibility = value; + OnPropertyChanged("DocumentoVisibility"); + } + } + + public bool ItemVisibility + { + get + { + return _itemVisibility; + } + set + { + _itemVisibility = value; + OnPropertyChanged("ItemVisibility"); + } + } + + public bool PerfilVisibility + { + get + { + return _perfilVisibility; + } + set + { + _perfilVisibility = value; + OnPropertyChanged("PerfilVisibility"); + } + } + + public TipoExtrato SelectedTipoExtrato + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selectedTipoExtrato; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + _selectedTipoExtrato = value; + AjustaTipoSelecionado(value); + OnPropertyChanged("SelectedTipoExtrato"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public void AjustaTipoSelecionado(TipoExtrato tipoExtrato) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Expected I4, but got Unknown + switch ((int)tipoExtrato) + { + case 0: + ClienteVisibility = true; + ClientePorPaginaVisibility = (Visibility)1; + DocumentoVisibility = false; + ItemVisibility = false; + PerfilVisibility = false; + EsconderResumido = true; + SelecionarItensVisibility = (Visibility)2; + SegurosVigentesVisibility = (Visibility)2; + SegurosVigentes = false; + EndossoVisibility = (Visibility)2; + ObsDocVisibility = (Visibility)2; + ExtratoCliente(); + break; + case 1: + ClienteVisibility = true; + ClientePorPaginaVisibility = (Visibility)0; + DocumentoVisibility = true; + ItemVisibility = true; + PerfilVisibility = true; + EsconderResumido = false; + SelecionarItensVisibility = (Visibility)(TipoDeRelatorio.HasValue ? 2 : 0); + SegurosVigentesVisibility = (Visibility)2; + SegurosVigentes = false; + EndossoVisibility = (Visibility)0; + ObsDocVisibility = (Visibility)0; + ApoliceSelecionada(); + break; + case 2: + ClienteVisibility = false; + ClientePorPaginaVisibility = (Visibility)2; + DocumentoVisibility = true; + ItemVisibility = false; + PerfilVisibility = true; + EsconderResumido = false; + SelecionarItensVisibility = (Visibility)2; + SegurosVigentesVisibility = (Visibility)0; + EndossoVisibility = (Visibility)2; + ObsDocVisibility = (Visibility)2; + RelacaoApolices(); + break; + } + } + + private void SetAllFalse() + { + ObsClienteEnabled = false; + ClientePorPaginaEnabled = false; + ComissaoDocumentoEnabled = false; + ObsApoliceEnabled = false; + BeneficiariosItensEnabled = false; + ObsItemEnabled = false; + SepararPaginaEnabled = false; + CoberturasEnabled = false; + PerfilCondutorEnabled = false; + EndossoEnabled = false; + } + + private void ExtratoCliente() + { + SetAllFalse(); + ObsClienteEnabled = true; + } + + private void ApoliceSelecionada() + { + SetAllFalse(); + ObsClienteEnabled = true; + ClientePorPaginaEnabled = true; + ComissaoDocumentoEnabled = true; + ObsApoliceEnabled = true; + BeneficiariosItensEnabled = true; + ObsItemEnabled = true; + SepararPaginaEnabled = true; + PerfilCondutorEnabled = true; + EndossoEnabled = true; + CoberturasEnabled = true; + } + + private void RelacaoApolices() + { + SetAllFalse(); + ComissaoDocumentoEnabled = true; + PerfilCondutorEnabled = true; + } + + public async Task Gerar(Relatorio? tipoRelatorio = null, bool pdf = false) + { + string html = ""; + string title; + if (Clientes != null && Documentos == null) + { + html += ""; + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE"; + html += title; + html += "
"; + html += ""; + long idCli = 0L; + Clientes.ForEach(delegate(Cliente x) + { + //IL_0353: Unknown result type (might be due to invalid IL or missing references) + //IL_0359: Invalid comparison between Unknown and I4 + //IL_080c: Unknown result type (might be due to invalid IL or missing references) + //IL_0812: Invalid comparison between Unknown and I4 + //IL_0988: Unknown result type (might be due to invalid IL or missing references) + //IL_098e: Invalid comparison between Unknown and I4 + //IL_0bb7: Unknown result type (might be due to invalid IL or missing references) + //IL_0bbd: Invalid comparison between Unknown and I4 + //IL_0d17: Unknown result type (might be due to invalid IL or missing references) + //IL_0d1d: Invalid comparison between Unknown and I4 + //IL_0d97: Unknown result type (might be due to invalid IL or missing references) + //IL_0d9d: Invalid comparison between Unknown and I4 + //IL_1351: Unknown result type (might be due to invalid IL or missing references) + //IL_12a2: Unknown result type (might be due to invalid IL or missing references) + //IL_12a8: Invalid comparison between Unknown and I4 + //IL_0a09: Unknown result type (might be due to invalid IL or missing references) + //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) + //IL_11e8: Unknown result type (might be due to invalid IL or missing references) + //IL_11ee: Invalid comparison between Unknown and I4 + //IL_0ea0: Unknown result type (might be due to invalid IL or missing references) + //IL_0ea5: Unknown result type (might be due to invalid IL or missing references) + //IL_1030: Unknown result type (might be due to invalid IL or missing references) + //IL_1035: Unknown result type (might be due to invalid IL or missing references) + int num6 = 0; + if (idCli != ((DomainBase)x).Id) + { + idCli = ((DomainBase)x).Id; + html += ((ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + html += "

"; + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + x.Nome; + html = html + title + "


"; + string text25 = ((x.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + bool pessoaFisica3 = x.PessoaFisica; + html = html + ""; + if (pessoaFisica3) + { + html = html + ""; + } + else + { + num6++; + } + html += ""; + if (x.Atividade != null) + { + html = html + ""; + if (!pessoaFisica3) + { + num6++; + } + } + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + if (pessoaFisica3) + { + html = html + ""; + } + html = html + ""; + } + if (pessoaFisica3) + { + html = html + ""; + } + if (!string.IsNullOrWhiteSpace(x.Identidade)) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + TipoTelefone valueOrDefault3; + if ((x.Telefones != null || x.Emails != null) && (int)SelectedTipoExtrato != 2) + { + html += ""; + if (x.Telefones != null) + { + string text26 = ""; + foreach (ClienteTelefone telefone in x.Telefones) + { + string[] obj32 = new string[7] { text26, "
", null, null, null, null, null }; + TipoTelefone? tipo2 = ((TelefoneBase)telefone).Tipo; + object obj33; + if (!tipo2.HasValue) + { + obj33 = null; + } + else + { + valueOrDefault3 = tipo2.GetValueOrDefault(); + obj33 = ((object)(TipoTelefone)(ref valueOrDefault3)).ToString().ToUpper(); + } + obj32[2] = (string)obj33; + obj32[3] = " ("; + obj32[4] = ((TelefoneBase)telefone).Prefixo; + obj32[5] = ") "; + obj32[6] = ((TelefoneBase)telefone).Numero; + text26 = string.Concat(obj32); + } + html = html + "
"; + } + if (x.Emails != null && !ExtratoResumido) + { + string text27 = ""; + foreach (ClienteEmail email in x.Emails) + { + text27 = text27 + "
" + ((EmailBase)email).Email; + } + html = html + "
"; + } + num6++; + html += ""; + } + if (x.Enderecos != null && (int)SelectedTipoExtrato != 2) + { + string text28 = ""; + foreach (ClienteEndereco endereco in x.Enderecos) + { + text28 = text28 + "
" + ((EnderecoBase)endereco).Endereco + ", " + ((EnderecoBase)endereco).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco).Complemento) ? "" : (((EnderecoBase)endereco).Complemento + ", ")) + ((EnderecoBase)endereco).Bairro + " - " + ((EnderecoBase)endereco).Cidade + " - " + ((EnderecoBase)endereco).Estado + " - " + ((EnderecoBase)endereco).Cep; + } + html = html + "
"; + } + if (x.Profissao != null && (int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + if (x.Contatos != null && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + string text29 = ""; + foreach (MaisContato contato in x.Contatos) + { + string[] obj34 = new string[15] + { + text29, + "
NOME: ", + contato.Nome, + (!string.IsNullOrWhiteSpace(contato.Documento)) ? (", DOCUMENTO: " + contato.Documento) : "", + contato.Nascimento.HasValue ? (", NASCIMENTO: " + contato.Nascimento?.ToShortDateString()) : "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + object obj35; + if (!contato.Parentesco.HasValue) + { + obj35 = ""; + } + else + { + Parentesco? parentesco2 = contato.Parentesco; + object obj36; + if (!parentesco2.HasValue) + { + obj36 = null; + } + else + { + Parentesco valueOrDefault4 = parentesco2.GetValueOrDefault(); + obj36 = ((object)(Parentesco)(ref valueOrDefault4)).ToString().ToUpper(); + } + obj35 = ", PARENTESCO: " + (string?)obj36; + } + obj34[5] = (string)obj35; + obj34[6] = ((!string.IsNullOrWhiteSpace(contato.Banco) || !string.IsNullOrWhiteSpace(contato.Agencia) || !string.IsNullOrWhiteSpace(contato.Conta)) ? "
" : ""); + obj34[7] = ((!string.IsNullOrWhiteSpace(contato.Banco)) ? ("BANCO: " + contato.Banco) : ""); + obj34[8] = ((!string.IsNullOrWhiteSpace(contato.Agencia)) ? (((!string.IsNullOrWhiteSpace(contato.Banco)) ? ", AGÊNCIA: " : "AGÊNCIA: ") + contato.Agencia) : ""); + obj34[9] = ((!string.IsNullOrWhiteSpace(contato.Conta)) ? (((!string.IsNullOrWhiteSpace(contato.Banco) || !string.IsNullOrWhiteSpace(contato.Agencia)) ? ", CONTA: " : "CONTA: ") + contato.Conta) : ""); + obj34[10] = ((contato.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone)) || !string.IsNullOrWhiteSpace(contato.Email)) ? "
" : ""); + object obj37; + if (!contato.Tipo.HasValue) + { + obj37 = ""; + } + else + { + TipoTelefone? tipo2 = contato.Tipo; + object obj38; + if (!tipo2.HasValue) + { + obj38 = null; + } + else + { + valueOrDefault3 = tipo2.GetValueOrDefault(); + obj38 = ((object)(TipoTelefone)(ref valueOrDefault3)).ToString().ToUpper(); + } + obj37 = "TIPO DO TELEFONE: " + (string?)obj38; + } + obj34[11] = (string)obj37; + obj34[12] = ((!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone)) ? ((contato.Tipo.HasValue ? ", TELEFONE: (" : "TELEFONE: (") + contato.Prefixo + ") " + contato.Telefone) : ""); + obj34[13] = ((!string.IsNullOrWhiteSpace(contato.Email)) ? (((contato.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone))) ? ", EMAIL: " : "EMAIL: ") + contato.Email) : ""); + obj34[14] = "
"; + text29 = string.Concat(obj34); + } + html = html + "
"; + } + if (ObsCliente && ClienteVisibility && ObsClienteEnabled && !string.IsNullOrWhiteSpace(x.Observacao) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + x.Observacao = "
" + x.Observacao.Replace("\r\n", "
"); + html = html + "
"; + } + if (!string.IsNullOrWhiteSpace(x.Pasta) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + html += "

CLIENTE: " + x.Nome + "

CPF/CNPJ: " + x.Documento + "

" + text25 + ": " + x.Nascimento?.ToShortDateString() + "

FALECIDO: " + (x.Falecido ? "SIM" : "NÃO") + "

RAMO DE ATIVIDADE: " + x.Atividade.Nome + "

ESTADO CIVIL: " + (x.EstadoCivil.HasValue ? x.EstadoCivil.ToString().ToUpper() : "-") + "

SEXO: " + (x.Sexo.HasValue ? x.Sexo.ToString().ToUpper() : "-") + "

CLIENTE DESDE: " + ((!x.ClienteDesde.HasValue) ? "-" : x.ClienteDesde?.ToShortDateString()) + "

HABILITAÇÃO: " + ((!string.IsNullOrWhiteSpace(x.Habilitacao)) ? x.Habilitacao : "-") + "

CATEGORIA: " + ((!string.IsNullOrWhiteSpace(x.CategoriaHabilitacao)) ? x.CategoriaHabilitacao : "-") + "

1ª HAB.: " + ((!x.PrimeiraHabilitacao.HasValue) ? "-" : x.PrimeiraHabilitacao?.ToShortDateString()) + "

VENCIMENTO: " + ((!x.VencimentoHabilitacao.HasValue) ? "-" : x.VencimentoHabilitacao?.ToShortDateString()) + "

RG: " + ((!string.IsNullOrWhiteSpace(x.Identidade)) ? x.Identidade : "-") + "

ORGÃO EMISSOR: " + ((!string.IsNullOrWhiteSpace(x.Emissor)) ? x.Emissor : "-") + "

ESTADO EMISSOR: " + ((!string.IsNullOrWhiteSpace(x.EstadoEmissor)) ? x.EstadoEmissor : "-") + "

EXPEDIÇÃO: " + ((!x.Expedicao.HasValue) ? "-" : x.Expedicao?.ToShortDateString()) + "

BANCO: " + ((x.Banco != null) ? x.Banco.Nome : "-") + "

AGÊNCIA: " + ((!string.IsNullOrWhiteSpace(x.Agencia)) ? x.Agencia : "-") + "

CONTA: " + ((!string.IsNullOrWhiteSpace(x.Conta)) ? x.Conta : "-") + "

TIPO: " + ((!string.IsNullOrWhiteSpace(x.TipoConta)) ? x.TipoConta : "-") + "

CONTATOS: " + text26 + "

EMAILS: " + text27 + "

ENDEREÇOS: " + text28 + "

PROFISSÃO: " + x.Profissao.Nome + "

MAIS CONTATOS: " + text29 + "

OBSERVAÇÕES: " + x.Observacao + "

PASTA: " + x.Pasta + "

"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + } + }); + DateTime networkTime = Funcoes.GetNetworkTime(); + html = html + "

" + Recursos.Usuario.Nome + " - " + networkTime.Date.ToShortDateString() + "
"; + string tempPath = Path.GetTempPath(); + string text = $"{tempPath}{(object)(TipoExtrato)0}_{networkTime:ddMMyyyyhhmmss}.html"; + if (pdf) + { + text = $"{tempPath}{(object)(TipoExtrato)0}_{networkTime:ddMMyyyyhhmmss}.pdf"; + byte[] bytes = ((HtmlToPdfConverter)new NRecoHtmlToPdfConverter()).GeneratePdf(html); + File.WriteAllBytes(text, bytes); + } + else + { + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(html); + streamWriter.Close(); + } + Process.Start(text); + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Clientes == null) ? "" : ((Clientes.Count > 1) ? $"DE {Clientes.Count} CLIENTES" : ("DO CLIENTE " + Clientes[0].Nome))), 0L, (TipoTela)23, "NOMES DOS CLIENTES:\n" + string.Join("\n", Clientes.Select((Cliente x) => x.Nome)) + GerarOpcoes()); + Documentos = null; + Clientes = null; + } + else + { + if ((Documentos == null && Prospeccoes == null) || Clientes != null) + { + return; + } + html = ""; + title = ""; + TipoExtrato selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 0: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE"; + break; + case 1: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE SELECIONADA"; + if (tipoRelatorio.HasValue && (int)tipoRelatorio.GetValueOrDefault() == 4) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO RELATÓRIO DE RENOVAÇÕES"; + } + break; + case 2: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DE RELAÇÃO DE APÓLICES"; + break; + } + html += title; + html += "
"; + List sDocumento = new List(); + if (Documentos != null && Documentos.Count > 0) + { + bool configEndosso = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 42); + foreach (Documento documento2 in Documentos) + { + Documento val = documento2; + val.Parcelas = await new ParcelaServico().BuscarParcelasAsync(((DomainBase)documento2).Id); + Controle controle = documento2.Controle; + controle.Cliente = await _clienteServico.BuscarCliente(((DomainBase)documento2.Controle.Cliente).Id); + Cliente cliente = documento2.Controle.Cliente; + cliente.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)documento2.Controle.Cliente).Id); + } + bool primeiro = true; + foreach (Documento documento in Documentos) + { + List itensDocumentos = new List(); + List list = ((!Endossos) ? (await new ItemServico().BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)0)).ToList() : (await new ItemServico().BuscarItens(((DomainBase)documento).Id, (StatusItem)2)).ToList()); + List list2 = list; + if (_itensSelecionados != null && _itensSelecionados.Count > 0) + { + list2.ForEach(delegate(Item x) + { + if (_itensSelecionados.Any((Item y) => ((DomainBase)y).Id == ((DomainBase)x).Id)) + { + itensDocumentos.Add(x); + } + }); + } + else + { + itensDocumentos.AddRange(list2); + } + List source = await new PerfilServico().BuscarPerfis(((DomainBase)documento.Controle).Id); + long num = 0L; + int color = 0; + if (!primeiro) + { + html += (ExtratoPorPagina ? "
" : ""); + } + if (num != ((DomainBase)documento.Controle.Cliente).Id) + { + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled && !ExtratoPorPagina) ? "
" : ""); + html += "

"; + selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 0: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + documento.Controle.Cliente.Nome; + break; + case 1: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE SELECIONADA: " + documento.Apolice; + if (tipoRelatorio.HasValue && (int)tipoRelatorio.GetValueOrDefault() == 4) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE: " + documento.Apolice; + } + if (!string.IsNullOrEmpty(documento.Endosso) && !documento.Endosso.Equals("0")) + { + title = title + " E DO ENDOSSO: " + documento.Endosso; + } + if (SomenteEndossos) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO ENDOSSO: " + documento.Endosso; + } + break; + case 2: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DE RELAÇÃO DE APÓLICES"; + break; + } + html = html + title + "


"; + html += ""; + TipoTelefone valueOrDefault; + if (ExtratoResumido) + { + bool pessoaFisica = documento.Controle.Cliente.PessoaFisica; + if ((!Endossos || !SomenteEndossos) && !sDocumento.Any((long x) => x == ((DomainBase)documento.Controle).Id)) + { + html = html + ""; + if (pessoaFisica) + { + html = html + ""; + } + html = html + ""; + if ((int)SelectedTipoExtrato != 2) + { + string text2 = ((documento.Controle.Cliente.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + html = html + ""; + } + else + { + color++; + } + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + string text3 = ""; + if (documento.Controle.Cliente.Telefones != null) + { + foreach (ClienteTelefone telefone2 in documento.Controle.Cliente.Telefones) + { + string[] obj = new string[7] { text3, "
", null, null, null, null, null }; + TipoTelefone? tipo = ((TelefoneBase)telefone2).Tipo; + object obj2; + if (!tipo.HasValue) + { + obj2 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj2 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj[2] = (string)obj2; + obj[3] = " ("; + obj[4] = ((TelefoneBase)telefone2).Prefixo; + obj[5] = ") "; + obj[6] = ((TelefoneBase)telefone2).Numero; + text3 = string.Concat(obj); + } + } + html = html + "
"; + string text4 = ""; + if (documento.Controle.Cliente.Emails != null) + { + foreach (ClienteEmail email2 in documento.Controle.Cliente.Emails) + { + text4 = text4 + "
" + ((EmailBase)email2).Email; + } + } + html = html + "
"; + string text5 = ""; + if (documento.Controle.Cliente.Enderecos != null) + { + foreach (ClienteEndereco endereco2 in documento.Controle.Cliente.Enderecos) + { + text5 = text5 + "
" + ((EnderecoBase)endereco2).Endereco + ", " + ((EnderecoBase)endereco2).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco2).Complemento) ? "" : (((EnderecoBase)endereco2).Complemento + ", ")) + ((EnderecoBase)endereco2).Bairro + " - " + ((EnderecoBase)endereco2).Cidade + " - " + ((EnderecoBase)endereco2).Estado + " - " + ((EnderecoBase)endereco2).Cep; + } + } + html = html + "
"; + html += ""; + } + html += "

CLIENTE: " + documento.Controle.Cliente.Nome + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

" + text2 + ": " + documento.Controle.Cliente.Nascimento?.ToShortDateString() + "

"; + if (pessoaFisica) + { + html = html + "

ESTADO CIVIL: " + (documento.Controle.Cliente.EstadoCivil.HasValue ? documento.Controle.Cliente.EstadoCivil.ToString().ToUpper() : "-") + "

SEXO: " + (documento.Controle.Cliente.Sexo.HasValue ? documento.Controle.Cliente.Sexo.ToString().ToUpper() : "-") + "

BANCO: " + ((documento.Controle.Cliente.Banco != null) ? documento.Controle.Cliente.Banco.Nome : "-") + "

AGÊNCIA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Agencia)) ? documento.Controle.Cliente.Agencia : "-") + "

CONTA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Conta)) ? documento.Controle.Cliente.Conta : "-") + "

TIPO: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.TipoConta)) ? documento.Controle.Cliente.TipoConta : "-") + "

CONTATOS: " + (string.IsNullOrEmpty(text3) ? "-" : text3) + "

EMAILS: " + (string.IsNullOrEmpty(text4) ? "-" : text4) + "

ENDEREÇOS: " + (string.IsNullOrEmpty(text5) ? "-" : text5) + "

"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + } + else + { + html = html + "

CLIENTE: " + documento.Controle.Cliente.Nome + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

"; + } + if ((int)SelectedTipoExtrato == 0) + { + return; + } + color = 0; + Documento val2 = documento.Controle.Documentos?.LastOrDefault((Func)((Documento x) => !x.Excluido && x.Ordem != 0)); + html = html + "
"; + if (!documento.NegocioCorretora.HasValue) + { + documento.NegocioCorretora = (NegocioCorretora)(((int)documento.Situacao == 2 && documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + html = html + ""; + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + string text6 = ""; + if (documento.Estipulante1 != null) + { + text6 = text6 + documento.Estipulante1.Nome + ", "; + } + if (documento.Estipulante2 != null) + { + text6 = text6 + documento.Estipulante2.Nome + ", "; + } + if (documento.Estipulante3 != null) + { + text6 = text6 + documento.Estipulante3.Nome + ", "; + } + if (documento.Estipulante4 != null) + { + text6 = text6 + documento.Estipulante4.Nome + ", "; + } + if (documento.Estipulante5 != null) + { + text6 = text6 + documento.Estipulante5.Nome + ", "; + } + if (!string.IsNullOrWhiteSpace(text6)) + { + int startIndex = text6.LastIndexOf(", ", StringComparison.Ordinal); + text6 = text6.Remove(startIndex, 2).Insert(startIndex, "."); + } + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + else + { + html = html + ""; + } + html = html + ""; + html += "

RAMO: " + documento.Controle.Ramo.Nome + "

VIGÊNCIA INICIAL: " + documento.Vigencia1.ToShortDateString() + "

VIGÊNCIA FINAL: " + ((!documento.Vigencia2.HasValue) ? "-" : documento.Vigencia2?.ToShortDateString()) + "

CONTRATO: " + (string.IsNullOrWhiteSpace(documento.Apolice) ? "-" : documento.Apolice) + "

POSSUI ENDOSSO? " + (documento.TemEndosso ? "SIM" : "NÃO") + "

ADITAMENTO: " + ((!string.IsNullOrWhiteSpace(documento.Endosso)) ? documento.Endosso : ((configEndosso && val2 != null) ? val2.Endosso : "-")) + "

NEGÓCIO CORRETORA: " + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "

STATUS DO SEGURO: " + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "

VENDEDOR: " + ((documento.VendedorPrincipal == null) ? "-" : documento.VendedorPrincipal.Nome) + "

ESTIPULANTE(S): " + (string.IsNullOrWhiteSpace(text6) ? "-" : text6) + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

APÓLICE SINISTRADA: " + (documento.Sinistro ? "SIM" : "NÃO") + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

FORMA PAGAMENTO: " + ValidationHelper.GetDescription((Enum)(object)documento.FormaPagamento) + "

"; + if (PremioParcela || ExtratoResumido) + { + html += ""; + if ((ComissaoDocumento && ComissaoDocumentoEnabled) || ExtratoResumido) + { + html = html + ""; + } + html = html + ""; + html += "

COMISSÃO: " + $"{Math.Round(documento.Comissao, 2):n2}%" + "

PRÊMIO LÍQUIDO: " + $"{Math.Round(documento.PremioLiquido, 2):c}" + "

ADICIONAL: " + $"{Math.Round(documento.PremioAdicional, 2):c}" + "

CUSTO APÓLICE: " + $"{Math.Round(documento.Custo, 2):c}" + "

I.O.F.: " + $"{Math.Round(documento.Iof, 2):c}" + "

PRÊMIO TOTAL: " + $"{Math.Round(documento.PremioTotal, 2):c}" + "

Nº PARCELAS: " + documento.NumeroParcelas + "

"; + } + if (PerfilCondutor && PerfilVisibility && ((DomainBase)documento.Controle.Ramo).Id == 5 && PerfilCondutorEnabled) + { + List list3 = source.ToList(); + foreach (Perfil item3 in list3) + { + color = 0; + if (!string.IsNullOrEmpty(item3.Nome)) + { + html = html + "

" + $"CONDUTOR {list3.IndexOf(item3) + 1}: " + "" + item3.Nome + "

CPF: " + (string.IsNullOrWhiteSpace(item3.Cpf) ? "-" : item3.Cpf) + "

NASCIMENTO: " + ((!item3.Nascimento.HasValue) ? "-" : item3.Nascimento?.ToShortDateString()) + "

ESTADO CIVIL: " + ((!item3.EstadoCivil.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.EstadoCivil)) + "

SEXO: " + ((!item3.Sexo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.Sexo)) + "

RELAÇÃO SEGURADO/CONDUTOR: " + ValidationHelper.GetDescription((Enum)(object)item3.Relacao) + "

GARAGEM NA RESIDÊNCIA: " + ((!item3.GaragemResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemResidencia)) + "

GARAGEM NO TRABALHO: " + ((!item3.GaragemTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemTrabalho)) + "

GARAGEM NO ESTUDO: " + ((!item3.GaragemEstudo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemEstudo)) + "

TIPO DE RESIDÊNCIA: " + ((!item3.TipoResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.TipoResidencia)) + "

DISTÂNCIA ATÉ O TRABALHO: " + ((!item3.DistanciaResidenciaTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.DistanciaResidenciaTrabalho)) + "

USO PROFISSIONAL: " + ((item3.UsoProfissional.HasValue && item3.UsoProfissional.Value) ? "SIM" : "NÃO") + "

USO POR DEPENDENTES: " + ((!item3.UsoDependentes.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.UsoDependentes)) + "

ISENÇÃO DE IMPOSTOS: " + ((item3.Isencao.HasValue && item3.Isencao.Value) ? "SIM" : "NÃO") + "

"; + } + } + } + List itens2 = itensDocumentos.ToList(); + if (itens2.Count == 0) + { + html += "

ESTA APÓLICE NÃO POSSUI ITENS

"; + } + else + { + color = 0; + foreach (Item item2 in itens2) + { + if (item2.Sinistros.Count > 0) + { + Item val3 = item2; + val3.Sinistros = await new SinistroServico().BuscarControles(((DomainBase)item2).Id); + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + html += (((int)SelectedTipoExtrato != 2 || itens2.IndexOf(item2) == 0) ? "
" : ""); + html += ""; + html += ""; + html += ""; + if ((int)SelectedTipoExtrato == 2) + { + html = html + ""; + } + else + { + switch (((DomainBase)documento.Controle.Ramo).Id) + { + case 1L: + case 2L: + case 3L: + case 15L: + case 18L: + { + Item val3 = item2; + val3.Patrimonial = await new ItemServico().BuscaPatrimonial(((DomainBase)item2).Id); + html = html + ""; + break; + } + case 5L: + case 37L: + { + Item val3 = item2; + val3.Auto = await new ItemServico().BuscaAuto(((DomainBase)item2).Id); + string[] obj3 = new string[26] + { + html, + ""; + html = string.Concat(obj3); + break; + } + default: + html = html + ""; + break; + } + } + if (item2.Sinistros.Count > 0) + { + Item obj4 = item2; + DateTime? obj5; + if (obj4 == null) + { + obj5 = null; + } + else + { + IList sinistros = obj4.Sinistros; + if (sinistros == null) + { + obj5 = null; + } + else + { + ControleSinistro? obj6 = sinistros.LastOrDefault(); + if (obj6 == null) + { + obj5 = null; + } + else + { + List sinistros2 = obj6.Sinistros; + if (sinistros2 == null) + { + obj5 = null; + } + else + { + Sinistro? obj7 = sinistros2.LastOrDefault(); + obj5 = ((obj7 != null) ? obj7.DataReclamacao : null); + } + } + } + } + DateTime? dateTime = obj5; + string text7 = (dateTime.HasValue ? dateTime.Value.ToShortDateString() : "-"); + string[] obj8 = new string[14] + { + html, ""; + html = string.Concat(obj8); + } + html += ""; + if ((int)SelectedTipoExtrato != 2) + { + string[] obj9 = new string[6] { html, ""; + html = string.Concat(obj9); + long id = ((DomainBase)documento.Controle.Ramo).Id; + long num3 = id - 1; + if ((ulong)num3 <= 58uL) + { + switch (num3) + { + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + case 4L: + case 36L: + { + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + string[] array = new string[26]; + array[0] = html; + array[1] = ""; + html = string.Concat(array); + break; + } + case 5L: + case 6L: + case 8L: + case 9L: + case 52L: + { + Item val3 = item2; + val3.Vida = await new ItemServico().BuscaVida(((DomainBase)item2).Id); + if (!item2.Sinistrado || !BeneficiariosItens || !BeneficiariosItensEnabled) + { + break; + } + html = html + ""; + break; + } + case 3L: + case 7L: + case 15L: + case 16L: + case 18L: + case 22L: + case 23L: + case 25L: + case 27L: + case 30L: + case 32L: + case 38L: + case 40L: + case 43L: + case 48L: + case 58L: + { + Item val3 = item2; + val3.RiscosDiversos = await new ItemServico().BuscaRiscosDiversos(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 12L: + { + Item val3 = item2; + val3.Aeronautico = await new ItemServico().BuscaAeronautico(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 19L: + { + Item val3 = item2; + val3.Granizo = await new ItemServico().BuscaGranizo(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + } + } + } + html += "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

" + $"ITEM {item2.Ordem}: " + "" + ((EnderecoBase)item2.Patrimonial).Endereco + ", " + ((EnderecoBase)item2.Patrimonial).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)item2.Patrimonial).Complemento) ? "" : (((EnderecoBase)item2.Patrimonial).Complemento + ", ")) + ((EnderecoBase)item2.Patrimonial).Bairro + " - " + ((EnderecoBase)item2.Patrimonial).Cidade + " - " + ((EnderecoBase)item2.Patrimonial).Estado + " - " + ((EnderecoBase)item2.Patrimonial).Cep + "

", + $"ITEM {item2.Ordem}: ", + "
", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + Fabricante fabricante = item2.Auto.Fabricante; + obj3[6] = ((fabricante != null) ? fabricante.Descricao : null); + obj3[7] = " "; + obj3[8] = item2.Auto.Modelo; + obj3[9] = " ("; + obj3[10] = item2.Auto.AnoFabricacao; + obj3[11] = "/"; + obj3[12] = item2.Auto.AnoModelo; + obj3[13] = ")
PLACA: "; + obj3[14] = item2.Auto.Placa; + obj3[15] = ", CHASSI: "; + obj3[16] = item2.Auto.Chassi; + obj3[17] = "
C.I.: "; + obj3[18] = item2.Auto.Ci; + obj3[19] = ", RENAVAM: "; + obj3[20] = item2.Auto.Renavam; + obj3[21] = ", CEP PERNOITE: "; + obj3[22] = item2.Auto.CepPernoite; + obj3[23] = "
FINANCIADO: "; + obj3[24] = (item2.Auto.Financiado.GetValueOrDefault() ? "SIM" : "NÃO"); + obj3[25] = "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

SINISTRO STATUS: "; + obj8[4] = ValidationHelper.GetDescription((Enum)(object)item2.Sinistros.LastOrDefault().Sinistros.LastOrDefault().StatusSinistro); + obj8[5] = "

DATA: "; + obj8[8] = text7; + obj8[9] = "

VALOR: "; + obj8[12] = ValidationHelper.ToCurrency(item2.Sinistros.LastOrDefault().Sinistros.LastOrDefault().Valor, "pt-BR"); + obj8[13] = "

ATIVO: "; + obj9[4] = ((!item2.Substituido.HasValue) ? "SIM" : "NÃO"); + obj9[5] = "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Patrimonial.Bens) ? "-" : item2.Patrimonial.Bens) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Auto.Observacao) ? "-" : item2.Auto.Observacao) + "

COBERTURA PADRÃO: "; + TipoCobertura? tipoCobertura = item2.Auto.TipoCobertura; + array[4] = (tipoCobertura.HasValue ? ValidationHelper.GetDescription((Enum)(object)tipoCobertura.GetValueOrDefault()) : null); + array[5] = "

BÔNUS: "; + array[8] = item2.Auto.Bonus.ToString(); + array[9] = "

REGIÃO DE CIRCULAÇÃO: "; + array[12] = (string.IsNullOrWhiteSpace(item2.Auto.RegiaoCirculacao) ? "-" : item2.Auto.RegiaoCirculacao); + array[13] = "

TABELA DE REFERÊNCIA: "; + TabelaReferencia? tabelaReferencia = item2.Auto.TabelaReferencia; + array[16] = (tabelaReferencia.HasValue ? ValidationHelper.GetDescription((Enum)(object)tabelaReferencia.GetValueOrDefault()) : null); + array[17] = "

FIPE: "; + array[20] = (string.IsNullOrWhiteSpace(item2.Auto.Fipe) ? "-" : item2.Auto.Fipe); + array[21] = "

% DE REFERÊNCIA: "; + array[24] = $"{item2.Auto.PorcentagemReferencia}%"; + array[25] = "

BENEFICIÁRIOS: "; + string text8 = ""; + foreach (ControleSinistro sinistro in item2.Sinistros) + { + if (sinistro.Sinistros == null) + { + continue; + } + foreach (Sinistro sinistro2 in sinistro.Sinistros) + { + if (!string.IsNullOrWhiteSpace(sinistro2.SinistroVida.Beneficiario)) + { + text8 = text8 + sinistro2.SinistroVida.Beneficiario + ", "; + } + } + } + if (!string.IsNullOrWhiteSpace(text8)) + { + int startIndex2 = text8.LastIndexOf(", ", StringComparison.Ordinal); + text8 = text8.Remove(startIndex2, 2).Insert(startIndex2, "."); + } + html = html + text8 + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.RiscosDiversos.Observacao) ? "-" : item2.RiscosDiversos.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Aeronautico.Observacao) ? "-" : item2.Aeronautico.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Granizo.Observacao) ? "-" : item2.Granizo.Observacao) + "

"; + if ((int)SelectedTipoExtrato != 2) + { + ObservableCollection observableCollection = await new ItemServico().BuscarCoberturasPorItemAsync(((DomainBase)item2).Id); + if (observableCollection.Count > 0 && Coberturas) + { + html += "
"; + foreach (Cobertura item4 in observableCollection) + { + color++; + html = html + ""; + } + html += "

COBERTURA

FRANQUIA

LMI

PRÊMIO

" + item4.Observacao + "

" + $"{item4.Franquia:c}" + "

" + $"{item4.Lmi:c}" + "

" + $"{item4.Premio:c}" + "

"; + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + } + if ((int)SelectedTipoExtrato != 2) + { + color = 0; + } + } + } + } + else + { + if ((!Endossos || !SomenteEndossos) && !sDocumento.Any((long x) => x == ((DomainBase)documento.Controle).Id)) + { + string text9 = ((documento.Controle.Cliente.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + bool pessoaFisica2 = documento.Controle.Cliente.PessoaFisica; + html = html + ""; + if (pessoaFisica2) + { + html = html + ""; + } + else + { + color++; + } + html += ""; + if (documento.Controle.Cliente.Atividade != null) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + if (documento.Controle.Cliente.Profissao != null && (int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + else + { + color++; + } + html += ""; + } + if (pessoaFisica2) + { + html = html + ""; + } + if (!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + if ((documento.Controle.Cliente.Telefones != null || documento.Controle.Cliente.Emails != null) && (int)SelectedTipoExtrato != 2) + { + html += ""; + if (documento.Controle.Cliente.Telefones != null) + { + string text10 = ""; + foreach (ClienteTelefone telefone3 in documento.Controle.Cliente.Telefones) + { + string[] obj10 = new string[10] { text10, "
", null, null, null, null, null, null, null, null }; + TipoTelefone? tipo = ((TelefoneBase)telefone3).Tipo; + object obj11; + if (!tipo.HasValue) + { + obj11 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj11 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj10[2] = (string)obj11; + obj10[3] = " ("; + obj10[4] = ((TelefoneBase)telefone3).Prefixo; + obj10[5] = ") "; + obj10[6] = ((TelefoneBase)telefone3).Numero; + obj10[7] = " ("; + obj10[8] = telefone3.Observacao; + obj10[9] = ") "; + text10 = string.Concat(obj10); + } + html = html + "
"; + } + if (documento.Controle.Cliente.Emails != null && !ExtratoResumido) + { + string text11 = ""; + foreach (ClienteEmail email3 in documento.Controle.Cliente.Emails) + { + text11 = text11 + "
" + ((EmailBase)email3).Email; + } + html = html + "
"; + } + else if (documento.Controle.Cliente.Enderecos != null && (int)SelectedTipoExtrato != 2) + { + string text12 = ""; + foreach (ClienteEndereco endereco3 in documento.Controle.Cliente.Enderecos) + { + text12 = text12 + "
" + ((EnderecoBase)endereco3).Endereco + ", " + ((EnderecoBase)endereco3).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco3).Complemento) ? "" : (((EnderecoBase)endereco3).Complemento + ", ")) + ((EnderecoBase)endereco3).Bairro + " - " + ((EnderecoBase)endereco3).Cidade + " - " + ((EnderecoBase)endereco3).Estado + " - " + ((EnderecoBase)endereco3).Cep; + } + html = html + "
"; + } + color++; + html += ""; + } + if (documento.Controle.Cliente.Enderecos != null && (int)SelectedTipoExtrato != 2 && documento.Controle.Cliente.Emails == null && ExtratoResumido) + { + string text13 = ""; + foreach (ClienteEndereco endereco4 in documento.Controle.Cliente.Enderecos) + { + text13 = text13 + "
" + ((EnderecoBase)endereco4).Endereco + ", " + ((EnderecoBase)endereco4).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco4).Complemento) ? "" : (((EnderecoBase)endereco4).Complemento + ", ")) + ((EnderecoBase)endereco4).Bairro + " - " + ((EnderecoBase)endereco4).Cidade + " - " + ((EnderecoBase)endereco4).Estado + " - " + ((EnderecoBase)endereco4).Cep; + } + html = html + "
"; + } + if (documento.Controle.Cliente.Contatos != null && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + string text14 = ""; + foreach (MaisContato contato2 in documento.Controle.Cliente.Contatos) + { + string[] obj12 = new string[15] + { + text14, + "
NOME: ", + contato2.Nome, + (!string.IsNullOrWhiteSpace(contato2.Documento)) ? (", DOCUMENTO: " + contato2.Documento) : "", + contato2.Nascimento.HasValue ? (", NASCIMENTO: " + contato2.Nascimento?.ToShortDateString()) : "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + object obj13; + if (!contato2.Parentesco.HasValue) + { + obj13 = ""; + } + else + { + Parentesco? parentesco = contato2.Parentesco; + object obj14; + if (!parentesco.HasValue) + { + obj14 = null; + } + else + { + Parentesco valueOrDefault2 = parentesco.GetValueOrDefault(); + obj14 = ((object)(Parentesco)(ref valueOrDefault2)).ToString().ToUpper(); + } + obj13 = ", PARENTESCO: " + (string?)obj14; + } + obj12[5] = (string)obj13; + obj12[6] = ((!string.IsNullOrWhiteSpace(contato2.Banco) || !string.IsNullOrWhiteSpace(contato2.Agencia) || !string.IsNullOrWhiteSpace(contato2.Conta)) ? "
" : ""); + obj12[7] = ((!string.IsNullOrWhiteSpace(contato2.Banco)) ? ("BANCO: " + contato2.Banco) : ""); + obj12[8] = ((!string.IsNullOrWhiteSpace(contato2.Agencia)) ? (((!string.IsNullOrWhiteSpace(contato2.Banco)) ? ", AGÊNCIA: " : "AGÊNCIA: ") + contato2.Agencia) : ""); + obj12[9] = ((!string.IsNullOrWhiteSpace(contato2.Conta)) ? (((!string.IsNullOrWhiteSpace(contato2.Banco) || !string.IsNullOrWhiteSpace(contato2.Agencia)) ? ", CONTA: " : "CONTA: ") + contato2.Conta) : ""); + obj12[10] = ((contato2.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone)) || !string.IsNullOrWhiteSpace(contato2.Email)) ? "
" : ""); + object obj15; + if (!contato2.Tipo.HasValue) + { + obj15 = ""; + } + else + { + TipoTelefone? tipo = contato2.Tipo; + object obj16; + if (!tipo.HasValue) + { + obj16 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj16 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj15 = "TIPO DO TELEFONE: " + (string?)obj16; + } + obj12[11] = (string)obj15; + obj12[12] = ((!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone)) ? ((contato2.Tipo.HasValue ? ", TELEFONE: (" : "TELEFONE: (") + contato2.Prefixo + ") " + contato2.Telefone) : ""); + obj12[13] = ((!string.IsNullOrWhiteSpace(contato2.Email)) ? (((contato2.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone))) ? ", EMAIL: " : "EMAIL: ") + contato2.Email) : ""); + obj12[14] = "
"; + text14 = string.Concat(obj12); + } + html = html + "
"; + } + if (documento.Controle.Cliente.Enderecos != null && !ExtratoResumido) + { + string text15 = ""; + foreach (ClienteEndereco endereco5 in documento.Controle.Cliente.Enderecos) + { + text15 = text15 + "
" + ((EnderecoBase)endereco5).Endereco + ", " + ((EnderecoBase)endereco5).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco5).Complemento) ? "" : (((EnderecoBase)endereco5).Complemento + ", ")) + ((EnderecoBase)endereco5).Bairro + " - " + ((EnderecoBase)endereco5).Cidade + " - " + ((EnderecoBase)endereco5).Estado + " - " + ((EnderecoBase)endereco5).Cep; + } + html = html + "
"; + } + if (ObsCliente && ClienteVisibility && ObsClienteEnabled && !string.IsNullOrWhiteSpace(documento.Controle.Cliente.Observacao) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + documento.Controle.Cliente.Observacao = "
" + documento.Controle.Cliente.Observacao.Replace("\r\n", "
"); + html = html + "
"; + } + if (!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Pasta) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + html += "

CLIENTE: " + documento.Controle.Cliente.Nome + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

" + text9 + ": " + documento.Controle.Cliente.Nascimento?.ToShortDateString() + "

FALECIDO: " + (documento.Controle.Cliente.Falecido ? "SIM" : "NÃO") + "

RAMO DE ATIVIDADE: " + documento.Controle.Cliente.Atividade.Nome + "

"; + if (pessoaFisica2) + { + html = html + "ESTADO CIVIL: " + (documento.Controle.Cliente.EstadoCivil.HasValue ? documento.Controle.Cliente.EstadoCivil.ToString().ToUpper() : "-") + "

SEXO: " + (documento.Controle.Cliente.Sexo.HasValue ? documento.Controle.Cliente.Sexo.ToString().ToUpper() : "-") + "

"; + } + html = html + "

CLIENTE DESDE: " + ((!documento.Controle.Cliente.ClienteDesde.HasValue) ? "-" : documento.Controle.Cliente.ClienteDesde?.ToShortDateString()) + "

PROFISSÃO: " + documento.Controle.Cliente.Profissao.Nome + "

HABILITAÇÃO: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Habilitacao)) ? documento.Controle.Cliente.Habilitacao : "-") + "

CATEGORIA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.CategoriaHabilitacao)) ? documento.Controle.Cliente.CategoriaHabilitacao : "-") + "

1ª HAB.: " + ((!documento.Controle.Cliente.PrimeiraHabilitacao.HasValue) ? "-" : documento.Controle.Cliente.PrimeiraHabilitacao?.ToShortDateString()) + "

VENCIMENTO: " + ((!documento.Controle.Cliente.VencimentoHabilitacao.HasValue) ? "-" : documento.Controle.Cliente.VencimentoHabilitacao?.ToShortDateString()) + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

ORGÃO EMISSOR: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Emissor)) ? documento.Controle.Cliente.Emissor : "-") + "

ESTADO EMISSOR: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.EstadoEmissor)) ? documento.Controle.Cliente.EstadoEmissor : "-") + "

EXPEDIÇÃO: " + ((!documento.Controle.Cliente.Expedicao.HasValue) ? "-" : documento.Controle.Cliente.Expedicao?.ToShortDateString()) + "

BANCO: " + ((documento.Controle.Cliente.Banco != null) ? documento.Controle.Cliente.Banco.Nome : "-") + "

AGÊNCIA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Agencia)) ? documento.Controle.Cliente.Agencia : "-") + "

CONTA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Conta)) ? documento.Controle.Cliente.Conta : "-") + "

TIPO: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.TipoConta)) ? documento.Controle.Cliente.TipoConta : "-") + "

CONTATOS: " + text10 + "

EMAILS: " + text11 + "

ENDEREÇOS: " + text12 + "

ENDEREÇOS: " + text13 + "

MAIS CONTATOS: " + text14 + "

ENDEREÇOS: " + text15 + "

OBSERVAÇÕES: " + documento.Controle.Cliente.Observacao + "

PASTA: " + documento.Controle.Cliente.Pasta + "

"; + if (!primeiro) + { + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + } + } + else + { + html = html + "

CLIENTE: " + documento.Controle.Cliente.Nome + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

"; + } + if ((int)SelectedTipoExtrato == 0) + { + return; + } + color = 0; + html = html + "
"; + if (!documento.NegocioCorretora.HasValue) + { + documento.NegocioCorretora = (NegocioCorretora)(((int)documento.Situacao == 2 && documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); + } + if (ComissaoDocumento && ComissaoDocumentoEnabled) + { + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + else + { + html = html + ""; + } + } + else if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + html = html + ""; + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html += ""; + string text16 = ""; + if (documento.Estipulante1 != null) + { + text16 = text16 + documento.Estipulante1.Nome + ", "; + } + if (documento.Estipulante2 != null) + { + text16 = text16 + documento.Estipulante2.Nome + ", "; + } + if (documento.Estipulante3 != null) + { + text16 = text16 + documento.Estipulante3.Nome + ", "; + } + if (documento.Estipulante4 != null) + { + text16 = text16 + documento.Estipulante4.Nome + ", "; + } + if (documento.Estipulante5 != null) + { + text16 = text16 + documento.Estipulante5.Nome + ", "; + } + if (!string.IsNullOrWhiteSpace(text16)) + { + int startIndex3 = text16.LastIndexOf(", ", StringComparison.Ordinal); + text16 = text16.Remove(startIndex3, 2).Insert(startIndex3, "."); + } + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + if (documento.Controle.SeguradoraAnterior != null && !ExtratoResumido) + { + html = html + ""; + } + } + else + { + html = html + ""; + } + html += "

RAMO: " + documento.Controle.Ramo.Nome + "

VIGÊNCIA INICIAL: " + documento.Vigencia1.ToShortDateString() + "

VIGÊNCIA FINAL: " + ((!documento.Vigencia2.HasValue) ? "-" : documento.Vigencia2?.ToShortDateString()) + "

CONTRATO: " + (string.IsNullOrWhiteSpace(documento.Apolice) ? "-" : documento.Apolice) + "

POSSUI ENDOSSO? " + (documento.TemEndosso ? "SIM" : "NÃO") + "

ADITAMENTO: " + ((!string.IsNullOrWhiteSpace(documento.Endosso)) ? documento.Endosso : ((configEndosso && documento.Controle.Documentos.Where((Documento x) => !x.Excluido && x.Ordem != 0).ToList().Count > 0) ? documento.Controle.Documentos.Last((Documento x) => !x.Excluido && x.Ordem != 0).Endosso : "-")) + "

APÓLICE ANTERIOR: " + (string.IsNullOrWhiteSpace(documento.ApoliceAnterior) ? "-" : documento.ApoliceAnterior) + "

BANCO: " + ((documento.Banco == null) ? "-" : documento.Banco.Nome) + "

AGÊNCIA: " + (string.IsNullOrWhiteSpace(documento.Agencia) ? "-" : documento.Agencia) + "

CONTA: " + (string.IsNullOrWhiteSpace(documento.Conta) ? "-" : documento.Conta) + "

NUMERO CARTÃO: " + (string.IsNullOrWhiteSpace(documento.NumeroCartao) ? "-" : documento.NumeroCartao) + "

VENCIMENTO: " + (string.IsNullOrWhiteSpace(documento.VencimentoCartao) ? "-" : documento.VencimentoCartao) + "

BANDEIRA: " + ((!documento.Bandeira.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)documento.Bandeira)) + "

TITULAR/PROPONENTE: " + (string.IsNullOrWhiteSpace(documento.NomeProponente) ? "-" : documento.NomeProponente) + "

NEGÓCIO CORRETORA: " + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "

STATUS DO SEGURO: " + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "

COMISSÃO: " + $"{documento.Comissao}%" + "

COMISSÃO: " + $"{documento.Comissao}%" + "

NEGÓCIO CORRETORA: " + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "

STATUS DO SEGURO: " + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "

VENDEDOR: " + ((documento.VendedorPrincipal == null) ? "-" : documento.VendedorPrincipal.Nome) + "

REMESSA: " + ((!documento.Remessa.HasValue) ? "-" : documento.Remessa?.ToShortDateString()) + "

EMISSÃO: " + ((!documento.Emissao.HasValue) ? "-" : documento.Emissao?.ToShortDateString()) + "

ESTIPULANTE(S): " + (string.IsNullOrWhiteSpace(text16) ? "-" : text16) + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

APÓLICE SINISTRADA: " + (documento.Sinistro ? "SIM" : "NÃO") + "

SEGURADORA ANTERIOR: " + documento.Controle.SeguradoraAnterior.Nome + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

"; + if (!ExtratoResumido && (PremioParcela || ObsApoliceEnabled)) + { + html += ""; + if (PremioParcela) + { + html = html + ""; + html += ""; + html += "

PRÊMIO LÍQUIDO:
" + documento.PremioLiquido.ToString("c") + "

ADICIONAL:
" + documento.PremioAdicional.ToString("c") + "

CUSTO APÓLICE:
" + documento.Custo.ToString("c") + "

I.O.F.:
" + documento.Iof.ToString("c") + "

PRÊMIO TOTAL:
" + documento.PremioTotal.ToString("c") + "


"; + ObservableCollection parcelas = documento.Parcelas; + if (parcelas != null && parcelas.Count > 0) + { + html += ""; + foreach (Parcela parcela in documento.Parcelas) + { + html = html + ""; + } + } + } + if (ObsApolice && ObsApoliceEnabled) + { + html = html + ""; + } + html += "

PARCELA

VENCIMENTO

VALOR

FORMA DE PAGAMENTO

" + parcela.NumeroParcela + "

" + parcela.Vencimento.ToShortDateString() + "

" + $"{parcela.Valor:c}" + "

" + ValidationHelper.GetDescription((Enum)(object)documento.FormaPagamento) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(documento.Observacao) ? "-" : documento.Observacao) + "

"; + } + if (PerfilCondutor && PerfilVisibility && ((DomainBase)documento.Controle.Ramo).Id == 5 && PerfilCondutorEnabled) + { + List list4 = source.ToList(); + foreach (Perfil item5 in list4) + { + color = 0; + if (!string.IsNullOrEmpty(item5.Nome)) + { + html = html + "

" + $"CONDUTOR {list4.IndexOf(item5) + 1}: " + "" + item5.Nome + "

CPF: " + (string.IsNullOrWhiteSpace(item5.Cpf) ? "-" : item5.Cpf) + "

NASCIMENTO: " + ((!item5.Nascimento.HasValue) ? "-" : item5.Nascimento?.ToShortDateString()) + "

ESTADO CIVIL: " + ((!item5.EstadoCivil.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.EstadoCivil)) + "

SEXO: " + ((!item5.Sexo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.Sexo)) + "

RELAÇÃO SEGURADO/CONDUTOR: " + ValidationHelper.GetDescription((Enum)(object)item5.Relacao) + "

HABILITAÇÃO: " + (string.IsNullOrWhiteSpace(item5.Habilitacao) ? "-" : item5.Habilitacao) + "

TEMPO DE HABILITAÇÃO: " + ((!item5.TempoHabilitacao.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.TempoHabilitacao)) + "

QUATIDADE DE VEÍCULOS: " + ((!item5.VeiculoResidencia.HasValue) ? "-" : item5.VeiculoResidencia.Value.ToString()) + "

GARAGEM NA RESIDÊNCIA: " + ((!item5.GaragemResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemResidencia)) + "

GARAGEM NO TRABALHO: " + ((!item5.GaragemTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemTrabalho)) + "

GARAGEM NO ESTUDO: " + ((!item5.GaragemEstudo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemEstudo)) + "

TIPO DE RESIDÊNCIA: " + ((!item5.TipoResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.TipoResidencia)) + "

QUILOMETRAGEM MENSAL: " + (string.IsNullOrWhiteSpace(item5.KmMensal) ? "-" : item5.KmMensal) + "

DISTÂNCIA ATÉ O TRABALHO: " + ((!item5.DistanciaResidenciaTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.DistanciaResidenciaTrabalho)) + "

USO PROFISSIONAL: " + ((item5.UsoProfissional.HasValue && item5.UsoProfissional.Value) ? "SIM" : "NÃO") + "

USO POR DEPENDENTES: " + ((!item5.UsoDependentes.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.UsoDependentes)) + "

OCUPAÇÃO: " + ((!item5.Ocupacao.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.Ocupacao)) + "

SEGURO VIDA: " + ((item5.SeguroVida.HasValue && item5.SeguroVida.Value) ? "SIM" : "NÃO") + "

ISENÇÃO DE IMPOSTOS: " + ((item5.Isencao.HasValue && item5.Isencao.Value) ? "SIM" : "NÃO") + "

ANTIFURTO: " + (item5.AntiFurto.HasValue ? ValidationHelper.GetDescription((Enum)(object)item5.AntiFurto) : "") + "

COBERTURA ESTENDIDA PARA RESIDENTES HABILITADOS: " + ((item5.EstenderCobertura.HasValue && item5.EstenderCobertura.Value) ? "SIM" : "NÃO") + "

"; + } + } + } + List itens2 = itensDocumentos.ToList(); + if (itens2.Count == 0) + { + html += "

ESTA APÓLICE NÃO POSSUI ITENS

"; + } + else + { + color = 0; + foreach (Item item2 in itens2) + { + if (item2.Sinistros.Count > 0) + { + Item val3 = item2; + val3.Sinistros = await new SinistroServico().BuscarControles(((DomainBase)item2).Id); + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + html += (((int)SelectedTipoExtrato != 2 || itens2.IndexOf(item2) == 0) ? "
" : ""); + html += ""; + html += ""; + html += ""; + if ((int)SelectedTipoExtrato == 2) + { + html = html + ""; + } + else + { + switch (((DomainBase)documento.Controle.Ramo).Id) + { + case 1L: + case 2L: + case 3L: + case 15L: + case 18L: + { + Item val3 = item2; + val3.Patrimonial = await new ItemServico().BuscaPatrimonial(((DomainBase)item2).Id); + html = html + ""; + break; + } + case 5L: + case 37L: + { + Item val3 = item2; + val3.Auto = await new ItemServico().BuscaAuto(((DomainBase)item2).Id); + string[] obj17 = new string[26] + { + html, + ""; + html = string.Concat(obj17); + break; + } + default: + html = html + ""; + break; + } + } + if (item2.Sinistros.Count > 0) + { + Item obj18 = item2; + DateTime? obj19; + if (obj18 == null) + { + obj19 = null; + } + else + { + IList sinistros3 = obj18.Sinistros; + if (sinistros3 == null) + { + obj19 = null; + } + else + { + ControleSinistro? obj20 = sinistros3.LastOrDefault(); + if (obj20 == null) + { + obj19 = null; + } + else + { + List sinistros4 = obj20.Sinistros; + if (sinistros4 == null) + { + obj19 = null; + } + else + { + Sinistro? obj21 = sinistros4.LastOrDefault(); + obj19 = ((obj21 != null) ? obj21.DataReclamacao : null); + } + } + } + } + DateTime? dateTime2 = obj19; + string text17 = (dateTime2.HasValue ? dateTime2.Value.ToShortDateString() : "-"); + string[] obj22 = new string[18] + { + html, ""; + html = string.Concat(obj22); + } + html += ""; + if ((int)SelectedTipoExtrato != 2) + { + string[] obj31 = new string[10] { html, ""; + html = string.Concat(obj31); + long id = ((DomainBase)documento.Controle.Ramo).Id; + long num4 = id - 1; + if ((ulong)num4 <= 58uL) + { + switch (num4) + { + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + case 4L: + case 36L: + { + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + string[] array2 = new string[30]; + array2[0] = html; + array2[1] = ""; + html = string.Concat(array2); + break; + } + case 5L: + case 6L: + case 8L: + case 9L: + case 52L: + { + Item val3 = item2; + val3.Vida = await new ItemServico().BuscaVida(((DomainBase)item2).Id); + if (!item2.Sinistrado || !BeneficiariosItens || !BeneficiariosItensEnabled) + { + break; + } + html = html + ""; + break; + } + case 3L: + case 7L: + case 15L: + case 16L: + case 18L: + case 22L: + case 23L: + case 25L: + case 27L: + case 30L: + case 32L: + case 38L: + case 40L: + case 43L: + case 48L: + case 58L: + { + Item val3 = item2; + val3.RiscosDiversos = await new ItemServico().BuscaRiscosDiversos(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 12L: + { + Item val3 = item2; + val3.Aeronautico = await new ItemServico().BuscaAeronautico(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 19L: + { + Item val3 = item2; + val3.Granizo = await new ItemServico().BuscaGranizo(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + } + } + } + html += "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

" + $"ITEM {item2.Ordem}: " + "" + ((EnderecoBase)item2.Patrimonial).Endereco + ", " + ((EnderecoBase)item2.Patrimonial).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)item2.Patrimonial).Complemento) ? "" : (((EnderecoBase)item2.Patrimonial).Complemento + ", ")) + ((EnderecoBase)item2.Patrimonial).Bairro + " - " + ((EnderecoBase)item2.Patrimonial).Cidade + " - " + ((EnderecoBase)item2.Patrimonial).Estado + " - " + ((EnderecoBase)item2.Patrimonial).Cep + "

", + $"ITEM {item2.Ordem}: ", + "
", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + Fabricante fabricante2 = item2.Auto.Fabricante; + obj17[6] = ((fabricante2 != null) ? fabricante2.Descricao : null); + obj17[7] = " "; + obj17[8] = item2.Auto.Modelo; + obj17[9] = " ("; + obj17[10] = item2.Auto.AnoFabricacao; + obj17[11] = "/"; + obj17[12] = item2.Auto.AnoModelo; + obj17[13] = ")
PLACA: "; + obj17[14] = item2.Auto.Placa; + obj17[15] = ", CHASSI: "; + obj17[16] = item2.Auto.Chassi; + obj17[17] = "
C.I.: "; + obj17[18] = item2.Auto.Ci; + obj17[19] = ", RENAVAM: "; + obj17[20] = item2.Auto.Renavam; + obj17[21] = ", CEP PERNOITE: "; + obj17[22] = item2.Auto.CepPernoite; + obj17[23] = "
FINANCIADO: "; + obj17[24] = (item2.Auto.Financiado.GetValueOrDefault() ? "SIM" : "NÃO"); + obj17[25] = "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

QTDE SINISTRO(S): " + item2.Sinistros.Count + "

SINISTRO STATUS: "; + Item obj23 = item2; + object obj24; + if (obj23 == null) + { + obj24 = null; + } + else + { + IList sinistros5 = obj23.Sinistros; + if (sinistros5 == null) + { + obj24 = null; + } + else + { + ControleSinistro? obj25 = sinistros5.LastOrDefault(); + if (obj25 == null) + { + obj24 = null; + } + else + { + List sinistros6 = obj25.Sinistros; + if (sinistros6 == null) + { + obj24 = null; + } + else + { + Sinistro? obj26 = sinistros6.LastOrDefault(); + obj24 = ((obj26 != null) ? ValidationHelper.GetDescription((Enum)(object)obj26.StatusSinistro) : null); + } + } + } + } + obj22[4] = (string)obj24; + obj22[5] = "

DATA: "; + obj22[8] = text17; + obj22[9] = "

VALOR: "; + Item obj27 = item2; + object obj28; + if (obj27 == null) + { + obj28 = null; + } + else + { + IList sinistros7 = obj27.Sinistros; + if (sinistros7 == null) + { + obj28 = null; + } + else + { + ControleSinistro? obj29 = sinistros7.LastOrDefault(); + if (obj29 == null) + { + obj28 = null; + } + else + { + List sinistros8 = obj29.Sinistros; + if (sinistros8 == null) + { + obj28 = null; + } + else + { + Sinistro? obj30 = sinistros8.LastOrDefault(); + obj28 = ((obj30 != null) ? ValidationHelper.ToCurrency(obj30.Valor, "pt-BR") : null); + } + } + } + } + obj22[12] = (string)obj28; + obj22[13] = "

QTDE SINISTRO(S): "; + obj22[16] = item2.Sinistros.Count.ToString(); + obj22[17] = "

STATUS: "; + obj31[4] = (string.IsNullOrWhiteSpace(item2.Status) ? item2.StatusInclusao : item2.Status); + obj31[5] = "

ATIVO: "; + obj31[8] = ((!item2.Substituido.HasValue) ? "SIM" : "NÃO"); + obj31[9] = "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Patrimonial.Item.Observacao) ? "-" : item2.Patrimonial.Item.Observacao) + "

BENS E INFORMAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Patrimonial.Bens) ? "-" : item2.Patrimonial.Bens) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Auto.Observacao) ? "-" : item2.Auto.Observacao) + "

COBERTURA PADRÃO: "; + TipoCobertura? tipoCobertura = item2.Auto.TipoCobertura; + array2[4] = (tipoCobertura.HasValue ? ValidationHelper.GetDescription((Enum)(object)tipoCobertura.GetValueOrDefault()) : null); + array2[5] = "

BÔNUS: "; + array2[8] = item2.Auto.Bonus.ToString(); + array2[9] = "

REGIÃO DE CIRCULAÇÃO: "; + array2[12] = (string.IsNullOrWhiteSpace(item2.Auto.RegiaoCirculacao) ? "-" : item2.Auto.RegiaoCirculacao); + array2[13] = "

TABELA DE REFERÊNCIA: "; + TabelaReferencia? tabelaReferencia = item2.Auto.TabelaReferencia; + array2[16] = (tabelaReferencia.HasValue ? ValidationHelper.GetDescription((Enum)(object)tabelaReferencia.GetValueOrDefault()) : null); + array2[17] = "

% DE REFERÊNCIA: "; + array2[20] = $"{item2.Auto.PorcentagemReferencia}%"; + array2[21] = "

CÓDIGO FIPE: "; + array2[24] = (string.IsNullOrWhiteSpace(item2.Auto.Fipe) ? "-" : item2.Auto.Fipe); + array2[25] = "

COR DO VEÍCULO: "; + array2[28] = ((!item2.Auto.Cor.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item2.Auto.Cor)); + array2[29] = "

BENEFICIÁRIOS: "; + string text18 = ""; + foreach (ControleSinistro sinistro3 in item2.Sinistros) + { + if (sinistro3.Sinistros == null) + { + continue; + } + foreach (Sinistro sinistro4 in sinistro3.Sinistros) + { + if (!string.IsNullOrWhiteSpace(sinistro4.SinistroVida.Beneficiario)) + { + text18 = text18 + sinistro4.SinistroVida.Beneficiario + ", "; + } + } + } + if (!string.IsNullOrWhiteSpace(text18)) + { + int startIndex4 = text18.LastIndexOf(", ", StringComparison.Ordinal); + text18 = text18.Remove(startIndex4, 2).Insert(startIndex4, "."); + } + html = html + text18 + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.RiscosDiversos.Observacao) ? "-" : item2.RiscosDiversos.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Aeronautico.Observacao) ? "-" : item2.Aeronautico.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Granizo.Observacao) ? "-" : item2.Granizo.Observacao) + "

"; + if ((int)SelectedTipoExtrato != 2) + { + ObservableCollection observableCollection2 = await new ItemServico().BuscarCoberturasPorItemAsync(((DomainBase)item2).Id); + if (observableCollection2.Count > 0 && Coberturas) + { + html += "
"; + foreach (Cobertura item6 in observableCollection2) + { + html = html + ""; + } + html += "

COBERTURA

FRANQUIA

L.M.I.

PRÊMIO

" + item6.Observacao + "

" + $"{item6.Franquia:c}" + "

" + $"{item6.Lmi:c}" + "

" + $"{item6.Premio:c}" + "

"; + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + } + if ((int)SelectedTipoExtrato != 2) + { + color = 0; + } + } + } + } + } + sDocumento.Add(((DomainBase)documento.Controle).Id); + primeiro = false; + } + } + if (Prospeccoes != null && Prospeccoes.Count > 0) + { + foreach (Prospeccao prospecco in Prospeccoes) + { + int num5 = 0; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + html += "

"; + if ((int)SelectedTipoExtrato == 0) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + prospecco.Nome; + } + html = html + title + "


"; + html += ""; + if (ExtratoResumido) + { + html = html + ""; + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + string text19 = ""; + if (prospecco.Telefone1 != null) + { + text19 = text19 + "
(" + prospecco.Prefixo1 + ") " + prospecco.Telefone1; + } + if (prospecco.Telefone2 != null) + { + text19 = text19 + "
(" + prospecco.Prefixo2 + ") " + prospecco.Telefone2; + } + html = html + "
"; + string text20 = ""; + if (prospecco.Email != null) + { + text20 = "
" + prospecco.Email; + } + html = html + "
"; + } + html += "

CLIENTE: " + prospecco.Nome + "

CPF/CNPJ: " + prospecco.Documento + "

CONTATOS: " + (string.IsNullOrEmpty(text19) ? "-" : text19) + "

EMAILS: " + (string.IsNullOrEmpty(text20) ? "-" : text20) + "

"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + if ((int)SelectedTipoExtrato == 0) + { + return; + } + num5 = 0; + html = html + "
"; + html = html + ""; + html += "

VIGÊNCIA FINAL: " + ((!prospecco.VigenciaFinal.HasValue) ? "-" : prospecco.VigenciaFinal?.ToShortDateString()) + "

VENDEDOR: " + ((prospecco.Vendedor == null) ? "-" : prospecco.Vendedor.Nome) + "

"; + continue; + } + string text21 = "NASCIMENTO"; + html = html + ""; + if ((prospecco.Telefone1 != null || prospecco.Email != null) && (int)SelectedTipoExtrato != 2) + { + html += ""; + if (prospecco.Telefone1 != null) + { + string text22 = ""; + text22 = text22 + "
(" + prospecco.Prefixo1 + ") " + prospecco.Telefone1; + if (prospecco.Telefone2 != null) + { + text22 = text22 + "
(" + prospecco.Prefixo2 + ") " + prospecco.Telefone2; + } + html = html + "
"; + } + if (prospecco.Email != null && !ExtratoResumido) + { + string text23 = ""; + text23 = text23 + "
" + prospecco.Email; + html = html + "
"; + } + html += ""; + } + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "" : ""); + if ((int)SelectedTipoExtrato == 0) + { + return; + } + num5 = 0; + html = html + "

CLIENTE: " + prospecco.Nome + "

CPF/CNPJ: " + prospecco.Documento + "

" + text21 + ": " + prospecco.Nascimento?.ToShortDateString() + "

CONTATOS: " + text22 + "

EMAILS: " + text23 + "

"; + html = html + ""; + html += "

VIGÊNCIA FINAL: " + ((!prospecco.VigenciaFinal.HasValue) ? "-" : prospecco.VigenciaFinal?.ToShortDateString()) + "

VENDEDOR: " + ((prospecco.Vendedor == null) ? "-" : prospecco.Vendedor.Nome) + "

"; + } + } + DateTime networkTime2 = Funcoes.GetNetworkTime(); + html = html + "

" + Recursos.Usuario.Nome + " - " + networkTime2.Date.ToShortDateString() + "
"; + string tempPath2 = Path.GetTempPath(); + string text24 = $"{tempPath2}{(object)(TipoExtrato)0}_{networkTime2:ddMMyyyyhhmmss}.html"; + if (pdf) + { + text24 = $"{tempPath2}{(object)(TipoExtrato)0}_{networkTime2:ddMMyyyyhhmmss}.pdf"; + byte[] bytes2 = ((HtmlToPdfConverter)new NRecoHtmlToPdfConverter()).GeneratePdf(html); + File.WriteAllBytes(text24, bytes2); + } + else + { + StreamWriter streamWriter2 = new StreamWriter(text24, append: true, Encoding.UTF8); + streamWriter2.Write(html); + streamWriter2.Close(); + } + Process.Start(text24); + if (Documentos != null && Documentos.Count > 1) + { + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Documentos == null) ? "" : ((Documentos.Count > 1) ? $"DE {Documentos.Count} DOCUMENTOS" : $"DO DOCUMENTO {((DomainBase)Documentos[0]).Id}")), 0L, (TipoTela)23, "IDS DOS DOCUMENTOS:\n" + string.Join("\n", Documentos.Select((Documento x) => ((DomainBase)x).Id)) + GerarOpcoes()); + } + if (Prospeccoes != null && Prospeccoes.Count > 1) + { + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Prospeccoes == null) ? "" : ((Prospeccoes.Count > 1) ? $"DE {Prospeccoes.Count} PROSPECÇÕES" : $"DA PROSPÇÃO{((DomainBase)Prospeccoes[0]).Id}")), 0L, (TipoTela)23, "IDS DOS DOCUMENTOS:\n" + string.Join("\n", Prospeccoes.Select((Prospeccao x) => ((DomainBase)x).Id)) + GerarOpcoes()); + } + Documentos = null; + Clientes = null; + Prospeccoes = null; + } + } + + public string GerarOpcoes() + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + string text = ""; + if (ClienteVisibility && ObsCliente && ObsClienteEnabled) + { + text += "\nOBSERVAÇÕES DO CLIENTE"; + } + if ((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) + { + text += "\nSEPARAR CLIENTES POR PÁGINA"; + } + if (DocumentoVisibility) + { + if (ComissaoDocumentoEnabled && ComissaoDocumento) + { + text += "\nCOMISSÕES DO DOCUMENTO"; + } + if (ObsApoliceEnabled && ObsApolice) + { + text += "\nOBSERVAÇÕES DA APÓLICE"; + } + if ((int)SegurosVigentesVisibility == 0 && SegurosVigentes) + { + text += "\nAPENAS SEGUROS VIGENTES"; + } + } + if (ItemVisibility) + { + if ((int)SelecionarItensVisibility == 0 && SelecionarItens) + { + text += "\nSELECIONAR ITENS"; + } + if (BeneficiariosItensEnabled && BeneficiariosItens) + { + text += "\nBENEFICIÁRIOS DOS ITENS"; + } + if (ObsItemEnabled && ObsItem) + { + text += "\nOBSERVAÇÕES DO ITEM"; + } + if (SepararPaginaEnabled && SepararPagina) + { + text += "\nSEPARAR ITENS POR PÁGINA"; + } + } + if (PerfilCondutor && PerfilVisibility && PerfilCondutorEnabled) + { + text += "\nPERFIL DO CONDUTOR"; + } + if (string.IsNullOrWhiteSpace(text)) + { + return ""; + } + return "\n\nOPÇÕES:" + text; + } + + public async Task PrepararExtrato(List clientes, List documentos, List prospeccoes, Relatorio? tipoRelatorio = null, List selecionadosDoc = null, List selecionadosPros = null, bool pdf = false) + { + Carregando = true; + if (tipoRelatorio == (Relatorio?)0 || (int)tipoRelatorio.GetValueOrDefault() == 1) + { + if (clientes == null || clientes.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM CLIENTE"); + Carregando = false; + return; + } + if (clientes.Count > 200 && !(await ShowMessage("A SELEÇÃO DE MUITOS EXTRATOS PODE DEMORAR MAIS DE 30 MINUTOS! CONTINUAR?", "SIM", "NÃO"))) + { + Carregando = false; + return; + } + List listaCli = new List(); + foreach (ClientesAtivosInativos item2 in clientes.Where((ClientesAtivosInativos x) => x.Selecionado)) + { + Cliente cli = await new ClienteServico().BuscarCliente(item2.Id); + Cliente val = cli; + val.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)cli).Id); + val = cli; + val.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)cli).Id); + val = cli; + val.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)cli).Id); + val = cli; + val.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)cli).Id); + val = cli; + val.Vinculos = await _clienteServico.BuscarVinculosAsync(((DomainBase)cli).Id); + listaCli.Add(cli); + } + Clientes = listaCli; + goto IL_16a4; + } + if ((documentos == null || documentos.Count == 0) && (prospeccoes == null || prospeccoes.Count == 0)) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO OU PROSPECÇÃO"); + Carregando = false; + return; + } + if (documentos == null || documentos.Count <= 200) + { + if (prospeccoes == null || prospeccoes.Count <= 200) + { + goto IL_0741; + } + } + if (!(await ShowMessage("A SELEÇÃO DE MUITOS EXTRATOS PODE DEMORAR MAIS DE 30 MINUTOS! CONTINUAR?", "SIM", "NÃO"))) + { + Carregando = false; + return; + } + goto IL_0741; + IL_16a4: + if ((int)SegurosVigentesVisibility == 0 && SegurosVigentes) + { + Documentos = Documentos.Where((Documento x) => (x.Vigencia2 > Funcoes.GetNetworkTime().Date.AddDays(-5.0) || !x.Vigencia2.HasValue) && (int)x.Situacao != 7).ToList(); + } + await Gerar(tipoRelatorio, pdf); + Carregando = false; + return; + IL_0741: + TipoExtrato selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 2: + { + List listaEndossos = new List(); + ApoliceServico apoliceServico = new ApoliceServico(); + long id = ((DomainBase)documentos.First().Controle.Cliente).Id; + FiltroStatusDocumento statusSelecionado = MainViewModel.StatusSelecionado; + Documentos = new List(await apoliceServico.BuscarApolicesAsync(id, statusSelecionado, await VerificaVinculoVendedor(Recursos.Usuario))); + foreach (Documento documento in Documentos) + { + foreach (Documento documento2 in documento.Controle.Documentos) + { + if (documento2.Tipo == 1) + { + listaEndossos.Add(documento2); + documento.TemEndosso = true; + } + } + } + Documentos.AddRange(listaEndossos); + break; + } + case 1: + if ((selecionadosDoc == null || selecionadosDoc.Count == 0) && (selecionadosPros == null || selecionadosPros.Count == 0)) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + Carregando = false; + return; + } + Documentos = new List(); + Prospeccoes = new List(); + if (selecionadosDoc != null) + { + foreach (long item3 in selecionadosDoc) + { + Documento doc = await new ApoliceServico().BuscarApoliceAsync(item3, itens: false, sinistrosPorControle: true); + List listDoc = ((SomenteEndossos && doc.Ordem != 1) ? new List() : new List { doc }); + if (SomenteEndossos) + { + IEnumerable enumerable = doc.Controle.Documentos.Where((Documento x) => !x.Excluido && x.Ordem != 0 && !listDoc.Any((Documento y) => ((DomainBase)y).Id == ((DomainBase)x).Id)); + foreach (Documento item4 in enumerable) + { + item4.Sinistro = doc.Sinistro; + } + listDoc.AddRange(enumerable); + } + else if (Endossos) + { + IEnumerable enumerable2 = doc.Controle.Documentos.Where((Documento x) => ((DomainBase)x).Id != ((DomainBase)doc).Id && !x.Excluido); + foreach (Documento item5 in enumerable2) + { + item5.Sinistro = doc.Sinistro; + } + listDoc.AddRange(enumerable2); + } + if (doc.Controle.Documentos.Any((Documento x) => ((DomainBase)x).Id != ((DomainBase)doc).Id && !x.Excluido && x.Ordem > doc.Ordem)) + { + doc.TemEndosso = true; + } + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 31) && doc.TemEndosso) + { + doc.PremioTotal = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioTotal); + doc.Iof = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.Iof); + doc.Custo = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.Custo); + doc.PremioLiquido = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioLiquido); + doc.PremioAdicional = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioAdicional); + } + Documentos.AddRange(listDoc.OrderBy((Documento x) => x.Ordem).ToList()); + } + } + if (selecionadosPros != null) + { + foreach (long selecionadosPro in selecionadosPros) + { + Prospeccao item = await new ProspeccaoServico().BuscarProspeccao(selecionadosPro); + Prospeccoes.Add(item); + } + } + if ((int)SelecionarItensVisibility == 0 && SelecionarItens && Documentos != null && Documentos.Count > 0) + { + _itensSelecionados = (await ShowSelecionarItensDialog(((DomainBase)Documentos.First().Controle).Id)).Where((Item x) => x.Selecionado).ToList(); + } + if ((Documentos == null || Documentos.Count == 0) && (Prospeccoes == null || Prospeccoes.Count == 0)) + { + if (!SomenteEndossos) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO OU PROSPECÇÃO SELECIONADO"); + } + else + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM ENDOSSO OU PROSPECÇÃO SELECIONADO"); + } + Carregando = false; + return; + } + break; + case 0: + { + if (selecionadosDoc == null || selecionadosDoc.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + Carregando = false; + return; + } + List listaCli = new List(); + foreach (Documento documento3 in documentos) + { + Cliente cli = await new ClienteServico().BuscarCliente(((DomainBase)documento3.Controle.Cliente).Id); + Cliente val = cli; + val.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)cli).Id); + val = cli; + val.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)cli).Id); + val = cli; + val.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)cli).Id); + val = cli; + val.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)cli).Id); + val = cli; + val.Vinculos = await _clienteServico.BuscarVinculosAsync(((DomainBase)cli).Id); + listaCli.Add(cli); + } + Clientes = listaCli; + Prospeccoes = prospeccoes; + break; + } + } + goto IL_16a4; + } +} -- cgit v1.2.3