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 --- .../DialogPrintViewModel.cs | 176 + .../RelatorioViewModel.cs | 14605 +++++++++++++++++++ .../SinteticoViewModel.cs | 445 + 3 files changed, 15226 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Relatorios/DialogPrintViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Relatorios/RelatorioViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Relatorios/SinteticoViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Relatorios') diff --git a/Decompiler/Gestor.Application.ViewModels.Relatorios/DialogPrintViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Relatorios/DialogPrintViewModel.cs new file mode 100644 index 0000000..859ee64 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Relatorios/DialogPrintViewModel.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Configuracoes; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Relatorios; + +namespace Gestor.Application.ViewModels.Relatorios; + +public class DialogPrintViewModel : BaseViewModel +{ + private bool _carregando; + + private ConfiguracaoImpressao _configuracoes; + + private List _tamanhos = new List { "GRANDE", "MÉDIO", "PEQUENO" }; + + private bool _orientacaoImpressaoPortrait; + + private bool _orientacaoImpressaoLandscape; + + private string _tamanhoFonte = "PEQUENO"; + + private Relatorio _relatorio { get; set; } + + private Type _tipo { get; set; } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + OnPropertyChanged("Carregando"); + } + } + + public ConfiguracaoImpressao Configuracoes + { + get + { + return _configuracoes; + } + set + { + _configuracoes = value; + OnPropertyChanged("Configuracoes"); + } + } + + public List Tamanhos + { + get + { + return _tamanhos; + } + set + { + _tamanhos = value; + OnPropertyChanged("Tamanhos"); + } + } + + public bool OrientacaoImpressaoPortrait + { + get + { + return _orientacaoImpressaoPortrait; + } + set + { + _orientacaoImpressaoPortrait = value; + OnPropertyChanged("OrientacaoImpressaoPortrait"); + } + } + + public bool OrientacaoImpressaoLandscape + { + get + { + return _orientacaoImpressaoLandscape; + } + set + { + _orientacaoImpressaoLandscape = value; + OnPropertyChanged("OrientacaoImpressaoLandscape"); + } + } + + public bool OrientacaoImpressao { get; set; } + + public string TamanhoFonte + { + get + { + return _tamanhoFonte; + } + set + { + _tamanhoFonte = value; + if (!(value == "MÉDIO")) + { + if (!(value == "GRANDE")) + { + Configuracoes.TamanhoFonte = 7; + } + else + { + Configuracoes.TamanhoFonte = 5; + } + } + else + { + Configuracoes.TamanhoFonte = 6; + } + OnPropertyChanged("TamanhoFonte"); + } + } + + public DialogPrintViewModel(Relatorio relatorio, Type tipo) + { + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + _relatorio = relatorio; + _tipo = tipo; + } + + public async Task Carregar() + { + List list = await new ConfuguracoesServico().BuscarParametros(_relatorio); + if (list == null || list.Count == 0) + { + list = ((IEnumerable)_tipo.GetProperties(BindingFlags.Instance | BindingFlags.Public)).Select((Func)((PropertyInfo x) => new ParametrosRelatorio + { + Campo = x.Name, + Header = x.GetDescriptionAttribute(), + Tipo = x.GetTypeAttribute(), + Relatorio = _relatorio, + Width = 0, + Ordem = 0 + })).ToList(); + } + list.ForEach(delegate(ParametrosRelatorio x) + { + x.Selecionado = true; + }); + Configuracoes = new ConfiguracaoImpressao + { + TamanhoFonte = 7, + Campos = list, + OrientacaoImpressao = false + }; + } + + public void Selecionar() + { + if (Carregando) + { + return; + } + ConfiguracaoImpressao configuracoes = Configuracoes; + if (configuracoes != null) + { + configuracoes.Campos?.ForEach(delegate(ParametrosRelatorio x) + { + x.Selecionado = !x.Selecionado; + }); + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Relatorios/RelatorioViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Relatorios/RelatorioViewModel.cs new file mode 100644 index 0000000..60e86e3 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Relatorios/RelatorioViewModel.cs @@ -0,0 +1,14605 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Forms; +using System.Windows.Threading; +using Agger.Registro; +using ClosedXML.Excel; +using CsQuery.ExtensionMethods; +using Gestor.Application.Actions; +using Gestor.Application.Componentes; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Configuracoes; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.BI; +using Gestor.Application.Views.Ferramentas; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Relatorios; +using Gestor.Common.Converters; +using Gestor.Common.Helpers; +using Gestor.Common.Validation; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Aggilizador; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Relatorios.ApolicePendente; +using Gestor.Model.Domain.Relatorios.Auditoria; +using Gestor.Model.Domain.Relatorios.Classificacao; +using Gestor.Model.Domain.Relatorios.Cliente; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Relatorios.Comissao; +using Gestor.Model.Domain.Relatorios.CriticaApolice; +using Gestor.Model.Domain.Relatorios.EndossoCancelamento; +using Gestor.Model.Domain.Relatorios.ExtratoBaixado; +using Gestor.Model.Domain.Relatorios.FaturaPendente; +using Gestor.Model.Domain.Relatorios.Fechamento; +using Gestor.Model.Domain.Relatorios.Licenciamento; +using Gestor.Model.Domain.Relatorios.Log; +using Gestor.Model.Domain.Relatorios.LogsEnvio; +using Gestor.Model.Domain.Relatorios.MetaSeguradora; +using Gestor.Model.Domain.Relatorios.MetaVendedor; +using Gestor.Model.Domain.Relatorios.NotaFiscal; +using Gestor.Model.Domain.Relatorios.Pagamento; +using Gestor.Model.Domain.Relatorios.Pendente; +using Gestor.Model.Domain.Relatorios.Placa; +using Gestor.Model.Domain.Relatorios.PrevisaoPagamentoComissao; +using Gestor.Model.Domain.Relatorios.Producao; +using Gestor.Model.Domain.Relatorios.Renovacao; +using Gestor.Model.Domain.Relatorios.Sinistro; +using Gestor.Model.Domain.Relatorios.Tarefa; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +using MaterialDesignThemes.Wpf; + +namespace Gestor.Application.ViewModels.Relatorios; + +public class RelatorioViewModel : BaseSegurosViewModel +{ + private bool _alterandoFiltros; + + private readonly ApoliceServico _apoliceServico; + + private readonly ParcelaServico _parcelaServico; + + private readonly SinistroServico _sinistroServico; + + private readonly ClienteServico _clienteServico; + + private readonly LogServico _logServico; + + private readonly CriticaApoliceServico _criticaServico; + + private readonly ServicoExtrato _extratoServico; + + private readonly MetaSeguradoraServico _metaSeguradoraServico; + + private readonly MetaVendedorServico _metaVendedorServico; + + private readonly NotaFiscalServico _notaFiscalServico; + + private readonly Func funcProducaoDistinctByDocumentoId = (Producao p) => ((DomainBase)p.Documento).Id; + + private readonly Func funcProducaoSegurosNovos = (Producao p) => (int)p.Documento.Situacao == 1; + + private readonly Func funcProducaoSegurosRenovacao = (Producao p) => (int)p.Documento.Situacao == 2; + + private readonly Func funcProducaoNegociosNovos = (Producao p) => p.Documento.NegocioCorretora == (NegocioCorretora?)0; + + private readonly Func funcProducaoNegociosProprios = (Producao p) => (int)p.Documento.NegocioCorretora.GetValueOrDefault() == 1; + + private bool _totalizacao = true; + + private bool _enableEmpresa; + + private bool _apelido; + + private List _empresas; + + private Empresa _empresa; + + private bool? _allSelectedSeguradora; + + private bool? _allSelectedRamo; + + private bool? _allSelectedVendedor; + + private bool? _allSelectedTipoVendedor; + + private bool? _allSelectedStatus; + + private bool? _allSelectedNegocio; + + private bool? _allSelectedEstipulante; + + private bool? _allSelectedProduto; + + private bool _allSelectedChanging; + + private string _filtro; + + private bool _visibilityHtml; + + private bool _relatorioVisibility; + + private string _htmlContent; + + private List _relatorios = new List(); + + private Relatorio _relatorio = (Relatorio)2; + + private bool _extratosEnabled; + + private Visibility _planilhaVisibility; + + private object _report; + + private bool _permitirFiltrosPersonalizados; + + private Visibility _filtrosPersonalizados = (Visibility)2; + + private bool _somenteNaoPagos; + + private bool _visibilityDesconsiderarNegativos = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 50); + + private bool _desconsiderarNegativos; + + private bool _segundaViaReciboPagamento; + + private bool _documentosEmitidos; + + private bool _sinteticosPagamento; + + private bool _visibilityUsuarios; + + private Visibility _visibilityDocumentoAtivo; + + private Visibility _visibilityReferencia = (Visibility)2; + + private Visibility _visibilityOrdem = (Visibility)2; + + private string _referencia; + + private ObservableCollection _referencias = new ObservableCollection(); + + private ObservableCollection _ordens = new ObservableCollection(); + + private string _ordemSelecionada; + + private DateTime _inicio = Funcoes.GetNetworkTime().Date.AddMonths(-1); + + private DateTime _fim = Funcoes.GetNetworkTime().Date; + + private int _inicioValor; + + private int _fimValor; + + private Agrupamento _agrupamento; + + private List _producao; + + private List _licenciamento; + + private List _placas; + + private List _tarefa; + + private List _endosso; + + private List _classificacao; + + private ObservableCollection _licenciamentoFiltrado; + + private ObservableCollection _placaFiltrado; + + private ObservableCollection _tarefaFiltrado; + + private List _renovacao; + + private List _faturaPendente; + + private ObservableCollection _faturaPendenteFiltrado; + + private List _sinistro; + + private List _comissao; + + private List _pendente; + + private List _pagamentos; + + private List _pagamentosSintetico; + + private List _clientesAtivosInativos; + + private List _logsEnvio; + + private ObservableCollection _apoliceCriticaFiltrado; + + private ObservableCollection _logUtilizacaoFiltrado; + + private ObservableCollection _fechamento; + + private ObservableCollection _previsao; + + private ObservableCollection _previsaoSintetico; + + private List _auditoria; + + private ObservableCollection _auditoriaFiltrado; + + private List _apolicePendente; + + private List _extratos; + + private ObservableCollection _apolicePendenteFiltrado; + + private ObservableCollection _extratosFiltrado; + + private List _metaSeguradora; + + private List _metaVendedor; + + private ObservableCollection _metaSeguradoraFiltrado; + + private ObservableCollection _metaVendedorFiltrado; + + private ObservableCollection _producaoFiltrado; + + private ObservableCollection _endossoFiltrado; + + private ObservableCollection _notaFiscalFiltrado; + + private ObservableCollection _renovacaoFiltrado; + + private ObservableCollection _sinistroFiltrado; + + private ObservableCollection _comissaoFiltrado; + + private ObservableCollection _pendenteFiltrado; + + private ObservableCollection _clientesAtivosInativosFiltrado; + + private ObservableCollection _classificacaoFiltrado; + + private ObservableCollection _logsEnvioFiltrado; + + private ObservableCollection _fechamentoFiltrado; + + private ObservableCollection _previsaoFiltrado; + + private bool _totais; + + private ObservableCollection _sinteticoRelatorio; + + private SinteticoClientes _sinteticoCliente; + + private ObservableCollection _sintetic; + + private bool _comparativo; + + private bool _completo; + + private bool _notaFiscalPorSeguradora; + + private Mes _selectedMes; + + private int _selectedAno; + + private Visibility _infoVisibility = (Visibility)2; + + private string _info; + + private string _erroRelatorio = "NÃO HÁ DADOS NO PERÍODO E FILTROS SELECIONADOS."; + + private bool _carregando; + + private bool _documentosAtivos; + + private List _seguradoras = (from x in Recursos.Seguradoras + where x.Ativo + orderby x.Nome + select x).ToList(); + + private List _ramos = (from x in Recursos.Ramos + where x.Ativo + orderby x.Nome + select x).ToList(); + + private List _notasFiscais = new List(); + + private bool _inativo = true; + + private List _vendedores = new List(); + + private List _tipoVendedor = (from x in Recursos.TipoVendedor + where x.Ativo.GetValueOrDefault() + orderby x.Descricao + select x).ToList(); + + private List _produtos = (from x in Recursos.Produtos + where x.Ativo + orderby x.Nome + select x).ToList(); + + private List _estipulantes = (from x in Recursos.Estipulantes + where (Recursos.Usuario.IdEmpresa == 1 || Recursos.Usuario.IdEmpresa == x.IdEmpresa) && x.Ativo + orderby x.Nome + select x).ToList(); + + private static readonly List NegocioList = new List + { + new NegocioRelatorio + { + Id = 0, + Selecionado = false, + Negocio = (NegocioCorretora)0 + }, + new NegocioRelatorio + { + Id = 1, + Selecionado = false, + Negocio = (NegocioCorretora)1 + } + }; + + private List _negocios = NegocioList; + + private static readonly List TipoSegurosList = new List + { + new StatusRelatorio + { + Id = 1, + Selecionado = false, + Status = (TipoSeguro)1 + }, + new StatusRelatorio + { + Id = 2, + Selecionado = false, + Status = (TipoSeguro)2 + }, + new StatusRelatorio + { + Id = 3, + Selecionado = false, + Status = (TipoSeguro)3 + }, + new StatusRelatorio + { + Id = 4, + Selecionado = false, + Status = (TipoSeguro)7 + }, + new StatusRelatorio + { + Id = 5, + Selecionado = false, + Status = (TipoSeguro)5 + }, + new StatusRelatorio + { + Id = 6, + Selecionado = false, + Status = (TipoSeguro)6 + }, + new StatusRelatorio + { + Id = 7, + Selecionado = false, + Status = (TipoSeguro)4 + } + }; + + private List _tipoSeguros = TipoSegurosList; + + private bool _isVisibleGrid1 = true; + + private bool _isVisibleGrid2 = true; + + private bool _isVisibleGrid3 = true; + + private bool _isVisibleGrid4 = true; + + private List _filtroRelatorioPersonalizado; + + private FiltroPersonalizado _filtroPersonalizado; + + private Type _tipoString = typeof(string); + + private Type _tipoEnum = typeof(Enum); + + private Type _tipoDateTime = typeof(DateTime); + + private Type _tipoDecimal = typeof(decimal); + + private Type _tipoInt = typeof(int); + + private Type _tipoLong = typeof(long); + + private ObservableCollection _ramosSelecionados; + + private bool _novosNegocios; + + private Ramo _ramoSelecionado; + + private string _valorIncial = ""; + + private string _valorFinal = ""; + + private bool _semValor; + + private bool _valorIgual; + + private Visibility _visibilitySemValor = (Visibility)2; + + private Visibility _visibilityOpcoesFiltros = (Visibility)2; + + private ObservableCollection _filtroPersonalizadoSelecionado; + + private ObservableCollection _filtroRelatorioSelecionado = new ObservableCollection(); + + private Visibility _visibilityFiltros; + + private Visibility _visibilityEtiqueta; + + private Visibility _visibiltyProtocolo; + + private Visibility _visibiltySincronizar; + + private Visibility _visibilityEmail; + + private Visibility _visibilityApolice; + + private Visibility _visibilityExtratos; + + private Visibility _visibilityData; + + private Visibility _visibilityMeta; + + private Visibility _visibilityMaisFiltros; + + private Visibility _visibilityGridFiltros; + + private Visibility _visibilityAgrupamento; + + private Visibility _visibilityOlho; + + private Visibility _visibilityEspecial; + + private Visibility _visibilityComparativo; + + private Visibility _visibilityCompleto; + + private Visibility _visibilityNotaFiscalPorSeguradora; + + private Visibility _visibilityPagamento; + + private Visibility _visibilitySintetizar; + + private Visibility _visibilityConfigurar; + + private Visibility _visibilityFiltroPersonalizadoButton; + + private Visibility _visibilityTarefas; + + private Visibility _visibilityAcompanhamento; + + private Visibility _visibilityValor; + + private Visibility _visibilityFiltroPersonalizado = (Visibility)2; + + private string _head; + + private List _parcelasEspeciais = new List + { + new FiltroTipoParcela + { + Selecionado = true, + Tipo = (SubTipo)1 + }, + new FiltroTipoParcela + { + Selecionado = true, + Tipo = (SubTipo)6 + }, + new FiltroTipoParcela + { + Selecionado = true, + Tipo = (SubTipo)3 + }, + new FiltroTipoParcela + { + Selecionado = true, + Tipo = (SubTipo)2 + }, + new FiltroTipoParcela + { + Selecionado = true, + Tipo = (SubTipo)5 + }, + new FiltroTipoParcela + { + Selecionado = true, + Tipo = (SubTipo)4 + } + }; + + private ObservableCollection _ajuda = new ObservableCollection(); + + private bool _carregandoAjuda; + + private ObservableCollection _parametrosRelatorio; + + private ObservableCollection _parametrosRelatorioAdicionados; + + private ObservableCollection _parametrosTotalizacao; + + private ObservableCollection _parametrosTotalizacaoAdicionados; + + private bool _isCampo = true; + + private ParametrosRelatorio _selectedParametrosRelatorio; + + private ParametrosTotalizacao _selectedParametrosTotalizacao; + + private ObservableCollection _usuariosFiltrados = new ObservableCollection(); + + public string Sessao { get; set; } + + public static DrawerHost Drawer { get; set; } + + public bool Totalizacao + { + get + { + return _totalizacao; + } + set + { + _totalizacao = value; + OnPropertyChanged("Totalizacao"); + } + } + + public bool EnableEmpresa + { + get + { + return _enableEmpresa; + } + set + { + _enableEmpresa = value; + OnPropertyChanged("EnableEmpresa"); + } + } + + public bool Apelido + { + get + { + return _apelido; + } + set + { + _apelido = value; + OnPropertyChanged("Apelido"); + } + } + + public List Empresas + { + get + { + return _empresas; + } + set + { + _empresas = value; + OnPropertyChanged("Empresas"); + } + } + + public Empresa Empresa + { + get + { + return _empresa; + } + set + { + _empresa = value; + OnPropertyChanged("Empresa"); + } + } + + public bool? AllSelectedSeguradora + { + get + { + return _allSelectedSeguradora; + } + set + { + if (value != _allSelectedSeguradora) + { + _allSelectedSeguradora = value; + AllSelectedChanged(0); + Seguradoras = new List(Seguradoras); + OnPropertyChanged("AllSelectedSeguradora"); + } + } + } + + public bool? AllSelectedRamo + { + get + { + return _allSelectedRamo; + } + set + { + if (value != _allSelectedRamo) + { + _allSelectedRamo = value; + AllSelectedChanged(1); + Ramos = new List(Ramos); + OnPropertyChanged("AllSelectedRamo"); + } + } + } + + public bool? AllSelectedVendedor + { + get + { + return _allSelectedVendedor; + } + set + { + if (value != _allSelectedVendedor) + { + _allSelectedVendedor = value; + AllSelectedChanged(2); + Vendedores = new List(Vendedores); + OnPropertyChanged("AllSelectedVendedor"); + } + } + } + + public bool? AllSelectedTipoVendedor + { + get + { + return _allSelectedTipoVendedor; + } + set + { + if (value != _allSelectedTipoVendedor) + { + _allSelectedTipoVendedor = value; + AllSelectedChanged(4); + TipoVendedor = new List(TipoVendedor); + OnPropertyChanged("AllSelectedTipoVendedor"); + } + } + } + + public bool? AllSelectedStatus + { + get + { + return _allSelectedStatus; + } + set + { + if (value != _allSelectedStatus) + { + _allSelectedStatus = value; + AllSelectedChanged(3); + TipoSeguros = new List(TipoSeguros); + OnPropertyChanged("AllSelectedStatus"); + } + } + } + + public bool? AllSelectedNegocio + { + get + { + return _allSelectedNegocio; + } + set + { + if (value != _allSelectedNegocio) + { + _allSelectedNegocio = value; + AllSelectedChanged(5); + Negocios = new List(Negocios); + OnPropertyChanged("AllSelectedNegocio"); + } + } + } + + public bool? AllSelectedEstipulante + { + get + { + return _allSelectedEstipulante; + } + set + { + if (value != _allSelectedEstipulante) + { + _allSelectedEstipulante = value; + AllSelectedChanged(7); + Estipulantes = new List(Estipulantes); + OnPropertyChanged("AllSelectedEstipulante"); + } + } + } + + public bool? AllSelectedProduto + { + get + { + return _allSelectedProduto; + } + set + { + if (value != _allSelectedProduto) + { + _allSelectedProduto = value; + AllSelectedChanged(6); + Produtos = new List(Produtos); + OnPropertyChanged("AllSelectedProduto"); + } + } + } + + public string Filtro + { + get + { + return _filtro; + } + set + { + _filtro = value; + Filtrar(); + OnPropertyChanged("Filtro"); + } + } + + public bool VisibilityHtml + { + get + { + return _visibilityHtml; + } + set + { + _visibilityHtml = value; + OnPropertyChanged("VisibilityHtml"); + } + } + + public bool RelatorioVisibility + { + get + { + return _relatorioVisibility; + } + set + { + _relatorioVisibility = value; + OnPropertyChanged("RelatorioVisibility"); + } + } + + public string HtmlContent + { + get + { + return _htmlContent; + } + set + { + _htmlContent = value; + OnPropertyChanged("HtmlContent"); + } + } + + public List Relatorios + { + get + { + return _relatorios; + } + set + { + _relatorios = value; + OnPropertyChanged("Relatorios"); + } + } + + public Relatorio Relatorio + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _relatorio; + } + 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) + _relatorio = value; + WorkOnRelatorio(value); + OnPropertyChanged("Relatorio"); + } + } + + public bool ExtratosEnabled + { + get + { + return _extratosEnabled; + } + set + { + _extratosEnabled = value; + OnPropertyChanged("ExtratosEnabled"); + } + } + + public Visibility PlanilhaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _planilhaVisibility; + } + 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) + _planilhaVisibility = value; + OnPropertyChanged("PlanilhaVisibility"); + } + } + + public object Report + { + get + { + return _report; + } + set + { + _report = value; + FiltrosPersonalizados = (Visibility)((value == null || !PermitirFiltrosPersonalizados) ? 2 : 0); + OnPropertyChanged("Report"); + } + } + + public bool PermitirFiltrosPersonalizados + { + get + { + return _permitirFiltrosPersonalizados; + } + set + { + _permitirFiltrosPersonalizados = value; + OnPropertyChanged("PermitirFiltrosPersonalizados"); + } + } + + public Visibility FiltrosPersonalizados + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _filtrosPersonalizados; + } + 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) + _filtrosPersonalizados = value; + OnPropertyChanged("FiltrosPersonalizados"); + } + } + + private bool ReciboPagamento { get; set; } + + public bool SomenteNaoPagos + { + get + { + return _somenteNaoPagos; + } + set + { + LimparRelatorio(); + _somenteNaoPagos = value; + if (value) + { + SegundaViaReciboPagamento = false; + } + OnPropertyChanged("SomenteNaoPagos"); + } + } + + public bool VisibilityDesconsiderarNegativos + { + get + { + return _visibilityDesconsiderarNegativos; + } + set + { + _visibilityDesconsiderarNegativos = value; + OnPropertyChanged("VisibilityDesconsiderarNegativos"); + } + } + + public bool DesconsiderarNegativos + { + get + { + return _desconsiderarNegativos; + } + set + { + LimparRelatorio(); + _desconsiderarNegativos = value; + OnPropertyChanged("DesconsiderarNegativos"); + } + } + + public bool SegundaViaReciboPagamento + { + get + { + return _segundaViaReciboPagamento; + } + set + { + LimparRelatorio(); + _segundaViaReciboPagamento = value; + if (value) + { + SomenteNaoPagos = false; + } + OnPropertyChanged("SegundaViaReciboPagamento"); + } + } + + public bool DocumentosEmitidos + { + get + { + return _documentosEmitidos; + } + set + { + LimparRelatorio(); + _documentosEmitidos = value; + OnPropertyChanged("DocumentosEmitidos"); + } + } + + public bool SinteticosPagamento + { + get + { + return _sinteticosPagamento; + } + set + { + _sinteticosPagamento = value; + OnPropertyChanged("SinteticosPagamento"); + } + } + + public bool VisibilityUsuarios + { + get + { + return _visibilityUsuarios; + } + set + { + _visibilityUsuarios = value; + OnPropertyChanged("VisibilityUsuarios"); + } + } + + public Visibility VisibilityDocumentoAtivo + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityDocumentoAtivo; + } + 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) + _visibilityDocumentoAtivo = value; + OnPropertyChanged("VisibilityDocumentoAtivo"); + } + } + + public Visibility VisibilityReferencia + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityReferencia; + } + 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) + _visibilityReferencia = value; + OnPropertyChanged("VisibilityReferencia"); + } + } + + public Visibility VisibilityOrdem + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityOrdem; + } + 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) + _visibilityOrdem = value; + OnPropertyChanged("VisibilityOrdem"); + } + } + + public string Referencia + { + get + { + return _referencia; + } + set + { + _referencia = value; + OnPropertyChanged("Referencia"); + } + } + + public ObservableCollection Referencias + { + get + { + return _referencias; + } + set + { + _referencias = value; + OnPropertyChanged("Referencias"); + } + } + + public ObservableCollection Ordens + { + get + { + return _ordens; + } + set + { + _ordens = value; + OnPropertyChanged("Ordens"); + } + } + + public string OrdemSelecionada + { + get + { + return _ordemSelecionada; + } + set + { + _ordemSelecionada = value; + OnPropertyChanged("OrdemSelecionada"); + } + } + + public DateTime Inicio + { + get + { + return _inicio; + } + set + { + if (value < new DateTime(1754, 1, 1)) + { + value = new DateTime(1754, 1, 1); + } + if (value > new DateTime(9999, 12, 31)) + { + value = new DateTime(9999, 12, 31); + } + _inicio = value; + OnPropertyChanged("Inicio"); + } + } + + public DateTime Fim + { + get + { + return _fim; + } + set + { + if (value < new DateTime(1754, 1, 1)) + { + value = new DateTime(1754, 1, 1); + } + if (value > new DateTime(9999, 12, 31)) + { + value = new DateTime(9999, 12, 31); + } + _fim = value; + OnPropertyChanged("Fim"); + } + } + + public int InicioValor + { + get + { + return _inicioValor; + } + set + { + _inicioValor = value; + OnPropertyChanged("InicioValor"); + } + } + + public int FimValor + { + get + { + return _fimValor; + } + set + { + _fimValor = value; + OnPropertyChanged("FimValor"); + } + } + + public Agrupamento Agrupamento + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _agrupamento; + } + 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) + _agrupamento = value; + OnPropertyChanged("Agrupamento"); + } + } + + public List Producao + { + get + { + return _producao; + } + set + { + _producao = value; + OnPropertyChanged("Producao"); + } + } + + public List Licenciamento + { + get + { + return _licenciamento; + } + set + { + _licenciamento = value; + OnPropertyChanged("Licenciamento"); + } + } + + public List Placas + { + get + { + return _placas; + } + set + { + _placas = value; + OnPropertyChanged("Placas"); + } + } + + public List Tarefa + { + get + { + return _tarefa; + } + set + { + _tarefa = value; + OnPropertyChanged("Tarefa"); + } + } + + public List Endossoo + { + get + { + return _endosso; + } + set + { + _endosso = value; + OnPropertyChanged("Endossoo"); + } + } + + public List Classificacao + { + get + { + return _classificacao; + } + set + { + _classificacao = value; + OnPropertyChanged("Classificacao"); + } + } + + public ObservableCollection LicenciamentoFiltrado + { + get + { + return _licenciamentoFiltrado; + } + set + { + _licenciamentoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("LicenciamentoFiltrado"); + } + } + + public ObservableCollection PlacaFiltrado + { + get + { + return _placaFiltrado; + } + set + { + _placaFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("PlacaFiltrado"); + } + } + + public ObservableCollection TarefaFiltrado + { + get + { + return _tarefaFiltrado; + } + set + { + _tarefaFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("TarefaFiltrado"); + } + } + + public List Renovacao + { + get + { + return _renovacao; + } + set + { + _renovacao = value; + OnPropertyChanged("Renovacao"); + } + } + + public List FaturaPendente + { + get + { + return _faturaPendente; + } + set + { + _faturaPendente = value; + OnPropertyChanged("FaturaPendente"); + } + } + + public ObservableCollection FaturaPendenteFiltrado + { + get + { + return _faturaPendenteFiltrado; + } + set + { + _faturaPendenteFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("FaturaPendenteFiltrado"); + } + } + + public List Sinistro + { + get + { + return _sinistro; + } + set + { + _sinistro = value; + OnPropertyChanged("Sinistro"); + } + } + + public List Comissao + { + get + { + return _comissao; + } + set + { + _comissao = value; + OnPropertyChanged("Comissao"); + } + } + + public List Pendente + { + get + { + return _pendente; + } + set + { + _pendente = value; + OnPropertyChanged("Pendente"); + } + } + + public List Pagamentos + { + get + { + return _pagamentos; + } + set + { + _pagamentos = value; + Sintetic = null; + OnPropertyChanged("Pagamentos"); + } + } + + public List PagamentosSintetico + { + get + { + return _pagamentosSintetico; + } + set + { + _pagamentosSintetico = value; + Sintetic = null; + OnPropertyChanged("PagamentosSintetico"); + } + } + + public List ClientesAtivosInativos + { + get + { + return _clientesAtivosInativos; + } + set + { + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Expected O, but got Unknown + _clientesAtivosInativos = value; + SinteticoCliente = new SinteticoClientes + { + Total = (value?.Count ?? 0) + }; + OnPropertyChanged("ClientesAtivosInativos"); + } + } + + public List LogsEnvio + { + get + { + return _logsEnvio; + } + set + { + _logsEnvio = value; + OnPropertyChanged("LogsEnvio"); + } + } + + public List ApoliceCritica { get; set; } + + public ObservableCollection ApoliceCriticaFiltrado + { + get + { + return _apoliceCriticaFiltrado; + } + set + { + _apoliceCriticaFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ApoliceCriticaFiltrado"); + } + } + + public List LogUtilizacao { get; set; } + + public ObservableCollection LogUtilizacaoFiltrado + { + get + { + return _logUtilizacaoFiltrado; + } + set + { + _logUtilizacaoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("LogUtilizacaoFiltrado"); + } + } + + public ObservableCollection Fechamento + { + get + { + return _fechamento; + } + set + { + _fechamento = value; + Sintetic = null; + OnPropertyChanged("Fechamento"); + } + } + + public ObservableCollection Previsao + { + get + { + return _previsao; + } + set + { + _previsao = value; + Sintetic = null; + OnPropertyChanged("Previsao"); + } + } + + public ObservableCollection PrevisaoSintetico + { + get + { + return _previsaoSintetico; + } + set + { + _previsaoSintetico = value; + Sintetic = null; + OnPropertyChanged("PrevisaoSintetico"); + } + } + + public List Auditoria + { + get + { + return _auditoria; + } + set + { + _auditoria = value; + OnPropertyChanged("Auditoria"); + } + } + + public ObservableCollection AuditoriaFiltrado + { + get + { + return _auditoriaFiltrado; + } + set + { + _auditoriaFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("AuditoriaFiltrado"); + } + } + + public List ApolicePendente + { + get + { + return _apolicePendente; + } + set + { + _apolicePendente = value; + OnPropertyChanged("ApolicePendente"); + } + } + + public List Extratos + { + get + { + return _extratos; + } + set + { + _extratos = value; + OnPropertyChanged("Extratos"); + } + } + + public ObservableCollection ApolicePendenteFiltrado + { + get + { + return _apolicePendenteFiltrado; + } + set + { + _apolicePendenteFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ApolicePendenteFiltrado"); + } + } + + public ObservableCollection ExtratosFiltrado + { + get + { + return _extratosFiltrado; + } + set + { + _extratosFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ExtratosFiltrado"); + } + } + + public List MetaSeguradora + { + get + { + return _metaSeguradora; + } + set + { + _metaSeguradora = value; + OnPropertyChanged("MetaSeguradora"); + } + } + + public List MetaVendedor + { + get + { + return _metaVendedor; + } + set + { + _metaVendedor = value; + OnPropertyChanged("MetaVendedor"); + } + } + + public ObservableCollection MetaSeguradoraFiltrado + { + get + { + return _metaSeguradoraFiltrado; + } + set + { + _metaSeguradoraFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("MetaSeguradoraFiltrado"); + } + } + + public ObservableCollection MetaVendedorFiltrado + { + get + { + return _metaVendedorFiltrado; + } + set + { + _metaVendedorFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("MetaVendedorFiltrado"); + } + } + + public ObservableCollection ProducaoFiltrado + { + get + { + return _producaoFiltrado; + } + set + { + _producaoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ProducaoFiltrado"); + } + } + + public ObservableCollection EndossoFiltrado + { + get + { + return _endossoFiltrado; + } + set + { + _endossoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("EndossoFiltrado"); + } + } + + public ObservableCollection NotaFiscalFiltrado + { + get + { + return _notaFiscalFiltrado; + } + set + { + _notaFiscalFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("NotaFiscalFiltrado"); + } + } + + public ObservableCollection RenovacaoFiltrado + { + get + { + return _renovacaoFiltrado; + } + set + { + _renovacaoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("RenovacaoFiltrado"); + } + } + + public ObservableCollection SinistroFiltrado + { + get + { + return _sinistroFiltrado; + } + set + { + _sinistroFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("SinistroFiltrado"); + } + } + + public ObservableCollection ComissaoFiltrado + { + get + { + return _comissaoFiltrado; + } + set + { + _comissaoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ComissaoFiltrado"); + } + } + + public ObservableCollection PendenteFiltrado + { + get + { + return _pendenteFiltrado; + } + set + { + _pendenteFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("PendenteFiltrado"); + } + } + + public ObservableCollection ClientesAtivosInativosFiltrado + { + get + { + return _clientesAtivosInativosFiltrado; + } + set + { + _clientesAtivosInativosFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ClientesAtivosInativosFiltrado"); + } + } + + public ObservableCollection ClassificacaoFiltrado + { + get + { + return _classificacaoFiltrado; + } + set + { + _classificacaoFiltrado = value; + SintetizarRelatorio(); + OnPropertyChanged("ClassificacaoFiltrado"); + } + } + + public ObservableCollection LogsEnvioFiltrado + { + get + { + return _logsEnvioFiltrado; + } + set + { + _logsEnvioFiltrado = value; + Sintetic = null; + OnPropertyChanged("LogsEnvioFiltrado"); + } + } + + public ObservableCollection FechamentoFiltrado + { + get + { + return _fechamentoFiltrado; + } + set + { + _fechamentoFiltrado = value; + SintetizarRelatorio(); + Sintetic = null; + OnPropertyChanged("FechamentoFiltrado"); + } + } + + public ObservableCollection PrevisaoFiltrado + { + get + { + return _previsaoFiltrado; + } + set + { + _previsaoFiltrado = value; + SintetizarRelatorio(); + Sintetic = null; + OnPropertyChanged("PrevisaoFiltrado"); + } + } + + public bool Totais + { + get + { + return _totais; + } + set + { + _totais = value; + OnPropertyChanged("Totais"); + } + } + + public ObservableCollection SinteticoRelatorio + { + get + { + return _sinteticoRelatorio; + } + set + { + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + _sinteticoRelatorio = value; + OnPropertyChanged("SinteticoRelatorio"); + Totais = value != null && value.Count > 0; + if (value != null && value.Count != 0) + { + List list = value.FirstOrDefault().ConstruirSintetico(Relatorio); + Sintetic = new ObservableCollection(list); + } + } + } + + public SinteticoClientes SinteticoCliente + { + get + { + return _sinteticoCliente; + } + set + { + _sinteticoCliente = value; + OnPropertyChanged("SinteticoCliente"); + } + } + + public ObservableCollection Sintetic + { + get + { + return _sintetic; + } + set + { + _sintetic = value; + OnPropertyChanged("Sintetic"); + } + } + + public bool Comparativo + { + get + { + return _comparativo; + } + set + { + _comparativo = value; + OnPropertyChanged("Comparativo"); + } + } + + public bool Completo + { + get + { + return _completo; + } + set + { + _completo = value; + OnPropertyChanged("Completo"); + } + } + + public bool NotaFiscalPorSeguradora + { + get + { + return _notaFiscalPorSeguradora; + } + set + { + _notaFiscalPorSeguradora = value; + OnPropertyChanged("NotaFiscalPorSeguradora"); + } + } + + public Mes SelectedMes + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selectedMes; + } + 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) + _selectedMes = value; + OnPropertyChanged("SelectedMes"); + } + } + + public int SelectedAno + { + get + { + return _selectedAno; + } + set + { + _selectedAno = value; + OnPropertyChanged("SelectedAno"); + } + } + + public Visibility InfoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _infoVisibility; + } + 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) + _infoVisibility = value; + OnPropertyChanged("InfoVisibility"); + } + } + + public string Info + { + get + { + return _info; + } + set + { + _info = value; + OnPropertyChanged("Info"); + } + } + + public string ErroRelatorio + { + get + { + return _erroRelatorio; + } + set + { + _erroRelatorio = value; + OnPropertyChanged("ErroRelatorio"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + OnPropertyChanged("Carregando"); + } + } + + public bool DocumentosAtivos + { + get + { + return _documentosAtivos; + } + set + { + _documentosAtivos = value; + OnPropertyChanged("DocumentosAtivos"); + } + } + + public Filtros Filtros { get; set; } + + public List ColunasOcultas { get; set; } = new List(); + + + public List Seguradoras + { + get + { + return _seguradoras; + } + set + { + _seguradoras = value; + foreach (Seguradora seguradora in Seguradoras) + { + seguradora.PropertyChanged += SeguradoraOnPropertyChanged; + } + OnPropertyChanged("Seguradoras"); + } + } + + public List Ramos + { + get + { + return _ramos; + } + set + { + _ramos = value; + foreach (Ramo ramo in Ramos) + { + ramo.PropertyChanged += RamoOnPropertyChanged; + } + OnPropertyChanged("Ramos"); + } + } + + public List NotasFiscais + { + get + { + return _notasFiscais; + } + set + { + _notasFiscais = value; + OnPropertyChanged("NotasFiscais"); + } + } + + public bool Inativo + { + get + { + return _inativo; + } + set + { + _inativo = value; + ReloadVendedores(); + OnPropertyChanged("Inativo"); + } + } + + public List Vendedores + { + get + { + return _vendedores; + } + set + { + _vendedores = value; + foreach (Vendedor vendedore in Vendedores) + { + vendedore.PropertyChanged += VendedorOnPropertyChanged; + } + OnPropertyChanged("Vendedores"); + } + } + + public List TipoVendedor + { + get + { + return _tipoVendedor; + } + set + { + _tipoVendedor = value; + foreach (TipoVendedor item in TipoVendedor) + { + item.PropertyChanged += TipoVendedorOnPropertyChanged; + } + OnPropertyChanged("TipoVendedor"); + } + } + + private List Vinculo { get; set; } + + public List Produtos + { + get + { + return _produtos; + } + set + { + _produtos = value; + foreach (Produto produto in Produtos) + { + produto.PropertyChanged += ProdutoOnPropertyChanged; + } + OnPropertyChanged("Produtos"); + } + } + + public List Estipulantes + { + get + { + return _estipulantes; + } + set + { + _estipulantes = value; + foreach (Estipulante estipulante in Estipulantes) + { + estipulante.PropertyChanged += EstipulanteOnPropertyChanged; + } + OnPropertyChanged("Estipulantes"); + } + } + + public List Negocios + { + get + { + return _negocios; + } + set + { + _negocios = value; + foreach (NegocioRelatorio negocio in Negocios) + { + negocio.PropertyChanged += NegocioOnPropertyChanged; + } + OnPropertyChanged("Negocios"); + } + } + + public List TipoSeguros + { + get + { + return _tipoSeguros; + } + set + { + _tipoSeguros = value; + foreach (StatusRelatorio tipoSeguro in TipoSeguros) + { + tipoSeguro.PropertyChanged += StatusOnPropertyChanged; + } + OnPropertyChanged("TipoSeguros"); + } + } + + public bool IsVisibleGrid1 + { + get + { + return _isVisibleGrid1; + } + set + { + _isVisibleGrid1 = value; + OnPropertyChanged("IsVisibleGrid1"); + } + } + + public bool IsVisibleGrid2 + { + get + { + return _isVisibleGrid2; + } + set + { + _isVisibleGrid2 = value; + OnPropertyChanged("IsVisibleGrid2"); + } + } + + public bool IsVisibleGrid3 + { + get + { + return _isVisibleGrid3; + } + set + { + _isVisibleGrid3 = value; + OnPropertyChanged("IsVisibleGrid3"); + } + } + + public bool IsVisibleGrid4 + { + get + { + return _isVisibleGrid4; + } + set + { + _isVisibleGrid4 = value; + OnPropertyChanged("IsVisibleGrid4"); + } + } + + public List RelatorioFiltroPersonalizado + { + get + { + return _filtroRelatorioPersonalizado; + } + set + { + _filtroRelatorioPersonalizado = value; + OnPropertyChanged("RelatorioFiltroPersonalizado"); + } + } + + public FiltroPersonalizado FiltroPersonalizado + { + get + { + return _filtroPersonalizado; + } + set + { + _filtroPersonalizado = value; + VisibilitySemValor = (Visibility)((value == null) ? 2 : 0); + VisibilityOpcoesFiltros = (Visibility)2; + OnPropertyChanged("FiltroPersonalizado"); + if (value == null) + { + return; + } + string name = value.Tipo.Name; + if (name == null) + { + return; + } + switch (name.Length) + { + default: + return; + case 4: + { + char c = name[0]; + if (c != 'E') + { + if (c != 'l' || !(name == "long")) + { + return; + } + break; + } + if (!(name == "Enum")) + { + return; + } + goto IL_013b; + } + case 5: + switch (name[3]) + { + default: + return; + case '3': + if (!(name == "int32")) + { + return; + } + break; + case '6': + if (!(name == "int64")) + { + return; + } + break; + } + break; + case 6: + if (name == "String") + { + ValorInicial = ""; + ValorFinal = ""; + VisibilityOpcoesFiltros = (Visibility)((value == null) ? 2 : 0); + } + return; + case 7: + if (name == "Decimal") + { + ValorInicial = "0,00"; + ValorFinal = "0,00"; + } + return; + case 8: + if (!(name == "DateTime")) + { + return; + } + goto IL_013b; + case 3: + { + if (!(name == "int")) + { + return; + } + break; + } + IL_013b: + ValorInicial = null; + ValorFinal = null; + return; + } + ValorInicial = "0"; + ValorFinal = "0"; + } + } + + public Type TipoString + { + get + { + return _tipoString; + } + set + { + _tipoString = value; + OnPropertyChanged("TipoString"); + } + } + + public Type TipoEnum + { + get + { + return _tipoEnum; + } + set + { + _tipoEnum = value; + OnPropertyChanged("TipoEnum"); + } + } + + public Type TipoDateTime + { + get + { + return _tipoDateTime; + } + set + { + _tipoDateTime = value; + OnPropertyChanged("TipoDateTime"); + } + } + + public Type TipoDecimal + { + get + { + return _tipoDecimal; + } + set + { + _tipoDecimal = value; + OnPropertyChanged("TipoDecimal"); + } + } + + public Type TipoInt + { + get + { + return _tipoInt; + } + set + { + _tipoInt = value; + OnPropertyChanged("TipoInt"); + } + } + + public Type TipoLong + { + get + { + return _tipoLong; + } + set + { + _tipoLong = value; + OnPropertyChanged("TipoLong"); + } + } + + public ObservableCollection RamosSelecionados + { + get + { + return _ramosSelecionados; + } + set + { + _ramosSelecionados = value; + OnPropertyChanged("RamosSelecionados"); + } + } + + public bool NovosNegocios + { + get + { + return _novosNegocios; + } + set + { + _novosNegocios = value; + OnPropertyChanged("NovosNegocios"); + } + } + + public Ramo RamoSelecionado + { + get + { + return _ramoSelecionado; + } + set + { + _ramoSelecionado = value; + OnPropertyChanged("RamoSelecionado"); + } + } + + public string ValorInicial + { + get + { + return _valorIncial; + } + set + { + _valorIncial = value; + OnPropertyChanged("ValorInicial"); + } + } + + public string ValorFinal + { + get + { + return _valorFinal; + } + set + { + _valorFinal = value; + OnPropertyChanged("ValorFinal"); + } + } + + public bool SemValor + { + get + { + return _semValor; + } + set + { + _semValor = value; + if (value) + { + ValorInicial = null; + ValorFinal = null; + } + OnPropertyChanged("SemValor"); + } + } + + public bool ValorIgual + { + get + { + return _valorIgual; + } + set + { + _valorIgual = value; + OnPropertyChanged("ValorIgual"); + } + } + + public Visibility VisibilitySemValor + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilitySemValor; + } + 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) + _visibilitySemValor = value; + OnPropertyChanged("VisibilitySemValor"); + } + } + + public Visibility VisibilityOpcoesFiltros + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityOpcoesFiltros; + } + 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) + _visibilityOpcoesFiltros = value; + OnPropertyChanged("VisibilityOpcoesFiltros"); + } + } + + public ObservableCollection FiltroPersonalizadoSelecionado + { + get + { + return _filtroPersonalizadoSelecionado; + } + set + { + _filtroPersonalizadoSelecionado = value; + OnPropertyChanged("FiltroPersonalizadoSelecionado"); + } + } + + public ObservableCollection FiltroRelatorioSelecionado + { + get + { + return _filtroRelatorioSelecionado; + } + set + { + _filtroRelatorioSelecionado = value; + OnPropertyChanged("FiltroRelatorioSelecionado"); + } + } + + public Visibility VisibilityFiltros + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityFiltros; + } + 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) + _visibilityFiltros = value; + OnPropertyChanged("VisibilityFiltros"); + } + } + + public Visibility VisibilityEtiqueta + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityEtiqueta; + } + 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) + _visibilityEtiqueta = value; + OnPropertyChanged("VisibilityEtiqueta"); + } + } + + public Visibility VisibiltyProtocolo + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibiltyProtocolo; + } + 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) + _visibiltyProtocolo = value; + OnPropertyChanged("VisibiltyProtocolo"); + } + } + + public Visibility VisibiltySincronizar + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibiltySincronizar; + } + 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) + _visibiltySincronizar = value; + OnPropertyChanged("VisibiltySincronizar"); + } + } + + public Visibility VisibilityEmail + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityEmail; + } + 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) + _visibilityEmail = value; + OnPropertyChanged("VisibilityEmail"); + } + } + + public Visibility VisibilityApolice + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityApolice; + } + 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) + _visibilityApolice = value; + OnPropertyChanged("VisibilityApolice"); + } + } + + public Visibility VisibilityExtratos + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityExtratos; + } + 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) + _visibilityExtratos = value; + OnPropertyChanged("VisibilityExtratos"); + } + } + + public Visibility VisibilityData + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityData; + } + 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) + _visibilityData = value; + OnPropertyChanged("VisibilityData"); + } + } + + public Visibility VisibilityMeta + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityMeta; + } + 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) + _visibilityMeta = value; + OnPropertyChanged("VisibilityMeta"); + } + } + + public Visibility VisibilityMaisFiltros + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityMaisFiltros; + } + 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) + _visibilityMaisFiltros = value; + OnPropertyChanged("VisibilityMaisFiltros"); + } + } + + public Visibility VisibilityGridFiltros + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityGridFiltros; + } + 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) + _visibilityGridFiltros = value; + OnPropertyChanged("VisibilityGridFiltros"); + } + } + + public Visibility VisibilityAgrupamento + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityAgrupamento; + } + 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) + _visibilityAgrupamento = value; + OnPropertyChanged("VisibilityAgrupamento"); + } + } + + public Visibility VisibilityOlho + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityOlho; + } + 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) + _visibilityOlho = value; + OnPropertyChanged("VisibilityOlho"); + } + } + + public Visibility VisibilityEspecial + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityEspecial; + } + 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) + _visibilityEspecial = value; + OnPropertyChanged("VisibilityEspecial"); + } + } + + public Visibility VisibilityComparativo + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityComparativo; + } + 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) + _visibilityComparativo = value; + OnPropertyChanged("VisibilityComparativo"); + } + } + + public Visibility VisibilityCompleto + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityCompleto; + } + 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) + _visibilityCompleto = value; + OnPropertyChanged("VisibilityCompleto"); + } + } + + public Visibility VisibilityNotaFiscalPorSeguradora + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityNotaFiscalPorSeguradora; + } + 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) + _visibilityNotaFiscalPorSeguradora = value; + OnPropertyChanged("VisibilityNotaFiscalPorSeguradora"); + } + } + + public Visibility VisibilityPagamento + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityPagamento; + } + 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) + _visibilityPagamento = value; + OnPropertyChanged("VisibilityPagamento"); + } + } + + public Visibility VisibilitySintetizar + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilitySintetizar; + } + 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) + _visibilitySintetizar = value; + OnPropertyChanged("VisibilitySintetizar"); + } + } + + public Visibility VisibilityConfigurar + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityConfigurar; + } + 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) + _visibilityConfigurar = value; + OnPropertyChanged("VisibilityConfigurar"); + } + } + + public Visibility VisibilityFiltroPersonalizadoButton + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityFiltroPersonalizadoButton; + } + 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) + _visibilityFiltroPersonalizadoButton = value; + OnPropertyChanged("VisibilityFiltroPersonalizadoButton"); + } + } + + public Visibility VisibilityTarefas + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityTarefas; + } + 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) + _visibilityTarefas = value; + OnPropertyChanged("VisibilityTarefas"); + } + } + + public Visibility VisibilityAcompanhamento + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityAcompanhamento; + } + 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) + _visibilityAcompanhamento = value; + OnPropertyChanged("VisibilityAcompanhamento"); + } + } + + public Visibility VisibilityValor + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityValor; + } + 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) + _visibilityValor = value; + OnPropertyChanged("VisibilityValor"); + } + } + + public Visibility VisibilityFiltroPersonalizado + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityFiltroPersonalizado; + } + 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) + _visibilityFiltroPersonalizado = value; + OnPropertyChanged("VisibilityFiltroPersonalizado"); + } + } + + public string Head + { + get + { + return _head; + } + set + { + _head = value; + OnPropertyChanged("Head"); + } + } + + public List ParcelasEspeciais + { + get + { + return _parcelasEspeciais; + } + set + { + _parcelasEspeciais = value; + OnPropertyChanged("ParcelasEspeciais"); + } + } + + public ObservableCollection Ajuda + { + get + { + return _ajuda; + } + set + { + _ajuda = value; + OnPropertyChanged("Ajuda"); + } + } + + public bool CarregandoAjuda + { + get + { + return _carregandoAjuda; + } + set + { + _carregandoAjuda = value; + OnPropertyChanged("CarregandoAjuda"); + } + } + + public ObservableCollection ParametrosRelatorio + { + get + { + return _parametrosRelatorio; + } + set + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Expected O, but got Unknown + if (value == null) + { + value = new ObservableCollection(); + } + value.Insert(0, new ParametrosRelatorio + { + Id = 0L, + Header = "SELECIONE UM CAMPO" + }); + _parametrosRelatorio = value; + SelectedParametrosRelatorio = value[0]; + OnPropertyChanged("ParametrosRelatorio"); + } + } + + public ObservableCollection ParametrosRelatorioAdicionados + { + get + { + return _parametrosRelatorioAdicionados; + } + set + { + _parametrosRelatorioAdicionados = value; + OnPropertyChanged("ParametrosRelatorioAdicionados"); + } + } + + public ObservableCollection ParametrosTotalizacao + { + get + { + return _parametrosTotalizacao; + } + set + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Expected O, but got Unknown + if (value == null) + { + value = new ObservableCollection(); + } + value.Insert(0, new ParametrosTotalizacao + { + Id = 0L, + Header = "SELECIONE UMA TOTALIZAÇÃO" + }); + _parametrosTotalizacao = value; + SelectedParametrosTotalizacao = value[0]; + OnPropertyChanged("ParametrosTotalizacao"); + } + } + + public ObservableCollection ParametrosTotalizacaoAdicionados + { + get + { + return _parametrosTotalizacaoAdicionados; + } + set + { + _parametrosTotalizacaoAdicionados = value; + OnPropertyChanged("ParametrosTotalizacaoAdicionados"); + } + } + + public bool IsCampo + { + get + { + return _isCampo; + } + set + { + _isCampo = value; + OnPropertyChanged("IsCampo"); + } + } + + public ParametrosRelatorio SelectedParametrosRelatorio + { + get + { + return _selectedParametrosRelatorio; + } + set + { + _selectedParametrosRelatorio = value; + OnPropertyChanged("SelectedParametrosRelatorio"); + } + } + + public ParametrosTotalizacao SelectedParametrosTotalizacao + { + get + { + return _selectedParametrosTotalizacao; + } + set + { + _selectedParametrosTotalizacao = value; + OnPropertyChanged("SelectedParametrosTotalizacao"); + } + } + + public List Usuarios { get; set; } + + public ObservableCollection UsuariosFiltrados + { + get + { + return _usuariosFiltrados; + } + set + { + _usuariosFiltrados = value; + OnPropertyChanged("UsuariosFiltrados"); + } + } + + public RelatorioViewModel(string opcao) + { + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00d4: Unknown result type (might be due to invalid IL or missing references) + //IL_010a: Unknown result type (might be due to invalid IL or missing references) + //IL_0111: Unknown result type (might be due to invalid IL or missing references) + //IL_015d: Unknown result type (might be due to invalid IL or missing references) + //IL_03f7: Unknown result type (might be due to invalid IL or missing references) + //IL_03fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0410: Unknown result type (might be due to invalid IL or missing references) + //IL_041c: Unknown result type (might be due to invalid IL or missing references) + //IL_0421: Unknown result type (might be due to invalid IL or missing references) + //IL_0428: Unknown result type (might be due to invalid IL or missing references) + //IL_0434: Expected O, but got Unknown + //IL_0435: Unknown result type (might be due to invalid IL or missing references) + //IL_043a: Unknown result type (might be due to invalid IL or missing references) + //IL_0441: Unknown result type (might be due to invalid IL or missing references) + //IL_044d: Expected O, but got Unknown + //IL_044e: Unknown result type (might be due to invalid IL or missing references) + //IL_0453: Unknown result type (might be due to invalid IL or missing references) + //IL_045a: Unknown result type (might be due to invalid IL or missing references) + //IL_0466: Expected O, but got Unknown + //IL_0467: Unknown result type (might be due to invalid IL or missing references) + //IL_046c: Unknown result type (might be due to invalid IL or missing references) + //IL_0473: Unknown result type (might be due to invalid IL or missing references) + //IL_047f: Expected O, but got Unknown + //IL_0480: Unknown result type (might be due to invalid IL or missing references) + //IL_0485: Unknown result type (might be due to invalid IL or missing references) + //IL_048c: Unknown result type (might be due to invalid IL or missing references) + //IL_0498: Expected O, but got Unknown + //IL_0499: Unknown result type (might be due to invalid IL or missing references) + //IL_049e: Unknown result type (might be due to invalid IL or missing references) + //IL_04a5: Unknown result type (might be due to invalid IL or missing references) + //IL_04b1: Expected O, but got Unknown + //IL_05c7: Unknown result type (might be due to invalid IL or missing references) + //IL_05cc: Unknown result type (might be due to invalid IL or missing references) + //IL_05d4: Unknown result type (might be due to invalid IL or missing references) + //IL_05e4: Expected O, but got Unknown + _apoliceServico = new ApoliceServico(); + _parcelaServico = new ParcelaServico(); + _sinistroServico = new SinistroServico(); + _clienteServico = new ClienteServico(); + _logServico = new LogServico(); + _extratoServico = new ServicoExtrato(); + _metaSeguradoraServico = new MetaSeguradoraServico(); + _metaVendedorServico = new MetaVendedorServico(); + _notaFiscalServico = new NotaFiscalServico(); + _criticaServico = new CriticaApoliceServico(); + Sessao = Guid.NewGuid().ToString(); + base.IsEnabled = true; + Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6); + List list = Recursos.Empresas.OrderBy((Empresa x) => ((DomainBase)x).Id).ToList(); + list.Insert(0, new Empresa + { + Id = 0L, + Nome = "TODAS, MATRIZ E FILIAIS" + }); + Empresas = list; + Empresa = (Empresa)((Recursos.Usuario.IdEmpresa <= 1) ? ((object)Empresas.First()) : ((object)Empresas.Find((Empresa x) => ((DomainBase)x).Id == Recursos.Usuario.IdEmpresa))); + EnableEmpresa = Recursos.Usuario.IdEmpresa <= 1; + base.EnableMenu = true; + LoadVendedores(); + PopularRelatorio(opcao); + } + + private void AllSelectedChanged(int tipo) + { + if (_allSelectedChanging) + { + return; + } + try + { + _alterandoFiltros = true; + _allSelectedChanging = true; + switch (tipo) + { + case 0: + if (!AllSelectedSeguradora.HasValue) + { + return; + } + foreach (Seguradora seguradora in Seguradoras) + { + seguradora.Selecionado = AllSelectedSeguradora.Value; + } + break; + case 1: + if (!AllSelectedRamo.HasValue) + { + return; + } + foreach (Ramo ramo in Ramos) + { + ramo.Selecionado = AllSelectedRamo.Value; + } + break; + case 2: + if (!AllSelectedVendedor.HasValue) + { + return; + } + foreach (Vendedor vendedore in Vendedores) + { + vendedore.Selecionado = AllSelectedVendedor.Value; + } + break; + case 3: + if (!AllSelectedStatus.HasValue) + { + return; + } + foreach (StatusRelatorio tipoSeguro in TipoSeguros) + { + tipoSeguro.Selecionado = AllSelectedStatus.Value; + } + break; + case 4: + if (!AllSelectedTipoVendedor.HasValue) + { + return; + } + foreach (TipoVendedor item in TipoVendedor) + { + item.Selecionado = AllSelectedTipoVendedor.Value; + } + break; + case 5: + if (!AllSelectedNegocio.HasValue) + { + return; + } + foreach (NegocioRelatorio negocio in Negocios) + { + negocio.Selecionado = AllSelectedNegocio.Value; + } + break; + case 6: + if (!AllSelectedProduto.HasValue) + { + return; + } + foreach (Produto produto in Produtos) + { + produto.Selecionado = AllSelectedProduto.Value; + } + break; + case 7: + if (!AllSelectedEstipulante.HasValue) + { + return; + } + foreach (Estipulante estipulante in Estipulantes) + { + estipulante.Selecionado = AllSelectedEstipulante.Value; + } + break; + } + _alterandoFiltros = false; + AdicionarFiltros(); + } + finally + { + _allSelectedChanging = false; + } + } + + private void Filtrar() + { + Seguradoras = (from x in Recursos.Seguradoras + where x.Ativo && x.Nome.Contains(Filtro) + orderby x.Nome + select x).ToList(); + Ramos = (from x in Recursos.Ramos + where x.Ativo && x.Nome.Contains(Filtro) + orderby x.Nome + select x).ToList(); + Estipulantes = (from x in Recursos.Estipulantes + where x.Ativo && x.Nome.Contains(Filtro) + orderby x.Nome + select x).ToList(); + Vendedores = ((Vinculo.Count > 0) ? (from x in Recursos.Vendedores + where Vinculo.Any((VendedorUsuario y) => ((DomainBase)y.Vendedor).Id == ((DomainBase)x).Id) && x.Nome.Contains(Filtro) && x.Ativo + orderby x.Nome + select x).ToList() : (from x in Recursos.Vendedores + where x.Nome.Contains(Filtro) && (Inativo || x.Ativo) + orderby x.Nome + select x).ToList()); + TipoVendedor = (from x in Recursos.TipoVendedor + where x.Ativo.GetValueOrDefault() && x.Descricao.Contains(Filtro) + orderby x.Descricao + select x).ToList(); + Produtos = (from x in Recursos.Produtos + where x.Ativo && x.Nome.Contains(Filtro) + orderby x.Nome + select x).ToList(); + TipoSeguros = (from x in TipoSegurosList + where EnumHelper.GetDescription(x.Status).Contains(Filtro) + orderby x.Status + select x).ToList(); + Negocios = (from x in NegocioList + where EnumHelper.GetDescription(x.Negocio).Contains(Filtro) + orderby x.Negocio + select x).ToList(); + } + + internal async Task RemoverVinculo(ApolicePendente pendencia) + { + Loading(isLoading: true); + VinculoDocumento vinculo = pendencia.Documento.Vinculo; + if (vinculo != null && vinculo.Id != 0L) + { + await _apoliceServico.ExcluirVinculo(vinculo.Id); + Gestor.Application.Actions.Actions.RecarregarRelatorios?.Invoke(Sessao); + Loading(isLoading: false); + } + } + + private void WorkOnRelatorio(Relatorio value) + { + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00be: Invalid comparison between Unknown and I4 + //IL_00c0: Unknown result type (might be due to invalid IL or missing references) + //IL_00c3: Invalid comparison between Unknown and I4 + //IL_00f9: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: Invalid comparison between Unknown and I4 + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: Invalid comparison between Unknown and I4 + //IL_016c: Unknown result type (might be due to invalid IL or missing references) + //IL_01ea: Expected I4, but got Unknown + //IL_0634: Unknown result type (might be due to invalid IL or missing references) + //IL_0639: Unknown result type (might be due to invalid IL or missing references) + //IL_0641: Unknown result type (might be due to invalid IL or missing references) + //IL_064d: Unknown result type (might be due to invalid IL or missing references) + //IL_0655: Expected O, but got Unknown + //IL_065c: Unknown result type (might be due to invalid IL or missing references) + //IL_0661: Unknown result type (might be due to invalid IL or missing references) + //IL_0669: Unknown result type (might be due to invalid IL or missing references) + //IL_0675: Unknown result type (might be due to invalid IL or missing references) + //IL_067d: Expected O, but got Unknown + //IL_053c: Unknown result type (might be due to invalid IL or missing references) + //IL_0541: Unknown result type (might be due to invalid IL or missing references) + //IL_0549: Unknown result type (might be due to invalid IL or missing references) + //IL_0555: Unknown result type (might be due to invalid IL or missing references) + //IL_055d: Expected O, but got Unknown + //IL_0564: Unknown result type (might be due to invalid IL or missing references) + //IL_0569: Unknown result type (might be due to invalid IL or missing references) + //IL_0571: Unknown result type (might be due to invalid IL or missing references) + //IL_057d: Unknown result type (might be due to invalid IL or missing references) + //IL_0585: Expected O, but got Unknown + //IL_058c: Unknown result type (might be due to invalid IL or missing references) + //IL_0591: Unknown result type (might be due to invalid IL or missing references) + //IL_0599: Unknown result type (might be due to invalid IL or missing references) + //IL_05a5: Unknown result type (might be due to invalid IL or missing references) + //IL_05ad: Expected O, but got Unknown + //IL_05b4: Unknown result type (might be due to invalid IL or missing references) + //IL_05b9: Unknown result type (might be due to invalid IL or missing references) + //IL_05c1: Unknown result type (might be due to invalid IL or missing references) + //IL_05cd: Unknown result type (might be due to invalid IL or missing references) + //IL_05d5: Expected O, but got Unknown + //IL_05dc: Unknown result type (might be due to invalid IL or missing references) + //IL_05e1: Unknown result type (might be due to invalid IL or missing references) + //IL_05e9: Unknown result type (might be due to invalid IL or missing references) + //IL_05f5: Unknown result type (might be due to invalid IL or missing references) + //IL_05fd: Expected O, but got Unknown + //IL_0604: Unknown result type (might be due to invalid IL or missing references) + //IL_0609: Unknown result type (might be due to invalid IL or missing references) + //IL_0611: Unknown result type (might be due to invalid IL or missing references) + //IL_061d: Unknown result type (might be due to invalid IL or missing references) + //IL_0625: Expected O, but got Unknown + //IL_0376: Unknown result type (might be due to invalid IL or missing references) + //IL_037d: Invalid comparison between Unknown and I4 + //IL_0797: Unknown result type (might be due to invalid IL or missing references) + //IL_079e: Invalid comparison between Unknown and I4 + HtmlContent = string.Empty; + VisibilityHtml = false; + FiltroRelatorioSelecionado = new ObservableCollection(); + LimparFiltros(); + VisibilityFiltros = (Visibility)0; + VisibilityMaisFiltros = (Visibility)0; + VisibilityGridFiltros = (Visibility)2; + VisibilityData = (Visibility)0; + VisibilityOlho = (Visibility)0; + VisibilityEspecial = (Visibility)2; + VisibilityPagamento = (Visibility)2; + VisibilityExtratos = (Visibility)0; + VisibilityEtiqueta = (Visibility)0; + VisibilityEmail = (Visibility)0; + VisibilityAgrupamento = (Visibility)0; + VisibilitySintetizar = (Visibility)0; + Usuario usuario = Recursos.Usuario; + VisibilityTarefas = (Visibility)((usuario == null || ((DomainBase)usuario).Id <= 0) ? 2 : 0); + VisibilityAcompanhamento = (Visibility)2; + VisibilityReferencia = (Visibility)2; + VisibiltyProtocolo = (Visibility)2; + VisibilityMeta = (Visibility)2; + VisibilityApolice = (Visibility)2; + VisibiltySincronizar = (Visibility)(((int)value != 3 && (int)value != 16) ? 2 : 0); + VisibilityComparativo = (Visibility)2; + VisibilityCompleto = (Visibility)2; + VisibilityNotaFiscalPorSeguradora = (Visibility)2; + Agrupamento = (Agrupamento)0; + NovosNegocios = false; + ExtratosEnabled = false; + PermitirFiltrosPersonalizados = (int)value != 11 && (int)value != 7; + VisibilityFiltroPersonalizadoButton = (Visibility)0; + Usuario usuario2 = Recursos.Usuario; + VisibilityConfigurar = (Visibility)((usuario2 == null || ((DomainBase)usuario2).Id <= 0) ? 2 : 0); + VisibilityUsuarios = false; + VisibilityOrdem = (Visibility)2; + VisibilityValor = (Visibility)2; + PlanilhaVisibility = (Visibility)2; + VisibilityDocumentoAtivo = (Visibility)2; + LimparFiltroUsuario(); + InicioValor = 0; + FimValor = 0; + switch ((int)value) + { + case 26: + VisibilityExtratos = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityTarefas = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + PlanilhaVisibility = (Visibility)2; + break; + case 24: + case 25: + VisibilityExtratos = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityMaisFiltros = (Visibility)0; + VisibilityTarefas = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityEmail = (Visibility)2; + break; + case 18: + VisibilityExtratos = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityTarefas = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityEmail = (Visibility)2; + break; + case 17: + VisibilityExtratos = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityTarefas = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityData = (Visibility)2; + VisibilityValor = (Visibility)0; + InfoVisibility = (Visibility)2; + break; + case 0: + VisibilityAgrupamento = (Visibility)2; + VisibilityData = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityFiltros = (Visibility)2; + VisibilityCompleto = (Visibility)0; + InfoVisibility = (Visibility)2; + break; + case 1: + VisibilityAgrupamento = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityFiltros = (Visibility)2; + VisibilityExtratos = (Visibility)2; + Info = "O RELATÓRIO DE ANIVERSARIANTE CONSIDERA O DIA E MÊS FILTRADOS E DESCONSIDERA O ANO INFORMADO NA PESQUISA."; + InfoVisibility = (Visibility)0; + break; + case 5: + VisibilityExtratos = (Visibility)2; + break; + case 13: + case 20: + { + List list = new List { "DATA IMPORTAÇÃO", "DATA DO EXTRATO", "DATA DO CRÉDITO" }; + Referencias = new ObservableCollection(list); + Referencia = Referencias.First(); + if ((int)Relatorio == 13) + { + VisibilityReferencia = (Visibility)0; + VisibilityMaisFiltros = (Visibility)2; + } + VisibilityEspecial = (Visibility)2; + VisibilityExtratos = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityTarefas = (Visibility)2; + break; + } + case 11: + { + VisibilityComparativo = (Visibility)0; + VisibilityEspecial = (Visibility)2; + VisibilityExtratos = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilitySintetizar = (Visibility)0; + VisibilityTarefas = (Visibility)2; + VisibilityReferencia = (Visibility)0; + List list = new List { "VIGÊNCIA INICIAL", "EMISSÃO" }; + Referencias = new ObservableCollection(list); + Referencia = Referencias.First(); + break; + } + case 7: + { + ParcelasEspeciais[0].IsEnable = true; + VisibilityEspecial = (Visibility)0; + VisibilityPagamento = (Visibility)0; + VisibilityExtratos = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityTarefas = (Visibility)2; + SomenteNaoPagos = true; + ReciboPagamento = false; + VisibilityOrdem = (Visibility)((!Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 8)) ? 2 : 0); + List list2 = new List { "DATA RECEBIMENTO", "NOME CLIENTE", "SEGURADORA, RAMO" }; + Ordens = new ObservableCollection(list2); + OrdemSelecionada = Ordens.First(); + VisibilityHtml = true; + break; + } + case 8: + { + ParcelasEspeciais[0].IsEnable = false; + VisibilityEspecial = (Visibility)0; + VisibilityExtratos = (Visibility)2; + Info = "AGORA O RELATÓRIO DE AUDITORIA SELECIONA TODOS OS SEGUROS, MESMO TENDO PARCELAS PENDENTES, PARA FILTRAR APENAS OS SEGUROS SEM PARCELAS PENDENTES, BASTA UTILIZAR O FILTRO PERSONALIZADO 'RECEBIDO POR COMPLETO', PREENCHER 'SIM' EM SEU VALOR E APLICAR O FILTRO"; + InfoVisibility = (Visibility)0; + FiltroRelatorio filtro = new FiltroRelatorio + { + Id = 1L, + Descricao = EnumHelper.GetDescription((TipoSeguro)1), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + filtro = new FiltroRelatorio + { + Id = 2L, + Descricao = EnumHelper.GetDescription((TipoSeguro)2), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + filtro = new FiltroRelatorio + { + Id = 3L, + Descricao = EnumHelper.GetDescription((TipoSeguro)3), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + filtro = new FiltroRelatorio + { + Id = 4L, + Descricao = EnumHelper.GetDescription((TipoSeguro)4), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + filtro = new FiltroRelatorio + { + Id = 5L, + Descricao = EnumHelper.GetDescription((TipoSeguro)5), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + filtro = new FiltroRelatorio + { + Id = 6L, + Descricao = EnumHelper.GetDescription((TipoSeguro)6), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + break; + } + case 2: + { + VisibiltyProtocolo = (Visibility)0; + FiltroRelatorio filtro = new FiltroRelatorio + { + Id = 1L, + Descricao = EnumHelper.GetDescription((TipoSeguro)1), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + filtro = new FiltroRelatorio + { + Id = 2L, + Descricao = EnumHelper.GetDescription((TipoSeguro)2), + Tipo = (TipoFiltroRelatorio)5 + }; + AdicionarFiltro(filtro); + List list = new List { "VIGÊNCIA INICIAL", "EMISSÃO", "TRANSMISSÃO PROPOSTA", "DATA DE CADASTRO" }; + Referencias = new ObservableCollection(list); + Referencia = Referencias.First(); + VisibilityReferencia = (Visibility)0; + VisibilityGridFiltros = (Visibility)0; + VisibilityOlho = (Visibility)2; + PlanilhaVisibility = (Visibility)0; + break; + } + case 12: + { + List list = new List { "VIGÊNCIA", "VENCIMENTO" }; + Referencias = new ObservableCollection(list); + Referencia = Referencias.First(); + VisibilityReferencia = (Visibility)0; + VisibilityExtratos = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + break; + } + case 3: + VisibiltyProtocolo = (Visibility)0; + VisibiltySincronizar = (Visibility)0; + VisibilityExtratos = (Visibility)2; + break; + case 4: + VisibiltyProtocolo = (Visibility)0; + VisibilityAcompanhamento = (Visibility)0; + PlanilhaVisibility = (Visibility)0; + break; + case 14: + case 15: + { + VisibilityEtiqueta = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityData = (Visibility)2; + VisibilitySintetizar = (Visibility)0; + VisibilityExtratos = (Visibility)2; + VisibilityMeta = (Visibility)0; + Agrupamento = (Agrupamento)(((int)Relatorio != 15) ? 1 : 3); + DateTime date = Funcoes.GetNetworkTime().Date; + SelectedMes = (Mes)date.Month; + SelectedAno = date.Year; + break; + } + case 10: + { + VisibilityExtratos = (Visibility)2; + VisibilityReferencia = (Visibility)0; + List list = new List { "DATA SINISTRO", "DATA LIQUIDAÇÃO", "DATA RECLAMAÇÃO" }; + Referencias = new ObservableCollection(list); + Referencia = Referencias.First(); + break; + } + case 16: + VisibilityExtratos = (Visibility)2; + PlanilhaVisibility = (Visibility)2; + VisibilityDocumentoAtivo = (Visibility)0; + break; + case 6: + case 9: + VisibilityExtratos = (Visibility)2; + PlanilhaVisibility = (Visibility)2; + break; + case 19: + VisibilityExtratos = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityNotaFiscalPorSeguradora = (Visibility)0; + VisibilitySintetizar = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityTarefas = (Visibility)2; + break; + case 23: + VisibilitySintetizar = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityTarefas = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityExtratos = (Visibility)2; + break; + case 28: + { + VisibilitySintetizar = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityTarefas = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityExtratos = (Visibility)2; + List list = new List { "VIGÊNCIA INICIAL", "EMISSÃO", "TRANSMISSÃO PROPOSTA", "DATA DE CADASTRO" }; + Referencias = new ObservableCollection(list); + Referencia = Referencias.First(); + VisibilityReferencia = (Visibility)0; + VisibilityGridFiltros = (Visibility)0; + PlanilhaVisibility = (Visibility)0; + break; + } + case 27: + VisibilitySintetizar = (Visibility)2; + VisibilityEtiqueta = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityTarefas = (Visibility)2; + VisibilityEmail = (Visibility)2; + VisibilityExtratos = (Visibility)2; + break; + case 29: + VisibilityExtratos = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityAgrupamento = (Visibility)2; + VisibilityData = (Visibility)2; + VisibilitySintetizar = (Visibility)2; + VisibilityMaisFiltros = (Visibility)2; + VisibilityFiltros = (Visibility)2; + VisibilityCompleto = (Visibility)2; + InfoVisibility = (Visibility)2; + Info = ""; + break; + case 21: + case 22: + break; + } + } + + public void SintetizarRelatorio() + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Expected I4, but got Unknown + //IL_0eb6: Unknown result type (might be due to invalid IL or missing references) + //IL_0ebb: Unknown result type (might be due to invalid IL or missing references) + //IL_0ecd: Unknown result type (might be due to invalid IL or missing references) + //IL_1420: Unknown result type (might be due to invalid IL or missing references) + //IL_1425: Unknown result type (might be due to invalid IL or missing references) + //IL_1122: Unknown result type (might be due to invalid IL or missing references) + //IL_1127: Unknown result type (might be due to invalid IL or missing references) + //IL_18a3: Unknown result type (might be due to invalid IL or missing references) + //IL_18a8: Unknown result type (might be due to invalid IL or missing references) + //IL_1bde: Unknown result type (might be due to invalid IL or missing references) + //IL_1be3: Unknown result type (might be due to invalid IL or missing references) + //IL_0d51: Unknown result type (might be due to invalid IL or missing references) + //IL_0d56: Unknown result type (might be due to invalid IL or missing references) + //IL_0700: Unknown result type (might be due to invalid IL or missing references) + //IL_0705: Unknown result type (might be due to invalid IL or missing references) + //IL_0a5f: Unknown result type (might be due to invalid IL or missing references) + //IL_0a64: Unknown result type (might be due to invalid IL or missing references) + //IL_044b: Unknown result type (might be due to invalid IL or missing references) + //IL_0450: Unknown result type (might be due to invalid IL or missing references) + //IL_0652: Unknown result type (might be due to invalid IL or missing references) + //IL_0657: Unknown result type (might be due to invalid IL or missing references) + //IL_066e: Expected O, but got Unknown + //IL_0350: Unknown result type (might be due to invalid IL or missing references) + //IL_0355: Unknown result type (might be due to invalid IL or missing references) + //IL_0255: Unknown result type (might be due to invalid IL or missing references) + //IL_025a: Unknown result type (might be due to invalid IL or missing references) + //IL_0fc6: Unknown result type (might be due to invalid IL or missing references) + //IL_0fcb: Unknown result type (might be due to invalid IL or missing references) + //IL_0fe2: Expected O, but got Unknown + //IL_1074: Unknown result type (might be due to invalid IL or missing references) + //IL_1079: Unknown result type (might be due to invalid IL or missing references) + //IL_1090: Expected O, but got Unknown + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_011e: Unknown result type (might be due to invalid IL or missing references) + //IL_1e6f: Unknown result type (might be due to invalid IL or missing references) + //IL_1e74: Unknown result type (might be due to invalid IL or missing references) + //IL_1e8f: Expected O, but got Unknown + //IL_0efe: Unknown result type (might be due to invalid IL or missing references) + //IL_1456: Unknown result type (might be due to invalid IL or missing references) + //IL_1158: Unknown result type (might be due to invalid IL or missing references) + //IL_18d9: Unknown result type (might be due to invalid IL or missing references) + //IL_1c14: Unknown result type (might be due to invalid IL or missing references) + //IL_0d87: Unknown result type (might be due to invalid IL or missing references) + //IL_0736: Unknown result type (might be due to invalid IL or missing references) + //IL_0a95: Unknown result type (might be due to invalid IL or missing references) + //IL_048a: Unknown result type (might be due to invalid IL or missing references) + //IL_0385: Unknown result type (might be due to invalid IL or missing references) + //IL_028a: Unknown result type (might be due to invalid IL or missing references) + //IL_014e: Unknown result type (might be due to invalid IL or missing references) + //IL_0f34: Expected O, but got Unknown + //IL_1487: Unknown result type (might be due to invalid IL or missing references) + //IL_1189: Unknown result type (might be due to invalid IL or missing references) + //IL_190a: Unknown result type (might be due to invalid IL or missing references) + //IL_1c45: Unknown result type (might be due to invalid IL or missing references) + //IL_0767: Unknown result type (might be due to invalid IL or missing references) + //IL_0ac6: Unknown result type (might be due to invalid IL or missing references) + //IL_04ba: Unknown result type (might be due to invalid IL or missing references) + //IL_03ba: Expected O, but got Unknown + //IL_02bf: Expected O, but got Unknown + //IL_017e: Unknown result type (might be due to invalid IL or missing references) + //IL_0ddc: Unknown result type (might be due to invalid IL or missing references) + //IL_0dee: Unknown result type (might be due to invalid IL or missing references) + //IL_0798: Unknown result type (might be due to invalid IL or missing references) + //IL_0af7: Unknown result type (might be due to invalid IL or missing references) + //IL_04ea: Unknown result type (might be due to invalid IL or missing references) + //IL_01ae: Unknown result type (might be due to invalid IL or missing references) + //IL_01c4: Expected O, but got Unknown + //IL_0e24: Expected O, but got Unknown + //IL_0b28: Unknown result type (might be due to invalid IL or missing references) + //IL_051a: Unknown result type (might be due to invalid IL or missing references) + //IL_1522: Unknown result type (might be due to invalid IL or missing references) + //IL_1220: Unknown result type (might be due to invalid IL or missing references) + //IL_19aa: Unknown result type (might be due to invalid IL or missing references) + //IL_1ccc: Unknown result type (might be due to invalid IL or missing references) + //IL_0b59: Unknown result type (might be due to invalid IL or missing references) + //IL_054a: Unknown result type (might be due to invalid IL or missing references) + //IL_1251: Unknown result type (might be due to invalid IL or missing references) + //IL_082e: Unknown result type (might be due to invalid IL or missing references) + //IL_057a: Unknown result type (might be due to invalid IL or missing references) + //IL_1282: Unknown result type (might be due to invalid IL or missing references) + //IL_19ff: Unknown result type (might be due to invalid IL or missing references) + //IL_1d21: Unknown result type (might be due to invalid IL or missing references) + //IL_085f: Unknown result type (might be due to invalid IL or missing references) + //IL_0bae: Unknown result type (might be due to invalid IL or missing references) + //IL_05aa: Unknown result type (might be due to invalid IL or missing references) + //IL_05c0: Expected O, but got Unknown + //IL_15b8: Unknown result type (might be due to invalid IL or missing references) + //IL_12b3: Unknown result type (might be due to invalid IL or missing references) + //IL_1a30: Unknown result type (might be due to invalid IL or missing references) + //IL_0890: Unknown result type (might be due to invalid IL or missing references) + //IL_0bdf: Unknown result type (might be due to invalid IL or missing references) + //IL_15e9: Unknown result type (might be due to invalid IL or missing references) + //IL_12e4: Unknown result type (might be due to invalid IL or missing references) + //IL_1a61: Unknown result type (might be due to invalid IL or missing references) + //IL_1d76: Unknown result type (might be due to invalid IL or missing references) + //IL_08c1: Unknown result type (might be due to invalid IL or missing references) + //IL_0c10: Unknown result type (might be due to invalid IL or missing references) + //IL_1315: Unknown result type (might be due to invalid IL or missing references) + //IL_1a92: Unknown result type (might be due to invalid IL or missing references) + //IL_1da7: Unknown result type (might be due to invalid IL or missing references) + //IL_08f2: Unknown result type (might be due to invalid IL or missing references) + //IL_0c41: Unknown result type (might be due to invalid IL or missing references) + //IL_0c58: Unknown result type (might be due to invalid IL or missing references) + //IL_163e: Unknown result type (might be due to invalid IL or missing references) + //IL_1661: Unknown result type (might be due to invalid IL or missing references) + //IL_1684: Unknown result type (might be due to invalid IL or missing references) + //IL_16a7: Unknown result type (might be due to invalid IL or missing references) + //IL_16ca: Unknown result type (might be due to invalid IL or missing references) + //IL_1346: Unknown result type (might be due to invalid IL or missing references) + //IL_1ac3: Unknown result type (might be due to invalid IL or missing references) + //IL_1ad3: Unknown result type (might be due to invalid IL or missing references) + //IL_1ddd: Expected O, but got Unknown + //IL_0923: Unknown result type (might be due to invalid IL or missing references) + //IL_0c89: Unknown result type (might be due to invalid IL or missing references) + //IL_1377: Unknown result type (might be due to invalid IL or missing references) + //IL_138e: Expected O, but got Unknown + //IL_1b04: Unknown result type (might be due to invalid IL or missing references) + //IL_0954: Unknown result type (might be due to invalid IL or missing references) + //IL_0cbf: Expected O, but got Unknown + //IL_171f: Unknown result type (might be due to invalid IL or missing references) + //IL_1b35: Unknown result type (might be due to invalid IL or missing references) + //IL_1b4c: Expected O, but got Unknown + //IL_0985: Unknown result type (might be due to invalid IL or missing references) + //IL_09b6: Unknown result type (might be due to invalid IL or missing references) + //IL_09cd: Expected O, but got Unknown + //IL_1774: Unknown result type (might be due to invalid IL or missing references) + //IL_17c9: Unknown result type (might be due to invalid IL or missing references) + //IL_17db: Unknown result type (might be due to invalid IL or missing references) + //IL_1811: Expected O, but got Unknown + SinteticoRelatorio = new ObservableCollection(); + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 19: + if (NotaFiscalFiltrado != null && NotaFiscalFiltrado.Count != 0) + { + List list9 = (NotaFiscalFiltrado.Any((NotaFiscalRelatorio x) => x.Selecionado) ? NotaFiscalFiltrado.Where((NotaFiscalRelatorio x) => x.Selecionado).ToList() : NotaFiscalFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + PremioLiquido = list9.Sum((NotaFiscalRelatorio p) => p.Liquido), + Iss = list9.Sum((NotaFiscalRelatorio p) => p.Iss), + PremioTotal = list9.Sum((NotaFiscalRelatorio x) => x.Bruto), + TotalGeral = list9.Count + } + }); + } + break; + case 15: + if (MetaVendedorFiltrado != null && MetaVendedorFiltrado.Count != 0) + { + List source = (MetaVendedorFiltrado.Any((MetaVendedorRelatorio x) => x.Selecionado) ? MetaVendedorFiltrado.Where((MetaVendedorRelatorio x) => x.Selecionado).ToList() : MetaVendedorFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + MetaAtingir = source.Sum((MetaVendedorRelatorio x) => x.MetaAtingir), + MetaCumprida = source.Sum((MetaVendedorRelatorio p) => p.MetaCumprida) + } + }); + } + break; + case 14: + if (MetaSeguradoraFiltrado != null && MetaSeguradoraFiltrado.Count != 0) + { + List source4 = (MetaSeguradoraFiltrado.Any((MetaSeguradoraRelatorio x) => x.Selecionado) ? MetaSeguradoraFiltrado.Where((MetaSeguradoraRelatorio x) => x.Selecionado).ToList() : MetaSeguradoraFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + MetaAtingir = source4.Sum((MetaSeguradoraRelatorio x) => x.MetaAtingir), + MetaCumprida = source4.Sum((MetaSeguradoraRelatorio p) => p.MetaCumprida) + } + }); + } + break; + case 12: + if (FaturaPendenteFiltrado != null && FaturaPendenteFiltrado.Count != 0) + { + List list8 = (FaturaPendenteFiltrado.Any((FaturaPendente x) => x.Selecionado) ? FaturaPendenteFiltrado.Where((FaturaPendente x) => x.Selecionado).ToList() : FaturaPendenteFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + TotalClientes = list8.Select((FaturaPendente x) => x.Cliente).Distinct().Count(), + Cancelamentos = list8.Count((FaturaPendente c) => (int)c.Documento.Situacao == 3), + Novos = list8.Count((FaturaPendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list8.Count((FaturaPendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list8.Count((FaturaPendente c) => c.Documento.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list8.Count((FaturaPendente c) => c.Documento.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list8.Count((FaturaPendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list8.Count + } + }); + } + break; + case 13: + if (ExtratosFiltrado != null && ExtratosFiltrado.Count != 0) + { + List list6 = (ExtratosFiltrado.Any((ExtratoBaixadoRelatorio x) => x.Selecionado) ? ExtratosFiltrado.Where((ExtratoBaixadoRelatorio x) => x.Selecionado).ToList() : ExtratosFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + TotalGeral = list6.Count + } + }); + } + break; + case 8: + if (AuditoriaFiltrado != null && AuditoriaFiltrado.Count != 0) + { + List list5 = (AuditoriaFiltrado.Any((Auditoria x) => x.Selecionado) ? AuditoriaFiltrado.Where((Auditoria x) => x.Selecionado).ToList() : AuditoriaFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + PremioTotal = list5.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list5.Sum((Auditoria p) => p.PremioLiquido), + ComissaoRecebidaBruta = list5.Sum((Auditoria p) => p.ComissaoRecebida), + MediaComissao = (list5.Any((Auditoria c) => c.Comissao > 0m) ? decimal.Round(list5.Sum((Auditoria c) => c.Comissao) / (decimal)list5.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m), + ComissaoPrevista = list5.Sum((Auditoria c) => c.ComissaoPrevista), + ComissaoPendente = list5.Sum((Auditoria c) => c.ComissaoPendente), + Cancelamentos = list5.Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = list5.Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list5.Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list5.Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list5.Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list5.Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list5.Count + } + }); + } + break; + case 9: + case 10: + if (SinistroFiltrado != null && SinistroFiltrado.Count != 0) + { + List source3 = (SinistroFiltrado.Any((Sinistro x) => x.Selecionado) ? SinistroFiltrado.Where((Sinistro x) => x.Selecionado).ToList() : SinistroFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + Liquidado = source3.Count((Sinistro x) => (int)x.StatusSinistro == 2 && (int)x.TipoSinistro == 0), + Valor = source3.Sum((Sinistro x) => x.Valor), + ValorOrcado = source3.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = source3.Sum((Sinistro x) => x.ValorLiberado), + ValorPago = source3.Sum((Sinistro x) => x.ValorPago), + ValorLiquidado = source3.Where((Sinistro x) => (int)x.StatusSinistro == 2).Sum((Sinistro x) => x.ValorPago), + ValorSalvado = source3.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = source3.Sum((Sinistro x) => x.ValorFranquia), + Pendente = source3.Count((Sinistro x) => !x.Liquidacao.HasValue), + TotalGeral = source3.Distinct().Count(), + TotalClientes = source3.Count((Sinistro x) => (int)x.TipoSinistro == 0), + TotalTerceiros = source3.Count((Sinistro x) => (int)x.TipoSinistro == 1) + } + }); + } + break; + case 6: + case 16: + if (PendenteFiltrado != null && PendenteFiltrado.Count != 0) + { + List list4 = (PendenteFiltrado.Any((Pendente x) => x.Selecionado) ? PendenteFiltrado.Where((Pendente x) => x.Selecionado).ToList() : PendenteFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + ComissaoPrevista = list4.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevista = Funcoes.DistinctBy(list4, (Pendente x) => ((DomainBase)x.Documento).Id).Sum((Pendente x) => x.TotalPrevisto), + TotalGeral = list4.Count, + TotalParcela = list4.Sum((Pendente x) => x.ValorParcela) + } + }); + } + break; + case 0: + case 1: + if (ClientesAtivosInativosFiltrado != null && ClientesAtivosInativosFiltrado.Count != 0) + { + List list11 = (ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado) ? ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).ToList() : ClientesAtivosInativosFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + TotalClientes = list11.Count, + TotalClientesAtivos = list11.Count((ClientesAtivosInativos x) => x.Ativo == "SIM"), + TotalClientesInativos = list11.Count((ClientesAtivosInativos x) => x.Ativo == "NÃO") + } + }); + } + break; + case 17: + if (LicenciamentoFiltrado != null && LicenciamentoFiltrado.Count != 0) + { + List list2 = (LicenciamentoFiltrado.Any((Licenciamento x) => x.Selecionado) ? LicenciamentoFiltrado.Where((Licenciamento x) => x.Selecionado).ToList() : LicenciamentoFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + TotalClientes = list2.Count + } + }); + } + break; + case 18: + if (TarefaFiltrado != null && TarefaFiltrado.Count != 0) + { + List list7 = (TarefaFiltrado.Any((Tarefa x) => x.Selecionado) ? TarefaFiltrado.Where((Tarefa x) => x.Selecionado).ToList() : TarefaFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + TotalTarefas = list7.Count + } + }); + } + break; + case 3: + if (ApolicePendenteFiltrado != null && ApolicePendenteFiltrado.Count != 0) + { + List list = (ApolicePendenteFiltrado.Any((ApolicePendente x) => x.Selecionado) ? ApolicePendenteFiltrado.Where((ApolicePendente x) => x.Selecionado).ToList() : ApolicePendenteFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + PremioTotal = list.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list.Sum((ApolicePendente p) => p.PremioLiquido), + MediaComissao = ((list.Count((ApolicePendente c) => c.Comissao > 0m) > 0) ? decimal.Round(list.Sum((ApolicePendente c) => c.Comissao) / (decimal)list.Count((ApolicePendente c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list.Sum((ApolicePendente c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list.Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = list.Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list.Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list.Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list.Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list.Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list.Count + } + }); + } + break; + case 2: + if (ProducaoFiltrado != null && ProducaoFiltrado.Count != 0) + { + List list10 = (ProducaoFiltrado.Any((Producao x) => x.Selecionado) ? ProducaoFiltrado.Where((Producao x) => x.Selecionado).ToList() : ProducaoFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + PremioTotal = list10.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list10.Sum((Producao p) => p.PremioLiquido), + MediaPonderada = ((list10.Sum((Producao p) => p.PremioLiquido) > 0m) ? decimal.Round(list10.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao) / list10.Sum((Producao p) => p.PremioLiquido), 2) : 0m), + MediaComissao = (list10.Any((Producao c) => c.Comissao > 0m) ? decimal.Round(list10.Sum((Producao c) => c.Comissao) / (decimal)list10.Count((Producao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list10.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = Funcoes.DistinctBy(list10, (Producao x) => ((DomainBase)x.Documento.Controle).Id).Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(list10, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosNovos), + NegociosProprios = Funcoes.DistinctBy(list10, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosProprios), + SegurosNovos = Funcoes.DistinctBy(list10, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosNovos), + Renovacoes = Funcoes.DistinctBy(list10, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosRenovacao), + Apolices = Funcoes.DistinctBy(list10, (Producao x) => ((DomainBase)x.Documento).Id).Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(list10, (Producao x) => ((DomainBase)x.Documento).Id).Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(list10, (Producao x) => ((DomainBase)x.Documento).Id).Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list10.Count, + TotalLiquido = list10.Count((Producao c) => (int)c.Documento.Situacao != 3) + } + }); + } + break; + case 4: + if (RenovacaoFiltrado != null && RenovacaoFiltrado.Count != 0) + { + List list3 = (RenovacaoFiltrado.Any((Renovacao x) => x.Selecionado) ? RenovacaoFiltrado.Where((Renovacao x) => x.Selecionado).ToList() : RenovacaoFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + PremioTotal = list3.Sum((Renovacao x) => x.PremioTotal), + PremioLiquido = list3.Sum((Renovacao p) => p.PremioLiquido), + MediaComissao = ((list3.Sum((Renovacao c) => c.Comissao) > 0m) ? decimal.Round(list3.Sum((Renovacao c) => c.Comissao) / (decimal)list3.Count((Renovacao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list3.Where((Renovacao x) => x.Tipo != 3 && x.Comissao > 0m).Sum((Renovacao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list3.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.Situacao == 3), + Novos = list3.Count((Renovacao c) => (c.Tipo != 3 && (int)c.Documento.Situacao == 1) || (c.Tipo != 3 && (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list3.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list3.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = null, + Faturas = list3.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalProspeccao = list3.Count((Renovacao c) => c.Tipo == 3), + TotalGeral = list3.Count + } + }); + } + break; + case 5: + if (ComissaoFiltrado != null && ComissaoFiltrado.Count != 0) + { + List source2 = (ComissaoFiltrado.Any((Comissao x) => x.Selecionado) ? ComissaoFiltrado.Where((Comissao x) => x.Selecionado).ToList() : ComissaoFiltrado.ToList()); + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + ComissaoRecebidaBruta = source2.Sum((Comissao x) => x.ComissaoBruta), + ComissaoRecebidaLiquida = source2.Sum((Comissao x) => x.ComissaoRecebida), + Impostos = source2.Sum((Comissao x) => x.Ir) + source2.Sum((Comissao x) => x.Iss) + source2.Sum((Comissao x) => x.Outros), + PremioLiquido = Funcoes.DistinctBy(source2, (Comissao x) => ((DomainBase)x.Documento).Id).Sum((Comissao x) => x.PremioLiquido), + PremioTotal = Funcoes.DistinctBy(source2, (Comissao x) => ((DomainBase)x.Documento).Id).Sum((Comissao x) => x.PremioTotal), + ComissaoPrevista = source2.Sum((Comissao x) => x.ValorLiquido), + Repasse = source2.Sum((Comissao x) => x.Repasse) + } + }); + } + break; + case 29: + if (ClassificacaoFiltrado == null || ClassificacaoFiltrado.Count == 0) + { + break; + } + if (!ClassificacaoFiltrado.Any((Classificacao x) => x.Selecionado)) + { + ClassificacaoFiltrado.ToList(); + } + else + { + ClassificacaoFiltrado.Where((Classificacao x) => x.Selecionado).ToList(); + } + SinteticoRelatorio = new ObservableCollection(new List + { + new Sintetico + { + TotalClientes = ClassificacaoFiltrado.Count() + } + }); + break; + case 7: + case 11: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + break; + } + } + + public async Task GerarRelatorio(DateTime? inicio, DateTime? fim) + { + ErroRelatorio = "NÃO HÁ DADOS NO PERÍODO E FILTROS SELECIONADOS."; + ColunasOcultas = new List(); + FiltroPersonalizadoSelecionado = null; + VisibilityFiltroPersonalizado = (Visibility)0; + RamosSelecionados = null; + RamoSelecionado = null; + ReciboPagamento = false; + VisibilityUsuarios = false; + List seguradoras = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 0 + select x.Id).ToList() : new List()); + List ramos = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 1 + select x.Id).ToList() : new List()); + List vendedores = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 2 + select x.Id).ToList() : new List()); + List tipoVendedor = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 6 + select x.Id).ToList() : new List()); + List estipulantes = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 3 + select x.Id).ToList() : new List()); + List produtos = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 4 + select x.Id).ToList() : new List()); + List status = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 5 + select x.Id).ToList() : new List()); + List negocios = ((FiltroRelatorioSelecionado != null) ? (from x in FiltroRelatorioSelecionado + where (int)x.Tipo == 7 + select x.Id).ToList() : new List()); + List usuarios = (UsuariosFiltrados.Any((Usuario x) => x.Selecionado) ? (from x in UsuariosFiltrados + where x.Selecionado + select ((DomainBase)x).Id).ToList() : new List()); + List list = await VerificaVinculoVendedor(Recursos.Usuario); + List vinculoVendedores = new List(); + list.ForEach(delegate(VendedorUsuario v) + { + vinculoVendedores.Add(((DomainBase)v.Vendedor).Id); + }); + if (vendedores.Count == 0 && list.Count > 0) + { + list.ForEach(delegate(VendedorUsuario x) + { + vendedores.Add(((DomainBase)x.Vendedor).Id); + }); + } + RelatorioViewModel relatorioViewModel = this; + Filtros val = new Filtros + { + Inicio = (inicio ?? Inicio), + Fim = (fim ?? Fim), + ValorInicio = InicioValor, + ValorFim = FimValor, + Status = status, + Seguradoras = seguradoras, + Ramos = ramos, + Estipulantes = estipulantes, + Produtos = produtos, + Vendedores = vendedores, + VinculoVendedores = vinculoVendedores, + TipoVendedor = tipoVendedor, + Negocio = negocios, + Referencia = Referencia + }; + Empresa empresa2 = Empresa; + val.IdEmpresa = ((empresa2 != null) ? ((DomainBase)empresa2).Id : Recursos.Usuario.IdEmpresa); + val.Usuarios = usuarios; + relatorioViewModel.Filtros = val; + bool nomeSeguradora = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 44); + try + { + DateTime today = Funcoes.GetNetworkTime().Date; + Relatorio relatorio = Relatorio; + Mes selectedMes; + switch ((int)relatorio) + { + case 0: + case 1: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list23; + if ((int)Relatorio == 0) + { + List list22 = ((list.Count <= 0) ? (await _clienteServico.BuscarClientesAtvosInativos(Completo)).ToList() : (await _clienteServico.BuscarClientesAtvosInativosVinculo(Completo, list)).ToList()); + list23 = list22; + } + else + { + List list22 = ((list.Count <= 0) ? (await _clienteServico.BuscarAniversariantes(Filtros)) : (await _clienteServico.BuscarAniversariantesVinculo(Filtros, list))); + list23 = list22; + } + List list24 = list23; + if (list24.Count == 0) + { + ExtratosEnabled = false; + return false; + } + ClientesAtivosInativos = list24; + ClientesAtivosInativosFiltrado = new ObservableCollection(ClientesAtivosInativos); + break; + } + case 17: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List licenciamentos = await _apoliceServico.BuscarLicenciamentos(Filtros); + if (licenciamentos.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List analiticoLicenciamento = new List(); + licenciamentos.SelectMany((Documento x) => x.ItensAtivo).ToList().ForEach(delegate(Item i) + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_00b0: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Unknown result type (might be due to invalid IL or missing references) + //IL_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_019c: Unknown result type (might be due to invalid IL or missing references) + //IL_01b4: Unknown result type (might be due to invalid IL or missing references) + //IL_01d5: Unknown result type (might be due to invalid IL or missing references) + //IL_022b: Unknown result type (might be due to invalid IL or missing references) + //IL_023c: Unknown result type (might be due to invalid IL or missing references) + //IL_0259: Unknown result type (might be due to invalid IL or missing references) + //IL_02a6: Unknown result type (might be due to invalid IL or missing references) + //IL_02b2: Unknown result type (might be due to invalid IL or missing references) + //IL_02b9: Unknown result type (might be due to invalid IL or missing references) + //IL_02d0: Expected O, but got Unknown + Documento val17 = ((IEnumerable)licenciamentos).FirstOrDefault((Func)((Documento d) => ((DomainBase)d).Id == ((DomainBase)i.Documento).Id)); + if (val17 != null) + { + Licenciamento val18 = new Licenciamento + { + Id = ((DomainBase)val17.Controle.Cliente).Id + }; + Cliente cliente5 = val17.Controle.Cliente; + val18.Cliente = ((cliente5 != null) ? cliente5.Nome : null) ?? ""; + val18.Telefone = string.Join(" | ", val17.Controle.Cliente.Telefones.Select((ClienteTelefone t) => ((TelefoneBase)t).Prefixo + " " + ((TelefoneBase)t).Numero)); + val18.Email = string.Join(" | ", val17.Controle.Cliente.Emails.Select((ClienteEmail t) => ((EmailBase)t).Email)); + Produto produto3 = val17.Controle.Produto; + val18.Produto = ((produto3 != null) ? produto3.Nome : null) ?? ""; + val18.Ramo = val17.Controle.Ramo.Nome ?? ""; + val18.Seguradora = (nomeSeguradora ? val17.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(val17.Controle.Seguradora.NomeSocial)) ? val17.Controle.Seguradora.NomeSocial : val17.Controle.Seguradora.Nome)); + Vendedor vendedorPrincipal2 = val17.VendedorPrincipal; + val18.Vendedor = ((vendedorPrincipal2 != null) ? vendedorPrincipal2.Nome : null); + Estipulante estipulante2 = val17.Estipulante1; + val18.Estipulante = ((estipulante2 != null) ? estipulante2.Nome : null) ?? ""; + val18.TodosVendedores = ((val17.Vendedores == null || val17.Vendedores.Count == 0) ? "" : string.Join(" | ", val17.Vendedores.Select((Vendedor v) => v.Nome))); + val18.Item = i.Descricao; + Auto auto = i.Auto; + val18.Placa = ((auto != null) ? auto.Placa : null); + Auto auto2 = i.Auto; + object categoria; + if (auto2 != null && auto2.Categoria.HasValue) + { + Auto auto3 = i.Auto; + categoria = ((auto3 != null) ? EnumHelper.GetDescription(auto3.Categoria) : null); + } + else + { + categoria = "AUTOMÓVEL"; + } + val18.Categoria = (string)categoria; + val18.EntidadeItem = i; + val18.Documento = val17; + val18.PastaCliente = val17.Controle.Cliente.Pasta; + Licenciamento item7 = val18; + analiticoLicenciamento.Add(item7); + } + }); + Licenciamento = analiticoLicenciamento.OrderBy((Licenciamento x) => x.Cliente).ToList(); + LicenciamentoFiltrado = new ObservableCollection(Licenciamento); + break; + } + case 27: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List placas = await _apoliceServico.BuscarPlacas(Filtros); + if (placas.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List analiticoPlaca = new List(); + placas.SelectMany((Documento x) => x.ItensAtivo).ToList().ForEach(delegate(Item i) + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_00b0: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Unknown result type (might be due to invalid IL or missing references) + //IL_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_019c: Unknown result type (might be due to invalid IL or missing references) + //IL_01b4: Unknown result type (might be due to invalid IL or missing references) + //IL_01d5: Unknown result type (might be due to invalid IL or missing references) + //IL_022b: Unknown result type (might be due to invalid IL or missing references) + //IL_023c: Unknown result type (might be due to invalid IL or missing references) + //IL_0259: Unknown result type (might be due to invalid IL or missing references) + //IL_02a6: Unknown result type (might be due to invalid IL or missing references) + //IL_02b2: Unknown result type (might be due to invalid IL or missing references) + //IL_02b9: Unknown result type (might be due to invalid IL or missing references) + //IL_02d0: Expected O, but got Unknown + Documento val31 = ((IEnumerable)placas).FirstOrDefault((Func)((Documento d) => ((DomainBase)d).Id == ((DomainBase)i.Documento).Id)); + if (val31 != null) + { + Placas val32 = new Placas + { + Id = ((DomainBase)val31.Controle.Cliente).Id + }; + Cliente cliente8 = val31.Controle.Cliente; + val32.Cliente = ((cliente8 != null) ? cliente8.Nome : null) ?? ""; + val32.Telefone = string.Join(" | ", val31.Controle.Cliente.Telefones.Select((ClienteTelefone t) => ((TelefoneBase)t).Prefixo + " " + ((TelefoneBase)t).Numero)); + val32.Email = string.Join(" | ", val31.Controle.Cliente.Emails.Select((ClienteEmail t) => ((EmailBase)t).Email)); + Produto produto7 = val31.Controle.Produto; + val32.Produto = ((produto7 != null) ? produto7.Nome : null) ?? ""; + val32.Ramo = val31.Controle.Ramo.Nome ?? ""; + val32.Seguradora = (nomeSeguradora ? val31.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(val31.Controle.Seguradora.NomeSocial)) ? val31.Controle.Seguradora.NomeSocial : val31.Controle.Seguradora.Nome)); + Vendedor vendedorPrincipal5 = val31.VendedorPrincipal; + val32.Vendedor = ((vendedorPrincipal5 != null) ? vendedorPrincipal5.Nome : null); + Estipulante estipulante5 = val31.Estipulante1; + val32.Estipulante = ((estipulante5 != null) ? estipulante5.Nome : null) ?? ""; + val32.TodosVendedores = ((val31.Vendedores == null || val31.Vendedores.Count == 0) ? "" : string.Join(" | ", val31.Vendedores.Select((Vendedor v) => v.Nome))); + val32.Item = i.Descricao; + Auto auto4 = i.Auto; + val32.Placa = ((auto4 != null) ? auto4.Placa : null); + Auto auto5 = i.Auto; + object categoria2; + if (auto5 != null && auto5.Categoria.HasValue) + { + Auto auto6 = i.Auto; + categoria2 = ((auto6 != null) ? EnumHelper.GetDescription(auto6.Categoria) : null); + } + else + { + categoria2 = "AUTOMÓVEL"; + } + val32.Categoria = (string)categoria2; + val32.EntidadeItem = i; + val32.Documento = val31; + val32.PastaCliente = val31.Controle.Cliente.Pasta; + Placas item10 = val32; + analiticoPlaca.Add(item10); + } + }); + Placas = analiticoPlaca.OrderBy((Placas x) => x.Cliente).ToList(); + PlacaFiltrado = new ObservableCollection(Placas); + break; + } + case 18: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list17 = await _apoliceServico.BuscarTarefas(Filtros); + if (list17.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List analiticoTarefa = new List(); + list17.ForEach(delegate(Tarefa x) + { + if (x != null) + { + analiticoTarefa.Add(x); + } + }); + Tarefa = analiticoTarefa.OrderBy((Tarefa x) => x.Cliente).ToList(); + TarefaFiltrado = new ObservableCollection(Tarefa); + break; + } + case 3: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list11 = await _apoliceServico.BuscarApolicesPendentes(Filtros); + if (list11.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List apolicePendente = ((IEnumerable)list11).Select((Func)delegate(Documento x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00cc: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: Unknown result type (might be due to invalid IL or missing references) + //IL_0111: Unknown result type (might be due to invalid IL or missing references) + //IL_012c: Unknown result type (might be due to invalid IL or missing references) + //IL_0144: Unknown result type (might be due to invalid IL or missing references) + //IL_0155: Unknown result type (might be due to invalid IL or missing references) + //IL_0166: Unknown result type (might be due to invalid IL or missing references) + //IL_0177: Unknown result type (might be due to invalid IL or missing references) + //IL_0188: Unknown result type (might be due to invalid IL or missing references) + //IL_01b3: Unknown result type (might be due to invalid IL or missing references) + //IL_01d7: Unknown result type (might be due to invalid IL or missing references) + //IL_0249: Unknown result type (might be due to invalid IL or missing references) + //IL_0250: Unknown result type (might be due to invalid IL or missing references) + //IL_0268: Unknown result type (might be due to invalid IL or missing references) + //IL_0285: Unknown result type (might be due to invalid IL or missing references) + //IL_02ab: Unknown result type (might be due to invalid IL or missing references) + //IL_0310: Unknown result type (might be due to invalid IL or missing references) + //IL_0321: Unknown result type (might be due to invalid IL or missing references) + //IL_0347: Unknown result type (might be due to invalid IL or missing references) + //IL_0358: Unknown result type (might be due to invalid IL or missing references) + //IL_036e: Unknown result type (might be due to invalid IL or missing references) + //IL_0396: Unknown result type (might be due to invalid IL or missing references) + //IL_03f9: Unknown result type (might be due to invalid IL or missing references) + //IL_0423: Unknown result type (might be due to invalid IL or missing references) + //IL_042f: Unknown result type (might be due to invalid IL or missing references) + //IL_0455: Unknown result type (might be due to invalid IL or missing references) + //IL_0466: Unknown result type (might be due to invalid IL or missing references) + //IL_0477: Unknown result type (might be due to invalid IL or missing references) + //IL_0488: Unknown result type (might be due to invalid IL or missing references) + //IL_04a4: Expected O, but got Unknown + ApolicePendente val36 = new ApolicePendente + { + Pendencia = ((!((today - x.Vigencia1).TotalDays < 0.0)) ? int.Parse($"{(today - x.Vigencia1).TotalDays:00}") : 0) + }; + Cliente cliente10 = x.Controle.Cliente; + val36.Cliente = ((cliente10 != null) ? cliente10.Nome : null) ?? ""; + Cliente cliente11 = x.Controle.Cliente; + val36.DocumentoCli = ((cliente11 != null) ? cliente11.Documento : null) ?? ""; + val36.Proposta = x.Proposta ?? ""; + val36.PedidoEndosso = x.PropostaEndosso ?? ""; + val36.Comissao = x.Comissao; + Negocio? negocio2 = x.Negocio; + val36.Negocio = (negocio2.HasValue ? EnumHelper.GetDescription(negocio2.GetValueOrDefault()) : null) ?? ""; + val36.PremioLiquido = x.PremioLiquido; + val36.PremioTotal = x.PremioTotal; + val36.VigenciaFinal = x.Vigencia2; + val36.VigenciaInicial = x.Vigencia1; + Produto produto9 = x.Controle.Produto; + val36.Produto = ((produto9 != null) ? produto9.Nome : null) ?? ""; + val36.Ramo = x.Controle.Ramo.Nome ?? ""; + val36.Seguradora = (nomeSeguradora ? x.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Controle.Seguradora.NomeSocial)) ? x.Controle.Seguradora.NomeSocial : x.Controle.Seguradora.Nome)); + val36.Status = EnumHelper.GetDescription(x.Situacao) ?? ""; + Vendedor vendedorPrincipal8 = x.VendedorPrincipal; + val36.Vendedor = ((vendedorPrincipal8 != null) ? vendedorPrincipal8.Nome : null); + Estipulante estipulante8 = x.Estipulante1; + val36.Estipulante = ((estipulante8 != null) ? estipulante8.Nome : null) ?? ""; + val36.TodosVendedores = ((x.Vendedores == null || x.Vendedores.Count == 0) ? "" : string.Join("; ", x.Vendedores.Select((Vendedor v) => v.Nome))); + val36.DataControle = x.DataControle; + Status status8 = x.Status; + val36.StatusApolice = ((status8 != null) ? status8.Nome : null) ?? ""; + val36.Tipo = x.Tipo; + val36.IdEmpresa = x.Controle.IdEmpresa; + Empresa? obj28 = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == x.Controle.IdEmpresa)); + val36.Empresa = ((obj28 != null) ? obj28.NomeSocial : null); + val36.Item = ((x.ItensAtivo == null) ? "" : ((x.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.ItensAtivo.Count == 1) ? x.ItensAtivo.First().Descricao : ""))); + val36.Vinculo = x.Vinculo != null && x.Vinculo.IdApoliceDigital > 0; + val36.Documento = x; + Banco banco4 = x.Banco; + val36.Banco = ((banco4 != null) ? banco4.Nome : null) ?? ""; + val36.Conta = x.Conta; + val36.Agencia = x.Agencia; + val36.Pasta = x.Pasta; + val36.PastaCliente = x.Controle.Cliente.Pasta; + return val36; + }).ToList(); + ApolicePendente = apolicePendente; + ApolicePendenteFiltrado = new ObservableCollection(ApolicePendente); + break; + } + case 2: + { + bool flag = Filtros.Inicio.AddDays(61.0) < Filtros.Fim; + if (flag) + { + flag = !(await ShowMessage("O RELATÓRIO DE PRODUÇÃO É INDIVIDUALIZADO, PORTANTO DEMORADO, CASO O INTUITO DA GERAÇÃO SEJA OS TOTAIS, OUTRAS OPÇÕES SÃO MAIS RÁPIDAS, COMO O RELATÓRIO DE FECHAMENTO!", "GERAR MESMO ASSIM", "CANCELAR")); + } + if (flag) + { + return false; + } + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + Task> producaoTask = _apoliceServico.BuscarApolices(Filtros, LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3)); + Task> faturaTask = _parcelaServico.BuscarFaturas(Filtros, LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3)); + await Task.WhenAll>(producaoTask, faturaTask); + List result = producaoTask.Result; + List result2 = faturaTask.Result; + result.AddRange(result2); + if (result.Count == 0) + { + ExtratosEnabled = false; + return false; + } + bool listarRepasse = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 37); + List producao = ((IEnumerable)result).Select((Func)delegate(Documento x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00c4: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_0108: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_012a: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Unknown result type (might be due to invalid IL or missing references) + //IL_014c: Unknown result type (might be due to invalid IL or missing references) + //IL_015d: Unknown result type (might be due to invalid IL or missing references) + //IL_016e: Unknown result type (might be due to invalid IL or missing references) + //IL_017f: Unknown result type (might be due to invalid IL or missing references) + //IL_01aa: Unknown result type (might be due to invalid IL or missing references) + //IL_01ce: Unknown result type (might be due to invalid IL or missing references) + //IL_0245: Unknown result type (might be due to invalid IL or missing references) + //IL_024c: Unknown result type (might be due to invalid IL or missing references) + //IL_0264: Unknown result type (might be due to invalid IL or missing references) + //IL_0281: Unknown result type (might be due to invalid IL or missing references) + //IL_02a5: Unknown result type (might be due to invalid IL or missing references) + //IL_02b6: Unknown result type (might be due to invalid IL or missing references) + //IL_031b: Unknown result type (might be due to invalid IL or missing references) + //IL_0380: Unknown result type (might be due to invalid IL or missing references) + //IL_0391: Unknown result type (might be due to invalid IL or missing references) + //IL_03c5: Unknown result type (might be due to invalid IL or missing references) + //IL_03d6: Unknown result type (might be due to invalid IL or missing references) + //IL_03fc: Unknown result type (might be due to invalid IL or missing references) + //IL_0412: Unknown result type (might be due to invalid IL or missing references) + //IL_043a: Unknown result type (might be due to invalid IL or missing references) + //IL_0446: Unknown result type (might be due to invalid IL or missing references) + //IL_04a9: Unknown result type (might be due to invalid IL or missing references) + //IL_04ba: Unknown result type (might be due to invalid IL or missing references) + //IL_04d9: Unknown result type (might be due to invalid IL or missing references) + //IL_04f8: Unknown result type (might be due to invalid IL or missing references) + //IL_04ff: Unknown result type (might be due to invalid IL or missing references) + //IL_0509: Unknown result type (might be due to invalid IL or missing references) + //IL_051a: Unknown result type (might be due to invalid IL or missing references) + //IL_056e: Unknown result type (might be due to invalid IL or missing references) + //IL_0584: Unknown result type (might be due to invalid IL or missing references) + //IL_0595: Unknown result type (might be due to invalid IL or missing references) + //IL_05bb: Unknown result type (might be due to invalid IL or missing references) + //IL_05cc: Unknown result type (might be due to invalid IL or missing references) + //IL_05dd: Unknown result type (might be due to invalid IL or missing references) + //IL_05f8: Unknown result type (might be due to invalid IL or missing references) + //IL_0613: Unknown result type (might be due to invalid IL or missing references) + //IL_0696: Unknown result type (might be due to invalid IL or missing references) + //IL_0719: Unknown result type (might be due to invalid IL or missing references) + //IL_074a: Expected O, but got Unknown + Producao val29 = new Producao(); + Cliente cliente7 = x.Controle.Cliente; + val29.Cliente = ((cliente7 != null) ? cliente7.Nome : null) ?? ""; + val29.Proposta = x.Proposta ?? ""; + val29.Apolice = x.Apolice ?? ""; + val29.ApoliceConferida = (x.ApoliceConferida ? "SIM" : "NÃO"); + val29.PropostaEndosso = x.PropostaEndosso ?? ""; + val29.Endosso = x.Endosso ?? ""; + val29.Comissao = x.Comissao; + NegocioCorretora? negocioCorretora3 = x.NegocioCorretora; + val29.Negocio = (negocioCorretora3.HasValue ? EnumHelper.GetDescription(negocioCorretora3.GetValueOrDefault()) : null) ?? ""; + val29.PremioLiquido = x.PremioLiquido; + val29.PremioTotal = x.PremioTotal; + val29.NumeroParcelas = x.NumeroParcelas; + val29.Emissao = x.Emissao; + val29.VigenciaFinal = x.Vigencia2; + val29.VigenciaInicial = x.Vigencia1; + val29.Remessa = x.Remessa; + Produto produto6 = x.Controle.Produto; + val29.Produto = ((produto6 != null) ? produto6.Nome : null) ?? ""; + val29.Ramo = x.Controle.Ramo.Nome ?? ""; + val29.Seguradora = (nomeSeguradora ? x.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Controle.Seguradora.NomeSocial)) ? x.Controle.Seguradora.NomeSocial : x.Controle.Seguradora.Nome)); + val29.Status = EnumHelper.GetDescription(x.Situacao) ?? ""; + Vendedor vendedorPrincipal4 = x.VendedorPrincipal; + val29.Vendedor = ((vendedorPrincipal4 != null) ? vendedorPrincipal4.Nome : null); + val29.RepasseVendedor = ((!listarRepasse) ? null : x.PercentualRepasse); + val29.Estipulante = x.Estipulantes; + val29.TodosVendedores = ((x.Vendedores == null || x.Vendedores.Count == 0) ? "" : string.Join("; ", x.Vendedores.Select((Vendedor v) => v.Nome))); + val29.DescricaoTipoVendedor = ((x.Pagamentos == null || x.Pagamentos.Count == 0) ? "" : string.Join("; ", x.Pagamentos.Select((VendedorParcela v) => v.TipoVendedor.Descricao ?? ""))); + val29.Tipo = x.Tipo; + val29.TipoDocumento = ((x.Tipo == 0) ? "APÓLICE" : ((x.Tipo == 1) ? "ENDOSSO" : "FATURA")); + val29.DataControle = x.DataControle; + Status status5 = x.Status; + val29.StatusApolice = ((status5 != null) ? status5.Nome : null) ?? ""; + val29.IdEmpresa = x.Controle.IdEmpresa; + Empresa? obj19 = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == x.Controle.IdEmpresa)); + val29.Empresa = ((obj19 != null) ? obj19.NomeSocial : null); + val29.Documento = x; + val29.Item = ((x.ItensAtivo == null) ? "" : ((x.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.ItensAtivo.Count == 1) ? x.ItensAtivo.First().Descricao : ""))); + val29.Assinaturas = x.Assinaturas; + val29.AssinadaSiggner = (x.AssinadaSiggner ? "SIM" : "NÃO"); + val29.PropAssinada = (x.PropostaAssinada ? "SIM" : "NÃO"); + val29.StatusAssinatura = x.StatusAssinatura; + val29.Pasta = x.Pasta; + val29.ComissaoGerada = (x.PremioLiquido + (x.AdicionalComiss ? x.PremioAdicional : 0m)) * x.Comissao * 0.01m; + val29.TipoPagamento = EnumHelper.GetDescription(x.TipoRecebimento); + val29.DataCriacao = x.DataCriacao; + Banco banco3 = x.Banco; + val29.Banco = ((banco3 != null) ? banco3.Nome : null) ?? ""; + val29.Conta = x.Conta; + val29.Agencia = x.Agencia; + val29.PastaCliente = x.Controle.Cliente.Pasta; + val29.DocumentoCliente = x.Controle.Cliente.Documento; + val29.Telefones = ((x.Controle.Cliente.Telefones == null || x.Controle.Cliente.Telefones.Count == 0) ? "" : string.Join(" | ", x.Controle.Cliente.Telefones.Select((ClienteTelefone v) => (((TelefoneBase)v).Prefixo + " " + ((TelefoneBase)v).Numero).Trim()))); + val29.Emails = ((x.Controle.Cliente.Emails == null || x.Controle.Cliente.Emails.Count == 0) ? "" : string.Join(" | ", x.Controle.Cliente.Emails.Select((ClienteEmail v) => ((EmailBase)v).Email))); + val29.TipoPessoa = ((x.Controle.Cliente.Documento.Length > 14) ? "PJ" : "PF"); + return val29; + }).ToList(); + Producao = producao; + ProducaoFiltrado = new ObservableCollection(Producao); + break; + } + case 4: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List analiticoRenovacao = (await _apoliceServico.BuscarApolicesVigenciaFinal(Filtros, Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 31))).Where((Documento documento) => documento.Tipo != 3).Select((Func)delegate(Documento documento) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0079: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: Unknown result type (might be due to invalid IL or missing references) + //IL_00ac: Unknown result type (might be due to invalid IL or missing references) + //IL_00bd: Unknown result type (might be due to invalid IL or missing references) + //IL_00e8: Unknown result type (might be due to invalid IL or missing references) + //IL_0113: Unknown result type (might be due to invalid IL or missing references) + //IL_0180: Unknown result type (might be due to invalid IL or missing references) + //IL_0187: Unknown result type (might be due to invalid IL or missing references) + //IL_018d: Invalid comparison between Unknown and I4 + //IL_0195: Unknown result type (might be due to invalid IL or missing references) + //IL_019b: Invalid comparison between Unknown and I4 + //IL_01c2: Unknown result type (might be due to invalid IL or missing references) + //IL_01a3: Unknown result type (might be due to invalid IL or missing references) + //IL_01df: Unknown result type (might be due to invalid IL or missing references) + //IL_020b: Unknown result type (might be due to invalid IL or missing references) + //IL_0237: Unknown result type (might be due to invalid IL or missing references) + //IL_025d: Unknown result type (might be due to invalid IL or missing references) + //IL_02c2: Unknown result type (might be due to invalid IL or missing references) + //IL_02d3: Unknown result type (might be due to invalid IL or missing references) + //IL_02df: Unknown result type (might be due to invalid IL or missing references) + //IL_02f0: Unknown result type (might be due to invalid IL or missing references) + //IL_0353: Unknown result type (might be due to invalid IL or missing references) + //IL_0387: Unknown result type (might be due to invalid IL or missing references) + //IL_03a6: Unknown result type (might be due to invalid IL or missing references) + //IL_03b7: Unknown result type (might be due to invalid IL or missing references) + //IL_03dd: Unknown result type (might be due to invalid IL or missing references) + //IL_03f3: Unknown result type (might be due to invalid IL or missing references) + //IL_0414: Unknown result type (might be due to invalid IL or missing references) + //IL_0449: Unknown result type (might be due to invalid IL or missing references) + //IL_046f: Unknown result type (might be due to invalid IL or missing references) + //IL_0480: Unknown result type (might be due to invalid IL or missing references) + //IL_0491: Unknown result type (might be due to invalid IL or missing references) + //IL_04a2: Unknown result type (might be due to invalid IL or missing references) + //IL_04bd: Unknown result type (might be due to invalid IL or missing references) + //IL_04ce: Unknown result type (might be due to invalid IL or missing references) + //IL_04f9: Unknown result type (might be due to invalid IL or missing references) + //IL_058d: Unknown result type (might be due to invalid IL or missing references) + //IL_05a3: Unknown result type (might be due to invalid IL or missing references) + //IL_05f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0612: Expected O, but got Unknown + Renovacao val16 = new Renovacao(); + Cliente cliente = documento.Controle.Cliente; + val16.Cliente = ((cliente != null) ? cliente.Nome : null) ?? ""; + val16.Apolice = documento.Apolice ?? ""; + val16.PremioLiquido = documento.PremioLiquido; + val16.PremioTotal = documento.PremioTotal; + NegocioCorretora? negocioCorretora = documento.NegocioCorretora; + val16.Negocio = (negocioCorretora.HasValue ? EnumHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + val16.VigenciaFinal = documento.Vigencia2; + Produto produto2 = documento.Controle.Produto; + val16.Produto = ((produto2 != null) ? produto2.Nome : null) ?? ""; + Ramo ramo = documento.Controle.Ramo; + val16.Ramo = ((ramo != null) ? ramo.Nome : null) ?? ""; + val16.Seguradora = (nomeSeguradora ? documento.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(documento.Controle.Seguradora.NomeSocial)) ? documento.Controle.Seguradora.NomeSocial : documento.Controle.Seguradora.Nome)); + val16.Status = (((int)documento.Situacao == 1 || (int)documento.Situacao == 2) ? "NÃO TRABALHADO" : (EnumHelper.GetDescription(documento.Situacao) ?? "")); + Vendedor vendedorPrincipal = documento.VendedorPrincipal; + val16.Vendedor = ((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null); + Cliente cliente2 = documento.Controle.Cliente; + val16.Telefone = JoinTelefones((cliente2 != null) ? cliente2.Telefones.ToList() : null); + Cliente cliente3 = documento.Controle.Cliente; + val16.Email = JoinEmails((cliente3 != null) ? cliente3.Emails.ToList() : null); + Estipulante estipulante = documento.Estipulante1; + val16.Estipulante = ((estipulante != null) ? estipulante.Nome : null) ?? ""; + val16.TodosVendedores = ((documento.Vendedores == null || documento.Vendedores.Count == 0) ? "" : string.Join("; ", documento.Vendedores.Select((Vendedor v) => v.Nome))); + val16.Tipo = documento.Tipo; + val16.Documento = documento; + val16.Comissao = documento.Comissao; + val16.Item = ((documento.ItensAtivo == null) ? "" : ((documento.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((documento.ItensAtivo.Count == 1) ? documento.ItensAtivo.First().Descricao : ""))); + val16.TipoDocumento = ((documento.Tipo == 0) ? "APÓLICE" : ((documento.Tipo == 1) ? "ENDOSSO" : "")); + val16.Sinistro = (documento.Sinistro ? "SIM" : "NÃO"); + val16.DataControle = documento.DataControle; + Status status3 = documento.Status; + val16.StatusApolice = ((status3 != null) ? status3.Nome : null) ?? ""; + val16.IdEmpresa = documento.Controle.IdEmpresa; + val16.Empresa = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == documento.Controle.IdEmpresa)).NomeSocial; + val16.QtdSinistro = documento.ItensAtivo.Sum((Item s) => s.Sinistros.Count); + Banco banco = documento.Banco; + val16.Banco = ((banco != null) ? banco.Nome : null) ?? ""; + val16.Conta = documento.Conta; + val16.Agencia = documento.Agencia; + val16.Pasta = documento.Pasta; + val16.PastaCliente = documento.Controle.Cliente.Pasta; + val16.Calculos = documento.Calculos; + Cliente cliente4 = documento.Controle.Cliente; + val16.DocumentoCliente = ((cliente4 != null) ? cliente4.Documento : null) ?? ""; + val16.TipoPessoa = ((documento.Controle.Cliente.Documento == null) ? "" : ((documento.Controle.Cliente.Documento.Length == 11) ? "FÍSICA" : ((documento.Controle.Cliente.Documento.Length == 14 && documento.Controle.Cliente.Documento.Contains(".")) ? "FÍSICA" : "JURÍDICA"))); + val16.TipoPagamento = EnumHelper.GetDescription(documento.TipoRecebimento); + val16.ComissaoGerada = (documento.PremioLiquido + (documento.AdicionalComiss ? documento.PremioAdicional : 0m)) * documento.Comissao * 0.01m; + val16.Endosso = documento.Endosso ?? ""; + return val16; + }).ToList(); + List collection4 = (await new ProspeccaoServico().BuscarProspeccoes(Filtros)).Where((Prospeccao x) => x.Renovacao).Select(delegate(Prospeccao x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + Renovacao val15 = new Renovacao(); + val15.Cliente = x.Nome ?? ""; + val15.DocumentoCliente = x.Documento; + val15.Apolice = "PROSPECÇÃO"; + val15.VigenciaFinal = x.VigenciaFinal; + StatusProspeccao? status2 = x.Status; + val15.Status = (status2.HasValue ? EnumHelper.GetDescription(status2.GetValueOrDefault()) : null) ?? ""; + Vendedor vendedor = x.Vendedor; + val15.Vendedor = ((vendedor != null) ? vendedor.Nome : null); + Vendedor vendedor2 = x.Vendedor; + val15.TodosVendedores = ((vendedor2 != null) ? vendedor2.Nome : null); + val15.Telefone = x.Prefixo1 + " " + x.Telefone1 + " | " + x.Prefixo2 + " " + x.Telefone2; + val15.Email = x.Email; + val15.Tipo = 3; + val15.TipoDocumento = "PROSPECÇÃO"; + val15.Item = x.Item; + Produto produto = x.Produto; + val15.Produto = ((produto != null) ? produto.Nome : null); + val15.Prospeccao = x; + return val15; + }).ToList(); + analiticoRenovacao.AddRange(collection4); + if (analiticoRenovacao.Count == 0) + { + ExtratosEnabled = false; + return false; + } + Renovacao = analiticoRenovacao.OrderBy((Renovacao x) => x.VigenciaFinal).ToList(); + RenovacaoFiltrado = new ObservableCollection(Renovacao); + break; + } + case 5: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list10 = await _parcelaServico.BuscarParcelasRecebimento(Filtros); + if (list10.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List comissao = ((IEnumerable)list10).Select((Func)delegate(Parcela x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0047: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_0085: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00e1: Unknown result type (might be due to invalid IL or missing references) + //IL_00f7: Unknown result type (might be due to invalid IL or missing references) + //IL_010d: Unknown result type (might be due to invalid IL or missing references) + //IL_0123: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_0162: Unknown result type (might be due to invalid IL or missing references) + //IL_0178: Unknown result type (might be due to invalid IL or missing references) + //IL_0189: Unknown result type (might be due to invalid IL or missing references) + //IL_019a: Unknown result type (might be due to invalid IL or missing references) + //IL_022b: Unknown result type (might be due to invalid IL or missing references) + //IL_0244: Unknown result type (might be due to invalid IL or missing references) + //IL_0255: Unknown result type (might be due to invalid IL or missing references) + //IL_0266: Unknown result type (might be due to invalid IL or missing references) + //IL_0277: Unknown result type (might be due to invalid IL or missing references) + //IL_0288: Unknown result type (might be due to invalid IL or missing references) + //IL_029f: Unknown result type (might be due to invalid IL or missing references) + //IL_02b0: Unknown result type (might be due to invalid IL or missing references) + //IL_02c1: Unknown result type (might be due to invalid IL or missing references) + //IL_02d2: Unknown result type (might be due to invalid IL or missing references) + //IL_02e3: Unknown result type (might be due to invalid IL or missing references) + //IL_02fa: Unknown result type (might be due to invalid IL or missing references) + //IL_0387: Unknown result type (might be due to invalid IL or missing references) + //IL_0411: Unknown result type (might be due to invalid IL or missing references) + //IL_0492: Unknown result type (might be due to invalid IL or missing references) + //IL_04c2: Unknown result type (might be due to invalid IL or missing references) + //IL_04ed: Unknown result type (might be due to invalid IL or missing references) + //IL_05c8: Unknown result type (might be due to invalid IL or missing references) + //IL_062d: Unknown result type (might be due to invalid IL or missing references) + //IL_063e: Unknown result type (might be due to invalid IL or missing references) + //IL_0664: Unknown result type (might be due to invalid IL or missing references) + //IL_0696: Unknown result type (might be due to invalid IL or missing references) + //IL_06b1: Unknown result type (might be due to invalid IL or missing references) + //IL_06d2: Unknown result type (might be due to invalid IL or missing references) + //IL_0730: Unknown result type (might be due to invalid IL or missing references) + //IL_0737: Unknown result type (might be due to invalid IL or missing references) + //IL_0741: Unknown result type (might be due to invalid IL or missing references) + //IL_0757: Unknown result type (might be due to invalid IL or missing references) + //IL_0777: Unknown result type (might be due to invalid IL or missing references) + //IL_078c: Unknown result type (might be due to invalid IL or missing references) + //IL_0792: Invalid comparison between Unknown and I4 + //IL_07bf: Expected O, but got Unknown + Comissao val37 = new Comissao + { + ParcelaEntity = x, + Cliente = (x.Documento.Controle.Cliente.Nome ?? ""), + Apolice = (x.Documento.Apolice ?? ""), + Endosso = (x.Documento.Endosso ?? ""), + Status = (EnumHelper.GetDescription(x.Documento.Situacao) ?? "") + }; + NegocioCorretora? negocioCorretora4 = x.Documento.NegocioCorretora; + val37.Negocio = (negocioCorretora4.HasValue ? EnumHelper.GetDescription(negocioCorretora4.GetValueOrDefault()) : null) ?? ""; + val37.VigenciaFinal = x.Documento.Vigencia2; + val37.VigenciaInicial = x.Documento.Vigencia1; + val37.PremioTotal = x.Documento.PremioTotal; + val37.PremioLiquido = x.Documento.PremioLiquido; + val37.Ramo = x.Documento.Controle.Ramo.Nome ?? ""; + val37.ComissaoApolice = x.Documento.Comissao; + val37.ComissaoPerc = x.Comissao; + val37.ValorRealizado = x.ValorRealizado; + val37.ValorComissao = ((x.Documento.Comissao > 0m) ? decimal.Round((x.Documento.PremioLiquido + (x.Documento.AdicionalComiss ? x.Documento.PremioAdicional : 0m)) * x.Documento.Comissao * 0.01m, 2) : 0m); + val37.Parcela = x.NumeroParcela.ToString(); + val37.Recebimento = x.DataRecebimento; + val37.Quitacao = x.DataQuitacao; + val37.Controle = x.DataControle; + val37.Vencimento = x.Vencimento; + val37.ComissaoBruta = decimal.Round(x.ValorComissao, 2); + val37.Ir = x.Irr; + val37.Iss = x.Iss; + val37.Desconto = x.Desconto; + val37.Outros = x.Outros; + val37.ComissaoRecebida = decimal.Round(x.ValorComDesconto, 2); + val37.Repasse = ((x.Vendedores == null || !x.Vendedores.Any()) ? 0m : decimal.Round(x.Vendedores.Where((VendedorParcela v) => v.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse).GetValueOrDefault(), 2)); + decimal valorComDesconto = x.ValorComDesconto; + decimal? obj29 = x.Vendedores?.Sum((VendedorParcela y) => y.ValorRepasse); + val37.ValorLiquido = decimal.Round(((decimal?)valorComDesconto - obj29).GetValueOrDefault(), 2); + val37.Seguradora = (nomeSeguradora ? x.Documento.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Documento.Controle.Seguradora.NomeSocial)) ? x.Documento.Controle.Seguradora.NomeSocial : x.Documento.Controle.Seguradora.Nome)); + Produto produto10 = x.Documento.Controle.Produto; + val37.Produto = ((produto10 != null) ? produto10.Nome : null) ?? ""; + Estipulante estipulante9 = x.Documento.Estipulante1; + val37.Estipulante = ((estipulante9 != null) ? estipulante9.Nome : null) ?? ""; + object obj31; + if (x.Vendedores != null && x.Vendedores.Count != 0) + { + VendedorParcela? obj30 = ((IEnumerable)x.Vendedores).FirstOrDefault((Func)((VendedorParcela v) => ((DomainBase)v.TipoVendedor).Id == 1)); + if (obj30 == null) + { + obj31 = null; + } + else + { + Vendedor vendedor5 = obj30.Vendedor; + obj31 = ((vendedor5 != null) ? vendedor5.Nome : null); + } + if (obj31 == null) + { + Vendedor? obj32 = ((IEnumerable)Recursos.Vendedores).FirstOrDefault((Func)((Vendedor v) => v.Corretora)); + obj31 = ((obj32 != null) ? obj32.Nome : null); + } + } + else + { + IEnumerable enumerable = Recursos.Vendedores.Where((Vendedor v) => v.Ativo && v.Corretora && v.IdEmpresa == x.IdEmpresa); + if (enumerable == null) + { + obj31 = null; + } + else + { + Vendedor? obj33 = enumerable.FirstOrDefault(); + obj31 = ((obj33 != null) ? obj33.Nome : null); + } + } + val37.Vendedor = (string)obj31; + val37.TodosVendedores = ((x.Vendedores == null || x.Vendedores.Count == 0) ? "" : string.Join("; ", x.Vendedores.Select((VendedorParcela v) => v.Vendedor.Nome))); + val37.Documento = x.Documento; + Documento documento9 = x.Documento; + val37.DataControle = ((documento9 != null) ? documento9.DataControle : null); + Documento documento10 = x.Documento; + object obj34; + if (documento10 == null) + { + obj34 = null; + } + else + { + Status status9 = documento10.Status; + obj34 = ((status9 != null) ? status9.Nome : null); + } + if (obj34 == null) + { + obj34 = ""; + } + val37.StatusApolice = (string)obj34; + val37.IdEmpresa = x.Documento.Controle.IdEmpresa; + val37.Empresa = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == x.Documento.Controle.IdEmpresa)).NomeSocial; + val37.Item = ((x.Documento.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.Documento.ItensAtivo.Count == 1) ? x.Documento.ItensAtivo.First().Descricao : "")); + val37.SubTipo = x.SubTipo; + val37.Pasta = x.Documento.Pasta; + val37.PastaCliente = x.Documento.Controle.Cliente.Pasta; + val37.TipoDocumento = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() == 2) ? "FATURA" : ((x.Documento.Tipo == 0) ? "APÓLICE" : "ENDOSSO")); + return val37; + }).ToList(); + Comissao = comissao; + ComissaoFiltrado = (Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 10) ? new ObservableCollection(Comissao.Where((Comissao x) => x.ComissaoRecebida != 0m).ToList()) : new ObservableCollection(Comissao)); + break; + } + case 6: + case 16: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list18 = (((int)Relatorio != 6) ? (await _parcelaServico.BuscarParcelas(Filtros, DocumentosAtivos)) : (await _parcelaServico.BuscarParcelasPendentes(Filtros))); + if (list18.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List pendente = ((IEnumerable)list18).Select((Func)delegate(Parcela x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00ce: Unknown result type (might be due to invalid IL or missing references) + //IL_00ee: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + //IL_011c: Unknown result type (might be due to invalid IL or missing references) + //IL_0132: Unknown result type (might be due to invalid IL or missing references) + //IL_015b: Unknown result type (might be due to invalid IL or missing references) + //IL_016f: Unknown result type (might be due to invalid IL or missing references) + //IL_0175: Invalid comparison between Unknown and I4 + //IL_0199: Unknown result type (might be due to invalid IL or missing references) + //IL_01e5: Unknown result type (might be due to invalid IL or missing references) + //IL_01eb: Invalid comparison between Unknown and I4 + //IL_0264: Unknown result type (might be due to invalid IL or missing references) + //IL_0278: Unknown result type (might be due to invalid IL or missing references) + //IL_027e: Invalid comparison between Unknown and I4 + //IL_02a2: Unknown result type (might be due to invalid IL or missing references) + //IL_02a8: Invalid comparison between Unknown and I4 + //IL_033a: Unknown result type (might be due to invalid IL or missing references) + //IL_034b: Unknown result type (might be due to invalid IL or missing references) + //IL_035c: Unknown result type (might be due to invalid IL or missing references) + //IL_036d: Unknown result type (might be due to invalid IL or missing references) + //IL_038c: Unknown result type (might be due to invalid IL or missing references) + //IL_03a0: Unknown result type (might be due to invalid IL or missing references) + //IL_03a6: Invalid comparison between Unknown and I4 + //IL_0481: Unknown result type (might be due to invalid IL or missing references) + //IL_0495: Unknown result type (might be due to invalid IL or missing references) + //IL_049b: Invalid comparison between Unknown and I4 + //IL_0589: Unknown result type (might be due to invalid IL or missing references) + //IL_05b9: Unknown result type (might be due to invalid IL or missing references) + //IL_063f: Unknown result type (might be due to invalid IL or missing references) + //IL_066a: Unknown result type (might be due to invalid IL or missing references) + //IL_068c: Unknown result type (might be due to invalid IL or missing references) + //IL_06df: Unknown result type (might be due to invalid IL or missing references) + //IL_06f0: Unknown result type (might be due to invalid IL or missing references) + //IL_0716: Unknown result type (might be due to invalid IL or missing references) + //IL_0748: Unknown result type (might be due to invalid IL or missing references) + //IL_07a6: Unknown result type (might be due to invalid IL or missing references) + //IL_07ad: Unknown result type (might be due to invalid IL or missing references) + //IL_07b7: Unknown result type (might be due to invalid IL or missing references) + //IL_07cd: Unknown result type (might be due to invalid IL or missing references) + //IL_07ee: Unknown result type (might be due to invalid IL or missing references) + //IL_07fd: Unknown result type (might be due to invalid IL or missing references) + //IL_081d: Unknown result type (might be due to invalid IL or missing references) + //IL_082e: Unknown result type (might be due to invalid IL or missing references) + //IL_0849: Unknown result type (might be due to invalid IL or missing references) + //IL_086a: Unknown result type (might be due to invalid IL or missing references) + //IL_0880: Unknown result type (might be due to invalid IL or missing references) + //IL_08a0: Unknown result type (might be due to invalid IL or missing references) + //IL_08c6: Unknown result type (might be due to invalid IL or missing references) + //IL_08cc: Invalid comparison between Unknown and I4 + //IL_08f9: Unknown result type (might be due to invalid IL or missing references) + //IL_092b: Expected O, but got Unknown + Pendente val27 = new Pendente + { + Pendencia = (int)(today - x.Vencimento).TotalDays, + ParcelaEntity = x, + Cliente = (x.Documento.Controle.Cliente.Nome ?? ""), + Apolice = (x.Documento.Apolice ?? ""), + Endosso = (x.Documento.Endosso ?? ""), + Status = (EnumHelper.GetDescription(x.Documento.Situacao) ?? "") + }; + Negocio? negocio = x.Documento.Negocio; + val27.Negocio = (negocio.HasValue ? EnumHelper.GetDescription(negocio.GetValueOrDefault()) : null) ?? ""; + val27.VigenciaInicial = x.Documento.Vigencia1; + val27.VigenciaFinal = x.Documento.Vigencia2; + val27.Ramo = x.Documento.Controle.Ramo.Nome ?? ""; + val27.ComissaoPerc = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() == 1) ? x.Documento.Comissao : x.Comissao); + val27.ComissaoGerada = ((x.Documento.Comissao > 0m) ? decimal.Round((((x.NumeroParcela == 999 && (int)x.Documento.TipoRecebimento.GetValueOrDefault() == 1) ? x.Valor : x.Documento.PremioLiquido) + (x.Documento.AdicionalComiss ? x.Documento.PremioAdicional : 0m)) * (x.Documento.Comissao / 100m), 2) : 0m); + val27.Pendentes = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() == 1 && x.NumeroParcela < 10) ? $"0{x.NumeroParcela} de {x.Documento.NumeroParcelas}" : (((int)x.Documento.TipoRecebimento.GetValueOrDefault() == 1 && x.NumeroParcela >= 10) ? $"{x.NumeroParcela} de {x.Documento.NumeroParcelas}" : $"{x.NumeroParcela}")); + val27.Vencimento = x.Vencimento; + val27.Quitacao = x.DataQuitacao; + val27.Controle = x.DataControle; + val27.Proposta = x.Documento.Proposta ?? ""; + val27.ComissaoPrevista = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() != 1) ? decimal.Round(x.Documento.PremioLiquido * (x.Comissao / 100m), 2) : ((x.Documento.NumeroParcelas == 0m) ? 0m : decimal.Round((x.Documento.PremioLiquido + (x.Documento.AdicionalComiss ? x.Documento.PremioAdicional : 0m)) * (x.Documento.Comissao / 100m) / x.Documento.NumeroParcelas, 2))); + val27.TotalPrevisto = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() == 1 && x.Documento.Parcelas != null) ? (decimal.Round((x.Documento.PremioLiquido + (x.Documento.AdicionalComiss ? x.Documento.PremioAdicional : 0m)) * (x.Documento.Comissao / 100m), 2) - x.Documento.Parcelas.Sum((Parcela p) => p.ValorComissao)) : decimal.Round(x.Documento.PremioLiquido * (x.Comissao / 100m), 2)); + Produto produto5 = x.Documento.Controle.Produto; + val27.Produto = ((produto5 != null) ? produto5.Nome : null) ?? ""; + val27.Seguradora = (nomeSeguradora ? x.Documento.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Documento.Controle.Seguradora.NomeSocial)) ? x.Documento.Controle.Seguradora.NomeSocial : x.Documento.Controle.Seguradora.Nome)); + Estipulante estipulante4 = x.Documento.Estipulante1; + val27.Estipulante = ((estipulante4 != null) ? estipulante4.Nome : null) ?? ""; + Vendedor vendedorPrincipal3 = x.Documento.VendedorPrincipal; + val27.Vendedor = ((vendedorPrincipal3 != null) ? vendedorPrincipal3.Nome : null); + val27.TodosVendedores = ((x.Vendedores != null) ? string.Join("; ", x.Vendedores.Select((VendedorParcela v) => v.Vendedor.Nome)) : ""); + val27.Documento = x.Documento; + Documento documento3 = x.Documento; + val27.DataControle = ((documento3 != null) ? documento3.DataControle : null); + Documento documento4 = x.Documento; + object obj18; + if (documento4 == null) + { + obj18 = null; + } + else + { + Status status4 = documento4.Status; + obj18 = ((status4 != null) ? status4.Nome : null); + } + if (obj18 == null) + { + obj18 = ""; + } + val27.StatusApolice = (string)obj18; + val27.Item = ((x.Documento.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.Documento.ItensAtivo.Count == 1) ? x.Documento.ItensAtivo.First().Descricao : "")); + val27.SubTipo = x.SubTipo; + val27.StatusPagamento = EnumHelper.GetDescription(x.StatusPagamento); + FormaPagamento? formaPagamento = x.Documento.FormaPagamento; + val27.FormaPagamento = (formaPagamento.HasValue ? EnumHelper.GetDescription(formaPagamento.GetValueOrDefault()) : null); + val27.DocumentoCliente = x.Documento.Controle.Cliente.Documento; + val27.ValorParcela = x.Valor; + val27.IdEmpresa = x.Documento.Controle.IdEmpresa; + val27.Empresa = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == x.Documento.Controle.IdEmpresa)).NomeSocial; + val27.Pasta = x.Documento.Pasta; + val27.PastaCliente = x.Documento.Controle.Cliente.Pasta; + val27.TipoDocumento = ((x.Documento.Tipo == 0 && (int)x.Documento.TipoRecebimento.GetValueOrDefault() == 2) ? "FATURA" : ((x.Documento.Tipo == 1) ? "ENDOSSO" : "APÓLICE")); + Cliente cliente6 = x.Documento.Controle.Cliente; + val27.Telefones = JoinTelefones((cliente6 != null) ? cliente6.Telefones.ToList() : null); + return val27; + }).ToList(); + Pendente = pendente; + PendenteFiltrado = new ObservableCollection(Pendente); + break; + } + case 9: + case 10: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list13 = (((int)Relatorio != 9) ? (await _sinistroServico.BuscarSinistro(Filtros)) : (await _sinistroServico.BuscarSinistroPendente(Filtros))); + if (list13.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List sinistro = ((IEnumerable)(from x in list13 + orderby x.ControleSinistro.DataSinistro, ((DomainBase)x.ControleSinistro).Id + select x)).Select((Func)delegate(Sinistro x) + { + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: Unknown result type (might be due to invalid IL or missing references) + //IL_00c7: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_016b: Unknown result type (might be due to invalid IL or missing references) + //IL_01b8: Unknown result type (might be due to invalid IL or missing references) + //IL_01de: Unknown result type (might be due to invalid IL or missing references) + //IL_0204: Unknown result type (might be due to invalid IL or missing references) + //IL_021e: Unknown result type (might be due to invalid IL or missing references) + //IL_022e: Unknown result type (might be due to invalid IL or missing references) + //IL_0238: Unknown result type (might be due to invalid IL or missing references) + //IL_0266: Unknown result type (might be due to invalid IL or missing references) + //IL_028f: Unknown result type (might be due to invalid IL or missing references) + //IL_02a9: Unknown result type (might be due to invalid IL or missing references) + //IL_02ba: Unknown result type (might be due to invalid IL or missing references) + //IL_02cb: Unknown result type (might be due to invalid IL or missing references) + //IL_02dc: Unknown result type (might be due to invalid IL or missing references) + //IL_02ed: Unknown result type (might be due to invalid IL or missing references) + //IL_0307: Unknown result type (might be due to invalid IL or missing references) + //IL_0318: Unknown result type (might be due to invalid IL or missing references) + //IL_0329: Unknown result type (might be due to invalid IL or missing references) + //IL_033a: Unknown result type (might be due to invalid IL or missing references) + //IL_0344: Unknown result type (might be due to invalid IL or missing references) + //IL_0377: Unknown result type (might be due to invalid IL or missing references) + //IL_03ac: Unknown result type (might be due to invalid IL or missing references) + //IL_03e1: Unknown result type (might be due to invalid IL or missing references) + //IL_048f: Unknown result type (might be due to invalid IL or missing references) + //IL_049b: Unknown result type (might be due to invalid IL or missing references) + //IL_04b6: Unknown result type (might be due to invalid IL or missing references) + //IL_04cc: Unknown result type (might be due to invalid IL or missing references) + //IL_04ec: Unknown result type (might be due to invalid IL or missing references) + //IL_0516: Unknown result type (might be due to invalid IL or missing references) + //IL_053b: Unknown result type (might be due to invalid IL or missing references) + //IL_0588: Unknown result type (might be due to invalid IL or missing references) + //IL_05d2: Unknown result type (might be due to invalid IL or missing references) + //IL_05f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0618: Unknown result type (might be due to invalid IL or missing references) + //IL_064a: Unknown result type (might be due to invalid IL or missing references) + //IL_067c: Unknown result type (might be due to invalid IL or missing references) + //IL_076d: Unknown result type (might be due to invalid IL or missing references) + //IL_0785: Unknown result type (might be due to invalid IL or missing references) + //IL_0731: Unknown result type (might be due to invalid IL or missing references) + //IL_07b8: Unknown result type (might be due to invalid IL or missing references) + //IL_07c9: Unknown result type (might be due to invalid IL or missing references) + //IL_07da: Unknown result type (might be due to invalid IL or missing references) + //IL_07f4: Unknown result type (might be due to invalid IL or missing references) + //IL_0805: Unknown result type (might be due to invalid IL or missing references) + //IL_082d: Unknown result type (might be due to invalid IL or missing references) + //IL_083e: Unknown result type (might be due to invalid IL or missing references) + //IL_0867: Expected O, but got Unknown + if (x.ControleSinistro.DataSinistro.HasValue) + { + Sinistro val34 = new Sinistro + { + Pendencia = ((!x.DataLiquidacao.HasValue) ? int.Parse($"{(today - x.ControleSinistro.DataSinistro.Value.Date).TotalDays}") : 0), + Nome = (x.ControleSinistro.Item.Documento.Controle.Cliente.Nome ?? ""), + Apolice = (x.ControleSinistro.Item.Documento.Apolice ?? ""), + Endosso = (x.ControleSinistro.Item.Documento.Endosso ?? "") + }; + ControleSinistro controleSinistro = x.ControleSinistro; + DateTime? vigenciaInicial; + if (controleSinistro == null) + { + vigenciaInicial = null; + } + else + { + Item item11 = controleSinistro.Item; + if (item11 == null) + { + vigenciaInicial = null; + } + else + { + Documento documento5 = item11.Documento; + vigenciaInicial = ((documento5 != null) ? new DateTime?(documento5.Vigencia1) : null); + } + } + val34.VigenciaInicial = vigenciaInicial; + ControleSinistro controleSinistro2 = x.ControleSinistro; + DateTime? vigenciaFinal; + if (controleSinistro2 == null) + { + vigenciaFinal = null; + } + else + { + Item item12 = controleSinistro2.Item; + if (item12 == null) + { + vigenciaFinal = null; + } + else + { + Documento documento6 = item12.Documento; + vigenciaFinal = ((documento6 != null) ? documento6.Vigencia2 : null); + } + } + val34.VigenciaFinal = vigenciaFinal; + SinistroAuto sinistroAuto = x.SinistroAuto; + val34.Email = ((sinistroAuto != null) ? sinistroAuto.Email : null) ?? ""; + SinistroAuto sinistroAuto2 = x.SinistroAuto; + val34.Telefone = ((sinistroAuto2 != null) ? sinistroAuto2.Telefone : null) ?? ""; + val34.NumeroSinistro = x.Numero ?? ""; + val34.TipoSinistro = x.TipoSinistro.GetValueOrDefault(); + val34.DataSinistro = x.ControleSinistro.DataSinistro ?? DateTime.MinValue; + val34.Reclamacao = x.DataReclamacao ?? DateTime.MinValue; + val34.Item = x.ItemSinistrado ?? ""; + val34.Valor = x.Valor; + val34.ValorOrcado = x.ValorOrcado; + val34.ValorLiberado = x.ValorLiberado; + val34.ValorPago = x.ValorPago; + val34.ValorSalvado = x.ValorSalvado.GetValueOrDefault(); + val34.ValorFranquia = x.ValorFranquia; + val34.Liquidacao = x.DataLiquidacao; + val34.StatusSinistro = x.StatusSinistro.GetValueOrDefault((StatusSinistro)1); + val34.Ramo = x.ControleSinistro.Item.Documento.Controle.Ramo.Nome ?? ""; + Estipulante estipulante6 = x.ControleSinistro.Item.Documento.Estipulante1; + val34.Estipulante = ((estipulante6 != null) ? estipulante6.Nome : null) ?? ""; + Vendedor vendedorPrincipal6 = x.ControleSinistro.Item.Documento.VendedorPrincipal; + val34.Vendedor = ((vendedorPrincipal6 != null) ? vendedorPrincipal6.Nome : null) ?? ""; + val34.Seguradora = (nomeSeguradora ? x.ControleSinistro.Item.Documento.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.ControleSinistro.Item.Documento.Controle.Seguradora.NomeSocial)) ? x.ControleSinistro.Item.Documento.Controle.Seguradora.NomeSocial : x.ControleSinistro.Item.Documento.Controle.Seguradora.Nome)); + val34.EntidadeSinistro = x; + val34.Documento = x.ControleSinistro.Item.Documento; + val34.EntidadeItem = x.ControleSinistro.Item; + val34.Pasta = x.ControleSinistro.Item.Documento.Pasta; + val34.PastaCliente = x.ControleSinistro.Item.Documento.Controle.Cliente.Pasta; + val34.Cliente = x.ControleSinistro.Item.Documento.Controle.Cliente; + ControleSinistro controleSinistro3 = x.ControleSinistro; + DateTime? dataControle; + if (controleSinistro3 == null) + { + dataControle = null; + } + else + { + Item item13 = controleSinistro3.Item; + if (item13 == null) + { + dataControle = null; + } + else + { + Documento documento7 = item13.Documento; + dataControle = ((documento7 != null) ? documento7.DataControle : null); + } + } + val34.DataControle = dataControle; + ControleSinistro controleSinistro4 = x.ControleSinistro; + object obj22; + if (controleSinistro4 == null) + { + obj22 = null; + } + else + { + Item item14 = controleSinistro4.Item; + if (item14 == null) + { + obj22 = null; + } + else + { + Documento documento8 = item14.Documento; + if (documento8 == null) + { + obj22 = null; + } + else + { + Status status6 = documento8.Status; + obj22 = ((status6 != null) ? status6.Nome : null); + } + } + } + if (obj22 == null) + { + obj22 = ""; + } + val34.StatusApolice = (string)obj22; + val34.IdEmpresa = x.ControleSinistro.Item.Documento.Controle.IdEmpresa; + val34.Empresa = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == x.ControleSinistro.Item.Documento.Controle.IdEmpresa)).NomeSocial; + SinistroAuto sinistroAuto3 = x.SinistroAuto; + object obj23; + if (sinistroAuto3 == null) + { + obj23 = null; + } + else + { + Parceiro parceiroMecanica = sinistroAuto3.ParceiroMecanica; + obj23 = ((parceiroMecanica != null) ? parceiroMecanica.Nome : null); + } + if (obj23 == null) + { + obj23 = ""; + } + val34.Mecanica = (string)obj23; + SinistroAuto sinistroAuto4 = x.SinistroAuto; + object obj24; + if (sinistroAuto4 == null) + { + obj24 = null; + } + else + { + Parceiro parceiroFunilaria = sinistroAuto4.ParceiroFunilaria; + obj24 = ((parceiroFunilaria != null) ? parceiroFunilaria.Nome : null); + } + if (obj24 == null) + { + obj24 = ""; + } + val34.Funilaria = (string)obj24; + object obj25; + if (((DomainBase)x.ControleSinistro.Item.Documento.Controle.Ramo).Id != 5) + { + if (!new List { 6L, 7L, 9L, 10L, 53L }.Contains(((DomainBase)x.ControleSinistro.Item.Documento.Controle.Ramo).Id)) + { + obj25 = ""; + } + else + { + SinistroVida sinistroVida = x.SinistroVida; + if (sinistroVida == null) + { + obj25 = null; + } + else + { + TipoPerda? tipoPerda = sinistroVida.TipoPerda; + obj25 = (tipoPerda.HasValue ? EnumHelper.GetDescription(tipoPerda.GetValueOrDefault()) : null); + } + if (obj25 == null) + { + obj25 = ""; + } + } + } + else + { + SinistroAuto sinistroAuto5 = x.SinistroAuto; + if (sinistroAuto5 == null) + { + obj25 = null; + } + else + { + TipoPerda? tipoPerda = sinistroAuto5.TipoPerda; + obj25 = (tipoPerda.HasValue ? EnumHelper.GetDescription(tipoPerda.GetValueOrDefault()) : null); + } + if (obj25 == null) + { + obj25 = ""; + } + } + val34.TipoPerda = (string)obj25; + val34.CpfCnpj = x.ControleSinistro.Item.Documento.Controle.Cliente.Documento ?? ""; + val34.StatusPersonalizado = x.StatusPersonalizado; + val34.Auxiliar = x.Auxiliar; + val34.Motivo = x.Motivo ?? ""; + val34.DataCriacao = x.DataCriacao; + Usuario? obj26 = ((IEnumerable)Recursos.Usuarios).FirstOrDefault((Func)((Usuario usuario) => ((DomainBase)usuario).Id == x.IdUsuarioCriacao)); + val34.UsuarioCriacao = ((obj26 != null) ? obj26.Nome : null); + val34.DataAlteracao = x.DataAlteracao; + Usuario? obj27 = ((IEnumerable)Recursos.Usuarios).FirstOrDefault((Func)((Usuario usuario) => ((DomainBase)usuario).Id == x.IdUsuarioAlteracao)); + val34.UsuarioAlteracao = ((obj27 != null) ? obj27.Nome : null); + return val34; + } + return (Sinistro)null; + }).ToList(); + Sinistro = sinistro; + SinistroFiltrado = new ObservableCollection(Sinistro); + break; + } + case 11: + { + List list25 = await _apoliceServico.BuscarFechamento(Filtros); + if (list25 == null) + { + ExtratosEnabled = false; + return false; + } + list25.ForEach(delegate(Fechamento x) + { + x.Pendente = x.Gerada - x.Recebida; + x.PendenteAnterior = x.GeradaAnterior - x.RecebidaAnterior; + }); + Fechamento = new ObservableCollection(); + List list26 = (from x in list25 + where x.Entidade == 0 + orderby x.PremioTotal descending + select x).ToList(); + if (list26.Count > 0) + { + list26.Add(new Fechamento + { + Entidade = list26.First().Entidade, + Nome = "TOTAL", + PremioTotal = list26.Sum((Fechamento x) => x.PremioTotal), + PremioTotalAnterior = list26.Sum((Fechamento x) => x.PremioTotalAnterior), + PremioLiquido = list26.Sum((Fechamento x) => x.PremioLiquido), + PremioLiquidoAnterior = list26.Sum((Fechamento x) => x.PremioLiquidoAnterior), + Fechada = (list26.Any() ? 100 : 0), + FechadaAnterior = (list26.Any() ? 100 : 0), + Mix = 100m, + MixAnterior = 100m, + Gerada = list26.Sum((Fechamento x) => x.Gerada), + GeradaAnterior = list26.Sum((Fechamento x) => x.GeradaAnterior), + Recebida = list26.Sum((Fechamento x) => x.Recebida), + RecebidaAnterior = list26.Sum((Fechamento x) => x.RecebidaAnterior), + Pendente = list26.Sum((Fechamento x) => x.Pendente), + PendenteAnterior = list26.Sum((Fechamento x) => x.PendenteAnterior), + Paga = list26.Sum((Fechamento x) => x.Paga), + PagaAnterior = list26.Sum((Fechamento x) => x.PagaAnterior), + Apolice = list26.Sum((Fechamento x) => x.Apolice), + ApoliceAnterior = list26.Sum((Fechamento x) => x.ApoliceAnterior), + Endosso = list26.Sum((Fechamento x) => x.Endosso), + EndossoAnterior = list26.Sum((Fechamento x) => x.EndossoAnterior), + Fatura = list26.Sum((Fechamento x) => x.Fatura), + FaturaAnterior = list26.Sum((Fechamento x) => x.FaturaAnterior), + Itens = list26.Sum((Fechamento x) => x.Itens), + ItensAnterior = list26.Sum((Fechamento x) => x.ItensAnterior) + }); + Fechamento.Add(new Fechamentos + { + Title = "SEGURADORA", + Fechamento = new ObservableCollection(list26) + }); + } + List list27 = (from x in list25 + where x.Entidade == 1 + orderby x.PremioTotal descending + select x).ToList(); + if (list27.Count > 0) + { + list27.Add(new Fechamento + { + Entidade = list27.First().Entidade, + Nome = "TOTAL", + PremioTotal = list27.Sum((Fechamento x) => x.PremioTotal), + PremioTotalAnterior = list27.Sum((Fechamento x) => x.PremioTotalAnterior), + PremioLiquido = list27.Sum((Fechamento x) => x.PremioLiquido), + PremioLiquidoAnterior = list27.Sum((Fechamento x) => x.PremioLiquidoAnterior), + Fechada = (list27.Any() ? 100 : 0), + FechadaAnterior = (list27.Any() ? 100 : 0), + Mix = 100m, + MixAnterior = 100m, + Gerada = list27.Sum((Fechamento x) => x.Gerada), + GeradaAnterior = list27.Sum((Fechamento x) => x.GeradaAnterior), + Recebida = list27.Sum((Fechamento x) => x.Recebida), + RecebidaAnterior = list27.Sum((Fechamento x) => x.RecebidaAnterior), + Pendente = list27.Sum((Fechamento x) => x.Pendente), + PendenteAnterior = list27.Sum((Fechamento x) => x.PendenteAnterior), + Paga = list27.Sum((Fechamento x) => x.Paga), + PagaAnterior = list27.Sum((Fechamento x) => x.PagaAnterior), + Apolice = list27.Sum((Fechamento x) => x.Apolice), + ApoliceAnterior = list27.Sum((Fechamento x) => x.ApoliceAnterior), + Endosso = list27.Sum((Fechamento x) => x.Endosso), + EndossoAnterior = list27.Sum((Fechamento x) => x.EndossoAnterior), + Fatura = list27.Sum((Fechamento x) => x.Fatura), + FaturaAnterior = list27.Sum((Fechamento x) => x.FaturaAnterior), + Itens = list27.Sum((Fechamento x) => x.Itens), + ItensAnterior = list27.Sum((Fechamento x) => x.ItensAnterior) + }); + Fechamento.Add(new Fechamentos + { + Title = "RAMO", + Fechamento = new ObservableCollection(list27) + }); + } + List list28 = (from x in list25 + where x.Entidade == 2 + orderby x.PremioTotal descending + select x).ToList(); + if (list28.Count > 0) + { + list28.Add(new Fechamento + { + Entidade = list28.First().Entidade, + Nome = "TOTAL", + PremioTotal = list28.Sum((Fechamento x) => x.PremioTotal), + PremioTotalAnterior = list28.Sum((Fechamento x) => x.PremioTotalAnterior), + PremioLiquido = list28.Sum((Fechamento x) => x.PremioLiquido), + PremioLiquidoAnterior = list28.Sum((Fechamento x) => x.PremioLiquidoAnterior), + Fechada = (list28.Any() ? 100 : 0), + FechadaAnterior = (list28.Any() ? 100 : 0), + Mix = 100m, + MixAnterior = 100m, + Gerada = list28.Sum((Fechamento x) => x.Gerada), + GeradaAnterior = list28.Sum((Fechamento x) => x.GeradaAnterior), + Recebida = list28.Sum((Fechamento x) => x.Recebida), + RecebidaAnterior = list28.Sum((Fechamento x) => x.RecebidaAnterior), + Pendente = list28.Sum((Fechamento x) => x.Pendente), + PendenteAnterior = list28.Sum((Fechamento x) => x.PendenteAnterior), + Paga = list28.Sum((Fechamento x) => x.Paga), + PagaAnterior = list28.Sum((Fechamento x) => x.PagaAnterior), + Apolice = list28.Sum((Fechamento x) => x.Apolice), + ApoliceAnterior = list28.Sum((Fechamento x) => x.ApoliceAnterior), + Endosso = list28.Sum((Fechamento x) => x.Endosso), + EndossoAnterior = list28.Sum((Fechamento x) => x.EndossoAnterior), + Fatura = list28.Sum((Fechamento x) => x.Fatura), + FaturaAnterior = list28.Sum((Fechamento x) => x.FaturaAnterior), + Itens = list28.Sum((Fechamento x) => x.Itens), + ItensAnterior = list28.Sum((Fechamento x) => x.ItensAnterior) + }); + Fechamento.Add(new Fechamentos + { + Title = "ESTIPULANTE", + Fechamento = new ObservableCollection(list28) + }); + } + List list29 = (from x in list25 + where x.Entidade == 3 + orderby x.PremioTotal descending + select x).ToList(); + if (list29.Count > 0) + { + List source7 = Funcoes.DistinctBy(list29, (Fechamento x) => new { x.PremioTotal, x.PremioLiquido, x.PremioTotalAnterior, x.PremioLiquidoAnterior }).ToList(); + list29.Add(new Fechamento + { + Entidade = list29.First().Entidade, + Nome = "TOTAL", + PremioTotal = source7.Sum((Fechamento x) => x.PremioTotal), + PremioTotalAnterior = source7.Sum((Fechamento x) => x.PremioTotalAnterior), + PremioLiquido = source7.Sum((Fechamento x) => x.PremioLiquido), + PremioLiquidoAnterior = source7.Sum((Fechamento x) => x.PremioLiquidoAnterior), + Fechada = (list29.Any() ? 100 : 0), + FechadaAnterior = (list29.Any() ? 100 : 0), + Mix = 100m, + MixAnterior = 100m, + Gerada = source7.Sum((Fechamento x) => x.Gerada), + GeradaAnterior = source7.Sum((Fechamento x) => x.GeradaAnterior), + Recebida = source7.Sum((Fechamento x) => x.Recebida), + RecebidaAnterior = source7.Sum((Fechamento x) => x.RecebidaAnterior), + Pendente = source7.Sum((Fechamento x) => x.Pendente), + PendenteAnterior = source7.Sum((Fechamento x) => x.PendenteAnterior), + Paga = source7.Sum((Fechamento x) => x.Paga), + PagaAnterior = source7.Sum((Fechamento x) => x.PagaAnterior), + Apolice = source7.Sum((Fechamento x) => x.Apolice), + ApoliceAnterior = source7.Sum((Fechamento x) => x.ApoliceAnterior), + Endosso = source7.Sum((Fechamento x) => x.Endosso), + EndossoAnterior = source7.Sum((Fechamento x) => x.EndossoAnterior), + Fatura = source7.Sum((Fechamento x) => x.Fatura), + FaturaAnterior = source7.Sum((Fechamento x) => x.FaturaAnterior), + Itens = source7.Sum((Fechamento x) => x.Itens), + ItensAnterior = source7.Sum((Fechamento x) => x.ItensAnterior) + }); + Fechamento.Add(new Fechamentos + { + Title = "VENDEDOR", + Fechamento = new ObservableCollection(list29) + }); + } + FechamentoFiltrado = new ObservableCollection(Fechamento); + HtmlContent = await GerarHtml(screen: true); + break; + } + case 8: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + Filtros.ParcelasEspeciais = ParcelasEspeciais; + List list12 = await _apoliceServico.Auditoria(Filtros); + if (list12.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List auditoria = ((IEnumerable)list12).Select((Func)delegate(Documento x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0040: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_0079: Unknown result type (might be due to invalid IL or missing references) + //IL_0085: Unknown result type (might be due to invalid IL or missing references) + //IL_00cb: Unknown result type (might be due to invalid IL or missing references) + //IL_0118: Unknown result type (might be due to invalid IL or missing references) + //IL_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_0120: Invalid comparison between Unknown and I4 + //IL_0126: Unknown result type (might be due to invalid IL or missing references) + //IL_012c: Invalid comparison between Unknown and I4 + //IL_026f: Unknown result type (might be due to invalid IL or missing references) + //IL_027b: Unknown result type (might be due to invalid IL or missing references) + //IL_0287: Unknown result type (might be due to invalid IL or missing references) + //IL_02ad: Unknown result type (might be due to invalid IL or missing references) + //IL_02cc: Unknown result type (might be due to invalid IL or missing references) + //IL_0325: Unknown result type (might be due to invalid IL or missing references) + //IL_0327: Unknown result type (might be due to invalid IL or missing references) + //IL_033f: Unknown result type (might be due to invalid IL or missing references) + //IL_0360: Unknown result type (might be due to invalid IL or missing references) + //IL_0381: Unknown result type (might be due to invalid IL or missing references) + //IL_03d7: Unknown result type (might be due to invalid IL or missing references) + //IL_03e3: Unknown result type (might be due to invalid IL or missing references) + //IL_03ef: Unknown result type (might be due to invalid IL or missing references) + //IL_0410: Unknown result type (might be due to invalid IL or missing references) + //IL_0417: Unknown result type (might be due to invalid IL or missing references) + //IL_0466: Unknown result type (might be due to invalid IL or missing references) + //IL_04b4: Unknown result type (might be due to invalid IL or missing references) + //IL_04c0: Unknown result type (might be due to invalid IL or missing references) + //IL_04d7: Expected O, but got Unknown + Auditoria val35 = new Auditoria(); + Cliente cliente9 = x.Controle.Cliente; + val35.Cliente = ((cliente9 != null) ? cliente9.Nome : null) ?? ""; + val35.Apolice = x.Apolice ?? ""; + val35.Endosso = x.Endosso ?? ""; + val35.Comissao = x.Comissao; + val35.PremioLiquido = x.PremioLiquido; + val35.PremioTotal = x.PremioTotal; + val35.PremioAdicional = x.PremioAdicional; + val35.ComissaoPrevista = decimal.Round((x.PremioLiquido + (x.AdicionalComiss ? x.PremioAdicional : 0m)) * x.Comissao * 0.01m, 2); + val35.ComissaoRecebida = ((x.Parcelas != null && x.Parcelas.Count > 0) ? x.Parcelas.Sum((Parcela p) => p.ValorComissao) : 0m); + val35.ComissaoPendente = (((int)x.Situacao == 3 || (int)x.Situacao == 7) ? 0m : (decimal.Round((x.PremioLiquido + (x.AdicionalComiss ? x.PremioAdicional : 0m)) * x.Comissao * 0.01m, 2) - ((x.Parcelas != null && x.Parcelas.Count > 0) ? ((x.Parcelas.Sum((Parcela p) => p.ValorComissao) < 0m && x.PremioLiquido > x.Parcelas.Sum((Parcela p) => p.ValorComissao)) ? (x.Parcelas.Sum((Parcela p) => p.ValorComissao) * -1m) : x.Parcelas.Sum((Parcela p) => p.ValorComissao)) : 0m))); + val35.VigenciaFinal = x.Vigencia2; + val35.VigenciaInicial = x.Vigencia1; + Produto produto8 = x.Controle.Produto; + val35.Produto = ((produto8 != null) ? produto8.Nome : null) ?? ""; + val35.Ramo = x.Controle.Ramo.Nome ?? ""; + val35.Seguradora = (nomeSeguradora ? x.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Controle.Seguradora.NomeSocial)) ? x.Controle.Seguradora.NomeSocial : x.Controle.Seguradora.Nome)); + val35.Status = EnumHelper.GetDescription(x.Situacao) ?? ""; + Vendedor vendedorPrincipal7 = x.VendedorPrincipal; + val35.Vendedor = ((vendedorPrincipal7 != null) ? vendedorPrincipal7.Nome : null) ?? ""; + Estipulante estipulante7 = x.Estipulante1; + val35.Estipulante = ((estipulante7 != null) ? estipulante7.Nome : null) ?? ""; + val35.TodosVendedores = ((x.Vendedores == null || x.Vendedores.Count == 0) ? "" : string.Join("; ", x.Vendedores.Select((Vendedor v) => v.Nome))); + val35.Tipo = x.Tipo; + val35.DataControle = x.DataControle; + Status status7 = x.Status; + val35.StatusApolice = ((status7 != null) ? status7.Nome : null) ?? ""; + val35.Documento = x; + val35.Item = ((x.ItensAtivo == null) ? "" : ((x.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.ItensAtivo.Count == 1) ? x.ItensAtivo.First().Descricao : ""))); + val35.Completo = (((decimal)x.Parcelas.Count((Parcela p) => (int)p.SubTipo == 1 && p.DataRecebimento.HasValue) == x.NumeroParcelas) ? "SIM" : "NÃO"); + val35.Pasta = x.Pasta; + val35.PastaCliente = x.Controle.Cliente.Pasta; + return val35; + }).ToList(); + Auditoria = auditoria; + AuditoriaFiltrado = new ObservableCollection(Auditoria); + break; + } + case 7: + { + AdiantamentoServico adiantamentoServico = new AdiantamentoServico(); + Filtros.ParcelasEspeciais = ParcelasEspeciais; + List pagamento = await _parcelaServico.BuscarPagamentoVendedor(Filtros, SomenteNaoPagos, SegundaViaReciboPagamento); + if (_documentosEmitidos) + { + pagamento = pagamento.Where(delegate(VendedorParcela x) + { + Documento documento2 = x.Documento; + return documento2 != null && documento2.Emissao.HasValue; + }).ToList(); + } + List list19 = await adiantamentoServico.BuscarPorData(Filtros, SegundaViaReciboPagamento); + if (pagamento.Count == 0 && list19.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List analiticoPagamento = ((IEnumerable)pagamento).Select((Func)delegate(VendedorParcela x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_004b: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_0117: Unknown result type (might be due to invalid IL or missing references) + //IL_012d: Unknown result type (might be due to invalid IL or missing references) + //IL_0143: Unknown result type (might be due to invalid IL or missing references) + //IL_0152: Unknown result type (might be due to invalid IL or missing references) + //IL_0158: Invalid comparison between Unknown and I4 + //IL_01be: Unknown result type (might be due to invalid IL or missing references) + //IL_01d4: Unknown result type (might be due to invalid IL or missing references) + //IL_0218: Unknown result type (might be due to invalid IL or missing references) + //IL_022e: Unknown result type (might be due to invalid IL or missing references) + //IL_0234: Invalid comparison between Unknown and I4 + //IL_024e: Unknown result type (might be due to invalid IL or missing references) + //IL_0262: Unknown result type (might be due to invalid IL or missing references) + //IL_0437: Unknown result type (might be due to invalid IL or missing references) + //IL_0443: Unknown result type (might be due to invalid IL or missing references) + //IL_0454: Unknown result type (might be due to invalid IL or missing references) + //IL_0465: Unknown result type (might be due to invalid IL or missing references) + //IL_0490: Unknown result type (might be due to invalid IL or missing references) + //IL_038e: Unknown result type (might be due to invalid IL or missing references) + //IL_04b6: Unknown result type (might be due to invalid IL or missing references) + //IL_04e1: Unknown result type (might be due to invalid IL or missing references) + //IL_04fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0515: Unknown result type (might be due to invalid IL or missing references) + //IL_052b: Unknown result type (might be due to invalid IL or missing references) + //IL_053c: Unknown result type (might be due to invalid IL or missing references) + //IL_054d: Unknown result type (might be due to invalid IL or missing references) + //IL_0577: Unknown result type (might be due to invalid IL or missing references) + //IL_0588: Unknown result type (might be due to invalid IL or missing references) + //IL_0599: Unknown result type (might be due to invalid IL or missing references) + //IL_05c1: Unknown result type (might be due to invalid IL or missing references) + //IL_0600: Unknown result type (might be due to invalid IL or missing references) + //IL_060f: Unknown result type (might be due to invalid IL or missing references) + //IL_0615: Invalid comparison between Unknown and I4 + //IL_062a: Expected O, but got Unknown + DadosRelatorio val26 = new DadosRelatorio + { + Id = ((DomainBase)x).Id, + EntidadeDocumento = x.Documento, + EntidadeParcela = x.Parcela, + EntidadeVendedorParcela = x, + Cliente = x.Documento.Controle.Cliente.Nome, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VigenciaIncial = x.Documento.Vigencia1, + VigenciaFinal = x.Documento.Vigencia2, + Status = EnumHelper.GetDescription(x.Documento.Situacao), + Seguradora = (nomeSeguradora ? x.Documento.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Documento.Controle.Seguradora.NomeSocial)) ? x.Documento.Controle.Seguradora.NomeSocial : x.Documento.Controle.Seguradora.Nome)), + Comissao = x.Documento.Comissao, + PremioLiquido = x.Documento.PremioLiquido, + Parcela = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() != 1) ? $"{x.Parcela.NumeroParcela}" : ((x.Parcela.NumeroParcela != 999) ? $"{x.Parcela.NumeroParcela} de {x.Documento.NumeroParcelas}" : " Especial")), + ValorParcela = x.Parcela.Valor, + Recebimento = (Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 34) ? x.Documento.DataControle : x.DataPrePagamento) + }; + Repasse repasse = x.Repasse; + val26.ComissaoRepasse = ((repasse != null && (int)repasse.Tipo.GetValueOrDefault() == 2) ? x.PorcentagemRepasse : null); + val26.Repasse = x.ValorRepasse.GetValueOrDefault(); + decimal? num2; + decimal? desconto; + if (x.Vendedor.Desconto.HasValue) + { + desconto = x.Vendedor.Desconto; + if (!((desconto.GetValueOrDefault() == default(decimal)) & desconto.HasValue) && x.ValorRepasse.HasValue) + { + desconto = x.ValorRepasse; + if (!((desconto.GetValueOrDefault() == default(decimal)) & desconto.HasValue)) + { + desconto = x.ValorRepasse; + if (!((desconto.GetValueOrDefault() < default(decimal)) & desconto.HasValue)) + { + desconto = x.ValorRepasse; + decimal value2 = 1; + decimal? desconto2 = x.Vendedor.Desconto; + num2 = desconto * (decimal?)((decimal?)value2 - desconto2).GetValueOrDefault(); + } + else if ((int)x.Vendedor.TipoIncidenciaDesconto != 0) + { + num2 = x.ValorRepasse; + } + else + { + desconto = x.ValorRepasse; + decimal value3 = 1; + decimal? desconto3 = x.Vendedor.Desconto; + num2 = desconto * (decimal?)((decimal?)value3 - desconto3).GetValueOrDefault(); + } + goto IL_042a; + } + } + } + num2 = x.ValorRepasse.GetValueOrDefault(); + goto IL_042a; + IL_042a: + desconto = num2; + val26.ValorLiquido = desconto.Value; + val26.DataPagamento = x.DataPagamento; + val26.Vendedor = x.Vendedor.Nome; + val26.CPFVendedor = x.Vendedor.Documento; + Produto produto4 = x.Documento.Controle.Produto; + val26.Produto = ((produto4 != null) ? produto4.Nome : null) ?? ""; + Estipulante estipulante3 = x.Documento.Estipulante1; + val26.Estipulante = ((estipulante3 != null) ? estipulante3.Nome : null) ?? ""; + Ramo ramo2 = x.Documento.Controle.Ramo; + val26.Ramo = ((ramo2 != null) ? ramo2.Nome : null) ?? ""; + NegocioCorretora? negocioCorretora2 = x.Documento.NegocioCorretora; + val26.Negocio = (negocioCorretora2.HasValue ? EnumHelper.GetDescription(negocioCorretora2.GetValueOrDefault()) : null) ?? ""; + val26.PremioTotal = x.Documento.PremioTotal; + val26.Proposta = x.Documento.Proposta; + val26.DataCriacao = x.Documento.DataCriacao; + val26.Banco = ((x.Vendedor.Banco == null) ? "" : x.Vendedor.Banco.Nome); + val26.Agencia = x.Vendedor.Agencia; + val26.Conta = x.Vendedor.Conta; + val26.DocumentoEmitido = (x.Documento.Emissao.HasValue ? "SIM" : "NÃO"); + val26.HouveRecebimento = ((x.Parcela.DataRecebimento.HasValue && x.Parcela.ValorComDesconto != 0m) ? "SIM" : "NÃO"); + val26.RecebidoPorCompleto = (((int)x.Documento.TipoRecebimento.GetValueOrDefault() == 1) ? x.RecebidoPorCompleto : "FATURA INDEFINIDO"); + return val26; + }).ToList(); + List collection2 = ((IEnumerable)list19).Select((Func)delegate(Adiantamento x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0074: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00b4: Expected O, but got Unknown + DadosRelatorio val25 = new DadosRelatorio + { + EntidadeAdiantamento = x, + Id = ((DomainBase)x).Id, + Cliente = x.Historico, + Recebimento = x.Data, + Repasse = -x.Valor, + ValorLiquido = -x.Valor, + Vendedor = x.Vendedor.Nome, + CPFVendedor = x.Vendedor.Documento + }; + Banco banco2 = x.Vendedor.Banco; + val25.Banco = ((banco2 != null) ? banco2.Nome : null); + val25.Agencia = x.Vendedor.Agencia; + val25.Conta = x.Vendedor.Conta; + return val25; + }).ToList(); + analiticoPagamento.AddRange(collection2); + if (DesconsiderarNegativos) + { + analiticoPagamento = analiticoPagamento.Where((DadosRelatorio x) => x.ValorLiquido >= 0m).ToList(); + } + if (Recursos.Configuracoes.Any((ConfiguracaoSistema y) => (int)y.Configuracao == 10)) + { + analiticoPagamento = analiticoPagamento.Where((DadosRelatorio x) => Math.Round(x.ValorLiquido, 2) != 0.00m).ToList(); + } + List list20 = (from x in analiticoPagamento + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + List pagamentos = new List(); + list20.ForEach(delegate(string x) + { + //IL_026e: Unknown result type (might be due to invalid IL or missing references) + //IL_0273: Unknown result type (might be due to invalid IL or missing references) + //IL_027e: Unknown result type (might be due to invalid IL or missing references) + //IL_02cd: Unknown result type (might be due to invalid IL or missing references) + //IL_031e: Expected O, but got Unknown + //IL_031e: Unknown result type (might be due to invalid IL or missing references) + //IL_0323: Unknown result type (might be due to invalid IL or missing references) + //IL_032e: Unknown result type (might be due to invalid IL or missing references) + //IL_037d: Unknown result type (might be due to invalid IL or missing references) + //IL_03ce: Expected O, but got Unknown + //IL_03ce: Unknown result type (might be due to invalid IL or missing references) + //IL_03d3: Unknown result type (might be due to invalid IL or missing references) + //IL_0410: Unknown result type (might be due to invalid IL or missing references) + //IL_041e: Unknown result type (might be due to invalid IL or missing references) + //IL_0424: Invalid comparison between Unknown and I4 + //IL_043e: Unknown result type (might be due to invalid IL or missing references) + //IL_04a3: Unknown result type (might be due to invalid IL or missing references) + //IL_0542: Expected O, but got Unknown + //IL_0542: Unknown result type (might be due to invalid IL or missing references) + //IL_0547: Unknown result type (might be due to invalid IL or missing references) + //IL_0552: Unknown result type (might be due to invalid IL or missing references) + //IL_066b: Unknown result type (might be due to invalid IL or missing references) + //IL_0696: Unknown result type (might be due to invalid IL or missing references) + //IL_06c3: Expected O, but got Unknown + //IL_06c3: Unknown result type (might be due to invalid IL or missing references) + //IL_06c8: Unknown result type (might be due to invalid IL or missing references) + //IL_06d4: Unknown result type (might be due to invalid IL or missing references) + //IL_06ec: Unknown result type (might be due to invalid IL or missing references) + //IL_0704: Unknown result type (might be due to invalid IL or missing references) + //IL_071c: Unknown result type (might be due to invalid IL or missing references) + //IL_0734: Unknown result type (might be due to invalid IL or missing references) + //IL_0783: Unknown result type (might be due to invalid IL or missing references) + //IL_07d2: Unknown result type (might be due to invalid IL or missing references) + //IL_0821: Unknown result type (might be due to invalid IL or missing references) + //IL_0870: Unknown result type (might be due to invalid IL or missing references) + //IL_08bf: Unknown result type (might be due to invalid IL or missing references) + //IL_08cc: Unknown result type (might be due to invalid IL or missing references) + //IL_08d9: Unknown result type (might be due to invalid IL or missing references) + //IL_08e8: Expected O, but got Unknown + //IL_091c: Unknown result type (might be due to invalid IL or missing references) + //IL_0921: Unknown result type (might be due to invalid IL or missing references) + //IL_092d: Unknown result type (might be due to invalid IL or missing references) + //IL_0939: Unknown result type (might be due to invalid IL or missing references) + //IL_0943: Expected O, but got Unknown + string ordemSelecionada = OrdemSelecionada; + List list30 = ((ordemSelecionada == "NOME CLIENTE") ? (from p in analiticoPagamento + orderby (p.EntidadeAdiantamento != null) ? 1 : 0, p.Cliente, p.Recebimento + where p.Vendedor == x + select p).ToList() : ((ordemSelecionada == "SEGURADORA, RAMO") ? (from p in analiticoPagamento + orderby (p.EntidadeAdiantamento != null) ? 1 : 0, p.Seguradora, p.Ramo, p.Recebimento + where p.Vendedor == x + select p).ToList() : (from p in analiticoPagamento + orderby (p.EntidadeAdiantamento != null) ? 1 : 0, p.Recebimento, p.Cliente + where p.Vendedor == x + select p).ToList())); + if (list30.Count == 0) + { + return; + } + List collection5 = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null).ToList(); + List collection6 = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento != null).ToList(); + DadosRelatorio item8 = new DadosRelatorio + { + Cliente = "TOTAL REPASSES", + Repasse = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null).Sum((DadosRelatorio p) => p.Repasse), + ValorLiquido = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null).Sum((DadosRelatorio p) => p.ValorLiquido) + }; + DadosRelatorio val19 = new DadosRelatorio + { + Cliente = "TOTAL ADIANTAMENTOS", + Repasse = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento != null).Sum((DadosRelatorio p) => p.Repasse), + ValorLiquido = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento != null).Sum((DadosRelatorio p) => p.ValorLiquido) + }; + DadosRelatorio val20 = new DadosRelatorio(); + DadosRelatorio? obj9 = list30.FirstOrDefault(); + object obj11; + if (obj9 != null) + { + VendedorParcela entidadeVendedorParcela = obj9.EntidadeVendedorParcela; + TipoIncidenciaDesconto? obj10; + if (entidadeVendedorParcela == null) + { + obj10 = null; + } + else + { + Vendedor vendedor3 = entidadeVendedorParcela.Vendedor; + obj10 = ((vendedor3 != null) ? new TipoIncidenciaDesconto?(vendedor3.TipoIncidenciaDesconto) : null); + } + TipoIncidenciaDesconto? val21 = obj10; + if ((int)val21.GetValueOrDefault() == 1) + { + obj11 = "SOMENTE POSITIVOS)"; + goto IL_0434; + } + } + obj11 = "AMBOS)"; + goto IL_0434; + IL_0434: + val20.Cliente = "DESCONTO (INCIDÊNCIA: " + (string?)obj11; + DadosRelatorio? obj12 = list30.FirstOrDefault(); + decimal? obj13; + if (obj12 == null) + { + obj13 = null; + } + else + { + VendedorParcela entidadeVendedorParcela2 = obj12.EntidadeVendedorParcela; + if (entidadeVendedorParcela2 == null) + { + obj13 = null; + } + else + { + Vendedor vendedor4 = entidadeVendedorParcela2.Vendedor; + obj13 = ((vendedor4 != null) ? vendedor4.Desconto : null); + } + } + decimal? num = obj13; + val20.ComissaoRepasse = num.GetValueOrDefault() * 100m; + val20.ValorLiquido = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null).Sum((DadosRelatorio p) => p.Repasse) - list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null).Sum((DadosRelatorio p) => p.ValorLiquido); + DadosRelatorio val22 = val20; + DadosRelatorio val23 = new DadosRelatorio + { + Cliente = "TOTAL GERAL", + PremioLiquido = Funcoes.DistinctBy(list30.Where((DadosRelatorio d) => d.EntidadeDocumento != null), delegate(DadosRelatorio c) + { + Documento entidadeDocumento = c.EntidadeDocumento; + return (entidadeDocumento == null) ? null : new long?(((DomainBase)entidadeDocumento).Id); + }).Sum((DadosRelatorio p) => p.PremioLiquido) + Funcoes.DistinctBy(list30.Where((DadosRelatorio d) => d.EntidadeDocumento == null), delegate(DadosRelatorio c) + { + Adiantamento entidadeAdiantamento = c.EntidadeAdiantamento; + return (entidadeAdiantamento == null) ? null : new long?(((DomainBase)entidadeAdiantamento).Id); + }).Sum((DadosRelatorio p) => p.PremioLiquido), + Repasse = list30.Sum((DadosRelatorio p) => p.Repasse), + ValorLiquido = list30.Sum((DadosRelatorio p) => p.ValorLiquido) + }; + AgrupamentoVendedor val24 = new AgrupamentoVendedor + { + Vendedor = x + }; + DadosRelatorio? obj14 = list30.FirstOrDefault(); + val24.CPF = ((obj14 != null) ? obj14.CPFVendedor : null); + DadosRelatorio? obj15 = list30.FirstOrDefault(); + val24.Banco = ((obj15 != null) ? obj15.Banco : null); + DadosRelatorio? obj16 = list30.FirstOrDefault(); + val24.Agencia = ((obj16 != null) ? obj16.Agencia : null); + DadosRelatorio? obj17 = list30.FirstOrDefault(); + val24.Conta = ((obj17 != null) ? obj17.Conta : null); + val24.Repasse = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null && p.Repasse >= 0m).Sum((DadosRelatorio p) => p.Repasse); + val24.Estorno = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null && p.Repasse < 0m).Sum((DadosRelatorio p) => p.Repasse); + val24.RepasseBruto = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento == null).Sum((DadosRelatorio p) => p.Repasse); + val24.Debito = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento != null && p.Repasse < 0m).Sum((DadosRelatorio p) => p.Repasse); + val24.Credito = list30.Where((DadosRelatorio p) => p.EntidadeAdiantamento != null && p.Repasse >= 0m).Sum((DadosRelatorio p) => p.Repasse); + val24.Desconto = val22.ValorLiquido; + val24.Adiantamento = val19.ValorLiquido; + val24.ValorLiquido = val23.ValorLiquido; + AgrupamentoVendedor vendedores2 = val24; + list30 = new List(); + list30.AddRange(collection5); + list30.Add(item8); + list30.AddRange(collection6); + list30.Add(val19); + list30.Add(val22); + list30.Add(val23); + Pagamento item9 = new Pagamento + { + Title = x, + Dados = new ObservableCollection(list30), + Vendedores = vendedores2 + }; + pagamentos.Add(item9); + }); + Pagamentos = pagamentos; + PagamentosSintetico = new List(); + PagamentoSintetico val9 = new PagamentoSintetico + { + Titulo = "SINTÉTICO POR SEGURADORA", + Agrupamento = new ObservableCollection() + }; + foreach (IGrouping s2 in (from x in analiticoPagamento + where x.Seguradora != null + orderby x.Seguradora + group x by x.Seguradora).ToList()) + { + List source4 = analiticoPagamento.Where((DadosRelatorio x) => x.Seguradora == s2.Key).ToList(); + AgrupamentoPagamentoSintetico val10 = new AgrupamentoPagamentoSintetico(); + DadosRelatorio? obj5 = ((IEnumerable)source4).FirstOrDefault((Func)((DadosRelatorio n) => n.Seguradora == s2.Key)); + val10.Nome = ((obj5 != null) ? obj5.Seguradora : null); + val10.Repasse = source4.Sum((DadosRelatorio x) => x.Repasse); + val10.VlrLiquido = source4.Sum((DadosRelatorio x) => x.ValorLiquido); + AgrupamentoPagamentoSintetico item4 = val10; + val9.Agrupamento.Add(item4); + } + val9.Agrupamento.Add(new AgrupamentoPagamentoSintetico + { + Nome = "TOTAL", + Repasse = val9.Agrupamento.Sum((AgrupamentoPagamentoSintetico x) => x.Repasse), + VlrLiquido = val9.Agrupamento.Sum((AgrupamentoPagamentoSintetico x) => x.VlrLiquido) + }); + PagamentosSintetico.Add(val9); + PagamentoSintetico val11 = new PagamentoSintetico + { + Titulo = "SINTÉTICO POR RAMO", + Agrupamento = new ObservableCollection() + }; + foreach (IGrouping r in (from x in analiticoPagamento + where x.Ramo != null + orderby x.Ramo + group x by x.Ramo).ToList()) + { + List source5 = (from x in analiticoPagamento + where x.Ramo == r.Key + orderby x.Ramo + select x).ToList(); + AgrupamentoPagamentoSintetico val12 = new AgrupamentoPagamentoSintetico(); + DadosRelatorio? obj6 = ((IEnumerable)source5).FirstOrDefault((Func)((DadosRelatorio n) => n.Ramo == r.Key)); + val12.Nome = ((obj6 != null) ? obj6.Ramo : null); + val12.Repasse = source5.Sum((DadosRelatorio x) => x.Repasse); + val12.VlrLiquido = source5.Sum((DadosRelatorio x) => x.ValorLiquido); + AgrupamentoPagamentoSintetico item5 = val12; + val11.Agrupamento.Add(item5); + } + val11.Agrupamento.Add(new AgrupamentoPagamentoSintetico + { + Nome = "TOTAL", + Repasse = val11.Agrupamento.Sum((AgrupamentoPagamentoSintetico x) => x.Repasse), + VlrLiquido = val11.Agrupamento.Sum((AgrupamentoPagamentoSintetico x) => x.VlrLiquido) + }); + PagamentosSintetico.Add(val11); + PagamentoSintetico val13 = new PagamentoSintetico + { + Titulo = "SINTÉTICO POR VENDEDOR", + Agrupamento = new ObservableCollection() + }; + foreach (IGrouping v2 in (from x in analiticoPagamento + orderby x.Vendedor + group x by x.Vendedor).ToList()) + { + List source6 = analiticoPagamento.Where((DadosRelatorio x) => x.Vendedor == v2.Key).ToList(); + AgrupamentoPagamentoSintetico val14 = new AgrupamentoPagamentoSintetico(); + DadosRelatorio? obj7 = ((IEnumerable)source6).FirstOrDefault((Func)((DadosRelatorio n) => n.Vendedor == v2.Key)); + val14.Nome = ((obj7 != null) ? obj7.Vendedor : null); + val14.Repasse = source6.Sum((DadosRelatorio x) => x.Repasse); + val14.VlrLiquido = source6.Sum((DadosRelatorio x) => x.ValorLiquido); + AgrupamentoPagamentoSintetico item6 = val14; + val13.Agrupamento.Add(item6); + } + val13.Agrupamento.Add(new AgrupamentoPagamentoSintetico + { + Nome = "TOTAL", + Repasse = val13.Agrupamento.Sum((AgrupamentoPagamentoSintetico x) => x.Repasse), + VlrLiquido = val13.Agrupamento.Sum((AgrupamentoPagamentoSintetico x) => x.VlrLiquido) + }); + PagamentosSintetico.Add(val13); + HtmlContent = await GerarHtml(screen: true); + break; + } + case 13: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list15 = await _extratoServico.BuscarExtratoPorData(Filtros); + if (list15.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List extratos = ((IEnumerable)list15).Select((Func)delegate(Extrato x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Unknown result type (might be due to invalid IL or missing references) + //IL_0045: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_0089: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_00ab: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Unknown result type (might be due to invalid IL or missing references) + //IL_0105: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: Unknown result type (might be due to invalid IL or missing references) + //IL_011b: Unknown result type (might be due to invalid IL or missing references) + //IL_0128: Expected O, but got Unknown + ExtratoBaixadoRelatorio val30 = new ExtratoBaixadoRelatorio + { + Id = ((DomainBase)x).Id, + Bruto = x.Bruto, + Data = x.Data, + DataCredito = x.DataCredito, + Historico = x.Historico, + Ir = x.Ir, + Iss = x.Iss, + Liquido = x.Liquido, + Numero = x.Numero, + Observacao = x.Observacao + }; + object seguradora; + if (x.Seguradora == null) + { + seguradora = null; + } + else + { + Seguradora? obj20 = ((IEnumerable)Recursos.Seguradoras).FirstOrDefault((Func)((Seguradora p) => ((DomainBase)p).Id == ((DomainBase)x.Seguradora).Id)); + seguradora = ((obj20 != null) ? obj20.Nome : null); + } + val30.Seguradora = (string)seguradora; + val30.Outro = x.Outro; + val30.Status = EnumHelper.GetDescription(x.Status); + val30.Extrato = x; + return val30; + }).ToList(); + Extratos = extratos; + ExtratosFiltrado = new ObservableCollection(Extratos); + break; + } + case 12: + { + if ((fim.Value - inicio.Value).TotalDays < 30.0) + { + await ShowMessage("RECOMENDAMOS FILTRAR UM PERÍODO DE 30 DIAS PARA QUE O RELATÓRIO FUNCIONE CORRETAMENTE."); + } + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list4 = await _parcelaServico.FaturaPendente(Filtros); + if (list4.Count == 0) + { + return false; + } + DateTime dateNow = Funcoes.GetNetworkTime(); + List faturaPendente = ((IEnumerable)list4).Select((Func)delegate(Documento x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_018c: Unknown result type (might be due to invalid IL or missing references) + //IL_01b2: Unknown result type (might be due to invalid IL or missing references) + //IL_01c7: Unknown result type (might be due to invalid IL or missing references) + //IL_01dc: Unknown result type (might be due to invalid IL or missing references) + //IL_01e8: Unknown result type (might be due to invalid IL or missing references) + //IL_01f4: Unknown result type (might be due to invalid IL or missing references) + //IL_021a: Unknown result type (might be due to invalid IL or missing references) + //IL_0239: Unknown result type (might be due to invalid IL or missing references) + //IL_029c: Unknown result type (might be due to invalid IL or missing references) + //IL_029e: Unknown result type (might be due to invalid IL or missing references) + //IL_02b6: Unknown result type (might be due to invalid IL or missing references) + //IL_02ce: Unknown result type (might be due to invalid IL or missing references) + //IL_02ef: Unknown result type (might be due to invalid IL or missing references) + //IL_02f6: Unknown result type (might be due to invalid IL or missing references) + //IL_0302: Unknown result type (might be due to invalid IL or missing references) + //IL_0323: Unknown result type (might be due to invalid IL or missing references) + //IL_032f: Unknown result type (might be due to invalid IL or missing references) + //IL_034c: Unknown result type (might be due to invalid IL or missing references) + //IL_039b: Unknown result type (might be due to invalid IL or missing references) + //IL_03ac: Unknown result type (might be due to invalid IL or missing references) + //IL_0419: Unknown result type (might be due to invalid IL or missing references) + //IL_0486: Unknown result type (might be due to invalid IL or missing references) + //IL_04ba: Unknown result type (might be due to invalid IL or missing references) + //IL_04d6: Expected O, but got Unknown + FaturaPendente val40 = new FaturaPendente(); + Parcela? obj35 = x.Parcelas.FirstOrDefault(); + int pendencia; + if (!(((obj35 != null) ? obj35.VigenciaFinal : null) == DateTime.MinValue)) + { + pendencia = (((x.Vigencia2 == DateTime.MinValue || !x.Vigencia2.HasValue) ? dateNow.Year : x.Vigencia2.Value.Year) - x.Parcelas.FirstOrDefault().VigenciaFinal.Value.Year) * 12 + ((x.Vigencia2 == DateTime.MinValue || !x.Vigencia2.HasValue) ? dateNow.Month : x.Vigencia2.Value.Month) - x.Parcelas.FirstOrDefault().VigenciaFinal.Value.Month; + } + else + { + _ = x.Vigencia1; + pendencia = (dateNow.Year - x.Vigencia1.Year) * 12 + (dateNow.Month - x.Vigencia1.Month); + } + val40.Pendencia = pendencia; + Cliente cliente13 = x.Controle.Cliente; + val40.Cliente = ((cliente13 != null) ? cliente13.Nome : null) ?? ""; + val40.Apolice = x.Apolice ?? ""; + val40.Endosso = x.Endosso ?? ""; + val40.VigenciaFinal = x.Vigencia2; + val40.VigenciaInicial = x.Vigencia1; + Produto produto12 = x.Controle.Produto; + val40.Produto = ((produto12 != null) ? produto12.Nome : null) ?? ""; + val40.Ramo = x.Controle.Ramo.Nome ?? ""; + val40.Seguradora = (nomeSeguradora ? x.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Controle.Seguradora.NomeSocial)) ? x.Controle.Seguradora.NomeSocial : x.Controle.Seguradora.Nome)); + val40.Status = EnumHelper.GetDescription(x.Situacao) ?? ""; + Vendedor vendedorPrincipal10 = x.VendedorPrincipal; + val40.Vendedor = ((vendedorPrincipal10 != null) ? vendedorPrincipal10.Nome : null); + Estipulante estipulante12 = x.Estipulante1; + val40.Estipulante = ((estipulante12 != null) ? estipulante12.Nome : null) ?? ""; + val40.Documento = x; + val40.DataControle = x.DataControle; + Status status11 = x.Status; + val40.StatusApolice = ((status11 != null) ? status11.Nome : null) ?? ""; + val40.Pasta = x.Pasta; + Cliente cliente14 = x.Controle.Cliente; + val40.PastaCliente = ((cliente14 != null) ? cliente14.Pasta : null); + val40.Item = ((x.ItensAtivo == null) ? "" : ((x.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.ItensAtivo.Count == 1) ? x.ItensAtivo.First().Descricao : ""))); + val40.Parcela = x.Parcelas.FirstOrDefault(); + val40.VigenciaFinalFatura = ((x.Parcelas.FirstOrDefault().VigenciaFinal == DateTime.MinValue || !x.Parcelas.FirstOrDefault().VigenciaFinal.HasValue) ? null : x.Parcelas.FirstOrDefault().VigenciaFinal); + val40.VigenciaIncialFatura = ((x.Parcelas.FirstOrDefault().VigenciaIncial == DateTime.MinValue || !x.Parcelas.FirstOrDefault().VigenciaIncial.HasValue) ? null : x.Parcelas.FirstOrDefault().VigenciaIncial); + val40.Fatura = (ValidationHelper.IsNullOrEmpty(x.Parcelas.FirstOrDefault().Fatura) ? "0" : x.Parcelas.FirstOrDefault().Fatura); + val40.Vencimento = x.Parcelas.FirstOrDefault().Vencimento; + return val40; + }).ToList(); + FaturaPendente = faturaPendente; + FaturaPendenteFiltrado = new ObservableCollection(FaturaPendente); + break; + } + case 14: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + Filtros filtros3 = Filtros; + int selectedAno4 = SelectedAno; + selectedMes = SelectedMes; + filtros3.Inicio = new DateTime(selectedAno4, ((object)(Mes)(ref selectedMes)).GetHashCode(), 1); + Filtros filtros4 = Filtros; + int selectedAno5 = SelectedAno; + selectedMes = SelectedMes; + int hashCode2 = ((object)(Mes)(ref selectedMes)).GetHashCode(); + int selectedAno6 = SelectedAno; + selectedMes = SelectedMes; + filtros4.Fim = new DateTime(selectedAno5, hashCode2, DateTime.DaysInMonth(selectedAno6, ((object)(Mes)(ref selectedMes)).GetHashCode())); + DateTime value = (Inicio = Filtros.Inicio); + inicio = value; + value = (Fim = Filtros.Fim); + fim = value; + List metasSeguradoras = await _metaSeguradoraServico.BuscarMetasSeguradoras(Filtros); + if (Filtros.Seguradoras.Count == 0) + { + Filtros.Seguradoras.AddRange(metasSeguradoras.Select((MetaSeguradora x) => ((DomainBase)x.Seguradora).Id)); + } + List prodParcelasSeg = await _apoliceServico.BuscarApolices(Filtros); + List collection3 = await _parcelaServico.BuscarFaturas(Filtros); + prodParcelasSeg.AddRange(collection3); + if (metasSeguradoras.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List metasS = new List(); + metasSeguradoras.ForEach(delegate(MetaSeguradora x) + { + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_003f: Unknown result type (might be due to invalid IL or missing references) + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_0096: Expected O, but got Unknown + metasS.Add(new MetaSeguradoraRelatorio + { + Id = ((DomainBase)x).Id, + Seguradora = x.Seguradora.Nome, + MetaAtingir = x.Valor, + MetaCumprida = prodParcelasSeg.Where((Documento y) => ((DomainBase)y.Controle.Seguradora).Id.Equals(((DomainBase)x.Seguradora).Id)).Sum((Documento y) => y.PremioLiquido) + }); + }); + MetaSeguradora = metasS; + MetaSeguradoraFiltrado = new ObservableCollection(MetaSeguradora); + break; + } + case 15: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + Filtros filtros = Filtros; + int selectedAno = SelectedAno; + selectedMes = SelectedMes; + filtros.Inicio = new DateTime(selectedAno, ((object)(Mes)(ref selectedMes)).GetHashCode(), 1); + Filtros filtros2 = Filtros; + int selectedAno2 = SelectedAno; + selectedMes = SelectedMes; + int hashCode = ((object)(Mes)(ref selectedMes)).GetHashCode(); + int selectedAno3 = SelectedAno; + selectedMes = SelectedMes; + filtros2.Fim = new DateTime(selectedAno2, hashCode, DateTime.DaysInMonth(selectedAno3, ((object)(Mes)(ref selectedMes)).GetHashCode())); + List metasVendedores = await _metaVendedorServico.BuscarMetasVendedores(Filtros); + Inicio = Filtros.Inicio; + Fim = Filtros.Fim; + List prodParcelasVen = await _apoliceServico.BuscarApolices(Filtros); + List collection = await _parcelaServico.BuscarFaturas(Filtros); + prodParcelasVen.AddRange(collection); + List vends = metasVendedores.Select((MetaVendedor x) => ((DomainBase)x.Vendedor).Id).ToList(); + prodParcelasVen = prodParcelasVen.Where((Documento x) => vends.Any((long m) => x.Vendedores.Select((Vendedor v) => ((DomainBase)v).Id).Contains(m))).ToList(); + if (metasVendedores.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List metasV = new List(); + metasVendedores.ForEach(delegate(MetaVendedor x) + { + //IL_0036: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Expected O, but got Unknown + decimal premioLiquido = default(decimal); + prodParcelasVen.ForEach(delegate(Documento y) + { + if (y.Vendedores.Any((Vendedor v) => ((DomainBase)v).Id == ((DomainBase)x.Vendedor).Id)) + { + premioLiquido += y.PremioLiquido; + } + }); + metasV.Add(new MetaVendedorRelatorio + { + Id = ((DomainBase)x).Id, + Vendedor = x.Vendedor.Nome, + MetaAtingir = x.Valor, + MetaCumprida = premioLiquido + }); + }); + MetaVendedor = metasV; + MetaVendedorFiltrado = new ObservableCollection(MetaVendedor); + break; + } + case 19: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list8 = ((IEnumerable)(await _notaFiscalServico.BuscarNotasFiscais(Filtros))).Select((Func)delegate(NotaFiscal x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Unknown result type (might be due to invalid IL or missing references) + //IL_00a3: Expected O, but got Unknown + NotaFiscalRelatorio val39 = new NotaFiscalRelatorio + { + Seguradora = (x.Seguradora.Nome ?? ""), + Liquido = x.ValorLiquido, + Ir = x.Ir, + Iss = x.Iss, + Bruto = x.ValorBruto, + Data = x.Data + }; + Estipulante estipulante11 = x.Estipulante; + val39.Estipulante = ((estipulante11 != null) ? estipulante11.Nome : null) ?? ""; + val39.Extrato = x.Extrato; + val39.Cnpj = x.Seguradora.Documento ?? ""; + return val39; + }).ToList(); + if (list8.Count == 0) + { + ExtratosEnabled = false; + return false; + } + NotasFiscais = list8.OrderBy((NotaFiscalRelatorio x) => x.Seguradora).ToList(); + NotaFiscalFiltrado = new ObservableCollection(NotasFiscais); + break; + } + case 20: + { + List list5 = await _parcelaServico.BuscarPrevisaoPagamentoComissao(Filtros); + if (list5 == null) + { + ExtratosEnabled = false; + return false; + } + PrevisaoSintetico = new ObservableCollection(); + PrevisaoPagamentoComissaoSintetico val2 = new PrevisaoPagamentoComissaoSintetico + { + Titulo = "SINTÉTICO POR SEGURADORA", + Agrupamento = new ObservableCollection() + }; + foreach (IGrouping s3 in (from x in list5 + orderby x.Seguradora + group x by x.Seguradora).ToList()) + { + List source = list5.Where((PrevisaoPagamento x) => x.Seguradora == s3.Key).ToList(); + AgrupamentoSintetico val3 = new AgrupamentoSintetico(); + PrevisaoPagamento? obj = ((IEnumerable)source).FirstOrDefault((Func)((PrevisaoPagamento n) => n.Seguradora == s3.Key)); + val3.Nome = ((obj != null) ? obj.Seguradora.ToUpper() : null); + val3.PrevisaoPagamento = source.Sum((PrevisaoPagamento x) => x.Repasse); + val3.PrevisaoLiquida = source.Sum((PrevisaoPagamento x) => x.RepasseLiquido); + AgrupamentoSintetico item = val3; + val2.Agrupamento.Add(item); + } + val2.Agrupamento.Add(new AgrupamentoSintetico + { + Nome = "TOTAL", + PrevisaoPagamento = val2.Agrupamento.Sum((AgrupamentoSintetico x) => x.PrevisaoPagamento), + PrevisaoLiquida = val2.Agrupamento.Sum((AgrupamentoSintetico x) => x.PrevisaoLiquida) + }); + PrevisaoSintetico.Add(val2); + PrevisaoPagamentoComissaoSintetico val4 = new PrevisaoPagamentoComissaoSintetico + { + Titulo = "SINTÉTICO POR RAMO", + Agrupamento = new ObservableCollection() + }; + foreach (IGrouping r2 in (from x in list5 + orderby x.Ramo + group x by x.Ramo).ToList()) + { + List source2 = (from x in list5 + where x.Ramo == r2.Key + orderby x.Ramo + select x).ToList(); + AgrupamentoSintetico val5 = new AgrupamentoSintetico(); + PrevisaoPagamento? obj2 = ((IEnumerable)source2).FirstOrDefault((Func)((PrevisaoPagamento n) => n.Ramo == r2.Key)); + val5.Nome = ((obj2 != null) ? obj2.Ramo.ToUpper() : null); + val5.PrevisaoPagamento = source2.Sum((PrevisaoPagamento x) => x.Repasse); + val5.PrevisaoLiquida = source2.Sum((PrevisaoPagamento x) => x.RepasseLiquido); + AgrupamentoSintetico item2 = val5; + val4.Agrupamento.Add(item2); + } + val4.Agrupamento.Add(new AgrupamentoSintetico + { + Nome = "TOTAL", + PrevisaoPagamento = val4.Agrupamento.Sum((AgrupamentoSintetico x) => x.PrevisaoPagamento), + PrevisaoLiquida = val4.Agrupamento.Sum((AgrupamentoSintetico x) => x.PrevisaoLiquida) + }); + PrevisaoSintetico.Add(val4); + PrevisaoPagamentoComissaoSintetico val6 = new PrevisaoPagamentoComissaoSintetico + { + Titulo = "SINTÉTICO POR VENDEDOR", + Agrupamento = new ObservableCollection() + }; + foreach (IGrouping v4 in (from x in list5 + orderby x.Vendedor.Nome + group x by ((DomainBase)x.Vendedor).Id).ToList()) + { + List source3 = list5.Where((PrevisaoPagamento x) => ((DomainBase)x.Vendedor).Id == v4.Key).ToList(); + AgrupamentoSintetico val7 = new AgrupamentoSintetico(); + PrevisaoPagamento? obj3 = ((IEnumerable)source3).FirstOrDefault((Func)((PrevisaoPagamento n) => ((DomainBase)n.Vendedor).Id == v4.Key)); + val7.Nome = ((obj3 != null) ? obj3.Vendedor.Nome.ToUpper() : null); + val7.PrevisaoPagamento = source3.Sum((PrevisaoPagamento x) => x.Repasse); + val7.PrevisaoLiquida = source3.Sum((PrevisaoPagamento x) => x.RepasseLiquido); + AgrupamentoSintetico item3 = val7; + val6.Agrupamento.Add(item3); + } + val6.Agrupamento.Add(new AgrupamentoSintetico + { + Nome = "TOTAL", + PrevisaoPagamento = val6.Agrupamento.Sum((AgrupamentoSintetico x) => x.PrevisaoPagamento), + PrevisaoLiquida = val6.Agrupamento.Sum((AgrupamentoSintetico x) => x.PrevisaoLiquida) + }); + PrevisaoSintetico.Add(val6); + List> list6 = (from x in list5 + group x by ((DomainBase)x.Vendedor).Id).ToList(); + Previsao = new ObservableCollection(); + foreach (IGrouping v3 in list6) + { + List list7 = list5.Where((PrevisaoPagamento x) => ((DomainBase)x.Vendedor).Id == v3.Key).ToList(); + list7.Add(new PrevisaoPagamento + { + Nome = "TOTAL", + PremioLiquido = list7.Sum((PrevisaoPagamento x) => x.PremioLiquido), + RepasseLiquido = list7.Sum((PrevisaoPagamento x) => x.RepasseLiquido) + }); + ObservableCollection previsao = Previsao; + PrevisaoPagamentoComissao val8 = new PrevisaoPagamentoComissao(); + PrevisaoPagamento? obj4 = ((IEnumerable)list7).FirstOrDefault((Func)((PrevisaoPagamento x) => ((DomainBase)x.Vendedor).Id == v3.Key)); + val8.Vendedor = ((obj4 != null) ? obj4.Vendedor.Nome.ToUpper() : null); + val8.PrevisaoPagamento = new ObservableCollection(list7); + previsao.Add(val8); + } + Previsao = new ObservableCollection(Previsao.OrderBy((PrevisaoPagamentoComissao x) => x.Vendedor)); + PrevisaoFiltrado = new ObservableCollection(Previsao); + HtmlContent = await GerarHtml(screen: true); + break; + } + case 23: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list3 = await _logServico.BuscarLogsEnvio(Filtros); + if (list3.Count == 0) + { + ExtratosEnabled = false; + return false; + } + LogsEnvio = list3; + LogsEnvioFiltrado = new ObservableCollection(LogsEnvio); + break; + } + case 24: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list21 = await _logServico.BuscarLogs(Filtros); + if (list21.Count == 0) + { + ExtratosEnabled = false; + return false; + } + LogUtilizacao = ((IEnumerable)list21).Select((Func)((RegistroAcao x) => new LogAcaoRelatorio + { + RegistroEntity = x, + EntidadeId = x.EntidadeId, + Acesso = ((!x.Tela.HasValue) ? EnumHelper.GetDescription(x.Relatorio) : EnumHelper.GetDescription(x.Tela)), + Data = x.DataHora, + Descricao = x.Descricao, + Ip = x.Ip, + Maquina = x.NomeMaquina, + UsuarioAgger = x.Usuario.Nome, + UsuarioMaquina = x.UsuarioMaquina, + Versao = x.Versao + })).ToList(); + LogUtilizacaoFiltrado = new ObservableCollection(LogUtilizacao); + break; + } + case 25: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list16 = await _logServico.BuscarLogsAntigos(Filtros); + if (list16.Count == 0) + { + ExtratosEnabled = false; + return false; + } + LogUtilizacao = ((IEnumerable)list16).Select((Func)delegate(RegistroAcao x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Expected O, but got Unknown + LogAcaoRelatorio val28 = new LogAcaoRelatorio + { + RegistroEntity = x, + EntidadeId = x.EntidadeId, + Acesso = ((!x.Tela.HasValue) ? EnumHelper.GetDescription(x.Relatorio) : EnumHelper.GetDescription(x.Tela)), + Data = x.DataHora, + Descricao = x.Descricao, + Ip = x.Ip, + Maquina = x.NomeMaquina + }; + Usuario usuario2 = x.Usuario; + val28.UsuarioAgger = ((usuario2 != null) ? usuario2.Nome : null); + val28.UsuarioMaquina = x.UsuarioMaquina; + val28.Versao = x.Versao; + return val28; + }).ToList(); + LogUtilizacaoFiltrado = new ObservableCollection(LogUtilizacao); + break; + } + case 26: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list14 = await _criticaServico.BuscarCritica(Inicio, Fim); + if (list14.Count == 0) + { + return false; + } + ApoliceCritica = ((IEnumerable)list14).Select((Func)delegate(CriticaApolice x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + //IL_009d: 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_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_0115: Unknown result type (might be due to invalid IL or missing references) + //IL_0135: Unknown result type (might be due to invalid IL or missing references) + //IL_017c: Unknown result type (might be due to invalid IL or missing references) + //IL_0195: Unknown result type (might be due to invalid IL or missing references) + //IL_01b2: Unknown result type (might be due to invalid IL or missing references) + //IL_01c3: Unknown result type (might be due to invalid IL or missing references) + //IL_0209: Expected O, but got Unknown + ApoliceCritica val33 = new ApoliceCritica + { + Critica = x, + Pendencia = (x.Critica.GetValueOrDefault() ? "" : $"{(DateTime.Today - x.DataImportacao.Value.Date).TotalDays} DIAS"), + Cliente = x.Documento.Controle.Cliente.Nome, + Proposta = x.Documento.Proposta, + Apolice = x.Documento.Apolice, + PropostaEndosso = x.Documento.PropostaEndosso, + VigenciaInicial = x.Documento.Vigencia1, + Ramo = x.Documento.Controle.Ramo.Nome, + Seguradora = x.Documento.Controle.Seguradora.Nome, + Tipo = ((x.Tipo == "0") ? "PROPOSTA" : ((x.Tipo == "1") ? "APÓLICE" : "PROPOSTA DE ENDOSSO")), + Importado = x.DataImportacao.Value + }; + Usuario usuarioImportacao = x.UsuarioImportacao; + val33.UsuarioImportacao = ((usuarioImportacao != null) ? usuarioImportacao.Nome : null); + val33.Criticado = x.DataCritica; + object usuarioCritica; + if (!x.UsuarioCritica.HasValue) + { + usuarioCritica = ""; + } + else + { + Usuario? obj21 = ((IEnumerable)Recursos.Usuarios).FirstOrDefault((Func)((Usuario u) => ((DomainBase)u).Id == x.UsuarioCritica)); + usuarioCritica = ((obj21 != null) ? obj21.Nome : null); + } + val33.UsuarioCritica = (string)usuarioCritica; + return val33; + }).ToList(); + ApoliceCriticaFiltrado = new ObservableCollection(ApoliceCritica); + break; + } + case 28: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list9 = await _apoliceServico.BuscarEndossos(Filtros, LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86 && x.Status != 3)); + if (list9.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List endossoo = ((IEnumerable)list9).Select((Func)delegate(Documento x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00c4: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_0108: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_012a: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Unknown result type (might be due to invalid IL or missing references) + //IL_014c: Unknown result type (might be due to invalid IL or missing references) + //IL_015d: Unknown result type (might be due to invalid IL or missing references) + //IL_016e: Unknown result type (might be due to invalid IL or missing references) + //IL_017f: Unknown result type (might be due to invalid IL or missing references) + //IL_01aa: Unknown result type (might be due to invalid IL or missing references) + //IL_01ce: Unknown result type (might be due to invalid IL or missing references) + //IL_023b: Unknown result type (might be due to invalid IL or missing references) + //IL_0242: Unknown result type (might be due to invalid IL or missing references) + //IL_025a: Unknown result type (might be due to invalid IL or missing references) + //IL_0277: Unknown result type (might be due to invalid IL or missing references) + //IL_0288: Unknown result type (might be due to invalid IL or missing references) + //IL_02ae: Unknown result type (might be due to invalid IL or missing references) + //IL_0313: Unknown result type (might be due to invalid IL or missing references) + //IL_0324: Unknown result type (might be due to invalid IL or missing references) + //IL_0358: Unknown result type (might be due to invalid IL or missing references) + //IL_0369: Unknown result type (might be due to invalid IL or missing references) + //IL_038f: Unknown result type (might be due to invalid IL or missing references) + //IL_03a5: Unknown result type (might be due to invalid IL or missing references) + //IL_03c6: Unknown result type (might be due to invalid IL or missing references) + //IL_03d2: Unknown result type (might be due to invalid IL or missing references) + //IL_0435: Unknown result type (might be due to invalid IL or missing references) + //IL_0446: Unknown result type (might be due to invalid IL or missing references) + //IL_0465: Unknown result type (might be due to invalid IL or missing references) + //IL_0484: Unknown result type (might be due to invalid IL or missing references) + //IL_048b: Unknown result type (might be due to invalid IL or missing references) + //IL_0495: Unknown result type (might be due to invalid IL or missing references) + //IL_04a6: Unknown result type (might be due to invalid IL or missing references) + //IL_04fa: Unknown result type (might be due to invalid IL or missing references) + //IL_0510: Unknown result type (might be due to invalid IL or missing references) + //IL_0521: Unknown result type (might be due to invalid IL or missing references) + //IL_053c: Unknown result type (might be due to invalid IL or missing references) + //IL_0558: Expected O, but got Unknown + Endosso val38 = new Endosso(); + Cliente cliente12 = x.Controle.Cliente; + val38.Cliente = ((cliente12 != null) ? cliente12.Nome : null) ?? ""; + val38.Proposta = x.Proposta ?? ""; + val38.Apolice = x.Apolice ?? ""; + val38.ApoliceConferida = (x.ApoliceConferida ? "SIM" : "NÃO"); + val38.PropostaEndosso = x.PropostaEndosso ?? ""; + val38.NumEndosso = x.Endosso ?? ""; + val38.Comissao = x.Comissao; + NegocioCorretora? negocioCorretora5 = x.NegocioCorretora; + val38.Negocio = (negocioCorretora5.HasValue ? EnumHelper.GetDescription(negocioCorretora5.GetValueOrDefault()) : null) ?? ""; + val38.PremioLiquido = x.PremioLiquido; + val38.PremioTotal = x.PremioTotal; + val38.NumeroParcelas = x.NumeroParcelas; + val38.Emissao = x.Emissao; + val38.VigenciaFinal = x.Vigencia2; + val38.VigenciaInicial = x.Vigencia1; + val38.Remessa = x.Remessa; + Produto produto11 = x.Controle.Produto; + val38.Produto = ((produto11 != null) ? produto11.Nome : null) ?? ""; + val38.Ramo = x.Controle.Ramo.Nome ?? ""; + val38.Seguradora = (nomeSeguradora ? x.Controle.Seguradora.Nome : ((!string.IsNullOrWhiteSpace(x.Controle.Seguradora.NomeSocial)) ? x.Controle.Seguradora.NomeSocial : x.Controle.Seguradora.Nome)); + val38.Status = EnumHelper.GetDescription(x.Situacao) ?? ""; + Vendedor vendedorPrincipal9 = x.VendedorPrincipal; + val38.Vendedor = ((vendedorPrincipal9 != null) ? vendedorPrincipal9.Nome : null); + val38.RepasseVendedor = x.PercentualRepasse; + Estipulante estipulante10 = x.Estipulante1; + val38.Estipulante = ((estipulante10 != null) ? estipulante10.Nome : null) ?? ""; + val38.TodosVendedores = ((x.Vendedores == null || x.Vendedores.Count == 0) ? "" : string.Join("; ", x.Vendedores.Select((Vendedor v) => v.Nome))); + val38.Tipo = x.Tipo; + val38.TipoDocumento = ((x.Tipo == 0) ? "APÓLICE" : ((x.Tipo == 1) ? "ENDOSSO" : "FATURA")); + val38.DataControle = x.DataControle; + Status status10 = x.Status; + val38.StatusApolice = ((status10 != null) ? status10.Nome : null) ?? ""; + val38.IdEmpresa = x.Controle.IdEmpresa; + val38.Empresa = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa empresa) => ((DomainBase)empresa).Id == x.Controle.IdEmpresa)).NomeSocial; + val38.Documento = x; + val38.Item = ((x.ItensAtivo == null) ? "" : ((x.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.ItensAtivo.Count == 1) ? x.ItensAtivo.First().Descricao : ""))); + val38.Assinaturas = x.Assinaturas; + val38.AssinadaSiggner = (x.AssinadaSiggner ? "SIM" : "NÃO"); + val38.PropAssinada = (x.PropostaAssinada ? "SIM" : "NÃO"); + val38.StatusAssinatura = x.StatusAssinatura; + val38.Pasta = x.Pasta; + val38.ComissaoGerada = (x.PremioLiquido + (x.AdicionalComiss ? x.PremioAdicional : 0m)) * x.Comissao * 0.01m; + val38.TipoPagamento = EnumHelper.GetDescription(x.TipoRecebimento); + val38.DataCriacao = x.DataCriacao; + val38.PastaCliente = x.Controle.Cliente.Pasta; + val38.DocumentoCliente = x.Controle.Cliente.Documento; + return val38; + }).ToList(); + Endossoo = endossoo; + EndossoFiltrado = new ObservableCollection(Endossoo); + break; + } + case 29: + { + RelatorioFiltroPersonalizado = Funcoes.PopularFiltroPersonalizado(); + List list2 = await _clienteServico.BuscarClassificacoes(); + if (list2.Count == 0) + { + ExtratosEnabled = false; + return false; + } + List classificacao = ((IEnumerable)list2).Select((Func)((Classificacao x) => new Classificacao + { + EntidadeCliente = x.EntidadeCliente, + Nome = x.Nome, + Premioliquido = x.Premioliquido, + Resultado = x.Resultado, + Comissao = x.Comissao, + Geral = x.Geral, + Ativo = x.Ativo + })).ToList(); + Classificacao = classificacao; + ClassificacaoFiltrado = new ObservableCollection(Classificacao); + break; + } + } + RegistrarAcao($"EMITIU RELATÓRIO PERÍODO ENTRE {Inicio:d} E {Fim:d}", Relatorio, Filtros); + PostMonitor(); + } + catch + { + string text = ""; + if ((int)Relatorio != 0 && (int)Relatorio != 15 && (int)Relatorio != 14) + { + text = " DE " + Inicio.ToShortDateString() + " ATÉ " + Fim.ToShortDateString(); + } + await ShowMessage("ERRO AO GERAR " + EnumHelper.GetDescription(Relatorio) + text + ".\nFAVOR ENTRAR EM CONTATO COM A AGGER."); + return false; + } + return true; + } + + private static string UltimaMovimentacaoSinistro(Sinistro x) + { + _ = x.IdUsuarioAlteracao; + if (x.IdUsuarioAlteracao != 0L) + { + return $"{x.DataAlteracao} / {Recursos.Usuarios.First((Usuario usuario) => ((DomainBase)usuario).Id == x.IdUsuarioAlteracao).Nome}"; + } + _ = x.IdUsuarioCriacao; + if (x.IdUsuarioCriacao != 0L) + { + return $"{x.DataCriacao} / {Recursos.Usuarios.First((Usuario usuario) => ((DomainBase)usuario).Id == x.IdUsuarioCriacao).Nome}"; + } + return ""; + } + + private static string JoinTelefones(List telefones) + { + if (telefones != null) + { + return string.Join(" | ", telefones.Select((ClienteTelefone v) => ((TelefoneBase)v).Prefixo + " " + ((TelefoneBase)v).Numero)); + } + return ""; + } + + private static string JoinEmails(List emails) + { + if (emails != null) + { + return string.Join(" | ", (from v in emails + where !string.IsNullOrEmpty(((EmailBase)v).Email) + select ((EmailBase)v).Email).Distinct()); + } + return ""; + } + + public async Task Print(bool pageBreak = false) + { + string html = ""; + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 0: + case 1: + { + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ClientesAtivosInativosFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 17: + { + if (LicenciamentoFiltrado == null || LicenciamentoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)LicenciamentoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 18: + { + if (TarefaFiltrado == null || TarefaFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)TarefaFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 2: + { + if (ProducaoFiltrado == null || ProducaoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ProducaoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 3: + { + if (ApolicePendenteFiltrado == null || ApolicePendenteFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ApolicePendenteFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 4: + { + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)RenovacaoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 5: + { + if (ComissaoFiltrado == null || ComissaoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ComissaoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 9: + case 10: + { + if (SinistroFiltrado == null || SinistroFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)SinistroFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 23: + { + if (LogsEnvioFiltrado == null || LogsEnvioFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)LogsEnvioFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 6: + case 16: + { + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)PendenteFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 8: + { + if (AuditoriaFiltrado == null || AuditoriaFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)AuditoriaFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 7: + { + if (Pagamentos == null || Pagamentos.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)Pagamentos.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + bool flag = Pagamentos.All((Pagamento x) => x.Dados.Any((DadosRelatorio p) => !p.DataPagamento.HasValue)) && SomenteNaoPagos; + if (flag) + { + flag = await ShowMessage("DESEJA REALMENTE EMITIR O RECIBO DE PAGAMENTO DOS VENDEDORES LISTADOS?" + Environment.NewLine + "ESSE PROCEDIMENTO IRÁ GERAR O PAGAMENTO DO REPASSE DAS PARCELAS PRESENTES NA LISTAGEM.", "SIM", "NÃO"); + } + if (flag) + { + ReciboPagamento = true; + } + Carregando = true; + base.IsEnabled = false; + html = await GerarHtml(screen: false, pageBreak, parametros); + if (ReciboPagamento) + { + await GerarPagamento(Pagamentos.ToList()); + } + ReciboPagamento = false; + break; + } + case 12: + { + if (FaturaPendenteFiltrado == null || FaturaPendenteFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)FaturaPendenteFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 11: + { + if (FechamentoFiltrado == null || FechamentoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)FechamentoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 14: + { + if (MetaSeguradoraFiltrado == null || MetaSeguradoraFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)MetaSeguradoraFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 15: + { + if (MetaVendedorFiltrado == null || MetaVendedorFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)MetaVendedorFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 19: + { + if (NotaFiscalFiltrado == null || NotaFiscalFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)NotaFiscalFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 20: + { + if (PrevisaoFiltrado == null || PrevisaoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)PrevisaoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 24: + case 25: + { + if (LogUtilizacaoFiltrado == null || LogUtilizacaoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)LogUtilizacaoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 26: + { + if (ApoliceCriticaFiltrado == null || ApoliceCriticaFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ApoliceCriticaFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 27: + { + if (PlacaFiltrado == null || PlacaFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)PlacaFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 13: + { + if (ExtratosFiltrado == null || ExtratosFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ExtratosFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 28: + { + if (EndossoFiltrado == null || EndossoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)EndossoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + case 29: + { + if (ClassificacaoFiltrado == null || ClassificacaoFiltrado.Count == 0) + { + return; + } + ConfiguracaoImpressao parametros = await ShowDialogPrint(Relatorio, ((object)ClassificacaoFiltrado.First()).GetType()); + if (parametros == null || !parametros.Campos.Any()) + { + return; + } + html = await GerarHtml(screen: false, pageBreak, parametros); + break; + } + } + if (string.IsNullOrEmpty(html)) + { + return; + } + RegistrarAcao($"IMPRIMIU RELATÓRIO PERÍODO ENTRE {Inicio:d} E {Fim:d}", Relatorio, Filtros); + string tempPath = Path.GetTempPath(); + string text = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, new Regex("[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]").Replace(EnumHelper.GetDescription(Relatorio), ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(html); + streamWriter.Close(); + try + { + Process.Start(text); + } + catch + { + await ShowMessage("NÃO FOI ENCONTRADO O APLICATIVO PADRÃO DE HTML. \nACESSE AS CONFIGURAÇÕES DO SISTEMA OPERACIONAL PARA CONFIGURAR OU CONTATE UM TÉCNICO PARA AUXILIÁ-LO."); + } + } + + private async Task PostMonitor() + { + try + { + HttpClient client = new HttpClient(); + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + client.Timeout = TimeSpan.FromSeconds(10.0); + string value = $"{ApplicationHelper.IdFornecedor}:{(int)Relatorio}:{Funcoes.GetNetworkTime().ToUniversalTime().Ticks}".EncodeBase64(); + Uri uri = Address.ApiMonitor.Append("report").AddQuery("reportQuery", value); + await client.GetAsync(uri); + } + finally + { + ((IDisposable)client)?.Dispose(); + } + } + catch + { + } + } + + private async Task GerarPagamento(List pagamentos) + { + ParcelaServico parcelaServico = new ParcelaServico(); + List repasses = pagamentos.SelectMany((Pagamento x) => x.Dados).ToList(); + if (await parcelaServico.GerarPagamento((from x in repasses + where x.EntidadeVendedorParcela != null + select x.EntidadeVendedorParcela).ToList())) + { + await new AdiantamentoServico().GerarPagamento((from x in repasses + where x.EntidadeAdiantamento != null && !x.DataPagamento.HasValue + select x.EntidadeAdiantamento).ToList()); + RegistrarAcao($"GEROU EMISSÃO DE RECIBO ENTRE {Inicio:d} E {Fim:d}", Relatorio, Filtros); + } + } + + public async Task GerarHtml(bool screen = false, bool pageBreak = false, ConfiguracaoImpressao config = null, bool portrait = false) + { + string relatorio = ""; + string footer = ""; + Relatorio relatorio2 = Relatorio; + if (!((object)(Relatorio)(ref relatorio2)).Equals((object)(Relatorio)0)) + { + footer = $"{EnumHelper.GetDescription(Relatorio)} - PERÍODO DE {Inicio:d} ATÉ {Fim:d}. DATA DE EMISSÃO DO RELATÓRIO EM {Funcoes.GetNetworkTime():G}"; + } + SintetizarRelatorio(); + relatorio2 = Relatorio; + switch ((int)relatorio2) + { + case 0: + case 1: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list73 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico8 = (list73.Any((ClientesAtivosInativos x) => x.Selecionado) ? list73.Where((ClientesAtivosInativos x) => x.Selecionado).ToList() : list73); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico8, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + case 17: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list44 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico5 = (list44.Any((Licenciamento x) => x.Selecionado) ? list44.Where((Licenciamento x) => x.Selecionado).ToList() : list44); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico5, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + case 27: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list45 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (list45.Any((Placas x) => x.Selecionado)) + { + list45.Where((Placas x) => x.Selecionado).ToList(); + } + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(list45, Relatorio, grafico: false, verificarColunas: true, footer)); + break; + } + case 18: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list38 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico4 = (list38.Any((Tarefa x) => x.Selecionado) ? list38.Where((Tarefa x) => x.Selecionado).ToList() : list38); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico4, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + default: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listProducao = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if ((int)Agrupamento != 0) + { + List list15 = (from x in listProducao + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = ((x.Key == null && (int)Agrupamento == 3) ? "SEM VENDEDOR" : x.Key), + PremioTotal = x.Sum((Producao c) => c.PremioTotal), + PremioLiquido = x.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((x.Sum((Producao c) => c.Comissao) > 0m) ? (decimal.Round(x.Sum((Producao c) => c.Comissao) / (decimal)x.Count((Producao c) => c.Comissao > 0m), 2) * 100m) : 0m) * 0.01m, + ComissaoGerada = x.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosNovos), + NegociosProprios = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosProprios), + SegurosNovos = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosNovos), + Renovacoes = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosRenovacao), + Apolices = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = x.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalLiquido = x.Count((Producao c) => (int)c.Documento.Situacao != 3), + TotalGeral = x.Count(), + MediaPonderada = ((x.Sum((Producao p) => p.PremioLiquido) > 0m) ? (decimal.Round(x.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao) / x.Sum((Producao p) => p.PremioLiquido), 2) * 100m) : 0m) * 0.01m + })).ToList(); + list15.Add(new Sintetico + { + Agrupamento = "TOTAL", + PremioTotal = listProducao.Sum((Producao c) => c.PremioTotal), + PremioLiquido = listProducao.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((listProducao.Sum((Producao c) => c.Comissao) > 0m) ? (decimal.Round(listProducao.Sum((Producao c) => c.Comissao) / (decimal)listProducao.Count((Producao c) => c.Comissao > 0m), 2) * 100m) : 0m) * 0.01m, + ComissaoGerada = listProducao.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = Funcoes.DistinctBy(listProducao, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(listProducao, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosNovos), + NegociosProprios = Funcoes.DistinctBy(listProducao, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosProprios), + SegurosNovos = Funcoes.DistinctBy(listProducao, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosNovos), + Renovacoes = Funcoes.DistinctBy(listProducao, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosRenovacao), + Apolices = Funcoes.DistinctBy(listProducao, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(listProducao, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = listProducao.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalLiquido = listProducao.Count((Producao c) => (int)c.Documento.Situacao != 3), + TotalGeral = listProducao.Count, + MediaPonderada = ((listProducao.Sum((Producao p) => p.PremioLiquido) > 0m) ? (decimal.Round(listProducao.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao) / listProducao.Sum((Producao p) => p.PremioLiquido), 2) * 100m) : 0m) * 0.01m + }); + relatorio = Funcoes.CreateCard("SINTÉTICO", await Funcoes.GenerateTableSintetic(list15.ConstruirSintetico(Relatorio), config.TamanhoFonte), pageBreak); + } + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado).ToList() : listProducao.ToList(), Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listProducao + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo33 in agrupamento30) + { + List list22 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Seguradora == grupo33).ToList() : listProducao.Where((Producao x) => x.Seguradora == grupo33).ToList()); + if (list22.Count != 0) + { + list22.Add(new Producao + { + Cliente = "TOTAL", + Comissao = (list22.Any() ? (list22.Sum((Producao x) => x.Comissao) / (decimal)list22.Count) : 0m), + PremioTotal = list22.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list22.Sum((Producao x) => x.PremioLiquido), + ComissaoGerada = list22.Sum((Producao x) => x.ComissaoGerada) + }); + string text11 = await Funcoes.GenerateTable(list22, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list23 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Seguradora == grupo33).ToList() : listProducao.Where((Producao x) => x.Seguradora == grupo33).ToList()); + List sintetic10 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo33, + PremioTotal = list23.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list23.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((list23.Sum((Producao c) => c.Comissao) > 0m) ? decimal.Round(list23.Sum((Producao c) => c.Comissao) / (decimal)list23.Count((Producao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list23.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list23.Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = list23.Count(funcProducaoNegociosNovos), + NegociosProprios = list23.Count(funcProducaoNegociosProprios), + SegurosNovos = list23.Count(funcProducaoSegurosNovos), + Renovacoes = list23.Count(funcProducaoSegurosRenovacao), + Apolices = list23.Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list23.Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list23.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list23.Count + }, Relatorio); + string text = text11; + text11 = text + await Funcoes.GenerateTableSintetic(sintetic10, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo33, text11, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in listProducao + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo34 in agrupamento30) + { + List list20 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Ramo == grupo34).ToList() : listProducao.Where((Producao x) => x.Ramo == grupo34).ToList()); + if (list20.Count != 0) + { + list20.Add(new Producao + { + Cliente = "TOTAL", + Comissao = (list20.Any() ? (list20.Sum((Producao x) => x.Comissao) / (decimal)list20.Count) : 0m), + PremioTotal = list20.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list20.Sum((Producao x) => x.PremioLiquido), + ComissaoGerada = list20.Sum((Producao x) => x.ComissaoGerada) + }); + string text10 = await Funcoes.GenerateTable(list20, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list21 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Ramo == grupo34).ToList() : listProducao.Where((Producao x) => x.Ramo == grupo34).ToList()); + List sintetic9 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo34, + PremioTotal = list21.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list21.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((list21.Sum((Producao c) => c.Comissao) > 0m) ? decimal.Round(list21.Sum((Producao c) => c.Comissao) / (decimal)list21.Count((Producao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list21.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list21.Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = list21.Count(funcProducaoNegociosNovos), + NegociosProprios = list21.Count(funcProducaoNegociosProprios), + SegurosNovos = list21.Count(funcProducaoSegurosNovos), + Renovacoes = list21.Count(funcProducaoSegurosRenovacao), + Apolices = list21.Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list21.Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list21.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list21.Count + }, Relatorio); + string text = text10; + text10 = text + await Funcoes.GenerateTableSintetic(sintetic9, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo34, text10, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in listProducao + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo35 in agrupamento30) + { + List list18 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Vendedor == grupo35).ToList() : listProducao.Where((Producao x) => x.Vendedor == grupo35).ToList()); + if (list18.Count != 0) + { + list18.Add(new Producao + { + Cliente = "TOTAL", + Comissao = (list18.Any() ? (list18.Sum((Producao x) => x.Comissao) / (decimal)list18.Count) : 0m), + PremioTotal = list18.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list18.Sum((Producao x) => x.PremioLiquido), + ComissaoGerada = list18.Sum((Producao x) => x.ComissaoGerada) + }); + string text9 = await Funcoes.GenerateTable(list18, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list19 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Vendedor == grupo35).ToList() : listProducao.Where((Producao x) => x.Vendedor == grupo35).ToList()); + List sintetic8 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo35, + PremioTotal = list19.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list19.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((list19.Sum((Producao c) => c.Comissao) > 0m) ? decimal.Round(list19.Sum((Producao c) => c.Comissao) / (decimal)list19.Count((Producao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list19.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list19.Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = list19.Count(funcProducaoNegociosNovos), + NegociosProprios = list19.Count(funcProducaoNegociosProprios), + SegurosNovos = list19.Count(funcProducaoSegurosNovos), + Renovacoes = list19.Count(funcProducaoSegurosRenovacao), + Apolices = list19.Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list19.Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list19.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list19.Count + }, Relatorio); + string text = text9; + text9 = text + await Funcoes.GenerateTableSintetic(sintetic8, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo35, text9, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in listProducao + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo32 in agrupamento30) + { + List list24 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Estipulante == grupo32).ToList() : listProducao.Where((Producao x) => x.Estipulante == grupo32).ToList()); + if (list24.Count != 0) + { + list24.Add(new Producao + { + Cliente = "TOTAL", + Comissao = (list24.Any() ? (list24.Sum((Producao x) => x.Comissao) / (decimal)list24.Count) : 0m), + PremioTotal = list24.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list24.Sum((Producao x) => x.PremioLiquido), + ComissaoGerada = list24.Sum((Producao x) => x.ComissaoGerada) + }); + string text12 = await Funcoes.GenerateTable(list24, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list25 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Estipulante == grupo32).ToList() : listProducao.Where((Producao x) => x.Estipulante == grupo32).ToList()); + List sintetic11 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo32, + PremioTotal = list25.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list25.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((list25.Sum((Producao c) => c.Comissao) > 0m) ? decimal.Round(list25.Sum((Producao c) => c.Comissao) / (decimal)list25.Count((Producao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list25.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list25.Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = list25.Count(funcProducaoNegociosNovos), + NegociosProprios = list25.Count(funcProducaoNegociosProprios), + SegurosNovos = list25.Count(funcProducaoSegurosNovos), + Renovacoes = list25.Count(funcProducaoSegurosRenovacao), + Apolices = list25.Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list25.Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list25.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list25.Count + }, Relatorio); + string text = text12; + text12 = text + await Funcoes.GenerateTableSintetic(sintetic11, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo32, text12, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in listProducao + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo36 in agrupamento30) + { + List list16 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Status == grupo36).ToList() : listProducao.Where((Producao x) => x.Status == grupo36).ToList()); + if (list16.Count != 0) + { + list16.Add(new Producao + { + Cliente = "TOTAL", + Comissao = (list16.Any() ? (list16.Sum((Producao x) => x.Comissao) / (decimal)list16.Count) : 0m), + PremioTotal = list16.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list16.Sum((Producao x) => x.PremioLiquido), + ComissaoGerada = list16.Sum((Producao x) => x.ComissaoGerada) + }); + string text8 = await Funcoes.GenerateTable(list16, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list17 = (listProducao.Any((Producao x) => x.Selecionado) ? listProducao.Where((Producao x) => x.Selecionado && x.Status == grupo36).ToList() : listProducao.Where((Producao x) => x.Status == grupo36).ToList()); + List sintetic7 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo36, + PremioTotal = list17.Sum((Producao x) => x.PremioTotal), + PremioLiquido = list17.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((list17.Sum((Producao c) => c.Comissao) > 0m) ? decimal.Round(list17.Sum((Producao c) => c.Comissao) / (decimal)list17.Count((Producao c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list17.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list17.Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = list17.Count(funcProducaoNegociosNovos), + NegociosProprios = list17.Count(funcProducaoNegociosProprios), + SegurosNovos = list17.Count(funcProducaoSegurosNovos), + Renovacoes = list17.Count(funcProducaoSegurosRenovacao), + Apolices = list17.Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list17.Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list17.Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list17.Count + }, Relatorio); + string text = text8; + text8 = text + await Funcoes.GenerateTableSintetic(sintetic7, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo36, text8, pageBreak); + } + } + break; + } + } + break; + } + case 3: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listApolicePendente = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listApolicePendente + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo18 in agrupamento30) + { + List list52 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Seguradora == grupo18).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Seguradora == grupo18).ToList()); + if (list52.Count != 0) + { + list52.Add(new ApolicePendente + { + Cliente = "TOTAL", + Comissao = (list52.Any() ? (list52.Sum((ApolicePendente x) => x.Comissao) / (decimal)list52.Count) : 0m), + PremioTotal = list52.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list52.Sum((ApolicePendente x) => x.PremioLiquido) + }); + string text26 = await Funcoes.GenerateTable(list52, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list53 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Seguradora == grupo18).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Seguradora == grupo18).ToList()); + List sintetic25 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo18, + PremioTotal = list53.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list53.Sum((ApolicePendente p) => p.PremioLiquido), + MediaComissao = ((list53.Sum((ApolicePendente c) => c.Comissao) > 0m) ? decimal.Round(list53.Sum((ApolicePendente c) => c.Comissao) / (decimal)list53.Count((ApolicePendente c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list53.Sum((ApolicePendente c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list53.Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = list53.Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list53.Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list53.Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list53.Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list53.Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list53.Count + }, Relatorio); + string text = text26; + text26 = text + await Funcoes.GenerateTableSintetic(sintetic25, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo18, text26, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in listApolicePendente + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo19 in agrupamento30) + { + List list50 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Ramo == grupo19).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Ramo == grupo19).ToList()); + if (list50.Count != 0) + { + list50.Add(new ApolicePendente + { + Cliente = "TOTAL", + Comissao = (list50.Any() ? (list50.Sum((ApolicePendente x) => x.Comissao) / (decimal)list50.Count) : 0m), + PremioTotal = list50.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list50.Sum((ApolicePendente x) => x.PremioLiquido) + }); + string text25 = await Funcoes.GenerateTable(list50, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list51 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Ramo == grupo19).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Ramo == grupo19).ToList()); + List sintetic24 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo19, + PremioTotal = list51.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list51.Sum((ApolicePendente p) => p.PremioLiquido), + MediaComissao = ((list51.Sum((ApolicePendente c) => c.Comissao) > 0m) ? decimal.Round(list51.Sum((ApolicePendente c) => c.Comissao) / (decimal)list51.Count((ApolicePendente c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list51.Sum((ApolicePendente c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list51.Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = list51.Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list51.Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list51.Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list51.Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list51.Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list51.Count + }, Relatorio); + string text = text25; + text25 = text + await Funcoes.GenerateTableSintetic(sintetic24, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo19, text25, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in listApolicePendente + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo20 in agrupamento30) + { + List list48 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Vendedor == grupo20).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Vendedor == grupo20).ToList()); + if (list48.Count != 0) + { + list48.Add(new ApolicePendente + { + Cliente = "TOTAL", + Comissao = (list48.Any() ? (list48.Sum((ApolicePendente x) => x.Comissao) / (decimal)list48.Count) : 0m), + PremioTotal = list48.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list48.Sum((ApolicePendente x) => x.PremioLiquido) + }); + string text24 = await Funcoes.GenerateTable(list48, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list49 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Vendedor == grupo20).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Vendedor == grupo20).ToList()); + List sintetic23 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo20, + PremioTotal = list49.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list49.Sum((ApolicePendente p) => p.PremioLiquido), + MediaComissao = ((list49.Sum((ApolicePendente c) => c.Comissao) > 0m) ? decimal.Round(list49.Sum((ApolicePendente c) => c.Comissao) / (decimal)list49.Count((ApolicePendente c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list49.Sum((ApolicePendente c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list49.Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = list49.Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list49.Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list49.Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list49.Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list49.Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list49.Count + }, Relatorio); + string text = text24; + text24 = text + await Funcoes.GenerateTableSintetic(sintetic23, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo20, text24, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in listApolicePendente + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo17 in agrupamento30) + { + List list54 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Estipulante == grupo17).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Estipulante == grupo17).ToList()); + if (list54.Count != 0) + { + list54.Add(new ApolicePendente + { + Cliente = "TOTAL", + Comissao = (list54.Any() ? (list54.Sum((ApolicePendente x) => x.Comissao) / (decimal)list54.Count) : 0m), + PremioTotal = list54.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list54.Sum((ApolicePendente x) => x.PremioLiquido) + }); + string text27 = await Funcoes.GenerateTable(list54, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list55 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Estipulante == grupo17).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Estipulante == grupo17).ToList()); + List sintetic26 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo17, + PremioTotal = list55.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list55.Sum((ApolicePendente p) => p.PremioLiquido), + MediaComissao = ((list55.Sum((ApolicePendente c) => c.Comissao) > 0m) ? decimal.Round(list55.Sum((ApolicePendente c) => c.Comissao) / (decimal)list55.Count((ApolicePendente c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list55.Sum((ApolicePendente c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list55.Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = list55.Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list55.Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list55.Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list55.Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list55.Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list55.Count + }, Relatorio); + string text = text27; + text27 = text + await Funcoes.GenerateTableSintetic(sintetic26, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo17, text27, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in listApolicePendente + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo21 in agrupamento30) + { + List list46 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Status == grupo21).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Status == grupo21).ToList()); + if (list46.Count != 0) + { + list46.Add(new ApolicePendente + { + Cliente = "TOTAL", + Comissao = (list46.Any() ? (list46.Sum((ApolicePendente x) => x.Comissao) / (decimal)list46.Count) : 0m), + PremioTotal = list46.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list46.Sum((ApolicePendente x) => x.PremioLiquido) + }); + string text23 = await Funcoes.GenerateTable(list46, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list47 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado && x.Status == grupo21).ToList() : listApolicePendente.Where((ApolicePendente x) => x.Status == grupo21).ToList()); + List sintetic22 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo21, + PremioTotal = list47.Sum((ApolicePendente x) => x.PremioTotal), + PremioLiquido = list47.Sum((ApolicePendente p) => p.PremioLiquido), + MediaComissao = ((list47.Sum((ApolicePendente c) => c.Comissao) > 0m) ? decimal.Round(list47.Sum((ApolicePendente c) => c.Comissao) / (decimal)list47.Count((ApolicePendente c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list47.Sum((ApolicePendente c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = list47.Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = list47.Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list47.Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list47.Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list47.Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list47.Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list47.Count + }, Relatorio); + string text = text23; + text23 = text + await Funcoes.GenerateTableSintetic(sintetic22, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo21, text23, pageBreak); + } + } + break; + } + } + break; + } + case 4: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listRenovacao = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listRenovacao + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo23 in agrupamento30) + { + List list42 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Seguradora == grupo23).ToList() : listRenovacao.Where((Renovacao x) => x.Seguradora == grupo23).ToList()); + if (list42.Count != 0) + { + list42.Add(new Renovacao + { + Cliente = "TOTAL", + Comissao = (list42.Any() ? (list42.Sum((Renovacao x) => x.Comissao) / (decimal)list42.Count) : 0m), + PremioTotal = list42.Sum((Renovacao x) => x.PremioTotal), + PremioLiquido = list42.Sum((Renovacao x) => x.PremioLiquido) + }); + string text21 = await Funcoes.GenerateTable(list42, Relatorio, grafico: false, verificarColunas: true, footer, config); + List sintetico6 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Seguradora == grupo23).ToList() : listRenovacao.Where((Renovacao x) => x.Seguradora == grupo23).ToList()); + List sintetic20 = SintetizarRenovacao(grupo23, sintetico6).ConstruirSintetico(Relatorio); + string text = text21; + text21 = text + await Funcoes.GenerateTableSintetic(sintetic20, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo23, text21, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in listRenovacao + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo24 in agrupamento30) + { + List list41 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Ramo == grupo24).ToList() : listRenovacao.Where((Renovacao x) => x.Ramo == grupo24).ToList()); + if (list41.Count != 0) + { + list41.Add(new Renovacao + { + Cliente = "TOTAL", + Comissao = (list41.Any() ? (list41.Sum((Renovacao x) => x.Comissao) / (decimal)list41.Count) : 0m), + PremioTotal = list41.Sum((Renovacao x) => x.PremioTotal), + PremioLiquido = list41.Sum((Renovacao x) => x.PremioLiquido) + }); + string text20 = await Funcoes.GenerateTable(list41, Relatorio, grafico: false, verificarColunas: true, footer, config); + List sintetico5 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Ramo == grupo24).ToList() : listRenovacao.Where((Renovacao x) => x.Ramo == grupo24).ToList()); + List sintetic19 = SintetizarRenovacao(grupo24, sintetico5).ConstruirSintetico(Relatorio); + string text = text20; + text20 = text + await Funcoes.GenerateTableSintetic(sintetic19, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo24, text20, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in listRenovacao + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo25 in agrupamento30) + { + List list40 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Vendedor == grupo25).ToList() : listRenovacao.Where((Renovacao x) => x.Vendedor == grupo25).ToList()); + if (list40.Count != 0) + { + list40.Add(new Renovacao + { + Cliente = "TOTAL", + Comissao = (list40.Any() ? (list40.Sum((Renovacao x) => x.Comissao) / (decimal)list40.Count) : 0m), + PremioTotal = list40.Sum((Renovacao x) => x.PremioTotal), + PremioLiquido = list40.Sum((Renovacao x) => x.PremioLiquido) + }); + string text19 = await Funcoes.GenerateTable(list40, Relatorio, grafico: false, verificarColunas: true, footer, config); + List sintetico4 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Vendedor == grupo25).ToList() : listRenovacao.Where((Renovacao x) => x.Vendedor == grupo25).ToList()); + List sintetic18 = SintetizarRenovacao(grupo25, sintetico4).ConstruirSintetico(Relatorio); + string text = text19; + text19 = text + await Funcoes.GenerateTableSintetic(sintetic18, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo25, text19, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in listRenovacao + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo22 in agrupamento30) + { + List list43 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Estipulante == grupo22).ToList() : listRenovacao.Where((Renovacao x) => x.Estipulante == grupo22).ToList()); + if (list43.Count != 0) + { + list43.Add(new Renovacao + { + Cliente = "TOTAL", + Comissao = (list43.Any() ? (list43.Sum((Renovacao x) => x.Comissao) / (decimal)list43.Count) : 0m), + PremioTotal = list43.Sum((Renovacao x) => x.PremioTotal), + PremioLiquido = list43.Sum((Renovacao x) => x.PremioLiquido) + }); + string text22 = await Funcoes.GenerateTable(list43, Relatorio, grafico: false, verificarColunas: true, footer, config); + List sintetico7 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Estipulante == grupo22).ToList() : listRenovacao.Where((Renovacao x) => x.Estipulante == grupo22).ToList()); + List sintetic21 = SintetizarRenovacao(grupo22, sintetico7).ConstruirSintetico(Relatorio); + string text = text22; + text22 = text + await Funcoes.GenerateTableSintetic(sintetic21, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo22, text22, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in listRenovacao + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo26 in agrupamento30) + { + List list39 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Status == grupo26).ToList() : listRenovacao.Where((Renovacao x) => x.Status == grupo26).ToList()); + if (list39.Count != 0) + { + list39.Add(new Renovacao + { + Cliente = "TOTAL", + Comissao = (list39.Any() ? (list39.Sum((Renovacao x) => x.Comissao) / (decimal)list39.Count) : 0m), + PremioTotal = list39.Sum((Renovacao x) => x.PremioTotal), + PremioLiquido = list39.Sum((Renovacao x) => x.PremioLiquido) + }); + string text18 = await Funcoes.GenerateTable(list39, Relatorio, grafico: false, verificarColunas: true, footer, config); + List sintetico3 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado && x.Status == grupo26).ToList() : listRenovacao.Where((Renovacao x) => x.Status == grupo26).ToList()); + List sintetic17 = SintetizarRenovacao(grupo26, sintetico3).ConstruirSintetico(Relatorio); + string text = text18; + text18 = text + await Funcoes.GenerateTableSintetic(sintetic17, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo26, text18, pageBreak); + } + } + break; + } + } + break; + } + case 5: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listComissaoRelatorio = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listComissaoRelatorio + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo2 in agrupamento30) + { + List list79 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Seguradora == grupo2).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Seguradora == grupo2).ToList()); + if (list79.Count != 0) + { + list79.Add(new Comissao + { + Cliente = "TOTAL", + ComissaoPerc = (list79.Any() ? (list79.Sum((Comissao x) => x.ComissaoPerc) / (decimal)list79.Count) : 0m), + ValorComissao = list79.Sum((Comissao x) => x.ValorComissao), + ComissaoBruta = list79.Sum((Comissao x) => x.ComissaoBruta), + ComissaoRecebida = list79.Sum((Comissao x) => x.ComissaoRecebida), + Repasse = list79.Sum((Comissao x) => x.Repasse) + }); + string text41 = await Funcoes.GenerateTable(list79, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source10 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Seguradora == grupo2).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Seguradora == grupo2).ToList()); + List sintetic40 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo2, + ComissaoRecebidaBruta = source10.Sum((Comissao x) => x.ComissaoRecebida), + ComissaoPrevista = source10.Sum((Comissao x) => x.ValorLiquido), + Repasse = source10.Sum((Comissao x) => x.Repasse) + }, Relatorio); + string text = text41; + text41 = text + await Funcoes.GenerateTableSintetic(sintetic40, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo2, text41, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in listComissaoRelatorio + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo3 in agrupamento30) + { + List list78 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Ramo == grupo3).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Ramo == grupo3).ToList()); + if (list78.Count != 0) + { + list78.Add(new Comissao + { + Cliente = "TOTAL", + ComissaoPerc = (list78.Any() ? (list78.Sum((Comissao x) => x.ComissaoPerc) / (decimal)list78.Count) : 0m), + ValorComissao = list78.Sum((Comissao x) => x.ValorComissao) + }); + string text40 = await Funcoes.GenerateTable(list78, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source9 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Ramo == grupo3).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Ramo == grupo3).ToList()); + List sintetic39 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo3, + ComissaoRecebidaBruta = source9.Sum((Comissao x) => x.ComissaoRecebida), + ComissaoPrevista = source9.Sum((Comissao x) => x.ValorLiquido), + Repasse = source9.Sum((Comissao x) => x.Repasse) + }, Relatorio); + string text = text40; + text40 = text + await Funcoes.GenerateTableSintetic(sintetic39, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo3, text40, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in listComissaoRelatorio + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + List sinteticVendedor = new List(); + bool tabelaVendedores = await ShowMessage("DESEJA COLOCAR A TOTALIZAÇÃO DOS VENDEDORES EM APENAS UMA TABELA??", "SIM", "NÃO"); + if (tabelaVendedores) + { + List list76 = new List(); + foreach (string grupo5 in agrupamento30) + { + List source7 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Vendedor == grupo5).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Vendedor == grupo5).ToList()); + List list77 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = (grupo5 ?? "NÃO CADASTRADO"), + ComissaoRecebidaBruta = source7.Sum((Comissao x) => x.ComissaoRecebida), + ComissaoPrevista = source7.Sum((Comissao x) => x.ValorLiquido), + Repasse = source7.Sum((Comissao x) => x.Repasse) + }, Relatorio); + list77.Insert(0, new SinteticModel + { + Hint = "VENDEDOR", + Value = (grupo5 ?? "NÃO CADASTRADO") + }); + list76.AddRange(list77); + } + sinteticVendedor = (from x in list76.OrderByDescending((SinteticModel x) => x.Hint).ToList() + group x by x.Hint).Select((Func, SinteticModelList>)((IGrouping x) => new SinteticModelList + { + Hint = x.First().Hint, + Value = x.Select((SinteticModel v) => v.Value).ToList() + })).ToList(); + } + int i = 0; + foreach (string grupo4 in agrupamento30) + { + string text39 = ""; + List prod2 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Vendedor == grupo4).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Vendedor == grupo4).ToList()); + if (prod2.Count != 0) + { + prod2.Add(new Comissao + { + Cliente = "TOTAL", + ComissaoPerc = (prod2.Any() ? (prod2.Sum((Comissao x) => x.ComissaoPerc) / (decimal)prod2.Count) : 0m), + ValorComissao = prod2.Sum((Comissao x) => x.ValorComissao), + ComissaoRecebida = prod2.Sum((Comissao p) => p.ComissaoRecebida), + Repasse = prod2.Sum((Comissao p) => p.Repasse), + ValorLiquido = prod2.Sum((Comissao p) => p.ValorLiquido), + PremioLiquido = prod2.Sum((Comissao p) => p.PremioLiquido) + }); + if (i == 0 && tabelaVendedores) + { + string text = text39; + text39 = text + await Funcoes.GenerateTableSintetic(sinteticVendedor, config.TamanhoFonte); + relatorio += Funcoes.CreateCard("COMISSÃO RECEBIDA POR VENDEDOR", text39, pageBreak); + } + i++; + text39 = await Funcoes.GenerateTable(prod2, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source8 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Vendedor == grupo4).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Vendedor == grupo4).ToList()); + Sintetico sintetico8 = new Sintetico + { + Agrupamento = (grupo4 ?? "NÃO CADASTRADO"), + ComissaoRecebidaBruta = source8.Sum((Comissao x) => x.ComissaoRecebida), + ComissaoPrevista = source8.Sum((Comissao x) => x.ValorLiquido), + Repasse = source8.Sum((Comissao x) => x.Repasse) + }; + if (!tabelaVendedores) + { + List sintetic38 = sintetico8.ConstruirSintetico(Relatorio); + string text = text39; + text39 = text + await Funcoes.GenerateTableSintetic(sintetic38, config.TamanhoFonte); + } + relatorio += Funcoes.CreateCard(grupo4 ?? "NÃO CADASTRADO", text39, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in listComissaoRelatorio + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo in agrupamento30) + { + List list80 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Estipulante == grupo).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Estipulante == grupo).ToList()); + if (list80.Count != 0) + { + list80.Add(new Comissao + { + Cliente = "TOTAL", + ComissaoPerc = (list80.Any() ? (list80.Sum((Comissao x) => x.ComissaoPerc) / (decimal)list80.Count) : 0m), + ValorComissao = list80.Sum((Comissao x) => x.ValorComissao) + }); + string text42 = await Funcoes.GenerateTable(list80, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source11 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Estipulante == grupo).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Estipulante == grupo).ToList()); + List sintetic41 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo, + ComissaoRecebidaBruta = source11.Sum((Comissao x) => x.ComissaoRecebida), + ComissaoPrevista = source11.Sum((Comissao x) => x.ValorLiquido), + Repasse = source11.Sum((Comissao x) => x.Repasse) + }, Relatorio); + string text = text42; + text42 = text + await Funcoes.GenerateTableSintetic(sintetic41, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo, text42, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in listComissaoRelatorio + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo6 in agrupamento30) + { + List list75 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Status == grupo6).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Status == grupo6).ToList()); + if (list75.Count != 0) + { + list75.Add(new Comissao + { + Cliente = "TOTAL", + ComissaoPerc = (list75.Any() ? (list75.Sum((Comissao x) => x.ComissaoPerc) / (decimal)list75.Count) : 0m), + ValorComissao = list75.Sum((Comissao x) => x.ValorComissao) + }); + string text38 = await Funcoes.GenerateTable(list75, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source6 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado && x.Status == grupo6).ToList() : listComissaoRelatorio.Where((Comissao x) => x.Status == grupo6).ToList()); + List sintetic37 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo6, + ComissaoRecebidaBruta = source6.Sum((Comissao x) => x.ComissaoRecebida), + ComissaoPrevista = source6.Sum((Comissao x) => x.ValorLiquido), + Repasse = source6.Sum((Comissao x) => x.Repasse) + }, Relatorio); + string text = text38; + text38 = text + await Funcoes.GenerateTableSintetic(sintetic37, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo6, text38, pageBreak); + } + } + break; + } + } + break; + } + case 6: + case 16: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listPendente = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listPendente + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo8 in agrupamento30) + { + List list69 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Seguradora == grupo8).ToList() : listPendente.Where((Pendente x) => x.Seguradora == grupo8).ToList()); + if (list69.Count != 0) + { + list69.Add(new Pendente + { + Cliente = "TOTAL", + ComissaoPerc = (list69.Any() ? (list69.Sum((Pendente x) => x.ComissaoPerc) / (decimal)list69.Count) : 0m), + ComissaoGerada = list69.Sum((Pendente x) => x.ComissaoGerada), + ComissaoPrevista = list69.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevisto = list69.Sum((Pendente x) => x.TotalPrevisto) + }); + string text36 = await Funcoes.GenerateTable(list69, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list70 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Seguradora == grupo8).ToList() : listPendente.Where((Pendente x) => x.Seguradora == grupo8).ToList()); + List sintetic35 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo8, + ComissaoPrevista = list70.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevista = list70.Sum((Pendente x) => x.TotalPrevisto), + TotalGeral = list70.Count + }, Relatorio); + string text = text36; + text36 = text + await Funcoes.GenerateTableSintetic(sintetic35, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo8, text36, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in listPendente + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo9 in agrupamento30) + { + List list67 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Ramo == grupo9).ToList() : listPendente.Where((Pendente x) => x.Ramo == grupo9).ToList()); + if (list67.Count != 0) + { + list67.Add(new Pendente + { + Cliente = "TOTAL", + ComissaoPerc = (list67.Any() ? (list67.Sum((Pendente x) => x.ComissaoPerc) / (decimal)list67.Count) : 0m), + ComissaoGerada = list67.Sum((Pendente x) => x.ComissaoGerada), + ComissaoPrevista = list67.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevisto = list67.Sum((Pendente x) => x.TotalPrevisto) + }); + string text35 = await Funcoes.GenerateTable(list67, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list68 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Ramo == grupo9).ToList() : listPendente.Where((Pendente x) => x.Ramo == grupo9).ToList()); + List sintetic34 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo9, + ComissaoPrevista = list68.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevista = list68.Sum((Pendente x) => x.TotalPrevisto), + TotalGeral = list68.Count + }, Relatorio); + string text = text35; + text35 = text + await Funcoes.GenerateTableSintetic(sintetic34, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo9, text35, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in listPendente + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo10 in agrupamento30) + { + List list65 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Vendedor == grupo10).ToList() : listPendente.Where((Pendente x) => x.Vendedor == grupo10).ToList()); + if (list65.Count != 0) + { + list65.Add(new Pendente + { + Cliente = "TOTAL", + ComissaoPerc = (list65.Any() ? (list65.Sum((Pendente x) => x.ComissaoPerc) / (decimal)list65.Count) : 0m), + ComissaoGerada = list65.Sum((Pendente x) => x.ComissaoGerada), + ComissaoPrevista = list65.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevisto = list65.Sum((Pendente x) => x.TotalPrevisto) + }); + string text34 = await Funcoes.GenerateTable(list65, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list66 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Vendedor == grupo10).ToList() : listPendente.Where((Pendente x) => x.Vendedor == grupo10).ToList()); + List sintetic33 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo10, + ComissaoPrevista = list66.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevista = list66.Sum((Pendente x) => x.TotalPrevisto), + TotalGeral = list66.Count + }, Relatorio); + string text = text34; + text34 = text + await Funcoes.GenerateTableSintetic(sintetic33, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo10, text34, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in listPendente + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo7 in agrupamento30) + { + List list71 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Estipulante == grupo7).ToList() : listPendente.Where((Pendente x) => x.Estipulante == grupo7).ToList()); + if (list71.Count != 0) + { + list71.Add(new Pendente + { + Cliente = "TOTAL", + ComissaoPerc = (list71.Any() ? (list71.Sum((Pendente x) => x.ComissaoPerc) / (decimal)list71.Count) : 0m), + ComissaoGerada = list71.Sum((Pendente x) => x.ComissaoGerada), + ComissaoPrevista = list71.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevisto = list71.Sum((Pendente x) => x.TotalPrevisto), + ValorParcela = list71.Sum((Pendente x) => x.ValorParcela) + }); + string text37 = await Funcoes.GenerateTable(list71, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list72 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Estipulante == grupo7).ToList() : listPendente.Where((Pendente x) => x.Estipulante == grupo7).ToList()); + List sintetic36 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo7, + ComissaoPrevista = list72.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevista = list72.Sum((Pendente x) => x.TotalPrevisto), + TotalGeral = list72.Count + }, Relatorio); + string text = text37; + text37 = text + await Funcoes.GenerateTableSintetic(sintetic36, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo7, text37, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in listPendente + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo11 in agrupamento30) + { + List list63 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Status == grupo11).ToList() : listPendente.Where((Pendente x) => x.Status == grupo11).ToList()); + if (list63.Count != 0) + { + list63.Add(new Pendente + { + Cliente = "TOTAL", + ComissaoPerc = (list63.Any() ? (list63.Sum((Pendente x) => x.ComissaoPerc) / (decimal)list63.Count) : 0m), + ComissaoGerada = list63.Sum((Pendente x) => x.ComissaoGerada), + ComissaoPrevista = list63.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevisto = list63.Sum((Pendente x) => x.TotalPrevisto) + }); + string text33 = await Funcoes.GenerateTable(list63, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list64 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado && x.Status == grupo11).ToList() : listPendente.Where((Pendente x) => x.Status == grupo11).ToList()); + List sintetic32 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo11, + ComissaoPrevista = list64.Sum((Pendente x) => x.ComissaoPrevista), + TotalPrevista = list64.Sum((Pendente x) => x.TotalPrevisto), + TotalGeral = list64.Count + }, Relatorio); + string text = text33; + text33 = text + await Funcoes.GenerateTableSintetic(sintetic32, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo11, text33, pageBreak); + } + } + break; + } + } + break; + } + case 9: + case 10: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listSinistroAnalitico = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listSinistroAnalitico + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo13 in agrupamento30) + { + List list59 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Seguradora == grupo13).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Seguradora == grupo13).ToList()); + if (list59.Count == 0) + { + continue; + } + if ((int)Relatorio != 9) + { + list59.Add(new Sinistro + { + Nome = "TOTAL", + Valor = list59.Sum((Sinistro x) => x.Valor), + ValorOrcado = list59.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = list59.Sum((Sinistro x) => x.ValorLiberado), + ValorPago = list59.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = list59.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = list59.Sum((Sinistro x) => x.ValorFranquia) + }); + } + string text31 = await Funcoes.GenerateTable(list59, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source4 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Seguradora == grupo13).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Seguradora == grupo13).ToList()); + List sintetic30 = Funcoes.ConstruirSintetico(new Sintetico + { + Liquidado = (from x in source4 + where x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + Valor = source4.Sum((Sinistro x) => x.Valor), + ValorOrcado = source4.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = source4.Sum((Sinistro x) => x.ValorLiberado), + ValorLiquidado = source4.Where((Sinistro x) => x.Liquidacao.HasValue).Sum((Sinistro x) => x.ValorPago), + ValorPago = source4.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = source4.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = source4.Sum((Sinistro x) => x.ValorFranquia), + Pendente = (from x in source4 + where !x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + TotalGeral = listSinistroAnalitico.Distinct().Count(), + TotalClientes = listSinistroAnalitico.Select((Sinistro x) => x.EntidadeSinistro.TipoSinistro == (TipoSinistro?)0).Distinct().Count(), + TotalTerceiros = listSinistroAnalitico.Select((Sinistro x) => (int)x.EntidadeSinistro.TipoSinistro.GetValueOrDefault() == 1).Distinct().Count() + }, Relatorio); + string text = text31; + text31 = text + await Funcoes.GenerateTableSintetic(sintetic30, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo13, text31, pageBreak); + } + break; + } + case 1: + { + List agrupamento30 = (from x in listSinistroAnalitico + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo14 in agrupamento30) + { + List list58 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Ramo == grupo14).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Ramo == grupo14).ToList()); + if (list58.Count == 0) + { + continue; + } + if ((int)Relatorio != 9) + { + list58.Add(new Sinistro + { + Nome = "TOTAL", + Valor = list58.Sum((Sinistro x) => x.Valor), + ValorOrcado = list58.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = list58.Sum((Sinistro x) => x.ValorLiberado), + ValorPago = list58.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = list58.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = list58.Sum((Sinistro x) => x.ValorFranquia) + }); + } + string text30 = await Funcoes.GenerateTable(list58, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source3 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Ramo == grupo14).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Ramo == grupo14).ToList()); + List sintetic29 = Funcoes.ConstruirSintetico(new Sintetico + { + Liquidado = (from x in source3 + where x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + Valor = source3.Sum((Sinistro x) => x.Valor), + ValorOrcado = source3.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = source3.Sum((Sinistro x) => x.ValorLiberado), + ValorLiquidado = source3.Where((Sinistro x) => x.Liquidacao.HasValue).Sum((Sinistro x) => x.ValorPago), + ValorPago = source3.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = source3.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = source3.Sum((Sinistro x) => x.ValorFranquia), + Pendente = (from x in source3 + where !x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + TotalGeral = listSinistroAnalitico.Distinct().Count(), + TotalClientes = listSinistroAnalitico.Select((Sinistro x) => x.EntidadeSinistro.TipoSinistro == (TipoSinistro?)0).Distinct().Count(), + TotalTerceiros = listSinistroAnalitico.Select((Sinistro x) => (int)x.EntidadeSinistro.TipoSinistro.GetValueOrDefault() == 1).Distinct().Count() + }, Relatorio); + string text = text30; + text30 = text + await Funcoes.GenerateTableSintetic(sintetic29, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo14, text30, pageBreak); + } + break; + } + case 2: + { + List agrupamento30 = (from x in listSinistroAnalitico + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo15 in agrupamento30) + { + List list57 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Vendedor == grupo15).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Vendedor == grupo15).ToList()); + if (list57.Count == 0) + { + continue; + } + if ((int)Relatorio != 9) + { + list57.Add(new Sinistro + { + Nome = "TOTAL", + Valor = list57.Sum((Sinistro x) => x.Valor), + ValorOrcado = list57.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = list57.Sum((Sinistro x) => x.ValorLiberado), + ValorPago = list57.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = list57.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = list57.Sum((Sinistro x) => x.ValorFranquia) + }); + } + string text29 = await Funcoes.GenerateTable(list57, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source2 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Vendedor == grupo15).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Vendedor == grupo15).ToList()); + List sintetic28 = Funcoes.ConstruirSintetico(new Sintetico + { + Liquidado = (from x in source2 + where x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + Valor = source2.Sum((Sinistro x) => x.Valor), + ValorOrcado = source2.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = source2.Sum((Sinistro x) => x.ValorLiberado), + ValorLiquidado = source2.Where((Sinistro x) => x.Liquidacao.HasValue).Sum((Sinistro x) => x.ValorPago), + ValorPago = source2.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = source2.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = source2.Sum((Sinistro x) => x.ValorFranquia), + Pendente = (from x in source2 + where !x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + TotalGeral = listSinistroAnalitico.Distinct().Count(), + TotalClientes = listSinistroAnalitico.Select((Sinistro x) => x.EntidadeSinistro.TipoSinistro == (TipoSinistro?)0).Distinct().Count(), + TotalTerceiros = listSinistroAnalitico.Select((Sinistro x) => (int)x.EntidadeSinistro.TipoSinistro.GetValueOrDefault() == 1).Distinct().Count() + }, Relatorio); + string text = text29; + text29 = text + await Funcoes.GenerateTableSintetic(sintetic28, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo15, text29, pageBreak); + } + break; + } + case 3: + { + List agrupamento30 = (from x in listSinistroAnalitico + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo12 in agrupamento30) + { + List list60 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Estipulante == grupo12).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Estipulante == grupo12).ToList()); + if (list60.Count == 0) + { + continue; + } + if ((int)Relatorio != 9) + { + list60.Add(new Sinistro + { + Nome = "TOTAL", + Valor = list60.Sum((Sinistro x) => x.Valor), + ValorOrcado = list60.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = list60.Sum((Sinistro x) => x.ValorLiberado), + ValorPago = list60.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = list60.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = list60.Sum((Sinistro x) => x.ValorFranquia) + }); + } + string text32 = await Funcoes.GenerateTable(list60, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source5 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && x.Estipulante == grupo12).ToList() : listSinistroAnalitico.Where((Sinistro x) => x.Estipulante == grupo12).ToList()); + List sintetic31 = Funcoes.ConstruirSintetico(new Sintetico + { + Liquidado = (from x in source5 + where x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + Valor = source5.Sum((Sinistro x) => x.Valor), + ValorOrcado = source5.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = source5.Sum((Sinistro x) => x.ValorLiberado), + ValorLiquidado = source5.Where((Sinistro x) => x.Liquidacao.HasValue).Sum((Sinistro x) => x.ValorPago), + ValorPago = source5.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = source5.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = source5.Sum((Sinistro x) => x.ValorFranquia), + Pendente = (from x in source5 + where !x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + TotalGeral = listSinistroAnalitico.Distinct().Count(), + TotalClientes = listSinistroAnalitico.Select((Sinistro x) => x.EntidadeSinistro.TipoSinistro == (TipoSinistro?)0).Distinct().Count(), + TotalTerceiros = listSinistroAnalitico.Select((Sinistro x) => (int)x.EntidadeSinistro.TipoSinistro.GetValueOrDefault() == 1).Distinct().Count() + }, Relatorio); + string text = text32; + text32 = text + await Funcoes.GenerateTableSintetic(sintetic31, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo12, text32, pageBreak); + } + break; + } + case 4: + { + List agrupamento30 = (from x in listSinistroAnalitico + orderby x.StatusSinistro + select EnumHelper.GetDescription(x.StatusSinistro)).Distinct().ToList(); + foreach (string grupo16 in agrupamento30) + { + List list56 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && EnumHelper.GetDescription(x.StatusSinistro) == grupo16).ToList() : listSinistroAnalitico.Where((Sinistro x) => EnumHelper.GetDescription(x.StatusSinistro) == grupo16).ToList()); + if (list56.Count == 0) + { + continue; + } + if ((int)Relatorio != 9) + { + list56.Add(new Sinistro + { + Nome = "TOTAL", + Valor = list56.Sum((Sinistro x) => x.Valor), + ValorOrcado = list56.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = list56.Sum((Sinistro x) => x.ValorLiberado), + ValorPago = list56.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = list56.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = list56.Sum((Sinistro x) => x.ValorFranquia) + }); + } + string text28 = await Funcoes.GenerateTable(list56, Relatorio, grafico: false, verificarColunas: true, footer, config); + List source = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado && EnumHelper.GetDescription(x.StatusSinistro) == grupo16).ToList() : listSinistroAnalitico.Where((Sinistro x) => EnumHelper.GetDescription(x.StatusSinistro) == grupo16).ToList()); + List sintetic27 = Funcoes.ConstruirSintetico(new Sintetico + { + Liquidado = (from x in source + where x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + Valor = source.Sum((Sinistro x) => x.Valor), + ValorOrcado = source.Sum((Sinistro x) => x.ValorOrcado), + ValorLiberado = source.Sum((Sinistro x) => x.ValorLiberado), + ValorLiquidado = source.Where((Sinistro x) => x.Liquidacao.HasValue).Sum((Sinistro x) => x.ValorPago), + ValorPago = source.Sum((Sinistro x) => x.ValorPago), + ValorSalvado = source.Sum((Sinistro x) => x.ValorSalvado), + ValorFranquia = source.Sum((Sinistro x) => x.ValorFranquia), + Pendente = (from x in source + where !x.Liquidacao.HasValue + select ((DomainBase)x.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + TotalGeral = listSinistroAnalitico.Distinct().Count(), + TotalClientes = listSinistroAnalitico.Select((Sinistro x) => x.EntidadeSinistro.TipoSinistro == (TipoSinistro?)0).Distinct().Count(), + TotalTerceiros = listSinistroAnalitico.Select((Sinistro x) => (int)x.EntidadeSinistro.TipoSinistro.GetValueOrDefault() == 1).Distinct().Count() + }, Relatorio); + string text = text28; + text28 = text + await Funcoes.GenerateTableSintetic(sintetic27, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo16, text28, pageBreak); + } + break; + } + } + break; + } + case 8: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listAuditoria = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in listAuditoria + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo39 in agrupamento30) + { + List list9 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Seguradora == grupo39).ToList() : listAuditoria.Where((Auditoria x) => x.Seguradora == grupo39).ToList()); + if (list9.Count != 0) + { + list9.Add(new Auditoria + { + Cliente = "TOTAL", + Comissao = (list9.Any() ? (list9.Sum((Auditoria x) => x.Comissao) / (decimal)list9.Count) : 0m), + PremioTotal = list9.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list9.Sum((Auditoria x) => x.PremioLiquido), + ComissaoPrevista = list9.Sum((Auditoria x) => x.ComissaoPrevista), + ComissaoRecebida = list9.Sum((Auditoria x) => x.ComissaoRecebida) + }); + string text5 = await Funcoes.GenerateTable(list9, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list10 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Seguradora == grupo39).ToList() : listAuditoria.Where((Auditoria x) => x.Seguradora == grupo39).ToList()); + List sintetic4 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo39, + PremioTotal = list10.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list10.Sum((Auditoria p) => p.PremioLiquido), + ComissaoRecebidaBruta = list10.Sum((Auditoria p) => p.ComissaoRecebida), + MediaComissao = (list10.Any((Auditoria c) => c.Comissao > 0m) ? decimal.Round(list10.Sum((Auditoria c) => c.Comissao) / (decimal)list10.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m), + ComissaoPrevista = list10.Sum((Auditoria c) => c.ComissaoPrevista), + ComissaoGerada = list10.Sum((Auditoria c) => c.ComissaoPrevista), + Cancelamentos = list10.Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = list10.Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list10.Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list10.Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list10.Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list10.Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list10.Count + }, Relatorio); + string text = text5; + text5 = text + await Funcoes.GenerateTableSintetic(sintetic4, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo39, text5, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in listAuditoria + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo40 in agrupamento30) + { + List list7 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Ramo == grupo40).ToList() : listAuditoria.Where((Auditoria x) => x.Ramo == grupo40).ToList()); + if (list7.Count != 0) + { + list7.Add(new Auditoria + { + Cliente = "TOTAL", + Comissao = (list7.Any() ? (list7.Sum((Auditoria x) => x.Comissao) / (decimal)list7.Count) : 0m), + PremioTotal = list7.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list7.Sum((Auditoria x) => x.PremioLiquido), + ComissaoPrevista = list7.Sum((Auditoria x) => x.ComissaoPrevista), + ComissaoRecebida = list7.Sum((Auditoria x) => x.ComissaoRecebida) + }); + string text4 = await Funcoes.GenerateTable(list7, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list8 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Ramo == grupo40).ToList() : listAuditoria.Where((Auditoria x) => x.Ramo == grupo40).ToList()); + List sintetic3 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo40, + PremioTotal = list8.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list8.Sum((Auditoria p) => p.PremioLiquido), + ComissaoRecebidaBruta = list8.Sum((Auditoria p) => p.ComissaoRecebida), + MediaComissao = (list8.Any((Auditoria c) => c.Comissao > 0m) ? decimal.Round(list8.Sum((Auditoria c) => c.Comissao) / (decimal)list8.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m), + ComissaoPrevista = list8.Sum((Auditoria c) => c.ComissaoPrevista), + ComissaoGerada = list8.Sum((Auditoria c) => c.ComissaoPrevista), + Cancelamentos = list8.Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = list8.Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list8.Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list8.Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list8.Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list8.Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list8.Count + }, Relatorio); + string text = text4; + text4 = text + await Funcoes.GenerateTableSintetic(sintetic3, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo40, text4, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in listAuditoria + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo41 in agrupamento30) + { + List list5 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Vendedor == grupo41).ToList() : listAuditoria.Where((Auditoria x) => x.Vendedor == grupo41).ToList()); + if (list5.Count != 0) + { + list5.Add(new Auditoria + { + Cliente = "TOTAL", + Comissao = (list5.Any() ? (list5.Sum((Auditoria x) => x.Comissao) / (decimal)list5.Count) : 0m), + PremioTotal = list5.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list5.Sum((Auditoria x) => x.PremioLiquido), + ComissaoPrevista = list5.Sum((Auditoria x) => x.ComissaoPrevista), + ComissaoRecebida = list5.Sum((Auditoria x) => x.ComissaoRecebida) + }); + string text3 = await Funcoes.GenerateTable(list5, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list6 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Vendedor == grupo41).ToList() : listAuditoria.Where((Auditoria x) => x.Vendedor == grupo41).ToList()); + List sintetic2 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo41, + PremioTotal = list6.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list6.Sum((Auditoria p) => p.PremioLiquido), + ComissaoRecebidaBruta = list6.Sum((Auditoria p) => p.ComissaoRecebida), + ComissaoPrevista = list6.Sum((Auditoria c) => c.ComissaoPrevista), + MediaComissao = (list6.Any((Auditoria c) => c.Comissao > 0m) ? decimal.Round(list6.Sum((Auditoria c) => c.Comissao) / (decimal)list6.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m), + ComissaoGerada = list6.Sum((Auditoria c) => c.ComissaoPrevista), + Cancelamentos = list6.Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = list6.Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list6.Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list6.Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list6.Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list6.Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list6.Count + }, Relatorio); + string text = text3; + text3 = text + await Funcoes.GenerateTableSintetic(sintetic2, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo41, text3, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in listAuditoria + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo38 in agrupamento30) + { + List list11 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Estipulante == grupo38).ToList() : listAuditoria.Where((Auditoria x) => x.Estipulante == grupo38).ToList()); + if (list11.Count != 0) + { + list11.Add(new Auditoria + { + Cliente = "TOTAL", + Comissao = (list11.Any() ? (list11.Sum((Auditoria x) => x.Comissao) / (decimal)list11.Count) : 0m), + PremioTotal = list11.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list11.Sum((Auditoria x) => x.PremioLiquido), + ComissaoPrevista = list11.Sum((Auditoria x) => x.ComissaoPrevista), + ComissaoRecebida = list11.Sum((Auditoria x) => x.ComissaoRecebida) + }); + string text6 = await Funcoes.GenerateTable(list11, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list12 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Estipulante == grupo38).ToList() : listAuditoria.Where((Auditoria x) => x.Estipulante == grupo38).ToList()); + List sintetic5 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo38, + PremioTotal = list12.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list12.Sum((Auditoria p) => p.PremioLiquido), + ComissaoRecebidaBruta = list12.Sum((Auditoria p) => p.ComissaoRecebida), + MediaComissao = (list12.Any((Auditoria c) => c.Comissao > 0m) ? decimal.Round(list12.Sum((Auditoria c) => c.Comissao) / (decimal)list12.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m), + ComissaoPrevista = list12.Sum((Auditoria c) => c.ComissaoPrevista), + Cancelamentos = list12.Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = list12.Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list12.Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list12.Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list12.Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list12.Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list12.Count + }, Relatorio); + string text = text6; + text6 = text + await Funcoes.GenerateTableSintetic(sintetic5, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo38, text6, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in listAuditoria + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo42 in agrupamento30) + { + List list3 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Status == grupo42).ToList() : listAuditoria.Where((Auditoria x) => x.Status == grupo42).ToList()); + if (list3.Count != 0) + { + list3.Add(new Auditoria + { + Cliente = "TOTAL", + Comissao = (list3.Any() ? (list3.Sum((Auditoria x) => x.Comissao) / (decimal)list3.Count) : 0m), + PremioTotal = list3.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list3.Sum((Auditoria x) => x.PremioLiquido), + ComissaoPrevista = list3.Sum((Auditoria x) => x.ComissaoPrevista), + ComissaoRecebida = list3.Sum((Auditoria x) => x.ComissaoRecebida) + }); + string text2 = await Funcoes.GenerateTable(list3, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list4 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado && x.Status == grupo42).ToList() : listAuditoria.Where((Auditoria x) => x.Status == grupo42).ToList()); + List sintetic = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo42, + PremioTotal = list4.Sum((Auditoria x) => x.PremioTotal), + PremioLiquido = list4.Sum((Auditoria p) => p.PremioLiquido), + ComissaoRecebidaBruta = list4.Sum((Auditoria p) => p.ComissaoRecebida), + MediaComissao = (list4.Any((Auditoria c) => c.Comissao > 0m) ? decimal.Round(list4.Sum((Auditoria c) => c.Comissao) / (decimal)list4.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m), + ComissaoPrevista = list4.Sum((Auditoria c) => c.ComissaoPrevista), + Cancelamentos = list4.Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = list4.Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = list4.Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = list4.Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = list4.Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = list4.Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = list4.Count + }, Relatorio); + string text = text2; + text2 = text + await Funcoes.GenerateTableSintetic(sintetic, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo42, text2, pageBreak); + } + } + break; + } + } + break; + } + case 7: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + if (SinteticosPagamento) + { + foreach (PagamentoSintetico sintetico2 in PagamentosSintetico) + { + string body = await Funcoes.GenerateTable(new List(sintetico2.Agrupamento), new List(), grafico: false, propertyName: false, "", config); + relatorio += Funcoes.CreateCard(sintetico2.Titulo, body); + } + relatorio += "
"; + } + int count = -1; + foreach (Pagamento x3 in Pagamentos.OrderBy((Pagamento x) => x.Title)) + { + count++; + string body2 = await Funcoes.GenerateTable(x3.Dados.ToList(), Relatorio, grafico: false, verificarColunas: true, footer, config); + relatorio += Funcoes.CreateCard(ReciboPagamento ? x3.Title : (SegundaViaReciboPagamento ? (x3.Title + " - SEGUNDA VIA") : (x3.Title + " - SIMPLES CONFERÊNCIA")), body2); + DadosRelatorio? obj = ((IEnumerable)x3.Dados).FirstOrDefault((Func)((DadosRelatorio y) => y.EntidadeVendedorParcela != null)); + object obj2; + if (obj == null) + { + obj2 = null; + } + else + { + VendedorParcela entidadeVendedorParcela = obj.EntidadeVendedorParcela; + obj2 = ((entidadeVendedorParcela != null) ? entidadeVendedorParcela.Vendedor : null); + } + if (obj2 == null) + { + DadosRelatorio? obj3 = ((IEnumerable)x3.Dados).FirstOrDefault((Func)((DadosRelatorio y) => y.EntidadeAdiantamento != null)); + obj2 = ((obj3 != null) ? obj3.EntidadeAdiantamento.Vendedor : null); + } + Vendedor vendedor = (Vendedor)obj2; + if (ReciboPagamento || SegundaViaReciboPagamento) + { + relatorio += Funcoes.CriarRecibo(vendedor, x3.Dados.Last().ValorLiquido, new Filtros + { + Inicio = Inicio, + Fim = Fim + }, SegundaViaReciboPagamento); + } + if (count < Pagamentos.Count - 1) + { + relatorio += "
"; + } + } + if (!SinteticosPagamento) + { + break; + } + List list14 = new List(); + foreach (Pagamento item in Pagamentos.OrderBy((Pagamento x) => x.Title)) + { + list14.Add(item.Vendedores); + } + list14.Add(new AgrupamentoVendedor + { + Vendedor = "TOTAL", + Repasse = list14.Sum((AgrupamentoVendedor p) => p.Repasse), + RepasseBruto = list14.Sum((AgrupamentoVendedor p) => p.RepasseBruto), + Estorno = list14.Sum((AgrupamentoVendedor p) => p.Estorno), + Debito = list14.Sum((AgrupamentoVendedor p) => p.Debito), + Credito = list14.Sum((AgrupamentoVendedor p) => p.Credito), + Desconto = list14.Sum((AgrupamentoVendedor p) => p.Desconto), + Adiantamento = list14.Sum((AgrupamentoVendedor p) => p.Adiantamento), + ValorLiquido = list14.Sum((AgrupamentoVendedor p) => p.ValorLiquido) + }); + relatorio = relatorio + "
" + Funcoes.CreateCard("", await Funcoes.GenerateTable(list14, new List(), grafico: false, propertyName: false, "", config)); + break; + } + case 12: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + if ((int)Agrupamento == 0) + { + relatorio = await Funcoes.GenerateTable(((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(), Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + } + IEnumerable> enumerable = from FaturaPendente x in (IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items + orderby ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora; + foreach (IGrouping x2 in enumerable) + { + string body3 = await Funcoes.GenerateTable(x2.ToList(), Relatorio, grafico: false, verificarColunas: true, footer, config); + string title = (((int)Agrupamento == 1) ? x2.First().Seguradora : (((int)Agrupamento == 2) ? x2.First().Ramo : (((int)Agrupamento == 3) ? x2.First().Vendedor : (((int)Agrupamento == 4) ? x2.First().Estipulante : x2.First().Status)))); + relatorio += Funcoes.CreateCard(title, body3); + } + break; + } + case 11: + { + if (Fechamento == null) + { + return ""; + } + ColunasOcultas = new List + { + "PRÊMIO TOTAL ANTERIOR", "COMPARATIVO PRÊMIO TOTAL", "PRÊMIO LÍQUIDO ANTERIOR", "COMPARATIVO PRÊMIO LÍQUIDO", "MÉDIA FECHADA ANTERIOR", "COMPARATIVO MÉDIA FECHADA", "MÉDIA MIX % ANTERIOR", "COMPARATIVO MÉDIA MIX %", "COMISSÃO GERADA ANTERIOR", "COMPARATIVO COMISSÃO GERADA", + "COMISSÃO RECEBIDA ANTERIOR", "COMPARATIVO COMISSÃO RECEBIDA", "COMISSÃO PAGA ANTERIOR", "COMPARATIVO COMISSÃO PAGA", "QTD APÓLICE ANTERIOR", "COMPARATIVO QTD APÓLICE", "QTD ENDOSSO ANTERIOR", "COMPARATIVO QTD ENDOSSO", "QTD FATURA ANTERIOR", "COMPARATIVO QTD FATURA", + "QTD ITENS ANTERIOR", "COMPARATIVO QTD ITENS", "ANO ANTERIOR" + }; + ComparativoConverter comparer = new ComparativoConverter(); + NumberFormatInfo percentageFormat = new NumberFormatInfo + { + PercentPositivePattern = 1, + PercentNegativePattern = 1 + }; + foreach (Fechamentos fechamento in Fechamento) + { + ExtensionMethods.ForEach((IEnumerable)fechamento.Fechamento, (Action)delegate(Fechamento x) + { + object[] array = new object[2] { x.PremioTotal, x.PremioTotalAnterior }; + x.PremioTotalComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.PremioLiquido; + array[1] = x.PremioLiquidoAnterior; + x.PremioLiquidoComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Fechada; + array[1] = x.FechadaAnterior; + x.FechadaAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Mix; + array[1] = x.MixAnterior; + x.MixAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Gerada; + array[1] = x.GeradaAnterior; + x.GeradaAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Recebida; + array[1] = x.RecebidaAnterior; + x.RecebidaAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Pendente; + array[1] = x.PendenteAnterior; + x.PendenteAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Paga; + array[1] = x.PagaAnterior; + x.PagaAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Apolice; + array[1] = x.ApoliceAnterior; + x.ApoliceAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Endosso; + array[1] = x.EndossoAnterior; + x.EndossoAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Fatura; + array[1] = x.FaturaAnterior; + x.FaturaAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + array[0] = x.Itens; + array[1] = x.ItensAnterior; + x.ItensAnteriorComparativo = decimal.Parse(comparer.Convert(array, typeof(decimal), new object(), new CultureInfo("pt-BR")).ToString()).ToString("P2", percentageFormat); + }); + ColunasOcultas = new List(); + string body6 = await Funcoes.GenerateTable(new List(fechamento.Fechamento), Relatorio, grafico: false, verificarColunas: true, footer, config); + relatorio += Funcoes.CreateCard(fechamento.Title, body6); + } + break; + } + case 14: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list26 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + relatorio = await Funcoes.GenerateTable(list26.Any((MetaSeguradoraRelatorio x) => x.Selecionado) ? list26.Where((MetaSeguradoraRelatorio x) => x.Selecionado).ToList() : list26, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + } + case 15: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list74 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + relatorio = await Funcoes.GenerateTable(list74.Any((MetaVendedorRelatorio x) => x.Selecionado) ? list74.Where((MetaVendedorRelatorio x) => x.Selecionado).ToList() : list74, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + } + case 19: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List listNotaFiscalRelatorio = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (NotaFiscalPorSeguradora) + { + List agrupamento30 = (from x in listNotaFiscalRelatorio + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo37 in agrupamento30) + { + List prod = (listNotaFiscalRelatorio.Any((NotaFiscalRelatorio x) => x.Selecionado) ? listNotaFiscalRelatorio.Where((NotaFiscalRelatorio x) => x.Selecionado && x.Seguradora == grupo37).ToList() : listNotaFiscalRelatorio.Where((NotaFiscalRelatorio x) => x.Seguradora == grupo37).ToList()); + if (prod.Count != 0) + { + prod.Add(new NotaFiscalRelatorio + { + Seguradora = "TOTAL", + Bruto = prod.Sum((NotaFiscalRelatorio x) => x.Bruto), + Liquido = prod.Sum((NotaFiscalRelatorio x) => x.Liquido), + Iss = prod.Sum((NotaFiscalRelatorio x) => x.Iss) + }); + string text7 = await Funcoes.GenerateTable(prod, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list13 = (listNotaFiscalRelatorio.Any((NotaFiscalRelatorio x) => x.Selecionado) ? listNotaFiscalRelatorio.Where((NotaFiscalRelatorio x) => x.Selecionado && x.Seguradora == grupo37).ToList() : listNotaFiscalRelatorio.Where((NotaFiscalRelatorio x) => x.Seguradora == grupo37).ToList()); + Sintetico val = new Sintetico + { + Agrupamento = grupo37, + ValorBruto = list13.Sum((NotaFiscalRelatorio g) => g.Bruto), + ValorLiquido = list13.Sum((NotaFiscalRelatorio g) => g.Liquido), + Iss = list13.Sum((NotaFiscalRelatorio g) => g.Iss), + TotalGeral = list13.Count + }; + string Aux = ""; + prod.Where((NotaFiscalRelatorio x) => x.Seguradora == grupo37).ToList().ForEach(delegate(NotaFiscalRelatorio x) + { + Aux = x.Cnpj; + }); + if (!string.IsNullOrEmpty(Aux)) + { + Aux = grupo37.ToString() + " - " + Aux; + } + else if (!string.IsNullOrEmpty(grupo37)) + { + Aux = grupo37; + } + List sintetic6 = Funcoes.ConstruirSintetico(val, Relatorio); + string text = text7; + text7 = text + await Funcoes.GenerateTableSintetic(sintetic6, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(Aux, text7, pageBreak); + } + } + } + else + { + relatorio = await Funcoes.GenerateTable(listNotaFiscalRelatorio.Any((NotaFiscalRelatorio x) => x.Selecionado) ? listNotaFiscalRelatorio.Where((NotaFiscalRelatorio x) => x.Selecionado).ToList() : listNotaFiscalRelatorio, Relatorio, grafico: false, verificarColunas: true, footer, config); + } + break; + } + case 20: + if (Previsao == null) + { + return ""; + } + foreach (PrevisaoPagamentoComissaoSintetico sintetico in PrevisaoSintetico) + { + string body4 = await Funcoes.GenerateTable(new List(sintetico.Agrupamento), new List()); + relatorio += Funcoes.CreateCard(sintetico.Titulo, body4); + } + foreach (PrevisaoPagamentoComissao previsao in Previsao) + { + string body5 = await Funcoes.GenerateTable(new List(previsao.PrevisaoPagamento), Relatorio, grafico: false, verificarColunas: true, footer, config); + relatorio += Funcoes.CreateCard(previsao.Vendedor, body5); + } + break; + case 23: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list61 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico6 = (list61.Any((LogsEnvio x) => x.Selecionado) ? list61.Where((LogsEnvio x) => x.Selecionado).ToList() : list61); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico6, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + case 24: + case 25: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list2 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico2 = (list2.Any((LogAcaoRelatorio x) => x.Selecionado) ? list2.Where((LogAcaoRelatorio x) => x.Selecionado).ToList() : list2); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico2, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + case 26: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list62 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico7 = (list62.Any((ApoliceCritica x) => x.Selecionado) ? list62.Where((ApoliceCritica x) => x.Selecionado).ToList() : list62); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico7, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + case 13: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list37 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico3 = (list37.Any((ExtratoBaixadoRelatorio x) => x.Selecionado) ? list37.Where((ExtratoBaixadoRelatorio x) => x.Selecionado).ToList() : list37); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico3, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + case 28: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List endossoBaixado = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + Agrupamento agrupamento42 = Agrupamento; + switch (agrupamento42 - 1) + { + default: + relatorio = await Funcoes.GenerateTable(endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado).ToList() : endossoBaixado, Relatorio, grafico: false, verificarColunas: true, footer, config); + break; + case 0: + { + List agrupamento30 = (from x in endossoBaixado + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + foreach (string grupo28 in agrupamento30) + { + List list33 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Seguradora == grupo28).ToList() : endossoBaixado.Where((Endosso x) => x.Seguradora == grupo28).ToList()); + if (list33.Count != 0) + { + list33.Add(new Endosso + { + Cliente = "TOTAL", + Comissao = (list33.Any() ? (list33.Sum((Endosso x) => x.Comissao) / (decimal)list33.Count) : 0m), + PremioTotal = list33.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list33.Sum((Endosso x) => x.PremioLiquido) + }); + string text16 = await Funcoes.GenerateTable(list33, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list34 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Seguradora == grupo28).ToList() : endossoBaixado.Where((Endosso x) => x.Seguradora == grupo28).ToList()); + List sintetic15 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo28, + PremioTotal = list34.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list34.Sum((Endosso p) => p.PremioLiquido), + Cancelamentos = list34.Count((Endosso c) => (int)c.Documento.Situacao == 3), + Endossos = list34.Count((Endosso c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1 && (int)c.Documento.Situacao != 3), + TotalGeral = list34.Count + }, Relatorio); + string text = text16; + text16 = text + await Funcoes.GenerateTableSintetic(sintetic15, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo28, text16, pageBreak); + } + } + break; + } + case 1: + { + List agrupamento30 = (from x in endossoBaixado + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + foreach (string grupo29 in agrupamento30) + { + List list31 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Ramo == grupo29).ToList() : endossoBaixado.Where((Endosso x) => x.Ramo == grupo29).ToList()); + if (list31.Count != 0) + { + list31.Add(new Endosso + { + Cliente = "TOTAL", + Comissao = (list31.Any() ? (list31.Sum((Endosso x) => x.Comissao) / (decimal)list31.Count) : 0m), + PremioTotal = list31.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list31.Sum((Endosso x) => x.PremioLiquido) + }); + string text15 = await Funcoes.GenerateTable(list31, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list32 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Ramo == grupo29).ToList() : endossoBaixado.Where((Endosso x) => x.Ramo == grupo29).ToList()); + List sintetic14 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo29, + PremioTotal = list32.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list32.Sum((Endosso p) => p.PremioLiquido), + Cancelamentos = list32.Count((Endosso c) => (int)c.Documento.Situacao == 3), + Endossos = list32.Count((Endosso c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1 && (int)c.Documento.Situacao != 3), + TotalGeral = list32.Count + }, Relatorio); + string text = text15; + text15 = text + await Funcoes.GenerateTableSintetic(sintetic14, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo29, text15, pageBreak); + } + } + break; + } + case 2: + { + List agrupamento30 = (from x in endossoBaixado + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + foreach (string grupo30 in agrupamento30) + { + List list29 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Vendedor == grupo30).ToList() : endossoBaixado.Where((Endosso x) => x.Vendedor == grupo30).ToList()); + if (list29.Count != 0) + { + list29.Add(new Endosso + { + Cliente = "TOTAL", + Comissao = (list29.Any() ? (list29.Sum((Endosso x) => x.Comissao) / (decimal)list29.Count) : 0m), + PremioTotal = list29.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list29.Sum((Endosso x) => x.PremioLiquido) + }); + string text14 = await Funcoes.GenerateTable(list29, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list30 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Vendedor == grupo30).ToList() : endossoBaixado.Where((Endosso x) => x.Vendedor == grupo30).ToList()); + List sintetic13 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo30, + PremioTotal = list30.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list30.Sum((Endosso p) => p.PremioLiquido), + Cancelamentos = list30.Count((Endosso c) => (int)c.Documento.Situacao == 3), + Endossos = list30.Count((Endosso c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1 && (int)c.Documento.Situacao != 3), + TotalGeral = list30.Count + }, Relatorio); + string text = text14; + text14 = text + await Funcoes.GenerateTableSintetic(sintetic13, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo30, text14, pageBreak); + } + } + break; + } + case 3: + { + List agrupamento30 = (from x in endossoBaixado + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + foreach (string grupo27 in agrupamento30) + { + List list35 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Estipulante == grupo27).ToList() : endossoBaixado.Where((Endosso x) => x.Estipulante == grupo27).ToList()); + if (list35.Count != 0) + { + list35.Add(new Endosso + { + Cliente = "TOTAL", + Comissao = (list35.Any() ? (list35.Sum((Endosso x) => x.Comissao) / (decimal)list35.Count) : 0m), + PremioTotal = list35.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list35.Sum((Endosso x) => x.PremioLiquido) + }); + string text17 = await Funcoes.GenerateTable(list35, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list36 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Estipulante == grupo27).ToList() : endossoBaixado.Where((Endosso x) => x.Estipulante == grupo27).ToList()); + List sintetic16 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo27, + PremioTotal = list36.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list36.Sum((Endosso p) => p.PremioLiquido), + Cancelamentos = list36.Count((Endosso c) => (int)c.Documento.Situacao == 3), + Endossos = list36.Count((Endosso c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1 && (int)c.Documento.Situacao != 3), + TotalGeral = list36.Count + }, Relatorio); + string text = text17; + text17 = text + await Funcoes.GenerateTableSintetic(sintetic16, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo27, text17, pageBreak); + } + } + break; + } + case 4: + { + List agrupamento30 = (from x in endossoBaixado + orderby x.Status + select x.Status).Distinct().ToList(); + foreach (string grupo31 in agrupamento30) + { + List list27 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Status == grupo31).ToList() : endossoBaixado.Where((Endosso x) => x.Status == grupo31).ToList()); + if (list27.Count != 0) + { + list27.Add(new Endosso + { + Cliente = "TOTAL", + Comissao = (list27.Any() ? (list27.Sum((Endosso x) => x.Comissao) / (decimal)list27.Count) : 0m), + PremioTotal = list27.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list27.Sum((Endosso x) => x.PremioLiquido) + }); + string text13 = await Funcoes.GenerateTable(list27, Relatorio, grafico: false, verificarColunas: true, footer, config); + List list28 = (endossoBaixado.Any((Endosso x) => x.Selecionado) ? endossoBaixado.Where((Endosso x) => x.Selecionado && x.Status == grupo31).ToList() : endossoBaixado.Where((Endosso x) => x.Status == grupo31).ToList()); + List sintetic12 = Funcoes.ConstruirSintetico(new Sintetico + { + Agrupamento = grupo31, + PremioTotal = list28.Sum((Endosso x) => x.PremioTotal), + PremioLiquido = list28.Sum((Endosso p) => p.PremioLiquido), + Cancelamentos = list28.Count((Endosso c) => (int)c.Documento.Situacao == 3), + Endossos = list28.Count((Endosso c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1 && (int)c.Documento.Situacao != 3), + TotalGeral = list28.Count + }, Relatorio); + string text = text13; + text13 = text + await Funcoes.GenerateTableSintetic(sintetic12, config.TamanhoFonte); + relatorio += Funcoes.CreateCard(grupo31, text13, pageBreak); + } + } + break; + } + } + break; + } + case 29: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List list = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + List analitico = (list.Any((Classificacao x) => x.Selecionado) ? list.Where((Classificacao x) => x.Selecionado).ToList() : list); + string text = relatorio; + relatorio = text + Funcoes.CreateCard("", await Funcoes.GenerateTable(analitico, Relatorio, grafico: false, verificarColunas: true, footer, config)); + break; + } + } + string filtros = ""; + int porcentagemImpressao = (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 14) ? 70 : 50); + if (FiltroRelatorioSelecionado != null && FiltroRelatorioSelecionado.Count > 0) + { + filtros = Funcoes.CreateCard("FILTROS ADICIONADOS AO RELATÓRIO", await Funcoes.GenerateTable(FiltroRelatorioSelecionado.ToList(), new List())); + } + TipoRelatorio tipo = new TipoRelatorio + { + Nome = EnumHelper.GetDescription(Relatorio), + Inicio = Inicio, + Fim = Fim + }; + string text43 = ""; + if (Totalizacao) + { + string text44 = ((Sintetic != null) ? Funcoes.CreateCard("TOTAL", await Funcoes.GenerateTableSintetic(Sintetic.ToList(), config.TamanhoFonte)) : ""); + text43 = text44; + } + bool? obj4; + if (config != null && config.OrientacaoImpressao.HasValue) + { + obj4 = ((config != null) ? config.OrientacaoImpressao : null); + } + else + { + obj4 = false; + } + bool? flag = obj4; + portrait = flag.Value; + return Funcoes.ExportarHtml(tipo, relatorio + text43 + filtros, porcentagemImpressao.ToString(), portrait ? "portrait" : "landscape", screen); + } + + private static Sintetico SintetizarRenovacao(string grupo, List sintetico) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_003c: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00cc: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: Unknown result type (might be due to invalid IL or missing references) + //IL_012c: Unknown result type (might be due to invalid IL or missing references) + //IL_015c: Unknown result type (might be due to invalid IL or missing references) + //IL_016e: Expected O, but got Unknown + return new Sintetico + { + Agrupamento = grupo, + Cancelamentos = sintetico.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.Situacao == 3), + Novos = sintetico.Count((Renovacao c) => (c.Tipo != 3 && (int)c.Documento.Situacao == 1) || (c.Tipo != 3 && (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = sintetico.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = sintetico.Count((Renovacao c) => c.Tipo != 3 && c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = sintetico.Count((Renovacao c) => c.Tipo != 3 && c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = sintetico.Count((Renovacao c) => c.Tipo != 3 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalProspeccao = sintetico.Count((Renovacao c) => c.Tipo == 3), + TotalGeral = sintetico.Count + }; + } + + public async Task Sintetico() + { + List list = null; + if ((GridRelatorio)Report == null && (int)Relatorio != 7 && (int)Relatorio != 11) + { + await ShowMessage("NECESSARIO GERAR UM RELATÓRIO COM DADOS PARA SINTETIZAR"); + return; + } + Relatorio relatorio = Relatorio; + switch (relatorio - 2) + { + case 0: + { + List list7 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ProducaoFiltrado == null || list7.Count == 0) + { + return; + } + if ((int)Agrupamento == 3) + { + list7 = list7.Where((Producao producao) => producao.Vendedor != null).ToList(); + } + list = (from x in list7 + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + PremioTotal = x.Sum((Producao c) => c.PremioTotal), + PremioLiquido = x.Sum((Producao p) => p.PremioLiquido), + MediaComissao = ((x.Sum((Producao c) => c.Comissao) > 0m) ? (decimal.Round(x.Sum((Producao c) => c.Comissao) / (decimal)x.Count((Producao c) => c.Comissao > 0m), 2) * 100m) : 0m), + ComissaoGerada = x.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosNovos), + NegociosProprios = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoNegociosProprios), + SegurosNovos = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosNovos), + Renovacoes = Funcoes.DistinctBy(x, funcProducaoDistinctByDocumentoId).Count(funcProducaoSegurosRenovacao), + Apolices = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(x, (Producao c) => ((DomainBase)c.Documento).Id).Count((Producao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalLiquido = x.Count((Producao c) => (int)c.Documento.Situacao != 3), + TotalGeral = x.Count(), + MediaPonderada = ((x.Sum((Producao p) => p.PremioLiquido) > 0m) ? (decimal.Round(x.Sum((Producao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao) / x.Sum((Producao p) => p.PremioLiquido), 2) * 100m) : 0m) + })).ToList(); + break; + } + case 9: + { + if (FechamentoFiltrado == null || FechamentoFiltrado.Count == 0) + { + return; + } + list = new List(); + Fechamento val = FechamentoFiltrado.First().Fechamento.Last(); + list.Add(new Sintetico + { + Agrupamento = "ATUAL: " + Inicio.Year, + TotalGeral = val.Apolice, + ValorPago = val.Paga, + ComissaoRecebidaBruta = val.Recebida, + ComissaoGerada = val.Gerada, + PremioLiquido = val.PremioLiquido, + PremioTotal = val.PremioTotal + }); + list.Add(new Sintetico + { + Agrupamento = "ANTERIOR: " + (Inicio.Year - 1), + TotalGeral = val.ApoliceAnterior, + ValorPago = val.PagaAnterior, + ComissaoRecebidaBruta = val.RecebidaAnterior, + ComissaoGerada = val.GeradaAnterior, + PremioLiquido = val.PremioLiquidoAnterior, + PremioTotal = val.PremioTotalAnterior + }); + break; + } + case 2: + { + List list3 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (RenovacaoFiltrado == null || list3.Count == 0) + { + return; + } + list = (from x in list3 + where x.Documento != null + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + PremioTotal = x.Sum((Renovacao c) => c.PremioTotal), + PremioLiquido = x.Sum((Renovacao p) => p.PremioLiquido), + MediaComissao = ((x.Sum((Renovacao c) => c.Comissao) > 0m) ? (decimal.Round(x.Sum((Renovacao c) => c.Comissao) / (decimal)x.Count((Renovacao c) => c.Comissao > 0m), 2) * 100m) : 0m), + ComissaoGerada = x.Sum((Renovacao c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + Cancelamentos = Funcoes.DistinctBy(x, (Renovacao c) => ((DomainBase)c.Documento).Id).Count((Renovacao c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, (Renovacao c) => ((DomainBase)c.Documento).Id).Count((Renovacao c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = Funcoes.DistinctBy(x, (Renovacao c) => ((DomainBase)c.Documento).Id).Count((Renovacao c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = Funcoes.DistinctBy(x, (Renovacao c) => ((DomainBase)c.Documento).Id).Count((Renovacao c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (Renovacao c) => ((DomainBase)c.Documento).Id).Count((Renovacao c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(x, (Renovacao c) => ((DomainBase)c.Documento).Id).Count((Renovacao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalProspeccao = x.Count((Renovacao c) => c.Tipo == 3), + TotalGeral = x.Count() + })).ToList(); + break; + } + case 1: + { + List list4 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ApolicePendenteFiltrado == null || list4.Count == 0) + { + return; + } + list = (from x in list4 + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + Cancelamentos = Funcoes.DistinctBy(x, (ApolicePendente c) => ((DomainBase)c.Documento).Id).Count((ApolicePendente c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, (ApolicePendente c) => ((DomainBase)c.Documento).Id).Count((ApolicePendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = Funcoes.DistinctBy(x, (ApolicePendente c) => ((DomainBase)c.Documento).Id).Count((ApolicePendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = Funcoes.DistinctBy(x, (ApolicePendente c) => ((DomainBase)c.Documento).Id).Count((ApolicePendente c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (ApolicePendente c) => ((DomainBase)c.Documento).Id).Count((ApolicePendente c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(x, (ApolicePendente c) => ((DomainBase)c.Documento).Id).Count((ApolicePendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalGeral = x.Count() + })).ToList(); + break; + } + case 3: + { + List list6 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ComissaoFiltrado == null || list6.Count == 0) + { + return; + } + list = (from x in list6 + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + Cancelamentos = Funcoes.DistinctBy(x, (Comissao c) => ((DomainBase)c.Documento).Id).Count((Comissao c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, (Comissao c) => ((DomainBase)c.Documento).Id).Count((Comissao c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = Funcoes.DistinctBy(x, (Comissao c) => ((DomainBase)c.Documento).Id).Count((Comissao c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = Funcoes.DistinctBy(x, (Comissao c) => ((DomainBase)c.Documento).Id).Count((Comissao c) => c.Documento.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (Comissao c) => ((DomainBase)c.Documento).Id).Count((Comissao c) => c.Documento.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(x, (Comissao c) => ((DomainBase)c.Documento).Id).Count((Comissao c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + ComissaoRecebidaBruta = x.Sum((Comissao c) => c.ComissaoBruta), + ComissaoRecebidaLiquida = x.Sum((Comissao c) => c.ComissaoRecebida), + Repasse = x.Sum((Comissao c) => c.Repasse), + MediaComissao = (x.Any((Comissao c) => c.ComissaoPerc > 0m) ? decimal.Round(x.Sum((Comissao c) => c.ComissaoPerc) / (decimal)x.Count((Comissao c) => c.ComissaoPerc > 0m), 2) : 0m) * 100m, + ComissaoPrevista = x.Sum((Comissao c) => c.ValorLiquido), + TotalGeral = x.Count() + })).ToList(); + break; + } + case 4: + case 14: + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0) + { + return; + } + list = (from x in PendenteFiltrado + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + Cancelamentos = Funcoes.DistinctBy(x, (Pendente c) => ((DomainBase)c.Documento).Id).Count((Pendente c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, (Pendente c) => ((DomainBase)c.Documento).Id).Count((Pendente c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = Funcoes.DistinctBy(x, (Pendente c) => ((DomainBase)c.Documento).Id).Count((Pendente c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = Funcoes.DistinctBy(x, (Pendente c) => ((DomainBase)c.Documento).Id).Count((Pendente c) => c.Documento.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (Pendente c) => ((DomainBase)c.Documento).Id).Count((Pendente c) => c.Documento.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(x, (Pendente c) => ((DomainBase)c.Documento).Id).Count((Pendente c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + ComissaoPrevista = x.Sum((Pendente c) => c.ComissaoPrevista), + TotalPrevista = x.Sum((Pendente c) => c.TotalPrevisto), + TotalGeral = x.Count() + })).ToList(); + break; + case 7: + case 8: + { + List list5 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (SinistroFiltrado == null || list5.Count == 0) + { + return; + } + list = (from x in list5 + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? EnumHelper.GetDescription(x.StatusSinistro) : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + Liquidado = (((int)Relatorio == 9) ? null : new int?((from s in x + where s.Liquidacao.HasValue + select ((DomainBase)s.EntidadeSinistro.ControleSinistro).Id).Distinct().Count())), + Valor = x.Sum((Sinistro s) => s.Valor), + ValorOrcado = x.Sum((Sinistro s) => s.ValorOrcado), + ValorLiberado = x.Sum((Sinistro s) => s.ValorLiberado), + ValorPago = x.Sum((Sinistro s) => s.ValorPago), + ValorLiquidado = (((int)Relatorio == 9) ? null : new decimal?(x.Where((Sinistro s) => s.Liquidacao.HasValue).Sum((Sinistro s) => s.ValorPago))), + ValorSalvado = x.Sum((Sinistro s) => s.ValorSalvado), + ValorFranquia = x.Sum((Sinistro s) => s.ValorFranquia), + Pendente = (from s in x + where !s.Liquidacao.HasValue + select ((DomainBase)s.EntidadeSinistro.ControleSinistro).Id).Distinct().Count(), + TotalGeral = x.Select((Sinistro s) => ((DomainBase)s.EntidadeSinistro.ControleSinistro).Id).Distinct().Count() + })).ToList(); + break; + } + case 6: + { + List list2 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (AuditoriaFiltrado == null || list2.Count == 0) + { + return; + } + list = (from x in list2 + group x by ((int)Agrupamento != 1) ? (((int)Agrupamento != 2) ? (((int)Agrupamento != 3) ? (((int)Agrupamento != 4) ? x.Status : x.Estipulante) : x.Vendedor) : x.Ramo) : x.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + PremioTotal = x.Sum((Auditoria c) => c.PremioTotal), + PremioLiquido = x.Sum((Auditoria p) => p.PremioLiquido), + MediaComissao = ((x.Sum((Auditoria c) => c.Comissao) > 0m) ? decimal.Round(x.Sum((Auditoria c) => c.Comissao) / (decimal)x.Count((Auditoria c) => c.Comissao > 0m), 2) : 0m) * 100m, + ComissaoGerada = x.Sum((Auditoria c) => (c.PremioLiquido + (c.Documento.AdicionalComiss ? c.Documento.PremioAdicional : 0m)) * c.Comissao * 0.01m), + ComissaoPrevista = x.Sum((Auditoria c) => c.ComissaoPrevista), + ComissaoRecebidaBruta = x.Sum((Auditoria c) => c.ComissaoRecebida), + ComissaoPendente = x.Sum((Auditoria c) => c.ComissaoPendente), + Cancelamentos = Funcoes.DistinctBy(x, (Auditoria c) => ((DomainBase)c.Documento).Id).Count((Auditoria c) => (int)c.Documento.Situacao == 3), + Novos = Funcoes.DistinctBy(x, (Auditoria c) => ((DomainBase)c.Documento).Id).Count((Auditoria c) => (int)c.Documento.Situacao == 1 || ((int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 2)), + Renovacoes = Funcoes.DistinctBy(x, (Auditoria c) => ((DomainBase)c.Documento).Id).Count((Auditoria c) => (int)c.Documento.Situacao == 2 && (int)c.Documento.Negocio.GetValueOrDefault() == 1), + Apolices = Funcoes.DistinctBy(x, (Auditoria c) => ((DomainBase)c.Documento).Id).Count((Auditoria c) => c.Tipo == 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Endossos = Funcoes.DistinctBy(x, (Auditoria c) => ((DomainBase)c.Documento).Id).Count((Auditoria c) => c.Tipo != 0 && (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 1), + Faturas = Funcoes.DistinctBy(x, (Auditoria c) => ((DomainBase)c.Documento).Id).Count((Auditoria c) => (int)c.Documento.TipoRecebimento.GetValueOrDefault() == 2), + TotalLiquido = x.Count((Auditoria c) => (int)c.Documento.Situacao != 3), + TotalGeral = x.Count() + })).ToList(); + break; + } + case 5: + if (Pagamentos == null || Pagamentos.Count == 0) + { + return; + } + list = ((IEnumerable)Pagamentos).Select((Func)((Pagamento x) => new Sintetico + { + Agrupamento = x.Vendedores.Vendedor, + ValorLiquido = x.Dados.Where((DadosRelatorio c) => c.Id != 0).Sum((DadosRelatorio c) => c.ValorLiquido), + ValorParcela = x.Dados.Where((DadosRelatorio c) => c.Id != 0).Sum((DadosRelatorio c) => c.ValorParcela), + Repasse = x.Dados.Where((DadosRelatorio c) => c.Id != 0).Sum((DadosRelatorio c) => c.Repasse), + TotalGeral = x.Dados.Count((DadosRelatorio c) => c.Id != 0) + })).ToList(); + break; + case 13: + if (MetaVendedor == null || MetaVendedor.Count == 0) + { + return; + } + list = (from g in MetaVendedor + group g by g.Vendedor).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + Meta = Math.Round(x.Where((MetaVendedorRelatorio m) => m.MetaAtingir > 0m).Sum((MetaVendedorRelatorio m) => m.MetaCumprida * 100m / m.MetaAtingir) * 100m, 2), + MetaAtingir = Math.Round(x.Sum((MetaVendedorRelatorio m) => m.MetaAtingir), 2), + MetaCumprida = Math.Round(x.Sum((MetaVendedorRelatorio m) => m.MetaCumprida), 2) + })).ToList(); + break; + case 12: + if (MetaSeguradora == null || MetaSeguradora.Count == 0) + { + return; + } + list = (from g in MetaSeguradora + group g by g.Seguradora).Select((Func, Sintetico>)((IGrouping x) => new Sintetico + { + Agrupamento = x.Key, + Meta = Math.Round(x.Where((MetaSeguradoraRelatorio m) => m.MetaAtingir > 0m).Sum((MetaSeguradoraRelatorio m) => m.MetaCumprida * 100m / m.MetaAtingir) * 100m, 2), + MetaAtingir = Math.Round(x.Sum((MetaSeguradoraRelatorio m) => m.MetaAtingir), 2), + MetaCumprida = Math.Round(x.Sum((MetaSeguradoraRelatorio m) => m.MetaCumprida), 2) + })).ToList(); + break; + } + if (list != null) + { + ((Window)new SinteticoView(list, EnumHelper.GetDescription(Relatorio), Inicio, Fim)).Show(); + } + } + + private void SeguradoraOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(0); + } + } + + public void RecheckAllLists() + { + for (int i = 0; i <= 9; i++) + { + RecheckAllSelected(i); + } + } + + public void RecheckAllSelected(int tipo) + { + if (_allSelectedChanging) + { + return; + } + try + { + _allSelectedChanging = true; + switch (tipo) + { + case 0: + if (Seguradoras.All((Seguradora e) => e.Selecionado)) + { + AllSelectedSeguradora = true; + } + else if (Seguradoras.All((Seguradora e) => !e.Selecionado)) + { + AllSelectedSeguradora = false; + } + else + { + AllSelectedSeguradora = null; + } + break; + case 1: + if (Ramos.All((Ramo e) => e.Selecionado)) + { + AllSelectedRamo = true; + } + else if (Ramos.All((Ramo e) => !e.Selecionado)) + { + AllSelectedRamo = false; + } + else + { + AllSelectedRamo = null; + } + break; + case 2: + if (Vendedores.All((Vendedor e) => e.Selecionado)) + { + AllSelectedVendedor = true; + } + else if (Vendedores.All((Vendedor e) => !e.Selecionado)) + { + AllSelectedVendedor = false; + } + else + { + AllSelectedVendedor = null; + } + break; + case 3: + if (TipoSeguros.All((StatusRelatorio e) => e.Selecionado)) + { + AllSelectedStatus = true; + } + else if (TipoSeguros.All((StatusRelatorio e) => !e.Selecionado)) + { + AllSelectedStatus = false; + } + else + { + AllSelectedStatus = null; + } + break; + case 4: + if (TipoVendedor.All((TipoVendedor e) => e.Selecionado)) + { + AllSelectedTipoVendedor = true; + } + else if (TipoVendedor.All((TipoVendedor e) => !e.Selecionado)) + { + AllSelectedTipoVendedor = false; + } + else + { + AllSelectedTipoVendedor = null; + } + break; + case 5: + if (Negocios.All((NegocioRelatorio e) => e.Selecionado)) + { + AllSelectedNegocio = true; + } + else if (Negocios.All((NegocioRelatorio e) => !e.Selecionado)) + { + AllSelectedNegocio = false; + } + else + { + AllSelectedNegocio = null; + } + break; + case 6: + if (Produtos.All((Produto e) => e.Selecionado)) + { + AllSelectedProduto = true; + } + else if (Produtos.All((Produto e) => !e.Selecionado)) + { + AllSelectedProduto = false; + } + else + { + AllSelectedProduto = null; + } + break; + case 7: + if (Estipulantes.All((Estipulante e) => e.Selecionado)) + { + AllSelectedEstipulante = true; + } + else if (Estipulantes.All((Estipulante e) => !e.Selecionado)) + { + AllSelectedEstipulante = false; + } + else + { + AllSelectedEstipulante = null; + } + break; + } + AdicionarFiltros(); + } + finally + { + _allSelectedChanging = false; + } + } + + private void RamoOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(1); + } + } + + public void ReloadVendedores() + { + if (!Inativo) + { + Vendedores = ((Vinculo.Count > 0) ? (from x in Recursos.Vendedores + where Vinculo.Any((VendedorUsuario y) => ((DomainBase)y.Vendedor).Id == ((DomainBase)x).Id) && x.Ativo + orderby x.Nome + select x).ToList() : (from x in Recursos.Vendedores + where (Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && x.Ativo + orderby x.Nome + select x).ToList()); + } + else + { + Vendedores = ((Vinculo.Count > 0) ? (from x in Recursos.Vendedores + where Vinculo.Any((VendedorUsuario y) => ((DomainBase)y.Vendedor).Id == ((DomainBase)x).Id) + orderby x.Nome + select x).ToList() : (from x in Recursos.Vendedores + where Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa + orderby x.Nome + select x).ToList()); + } + OnPropertyChanged("ReloadVendedores"); + } + + private void TipoVendedorOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(4); + } + } + + private void VendedorOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(2); + } + } + + private async Task LoadVendedores() + { + Vinculo = await VerificaVinculoVendedor(Recursos.Usuario); + Vendedores = ((Vinculo.Count > 0) ? (from x in Recursos.Vendedores + where Vinculo.Any((VendedorUsuario y) => ((DomainBase)y.Vendedor).Id == ((DomainBase)x).Id) + orderby x.Nome + select x).ToList() : (from x in Recursos.Vendedores + where Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa + orderby x.Nome + select x).ToList()); + Usuarios = (from x in Recursos.Usuarios + where !x.Excluido + orderby x.Nome + select x).ToList(); + UsuariosFiltrados = new ObservableCollection(Usuarios); + } + + private void ProdutoOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(5); + } + } + + private void EstipulanteOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(6); + } + } + + private void NegocioOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(9); + } + } + + private void StatusOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (!_alterandoFiltros) + { + RecheckAllSelected(3); + } + } + + private async void PopularRelatorio(string opcao) + { + Relatorios = new List(); + List source = await ServicoRestriUsuario.BuscarRestricoes(((DomainBase)Recursos.Usuario).Id); + foreach (Relatorio item in ((Relatorio[])Enum.GetValues(typeof(Relatorio))).OrderBy((Relatorio x) => EnumHelper.GetDescription(x))) + { + if (ValidationHelper.GetTipo((Enum)(object)item) != opcao) + { + continue; + } + switch ((int)item) + { + case 3: + { + RestricaoUsuario? obj19 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 34)); + if (obj19 == null || !obj19.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 2: + { + RestricaoUsuario? obj26 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 23)); + if (obj26 == null || !obj26.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 4: + { + RestricaoUsuario? obj12 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 24)); + if (obj12 == null || !obj12.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 23: + { + RestricaoUsuario? obj23 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 96)); + if (obj23 == null || !obj23.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 24: + { + RestricaoUsuario? obj17 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 98)); + if (obj17 == null || !obj17.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 25: + { + RestricaoUsuario? obj27 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 98)); + if ((obj27 == null || !obj27.Restricao) && !Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 22)) + { + Relatorios.Add(item); + } + break; + } + case 9: + { + RestricaoUsuario? obj2 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 25)); + if (obj2 == null || !obj2.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 10: + { + RestricaoUsuario? obj18 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 26)); + if (obj18 == null || !obj18.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 5: + { + RestricaoUsuario? obj13 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 27)); + if (obj13 == null || !obj13.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 7: + { + RestricaoUsuario? obj7 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 28)); + if (obj7 == null || !obj7.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 6: + { + RestricaoUsuario? obj11 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 29)); + if (obj11 == null || !obj11.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 1: + { + RestricaoUsuario? obj21 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 49)); + if (obj21 == null || !obj21.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 0: + { + RestricaoUsuario? obj4 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 30)); + if (obj4 == null || !obj4.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 11: + { + RestricaoUsuario? obj14 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 41)); + if (obj14 == null || !obj14.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 8: + { + RestricaoUsuario? obj6 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 46)); + if (obj6 == null || !obj6.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 12: + { + RestricaoUsuario? obj24 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 51)); + if (obj24 == null || !obj24.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 13: + { + RestricaoUsuario? obj10 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 50)); + if (obj10 == null || !obj10.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 14: + { + RestricaoUsuario? obj28 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 52)); + if (obj28 == null || !obj28.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 15: + { + RestricaoUsuario? obj16 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 53)); + if (obj16 == null || !obj16.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 16: + { + RestricaoUsuario? obj5 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 62)); + if (obj5 == null || !obj5.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 17: + { + RestricaoUsuario? obj25 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 63)); + if (obj25 == null || !obj25.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 18: + { + RestricaoUsuario? obj20 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 31)); + if (obj20 == null || !obj20.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 19: + { + RestricaoUsuario? obj9 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 90)); + if (obj9 == null || !obj9.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 20: + { + RestricaoUsuario? obj3 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 91)); + if (obj3 == null || !obj3.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 26: + { + RestricaoUsuario? obj22 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 107)); + if (obj22 == null || !obj22.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 27: + { + RestricaoUsuario? obj15 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 111)); + if (obj15 == null || !obj15.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 28: + { + RestricaoUsuario? obj8 = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 112)); + if (obj8 == null || !obj8.Restricao) + { + Relatorios.Add(item); + } + break; + } + case 29: + { + RestricaoUsuario? obj = ((IEnumerable)source).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 30)); + if (obj == null || !obj.Restricao) + { + Relatorios.Add(item); + } + break; + } + } + } + Relatorio = Relatorios.FirstOrDefault(); + } + + public void AdicionarFiltro(FiltroRelatorio filtro) + { + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Expected I4, but got Unknown + if (filtro == null) + { + return; + } + if (FiltroRelatorioSelecionado == null) + { + FiltroRelatorioSelecionado = new ObservableCollection(); + } + if (FiltroRelatorioSelecionado.Any((FiltroRelatorio x) => x.Id == filtro.Id && x.Tipo == filtro.Tipo)) + { + return; + } + FiltroRelatorioSelecionado.Add(filtro); + TipoFiltroRelatorio tipo = filtro.Tipo; + switch ((int)tipo) + { + case 5: + { + StatusRelatorio val8 = ((IEnumerable)TipoSeguros).FirstOrDefault((Func)((StatusRelatorio x) => (long)x.Status == filtro.Id)); + if (val8 != null) + { + val8.Selecionado = true; + } + break; + } + case 0: + { + Seguradora val4 = ((IEnumerable)Seguradoras).FirstOrDefault((Func)((Seguradora x) => ((DomainBase)x).Id == filtro.Id)); + if (val4 != null) + { + val4.Selecionado = true; + } + break; + } + case 1: + { + Ramo val6 = ((IEnumerable)Ramos).FirstOrDefault((Func)((Ramo x) => ((DomainBase)x).Id == filtro.Id)); + if (val6 != null) + { + val6.Selecionado = true; + } + break; + } + case 3: + { + Estipulante val2 = ((IEnumerable)Estipulantes).FirstOrDefault((Func)((Estipulante x) => ((DomainBase)x).Id == filtro.Id)); + if (val2 != null) + { + val2.Selecionado = true; + } + break; + } + case 2: + { + Vendedor val7 = ((IEnumerable)Vendedores).FirstOrDefault((Func)((Vendedor x) => ((DomainBase)x).Id == filtro.Id)); + if (val7 != null) + { + val7.Selecionado = true; + } + break; + } + case 6: + { + TipoVendedor val5 = ((IEnumerable)TipoVendedor).FirstOrDefault((Func)((TipoVendedor x) => ((DomainBase)x).Id == filtro.Id)); + if (val5 != null) + { + val5.Selecionado = true; + } + break; + } + case 4: + { + Produto val3 = ((IEnumerable)Produtos).FirstOrDefault((Func)((Produto x) => ((DomainBase)x).Id == filtro.Id)); + if (val3 != null) + { + val3.Selecionado = true; + } + break; + } + case 7: + { + NegocioRelatorio val = ((IEnumerable)Negocios).FirstOrDefault((Func)((NegocioRelatorio x) => x.Id == filtro.Id)); + if (val != null) + { + val.Selecionado = true; + } + break; + } + } + } + + public void LimparFiltros() + { + _alterandoFiltros = true; + FiltroRelatorioSelecionado = null; + foreach (StatusRelatorio item in TipoSeguros.Where((StatusRelatorio x) => x.Selecionado)) + { + item.Selecionado = false; + } + foreach (Seguradora item2 in Seguradoras.Where((Seguradora x) => x.Selecionado)) + { + item2.Selecionado = false; + } + foreach (Ramo item3 in Ramos.Where((Ramo x) => x.Selecionado)) + { + item3.Selecionado = false; + } + foreach (Estipulante item4 in Estipulantes.Where((Estipulante x) => x.Selecionado)) + { + item4.Selecionado = false; + } + foreach (Vendedor item5 in Vendedores.Where((Vendedor x) => x.Selecionado)) + { + item5.Selecionado = false; + } + foreach (TipoVendedor item6 in TipoVendedor.Where((TipoVendedor x) => x.Selecionado)) + { + item6.Selecionado = false; + } + foreach (Produto item7 in Produtos.Where((Produto x) => x.Selecionado)) + { + item7.Selecionado = false; + } + foreach (NegocioRelatorio item8 in Negocios.Where((NegocioRelatorio x) => x.Selecionado)) + { + item8.Selecionado = false; + } + _alterandoFiltros = false; + } + + public void AdicionarFiltros() + { + List list = new List(); + List collection = Seguradoras.Where((Seguradora x) => x.Selecionado).Select((Func)((Seguradora x) => new FiltroRelatorio + { + Id = ((DomainBase)x).Id, + Descricao = x.Nome, + Tipo = (TipoFiltroRelatorio)0 + })).ToList(); + list.AddRange(collection); + collection = Ramos.Where((Ramo x) => x.Selecionado).Select((Func)((Ramo x) => new FiltroRelatorio + { + Id = ((DomainBase)x).Id, + Descricao = x.Nome, + Tipo = (TipoFiltroRelatorio)1 + })).ToList(); + list.AddRange(collection); + collection = Vendedores.Where((Vendedor x) => x.Selecionado).Select((Func)((Vendedor x) => new FiltroRelatorio + { + Id = ((DomainBase)x).Id, + Descricao = x.Nome, + Tipo = (TipoFiltroRelatorio)2 + })).ToList(); + list.AddRange(collection); + collection = TipoVendedor.Where((TipoVendedor x) => x.Selecionado).Select((Func)((TipoVendedor x) => new FiltroRelatorio + { + Id = ((DomainBase)x).Id, + Descricao = x.Descricao, + Tipo = (TipoFiltroRelatorio)6 + })).ToList(); + list.AddRange(collection); + collection = Estipulantes.Where((Estipulante x) => x.Selecionado).Select((Func)((Estipulante x) => new FiltroRelatorio + { + Id = ((DomainBase)x).Id, + Descricao = x.Nome, + Tipo = (TipoFiltroRelatorio)3 + })).ToList(); + list.AddRange(collection); + collection = Produtos.Where((Produto x) => x.Selecionado).Select((Func)((Produto x) => new FiltroRelatorio + { + Id = ((DomainBase)x).Id, + Descricao = x.Nome, + Tipo = (TipoFiltroRelatorio)4 + })).ToList(); + list.AddRange(collection); + collection = TipoSeguros.Where((StatusRelatorio x) => x.Selecionado).Select((Func)((StatusRelatorio x) => new FiltroRelatorio + { + Id = (long)x.Status, + Descricao = EnumHelper.GetDescription(x.Status), + Tipo = (TipoFiltroRelatorio)5 + })).ToList(); + list.AddRange(collection); + collection = Negocios.Where((NegocioRelatorio x) => x.Selecionado).Select((Func)((NegocioRelatorio x) => new FiltroRelatorio + { + Id = (long)x.Negocio, + Descricao = EnumHelper.GetDescription(x.Negocio), + Tipo = (TipoFiltroRelatorio)7 + })).ToList(); + list.AddRange(collection); + FiltroRelatorioSelecionado = new ObservableCollection(list); + } + + public void LimparRelatorio() + { + RelatorioVisibility = false; + VisibilityFiltroPersonalizado = (Visibility)2; + } + + public async Task GerarExcel() + { + string text = ""; + string fileName; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41)) + { + FolderBrowserDialog val = new FolderBrowserDialog(); + try + { + if (1 != (int)((CommonDialog)val).ShowDialog()) + { + return; + } + text = val.SelectedPath + "\\"; + Directory.CreateDirectory(text); + } + finally + { + ((IDisposable)val)?.Dispose(); + } + fileName = text + EnumHelper.GetDescription(Relatorio) + " " + Functions.GetNetworkTime().Date.ToShortDateString().Replace("/", "") + ".xlsx"; + } + else + { + text = Path.GetTempPath(); + fileName = $"{text}{Guid.NewGuid()}.xlsx"; + } + XLWorkbook workbook = new XLWorkbook(); + int index3 = 1; + Relatorio relatorio = Relatorio; + Agrupamento agrupamento40; + Agrupamento agrupamento41; + switch ((int)relatorio) + { + case 19: + { + List list47 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (NotaFiscalFiltrado == null || list47.Count == 0) + { + return; + } + List analitico48 = (list47.Any((NotaFiscalRelatorio x) => x.Selecionado) ? list47.Where((NotaFiscalRelatorio x) => x.Selecionado).ToList() : list47); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico48, Relatorio); + break; + } + case 17: + { + List list48 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (LicenciamentoFiltrado == null || list48.Count == 0) + { + return; + } + List analitico49 = (list48.Any((Licenciamento x) => x.Selecionado) ? list48.Where((Licenciamento x) => x.Selecionado).ToList() : list48); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico49, Relatorio); + break; + } + case 18: + { + List list56 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (TarefaFiltrado == null || list56.Count == 0) + { + return; + } + List analitico58 = (list56.Any((Tarefa x) => x.Selecionado) ? list56.Where((Tarefa x) => x.Selecionado).ToList() : list56); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico58, Relatorio); + break; + } + case 0: + case 1: + { + List list23 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ClientesAtivosInativosFiltrado == null || list23.Count == 0) + { + return; + } + List analitico27 = (list23.Any((ClientesAtivosInativos x) => x.Selecionado) ? list23.Where((ClientesAtivosInativos x) => x.Selecionado).ToList() : list23); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico27, Relatorio); + break; + } + case 4: + { + List listRenovacao = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (RenovacaoFiltrado == null || listRenovacao.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico7 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao.ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico7, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listRenovacao + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico6 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao.ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico6, Relatorio); + break; + } + foreach (string grupo35 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo35)) + { + List list6 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? (from x in listRenovacao + where x.Selecionado && x.Seguradora == grupo35 + orderby x.VigenciaFinal + select x).ToList() : (from x in listRenovacao + where x.Seguradora == grupo35 + orderby x.VigenciaFinal + select x).ToList()); + if (list6.Count != 0) + { + string nome6 = grupo35; + agrupamento41 = Agrupamento; + string nome2 = nome6.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list6, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listRenovacao + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico5 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao.ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico5, Relatorio); + break; + } + foreach (string grupo36 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo36)) + { + List list5 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? (from x in listRenovacao + where x.Selecionado && x.Ramo == grupo36 + orderby x.VigenciaFinal + select x).ToList() : (from x in listRenovacao + where x.Ramo == grupo36 + orderby x.VigenciaFinal + select x).ToList()); + if (list5.Count != 0) + { + string nome5 = grupo36; + agrupamento41 = Agrupamento; + string nome2 = nome5.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list5, Relatorio); + index3++; + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listRenovacao + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico3 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao.ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico3, Relatorio); + break; + } + index3 = 1; + foreach (string grupo38 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo38)) + { + List list3 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? (from x in listRenovacao + where x.Selecionado && x.Vendedor == grupo38 + orderby x.VigenciaFinal + select x).ToList() : (from x in listRenovacao + where x.Vendedor == grupo38 + orderby x.VigenciaFinal + select x).ToList()); + if (list3.Count != 0) + { + string nome3 = grupo38; + agrupamento41 = Agrupamento; + string nome2 = nome3.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list3, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listRenovacao + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico4 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao.ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico4, Relatorio); + break; + } + index3 = 1; + foreach (string grupo37 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo37)) + { + List list4 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? (from x in listRenovacao + where x.Selecionado && x.Estipulante == grupo37 + orderby x.VigenciaFinal + select x).ToList() : (from x in listRenovacao + where x.Estipulante == grupo37 + orderby x.VigenciaFinal + select x).ToList()); + if (list4.Count != 0) + { + string nome4 = grupo37; + agrupamento41 = Agrupamento; + string nome2 = nome4.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list4, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + List agrupamento9 = (from x in listRenovacao + orderby x.Status + select x.Status).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico2 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? listRenovacao.Where((Renovacao x) => x.Selecionado).ToList() : listRenovacao.ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico2, Relatorio); + break; + } + foreach (string grupo39 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo39)) + { + List list2 = (listRenovacao.Any((Renovacao x) => x.Selecionado) ? (from x in listRenovacao + where x.Selecionado && x.Status == grupo39 + orderby x.VigenciaFinal + select x).ToList() : (from x in listRenovacao + where x.Status == grupo39 + orderby x.VigenciaFinal + select x).ToList()); + if (list2.Count != 0) + { + string nome = grupo39; + agrupamento41 = Agrupamento; + string nome2 = nome.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list2, Relatorio); + } + } + } + break; + } + } + break; + } + case 2: + { + List listProducao = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ProducaoFiltrado == null || listProducao.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List source = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao + where x.Selecionado + orderby x.VigenciaInicial + select x).ToList() : listProducao.OrderBy((Producao x) => x.VigenciaInicial).ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", source.ToList(), Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listProducao + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico31 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao.Where((Producao x) => x.Selecionado).ToList() + orderby x.VigenciaInicial + select x).ToList() : listProducao.OrderBy((Producao x) => x.VigenciaInicial).ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico31, Relatorio); + break; + } + foreach (string grupo17 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo17)) + { + List list27 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao + where x.Selecionado && x.Seguradora == grupo17 + orderby x.VigenciaInicial + select x).ToList() : (from x in listProducao + where x.Seguradora == grupo17 + orderby x.VigenciaInicial + select x).ToList()); + if (list27.Count != 0) + { + string nome24 = grupo17; + agrupamento41 = Agrupamento; + string nome2 = nome24.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list27, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listProducao + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico33 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao.Where((Producao x) => x.Selecionado).ToList() + orderby x.VigenciaInicial + select x).ToList() : listProducao.OrderBy((Producao x) => x.VigenciaInicial).ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico33, Relatorio); + break; + } + foreach (string grupo15 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo15)) + { + List list29 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao + where x.Selecionado && x.Ramo == grupo15 + orderby x.VigenciaInicial + select x).ToList() : (from x in listProducao + where x.Ramo == grupo15 + orderby x.VigenciaInicial + select x).ToList()); + if (list29.Count != 0) + { + string nome26 = grupo15; + agrupamento41 = Agrupamento; + string nome2 = nome26.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list29, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listProducao + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico30 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao.Where((Producao x) => x.Selecionado).ToList() + orderby x.VigenciaInicial + select x).ToList() : listProducao.OrderBy((Producao x) => x.VigenciaInicial).ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico30, Relatorio); + break; + } + index3 = 1; + foreach (string grupo18 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo18)) + { + List list26 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao + where x.Selecionado && x.Vendedor == grupo18 + orderby x.VigenciaInicial + select x).ToList() : (from x in listProducao + where x.Vendedor == grupo18 + orderby x.VigenciaInicial + select x).ToList()); + if (list26.Count != 0) + { + string nome23 = grupo18; + agrupamento41 = Agrupamento; + string nome2 = nome23.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list26, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listProducao + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico32 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao.Where((Producao x) => x.Selecionado).ToList() + orderby x.VigenciaInicial + select x).ToList() : listProducao.OrderBy((Producao x) => x.VigenciaInicial).ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico32, Relatorio); + break; + } + index3 = 1; + foreach (string grupo16 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo16)) + { + List list28 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao + where x.Selecionado && x.Estipulante == grupo16 + orderby x.VigenciaInicial + select x).ToList() : (from x in listProducao + where x.Estipulante == grupo16 + orderby x.VigenciaInicial + select x).ToList()); + if (list28.Count != 0) + { + string nome25 = grupo16; + agrupamento41 = Agrupamento; + string nome2 = nome25.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list28, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + List agrupamento9 = (from x in listProducao + orderby x.Status + select x.Status).Distinct().ToList(); + ColunasOcultas = await Funcoes.OcultarColunas(Relatorio); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico29 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao.Where((Producao x) => x.Selecionado).ToList() + orderby x.VigenciaInicial + select x).ToList() : listProducao.OrderBy((Producao x) => x.VigenciaInicial).ToList()); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico29, ColunasOcultas); + break; + } + foreach (string grupo19 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo19)) + { + List list25 = (listProducao.Any((Producao x) => x.Selecionado) ? (from x in listProducao + where x.Selecionado && x.Status == grupo19 + orderby x.VigenciaInicial + select x).ToList() : (from x in listProducao + where x.Status == grupo19 + orderby x.VigenciaInicial + select x).ToList()); + if (list25.Count != 0) + { + string nome22 = grupo19; + agrupamento41 = Agrupamento; + string nome2 = nome22.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list25, ColunasOcultas); + } + } + } + break; + } + } + break; + } + case 3: + { + List listApolicePendente = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ApolicePendenteFiltrado == null || listApolicePendente.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico46 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico46, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listApolicePendente + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico45 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico45, Relatorio); + break; + } + foreach (string grupo6 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo6)) + { + List list42 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? (from x in listApolicePendente + where x.Selecionado && x.Seguradora == grupo6 + orderby x.VigenciaInicial + select x).ToList() : (from x in listApolicePendente + where x.Seguradora == grupo6 + orderby x.VigenciaInicial + select x).ToList()); + if (list42.Count != 0) + { + string nome38 = grupo6; + agrupamento41 = Agrupamento; + string nome2 = nome38.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list42, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listApolicePendente + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico44 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico44, Relatorio); + break; + } + foreach (string grupo7 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo7)) + { + List list41 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? (from x in listApolicePendente + where x.Selecionado && x.Ramo == grupo7 + orderby x.Seguradora + select x).ToList() : (from x in listApolicePendente + where x.Ramo == grupo7 + orderby x.Seguradora + select x).ToList()); + if (list41.Count != 0) + { + string nome37 = grupo7; + agrupamento41 = Agrupamento; + string nome2 = nome37.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list41, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listApolicePendente + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico42 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico42, Relatorio); + break; + } + index3 = 1; + foreach (string grupo9 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo9)) + { + List list39 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? (from x in listApolicePendente + where x.Selecionado && x.Vendedor == grupo9 + orderby x.Seguradora + select x).ToList() : (from x in listApolicePendente + where x.Vendedor == grupo9 + orderby x.Seguradora + select x).ToList()); + if (list39.Count != 0) + { + string nome35 = grupo9; + agrupamento41 = Agrupamento; + string nome2 = nome35.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list39, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listApolicePendente + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico43 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico43, Relatorio); + break; + } + index3 = 1; + foreach (string grupo8 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo8)) + { + List list40 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? (from x in listApolicePendente + where x.Selecionado && x.Estipulante == grupo8 + orderby x.Seguradora + select x).ToList() : (from x in listApolicePendente + where x.Estipulante == grupo8 + orderby x.Seguradora + select x).ToList()); + if (list40.Count != 0) + { + string nome36 = grupo8; + agrupamento41 = Agrupamento; + string nome2 = nome36.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list40, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + List agrupamento9 = (from x in listApolicePendente + orderby x.Status + select x.Status).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico41 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? listApolicePendente.Where((ApolicePendente x) => x.Selecionado).ToList() : listApolicePendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico41, ColunasOcultas); + break; + } + foreach (string grupo10 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo10)) + { + List list38 = (listApolicePendente.Any((ApolicePendente x) => x.Selecionado) ? (from x in listApolicePendente + where x.Selecionado && x.Status == grupo10 + orderby x.Seguradora + select x).ToList() : (from x in listApolicePendente + where x.Status == grupo10 + orderby x.Seguradora + select x).ToList()); + if (list38.Count != 0) + { + string nome34 = grupo10; + agrupamento41 = Agrupamento; + string nome2 = nome34.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list38, ColunasOcultas); + } + } + } + break; + } + } + break; + } + case 5: + { + List listComissaoRelatorio = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ComissaoFiltrado == null || listComissaoRelatorio.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico19 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico19, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listComissaoRelatorio + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico18 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico18, Relatorio); + break; + } + foreach (string grupo25 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo25)) + { + List list16 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? (from x in listComissaoRelatorio + where x.Selecionado && x.Seguradora == grupo25 + orderby x.Recebimento + select x).ToList() : (from x in listComissaoRelatorio + where x.Seguradora == grupo25 + orderby x.Recebimento + select x).ToList()); + if (list16.Count != 0) + { + string nome16 = grupo25; + agrupamento41 = Agrupamento; + string nome2 = nome16.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list16, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listComissaoRelatorio + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico17 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico17, Relatorio); + break; + } + foreach (string grupo26 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo26)) + { + List list15 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? (from x in listComissaoRelatorio + where x.Selecionado && x.Ramo == grupo26 + orderby x.Recebimento + select x).ToList() : (from x in listComissaoRelatorio + where x.Ramo == grupo26 + orderby x.Recebimento + select x).ToList()); + if (list15.Count != 0) + { + string nome15 = grupo26; + agrupamento41 = Agrupamento; + string nome2 = nome15.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list15, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listComissaoRelatorio + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico15 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico15, Relatorio); + break; + } + index3 = 1; + foreach (string grupo28 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo28)) + { + List list13 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? (from x in listComissaoRelatorio + where x.Selecionado && x.Vendedor == grupo28 + orderby x.Recebimento + select x).ToList() : (from x in listComissaoRelatorio + where x.Vendedor == grupo28 + orderby x.Recebimento + select x).ToList()); + if (list13.Count != 0) + { + string nome13 = grupo28; + agrupamento41 = Agrupamento; + string nome2 = nome13.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list13, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listComissaoRelatorio + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico16 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico16, Relatorio); + break; + } + index3 = 1; + foreach (string grupo27 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo27)) + { + List list14 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? (from x in listComissaoRelatorio + where x.Selecionado && x.Estipulante == grupo27 + orderby x.Recebimento + select x).ToList() : (from x in listComissaoRelatorio + where x.Estipulante == grupo27 + orderby x.Recebimento + select x).ToList()); + if (list14.Count != 0) + { + string nome14 = grupo27; + agrupamento41 = Agrupamento; + string nome2 = nome14.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list14, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + List agrupamento9 = (from x in listComissaoRelatorio + orderby x.Status + select x.Status).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico14 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? listComissaoRelatorio.Where((Comissao x) => x.Selecionado).ToList() : listComissaoRelatorio); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico14, ColunasOcultas); + break; + } + foreach (string grupo29 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo29)) + { + List list12 = (listComissaoRelatorio.Any((Comissao x) => x.Selecionado) ? (from x in listComissaoRelatorio + where x.Selecionado && x.Status == grupo29 + orderby x.Recebimento + select x).ToList() : (from x in listComissaoRelatorio + where x.Status == grupo29 + orderby x.Recebimento + select x).ToList()); + if (list12.Count != 0) + { + string nome12 = grupo29; + agrupamento41 = Agrupamento; + string nome2 = nome12.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list12, ColunasOcultas); + } + } + } + break; + } + } + break; + } + case 7: + { + if (Pagamentos == null) + { + return; + } + List list43 = PagamentosSintetico.OrderByDescending((PagamentoSintetico x) => x.Titulo).ToList(); + foreach (PagamentoSintetico item in list43) + { + string titulo2 = item.Titulo; + agrupamento40 = Agrupamento; + string nome39 = titulo2.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento40)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome39, item.Agrupamento.ToList(), Relatorio); + } + index3 = 1; + List list44 = Pagamentos.OrderByDescending((Pagamento x) => x.Title).ToList(); + foreach (Pagamento item2 in list44) + { + string title2 = item2.Title; + agrupamento40 = Agrupamento; + string nome40 = title2.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento40)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome40, item2.Dados.ToList(), Relatorio); + index3++; + } + List list45 = new List(); + foreach (Pagamento item3 in Pagamentos.OrderBy((Pagamento x) => x.Title)) + { + list45.Add(item3.Vendedores); + } + list45.Add(new AgrupamentoVendedor + { + Vendedor = "TOTAL", + Repasse = list45.Sum((AgrupamentoVendedor p) => p.Repasse), + Debito = list45.Sum((AgrupamentoVendedor p) => p.Debito), + Credito = list45.Sum((AgrupamentoVendedor p) => p.Credito), + Desconto = list45.Sum((AgrupamentoVendedor p) => p.Desconto), + Adiantamento = list45.Sum((AgrupamentoVendedor p) => p.Adiantamento), + ValorLiquido = list45.Sum((AgrupamentoVendedor p) => p.ValorLiquido) + }); + workbook = await Funcoes.GerarXls(workbook, "DADOS BANCÁRIOS", list45, Relatorio, verificarColunas: false); + break; + } + case 6: + case 16: + { + List listPendente = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (PendenteFiltrado == null || listPendente.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico25 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico25, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listPendente + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico24 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico24, Relatorio); + break; + } + foreach (string grupo20 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo20)) + { + List list21 = (listPendente.Any((Pendente x) => x.Selecionado) ? (from x in listPendente + where x.Selecionado && x.Seguradora == grupo20 + orderby x.Vencimento + select x).ToList() : (from x in listPendente + where x.Seguradora == grupo20 + orderby x.Vencimento + select x).ToList()); + if (list21.Count != 0) + { + string nome21 = grupo20; + agrupamento41 = Agrupamento; + string nome2 = nome21.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list21, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listPendente + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico23 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico23, Relatorio); + break; + } + foreach (string grupo21 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo21)) + { + List list20 = (listPendente.Any((Pendente x) => x.Selecionado) ? (from x in listPendente + where x.Selecionado && x.Ramo == grupo21 + orderby x.Vencimento + select x).ToList() : (from x in listPendente + where x.Ramo == grupo21 + orderby x.Vencimento + select x).ToList()); + if (list20.Count != 0) + { + string nome20 = grupo21; + agrupamento41 = Agrupamento; + string nome2 = nome20.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list20, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listPendente + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico21 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico21, Relatorio); + break; + } + index3 = 1; + foreach (string grupo23 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo23)) + { + List list18 = (listPendente.Any((Pendente x) => x.Selecionado) ? (from x in listPendente + where x.Selecionado && x.Vendedor == grupo23 + orderby x.Vencimento + select x).ToList() : (from x in listPendente + where x.Vendedor == grupo23 + orderby x.Vencimento + select x).ToList()); + if (list18.Count != 0) + { + string nome18 = grupo23; + agrupamento41 = Agrupamento; + string nome2 = nome18.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list18, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listPendente + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico22 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico22, Relatorio); + break; + } + index3 = 1; + foreach (string grupo22 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo22)) + { + List list19 = (listPendente.Any((Pendente x) => x.Selecionado) ? (from x in listPendente + where x.Selecionado && x.Estipulante == grupo22 + orderby x.Vencimento + select x).ToList() : (from x in listPendente + where x.Estipulante == grupo22 + orderby x.Vencimento + select x).ToList()); + if (list19.Count != 0) + { + string nome19 = grupo22; + agrupamento41 = Agrupamento; + string nome2 = nome19.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list19, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + List agrupamento9 = (from x in listPendente + orderby x.Status + select x.Status).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico20 = (listPendente.Any((Pendente x) => x.Selecionado) ? listPendente.Where((Pendente x) => x.Selecionado).ToList() : listPendente); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico20, ColunasOcultas); + break; + } + foreach (string grupo24 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo24)) + { + List list17 = (listPendente.Any((Pendente x) => x.Selecionado) ? (from x in listPendente + where x.Selecionado && x.Status == grupo24 + orderby x.Vencimento + select x).ToList() : (from x in listPendente + where x.Status == grupo24 + orderby x.Vencimento + select x).ToList()); + if (list17.Count != 0) + { + string nome17 = grupo24; + agrupamento41 = Agrupamento; + string nome2 = nome17.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list17, ColunasOcultas); + } + } + } + break; + } + } + break; + } + case 9: + case 10: + { + List listSinistroAnalitico = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (SinistroFiltrado == null || listSinistroAnalitico.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico13 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico13, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from Sinistro x in (IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico12 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico12, Relatorio); + break; + } + foreach (string grupo30 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo30)) + { + List list11 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? (from x in listSinistroAnalitico + where x.Selecionado && x.Seguradora == grupo30 + orderby x.DataSinistro + select x).ToList() : (from x in listSinistroAnalitico + where x.Seguradora == grupo30 + orderby x.DataSinistro + select x).ToList()); + if (list11.Count != 0) + { + string nome11 = grupo30; + agrupamento41 = Agrupamento; + string nome2 = nome11.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list11, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from Sinistro x in (IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico11 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico11, Relatorio); + break; + } + foreach (string grupo31 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo31)) + { + List list10 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? (from x in listSinistroAnalitico + where x.Selecionado && x.Ramo == grupo31 + orderby x.DataSinistro + select x).ToList() : (from x in listSinistroAnalitico + where x.Ramo == grupo31 + orderby x.DataSinistro + select x).ToList()); + if (list10.Count != 0) + { + string nome10 = grupo31; + agrupamento41 = Agrupamento; + string nome2 = nome10.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list10, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from Sinistro x in (IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico9 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico9, Relatorio); + break; + } + index3 = 1; + foreach (string grupo33 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo33)) + { + List list8 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? (from x in listSinistroAnalitico + where x.Selecionado && x.Vendedor == grupo33 + orderby x.DataSinistro + select x).ToList() : (from x in listSinistroAnalitico + where x.Vendedor == grupo33 + orderby x.DataSinistro + select x).ToList()); + if (list8.Count != 0) + { + string nome8 = grupo33; + agrupamento41 = Agrupamento; + string nome2 = nome8.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list8, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from Sinistro x in (IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico10 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico10, Relatorio); + break; + } + index3 = 1; + foreach (string grupo32 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo32)) + { + List list9 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? (from x in listSinistroAnalitico + where x.Selecionado && x.Estipulante == grupo32 + orderby x.DataSinistro + select x).ToList() : (from x in listSinistroAnalitico + where x.Estipulante == grupo32 + orderby x.DataSinistro + select x).ToList()); + if (list9.Count != 0) + { + string nome9 = grupo32; + agrupamento41 = Agrupamento; + string nome2 = nome9.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list9, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + List agrupamento9 = (from Sinistro x in (IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items + orderby x.StatusApolice + select EnumHelper.GetDescription(x.StatusSinistro)).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico8 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? listSinistroAnalitico.Where((Sinistro x) => x.Selecionado).ToList() : listSinistroAnalitico); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico8, ColunasOcultas); + break; + } + foreach (string grupo34 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo34)) + { + List list7 = (listSinistroAnalitico.Any((Sinistro x) => x.Selecionado) ? (from x in listSinistroAnalitico + where x.Selecionado && x.StatusApolice == grupo34 + orderby x.DataSinistro + select x).ToList() : (from x in listSinistroAnalitico + where x.StatusApolice == grupo34 + orderby x.DataSinistro + select x).ToList()); + if (list7.Count != 0) + { + string nome7 = grupo34; + agrupamento41 = Agrupamento; + string nome2 = nome7.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list7, ColunasOcultas); + } + } + } + break; + } + } + break; + } + case 8: + { + List listAuditoria = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (AuditoriaFiltrado == null || listAuditoria.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico55 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico55, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listAuditoria + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico54 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico54, Relatorio); + break; + } + foreach (string grupo in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo)) + { + List list53 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? (from x in listAuditoria + where x.Selecionado && x.Seguradora == grupo + orderby x.VigenciaInicial + select x).ToList() : (from x in listAuditoria + where x.Seguradora == grupo + orderby x.VigenciaInicial + select x).ToList()); + if (list53.Count != 0) + { + string nome45 = grupo; + agrupamento41 = Agrupamento; + string nome2 = nome45.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list53, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listAuditoria + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico53 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico53, Relatorio); + break; + } + foreach (string grupo2 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo2)) + { + List list52 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? (from x in listAuditoria + where x.Selecionado && x.Ramo == grupo2 + orderby x.VigenciaInicial + select x).ToList() : (from x in listAuditoria + where x.Ramo == grupo2 + orderby x.VigenciaInicial + select x).ToList()); + if (list52.Count != 0) + { + string nome44 = grupo2; + agrupamento41 = Agrupamento; + string nome2 = nome44.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list52, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listAuditoria + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico51 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico51, Relatorio); + break; + } + index3 = 1; + foreach (string grupo4 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo4)) + { + List list50 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? (from x in listAuditoria + where x.Selecionado && x.Vendedor == grupo4 + orderby x.VigenciaInicial + select x).ToList() : (from x in listAuditoria + where x.Vendedor == grupo4 + orderby x.VigenciaInicial + select x).ToList()); + if (list50.Count != 0) + { + string nome42 = grupo4; + agrupamento41 = Agrupamento; + string nome2 = nome42.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list50, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listAuditoria + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico52 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico52, Relatorio); + break; + } + index3 = 1; + foreach (string grupo3 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo3)) + { + List list51 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? (from x in listAuditoria + where x.Selecionado && x.Estipulante == grupo3 + orderby x.VigenciaInicial + select x).ToList() : (from x in listAuditoria + where x.Estipulante == grupo3 + orderby x.VigenciaInicial + select x).ToList()); + if (list51.Count != 0) + { + string nome43 = grupo3; + agrupamento41 = Agrupamento; + string nome2 = nome43.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list51, Relatorio); + index3++; + } + } + } + break; + } + case 4: + { + List agrupamento9 = (from x in listAuditoria + orderby x.Status + select x.Status).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico50 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? listAuditoria.Where((Auditoria x) => x.Selecionado).ToList() : listAuditoria); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico50, ColunasOcultas); + break; + } + foreach (string grupo5 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo5)) + { + List list49 = (listAuditoria.Any((Auditoria x) => x.Selecionado) ? (from x in listAuditoria + where x.Selecionado && x.Status == grupo5 + orderby x.VigenciaInicial + select x).ToList() : (from x in listAuditoria + where x.Status == grupo5 + orderby x.VigenciaInicial + select x).ToList()); + if (list49.Count != 0) + { + string nome41 = grupo5; + agrupamento41 = Agrupamento; + string nome2 = nome41.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list49, ColunasOcultas); + } + } + } + break; + } + } + break; + } + case 12: + { + List list24 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (FaturaPendenteFiltrado == null || list24.Count == 0) + { + return; + } + List analitico28 = (list24.Any((FaturaPendente x) => x.Selecionado) ? list24.Where((FaturaPendente x) => x.Selecionado).ToList() : list24); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico28, Relatorio); + break; + } + case 14: + { + List list22 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (MetaSeguradoraFiltrado == null || list22.Count == 0) + { + return; + } + List analitico26 = (list22.Any((MetaSeguradoraRelatorio x) => x.Selecionado) ? list22.Where((MetaSeguradoraRelatorio x) => x.Selecionado).ToList() : list22); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico26, Relatorio); + break; + } + case 15: + { + List list55 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (MetaVendedorFiltrado == null || list55.Count == 0) + { + return; + } + List analitico57 = (list55.Any((MetaVendedorRelatorio x) => x.Selecionado) ? list55.Where((MetaVendedorRelatorio x) => x.Selecionado).ToList() : list55); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico57, Relatorio); + break; + } + case 11: + { + List list30 = new List(); + if ((GridRelatorio)Report != null) + { + list30 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + } + if (FechamentoFiltrado == null || (list30.Count == 0 && (GridRelatorio)Report != null)) + { + return; + } + index3 = 1; + foreach (Fechamentos item4 in Fechamento) + { + string title = item4.Title; + agrupamento40 = Agrupamento; + string nome27 = title.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento40)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome27, item4.Fechamento.ToList(), Relatorio); + index3++; + } + break; + } + case 13: + { + List list46 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ExtratosFiltrado == null || list46.Count == 0) + { + return; + } + List analitico47 = (list46.Any((ExtratoBaixadoRelatorio x) => x.Selecionado) ? list46.Where((ExtratoBaixadoRelatorio x) => x.Selecionado).ToList() : list46); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico47, Relatorio); + break; + } + case 20: + { + if (PrevisaoFiltrado == null) + { + return; + } + List list36 = PrevisaoSintetico.OrderByDescending((PrevisaoPagamentoComissaoSintetico x) => x.Titulo).ToList(); + foreach (PrevisaoPagamentoComissaoSintetico item5 in list36) + { + string titulo = item5.Titulo; + agrupamento40 = Agrupamento; + string nome32 = titulo.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento40)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome32, item5.Agrupamento.ToList(), Relatorio, verificarColunas: false); + } + index3 = 1; + foreach (PrevisaoPagamentoComissao item6 in Previsao) + { + string vendedor = item6.Vendedor; + agrupamento40 = Agrupamento; + string nome33 = vendedor.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento40)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome33, item6.PrevisaoPagamento.ToList(), Relatorio); + index3++; + } + break; + } + case 23: + { + List list54 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (LogsEnvioFiltrado == null || list54.Count == 0) + { + return; + } + List analitico56 = (list54.Any((LogsEnvio x) => x.Selecionado) ? list54.Where((LogsEnvio x) => x.Selecionado).ToList() : list54); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico56, Relatorio); + break; + } + case 24: + case 25: + { + List list35 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (LogUtilizacaoFiltrado == null || list35.Count == 0) + { + return; + } + List analitico39 = (list35.Any((LogAcaoRelatorio x) => x.Selecionado) ? list35.Where((LogAcaoRelatorio x) => x.Selecionado).ToList() : list35); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico39, Relatorio); + break; + } + case 26: + { + List list57 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ApoliceCriticaFiltrado == null || list57.Count == 0) + { + return; + } + List analitico59 = (list57.Any((ApoliceCritica x) => x.Selecionado) ? list57.Where((ApoliceCritica x) => x.Selecionado).ToList() : list57); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico59, Relatorio); + break; + } + case 28: + { + List list37 = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (EndossoFiltrado == null || list37.Count == 0) + { + return; + } + List analitico40 = (list37.Any((Endosso x) => x.Selecionado) ? list37.Where((Endosso x) => x.Selecionado).ToList() : list37); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico40, Relatorio); + break; + } + case 27: + { + List listPlaca = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (PlacaFiltrado == null || listPlaca.Count == 0) + { + return; + } + agrupamento40 = Agrupamento; + switch (agrupamento40 - 1) + { + default: + { + List analitico38 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado).ToList() : listPlaca); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico38, Relatorio); + break; + } + case 0: + { + List agrupamento9 = (from x in listPlaca + orderby x.Seguradora + select x.Seguradora).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico36 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado).ToList() : listPlaca); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico36, Relatorio); + break; + } + foreach (string grupo12 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo12)) + { + List list33 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado && x.Seguradora == grupo12).ToList() : listPlaca.Where((Placas x) => x.Seguradora == grupo12).ToList()); + if (list33.Count != 0) + { + string nome30 = grupo12; + agrupamento41 = Agrupamento; + string nome2 = nome30.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list33, Relatorio); + } + } + } + break; + } + case 1: + { + List agrupamento9 = (from x in listPlaca + orderby x.Ramo + select x.Ramo).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico35 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado).ToList() : listPlaca); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico35, Relatorio); + break; + } + foreach (string grupo13 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo13)) + { + List list32 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado && x.Ramo == grupo13).ToList() : listPlaca.Where((Placas x) => x.Ramo == grupo13).ToList()); + if (list32.Count != 0) + { + string nome29 = grupo13; + agrupamento41 = Agrupamento; + string nome2 = nome29.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString()); + workbook = await Funcoes.GerarXls(workbook, nome2, list32, Relatorio); + } + } + } + break; + } + case 2: + { + List agrupamento9 = (from x in listPlaca + orderby x.Vendedor + select x.Vendedor).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico37 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado).ToList() : listPlaca); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico37, Relatorio); + break; + } + index3 = 1; + foreach (string grupo11 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo11)) + { + List list34 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado && x.Vendedor == grupo11).ToList() : listPlaca.Where((Placas x) => x.Vendedor == grupo11).ToList()); + if (list34.Count != 0) + { + string nome31 = grupo11; + agrupamento41 = Agrupamento; + string nome2 = nome31.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list34, Relatorio); + index3++; + } + } + } + break; + } + case 3: + { + List agrupamento9 = (from x in listPlaca + orderby x.Estipulante + select x.Estipulante).Distinct().ToList(); + if ((agrupamento9.Count == 2 && agrupamento9[0] == null && agrupamento9[1] == "") || (agrupamento9.Count == 1 && agrupamento9[0] == null) || (agrupamento9.Count == 1 && agrupamento9[0] == "")) + { + List analitico34 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado).ToList() : listPlaca); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico34, Relatorio); + break; + } + index3 = 1; + foreach (string grupo14 in agrupamento9) + { + if (!string.IsNullOrWhiteSpace(grupo14)) + { + List list31 = (listPlaca.Any((Placas x) => x.Selecionado) ? listPlaca.Where((Placas x) => x.Selecionado && x.Estipulante == grupo14).ToList() : listPlaca.Where((Placas x) => x.Estipulante == grupo14).ToList()); + if (list31.Count != 0) + { + string nome28 = grupo14; + agrupamento41 = Agrupamento; + string nome2 = nome28.ValidaNomePlanilha(((object)(Agrupamento)(ref agrupamento41)).ToString(), index3); + workbook = await Funcoes.GerarXls(workbook, nome2, list31, Relatorio); + index3++; + } + } + } + break; + } + } + break; + } + case 29: + { + List list = ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList(); + if (ClassificacaoFiltrado == null || list.Count == 0) + { + return; + } + List analitico = (list.Any((Classificacao x) => x.Selecionado) ? list.Where((Classificacao x) => x.Selecionado).ToList() : list); + workbook = await Funcoes.GerarXls(workbook, "ANALÍTICO", analitico, Relatorio); + break; + } + } + if (SinteticoRelatorio != null && SinteticoRelatorio.Count > 0) + { + workbook = await Funcoes.GerarXlsSintetico(workbook, "SINTÉTICO", Sintetic.ToList()); + } + if (FiltroRelatorioSelecionado != null && FiltroRelatorioSelecionado.Count > 0) + { + workbook = await Funcoes.GerarXls(workbook, "FILTROS", FiltroRelatorioSelecionado.ToList(), ColunasOcultas); + } + RegistrarAcao($"EMITIU EXCEL DO RELATÓRIO PERÍODO ENTRE {Inicio:d} E {Fim:d}", Relatorio, Filtros); + workbook.SaveAs(fileName); + Process.Start(fileName); + } + + public void Bind() + { + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Expected I4, but got Unknown + ((GridRelatorio)Report).DataGrid.CancelEdit(); + ((GridRelatorio)Report).DataGrid.CancelEdit(); + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 0: + case 1: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ClientesAtivosInativosFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 17: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = LicenciamentoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 27: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = PlacaFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 18: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = TarefaFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 3: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ApolicePendenteFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 12: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = FaturaPendenteFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 2: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ProducaoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 4: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = RenovacaoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 5: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ComissaoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 6: + case 16: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = PendenteFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 9: + case 10: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = SinistroFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 13: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ExtratosFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 14: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = MetaSeguradoraFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 15: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = MetaVendedorFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 19: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = NotaFiscalFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 23: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = LogsEnvioFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 24: + case 25: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = LogUtilizacaoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 8: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = AuditoriaFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 28: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = EndossoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 26: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ApoliceCriticaFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 29: + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ClassificacaoFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + break; + case 7: + case 11: + case 20: + case 21: + case 22: + break; + } + } + + public async Task Selecionar() + { + await Task.Run(delegate + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0085: Expected I4, but got Unknown + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 0: + case 1: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0) + { + return; + } + ClientesAtivosInativosFiltrado.ToList().ForEach(delegate(ClientesAtivosInativos x) + { + x.Selecionado = !x.Selecionado; + }); + ClientesAtivosInativosFiltrado = new ObservableCollection(ClientesAtivosInativosFiltrado); + break; + case 17: + if (LicenciamentoFiltrado == null || LicenciamentoFiltrado.Count == 0) + { + return; + } + LicenciamentoFiltrado.ToList().ForEach(delegate(Licenciamento x) + { + x.Selecionado = !x.Selecionado; + }); + LicenciamentoFiltrado = new ObservableCollection(LicenciamentoFiltrado); + break; + case 18: + if (TarefaFiltrado == null || TarefaFiltrado.Count == 0) + { + return; + } + TarefaFiltrado.ToList().ForEach(delegate(Tarefa x) + { + x.Selecionado = !x.Selecionado; + }); + TarefaFiltrado = new ObservableCollection(TarefaFiltrado); + break; + case 3: + if (ApolicePendenteFiltrado == null || ApolicePendenteFiltrado.Count == 0) + { + return; + } + ApolicePendenteFiltrado.ToList().ForEach(delegate(ApolicePendente x) + { + x.Selecionado = !x.Selecionado; + }); + ApolicePendenteFiltrado = new ObservableCollection(ApolicePendenteFiltrado); + break; + case 12: + if (FaturaPendenteFiltrado == null || FaturaPendenteFiltrado.Count == 0) + { + return; + } + FaturaPendenteFiltrado.ToList().ForEach(delegate(FaturaPendente x) + { + x.Selecionado = !x.Selecionado; + }); + FaturaPendenteFiltrado = new ObservableCollection(FaturaPendenteFiltrado); + break; + case 2: + if (ProducaoFiltrado == null || ProducaoFiltrado.Count == 0) + { + return; + } + ProducaoFiltrado.ToList().ForEach(delegate(Producao x) + { + x.Selecionado = !x.Selecionado; + }); + ProducaoFiltrado = new ObservableCollection(ProducaoFiltrado); + break; + case 4: + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0) + { + return; + } + RenovacaoFiltrado.ToList().ForEach(delegate(Renovacao x) + { + x.Selecionado = !x.Selecionado; + }); + RenovacaoFiltrado = new ObservableCollection(RenovacaoFiltrado); + break; + case 5: + if (ComissaoFiltrado == null || ComissaoFiltrado.Count == 0) + { + return; + } + ComissaoFiltrado.ToList().ForEach(delegate(Comissao x) + { + x.Selecionado = !x.Selecionado; + }); + ComissaoFiltrado = new ObservableCollection(ComissaoFiltrado); + break; + case 6: + case 16: + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0) + { + return; + } + PendenteFiltrado.ToList().ForEach(delegate(Pendente x) + { + x.Selecionado = !x.Selecionado; + }); + PendenteFiltrado = new ObservableCollection(PendenteFiltrado); + break; + case 9: + case 10: + if (SinistroFiltrado == null || SinistroFiltrado.Count == 0) + { + return; + } + SinistroFiltrado.ToList().ForEach(delegate(Sinistro x) + { + x.Selecionado = !x.Selecionado; + }); + SinistroFiltrado = new ObservableCollection(SinistroFiltrado); + break; + case 13: + if (ExtratosFiltrado == null || ExtratosFiltrado.Count == 0) + { + return; + } + ExtratosFiltrado.ToList().ForEach(delegate(ExtratoBaixadoRelatorio x) + { + x.Selecionado = !x.Selecionado; + }); + ExtratosFiltrado = new ObservableCollection(ExtratosFiltrado); + break; + case 14: + if (MetaSeguradoraFiltrado == null || MetaSeguradoraFiltrado.Count == 0) + { + return; + } + MetaSeguradoraFiltrado.ToList().ForEach(delegate(MetaSeguradoraRelatorio x) + { + x.Selecionado = !x.Selecionado; + }); + MetaSeguradoraFiltrado = new ObservableCollection(MetaSeguradoraFiltrado); + break; + case 15: + if (MetaVendedorFiltrado == null || MetaVendedorFiltrado.Count == 0) + { + return; + } + MetaVendedorFiltrado.ToList().ForEach(delegate(MetaVendedorRelatorio x) + { + x.Selecionado = !x.Selecionado; + }); + MetaVendedorFiltrado = new ObservableCollection(MetaVendedorFiltrado); + break; + case 19: + if (NotaFiscalFiltrado == null || NotaFiscalFiltrado.Count == 0) + { + return; + } + NotaFiscalFiltrado.ToList().ForEach(delegate(NotaFiscalRelatorio x) + { + x.Selecionado = !x.Selecionado; + }); + NotaFiscalFiltrado = new ObservableCollection(NotaFiscalFiltrado); + break; + case 23: + if (LogsEnvioFiltrado == null || LogsEnvioFiltrado.Count == 0) + { + return; + } + LogsEnvioFiltrado.ToList().ForEach(delegate(LogsEnvio x) + { + x.Selecionado = !x.Selecionado; + }); + LogsEnvioFiltrado = new ObservableCollection(LogsEnvioFiltrado); + break; + case 24: + case 25: + if (LogUtilizacaoFiltrado == null || LogUtilizacaoFiltrado.Count == 0) + { + return; + } + LogUtilizacaoFiltrado.ToList().ForEach(delegate(LogAcaoRelatorio x) + { + x.Selecionado = !x.Selecionado; + }); + LogUtilizacaoFiltrado = new ObservableCollection(LogUtilizacaoFiltrado); + break; + case 8: + if (AuditoriaFiltrado == null || AuditoriaFiltrado.Count == 0) + { + return; + } + AuditoriaFiltrado.ToList().ForEach(delegate(Auditoria x) + { + x.Selecionado = !x.Selecionado; + }); + AuditoriaFiltrado = new ObservableCollection(AuditoriaFiltrado); + break; + case 28: + if (EndossoFiltrado == null || EndossoFiltrado.Count == 0) + { + return; + } + EndossoFiltrado.ToList().ForEach(delegate(Endosso x) + { + x.Selecionado = !x.Selecionado; + }); + EndossoFiltrado = new ObservableCollection(EndossoFiltrado); + break; + case 27: + if (PlacaFiltrado == null || PlacaFiltrado.Count == 0) + { + return; + } + PlacaFiltrado.ToList().ForEach(delegate(Placas x) + { + x.Selecionado = !x.Selecionado; + }); + PlacaFiltrado = new ObservableCollection(PlacaFiltrado); + break; + case 26: + if (ApoliceCriticaFiltrado == null || ApoliceCriticaFiltrado.Count == 0) + { + return; + } + ApoliceCriticaFiltrado.ToList().ForEach(delegate(ApoliceCritica x) + { + x.Selecionado = !x.Selecionado; + }); + ApoliceCriticaFiltrado = new ObservableCollection(ApoliceCriticaFiltrado); + break; + case 29: + if (ClassificacaoFiltrado == null || ClassificacaoFiltrado.Count == 0) + { + return; + } + ClassificacaoFiltrado.ToList().ForEach(delegate(Classificacao x) + { + x.Selecionado = !x.Selecionado; + }); + ClassificacaoFiltrado = new ObservableCollection(ClassificacaoFiltrado); + break; + } + Dispatcher dispatcher = ((DispatcherObject)Application.Current).Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)new Action(Bind)); + } + }); + } + + public async Task Acompanhamento() + { + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0 || RenovacaoFiltrado.All((Renovacao x) => !x.Selecionado)) + { + await ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM ITEM NA LISTA PARA GERAR O ACOMPANHAMENTO."); + return; + } + Trilha trilha2 = new Trilha + { + Ativo = true, + Titulo = "ACOMPANHAMENTO DE RENOVAÇÃO", + Tipo = (TipoTrilha)0, + Fases = new List + { + new Fase + { + Titulo = "A RENOVAR" + }, + new Fase + { + Titulo = "EM RENOVAÇÃO" + }, + new Fase + { + Titulo = "RENOVADOS" + }, + new Fase + { + Titulo = "PERDIDOS" + } + } + }; + trilha2 = await SalvarTrilha(trilha2); + if (trilha2 == null) + { + return; + } + List tarefas = await new TarefaServico().BuscarTarefas(((DomainBase)trilha2).Id); + foreach (Renovacao r in RenovacaoFiltrado.Where((Renovacao x) => x.Selecionado)) + { + if (!tarefas.Any((Tarefa x) => x.IdEntidade == ((DomainBase)r.Documento).Id)) + { + Tarefa val = new Tarefa(); + val.Entidade = (TipoTarefa)0; + val.IdEntidade = ((DomainBase)r.Documento).Id; + val.IdCliente = ((DomainBase)r.Documento.Controle.Cliente).Id; + val.Cliente = r.Cliente; + val.Titulo = "APÓLICE NÚMERO " + r.Apolice; + val.Usuario = Recursos.Usuario; + val.Agendamento = Funcoes.GetNetworkTime(); + val.Trilha = trilha2; + val.Fase = trilha2.Fases.First(); + val.Referencia = $"VIGÊNCIA FINAL: {r.VigenciaFinal}\nSEGURADORA: {r.Seguradora}\nRAMO: {r.Ramo}\nITEM: {r.Item}"; + Tarefa tarefa = val; + await new TarefaServico().Salvar(tarefa); + } + } + if (Funcoes.IsWindowOpen("ACOMPANHAMENTO DE RENOVAÇÃO")) + { + Funcoes.Destroy("ACOMPANHAMENTO DE RENOVAÇÃO"); + } + ((Window)new HosterWindow((ContentControl)(object)new AcompanhamentoView(), "ACOMPANHAMENTO DE RENOVAÇÃO", 910.0, 600.0, canMaximize: true)).Show(); + } + + public async Task SalvarTrilha(Trilha destino) + { + List fases2 = destino.Fases; + TarefaServico servico = new TarefaServico(); + List source = await servico.BuscarTrilhas(); + if (source.Any((Trilha x) => x.Tipo == destino.Tipo)) + { + Trilha trilhaExistente = source.First((Trilha x) => x.Tipo == destino.Tipo); + Trilha val = trilhaExistente; + val.Fases = await servico.BuscarFases(((DomainBase)trilhaExistente).Id); + return trilhaExistente; + } + Trilha trilha = await servico.Salvar(destino); + if (!servico.Sucesso) + { + return null; + } + fases2.ForEach(delegate(Fase x) + { + x.Trilha = trilha; + }); + fases2 = await servico.Salvar(fases2); + if (!servico.Sucesso) + { + return null; + } + trilha.Fases = fases2; + return trilha; + } + + public async Task SalvarTarefas(List tarefas) + { + await new TarefaServico().Salvar(tarefas); + } + + public List GerarTarefas(Tarefa tarefa) + { + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Expected I4, but got Unknown + List list = new List(); + Usuario usuario = tarefa.Usuario; + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 17: + if (LicenciamentoFiltrado == null || LicenciamentoFiltrado.Count == 0 || !LicenciamentoFiltrado.Any((Licenciamento x) => x.Selecionado)) + { + return null; + } + return LicenciamentoFiltrado.Where((Licenciamento x) => x.Selecionado).Select((Func)((Licenciamento x) => new Tarefa + { + Entidade = (TipoTarefa)2, + IdEntidade = ((DomainBase)x.Documento.Controle.Cliente).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Cliente, + IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id, + Referencia = "VENCIMENTO CRLV " + x.Placa + " - ITEM " + x.Item, + Responsaveis = tarefa.Responsaveis + })).ToList(); + case 9: + case 10: + if (SinistroFiltrado == null || SinistroFiltrado.Count == 0 || !SinistroFiltrado.Any((Sinistro x) => x.Selecionado)) + { + return null; + } + return SinistroFiltrado.Where((Sinistro x) => x.Selecionado).Select((Func)((Sinistro x) => new Tarefa + { + Entidade = (TipoTarefa)4, + IdEntidade = ((DomainBase)x.EntidadeSinistro).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Nome, + IdCliente = ((DomainBase)x.EntidadeSinistro.ControleSinistro.Item.Documento.Controle.Cliente).Id, + Referencia = "SINISTRO " + x.NumeroSinistro + " - ITEM " + x.Item, + Responsaveis = tarefa.Responsaveis + })).ToList(); + case 5: + if (ComissaoFiltrado == null || ComissaoFiltrado.Count == 0 || !ComissaoFiltrado.Any((Comissao x) => x.Selecionado)) + { + return null; + } + return ComissaoFiltrado.Where((Comissao x) => x.Selecionado).Select(delegate(Comissao x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + Tarefa val = new Tarefa(); + val.Entidade = (TipoTarefa)3; + val.IdEntidade = ((DomainBase)x.ParcelaEntity).Id; + val.Agendamento = tarefa.Agendamento; + val.Titulo = tarefa.Titulo; + val.Descricao = tarefa.Anotacoes; + val.Usuario = usuario; + val.UsuarioCadastro = Recursos.Usuario; + val.Cliente = x.Documento.Controle.Cliente.Nome; + val.IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id; + val.Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("PARCELA " + x.Parcela + " DA APÓLICE " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("PARCELA " + x.Parcela + " DA APÓLICE " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PARCELA " + x.Parcela + " DA PROPOSTA " + x.Documento.Proposta))); + val.Responsaveis = tarefa.Responsaveis; + return val; + }).ToList(); + case 6: + case 16: + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0 || !PendenteFiltrado.Any((Pendente x) => x.Selecionado)) + { + return null; + } + return PendenteFiltrado.Where((Pendente x) => x.Selecionado).Select((Func)((Pendente x) => new Tarefa + { + Entidade = (TipoTarefa)3, + IdEntidade = ((DomainBase)x.ParcelaEntity).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Documento.Controle.Cliente.Nome, + IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id, + Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? $"PARCELA {x.ParcelaEntity.NumeroParcela} DA APÓLICE {x.Documento.Apolice}" : ((x.Documento.Tipo > 0) ? $"PARCELA {x.ParcelaEntity.NumeroParcela} DA APÓLICE {x.Documento.Apolice} ENDOSSO {x.Documento.Endosso}" : $"PARCELA {x.ParcelaEntity.NumeroParcela} DA PROPOSTA {x.Documento.Proposta}")), + Responsaveis = tarefa.Responsaveis + })).ToList(); + case 1: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || !ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado)) + { + return null; + } + return ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).Select((Func)((ClientesAtivosInativos x) => new Tarefa + { + Entidade = (TipoTarefa)2, + IdEntidade = x.Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Nome, + IdCliente = x.Id + })).ToList(); + case 0: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || !ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado)) + { + return null; + } + return ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).Select((Func)((ClientesAtivosInativos x) => new Tarefa + { + Entidade = (TipoTarefa)2, + IdEntidade = x.Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Nome, + IdCliente = x.Id + })).ToList(); + case 3: + if (ApolicePendenteFiltrado == null || ApolicePendenteFiltrado.Count == 0 || !ApolicePendenteFiltrado.Any((ApolicePendente x) => x.Selecionado)) + { + return null; + } + return ApolicePendenteFiltrado.Where((ApolicePendente x) => x.Selecionado).Select((Func)((ApolicePendente x) => new Tarefa + { + Entidade = (TipoTarefa)0, + IdEntidade = ((DomainBase)x.Documento).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Documento.Controle.Cliente.Nome, + IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id, + Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("APÓLICE NÚMERO " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("APÓLICE NÚMERO " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PROPOSTA NÚMERO " + x.Documento.Proposta))) + })).ToList(); + case 4: + { + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0 || !RenovacaoFiltrado.Any((Renovacao x) => x.Selecionado)) + { + return null; + } + IEnumerable enumerable = RenovacaoFiltrado.Where((Renovacao x) => x.Documento != null); + IEnumerable enumerable2 = RenovacaoFiltrado.Where((Renovacao x) => x.Prospeccao != null); + List collection = new List(); + List collection2 = new List(); + Renovacao[] source = (enumerable as Renovacao[]) ?? enumerable.ToArray(); + if (source.Any()) + { + collection = source.Where((Renovacao x) => x.Selecionado).Select((Func)((Renovacao x) => new Tarefa + { + Entidade = (TipoTarefa)0, + IdEntidade = ((DomainBase)x.Documento).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Documento.Controle.Cliente.Nome, + IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id, + Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("APÓLICE NÚMERO " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("APÓLICE NÚMERO " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PROPOSTA NÚMERO " + x.Documento.Proposta))) + })).ToList(); + } + Renovacao[] source2 = (enumerable2 as Renovacao[]) ?? enumerable2.ToArray(); + if (source2.Any()) + { + collection2 = source2.Where((Renovacao x) => x.Selecionado).Select((Func)((Renovacao x) => new Tarefa + { + Entidade = (TipoTarefa)5, + IdEntidade = ((DomainBase)x.Prospeccao).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Prospeccao.Nome, + Referencia = "PROSPECÇÃO " + x.VigenciaFinal?.ToString("d") + })).ToList(); + } + list.AddRange(collection); + list.AddRange(collection2); + if (list.Count <= 0) + { + return null; + } + return list; + } + case 8: + if (AuditoriaFiltrado == null || AuditoriaFiltrado.Count == 0 || !AuditoriaFiltrado.Any((Auditoria x) => x.Selecionado)) + { + return null; + } + return AuditoriaFiltrado.Where((Auditoria x) => x.Selecionado).Select((Func)((Auditoria x) => new Tarefa + { + Entidade = (TipoTarefa)0, + IdEntidade = ((DomainBase)x.Documento).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Documento.Controle.Cliente.Nome, + IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id, + Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("APÓLICE NÚMERO " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("APÓLICE NÚMERO " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PROPOSTA NÚMERO " + x.Documento.Proposta))) + })).ToList(); + case 15: + if (MetaVendedorFiltrado == null || MetaVendedorFiltrado.Count == 0 || !MetaVendedorFiltrado.Any((MetaVendedorRelatorio x) => x.Selecionado)) + { + return null; + } + return MetaVendedorFiltrado.Where((MetaVendedorRelatorio x) => x.Selecionado).Select((Func)((MetaVendedorRelatorio x) => new Tarefa + { + Entidade = (TipoTarefa)6, + IdEntidade = x.Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Vendedor, + Referencia = "VENDEDOR " + x.Vendedor + })).ToList(); + case 14: + if (MetaSeguradoraFiltrado == null || MetaSeguradoraFiltrado.Count == 0 || !MetaSeguradoraFiltrado.Any((MetaSeguradoraRelatorio x) => x.Selecionado)) + { + return null; + } + return MetaSeguradoraFiltrado.Where((MetaSeguradoraRelatorio x) => x.Selecionado).Select((Func)((MetaSeguradoraRelatorio x) => new Tarefa + { + Entidade = (TipoTarefa)7, + IdEntidade = x.Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Seguradora, + Referencia = "SEGURADORA " + x.Seguradora + })).ToList(); + default: + if (ProducaoFiltrado == null || ProducaoFiltrado.Count == 0 || !ProducaoFiltrado.Any((Producao x) => x.Selecionado)) + { + return null; + } + return ProducaoFiltrado.Where((Producao x) => x.Selecionado).Select((Func)((Producao x) => new Tarefa + { + Entidade = (TipoTarefa)0, + IdEntidade = ((DomainBase)x.Documento).Id, + Agendamento = tarefa.Agendamento, + Titulo = tarefa.Titulo, + Descricao = tarefa.Anotacoes, + Responsaveis = tarefa.Responsaveis, + Usuario = usuario, + UsuarioCadastro = Recursos.Usuario, + Cliente = x.Documento.Controle.Cliente.Nome, + IdCliente = ((DomainBase)x.Documento.Controle.Cliente).Id, + Referencia = ((x.Documento.Tipo == 0 && !string.IsNullOrWhiteSpace(x.Documento.Apolice)) ? ("APÓLICE NÚMERO " + x.Documento.Apolice) : ((x.Documento.Tipo > 0) ? ("APÓLICE NÚMERO " + x.Documento.Apolice + " ENDOSSO " + x.Documento.Endosso) : ("PROPOSTA NÚMERO " + x.Documento.Proposta))) + })).ToList(); + } + } + + public async Task> CriarLista() + { + return await Task.Run(delegate + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Expected I4, but got Unknown + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Invalid comparison between Unknown and I4 + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + default: + if ((int)relatorio == 26) + { + if (ApoliceCriticaFiltrado == null || ApoliceCriticaFiltrado.Count == 0 || !ApoliceCriticaFiltrado.Any((ApoliceCritica x) => x.Selecionado)) + { + return new List(); + } + return ApoliceCriticaFiltrado.Where((ApoliceCritica x) => x.Selecionado).Select((Func)((ApoliceCritica x) => new MalaDireta + { + Cliente = x.Critica.Documento.Controle.Cliente, + Apolice = x.Critica.Documento, + Tela = (TipoTela)2, + Item = new Item + { + Descricao = ((x.Critica.Documento.ItensAtivo == null) ? "" : ((x.Critica.Documento.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.Critica.Documento.ItensAtivo.Count == 1) ? x.Critica.Documento.ItensAtivo.First().Descricao : ""))) + }, + Relatorio = Relatorio + })).ToList(); + } + break; + case 17: + if (LicenciamentoFiltrado == null || LicenciamentoFiltrado.Count == 0 || !LicenciamentoFiltrado.Any((Licenciamento x) => x.Selecionado)) + { + return new List(); + } + return LicenciamentoFiltrado.Where((Licenciamento x) => x.Selecionado).Select((Func)((Licenciamento x) => new MalaDireta + { + Cliente = x.Documento.Controle.Cliente, + Apolice = x.Documento, + Item = x.EntidadeItem, + Tela = (TipoTela)3, + Relatorio = Relatorio + })).ToList(); + case 1: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || !ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado)) + { + return new List(); + } + return ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).Select((Func)((ClientesAtivosInativos x) => new MalaDireta + { + Cliente = new Cliente + { + Id = x.Id, + Nome = x.Nome, + Nascimento = x.Nascimento, + Documento = x.Documento, + VencimentoHabilitacao = x.VencimentoCnh, + MalaDireta = x.EntidadeCliente.MalaDireta + }, + Tela = (TipoTela)1, + Relatorio = Relatorio + })).ToList(); + case 0: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || !ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado)) + { + return new List(); + } + return ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).Select((Func)((ClientesAtivosInativos x) => new MalaDireta + { + Cliente = new Cliente + { + Id = x.Id, + Nome = x.Nome, + Nascimento = x.Nascimento, + Documento = x.Documento, + VencimentoHabilitacao = x.VencimentoCnh, + NomeSocialRg = x.EntidadeCliente.NomeSocialRg, + MalaDireta = x.EntidadeCliente.MalaDireta + }, + Tela = (TipoTela)1, + Relatorio = Relatorio + })).ToList(); + case 2: + if (ProducaoFiltrado == null || ProducaoFiltrado.Count == 0 || !ProducaoFiltrado.Any((Producao x) => x.Selecionado && x.Documento != null)) + { + return new List(); + } + return ProducaoFiltrado.Where((Producao x) => x.Selecionado && x.Documento != null).Select((Func)((Producao x) => new MalaDireta + { + Cliente = x.Documento.Controle.Cliente, + Apolice = x.Documento, + Item = new Item + { + Descricao = x.Item + }, + Tela = (TipoTela)2, + Relatorio = Relatorio + })).ToList(); + case 3: + if (ApolicePendenteFiltrado == null || ApolicePendenteFiltrado.Count == 0 || !ApolicePendenteFiltrado.Any((ApolicePendente x) => x.Selecionado && x.Documento != null)) + { + return new List(); + } + return ApolicePendenteFiltrado.Where((ApolicePendente x) => x.Selecionado && x.Documento != null).Select((Func)((ApolicePendente x) => new MalaDireta + { + Cliente = x.Documento.Controle.Cliente, + Apolice = x.Documento, + Item = new Item + { + Descricao = x.Item + }, + Tela = (TipoTela)2, + Relatorio = Relatorio + })).ToList(); + case 4: + { + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0 || !RenovacaoFiltrado.Any((Renovacao x) => x.Selecionado)) + { + return new List(); + } + List list = RenovacaoFiltrado.Where((Renovacao x) => x.Selecionado && x.Documento != null).Select((Func)((Renovacao x) => new MalaDireta + { + Cliente = x.Documento.Controle.Cliente, + Apolice = x.Documento, + Tela = (TipoTela)2, + Item = new Item + { + Descricao = x.Item + }, + Relatorio = Relatorio + })).ToList(); + List list2 = RenovacaoFiltrado.Where((Renovacao x) => x.Selecionado && x.Prospeccao != null).Select((Func)((Renovacao x) => new MalaDireta + { + Cliente = new Cliente + { + Nome = x.Prospeccao.Nome, + Id = 0L + }, + Prospeccao = x.Prospeccao, + Tela = (TipoTela)33, + Item = new Item + { + Descricao = x.Item + }, + Relatorio = Relatorio + })).ToList(); + if (list2.Count > 0) + { + list.AddRange(list2); + } + return list; + } + case 5: + if (ComissaoFiltrado == null || ComissaoFiltrado.Count == 0 || !ComissaoFiltrado.Any((Comissao x) => x.Selecionado && x.Documento != null)) + { + return new List(); + } + return ComissaoFiltrado.Where((Comissao x) => x.Selecionado && x.Documento != null).Select((Func)((Comissao x) => new MalaDireta + { + Cliente = x.Documento.Controle.Cliente, + Apolice = x.Documento, + Parcela = x.ParcelaEntity, + Item = new Item + { + Descricao = x.Item + }, + Tela = (TipoTela)5, + Relatorio = Relatorio + })).ToList(); + case 9: + case 10: + if (SinistroFiltrado == null || SinistroFiltrado.Count == 0 || !SinistroFiltrado.Any((Sinistro x) => x.Selecionado)) + { + return new List(); + } + return SinistroFiltrado.Where((Sinistro x) => x.Selecionado).Select((Func)((Sinistro x) => new MalaDireta + { + Cliente = x.Cliente, + Apolice = x.Documento, + Item = new Item + { + Descricao = x.Item + }, + Sinistro = x.EntidadeSinistro, + Tela = (TipoTela)7, + Relatorio = Relatorio + })).ToList(); + case 6: + case 16: + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0 || !PendenteFiltrado.Any((Pendente x) => x.Selecionado && x.Documento != null)) + { + return new List(); + } + return PendenteFiltrado.Where((Pendente x) => x.Selecionado && x.Documento != null).Select((Func)((Pendente x) => new MalaDireta + { + Cliente = x.Documento.Controle.Cliente, + Apolice = x.Documento, + Item = new Item + { + Descricao = x.Item + }, + Parcela = x.ParcelaEntity, + Tela = (TipoTela)5, + Relatorio = Relatorio + })).ToList(); + case 7: + case 8: + case 11: + case 12: + case 13: + case 14: + case 15: + break; + } + return (List)null; + }); + } + + public async Task> CriarListaEtiqueta() + { + return await Task.Run(delegate + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Expected I4, but got Unknown + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 1: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || !ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado)) + { + return (List)null; + } + return ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).Select((Func)((ClientesAtivosInativos x) => new Documento + { + Controle = new Controle + { + Cliente = new Cliente + { + Id = x.Id, + Nome = x.Nome + } + } + })).ToList(); + case 0: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || !ClientesAtivosInativosFiltrado.Any((ClientesAtivosInativos x) => x.Selecionado)) + { + return (List)null; + } + return ClientesAtivosInativosFiltrado.Where((ClientesAtivosInativos x) => x.Selecionado).Select((Func)((ClientesAtivosInativos x) => new Documento + { + Controle = new Controle + { + Cliente = new Cliente + { + Id = x.Id, + Nome = x.Nome + } + } + })).ToList(); + case 2: + if (Producao == null || Producao.Count == 0 || !Producao.Any((Producao x) => x.Selecionado)) + { + return (List)null; + } + return Producao.Where((Producao x) => x.Selecionado).Select((Func)((Producao x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 3: + if (ApolicePendente == null || ApolicePendente.Count == 0 || !ApolicePendente.Any((ApolicePendente x) => x.Selecionado)) + { + return (List)null; + } + return ApolicePendente.Where((ApolicePendente x) => x.Selecionado).Select((Func)((ApolicePendente x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 4: + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0 || !RenovacaoFiltrado.Any((Renovacao x) => x.Selecionado)) + { + return (List)null; + } + return RenovacaoFiltrado.Where((Renovacao x) => x.Selecionado).Select((Func)((Renovacao x) => new Documento + { + Id = ((x.Apolice == "PROSPECÇÃO") ? ((DomainBase)x.Prospeccao).Id : ((DomainBase)x.Documento).Id), + Vigencia1 = ((x.Apolice == "PROSPECÇÃO") ? default(DateTime) : x.Documento.Vigencia1), + Vigencia2 = x.VigenciaFinal, + Apolice = x.Apolice, + Endosso = ((x.Apolice == "PROSPECÇÃO") ? "" : x.Documento.Endosso), + VendedorPrincipal = (Vendedor)((!(x.Apolice == "PROSPECÇÃO")) ? ((object)x.Documento.VendedorPrincipal) : ((object)new Vendedor + { + Nome = x.Vendedor + })), + Controle = new Controle + { + Seguradora = ((x.Apolice == "PROSPECÇÃO") ? new Seguradora() : new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }), + Ramo = ((x.Apolice == "PROSPECÇÃO") ? new Ramo() : new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }), + Cliente = ((x.Apolice == "PROSPECÇÃO") ? new Cliente + { + Nome = x.Cliente + } : new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + }) + }, + ItensAtivo = new List + { + new Item + { + Descricao = x.Item + } + } + })).ToList(); + case 5: + if (ComissaoFiltrado == null || ComissaoFiltrado.Count == 0 || !ComissaoFiltrado.Any((Comissao x) => x.Selecionado)) + { + return (List)null; + } + return ComissaoFiltrado.Where((Comissao x) => x.Selecionado).Select((Func)((Comissao x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 6: + case 16: + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0 || !PendenteFiltrado.Any((Pendente x) => x.Selecionado)) + { + return (List)null; + } + return PendenteFiltrado.Where((Pendente x) => x.Selecionado).Select((Func)((Pendente x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 8: + if (Auditoria == null || Auditoria.Count == 0 || !Auditoria.Any((Auditoria x) => x.Selecionado)) + { + return (List)null; + } + return Auditoria.Where((Auditoria x) => x.Selecionado).Select((Func)((Auditoria x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 9: + if (Sinistro == null || Sinistro.Count == 0 || !Sinistro.Any((Sinistro x) => x.Selecionado)) + { + return (List)null; + } + return Sinistro.Where((Sinistro x) => x.Selecionado).Select((Func)((Sinistro x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 10: + if (Sinistro == null || Sinistro.Count == 0 || !Sinistro.Any((Sinistro x) => x.Selecionado)) + { + return (List)null; + } + return Sinistro.Where((Sinistro x) => x.Selecionado).Select((Func)((Sinistro x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + case 12: + if (FaturaPendenteFiltrado == null || FaturaPendenteFiltrado.Count == 0 || !FaturaPendenteFiltrado.Any((FaturaPendente x) => x.Selecionado)) + { + return (List)null; + } + return FaturaPendenteFiltrado.Where((FaturaPendente x) => x.Selecionado).Select((Func)((FaturaPendente x) => new Documento + { + Id = ((DomainBase)x.Documento).Id, + Vigencia1 = x.Documento.Vigencia1, + Vigencia2 = x.Documento.Vigencia2, + Apolice = x.Documento.Apolice, + Endosso = x.Documento.Endosso, + VendedorPrincipal = x.Documento.VendedorPrincipal, + Controle = new Controle + { + Seguradora = new Seguradora + { + Id = ((DomainBase)x.Documento.Controle.Seguradora).Id, + Nome = x.Documento.Controle.Seguradora.Nome + }, + Ramo = new Ramo + { + Id = ((DomainBase)x.Documento.Controle.Ramo).Id, + Nome = x.Documento.Controle.Ramo.Nome + }, + Cliente = new Cliente + { + Id = ((DomainBase)x.Documento.Controle.Cliente).Id, + Nome = x.Documento.Controle.Cliente.Nome + } + } + })).ToList(); + default: + return (List)null; + } + }); + } + + public async void ExibirExtratoDrawer() + { + List list = new List(); + List list2 = new List(); + List list3 = new List(); + List list4 = new List(); + List list5 = new List(); + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 0: + foreach (ClientesAtivosInativos item in ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList()) + { + list3.Add(new ClientesAtivosInativos + { + Id = item.Id, + Nome = item.Nome, + Documento = item.Documento, + Selecionado = item.Selecionado + }); + } + ShowDrawer(new ExtratosDrawer(list3, null, Relatorio), 0, close: false); + return; + case 2: + foreach (Producao item2 in ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList()) + { + list.Add(item2.Documento); + if (item2.Selecionado) + { + list4.Add(((DomainBase)item2.Documento).Id); + } + } + break; + case 4: + foreach (Renovacao item3 in ((IEnumerable)((ItemsControl)((GridRelatorio)Report).DataGrid).Items).Cast().ToList()) + { + if (item3.Documento != null) + { + list.Add(item3.Documento); + if (item3.Selecionado) + { + list4.Add(((DomainBase)item3.Documento).Id); + } + } + if (item3.Prospeccao != null) + { + list2.Add(item3.Prospeccao); + if (item3.Selecionado) + { + list5.Add(((DomainBase)item3.Prospeccao).Id); + } + } + } + break; + } + if (list4.Count == 0 && list5.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + } + else + { + ShowDrawer(new ExtratosDrawer(null, list, Relatorio, list4, list5, list2), 0, close: false); + } + } + + public async void MostrarProtocolo() + { + Relatorio relatorio = Relatorio; + switch (relatorio - 2) + { + case 0: + if (!ProducaoFiltrado.Any((Producao x) => x.Selecionado)) + { + await ShowMessage("NECESSÁRIO SELECIONAR OS DOCUMENTOS PARA EMISSÃO DE PROTOCOLO"); + break; + } + PrepararProtocolo(await ShowProtocoloDialog((from x in ProducaoFiltrado + where x.Selecionado + select x.Documento).ToList())); + break; + case 1: + if (!ApolicePendenteFiltrado.Any((ApolicePendente x) => x.Selecionado)) + { + await ShowMessage("NECESSÁRIO SELECIONAR OS DOCUMENTOS PARA EMISSÃO DE PROTOCOLO"); + break; + } + PrepararProtocolo(await ShowProtocoloDialog((from x in ApolicePendenteFiltrado + where x.Selecionado + select x.Documento).ToList())); + break; + case 2: + if (!RenovacaoFiltrado.Any((Renovacao x) => x.Selecionado)) + { + await ShowMessage("NECESSÁRIO SELECIONAR OS DOCUMENTOS PARA EMISSÃO DE PROTOCOLO"); + break; + } + PrepararProtocolo(await ShowProtocoloDialog((from x in RenovacaoFiltrado + where x.Selecionado + select x.Documento).ToList())); + break; + } + } + + public async void PrepararProtocolo(List itens) + { + if (itens == null) + { + return; + } + Carregando = true; + base.IsEnabled = false; + if (await ShowMessage("DESEJA EMITIR O CHECKLIST?", "SIM", "NÃO")) + { + await EmitirCheckList(itens); + } + List> listaIds = new List>(); + foreach (Documento iten in itens) + { + listaIds.Add(new Tuple(((DomainBase)iten).Id, iten.ObsProtocolo)); + } + await EmitirProtocolos(listaIds, await ShowMessage("DESEJA EMITIR DOIS PROTOCOLOS POR PÁGINA?" + Environment.NewLine + "A QUANTIDADE DE INFORMÃÇÕES PODE IMPEDIR QUE ESSA FUNÇÃO FUNCIONE CORRETAMENTE", "SIM", "NÃO"), itens); + base.IsEnabled = true; + Carregando = false; + } + + public async void AdcionarFiltroPersonalizado() + { + if (FiltroPersonalizado == null) + { + return; + } + string descricao; + if (!SemValor) + { + List list = ((FiltroPersonalizadoSelecionado == null) ? new List() : FiltroPersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade == FiltroPersonalizado.Propriedade && x.SemValor).ToList()); + if (list.Count > 0) + { + list.ForEach(delegate(FiltroPersonalizado x) + { + FiltroPersonalizadoSelecionado.Remove(x); + }); + } + switch (FiltroPersonalizado.Tipo.Name) + { + default: + if (string.IsNullOrEmpty(ValorInicial)) + { + await ShowMessage("O VALOR DEVE SER PREENCHIDO CORRETAMENTE."); + return; + } + descricao = FiltroPersonalizado.Nome + " = " + ValorInicial; + break; + case "DateTime": + { + if (!DateTime.TryParse(ValorInicial, out var result3) || !DateTime.TryParse(ValorFinal, out result3) || DateTime.Parse(ValorInicial) > DateTime.Parse(ValorFinal)) + { + await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE."); + return; + } + descricao = $"{FiltroPersonalizado.Nome}: {DateTime.Parse(ValorInicial):d} até {DateTime.Parse(ValorFinal):d}"; + break; + } + case "Decimal": + { + if (!decimal.TryParse(ValorInicial, out var result2) || !decimal.TryParse(ValorFinal, out result2) || decimal.Parse(ValorInicial) > decimal.Parse(ValorFinal)) + { + await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE."); + return; + } + descricao = $"{FiltroPersonalizado.Nome}: {decimal.Parse(ValorInicial):n2} até {decimal.Parse(ValorFinal):n2}"; + break; + } + case "Int32": + { + if (!int.TryParse(ValorInicial, out var result4) || !int.TryParse(ValorFinal, out result4) || int.Parse(ValorInicial) > int.Parse(ValorFinal)) + { + await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE."); + return; + } + descricao = $"{FiltroPersonalizado.Nome}: {int.Parse(ValorInicial):n0} até {int.Parse(ValorFinal):n0}"; + break; + } + case "Int64": + { + if (!long.TryParse(ValorInicial, out var result) || !long.TryParse(ValorFinal, out result) || long.Parse(ValorInicial) > int.Parse(ValorFinal)) + { + await ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE."); + return; + } + descricao = $"{FiltroPersonalizado.Nome}: {long.Parse(ValorInicial):n0} até {long.Parse(ValorFinal):n0}"; + break; + } + } + } + else + { + List list2 = ((FiltroPersonalizadoSelecionado == null) ? new List() : FiltroPersonalizadoSelecionado.Where((FiltroPersonalizado x) => x.Propriedade == FiltroPersonalizado.Propriedade).ToList()); + if (list2.Count > 0) + { + list2.ForEach(delegate(FiltroPersonalizado x) + { + FiltroPersonalizadoSelecionado.Remove(x); + }); + } + descricao = FiltroPersonalizado.Nome + ": EM BRANCO"; + } + if (FiltroPersonalizadoSelecionado == null) + { + FiltroPersonalizadoSelecionado = new ObservableCollection(); + } + FiltroPersonalizadoSelecionado.Add(new FiltroPersonalizado + { + Nome = FiltroPersonalizado.Nome, + Propriedade = FiltroPersonalizado.Propriedade, + Tipo = FiltroPersonalizado.Tipo, + ValorIncial = ValorInicial, + ValorFinal = ValorFinal, + SemValor = SemValor, + Descricao = descricao + }); + FiltroPersonalizado = null; + ValorInicial = string.Empty; + ValorFinal = string.Empty; + PesquisaPersonalizada(); + } + + public void PesquisaPersonalizada() + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0085: Expected I4, but got Unknown + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 17: + LicenciamentoFiltrado = new ObservableCollection(Licenciamento.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = LicenciamentoFiltrado; + break; + case 27: + PlacaFiltrado = new ObservableCollection(Placas.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = PlacaFiltrado; + break; + case 1: + ClientesAtivosInativosFiltrado = new ObservableCollection(ClientesAtivosInativos.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ClientesAtivosInativosFiltrado; + break; + case 0: + FiltrarRamo(); + break; + case 2: + ProducaoFiltrado = new ObservableCollection(Producao.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ProducaoFiltrado; + break; + case 3: + ApolicePendenteFiltrado = new ObservableCollection(ApolicePendente.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ApolicePendenteFiltrado; + break; + case 4: + RenovacaoFiltrado = new ObservableCollection(Renovacao.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = RenovacaoFiltrado; + break; + case 5: + ComissaoFiltrado = new ObservableCollection(Comissao.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ComissaoFiltrado; + break; + case 6: + case 16: + PendenteFiltrado = new ObservableCollection(Pendente.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = PendenteFiltrado; + break; + case 8: + AuditoriaFiltrado = new ObservableCollection(Auditoria.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = AuditoriaFiltrado; + break; + case 9: + case 10: + SinistroFiltrado = new ObservableCollection(Sinistro.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = SinistroFiltrado; + break; + case 13: + ExtratosFiltrado = new ObservableCollection(Extratos.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ExtratosFiltrado; + break; + case 12: + FaturaPendenteFiltrado = new ObservableCollection(FaturaPendente.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = FaturaPendenteFiltrado; + break; + case 14: + MetaSeguradoraFiltrado = new ObservableCollection(MetaSeguradora.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = MetaSeguradoraFiltrado; + break; + case 15: + MetaVendedorFiltrado = new ObservableCollection(MetaVendedor.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = MetaVendedorFiltrado; + break; + case 18: + TarefaFiltrado = new ObservableCollection(Tarefa.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = TarefaFiltrado; + break; + case 19: + NotaFiscalFiltrado = new ObservableCollection(NotasFiscais.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = NotaFiscalFiltrado; + break; + case 23: + LogsEnvioFiltrado = new ObservableCollection(LogsEnvio.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = LogsEnvioFiltrado; + break; + case 24: + case 25: + LogUtilizacaoFiltrado = new ObservableCollection(LogUtilizacao.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = LogUtilizacaoFiltrado; + break; + case 26: + ApoliceCriticaFiltrado = new ObservableCollection(ApoliceCritica.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ApoliceCriticaFiltrado; + break; + case 28: + EndossoFiltrado = new ObservableCollection(Endossoo.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = EndossoFiltrado; + break; + case 29: + ClassificacaoFiltrado = new ObservableCollection(Classificacao.CustomWhere(FiltroPersonalizadoSelecionado.ToList(), ValorIgual)); + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ClassificacaoFiltrado; + break; + } + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + } + + public async Task ValidateTarefa() + { + bool erro = false; + await ServicoRestriUsuario.BuscarRestricoes(((DomainBase)Recursos.Usuario).Id); + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 17: + if (LicenciamentoFiltrado == null || LicenciamentoFiltrado.Count == 0 || LicenciamentoFiltrado.All((Licenciamento x) => !x.Selecionado)) + { + erro = true; + } + break; + case 1: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || ClientesAtivosInativosFiltrado.All((ClientesAtivosInativos x) => !x.Selecionado)) + { + erro = true; + } + break; + case 0: + if (ClientesAtivosInativosFiltrado == null || ClientesAtivosInativosFiltrado.Count == 0 || ClientesAtivosInativosFiltrado.All((ClientesAtivosInativos x) => !x.Selecionado)) + { + erro = true; + } + break; + case 3: + if (ApolicePendenteFiltrado == null || ApolicePendenteFiltrado.Count == 0 || ApolicePendenteFiltrado.All((ApolicePendente x) => !x.Selecionado)) + { + erro = true; + } + break; + case 2: + if (ProducaoFiltrado == null || ProducaoFiltrado.Count == 0 || ProducaoFiltrado.All((Producao x) => !x.Selecionado)) + { + erro = true; + } + break; + case 4: + if (RenovacaoFiltrado == null || RenovacaoFiltrado.Count == 0 || RenovacaoFiltrado.All((Renovacao x) => !x.Selecionado)) + { + erro = true; + } + break; + case 5: + if (ComissaoFiltrado == null || ComissaoFiltrado.Count == 0 || ComissaoFiltrado.All((Comissao x) => !x.Selecionado)) + { + erro = true; + } + break; + case 6: + case 16: + if (PendenteFiltrado == null || PendenteFiltrado.Count == 0 || PendenteFiltrado.All((Pendente x) => !x.Selecionado)) + { + erro = true; + } + break; + case 9: + case 10: + if (SinistroFiltrado == null || SinistroFiltrado.Count == 0 || SinistroFiltrado.All((Sinistro x) => !x.Selecionado)) + { + erro = true; + } + break; + case 13: + if (ExtratosFiltrado == null || ExtratosFiltrado.Count == 0 || ExtratosFiltrado.All((ExtratoBaixadoRelatorio x) => !x.Selecionado)) + { + erro = true; + } + break; + case 14: + if (MetaSeguradoraFiltrado == null || MetaSeguradoraFiltrado.Count == 0 || MetaSeguradoraFiltrado.All((MetaSeguradoraRelatorio x) => !x.Selecionado)) + { + erro = true; + } + break; + case 15: + if (MetaVendedorFiltrado == null || MetaVendedorFiltrado.Count == 0 || MetaVendedorFiltrado.All((MetaVendedorRelatorio x) => !x.Selecionado)) + { + erro = true; + } + break; + case 7: + erro = true; + break; + case 11: + case 20: + erro = true; + break; + case 8: + if (Auditoria == null || Auditoria.Count == 0 || Auditoria.All((Auditoria x) => !x.Selecionado)) + { + erro = true; + } + break; + case 12: + if (FaturaPendente == null || FaturaPendente.Count == 0 || FaturaPendente.All((FaturaPendente x) => !x.Selecionado)) + { + erro = true; + } + break; + case 27: + if (PlacaFiltrado == null || PlacaFiltrado.Count == 0 || PlacaFiltrado.All((Placas x) => !x.Selecionado)) + { + erro = true; + } + break; + } + if (erro) + { + await ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM ITEM NA LISTA PARA GERAR TAREFAS."); + } + return erro; + } + + public void AdicionarRamo() + { + if (RamoSelecionado != null) + { + if (RamosSelecionados == null) + { + RamosSelecionados = new ObservableCollection(); + } + if (RamosSelecionados.All((Ramo x) => ((DomainBase)x).Id != ((DomainBase)RamoSelecionado).Id)) + { + RamosSelecionados.Add(RamoSelecionado); + } + RamoSelecionado = null; + FiltrarRamo(); + } + } + + public void RemoverRamo(Ramo ramo) + { + if (ramo != null) + { + if (RamosSelecionados.Any((Ramo x) => ((DomainBase)x).Id == ((DomainBase)ramo).Id)) + { + RamosSelecionados.Remove(ramo); + } + FiltrarRamo(); + } + } + + private void FiltrarRamo() + { + List property = ((RamosSelecionados == null) ? new List() : ((IEnumerable)RamosSelecionados).Select((Func)((Ramo x) => new FiltroPersonalizado + { + Nome = x.Nome, + Propriedade = "Ramo", + Tipo = typeof(string), + ValorIncial = x.Nome, + SemValor = false, + Descricao = x.Nome, + Diferente = true + })).ToList()); + ClientesAtivosInativosFiltrado = new ObservableCollection(ClientesAtivosInativos.CustomNot(property)); + if (FiltroPersonalizadoSelecionado != null) + { + ClientesAtivosInativosFiltrado = new ObservableCollection(ClientesAtivosInativosFiltrado.ToList().CustomWhere(FiltroPersonalizadoSelecionado.ToList())); + } + ((ItemsControl)((GridRelatorio)Report).DataGrid).ItemsSource = ClientesAtivosInativosFiltrado; + ((GridRelatorio)Report).SinteticoGrid.ItemsSource = Sintetic; + } + + public async Task Sincronizar() + { + if (LicenseHelper.Produtos.All((Licenca x) => (int)x.Produto != 77) && LicenseHelper.Produtos.All((Licenca x) => (int)x.Produto != 84)) + { + await ShowMessage("VOCÊ AINDA NÃO POSSUI O AGGILIZADOR DE DOCUMENTOS, NAVEGUE POR NOSSO PORTAL E ENCONTRE A OFERTA QUE MAIS ENCAIXE EM SEU DIA-A-DIA."); + Process.Start("https://agger.com.br"); + return; + } + Relatorio relatorio = Relatorio; + if ((int)relatorio != 3) + { + if ((int)relatorio != 16) + { + return; + } + if (PendenteFiltrado == null || !PendenteFiltrado.Any()) + { + await ShowMessage("NÃO HÁ DADOS PARA SINCRONIZAÇÃO"); + return; + } + List ids = PendenteFiltrado.Select((Pendente x) => ((DomainBase)x.ParcelaEntity).Id).ToList(); + int[] array = await _parcelaServico.Sincronizar(Inicio, ids); + if (array[0] == 0) + { + await ShowMessage("NÃO HÁ PARCELAS PENDENTES NO PERIODO SELECIONADO."); + } + else if (array[0] <= 0 || array[1] != 0) + { + Gestor.Application.Actions.Actions.RecarregarRelatorios?.Invoke(Sessao); + ToggleSnackBar($"{array[1]} PARCELAS VINCULADAS"); + } + return; + } + if (ApolicePendenteFiltrado == null || !ApolicePendenteFiltrado.Any()) + { + await ShowMessage("NÃO HÁ DADOS PARA SINCRONIZAÇÃO"); + return; + } + List dados = ApolicePendenteFiltrado.Where(delegate(ApolicePendente x) + { + Documento documento4 = x.Documento; + if (documento4 != null) + { + Controle controle = documento4.Controle; + if (controle != null) + { + Seguradora seguradora = controle.Seguradora; + if (seguradora != null && seguradora.IdAggilizador.HasValue) + { + Documento documento5 = x.Documento; + if (((documento5 != null) ? documento5.Vinculo : null) != null) + { + Documento documento6 = x.Documento; + if (documento6 == null) + { + return false; + } + VinculoDocumento vinculo4 = documento6.Vinculo; + return ((vinculo4 != null) ? new long?(vinculo4.IdApoliceDigital) : null) == 0; + } + return true; + } + } + } + return false; + }).Select((Func)delegate(ApolicePendente x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00e3: Unknown result type (might be due to invalid IL or missing references) + //IL_0103: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_0157: Unknown result type (might be due to invalid IL or missing references) + //IL_016d: Unknown result type (might be due to invalid IL or missing references) + //IL_0184: Expected O, but got Unknown + DadosVinculo val2 = new DadosVinculo + { + Id = ((DomainBase)x.Documento).Id + }; + object proposta; + if (x.Documento.Controle.Seguradora.IdAggilizador.Value != 1 || ((DomainBase)x.Documento.Controle.Ramo).Id != 5) + { + proposta = x.Documento.Proposta; + } + else + { + ObservableCollection result = Task.Run(() => new ItemServico().BuscarItems(((DomainBase)x.Documento).Id, (StatusItem)2)).Result; + object obj; + if (result == null) + { + obj = null; + } + else + { + Item? obj2 = result.FirstOrDefault(); + obj = ((obj2 != null) ? obj2.Auto.Placa : null); + } + proposta = ((string)obj)?.Replace("-", string.Empty); + } + val2.Proposta = (string)proposta; + val2.Apolice = x.Documento.Apolice; + val2.Documento = x.Documento.Controle.Cliente.Documento; + val2.Endosso = x.Documento.PropostaEndosso; + val2.IdSeguradora = x.Documento.Controle.Seguradora.IdAggilizador.Value; + val2.VigenciaInicial = x.Documento.Vigencia1; + val2.Vigenciafinal = x.Documento.Vigencia2; + val2.Vinculo = x.Documento.Vinculo; + return val2; + }).ToList(); + Filtros filtros = new Filtros + { + Inicio = Inicio, + Fim = Fim + }; + int num = await _apoliceServico.Sincronizar(dados, filtros); + Gestor.Application.Actions.Actions.RecarregarRelatorios?.Invoke(Sessao); + if (ApolicePendenteFiltrado.All(delegate(ApolicePendente x) + { + Documento documento3 = x.Documento; + if (documento3 == null) + { + return false; + } + VinculoDocumento vinculo3 = documento3.Vinculo; + return ((vinculo3 != null) ? new long?(vinculo3.IdApoliceDigital) : null) == 0; + })) + { + await ShowMessage("NENHUM NOVO DOCUMENTO FOI SINCRONIZADO"); + return; + } + if (num == 0) + { + if (!(await ShowMessage("NENHUM NOVO DOCUMENTO FOI SINCRONIZADO, DESEJA IMPORTAR OS DOCUMENTOS ANTERIORMENTE SINCRONIZADOS?", "SIM", "NÃO"))) + { + return; + } + } + else + { + ToggleSnackBar($"{num} DOCUMENTOS SINCRONIZADOS"); + if (!(await ShowMessage($"{ApolicePendenteFiltrado.Count(delegate(ApolicePendente x) + { + Documento documento2 = x.Documento; + if (documento2 == null) + { + return false; + } + VinculoDocumento vinculo2 = documento2.Vinculo; + return ((vinculo2 != null) ? new long?(vinculo2.IdApoliceDigital) : null) > 0; + })} DOCUMENTOS SINCRONIZADOS, DESEJA INICIAR A IMPORTAÇÃO DESSES DOCUMENTOS?", "SIM", "NÃO"))) + { + return; + } + } + List ids2 = (from x in ApolicePendenteFiltrado.Where(delegate(ApolicePendente x) + { + Documento documento = x.Documento; + if (documento == null) + { + return false; + } + VinculoDocumento vinculo = documento.Vinculo; + return ((vinculo != null) ? new long?(vinculo.IdApoliceDigital) : null) > 0; + }) + select x.Documento.Vinculo.IdApoliceDigital).ToList(); + await DownloadAll(ids2, (TipoArquivoVinculo)1); + Parameters val = new Parameters(); + val.Beta = false; + val.Type = 4; + val.Application = "Agger.ImportPDF.exe"; + val.Directory = "Agger.Import"; + val.Arguments = $"{((DomainBase)Recursos.Empresa).Id} {((DomainBase)Recursos.Usuario).Id} NOVOGESTOR PERFIL:{ApplicationHelper.Subkey} SERIAL:{ApplicationHelper.NumeroSerial}"; + val.Run = true; + ((Window)new DownloadWindow(val)).Show(); + } + + public async Task CarregarAjuda() + { + if (!Ajuda.Any((AjudaTela x) => (int)x.Tela == int.Parse(EnumHelper.GetOldValue(Relatorio)))) + { + CarregandoAjuda = true; + List list = await Connection.Get>($"Help/{int.Parse(EnumHelper.GetOldValue(Relatorio))}"); + if (list != null) + { + Ajuda = new ObservableCollection(list); + CarregandoAjuda = false; + } + } + } + + public async Task GerarPlanilhaCompleta() + { + RestricaoUsuario? obj = ((IEnumerable)(await ServicoRestriUsuario.BuscarRestricoes(((DomainBase)Recursos.Usuario).Id))).FirstOrDefault((Func)((RestricaoUsuario x) => (int)x.Tipo == 99)); + if (obj != null && obj.Restricao) + { + await ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA ACESSAR O PLANILHA COMPLETA"); + return; + } + if ((Fim - Inicio).TotalDays > 31.0) + { + await ShowMessage("NÃO É POSSÍVEL GERAR A PLANILHA COMPLETA COM INTERVALO MAIOR QUE 31 DIAS FILTRADOS."); + return; + } + Loading(isLoading: true); + List idsProspeccoes = new List(); + new List(); + bool configFranquia = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 40); + bool configSomaPremio = false; + Relatorio relatorio = Relatorio; + List list; + List idsFaturas; + if ((int)relatorio != 2) + { + if ((int)relatorio != 4) + { + Loading(isLoading: false); + return; + } + configSomaPremio = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 31); + RenovacaoFiltrado?.Where((Renovacao x) => x.Selecionado).ToList(); + list = (from x in RenovacaoFiltrado?.Where((Renovacao x) => x.Selecionado && x.Documento != null && !x.TipoPagamento.Equals("FATURA")) + select ((DomainBase)x.Documento).Id).ToList() ?? new List(); + idsFaturas = (from x in RenovacaoFiltrado?.Where((Renovacao x) => x.Selecionado && x.Documento != null && x.TipoPagamento.Equals("FATURA")) + select ((DomainBase)x.Documento).Id).ToList() ?? new List(); + idsProspeccoes = (from x in RenovacaoFiltrado?.Where((Renovacao x) => x.Selecionado && x.Prospeccao != null) + select ((DomainBase)x.Prospeccao).Id).ToList() ?? new List(); + if (list.Count == 0 && idsFaturas.Count == 0 && idsProspeccoes.Count == 0) + { + await ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM DOCUMENTO"); + return; + } + } + else + { + list = (from x in ProducaoFiltrado?.Where((Producao x) => x.Selecionado && x.Tipo != 2) + select ((DomainBase)x.Documento).Id).ToList() ?? new List(); + idsFaturas = (from x in ProducaoFiltrado?.Where((Producao x) => x.Selecionado && x.Tipo == 2) + select ((DomainBase)x.Documento).Id).ToList() ?? new List(); + if (list.Count == 0 && idsFaturas.Count == 0) + { + await ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM DOCUMENTO"); + return; + } + } + List list2 = ((list == null || list.Count <= 0) ? new List() : (await _apoliceServico.BuscarPlanilhaCompleta(list, configFranquia, configSomaPremio))); + List planilha2 = list2; + List list3 = idsFaturas; + list2 = ((list3 == null || list3.Count <= 0) ? new List() : (await _apoliceServico.BuscarPlanilhaCompletaFatura(idsFaturas, Relatorio, Filtros.Inicio, Filtros.Fim, configFranquia, configSomaPremio))); + List planilhaFatura = list2; + List list4 = idsProspeccoes; + list2 = ((list4 == null || list4.Count <= 0) ? new List() : (await _apoliceServico.BuscarPlanilhaCompletaProspeccao(idsProspeccoes))); + List list5 = list2; + if (planilha2 == null || planilhaFatura == null || list5 == null) + { + await ShowMessage("ERRO AO GERAR PLANILHA COMPLETA, TENTE NOVAMENTE MAIS TARDE."); + Loading(isLoading: false); + return; + } + planilha2.AddRange(planilhaFatura); + planilha2.AddRange(list5); + List list6 = planilha2; + if (list6 != null && list6.Count == 0) + { + await ShowMessage("NÃO HÁ DADOS PARA EMISSÃO DA PLANILHA COMPLETA."); + Loading(isLoading: false); + return; + } + planilha2 = (((int)Relatorio == 4) ? planilha2.OrderBy((PlanilhaCompleta x) => x.VigenciaFinal).ToList() : planilha2.OrderBy((PlanilhaCompleta x) => x.VigenciaInicial).ToList()); + string text = ""; + string fileName; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41)) + { + FolderBrowserDialog val = new FolderBrowserDialog(); + try + { + if (1 != (int)((CommonDialog)val).ShowDialog()) + { + return; + } + text = val.SelectedPath + "\\"; + Directory.CreateDirectory(text); + } + finally + { + ((IDisposable)val)?.Dispose(); + } + fileName = text + EnumHelper.GetDescription(Relatorio) + " " + Functions.GetNetworkTime().Date.ToShortDateString().Replace("/", "") + ".xlsx"; + } + else + { + text = Path.GetTempPath(); + fileName = $"{text}{Guid.NewGuid()}.xlsx"; + } + (await Funcoes.GerarXls(new XLWorkbook(), "PLANILHA COMPLETA", planilha2, new List())).SaveAs(fileName); + Process.Start(fileName); + Loading(isLoading: false); + } + + public async Task CarregarConfiguracoes() + { + List parametros = new List(); + List list = await new ConfuguracoesServico().BuscarParametros(Relatorio); + Relatorio relatorio = Relatorio; + switch ((int)relatorio) + { + case 0: + case 1: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 2: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 3: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 18: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 4: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 5: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 6: + case 16: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 9: + case 10: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 23: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 8: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 13: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 12: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 14: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 15: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 11: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 17: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 27: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 7: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 19: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 20: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 24: + case 25: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 26: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 28: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + case 29: + parametros = Funcoes.ColunasRelatorio(Relatorio, list); + break; + } + ParametrosRelatorio = new ObservableCollection(parametros); + ParametrosRelatorioAdicionados = new ObservableCollection(list.OrderBy((ParametrosRelatorio x) => x.Ordem)); + List list2 = await new ConfuguracoesServico().BuscarParametroTotalizacaoAsync(Relatorio); + ParametrosTotalizacao = new ObservableCollection(Funcoes.TotalizacoesRelatorio(Relatorio, list2)); + ParametrosTotalizacaoAdicionados = new ObservableCollection(list2); + } + + public async Task SalvarParametros() + { + if (!(await new ConfuguracoesServico().Salvar(ParametrosRelatorioAdicionados.ToList(), ParametrosRelatorio.ToList()))) + { + return false; + } + if (!(await new ConfuguracoesServico().SalvarTotalizacoes(ParametrosTotalizacaoAdicionados.ToList(), ParametrosTotalizacao.ToList()))) + { + return false; + } + RegistrarAcao("SALVOU CONFIGURAÇÃO DO RELATORIO", Relatorio, Filtros); + await CarregarConfiguracoes(); + return true; + } + + public void AdicionarParametro(ParametrosRelatorio parametro) + { + if (parametro != null && parametro.Header != "SELECIONE UM CAMPO") + { + ParametrosRelatorio.Remove(parametro); + ParametrosRelatorioAdicionados.Add(parametro); + SelectedParametrosRelatorio = ParametrosRelatorio[0]; + } + } + + public void AdicionarTotalizacao(ParametrosTotalizacao parametro) + { + if (parametro != null && parametro.Header != "SELECIONE UMA TOTALIZAÇÃO") + { + ParametrosTotalizacao.Remove(parametro); + ParametrosTotalizacaoAdicionados.Add(parametro); + SelectedParametrosTotalizacao = ParametrosTotalizacao[0]; + } + } + + public void ExcluirParametro(ParametrosRelatorio parametro) + { + if (parametro != null) + { + ParametrosRelatorioAdicionados.Remove(parametro); + ParametrosRelatorio.Add(parametro); + ParametrosRelatorio = new ObservableCollection(ParametrosRelatorio.OrderBy((ParametrosRelatorio x) => x.Header)); + } + } + + public void ExcluirTotalizacao(ParametrosTotalizacao parametro) + { + if (parametro != null) + { + ParametrosTotalizacaoAdicionados.Remove(parametro); + ParametrosTotalizacao.Add(parametro); + ParametrosTotalizacao = new ObservableCollection(ParametrosTotalizacao.OrderBy((ParametrosTotalizacao x) => x.Header)); + } + } + + public void SubirParametro(ParametrosRelatorio parametro) + { + if (parametro != null) + { + int num = ParametrosRelatorioAdicionados.IndexOf(parametro); + if (num != 0) + { + ParametrosRelatorioAdicionados.Move(num, num - 1); + } + } + } + + public void DescerParametro(ParametrosRelatorio parametro) + { + if (parametro != null) + { + int num = ParametrosRelatorioAdicionados.IndexOf(parametro); + if (num != ParametrosRelatorioAdicionados.Count - 1) + { + ParametrosRelatorioAdicionados.Move(num, num + 1); + } + } + } + + internal async Task> Filtrar(string value) + { + return await Task.Run(() => FiltrarUsuario(value)); + } + + public List FiltrarUsuario(string filter) + { + UsuariosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection(Usuarios) : new ObservableCollection(from x in Usuarios + where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) + orderby !x.Excluido descending, x.Nome + select x)); + return UsuariosFiltrados.ToList(); + } + + private void LimparFiltroUsuario() + { + ExtensionMethods.ForEach((IEnumerable)UsuariosFiltrados, (Action)delegate(Usuario x) + { + x.Selecionado = false; + }); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Relatorios/SinteticoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Relatorios/SinteticoViewModel.cs new file mode 100644 index 0000000..c3adb1d --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Relatorios/SinteticoViewModel.cs @@ -0,0 +1,445 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Forms; +using System.Windows.Media; +using ClosedXML.Excel; +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.Model; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Helpers; +using Gestor.Model.Attributes; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Relatorios; +using LiveCharts; +using LiveCharts.Definitions.Series; +using LiveCharts.Helpers; +using LiveCharts.Wpf; +using NReco.PdfGenerator; + +namespace Gestor.Application.ViewModels.Relatorios; + +public class SinteticoViewModel : BaseSegurosViewModel +{ + private Visibility _unicaPaginaVisibility = (Visibility)2; + + private Geometry _maximizeRestore = Geometry.Parse((string)Application.Current.Resources[(object)"Restore"]); + + private ObservableCollection _series; + + private string _titulotela = $"RELATÓRIO SINTÉTICO | VERSÃO GESTOR {ApplicationHelper.Versao}"; + + public Visibility UnicaPaginaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _unicaPaginaVisibility; + } + 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) + _unicaPaginaVisibility = value; + OnPropertyChanged("UnicaPaginaVisibility"); + } + } + + public string Relatorio { get; set; } + + public Geometry MaximizeRestore + { + get + { + return _maximizeRestore; + } + set + { + _maximizeRestore = value; + OnPropertyChanged("MaximizeRestore"); + } + } + + public ObservableCollection Series + { + get + { + return _series; + } + set + { + _series = value; + OnPropertyChanged("Series"); + } + } + + public string Titulotela + { + get + { + return _titulotela; + } + set + { + _titulotela = value; + OnPropertyChanged("Titulotela"); + } + } + + public SinteticoViewModel(List sintetico, string relatorio) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + Relatorio = relatorio; + GerarSintetico(sintetico); + } + + private void GerarSintetico(List sintetico) + { + //IL_00d6: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Expected O, but got Unknown + //IL_0117: Unknown result type (might be due to invalid IL or missing references) + //IL_0169: Unknown result type (might be due to invalid IL or missing references) + //IL_016e: Unknown result type (might be due to invalid IL or missing references) + //IL_0180: Unknown result type (might be due to invalid IL or missing references) + //IL_0189: Expected O, but got Unknown + //IL_02f2: Unknown result type (might be due to invalid IL or missing references) + //IL_02f7: Unknown result type (might be due to invalid IL or missing references) + //IL_03f4: Unknown result type (might be due to invalid IL or missing references) + //IL_03f9: Unknown result type (might be due to invalid IL or missing references) + //IL_0203: Unknown result type (might be due to invalid IL or missing references) + //IL_0208: Unknown result type (might be due to invalid IL or missing references) + //IL_031e: Unknown result type (might be due to invalid IL or missing references) + //IL_0356: Unknown result type (might be due to invalid IL or missing references) + //IL_0361: Unknown result type (might be due to invalid IL or missing references) + //IL_0420: Unknown result type (might be due to invalid IL or missing references) + //IL_0449: Unknown result type (might be due to invalid IL or missing references) + //IL_0451: Unknown result type (might be due to invalid IL or missing references) + //IL_045c: Unknown result type (might be due to invalid IL or missing references) + //IL_022f: Unknown result type (might be due to invalid IL or missing references) + //IL_0257: Unknown result type (might be due to invalid IL or missing references) + //IL_025f: Unknown result type (might be due to invalid IL or missing references) + //IL_036f: Unknown result type (might be due to invalid IL or missing references) + //IL_037c: Expected O, but got Unknown + //IL_046a: Unknown result type (might be due to invalid IL or missing references) + //IL_0477: Expected O, but got Unknown + //IL_026d: Unknown result type (might be due to invalid IL or missing references) + //IL_027a: Expected O, but got Unknown + //IL_071b: Unknown result type (might be due to invalid IL or missing references) + //IL_0720: Unknown result type (might be due to invalid IL or missing references) + //IL_072b: Unknown result type (might be due to invalid IL or missing references) + //IL_0733: Unknown result type (might be due to invalid IL or missing references) + //IL_073e: Unknown result type (might be due to invalid IL or missing references) + //IL_0746: Unknown result type (might be due to invalid IL or missing references) + //IL_0589: Unknown result type (might be due to invalid IL or missing references) + //IL_058e: Unknown result type (might be due to invalid IL or missing references) + //IL_0599: Unknown result type (might be due to invalid IL or missing references) + //IL_05a6: Unknown result type (might be due to invalid IL or missing references) + //IL_05ae: Unknown result type (might be due to invalid IL or missing references) + //IL_076e: Unknown result type (might be due to invalid IL or missing references) + //IL_077e: Expected O, but got Unknown + //IL_05cd: Unknown result type (might be due to invalid IL or missing references) + //IL_05dd: Expected O, but got Unknown + UnicaPaginaVisibility = (Visibility)((!(Relatorio == "RELATÓRIO DE FECHAMENTO")) ? 2 : 0); + Series = new ObservableCollection(); + PropertyInfo[] properties = ((object)sintetico.First()).GetType().GetProperties(); + foreach (PropertyInfo parentProperty in properties) + { + if (parentProperty.Name == "ValidationEvent" || parentProperty.Name == "Agrupamento" || sintetico.All((Sintetico s) => ((object)s).GetType().GetProperty(parentProperty.Name)?.GetValue(s, null) == null)) + { + continue; + } + object obj = parentProperty.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); + if (obj == null) + { + continue; + } + string description = ((DescriptionAttribute)obj).Description; + SinteticoSource sinteticoSource = new SinteticoSource + { + Titulo = description, + Colecao = new SeriesCollection(), + Lista = new ObservableCollection() + }; + object obj2 = parentProperty.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault(); + string text = ""; + if (obj2 != null) + { + text = ((TipoAttribute)obj2).Description; + } + sintetico = sintetico.OrderByDescending((Sintetico x) => parentProperty.GetValue(x, null)).ToList(); + foreach (Sintetico x2 in sintetico) + { + bool flag = false; + PieSeries val = new PieSeries + { + Title = x2.Agrupamento, + DataLabels = false + }; + IChartValues values; + if (!(text == "PERCENTUAL")) + { + if (!(text == "VALOR")) + { + flag = (int)parentProperty.GetValue(x2) < 0; + ChartValues obj3 = new ChartValues(); + ((NoisyCollection)(object)obj3).Add(Math.Abs((int)parentProperty.GetValue(x2))); + values = (IChartValues)(object)obj3; + sinteticoSource.Lista.Add(new ValorSintetico + { + Indice = x2.Agrupamento + (flag ? " (-)" : ""), + Valor = decimal.Parse(parentProperty.GetValue(x2).ToString()), + Formato = text, + Sinal = (Sinal)(flag ? 1 : 0), + NomeRelatorio = description + }); + ((Series)val).LabelPoint = (ChartPoint chartPoint) => ((int)parentProperty.GetValue(x2)).ToString("n"); + } + else + { + flag = (decimal)parentProperty.GetValue(x2) < 0m; + ChartValues obj4 = new ChartValues(); + ((NoisyCollection)(object)obj4).Add(Math.Abs((decimal)parentProperty.GetValue(x2))); + values = (IChartValues)(object)obj4; + sinteticoSource.Lista.Add(new ValorSintetico + { + Indice = x2.Agrupamento + (flag ? " (-)" : ""), + Valor = Math.Round((decimal)parentProperty.GetValue(x2), 2), + Formato = text, + Unidate = "R$", + Sinal = (Sinal)(flag ? 1 : 0), + NomeRelatorio = description + }); + ((Series)val).LabelPoint = (ChartPoint chartPoint) => ((decimal)parentProperty.GetValue(x2)).ToString("n2"); + } + } + else + { + flag = (decimal)parentProperty.GetValue(x2) < 0m; + ChartValues obj5 = new ChartValues(); + ((NoisyCollection)(object)obj5).Add(Math.Abs((decimal)parentProperty.GetValue(x2))); + values = (IChartValues)(object)obj5; + sinteticoSource.Lista.Add(new ValorSintetico + { + Indice = x2.Agrupamento + (flag ? " (-)" : ""), + Valor = Math.Round((decimal)parentProperty.GetValue(x2) * 0.01m, 2), + Unidate = "%", + Sinal = (Sinal)(flag ? 1 : 0), + NomeRelatorio = description + }); + ((Series)val).LabelPoint = (ChartPoint chartPoint) => ((decimal)parentProperty.GetValue(x2)).ToString("n2"); + } + ((Series)val).Values = values; + ((NoisyCollection)(object)sinteticoSource.Colecao).Add((ISeriesView)(object)val); + } + if (obj2 != null && !(text == "PERCENTUAL")) + { + if (!(text == "VALOR")) + { + if (!Relatorio.Equals("RELATÓRIO DE FECHAMENTO")) + { + int num = sintetico.Sum((Sintetico x) => (int)parentProperty.GetValue(x, null)); + if (num != 0) + { + foreach (ValorSintetico listum in sinteticoSource.Lista) + { + listum.Porcentagem = (100m * listum.Valor / (decimal)num).ToString("F") + "%"; + } + } + sinteticoSource.Lista.Add(new ValorSintetico + { + Indice = "TOTAL", + Valor = num, + Formato = text, + Sinal = (Sinal)(sintetico.Sum((Sintetico x) => (int)parentProperty.GetValue(x, null)) < 0), + Porcentagem = "100%" + }); + } + else + { + int num2 = sintetico.Sum((Sintetico x) => (int)parentProperty.GetValue(x, null)); + if (num2 != 0) + { + foreach (ValorSintetico listum2 in sinteticoSource.Lista) + { + listum2.Porcentagem = (100m * listum2.Valor / (decimal)num2).ToString("F") + "%"; + } + } + } + } + else if (!Relatorio.Equals("RELATÓRIO DE FECHAMENTO")) + { + decimal num3 = Math.Round(sintetico.Sum((Sintetico x) => (decimal)parentProperty.GetValue(x, null)), 2); + if (num3 != 0m) + { + foreach (ValorSintetico listum3 in sinteticoSource.Lista) + { + listum3.Porcentagem = (100m * listum3.Valor / num3).ToString("F") + "%"; + } + } + sinteticoSource.Lista.Add(new ValorSintetico + { + Indice = "TOTAL", + Valor = num3, + Unidate = "R$", + Formato = text, + Sinal = (Sinal)((sintetico.Sum((Sintetico x) => (decimal)parentProperty.GetValue(x, null)) < 0m) ? 1 : 0), + Porcentagem = "100%" + }); + } + else + { + decimal num4 = Math.Round(sintetico.Sum((Sintetico x) => (decimal)parentProperty.GetValue(x, null)), 2); + if (num4 != 0m) + { + foreach (ValorSintetico listum4 in sinteticoSource.Lista) + { + listum4.Porcentagem = (100m * listum4.Valor / num4).ToString("F") + "%"; + } + } + } + } + Series.Add(sinteticoSource); + } + } + + public async Task Print(SinteticoSource sintetico) + { + string grafico = Funcoes.GerarGrafico(sintetico.Lista.ToList()); + string dados = await Funcoes.GenerateTable(GerarRelacao(sintetico.Lista.ToList()), new List(), grafico: true); + string value = Funcoes.ExportarHtml(new TipoRelatorio + { + Nome = sintetico.Titulo, + Inicio = (sintetico.DateStart ?? DateTime.MinValue), + Fim = (sintetico.DateFinal ?? DateTime.MinValue) + }, dados, "60", "landscape", search: false, grafico); + string tempPath = Path.GetTempPath(); + string text = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, new Regex("[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]").Replace(Relatorio, ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(value); + streamWriter.Close(); + Process.Start(text); + } + + public async Task PrintUnica(SinteticoSource sintetico) + { + List> list = new List>(); + foreach (SinteticoSource item in Series) + { + list.Add(item.Lista.ToList()); + } + string grafico = Funcoes.GerarGraficoUnico(list); + string dados = await Funcoes.GenerateMultipleTable(GerarRelacao(list), new List(), grafico: true); + string value = Funcoes.ExportarMultipleHtml(new TipoRelatorio + { + Nome = "RELATÓRIOS", + Inicio = (sintetico.DateStart ?? DateTime.MinValue), + Fim = (sintetico.DateFinal ?? DateTime.MinValue) + }, dados, "60", "landscape", search: false, grafico); + string tempPath = Path.GetTempPath(); + string text = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, new Regex("[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]").Replace(Relatorio, ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(value); + streamWriter.Close(); + Process.Start(text); + } + + private static List GerarRelacao(List lista) + { + return ((IEnumerable)lista).Select((Func)((ValorSintetico x) => new Listagem + { + Agrupamento = x.Indice, + Valor = ((x.Formato == "VALOR") ? x.Valor.ToString("c2") : ((x.Formato == "PERCENTUAL") ? x.Valor.ToString("p2") : x.Valor.ToString(new CultureInfo("pt-BR")))), + NomeRelatorio = x.NomeRelatorio + })).ToList(); + } + + private static List> GerarRelacao(List> listas) + { + List> list = new List>(); + foreach (List lista in listas) + { + list.Add(GerarRelacao(lista)); + } + return list; + } + + public async Task GerarPdf(SinteticoSource sintetico) + { + string dados = await Funcoes.GenerateTable(GerarRelacao(sintetico.Lista.ToList()), new List()); + string text = Funcoes.ExportarHtml(new TipoRelatorio + { + Nome = sintetico.Titulo, + Inicio = DateTime.MinValue, + Fim = DateTime.MinValue + }, dados); + NRecoHtmlToPdfConverter nRecoHtmlToPdfConverter = new NRecoHtmlToPdfConverter(); + ((HtmlToPdfConverter)nRecoHtmlToPdfConverter).Orientation = (PageOrientation)1; + ((HtmlToPdfConverter)nRecoHtmlToPdfConverter).Zoom = 0.5f; + byte[] bytes = ((HtmlToPdfConverter)nRecoHtmlToPdfConverter).GeneratePdf(text); + SaveFileDialog sfd = new SaveFileDialog(); + try + { + ((FileDialog)sfd).Filter = "All Files|*.*"; + ((FileDialog)sfd).FileName = $"RELATORIO FINANCEIRO_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}"; + if (1 != (int)((CommonDialog)sfd).ShowDialog()) + { + return; + } + if (File.Exists(((FileDialog)sfd).FileName + ".pdf")) + { + await ShowMessage("JÁ EXISTE UM ARQUIVO COM O NOME DE " + ((FileDialog)sfd).FileName + ".pdf NA PASTA SELECIONADA. " + Environment.NewLine + "TENTE NOVAMENTE EM OUTRA PASTA."); + return; + } + File.WriteAllBytes(((FileDialog)sfd).FileName + ".pdf", bytes); + Process.Start(((FileDialog)sfd).FileName + ".pdf"); + } + finally + { + ((IDisposable)sfd)?.Dispose(); + } + } + + public async Task GerarExcel(SinteticoSource sintetico) + { + List analitico = GerarRelacao(sintetico.Lista.ToList()); + string text = ""; + string fileName; + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 41)) + { + FolderBrowserDialog val = new FolderBrowserDialog(); + try + { + if (1 != (int)((CommonDialog)val).ShowDialog()) + { + return; + } + text = val.SelectedPath + "\\"; + Directory.CreateDirectory(text); + } + finally + { + ((IDisposable)val)?.Dispose(); + } + fileName = text + "SINTETICO " + Functions.GetNetworkTime().Date.ToShortDateString().Replace("/", "") + ".xlsx"; + } + else + { + text = Path.GetTempPath(); + fileName = $"{text}{Guid.NewGuid()}.xlsx"; + } + (await Funcoes.GerarXls(new XLWorkbook(), "SINTÉTICO", analitico)).SaveAs(fileName); + Process.Start(fileName); + } +} -- cgit v1.2.3