From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../ViewModels/Relatorios/RelatorioViewModel.cs | 14619 +++++++++++++++++++ 1 file changed, 14619 insertions(+) create mode 100644 Gestor.Application/ViewModels/Relatorios/RelatorioViewModel.cs (limited to 'Gestor.Application/ViewModels/Relatorios/RelatorioViewModel.cs') diff --git a/Gestor.Application/ViewModels/Relatorios/RelatorioViewModel.cs b/Gestor.Application/ViewModels/Relatorios/RelatorioViewModel.cs new file mode 100644 index 0000000..f85b039 --- /dev/null +++ b/Gestor.Application/ViewModels/Relatorios/RelatorioViewModel.cs @@ -0,0 +1,14619 @@ +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.Generic; +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; +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.Reflection; +using System.Runtime.CompilerServices; +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; + +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 = new Func((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_Id()); + + private readonly Func funcProducaoSegurosNovos = new Func((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_Situacao() == 1); + + private readonly Func funcProducaoSegurosRenovacao = new Func((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_Situacao() == 2); + + private readonly Func funcProducaoNegociosNovos = new Func((Gestor.Model.Domain.Relatorios.Producao.Producao p) => { + NegocioCorretora? negocioCorretora = p.get_Documento().get_NegocioCorretora(); + return negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue; + }); + + private readonly Func funcProducaoNegociosProprios = new Func((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_NegocioCorretora().GetValueOrDefault() == 1); + + private bool _totalizacao = true; + + private bool _enableEmpresa; + + private bool _apelido; + + private List _empresas; + + private Gestor.Model.Domain.Common.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 Gestor.Model.Common.Relatorio _relatorio = 2; + + private bool _extratosEnabled; + + private Visibility _planilhaVisibility; + + private object _report; + + private bool _permitirFiltrosPersonalizados; + + private Visibility _filtrosPersonalizados = Visibility.Collapsed; + + private bool _somenteNaoPagos; + + private bool _visibilityDesconsiderarNegativos = Recursos.Configuracoes.Any(new Func((ConfiguracaoSistema x) => x.get_Configuracao() == 50)); + + private bool _desconsiderarNegativos; + + private bool _segundaViaReciboPagamento; + + private bool _documentosEmitidos; + + private bool _sinteticosPagamento; + + private bool _visibilityUsuarios; + + private Visibility _visibilityDocumentoAtivo; + + private Visibility _visibilityReferencia = Visibility.Collapsed; + + private Visibility _visibilityOrdem = Visibility.Collapsed; + + 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 Gestor.Model.Common.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.Collapsed; + + 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 = Recursos.Seguradoras.Where(new Func((Seguradora x) => x.get_Ativo())).OrderBy(new Func((Seguradora x) => x.get_Nome())).ToList(); + + private List _ramos = Recursos.Ramos.Where(new Func((Ramo x) => x.get_Ativo())).OrderBy(new Func((Ramo x) => x.get_Nome())).ToList(); + + private List _notasFiscais = new List(); + + private bool _inativo = true; + + private List _vendedores = new List(); + + private List _tipoVendedor = Recursos.TipoVendedor.Where(new Func((Gestor.Model.Domain.Seguros.TipoVendedor x) => x.get_Ativo().GetValueOrDefault())).OrderBy(new Func((Gestor.Model.Domain.Seguros.TipoVendedor x) => x.get_Descricao())).ToList(); + + private List _produtos = Recursos.Produtos.Where(new Func((Gestor.Model.Domain.Seguros.Produto x) => x.get_Ativo())).OrderBy(new Func((Gestor.Model.Domain.Seguros.Produto x) => x.get_Nome())).ToList(); + + private List _estipulantes = Recursos.Estipulantes.Where(new Func((Estipulante x) => { + if (Recursos.Usuario.get_IdEmpresa() != (long)1 && Recursos.Usuario.get_IdEmpresa() != x.get_IdEmpresa()) + { + return false; + } + return x.get_Ativo(); + })).OrderBy(new Func((Estipulante x) => x.get_Nome())).ToList(); + + private readonly static List NegocioList; + + private List _negocios = RelatorioViewModel.NegocioList; + + private readonly static List TipoSegurosList; + + private List _tipoSeguros = RelatorioViewModel.TipoSegurosList; + + private bool _isVisibleGrid1 = true; + + private bool _isVisibleGrid2 = true; + + private bool _isVisibleGrid3 = true; + + private bool _isVisibleGrid4 = true; + + private List _filtroRelatorioPersonalizado; + + private Gestor.Model.Domain.Relatorios.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.Collapsed; + + private Visibility _visibilityOpcoesFiltros = Visibility.Collapsed; + + 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.Collapsed; + + private string _head; + + private List _parcelasEspeciais; + + private ObservableCollection _ajuda; + + private bool _carregandoAjuda; + + private ObservableCollection _parametrosRelatorio; + + private ObservableCollection _parametrosRelatorioAdicionados; + + private ObservableCollection _parametrosTotalizacao; + + private ObservableCollection _parametrosTotalizacaoAdicionados; + + private bool _isCampo; + + private Gestor.Model.Domain.Relatorios.ParametrosRelatorio _selectedParametrosRelatorio; + + private Gestor.Model.Domain.Relatorios.ParametrosTotalizacao _selectedParametrosTotalizacao; + + private ObservableCollection _usuariosFiltrados; + + public Gestor.Model.Common.Agrupamento Agrupamento + { + get + { + return this._agrupamento; + } + set + { + this._agrupamento = value; + base.OnPropertyChanged("Agrupamento"); + } + } + + public ObservableCollection Ajuda + { + get + { + return this._ajuda; + } + set + { + this._ajuda = value; + base.OnPropertyChanged("Ajuda"); + } + } + + public bool? AllSelectedEstipulante + { + get + { + return this._allSelectedEstipulante; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedEstipulante; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedEstipulante = value; + this.AllSelectedChanged(7); + this.Estipulantes = new List(this.Estipulantes); + base.OnPropertyChanged("AllSelectedEstipulante"); + } + } + + public bool? AllSelectedNegocio + { + get + { + return this._allSelectedNegocio; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedNegocio; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedNegocio = value; + this.AllSelectedChanged(5); + this.Negocios = new List(this.Negocios); + base.OnPropertyChanged("AllSelectedNegocio"); + } + } + + public bool? AllSelectedProduto + { + get + { + return this._allSelectedProduto; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedProduto; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedProduto = value; + this.AllSelectedChanged(6); + this.Produtos = new List(this.Produtos); + base.OnPropertyChanged("AllSelectedProduto"); + } + } + + public bool? AllSelectedRamo + { + get + { + return this._allSelectedRamo; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedRamo; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedRamo = value; + this.AllSelectedChanged(1); + this.Ramos = new List(this.Ramos); + base.OnPropertyChanged("AllSelectedRamo"); + } + } + + public bool? AllSelectedSeguradora + { + get + { + return this._allSelectedSeguradora; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedSeguradora; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedSeguradora = value; + this.AllSelectedChanged(0); + this.Seguradoras = new List(this.Seguradoras); + base.OnPropertyChanged("AllSelectedSeguradora"); + } + } + + public bool? AllSelectedStatus + { + get + { + return this._allSelectedStatus; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedStatus; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedStatus = value; + this.AllSelectedChanged(3); + this.TipoSeguros = new List(this.TipoSeguros); + base.OnPropertyChanged("AllSelectedStatus"); + } + } + + public bool? AllSelectedTipoVendedor + { + get + { + return this._allSelectedTipoVendedor; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedTipoVendedor; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedTipoVendedor = value; + this.AllSelectedChanged(4); + this.TipoVendedor = new List(this.TipoVendedor); + base.OnPropertyChanged("AllSelectedTipoVendedor"); + } + } + + public bool? AllSelectedVendedor + { + get + { + return this._allSelectedVendedor; + } + set + { + bool? nullable = value; + bool? nullable1 = this._allSelectedVendedor; + if (nullable.GetValueOrDefault() == nullable1.GetValueOrDefault() & nullable.HasValue == nullable1.HasValue) + { + return; + } + this._allSelectedVendedor = value; + this.AllSelectedChanged(2); + this.Vendedores = new List(this.Vendedores); + base.OnPropertyChanged("AllSelectedVendedor"); + } + } + + public bool Apelido + { + get + { + return this._apelido; + } + set + { + this._apelido = value; + base.OnPropertyChanged("Apelido"); + } + } + + public List ApoliceCritica + { + get; + set; + } + + public ObservableCollection ApoliceCriticaFiltrado + { + get + { + return this._apoliceCriticaFiltrado; + } + set + { + this._apoliceCriticaFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ApoliceCriticaFiltrado"); + } + } + + public List ApolicePendente + { + get + { + return this._apolicePendente; + } + set + { + this._apolicePendente = value; + base.OnPropertyChanged("ApolicePendente"); + } + } + + public ObservableCollection ApolicePendenteFiltrado + { + get + { + return this._apolicePendenteFiltrado; + } + set + { + this._apolicePendenteFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ApolicePendenteFiltrado"); + } + } + + public List Auditoria + { + get + { + return this._auditoria; + } + set + { + this._auditoria = value; + base.OnPropertyChanged("Auditoria"); + } + } + + public ObservableCollection AuditoriaFiltrado + { + get + { + return this._auditoriaFiltrado; + } + set + { + this._auditoriaFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("AuditoriaFiltrado"); + } + } + + public bool Carregando + { + get + { + return this._carregando; + } + set + { + this._carregando = value; + base.OnPropertyChanged("Carregando"); + } + } + + public bool CarregandoAjuda + { + get + { + return this._carregandoAjuda; + } + set + { + this._carregandoAjuda = value; + base.OnPropertyChanged("CarregandoAjuda"); + } + } + + public List Classificacao + { + get + { + return this._classificacao; + } + set + { + this._classificacao = value; + base.OnPropertyChanged("Classificacao"); + } + } + + public ObservableCollection ClassificacaoFiltrado + { + get + { + return this._classificacaoFiltrado; + } + set + { + this._classificacaoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ClassificacaoFiltrado"); + } + } + + public List ClientesAtivosInativos + { + get + { + return this._clientesAtivosInativos; + } + set + { + this._clientesAtivosInativos = value; + SinteticoClientes sinteticoCliente = new SinteticoClientes(); + sinteticoCliente.set_Total((value != null ? value.Count : 0)); + this.SinteticoCliente = sinteticoCliente; + base.OnPropertyChanged("ClientesAtivosInativos"); + } + } + + public ObservableCollection ClientesAtivosInativosFiltrado + { + get + { + return this._clientesAtivosInativosFiltrado; + } + set + { + this._clientesAtivosInativosFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ClientesAtivosInativosFiltrado"); + } + } + + public List ColunasOcultas { get; set; } = new List(); + + public List Comissao + { + get + { + return this._comissao; + } + set + { + this._comissao = value; + base.OnPropertyChanged("Comissao"); + } + } + + public ObservableCollection ComissaoFiltrado + { + get + { + return this._comissaoFiltrado; + } + set + { + this._comissaoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ComissaoFiltrado"); + } + } + + public bool Comparativo + { + get + { + return this._comparativo; + } + set + { + this._comparativo = value; + base.OnPropertyChanged("Comparativo"); + } + } + + public bool Completo + { + get + { + return this._completo; + } + set + { + this._completo = value; + base.OnPropertyChanged("Completo"); + } + } + + public bool DesconsiderarNegativos + { + get + { + return this._desconsiderarNegativos; + } + set + { + this.LimparRelatorio(); + this._desconsiderarNegativos = value; + base.OnPropertyChanged("DesconsiderarNegativos"); + } + } + + public bool DocumentosAtivos + { + get + { + return this._documentosAtivos; + } + set + { + this._documentosAtivos = value; + base.OnPropertyChanged("DocumentosAtivos"); + } + } + + public bool DocumentosEmitidos + { + get + { + return this._documentosEmitidos; + } + set + { + this.LimparRelatorio(); + this._documentosEmitidos = value; + base.OnPropertyChanged("DocumentosEmitidos"); + } + } + + public static DrawerHost Drawer + { + get; + set; + } + + public Gestor.Model.Domain.Common.Empresa Empresa + { + get + { + return this._empresa; + } + set + { + this._empresa = value; + base.OnPropertyChanged("Empresa"); + } + } + + public List Empresas + { + get + { + return this._empresas; + } + set + { + this._empresas = value; + base.OnPropertyChanged("Empresas"); + } + } + + public bool EnableEmpresa + { + get + { + return this._enableEmpresa; + } + set + { + this._enableEmpresa = value; + base.OnPropertyChanged("EnableEmpresa"); + } + } + + public ObservableCollection EndossoFiltrado + { + get + { + return this._endossoFiltrado; + } + set + { + this._endossoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("EndossoFiltrado"); + } + } + + public List Endossoo + { + get + { + return this._endosso; + } + set + { + this._endosso = value; + base.OnPropertyChanged("Endossoo"); + } + } + + public string ErroRelatorio + { + get + { + return this._erroRelatorio; + } + set + { + this._erroRelatorio = value; + base.OnPropertyChanged("ErroRelatorio"); + } + } + + public List Estipulantes + { + get + { + return this._estipulantes; + } + set + { + this._estipulantes = value; + foreach (Estipulante estipulante in this.Estipulantes) + { + estipulante.add_PropertyChanged(new PropertyChangedEventHandler(this.EstipulanteOnPropertyChanged)); + } + base.OnPropertyChanged("Estipulantes"); + } + } + + public List Extratos + { + get + { + return this._extratos; + } + set + { + this._extratos = value; + base.OnPropertyChanged("Extratos"); + } + } + + public bool ExtratosEnabled + { + get + { + return this._extratosEnabled; + } + set + { + this._extratosEnabled = value; + base.OnPropertyChanged("ExtratosEnabled"); + } + } + + public ObservableCollection ExtratosFiltrado + { + get + { + return this._extratosFiltrado; + } + set + { + this._extratosFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ExtratosFiltrado"); + } + } + + public List FaturaPendente + { + get + { + return this._faturaPendente; + } + set + { + this._faturaPendente = value; + base.OnPropertyChanged("FaturaPendente"); + } + } + + public ObservableCollection FaturaPendenteFiltrado + { + get + { + return this._faturaPendenteFiltrado; + } + set + { + this._faturaPendenteFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("FaturaPendenteFiltrado"); + } + } + + public ObservableCollection Fechamento + { + get + { + return this._fechamento; + } + set + { + this._fechamento = value; + this.Sintetic = null; + base.OnPropertyChanged("Fechamento"); + } + } + + public ObservableCollection FechamentoFiltrado + { + get + { + return this._fechamentoFiltrado; + } + set + { + this._fechamentoFiltrado = value; + this.SintetizarRelatorio(); + this.Sintetic = null; + base.OnPropertyChanged("FechamentoFiltrado"); + } + } + + public string Filtro + { + get + { + return this._filtro; + } + set + { + this._filtro = value; + this.Filtrar(); + base.OnPropertyChanged("Filtro"); + } + } + + public Gestor.Model.Domain.Relatorios.FiltroPersonalizado FiltroPersonalizado + { + get + { + return this._filtroPersonalizado; + } + set + { + char chr; + this._filtroPersonalizado = value; + this.VisibilitySemValor = (value != null ? Visibility.Visible : Visibility.Collapsed); + this.VisibilityOpcoesFiltros = Visibility.Collapsed; + base.OnPropertyChanged("FiltroPersonalizado"); + if (value == null) + { + return; + } + string name = value.get_Tipo().Name; + if (name != null) + { + switch (name.Length) + { + case 3: + { + if (name == "int") + { + break; + } + return; + } + case 4: + { + chr = name[0]; + if (chr == 'E') + { + if (name == "Enum") + { + this.ValorInicial = null; + this.ValorFinal = null; + return; + } + return; + } + else + { + if (chr != 'l') + { + return; + } + if (name == "long") + { + break; + } + return; + } + } + case 5: + { + chr = name[3]; + if (chr == '3') + { + if (name == "int32") + { + break; + } + return; + } + else + { + if (chr != '6') + { + return; + } + if (name == "int64") + { + break; + } + return; + } + } + case 6: + { + if (name != "String") + { + return; + } + this.ValorInicial = ""; + this.ValorFinal = ""; + this.VisibilityOpcoesFiltros = (value != null ? Visibility.Visible : Visibility.Collapsed); + return; + } + case 7: + { + if (name != "Decimal") + { + return; + } + this.ValorInicial = "0,00"; + this.ValorFinal = "0,00"; + return; + } + case 8: + { + if (name == "DateTime") + { + this.ValorInicial = null; + this.ValorFinal = null; + return; + } + return; + } + default: + { + return; + } + } + this.ValorInicial = "0"; + this.ValorFinal = "0"; + } + } + } + + public ObservableCollection FiltroPersonalizadoSelecionado + { + get + { + return this._filtroPersonalizadoSelecionado; + } + set + { + this._filtroPersonalizadoSelecionado = value; + base.OnPropertyChanged("FiltroPersonalizadoSelecionado"); + } + } + + public ObservableCollection FiltroRelatorioSelecionado + { + get + { + return this._filtroRelatorioSelecionado; + } + set + { + this._filtroRelatorioSelecionado = value; + base.OnPropertyChanged("FiltroRelatorioSelecionado"); + } + } + + public Gestor.Model.Domain.Relatorios.Filtros Filtros + { + get; + set; + } + + public Visibility FiltrosPersonalizados + { + get + { + return this._filtrosPersonalizados; + } + set + { + this._filtrosPersonalizados = value; + base.OnPropertyChanged("FiltrosPersonalizados"); + } + } + + public DateTime Fim + { + get + { + return this._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); + } + this._fim = value; + base.OnPropertyChanged("Fim"); + } + } + + public int FimValor + { + get + { + return this._fimValor; + } + set + { + this._fimValor = value; + base.OnPropertyChanged("FimValor"); + } + } + + public string Head + { + get + { + return this._head; + } + set + { + this._head = value; + base.OnPropertyChanged("Head"); + } + } + + public string HtmlContent + { + get + { + return this._htmlContent; + } + set + { + this._htmlContent = value; + base.OnPropertyChanged("HtmlContent"); + } + } + + public bool Inativo + { + get + { + return this._inativo; + } + set + { + this._inativo = value; + this.ReloadVendedores(); + base.OnPropertyChanged("Inativo"); + } + } + + public string Info + { + get + { + return this._info; + } + set + { + this._info = value; + base.OnPropertyChanged("Info"); + } + } + + public Visibility InfoVisibility + { + get + { + return this._infoVisibility; + } + set + { + this._infoVisibility = value; + base.OnPropertyChanged("InfoVisibility"); + } + } + + public DateTime Inicio + { + get + { + return this._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); + } + this._inicio = value; + base.OnPropertyChanged("Inicio"); + } + } + + public int InicioValor + { + get + { + return this._inicioValor; + } + set + { + this._inicioValor = value; + base.OnPropertyChanged("InicioValor"); + } + } + + public bool IsCampo + { + get + { + return this._isCampo; + } + set + { + this._isCampo = value; + base.OnPropertyChanged("IsCampo"); + } + } + + public bool IsVisibleGrid1 + { + get + { + return this._isVisibleGrid1; + } + set + { + this._isVisibleGrid1 = value; + base.OnPropertyChanged("IsVisibleGrid1"); + } + } + + public bool IsVisibleGrid2 + { + get + { + return this._isVisibleGrid2; + } + set + { + this._isVisibleGrid2 = value; + base.OnPropertyChanged("IsVisibleGrid2"); + } + } + + public bool IsVisibleGrid3 + { + get + { + return this._isVisibleGrid3; + } + set + { + this._isVisibleGrid3 = value; + base.OnPropertyChanged("IsVisibleGrid3"); + } + } + + public bool IsVisibleGrid4 + { + get + { + return this._isVisibleGrid4; + } + set + { + this._isVisibleGrid4 = value; + base.OnPropertyChanged("IsVisibleGrid4"); + } + } + + public List Licenciamento + { + get + { + return this._licenciamento; + } + set + { + this._licenciamento = value; + base.OnPropertyChanged("Licenciamento"); + } + } + + public ObservableCollection LicenciamentoFiltrado + { + get + { + return this._licenciamentoFiltrado; + } + set + { + this._licenciamentoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("LicenciamentoFiltrado"); + } + } + + public List LogsEnvio + { + get + { + return this._logsEnvio; + } + set + { + this._logsEnvio = value; + base.OnPropertyChanged("LogsEnvio"); + } + } + + public ObservableCollection LogsEnvioFiltrado + { + get + { + return this._logsEnvioFiltrado; + } + set + { + this._logsEnvioFiltrado = value; + this.Sintetic = null; + base.OnPropertyChanged("LogsEnvioFiltrado"); + } + } + + public List LogUtilizacao + { + get; + set; + } + + public ObservableCollection LogUtilizacaoFiltrado + { + get + { + return this._logUtilizacaoFiltrado; + } + set + { + this._logUtilizacaoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("LogUtilizacaoFiltrado"); + } + } + + public List MetaSeguradora + { + get + { + return this._metaSeguradora; + } + set + { + this._metaSeguradora = value; + base.OnPropertyChanged("MetaSeguradora"); + } + } + + public ObservableCollection MetaSeguradoraFiltrado + { + get + { + return this._metaSeguradoraFiltrado; + } + set + { + this._metaSeguradoraFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("MetaSeguradoraFiltrado"); + } + } + + public List MetaVendedor + { + get + { + return this._metaVendedor; + } + set + { + this._metaVendedor = value; + base.OnPropertyChanged("MetaVendedor"); + } + } + + public ObservableCollection MetaVendedorFiltrado + { + get + { + return this._metaVendedorFiltrado; + } + set + { + this._metaVendedorFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("MetaVendedorFiltrado"); + } + } + + public List Negocios + { + get + { + return this._negocios; + } + set + { + this._negocios = value; + foreach (NegocioRelatorio negocio in this.Negocios) + { + negocio.add_PropertyChanged(new PropertyChangedEventHandler(this.NegocioOnPropertyChanged)); + } + base.OnPropertyChanged("Negocios"); + } + } + + public ObservableCollection NotaFiscalFiltrado + { + get + { + return this._notaFiscalFiltrado; + } + set + { + this._notaFiscalFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("NotaFiscalFiltrado"); + } + } + + public bool NotaFiscalPorSeguradora + { + get + { + return this._notaFiscalPorSeguradora; + } + set + { + this._notaFiscalPorSeguradora = value; + base.OnPropertyChanged("NotaFiscalPorSeguradora"); + } + } + + public List NotasFiscais + { + get + { + return this._notasFiscais; + } + set + { + this._notasFiscais = value; + base.OnPropertyChanged("NotasFiscais"); + } + } + + public bool NovosNegocios + { + get + { + return this._novosNegocios; + } + set + { + this._novosNegocios = value; + base.OnPropertyChanged("NovosNegocios"); + } + } + + public string OrdemSelecionada + { + get + { + return this._ordemSelecionada; + } + set + { + this._ordemSelecionada = value; + base.OnPropertyChanged("OrdemSelecionada"); + } + } + + public ObservableCollection Ordens + { + get + { + return this._ordens; + } + set + { + this._ordens = value; + base.OnPropertyChanged("Ordens"); + } + } + + public List Pagamentos + { + get + { + return this._pagamentos; + } + set + { + this._pagamentos = value; + this.Sintetic = null; + base.OnPropertyChanged("Pagamentos"); + } + } + + public List PagamentosSintetico + { + get + { + return this._pagamentosSintetico; + } + set + { + this._pagamentosSintetico = value; + this.Sintetic = null; + base.OnPropertyChanged("PagamentosSintetico"); + } + } + + public ObservableCollection ParametrosRelatorio + { + get + { + return this._parametrosRelatorio; + } + set + { + if (value == null) + { + value = new ObservableCollection(); + } + Gestor.Model.Domain.Relatorios.ParametrosRelatorio parametrosRelatorio = new Gestor.Model.Domain.Relatorios.ParametrosRelatorio(); + parametrosRelatorio.set_Id((long)0); + parametrosRelatorio.set_Header("SELECIONE UM CAMPO"); + value.Insert(0, parametrosRelatorio); + this._parametrosRelatorio = value; + this.SelectedParametrosRelatorio = value[0]; + base.OnPropertyChanged("ParametrosRelatorio"); + } + } + + public ObservableCollection ParametrosRelatorioAdicionados + { + get + { + return this._parametrosRelatorioAdicionados; + } + set + { + this._parametrosRelatorioAdicionados = value; + base.OnPropertyChanged("ParametrosRelatorioAdicionados"); + } + } + + public ObservableCollection ParametrosTotalizacao + { + get + { + return this._parametrosTotalizacao; + } + set + { + if (value == null) + { + value = new ObservableCollection(); + } + Gestor.Model.Domain.Relatorios.ParametrosTotalizacao parametrosTotalizacao = new Gestor.Model.Domain.Relatorios.ParametrosTotalizacao(); + parametrosTotalizacao.set_Id((long)0); + parametrosTotalizacao.set_Header("SELECIONE UMA TOTALIZAÇÃO"); + value.Insert(0, parametrosTotalizacao); + this._parametrosTotalizacao = value; + this.SelectedParametrosTotalizacao = value[0]; + base.OnPropertyChanged("ParametrosTotalizacao"); + } + } + + public ObservableCollection ParametrosTotalizacaoAdicionados + { + get + { + return this._parametrosTotalizacaoAdicionados; + } + set + { + this._parametrosTotalizacaoAdicionados = value; + base.OnPropertyChanged("ParametrosTotalizacaoAdicionados"); + } + } + + public List ParcelasEspeciais + { + get + { + return this._parcelasEspeciais; + } + set + { + this._parcelasEspeciais = value; + base.OnPropertyChanged("ParcelasEspeciais"); + } + } + + public List Pendente + { + get + { + return this._pendente; + } + set + { + this._pendente = value; + base.OnPropertyChanged("Pendente"); + } + } + + public ObservableCollection PendenteFiltrado + { + get + { + return this._pendenteFiltrado; + } + set + { + this._pendenteFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("PendenteFiltrado"); + } + } + + public bool PermitirFiltrosPersonalizados + { + get + { + return this._permitirFiltrosPersonalizados; + } + set + { + this._permitirFiltrosPersonalizados = value; + base.OnPropertyChanged("PermitirFiltrosPersonalizados"); + } + } + + public ObservableCollection PlacaFiltrado + { + get + { + return this._placaFiltrado; + } + set + { + this._placaFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("PlacaFiltrado"); + } + } + + public List Placas + { + get + { + return this._placas; + } + set + { + this._placas = value; + base.OnPropertyChanged("Placas"); + } + } + + public Visibility PlanilhaVisibility + { + get + { + return this._planilhaVisibility; + } + set + { + this._planilhaVisibility = value; + base.OnPropertyChanged("PlanilhaVisibility"); + } + } + + public ObservableCollection Previsao + { + get + { + return this._previsao; + } + set + { + this._previsao = value; + this.Sintetic = null; + base.OnPropertyChanged("Previsao"); + } + } + + public ObservableCollection PrevisaoFiltrado + { + get + { + return this._previsaoFiltrado; + } + set + { + this._previsaoFiltrado = value; + this.SintetizarRelatorio(); + this.Sintetic = null; + base.OnPropertyChanged("PrevisaoFiltrado"); + } + } + + public ObservableCollection PrevisaoSintetico + { + get + { + return this._previsaoSintetico; + } + set + { + this._previsaoSintetico = value; + this.Sintetic = null; + base.OnPropertyChanged("PrevisaoSintetico"); + } + } + + public List Producao + { + get + { + return this._producao; + } + set + { + this._producao = value; + base.OnPropertyChanged("Producao"); + } + } + + public ObservableCollection ProducaoFiltrado + { + get + { + return this._producaoFiltrado; + } + set + { + this._producaoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("ProducaoFiltrado"); + } + } + + public List Produtos + { + get + { + return this._produtos; + } + set + { + this._produtos = value; + foreach (Gestor.Model.Domain.Seguros.Produto produto in this.Produtos) + { + produto.add_PropertyChanged(new PropertyChangedEventHandler(this.ProdutoOnPropertyChanged)); + } + base.OnPropertyChanged("Produtos"); + } + } + + public List Ramos + { + get + { + return this._ramos; + } + set + { + this._ramos = value; + foreach (Ramo ramo in this.Ramos) + { + ramo.add_PropertyChanged(new PropertyChangedEventHandler(this.RamoOnPropertyChanged)); + } + base.OnPropertyChanged("Ramos"); + } + } + + public Ramo RamoSelecionado + { + get + { + return this._ramoSelecionado; + } + set + { + this._ramoSelecionado = value; + base.OnPropertyChanged("RamoSelecionado"); + } + } + + public ObservableCollection RamosSelecionados + { + get + { + return this._ramosSelecionados; + } + set + { + this._ramosSelecionados = value; + base.OnPropertyChanged("RamosSelecionados"); + } + } + + private bool ReciboPagamento + { + get; + set; + } + + public string Referencia + { + get + { + return this._referencia; + } + set + { + this._referencia = value; + base.OnPropertyChanged("Referencia"); + } + } + + public ObservableCollection Referencias + { + get + { + return this._referencias; + } + set + { + this._referencias = value; + base.OnPropertyChanged("Referencias"); + } + } + + public Gestor.Model.Common.Relatorio Relatorio + { + get + { + return this._relatorio; + } + set + { + this._relatorio = value; + this.WorkOnRelatorio(value); + base.OnPropertyChanged("Relatorio"); + } + } + + public List RelatorioFiltroPersonalizado + { + get + { + return this._filtroRelatorioPersonalizado; + } + set + { + this._filtroRelatorioPersonalizado = value; + base.OnPropertyChanged("RelatorioFiltroPersonalizado"); + } + } + + public List Relatorios + { + get + { + return this._relatorios; + } + set + { + this._relatorios = value; + base.OnPropertyChanged("Relatorios"); + } + } + + public bool RelatorioVisibility + { + get + { + return this._relatorioVisibility; + } + set + { + this._relatorioVisibility = value; + base.OnPropertyChanged("RelatorioVisibility"); + } + } + + public List Renovacao + { + get + { + return this._renovacao; + } + set + { + this._renovacao = value; + base.OnPropertyChanged("Renovacao"); + } + } + + public ObservableCollection RenovacaoFiltrado + { + get + { + return this._renovacaoFiltrado; + } + set + { + this._renovacaoFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("RenovacaoFiltrado"); + } + } + + public object Report + { + get + { + return this._report; + } + set + { + this._report = value; + this.FiltrosPersonalizados = (value == null || !this.PermitirFiltrosPersonalizados ? Visibility.Collapsed : Visibility.Visible); + base.OnPropertyChanged("Report"); + } + } + + public bool SegundaViaReciboPagamento + { + get + { + return this._segundaViaReciboPagamento; + } + set + { + this.LimparRelatorio(); + this._segundaViaReciboPagamento = value; + if (value) + { + this.SomenteNaoPagos = false; + } + base.OnPropertyChanged("SegundaViaReciboPagamento"); + } + } + + public List Seguradoras + { + get + { + return this._seguradoras; + } + set + { + this._seguradoras = value; + foreach (Seguradora seguradora in this.Seguradoras) + { + seguradora.add_PropertyChanged(new PropertyChangedEventHandler(this.SeguradoraOnPropertyChanged)); + } + base.OnPropertyChanged("Seguradoras"); + } + } + + public int SelectedAno + { + get + { + return this._selectedAno; + } + set + { + this._selectedAno = value; + base.OnPropertyChanged("SelectedAno"); + } + } + + public Mes SelectedMes + { + get + { + return this._selectedMes; + } + set + { + this._selectedMes = value; + base.OnPropertyChanged("SelectedMes"); + } + } + + public Gestor.Model.Domain.Relatorios.ParametrosRelatorio SelectedParametrosRelatorio + { + get + { + return this._selectedParametrosRelatorio; + } + set + { + this._selectedParametrosRelatorio = value; + base.OnPropertyChanged("SelectedParametrosRelatorio"); + } + } + + public Gestor.Model.Domain.Relatorios.ParametrosTotalizacao SelectedParametrosTotalizacao + { + get + { + return this._selectedParametrosTotalizacao; + } + set + { + this._selectedParametrosTotalizacao = value; + base.OnPropertyChanged("SelectedParametrosTotalizacao"); + } + } + + public bool SemValor + { + get + { + return this._semValor; + } + set + { + this._semValor = value; + if (value) + { + this.ValorInicial = null; + this.ValorFinal = null; + } + base.OnPropertyChanged("SemValor"); + } + } + + public string Sessao + { + get; + set; + } + + public List Sinistro + { + get + { + return this._sinistro; + } + set + { + this._sinistro = value; + base.OnPropertyChanged("Sinistro"); + } + } + + public ObservableCollection SinistroFiltrado + { + get + { + return this._sinistroFiltrado; + } + set + { + this._sinistroFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("SinistroFiltrado"); + } + } + + public ObservableCollection Sintetic + { + get + { + return this._sintetic; + } + set + { + this._sintetic = value; + base.OnPropertyChanged("Sintetic"); + } + } + + public SinteticoClientes SinteticoCliente + { + get + { + return this._sinteticoCliente; + } + set + { + this._sinteticoCliente = value; + base.OnPropertyChanged("SinteticoCliente"); + } + } + + public ObservableCollection SinteticoRelatorio + { + get + { + return this._sinteticoRelatorio; + } + set + { + this._sinteticoRelatorio = value; + base.OnPropertyChanged("SinteticoRelatorio"); + this.Totais = (value == null ? false : value.Count > 0); + if (value == null || value.Count == 0) + { + return; + } + List sinteticModels = value.FirstOrDefault().ConstruirSintetico(this.Relatorio); + this.Sintetic = new ObservableCollection(sinteticModels); + } + } + + public bool SinteticosPagamento + { + get + { + return this._sinteticosPagamento; + } + set + { + this._sinteticosPagamento = value; + base.OnPropertyChanged("SinteticosPagamento"); + } + } + + public bool SomenteNaoPagos + { + get + { + return this._somenteNaoPagos; + } + set + { + this.LimparRelatorio(); + this._somenteNaoPagos = value; + if (value) + { + this.SegundaViaReciboPagamento = false; + } + base.OnPropertyChanged("SomenteNaoPagos"); + } + } + + public List Tarefa + { + get + { + return this._tarefa; + } + set + { + this._tarefa = value; + base.OnPropertyChanged("Tarefa"); + } + } + + public ObservableCollection TarefaFiltrado + { + get + { + return this._tarefaFiltrado; + } + set + { + this._tarefaFiltrado = value; + this.SintetizarRelatorio(); + base.OnPropertyChanged("TarefaFiltrado"); + } + } + + public Type TipoDateTime + { + get + { + return this._tipoDateTime; + } + set + { + this._tipoDateTime = value; + base.OnPropertyChanged("TipoDateTime"); + } + } + + public Type TipoDecimal + { + get + { + return this._tipoDecimal; + } + set + { + this._tipoDecimal = value; + base.OnPropertyChanged("TipoDecimal"); + } + } + + public Type TipoEnum + { + get + { + return this._tipoEnum; + } + set + { + this._tipoEnum = value; + base.OnPropertyChanged("TipoEnum"); + } + } + + public Type TipoInt + { + get + { + return this._tipoInt; + } + set + { + this._tipoInt = value; + base.OnPropertyChanged("TipoInt"); + } + } + + public Type TipoLong + { + get + { + return this._tipoLong; + } + set + { + this._tipoLong = value; + base.OnPropertyChanged("TipoLong"); + } + } + + public List TipoSeguros + { + get + { + return this._tipoSeguros; + } + set + { + this._tipoSeguros = value; + foreach (StatusRelatorio tipoSeguro in this.TipoSeguros) + { + tipoSeguro.add_PropertyChanged(new PropertyChangedEventHandler(this.StatusOnPropertyChanged)); + } + base.OnPropertyChanged("TipoSeguros"); + } + } + + public Type TipoString + { + get + { + return this._tipoString; + } + set + { + this._tipoString = value; + base.OnPropertyChanged("TipoString"); + } + } + + public List TipoVendedor + { + get + { + return this._tipoVendedor; + } + set + { + this._tipoVendedor = value; + foreach (Gestor.Model.Domain.Seguros.TipoVendedor tipoVendedor in this.TipoVendedor) + { + tipoVendedor.add_PropertyChanged(new PropertyChangedEventHandler(this.TipoVendedorOnPropertyChanged)); + } + base.OnPropertyChanged("TipoVendedor"); + } + } + + public bool Totais + { + get + { + return this._totais; + } + set + { + this._totais = value; + base.OnPropertyChanged("Totais"); + } + } + + public bool Totalizacao + { + get + { + return this._totalizacao; + } + set + { + this._totalizacao = value; + base.OnPropertyChanged("Totalizacao"); + } + } + + public List Usuarios + { + get; + set; + } + + public ObservableCollection UsuariosFiltrados + { + get + { + return this._usuariosFiltrados; + } + set + { + this._usuariosFiltrados = value; + base.OnPropertyChanged("UsuariosFiltrados"); + } + } + + public string ValorFinal + { + get + { + return this._valorFinal; + } + set + { + this._valorFinal = value; + base.OnPropertyChanged("ValorFinal"); + } + } + + public bool ValorIgual + { + get + { + return this._valorIgual; + } + set + { + this._valorIgual = value; + base.OnPropertyChanged("ValorIgual"); + } + } + + public string ValorInicial + { + get + { + return this._valorIncial; + } + set + { + this._valorIncial = value; + base.OnPropertyChanged("ValorInicial"); + } + } + + public List Vendedores + { + get + { + return this._vendedores; + } + set + { + this._vendedores = value; + foreach (Vendedor vendedore in this.Vendedores) + { + vendedore.add_PropertyChanged(new PropertyChangedEventHandler(this.VendedorOnPropertyChanged)); + } + base.OnPropertyChanged("Vendedores"); + } + } + + private List Vinculo + { + get; + set; + } + + public Visibility VisibilityAcompanhamento + { + get + { + return this._visibilityAcompanhamento; + } + set + { + this._visibilityAcompanhamento = value; + base.OnPropertyChanged("VisibilityAcompanhamento"); + } + } + + public Visibility VisibilityAgrupamento + { + get + { + return this._visibilityAgrupamento; + } + set + { + this._visibilityAgrupamento = value; + base.OnPropertyChanged("VisibilityAgrupamento"); + } + } + + public Visibility VisibilityApolice + { + get + { + return this._visibilityApolice; + } + set + { + this._visibilityApolice = value; + base.OnPropertyChanged("VisibilityApolice"); + } + } + + public Visibility VisibilityComparativo + { + get + { + return this._visibilityComparativo; + } + set + { + this._visibilityComparativo = value; + base.OnPropertyChanged("VisibilityComparativo"); + } + } + + public Visibility VisibilityCompleto + { + get + { + return this._visibilityCompleto; + } + set + { + this._visibilityCompleto = value; + base.OnPropertyChanged("VisibilityCompleto"); + } + } + + public Visibility VisibilityConfigurar + { + get + { + return this._visibilityConfigurar; + } + set + { + this._visibilityConfigurar = value; + base.OnPropertyChanged("VisibilityConfigurar"); + } + } + + public Visibility VisibilityData + { + get + { + return this._visibilityData; + } + set + { + this._visibilityData = value; + base.OnPropertyChanged("VisibilityData"); + } + } + + public bool VisibilityDesconsiderarNegativos + { + get + { + return this._visibilityDesconsiderarNegativos; + } + set + { + this._visibilityDesconsiderarNegativos = value; + base.OnPropertyChanged("VisibilityDesconsiderarNegativos"); + } + } + + public Visibility VisibilityDocumentoAtivo + { + get + { + return this._visibilityDocumentoAtivo; + } + set + { + this._visibilityDocumentoAtivo = value; + base.OnPropertyChanged("VisibilityDocumentoAtivo"); + } + } + + public Visibility VisibilityEmail + { + get + { + return this._visibilityEmail; + } + set + { + this._visibilityEmail = value; + base.OnPropertyChanged("VisibilityEmail"); + } + } + + public Visibility VisibilityEspecial + { + get + { + return this._visibilityEspecial; + } + set + { + this._visibilityEspecial = value; + base.OnPropertyChanged("VisibilityEspecial"); + } + } + + public Visibility VisibilityEtiqueta + { + get + { + return this._visibilityEtiqueta; + } + set + { + this._visibilityEtiqueta = value; + base.OnPropertyChanged("VisibilityEtiqueta"); + } + } + + public Visibility VisibilityExtratos + { + get + { + return this._visibilityExtratos; + } + set + { + this._visibilityExtratos = value; + base.OnPropertyChanged("VisibilityExtratos"); + } + } + + public Visibility VisibilityFiltroPersonalizado + { + get + { + return this._visibilityFiltroPersonalizado; + } + set + { + this._visibilityFiltroPersonalizado = value; + base.OnPropertyChanged("VisibilityFiltroPersonalizado"); + } + } + + public Visibility VisibilityFiltroPersonalizadoButton + { + get + { + return this._visibilityFiltroPersonalizadoButton; + } + set + { + this._visibilityFiltroPersonalizadoButton = value; + base.OnPropertyChanged("VisibilityFiltroPersonalizadoButton"); + } + } + + public Visibility VisibilityFiltros + { + get + { + return this._visibilityFiltros; + } + set + { + this._visibilityFiltros = value; + base.OnPropertyChanged("VisibilityFiltros"); + } + } + + public Visibility VisibilityGridFiltros + { + get + { + return this._visibilityGridFiltros; + } + set + { + this._visibilityGridFiltros = value; + base.OnPropertyChanged("VisibilityGridFiltros"); + } + } + + public bool VisibilityHtml + { + get + { + return this._visibilityHtml; + } + set + { + this._visibilityHtml = value; + base.OnPropertyChanged("VisibilityHtml"); + } + } + + public Visibility VisibilityMaisFiltros + { + get + { + return this._visibilityMaisFiltros; + } + set + { + this._visibilityMaisFiltros = value; + base.OnPropertyChanged("VisibilityMaisFiltros"); + } + } + + public Visibility VisibilityMeta + { + get + { + return this._visibilityMeta; + } + set + { + this._visibilityMeta = value; + base.OnPropertyChanged("VisibilityMeta"); + } + } + + public Visibility VisibilityNotaFiscalPorSeguradora + { + get + { + return this._visibilityNotaFiscalPorSeguradora; + } + set + { + this._visibilityNotaFiscalPorSeguradora = value; + base.OnPropertyChanged("VisibilityNotaFiscalPorSeguradora"); + } + } + + public Visibility VisibilityOlho + { + get + { + return this._visibilityOlho; + } + set + { + this._visibilityOlho = value; + base.OnPropertyChanged("VisibilityOlho"); + } + } + + public Visibility VisibilityOpcoesFiltros + { + get + { + return this._visibilityOpcoesFiltros; + } + set + { + this._visibilityOpcoesFiltros = value; + base.OnPropertyChanged("VisibilityOpcoesFiltros"); + } + } + + public Visibility VisibilityOrdem + { + get + { + return this._visibilityOrdem; + } + set + { + this._visibilityOrdem = value; + base.OnPropertyChanged("VisibilityOrdem"); + } + } + + public Visibility VisibilityPagamento + { + get + { + return this._visibilityPagamento; + } + set + { + this._visibilityPagamento = value; + base.OnPropertyChanged("VisibilityPagamento"); + } + } + + public Visibility VisibilityReferencia + { + get + { + return this._visibilityReferencia; + } + set + { + this._visibilityReferencia = value; + base.OnPropertyChanged("VisibilityReferencia"); + } + } + + public Visibility VisibilitySemValor + { + get + { + return this._visibilitySemValor; + } + set + { + this._visibilitySemValor = value; + base.OnPropertyChanged("VisibilitySemValor"); + } + } + + public Visibility VisibilitySintetizar + { + get + { + return this._visibilitySintetizar; + } + set + { + this._visibilitySintetizar = value; + base.OnPropertyChanged("VisibilitySintetizar"); + } + } + + public Visibility VisibilityTarefas + { + get + { + return this._visibilityTarefas; + } + set + { + this._visibilityTarefas = value; + base.OnPropertyChanged("VisibilityTarefas"); + } + } + + public bool VisibilityUsuarios + { + get + { + return this._visibilityUsuarios; + } + set + { + this._visibilityUsuarios = value; + base.OnPropertyChanged("VisibilityUsuarios"); + } + } + + public Visibility VisibilityValor + { + get + { + return this._visibilityValor; + } + set + { + this._visibilityValor = value; + base.OnPropertyChanged("VisibilityValor"); + } + } + + public Visibility VisibiltyProtocolo + { + get + { + return this._visibiltyProtocolo; + } + set + { + this._visibiltyProtocolo = value; + base.OnPropertyChanged("VisibiltyProtocolo"); + } + } + + public Visibility VisibiltySincronizar + { + get + { + return this._visibiltySincronizar; + } + set + { + this._visibiltySincronizar = value; + base.OnPropertyChanged("VisibiltySincronizar"); + } + } + + static RelatorioViewModel() + { + List negocioRelatorios = new List(); + NegocioRelatorio negocioRelatorio = new NegocioRelatorio(); + negocioRelatorio.set_Id(0); + negocioRelatorio.set_Selecionado(false); + negocioRelatorio.set_Negocio(0); + negocioRelatorios.Add(negocioRelatorio); + NegocioRelatorio negocioRelatorio1 = new NegocioRelatorio(); + negocioRelatorio1.set_Id(1); + negocioRelatorio1.set_Selecionado(false); + negocioRelatorio1.set_Negocio(1); + negocioRelatorios.Add(negocioRelatorio1); + RelatorioViewModel.NegocioList = negocioRelatorios; + List statusRelatorios = new List(); + StatusRelatorio statusRelatorio = new StatusRelatorio(); + statusRelatorio.set_Id(1); + statusRelatorio.set_Selecionado(false); + statusRelatorio.set_Status(1); + statusRelatorios.Add(statusRelatorio); + StatusRelatorio statusRelatorio1 = new StatusRelatorio(); + statusRelatorio1.set_Id(2); + statusRelatorio1.set_Selecionado(false); + statusRelatorio1.set_Status(2); + statusRelatorios.Add(statusRelatorio1); + StatusRelatorio statusRelatorio2 = new StatusRelatorio(); + statusRelatorio2.set_Id(3); + statusRelatorio2.set_Selecionado(false); + statusRelatorio2.set_Status(3); + statusRelatorios.Add(statusRelatorio2); + StatusRelatorio statusRelatorio3 = new StatusRelatorio(); + statusRelatorio3.set_Id(4); + statusRelatorio3.set_Selecionado(false); + statusRelatorio3.set_Status(7); + statusRelatorios.Add(statusRelatorio3); + StatusRelatorio statusRelatorio4 = new StatusRelatorio(); + statusRelatorio4.set_Id(5); + statusRelatorio4.set_Selecionado(false); + statusRelatorio4.set_Status(5); + statusRelatorios.Add(statusRelatorio4); + StatusRelatorio statusRelatorio5 = new StatusRelatorio(); + statusRelatorio5.set_Id(6); + statusRelatorio5.set_Selecionado(false); + statusRelatorio5.set_Status(6); + statusRelatorios.Add(statusRelatorio5); + StatusRelatorio statusRelatorio6 = new StatusRelatorio(); + statusRelatorio6.set_Id(7); + statusRelatorio6.set_Selecionado(false); + statusRelatorio6.set_Status(4); + statusRelatorios.Add(statusRelatorio6); + RelatorioViewModel.TipoSegurosList = statusRelatorios; + } + + public RelatorioViewModel(string opcao) + { + this.funcProducaoDistinctByDocumentoId = (Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_Id(); + this.funcProducaoSegurosNovos = (Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_Situacao() == 1; + this.funcProducaoSegurosRenovacao = (Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_Situacao() == 2; + this.funcProducaoNegociosNovos = (Gestor.Model.Domain.Relatorios.Producao.Producao p) => { + NegocioCorretora? negocioCorretora = p.get_Documento().get_NegocioCorretora(); + return negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue; + }; + this.funcProducaoNegociosProprios = (Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_Documento().get_NegocioCorretora().GetValueOrDefault() == 1; + this._totalizacao = true; + this._relatorios = new List(); + this._relatorio = 2; + this._filtrosPersonalizados = Visibility.Collapsed; + this._visibilityDesconsiderarNegativos = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 50); + this._visibilityReferencia = Visibility.Collapsed; + this._visibilityOrdem = Visibility.Collapsed; + this._referencias = new ObservableCollection(); + this._ordens = new ObservableCollection(); + DateTime date = Funcoes.GetNetworkTime().Date; + this._inicio = date.AddMonths(-1); + this._fim = Funcoes.GetNetworkTime().Date; + this._infoVisibility = Visibility.Collapsed; + this._erroRelatorio = "NÃO HÁ DADOS NO PERÍODO E FILTROS SELECIONADOS."; + this.ColunasOcultas = new List(); + this._seguradoras = ( + from x in Recursos.Seguradoras + where x.get_Ativo() + orderby x.get_Nome() + select x).ToList(); + this._ramos = ( + from x in Recursos.Ramos + where x.get_Ativo() + orderby x.get_Nome() + select x).ToList(); + this._notasFiscais = new List(); + this._inativo = true; + this._vendedores = new List(); + this._tipoVendedor = ( + from x in Recursos.TipoVendedor + where x.get_Ativo().GetValueOrDefault() + orderby x.get_Descricao() + select x).ToList(); + this._produtos = ( + from x in Recursos.Produtos + where x.get_Ativo() + orderby x.get_Nome() + select x).ToList(); + this._estipulantes = Recursos.Estipulantes.Where((Estipulante x) => { + if (Recursos.Usuario.get_IdEmpresa() != (long)1 && Recursos.Usuario.get_IdEmpresa() != x.get_IdEmpresa()) + { + return false; + } + return x.get_Ativo(); + }).OrderBy((Estipulante x) => x.get_Nome()).ToList(); + this._negocios = RelatorioViewModel.NegocioList; + this._tipoSeguros = RelatorioViewModel.TipoSegurosList; + this._isVisibleGrid1 = true; + this._isVisibleGrid2 = true; + this._isVisibleGrid3 = true; + this._isVisibleGrid4 = true; + this._tipoString = typeof(string); + this._tipoEnum = typeof(Enum); + this._tipoDateTime = typeof(DateTime); + this._tipoDecimal = typeof(decimal); + this._tipoInt = typeof(int); + this._tipoLong = typeof(long); + this._valorIncial = ""; + this._valorFinal = ""; + this._visibilitySemValor = Visibility.Collapsed; + this._visibilityOpcoesFiltros = Visibility.Collapsed; + this._filtroRelatorioSelecionado = new ObservableCollection(); + this._visibilityFiltroPersonalizado = Visibility.Collapsed; + List filtroTipoParcelas = new List(); + FiltroTipoParcela filtroTipoParcela = new FiltroTipoParcela(); + filtroTipoParcela.set_Selecionado(true); + filtroTipoParcela.set_Tipo(1); + filtroTipoParcelas.Add(filtroTipoParcela); + FiltroTipoParcela filtroTipoParcela1 = new FiltroTipoParcela(); + filtroTipoParcela1.set_Selecionado(true); + filtroTipoParcela1.set_Tipo(6); + filtroTipoParcelas.Add(filtroTipoParcela1); + FiltroTipoParcela filtroTipoParcela2 = new FiltroTipoParcela(); + filtroTipoParcela2.set_Selecionado(true); + filtroTipoParcela2.set_Tipo(3); + filtroTipoParcelas.Add(filtroTipoParcela2); + FiltroTipoParcela filtroTipoParcela3 = new FiltroTipoParcela(); + filtroTipoParcela3.set_Selecionado(true); + filtroTipoParcela3.set_Tipo(2); + filtroTipoParcelas.Add(filtroTipoParcela3); + FiltroTipoParcela filtroTipoParcela4 = new FiltroTipoParcela(); + filtroTipoParcela4.set_Selecionado(true); + filtroTipoParcela4.set_Tipo(5); + filtroTipoParcelas.Add(filtroTipoParcela4); + FiltroTipoParcela filtroTipoParcela5 = new FiltroTipoParcela(); + filtroTipoParcela5.set_Selecionado(true); + filtroTipoParcela5.set_Tipo(4); + filtroTipoParcelas.Add(filtroTipoParcela5); + this._parcelasEspeciais = filtroTipoParcelas; + this._ajuda = new ObservableCollection(); + this._isCampo = true; + this._usuariosFiltrados = new ObservableCollection(); + base(); + this._apoliceServico = new ApoliceServico(); + this._parcelaServico = new ParcelaServico(); + this._sinistroServico = new SinistroServico(); + this._clienteServico = new ClienteServico(); + this._logServico = new LogServico(); + this._extratoServico = new ServicoExtrato(); + this._metaSeguradoraServico = new MetaSeguradoraServico(); + this._metaVendedorServico = new MetaVendedorServico(); + this._notaFiscalServico = new NotaFiscalServico(); + this._criticaServico = new CriticaApoliceServico(); + this.Sessao = Guid.NewGuid().ToString(); + base.IsEnabled = true; + this.Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 6); + List list = ( + from x in Recursos.Empresas + orderby x.get_Id() + select x).ToList(); + Gestor.Model.Domain.Common.Empresa empresa = new Gestor.Model.Domain.Common.Empresa(); + empresa.set_Id((long)0); + empresa.set_Nome("TODAS, MATRIZ E FILIAIS"); + list.Insert(0, empresa); + this.Empresas = list; + this.Empresa = (Recursos.Usuario.get_IdEmpresa() <= (long)1 ? this.Empresas.First() : this.Empresas.Find((Gestor.Model.Domain.Common.Empresa x) => x.get_Id() == Recursos.Usuario.get_IdEmpresa())); + this.EnableEmpresa = Recursos.Usuario.get_IdEmpresa() <= (long)1; + base.EnableMenu = true; + this.LoadVendedores(); + this.PopularRelatorio(opcao); + } + + public async Task Acompanhamento() + { + Trilha trilha; + List tarefas; + if (this.RenovacaoFiltrado != null && this.RenovacaoFiltrado.Count != 0) + { + ObservableCollection renovacaoFiltrado = this.RenovacaoFiltrado; + if (!renovacaoFiltrado.All((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => !x.get_Selecionado())) + { + Trilha trilha1 = new Trilha(); + trilha1.set_Ativo(true); + trilha1.set_Titulo("ACOMPANHAMENTO DE RENOVAÇÃO"); + trilha1.set_Tipo(0); + List fases = new List(); + Fase fase = new Fase(); + fase.set_Titulo("A RENOVAR"); + fases.Add(fase); + Fase fase1 = new Fase(); + fase1.set_Titulo("EM RENOVAÇÃO"); + fases.Add(fase1); + Fase fase2 = new Fase(); + fase2.set_Titulo("RENOVADOS"); + fases.Add(fase2); + Fase fase3 = new Fase(); + fase3.set_Titulo("PERDIDOS"); + fases.Add(fase3); + trilha1.set_Fases(fases); + trilha = trilha1; + trilha = await this.SalvarTrilha(trilha); + if (trilha != null) + { + tarefas = await (new TarefaServico()).BuscarTarefas(trilha.get_Id()); + ObservableCollection observableCollection = this.RenovacaoFiltrado; + foreach (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao renovacao in + from x in observableCollection + where x.get_Selecionado() + select x) + { + if (tarefas.Any((Gestor.Model.Domain.Ferramentas.Tarefa x) => x.get_IdEntidade() == renovacao.get_Documento().get_Id())) + { + continue; + } + Gestor.Model.Domain.Ferramentas.Tarefa tarefa = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa.set_Entidade(0); + tarefa.set_IdEntidade(renovacao.get_Documento().get_Id()); + tarefa.set_IdCliente(renovacao.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa.set_Cliente(renovacao.get_Cliente()); + tarefa.set_Titulo(string.Concat("APÓLICE NÚMERO ", renovacao.get_Apolice())); + tarefa.set_Usuario(Recursos.Usuario); + tarefa.set_Agendamento(Funcoes.GetNetworkTime()); + tarefa.set_Trilha(trilha); + tarefa.set_Fase(trilha.get_Fases().First()); + object[] vigenciaFinal = new object[] { renovacao.get_VigenciaFinal(), renovacao.get_Seguradora(), renovacao.get_Ramo(), renovacao.get_Item() }; + tarefa.set_Referencia(string.Format("VIGÊNCIA FINAL: {0}\nSEGURADORA: {1}\nRAMO: {2}\nITEM: {3}", vigenciaFinal)); + await (new TarefaServico()).Salvar(tarefa); + } + if (Funcoes.IsWindowOpen("ACOMPANHAMENTO DE RENOVAÇÃO")) + { + Funcoes.Destroy("ACOMPANHAMENTO DE RENOVAÇÃO"); + } + (new HosterWindow(new AcompanhamentoView(), "ACOMPANHAMENTO DE RENOVAÇÃO", new double?((double)910), new double?((double)600), true)).Show(); + trilha = null; + tarefas = null; + return; + } + else + { + trilha = null; + tarefas = null; + return; + } + } + } + await base.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM ITEM NA LISTA PARA GERAR O ACOMPANHAMENTO.", "OK", "", false); + trilha = null; + tarefas = null; + } + + public async void AdcionarFiltroPersonalizado() + { + string str; + DateTime dateTime; + decimal num; + int num1; + long num2; + List filtroPersonalizados; + List filtroPersonalizados1; + if (this.FiltroPersonalizado != null) + { + if (this.SemValor) + { + filtroPersonalizados = (this.FiltroPersonalizadoSelecionado == null ? new List() : ( + from x in this.FiltroPersonalizadoSelecionado + where x.get_Propriedade() == this.FiltroPersonalizado.get_Propriedade() + select x).ToList()); + List filtroPersonalizados2 = filtroPersonalizados; + if (filtroPersonalizados2.Count > 0) + { + filtroPersonalizados2.ForEach((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => this.FiltroPersonalizadoSelecionado.Remove(x)); + } + str = string.Concat(this.FiltroPersonalizado.get_Nome(), ": EM BRANCO"); + } + else + { + filtroPersonalizados1 = (this.FiltroPersonalizadoSelecionado == null ? new List() : this.FiltroPersonalizadoSelecionado.Where((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => { + if (x.get_Propriedade() != this.FiltroPersonalizado.get_Propriedade()) + { + return false; + } + return x.get_SemValor(); + }).ToList()); + List filtroPersonalizados3 = filtroPersonalizados1; + if (filtroPersonalizados3.Count > 0) + { + filtroPersonalizados3.ForEach((Gestor.Model.Domain.Relatorios.FiltroPersonalizado x) => this.FiltroPersonalizadoSelecionado.Remove(x)); + } + string name = this.FiltroPersonalizado.get_Tipo().Name; + if (name == "DateTime") + { + if (!DateTime.TryParse(this.ValorInicial, out dateTime) || !DateTime.TryParse(this.ValorFinal, out dateTime) || DateTime.Parse(this.ValorInicial) > DateTime.Parse(this.ValorFinal)) + { + await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false); + return; + } + else + { + str = string.Format("{0}: {1:d} até {2:d}", this.FiltroPersonalizado.get_Nome(), DateTime.Parse(this.ValorInicial), DateTime.Parse(this.ValorFinal)); + } + } + else if (name == "Decimal") + { + if (!decimal.TryParse(this.ValorInicial, out num) || !decimal.TryParse(this.ValorFinal, out num) || decimal.Parse(this.ValorInicial) > decimal.Parse(this.ValorFinal)) + { + await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false); + return; + } + else + { + str = string.Format("{0}: {1:n2} até {2:n2}", this.FiltroPersonalizado.get_Nome(), decimal.Parse(this.ValorInicial), decimal.Parse(this.ValorFinal)); + } + } + else if (name == "Int32") + { + if (!int.TryParse(this.ValorInicial, out num1) || !int.TryParse(this.ValorFinal, out num1) || int.Parse(this.ValorInicial) > int.Parse(this.ValorFinal)) + { + await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false); + return; + } + else + { + str = string.Format("{0}: {1:n0} até {2:n0}", this.FiltroPersonalizado.get_Nome(), int.Parse(this.ValorInicial), int.Parse(this.ValorFinal)); + } + } + else if (name != "Int64") + { + if (!string.IsNullOrEmpty(this.ValorInicial)) + { + str = string.Concat(this.FiltroPersonalizado.get_Nome(), " = ", this.ValorInicial); + } + else + { + await base.ShowMessage("O VALOR DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false); + return; + } + } + else if (!long.TryParse(this.ValorInicial, out num2) || !long.TryParse(this.ValorFinal, out num2) || long.Parse(this.ValorInicial) > (long)int.Parse(this.ValorFinal)) + { + await base.ShowMessage("O VALOR DE INTERVALO DEVE SER PREENCHIDO CORRETAMENTE.", "OK", "", false); + return; + } + else + { + str = string.Format("{0}: {1:n0} até {2:n0}", this.FiltroPersonalizado.get_Nome(), long.Parse(this.ValorInicial), long.Parse(this.ValorFinal)); + } + } + if (this.FiltroPersonalizadoSelecionado == null) + { + this.FiltroPersonalizadoSelecionado = new ObservableCollection(); + } + ObservableCollection filtroPersonalizadoSelecionado = this.FiltroPersonalizadoSelecionado; + Gestor.Model.Domain.Relatorios.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Relatorios.FiltroPersonalizado(); + filtroPersonalizado.set_Nome(this.FiltroPersonalizado.get_Nome()); + filtroPersonalizado.set_Propriedade(this.FiltroPersonalizado.get_Propriedade()); + filtroPersonalizado.set_Tipo(this.FiltroPersonalizado.get_Tipo()); + filtroPersonalizado.set_ValorIncial(this.ValorInicial); + filtroPersonalizado.set_ValorFinal(this.ValorFinal); + filtroPersonalizado.set_SemValor(this.SemValor); + filtroPersonalizado.set_Descricao(str); + filtroPersonalizadoSelecionado.Add(filtroPersonalizado); + this.FiltroPersonalizado = null; + this.ValorInicial = string.Empty; + this.ValorFinal = string.Empty; + this.PesquisaPersonalizada(); + } + } + + public void AdicionarFiltro(FiltroRelatorio filtro) + { + if (filtro == null) + { + return; + } + if (this.FiltroRelatorioSelecionado == null) + { + this.FiltroRelatorioSelecionado = new ObservableCollection(); + } + if (this.FiltroRelatorioSelecionado.Any((FiltroRelatorio x) => { + if (x.get_Id() != filtro.get_Id()) + { + return false; + } + return x.get_Tipo() == filtro.get_Tipo(); + })) + { + return; + } + this.FiltroRelatorioSelecionado.Add(filtro); + switch (filtro.get_Tipo()) + { + case 0: + { + Seguradora seguradora = this.Seguradoras.FirstOrDefault((Seguradora x) => x.get_Id() == filtro.get_Id()); + if (seguradora == null) + { + break; + } + seguradora.set_Selecionado(true); + return; + } + case 1: + { + Ramo ramo = this.Ramos.FirstOrDefault((Ramo x) => x.get_Id() == filtro.get_Id()); + if (ramo == null) + { + break; + } + ramo.set_Selecionado(true); + return; + } + case 2: + { + Vendedor vendedor = this.Vendedores.FirstOrDefault((Vendedor x) => x.get_Id() == filtro.get_Id()); + if (vendedor == null) + { + break; + } + vendedor.set_Selecionado(true); + return; + } + case 3: + { + Estipulante estipulante = this.Estipulantes.FirstOrDefault((Estipulante x) => x.get_Id() == filtro.get_Id()); + if (estipulante == null) + { + break; + } + estipulante.set_Selecionado(true); + return; + } + case 4: + { + Gestor.Model.Domain.Seguros.Produto produto = this.Produtos.FirstOrDefault((Gestor.Model.Domain.Seguros.Produto x) => x.get_Id() == filtro.get_Id()); + if (produto == null) + { + break; + } + produto.set_Selecionado(true); + return; + } + case 5: + { + StatusRelatorio statusRelatorio = this.TipoSeguros.FirstOrDefault((StatusRelatorio x) => (long)x.get_Status() == filtro.get_Id()); + if (statusRelatorio == null) + { + break; + } + statusRelatorio.set_Selecionado(true); + return; + } + case 6: + { + Gestor.Model.Domain.Seguros.TipoVendedor tipoVendedor = this.TipoVendedor.FirstOrDefault((Gestor.Model.Domain.Seguros.TipoVendedor x) => x.get_Id() == filtro.get_Id()); + if (tipoVendedor == null) + { + break; + } + tipoVendedor.set_Selecionado(true); + return; + } + case 7: + { + NegocioRelatorio negocioRelatorio = this.Negocios.FirstOrDefault((NegocioRelatorio x) => (long)x.get_Id() == filtro.get_Id()); + if (negocioRelatorio == null) + { + break; + } + negocioRelatorio.set_Selecionado(true); + break; + } + default: + { + return; + } + } + } + + public void AdicionarFiltros() + { + List filtroRelatorios = new List(); + List list = ( + from x in this.Seguradoras + where x.get_Selecionado() + select x).Select((Seguradora x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id(x.get_Id()); + filtroRelatorio.set_Descricao(x.get_Nome()); + filtroRelatorio.set_Tipo(0); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.Ramos + where x.get_Selecionado() + select x).Select((Ramo x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id(x.get_Id()); + filtroRelatorio.set_Descricao(x.get_Nome()); + filtroRelatorio.set_Tipo(1); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.Vendedores + where x.get_Selecionado() + select x).Select((Vendedor x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id(x.get_Id()); + filtroRelatorio.set_Descricao(x.get_Nome()); + filtroRelatorio.set_Tipo(2); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.TipoVendedor + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Seguros.TipoVendedor x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id(x.get_Id()); + filtroRelatorio.set_Descricao(x.get_Descricao()); + filtroRelatorio.set_Tipo(6); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.Estipulantes + where x.get_Selecionado() + select x).Select((Estipulante x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id(x.get_Id()); + filtroRelatorio.set_Descricao(x.get_Nome()); + filtroRelatorio.set_Tipo(3); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.Produtos + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Seguros.Produto x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id(x.get_Id()); + filtroRelatorio.set_Descricao(x.get_Nome()); + filtroRelatorio.set_Tipo(4); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.TipoSeguros + where x.get_Selecionado() + select x).Select((StatusRelatorio x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id((long)x.get_Status()); + filtroRelatorio.set_Descricao(EnumHelper.GetDescription(x.get_Status())); + filtroRelatorio.set_Tipo(5); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + list = ( + from x in this.Negocios + where x.get_Selecionado() + select x).Select((NegocioRelatorio x) => { + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id((long)x.get_Negocio()); + filtroRelatorio.set_Descricao(EnumHelper.GetDescription(x.get_Negocio())); + filtroRelatorio.set_Tipo(7); + return filtroRelatorio; + }).ToList(); + filtroRelatorios.AddRange(list); + this.FiltroRelatorioSelecionado = new ObservableCollection(filtroRelatorios); + } + + public void AdicionarParametro(Gestor.Model.Domain.Relatorios.ParametrosRelatorio parametro) + { + if (parametro != null && parametro.get_Header() != "SELECIONE UM CAMPO") + { + this.ParametrosRelatorio.Remove(parametro); + this.ParametrosRelatorioAdicionados.Add(parametro); + this.SelectedParametrosRelatorio = this.ParametrosRelatorio[0]; + } + } + + public void AdicionarRamo() + { + if (this.RamoSelecionado == null) + { + return; + } + if (this.RamosSelecionados == null) + { + this.RamosSelecionados = new ObservableCollection(); + } + if (this.RamosSelecionados.All((Ramo x) => x.get_Id() != this.RamoSelecionado.get_Id())) + { + this.RamosSelecionados.Add(this.RamoSelecionado); + } + this.RamoSelecionado = null; + this.FiltrarRamo(); + } + + public void AdicionarTotalizacao(Gestor.Model.Domain.Relatorios.ParametrosTotalizacao parametro) + { + if (parametro != null && parametro.get_Header() != "SELECIONE UMA TOTALIZAÇÃO") + { + this.ParametrosTotalizacao.Remove(parametro); + this.ParametrosTotalizacaoAdicionados.Add(parametro); + this.SelectedParametrosTotalizacao = this.ParametrosTotalizacao[0]; + } + } + + private void AllSelectedChanged(int tipo) + { + if (this._allSelectedChanging) + { + return; + } + try + { + this._alterandoFiltros = true; + this._allSelectedChanging = true; + switch (tipo) + { + case 0: + { + if (this.AllSelectedSeguradora.HasValue) + { + List.Enumerator enumerator = this.Seguradoras.GetEnumerator(); + try + { + while (enumerator.MoveNext()) + { + enumerator.Current.set_Selecionado(this.AllSelectedSeguradora.Value); + } + break; + } + finally + { + ((IDisposable)enumerator).Dispose(); + } + } + else + { + return; + } + break; + } + case 1: + { + if (this.AllSelectedRamo.HasValue) + { + List.Enumerator enumerator1 = this.Ramos.GetEnumerator(); + try + { + while (enumerator1.MoveNext()) + { + enumerator1.Current.set_Selecionado(this.AllSelectedRamo.Value); + } + break; + } + finally + { + ((IDisposable)enumerator1).Dispose(); + } + } + else + { + return; + } + break; + } + case 2: + { + if (this.AllSelectedVendedor.HasValue) + { + List.Enumerator enumerator2 = this.Vendedores.GetEnumerator(); + try + { + while (enumerator2.MoveNext()) + { + enumerator2.Current.set_Selecionado(this.AllSelectedVendedor.Value); + } + break; + } + finally + { + ((IDisposable)enumerator2).Dispose(); + } + } + else + { + return; + } + break; + } + case 3: + { + if (this.AllSelectedStatus.HasValue) + { + List.Enumerator enumerator3 = this.TipoSeguros.GetEnumerator(); + try + { + while (enumerator3.MoveNext()) + { + enumerator3.Current.set_Selecionado(this.AllSelectedStatus.Value); + } + break; + } + finally + { + ((IDisposable)enumerator3).Dispose(); + } + } + else + { + return; + } + break; + } + case 4: + { + if (this.AllSelectedTipoVendedor.HasValue) + { + List.Enumerator enumerator4 = this.TipoVendedor.GetEnumerator(); + try + { + while (enumerator4.MoveNext()) + { + enumerator4.Current.set_Selecionado(this.AllSelectedTipoVendedor.Value); + } + break; + } + finally + { + ((IDisposable)enumerator4).Dispose(); + } + } + else + { + return; + } + break; + } + case 5: + { + if (this.AllSelectedNegocio.HasValue) + { + List.Enumerator enumerator5 = this.Negocios.GetEnumerator(); + try + { + while (enumerator5.MoveNext()) + { + enumerator5.Current.set_Selecionado(this.AllSelectedNegocio.Value); + } + break; + } + finally + { + ((IDisposable)enumerator5).Dispose(); + } + } + else + { + return; + } + break; + } + case 6: + { + if (this.AllSelectedProduto.HasValue) + { + List.Enumerator enumerator6 = this.Produtos.GetEnumerator(); + try + { + while (enumerator6.MoveNext()) + { + enumerator6.Current.set_Selecionado(this.AllSelectedProduto.Value); + } + break; + } + finally + { + ((IDisposable)enumerator6).Dispose(); + } + } + else + { + return; + } + break; + } + case 7: + { + if (this.AllSelectedEstipulante.HasValue) + { + List.Enumerator enumerator7 = this.Estipulantes.GetEnumerator(); + try + { + while (enumerator7.MoveNext()) + { + enumerator7.Current.set_Selecionado(this.AllSelectedEstipulante.Value); + } + break; + } + finally + { + ((IDisposable)enumerator7).Dispose(); + } + } + else + { + return; + } + break; + } + } + this._alterandoFiltros = false; + this.AdicionarFiltros(); + } + finally + { + this._allSelectedChanging = false; + } + } + + public void Bind() + { + ((GridRelatorio)this.Report).DataGrid.CancelEdit(); + ((GridRelatorio)this.Report).DataGrid.CancelEdit(); + switch (this.Relatorio) + { + case 0: + case 1: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ClientesAtivosInativosFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 2: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ProducaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 3: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ApolicePendenteFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 4: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.RenovacaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 5: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ComissaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 6: + case 16: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.PendenteFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 7: + case 11: + case 20: + case 21: + case 22: + { + return; + } + case 8: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.AuditoriaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 9: + case 10: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.SinistroFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 12: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.FaturaPendenteFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 13: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ExtratosFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 14: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.MetaSeguradoraFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 15: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.MetaVendedorFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 17: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.LicenciamentoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 18: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.TarefaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 19: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.NotaFiscalFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 23: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.LogsEnvioFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 24: + case 25: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.LogUtilizacaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 26: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ApoliceCriticaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 27: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.PlacaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 28: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.EndossoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 29: + { + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ClassificacaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + default: + { + return; + } + } + } + + public async Task CarregarAjuda() + { + if (!this.Ajuda.Any((AjudaTela x) => x.get_Tela() == int.Parse(EnumHelper.GetOldValue(this.Relatorio)))) + { + this.CarregandoAjuda = true; + List ajudaTelas = await Gestor.Application.Helpers.Connection.Get>(string.Format("Help/{0}", int.Parse(EnumHelper.GetOldValue(this.Relatorio))), true, false); + if (ajudaTelas != null) + { + this.Ajuda = new ObservableCollection(ajudaTelas); + this.CarregandoAjuda = false; + } + } + } + + public async Task CarregarConfiguracoes() + { + List parametrosRelatorios = new List(); + List parametrosRelatorios1 = await (new ConfuguracoesServico()).BuscarParametros(this.Relatorio); + switch (this.Relatorio) + { + case 0: + case 1: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 2: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 3: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 4: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 5: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 6: + case 16: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 7: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 8: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 9: + case 10: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 11: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 12: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 13: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 14: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 15: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 17: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 18: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 19: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 20: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 21: + case 22: + { + this.ParametrosRelatorio = new ObservableCollection(parametrosRelatorios); + RelatorioViewModel observableCollection = this; + List parametrosRelatorios2 = parametrosRelatorios1; + observableCollection.ParametrosRelatorioAdicionados = new ObservableCollection( + from x in parametrosRelatorios2 + orderby x.get_Ordem() + select x); + List parametrosTotalizacaos = await (new ConfuguracoesServico()).BuscarParametroTotalizacaoAsync(this.Relatorio); + this.ParametrosTotalizacao = new ObservableCollection(Funcoes.TotalizacoesRelatorio(this.Relatorio, parametrosTotalizacaos)); + this.ParametrosTotalizacaoAdicionados = new ObservableCollection(parametrosTotalizacaos); + break; + } + case 23: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 24: + case 25: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 26: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 27: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 28: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + case 29: + { + parametrosRelatorios = Funcoes.ColunasRelatorio(this.Relatorio, parametrosRelatorios1); + goto case 22; + } + default: + { + goto case 22; + } + } + parametrosRelatorios = null; + } + + public async Task> CriarLista() + { + List malaDiretas1 = await Task.Run>(() => { + Gestor.Model.Common.Relatorio relatorio = this.Relatorio; + switch (relatorio) + { + case 0: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + if (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + return ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => { + MalaDireta malaDiretum = new MalaDireta(); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Id()); + cliente.set_Nome(x.get_Nome()); + cliente.set_Nascimento(x.get_Nascimento()); + cliente.set_Documento(x.get_Documento()); + cliente.set_VencimentoHabilitacao(x.get_VencimentoCnh()); + cliente.set_NomeSocialRg(x.get_EntidadeCliente().get_NomeSocialRg()); + cliente.set_MalaDireta(x.get_EntidadeCliente().get_MalaDireta()); + malaDiretum.set_Cliente(cliente); + malaDiretum.set_Tela(1); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 1: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + if (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + return ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => { + MalaDireta malaDiretum = new MalaDireta(); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Id()); + cliente.set_Nome(x.get_Nome()); + cliente.set_Nascimento(x.get_Nascimento()); + cliente.set_Documento(x.get_Documento()); + cliente.set_VencimentoHabilitacao(x.get_VencimentoCnh()); + cliente.set_MalaDireta(x.get_EntidadeCliente().get_MalaDireta()); + malaDiretum.set_Cliente(cliente); + malaDiretum.set_Tela(1); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 2: + { + if (this.ProducaoFiltrado != null && this.ProducaoFiltrado.Count != 0) + { + if (this.ProducaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + })) + { + return this.ProducaoFiltrado.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + }).Select((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Tela(2); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 3: + { + if (this.ApolicePendenteFiltrado != null && this.ApolicePendenteFiltrado.Count != 0) + { + if (this.ApolicePendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + })) + { + return this.ApolicePendenteFiltrado.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + }).Select((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Tela(2); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 4: + { + if (this.RenovacaoFiltrado != null && this.RenovacaoFiltrado.Count != 0) + { + if (this.RenovacaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List list = this.RenovacaoFiltrado.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + }).Select((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + malaDiretum.set_Tela(2); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + List malaDiretas = this.RenovacaoFiltrado.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Prospeccao() != null; + }).Select((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + MalaDireta malaDiretum = new MalaDireta(); + Cliente cliente = new Cliente(); + cliente.set_Nome(x.get_Prospeccao().get_Nome()); + cliente.set_Id((long)0); + malaDiretum.set_Cliente(cliente); + malaDiretum.set_Prospeccao(x.get_Prospeccao()); + malaDiretum.set_Tela(33); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + if (malaDiretas.Count > 0) + { + list.AddRange(malaDiretas); + } + return list; + } + } + return new List(); + } + case 5: + { + if (this.ComissaoFiltrado != null && this.ComissaoFiltrado.Count != 0) + { + if (this.ComissaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + })) + { + return this.ComissaoFiltrado.Where((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + }).Select((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + malaDiretum.set_Parcela(x.get_ParcelaEntity()); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Tela(5); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 6: + case 16: + { + if (this.PendenteFiltrado != null && this.PendenteFiltrado.Count != 0) + { + if (this.PendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + })) + { + return this.PendenteFiltrado.Where((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Documento() != null; + }).Select((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Parcela(x.get_ParcelaEntity()); + malaDiretum.set_Tela(5); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 7: + case 8: + case 11: + case 12: + case 13: + case 14: + case 15: + { + return null; + } + case 9: + case 10: + { + if (this.SinistroFiltrado != null && this.SinistroFiltrado.Count != 0) + { + if (this.SinistroFiltrado.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + return ( + from x in this.SinistroFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + malaDiretum.set_Item(item); + malaDiretum.set_Sinistro(x.get_EntidadeSinistro()); + malaDiretum.set_Tela(7); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + case 17: + { + if (this.LicenciamentoFiltrado != null && this.LicenciamentoFiltrado.Count != 0) + { + if (this.LicenciamentoFiltrado.Any((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => x.get_Selecionado())) + { + return ( + from x in this.LicenciamentoFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Documento()); + malaDiretum.set_Item(x.get_EntidadeItem()); + malaDiretum.set_Tela(3); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + default: + { + if (relatorio == 26) + { + if (this.ApoliceCriticaFiltrado != null && this.ApoliceCriticaFiltrado.Count != 0) + { + if (this.ApoliceCriticaFiltrado.Any((Gestor.Model.Domain.Relatorios.CriticaApolice.ApoliceCritica x) => x.get_Selecionado())) + { + return ( + from x in this.ApoliceCriticaFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.CriticaApolice.ApoliceCritica x) => { + MalaDireta malaDiretum = new MalaDireta(); + malaDiretum.set_Cliente(x.get_Critica().get_Documento().get_Controle().get_Cliente()); + malaDiretum.set_Apolice(x.get_Critica().get_Documento()); + malaDiretum.set_Tela(2); + Item item = new Item(); + item.set_Descricao((x.get_Critica().get_Documento().get_ItensAtivo() != null ? (x.get_Critica().get_Documento().get_ItensAtivo().Count > 1 ? "APÓLICE COLETIVA" : (x.get_Critica().get_Documento().get_ItensAtivo().Count == 1 ? x.get_Critica().get_Documento().get_ItensAtivo().First().get_Descricao() : "")) : "")); + malaDiretum.set_Item(item); + malaDiretum.set_Relatorio(this.Relatorio); + return malaDiretum; + }).ToList(); + } + } + return new List(); + } + return null; + } + } + }); + return malaDiretas1; + } + + public async Task> CriarListaEtiqueta() + { + List documentos = await Task.Run>(() => { + switch (this.Relatorio) + { + case 0: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + if (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + return ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => { + Documento documento = new Documento(); + Controle controle = new Controle(); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Id()); + cliente.set_Nome(x.get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 1: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + if (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + return ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => { + Documento documento = new Documento(); + Controle controle = new Controle(); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Id()); + cliente.set_Nome(x.get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 2: + { + if (this.Producao != null && this.Producao.Count != 0) + { + if (this.Producao.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + return ( + from x in this.Producao + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 3: + { + if (this.ApolicePendente != null && this.ApolicePendente.Count != 0) + { + if (this.ApolicePendente.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + return ( + from x in this.ApolicePendente + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 4: + { + if (this.RenovacaoFiltrado != null && this.RenovacaoFiltrado.Count != 0) + { + if (this.RenovacaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + return ( + from x in this.RenovacaoFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + Vendedor vendedor; + Seguradora seguradora; + Ramo ramo; + Cliente cliente; + Documento documento = new Documento(); + documento.set_Id((x.get_Apolice() == "PROSPECÇÃO" ? x.get_Prospeccao().get_Id() : x.get_Documento().get_Id())); + documento.set_Vigencia1((x.get_Apolice() == "PROSPECÇÃO" ? new DateTime() : x.get_Documento().get_Vigencia1())); + documento.set_Vigencia2(x.get_VigenciaFinal()); + documento.set_Apolice(x.get_Apolice()); + documento.set_Endosso((x.get_Apolice() == "PROSPECÇÃO" ? "" : x.get_Documento().get_Endosso())); + if (x.get_Apolice() == "PROSPECÇÃO") + { + vendedor = new Vendedor(); + vendedor.set_Nome(x.get_Vendedor()); + } + else + { + vendedor = x.get_Documento().get_VendedorPrincipal(); + } + documento.set_VendedorPrincipal(vendedor); + Controle controle = new Controle(); + if (x.get_Apolice() == "PROSPECÇÃO") + { + seguradora = new Seguradora(); + } + else + { + seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + } + controle.set_Seguradora(seguradora); + if (x.get_Apolice() == "PROSPECÇÃO") + { + ramo = new Ramo(); + } + else + { + ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + } + controle.set_Ramo(ramo); + if (x.get_Apolice() == "PROSPECÇÃO") + { + cliente = new Cliente(); + cliente.set_Nome(x.get_Cliente()); + } + else + { + cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + } + controle.set_Cliente(cliente); + documento.set_Controle(controle); + List items = new List(); + Item item = new Item(); + item.set_Descricao(x.get_Item()); + items.Add(item); + documento.set_ItensAtivo(items); + return documento; + }).ToList(); + } + } + return null; + } + case 5: + { + if (this.ComissaoFiltrado != null && this.ComissaoFiltrado.Count != 0) + { + if (this.ComissaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + return ( + from x in this.ComissaoFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 6: + case 16: + { + if (this.PendenteFiltrado != null && this.PendenteFiltrado.Count != 0) + { + if (this.PendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + return ( + from x in this.PendenteFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 7: + case 11: + case 13: + case 14: + case 15: + { + return null; + } + case 8: + { + if (this.Auditoria != null && this.Auditoria.Count != 0) + { + if (this.Auditoria.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + return ( + from x in this.Auditoria + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 9: + { + if (this.Sinistro != null && this.Sinistro.Count != 0) + { + if (this.Sinistro.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + return ( + from x in this.Sinistro + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 10: + { + if (this.Sinistro != null && this.Sinistro.Count != 0) + { + if (this.Sinistro.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + return ( + from x in this.Sinistro + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + case 12: + { + if (this.FaturaPendenteFiltrado != null && this.FaturaPendenteFiltrado.Count != 0) + { + if (this.FaturaPendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente x) => x.get_Selecionado())) + { + return ( + from x in this.FaturaPendenteFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente x) => { + Documento documento = new Documento(); + documento.set_Id(x.get_Documento().get_Id()); + documento.set_Vigencia1(x.get_Documento().get_Vigencia1()); + documento.set_Vigencia2(x.get_Documento().get_Vigencia2()); + documento.set_Apolice(x.get_Documento().get_Apolice()); + documento.set_Endosso(x.get_Documento().get_Endosso()); + documento.set_VendedorPrincipal(x.get_Documento().get_VendedorPrincipal()); + Controle controle = new Controle(); + Seguradora seguradora = new Seguradora(); + seguradora.set_Id(x.get_Documento().get_Controle().get_Seguradora().get_Id()); + seguradora.set_Nome(x.get_Documento().get_Controle().get_Seguradora().get_Nome()); + controle.set_Seguradora(seguradora); + Ramo ramo = new Ramo(); + ramo.set_Id(x.get_Documento().get_Controle().get_Ramo().get_Id()); + ramo.set_Nome(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + controle.set_Ramo(ramo); + Cliente cliente = new Cliente(); + cliente.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + cliente.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + controle.set_Cliente(cliente); + documento.set_Controle(controle); + return documento; + }).ToList(); + } + } + return null; + } + default: + { + return null; + } + } + }); + return documentos; + } + + public void DescerParametro(Gestor.Model.Domain.Relatorios.ParametrosRelatorio parametro) + { + if (parametro == null) + { + return; + } + int num = this.ParametrosRelatorioAdicionados.IndexOf(parametro); + if (num == this.ParametrosRelatorioAdicionados.Count - 1) + { + return; + } + this.ParametrosRelatorioAdicionados.Move(num, num + 1); + } + + private void EstipulanteOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(6); + } + + public void ExcluirParametro(Gestor.Model.Domain.Relatorios.ParametrosRelatorio parametro) + { + if (parametro == null) + { + return; + } + this.ParametrosRelatorioAdicionados.Remove(parametro); + this.ParametrosRelatorio.Add(parametro); + this.ParametrosRelatorio = new ObservableCollection( + from x in this.ParametrosRelatorio + orderby x.get_Header() + select x); + } + + public void ExcluirTotalizacao(Gestor.Model.Domain.Relatorios.ParametrosTotalizacao parametro) + { + if (parametro == null) + { + return; + } + this.ParametrosTotalizacaoAdicionados.Remove(parametro); + this.ParametrosTotalizacao.Add(parametro); + this.ParametrosTotalizacao = new ObservableCollection( + from x in this.ParametrosTotalizacao + orderby x.get_Header() + select x); + } + + public async void ExibirExtratoDrawer() + { + List documentos = new List(); + List prospeccaos = new List(); + List clientesAtivosInativos = new List(); + List nums = new List(); + List nums1 = new List(); + switch (this.Relatorio) + { + case 0: + { + foreach (Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos list in ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList()) + { + Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos clientesAtivosInativo = new Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(list.get_Id()); + clientesAtivosInativo.set_Nome(list.get_Nome()); + clientesAtivosInativo.set_Documento(list.get_Documento()); + clientesAtivosInativo.set_Selecionado(list.get_Selecionado()); + clientesAtivosInativos.Add(clientesAtivosInativo); + } + base.ShowDrawer(new ExtratosDrawer(clientesAtivosInativos, null, new Gestor.Model.Common.Relatorio?(this.Relatorio), null, null, null), 0, false); + break; + } + case 1: + case 3: + { + if (nums.Count != 0 || nums1.Count != 0) + { + base.ShowDrawer(new ExtratosDrawer(null, documentos, new Gestor.Model.Common.Relatorio?(this.Relatorio), nums, nums1, prospeccaos), 0, false); + break; + } + else + { + await base.ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO", "OK", "", false); + break; + } + } + case 2: + { + List.Enumerator enumerator = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList().GetEnumerator(); + try + { + while (enumerator.MoveNext()) + { + Gestor.Model.Domain.Relatorios.Producao.Producao current = enumerator.Current; + documentos.Add(current.get_Documento()); + if (!current.get_Selecionado()) + { + continue; + } + nums.Add(current.get_Documento().get_Id()); + } + goto case 3; + } + finally + { + ((IDisposable)enumerator).Dispose(); + } + break; + } + case 4: + { + List.Enumerator enumerator1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList().GetEnumerator(); + try + { + while (enumerator1.MoveNext()) + { + Gestor.Model.Domain.Relatorios.Renovacao.Renovacao renovacao = enumerator1.Current; + if (renovacao.get_Documento() != null) + { + documentos.Add(renovacao.get_Documento()); + if (renovacao.get_Selecionado()) + { + nums.Add(renovacao.get_Documento().get_Id()); + } + } + if (renovacao.get_Prospeccao() == null) + { + continue; + } + prospeccaos.Add(renovacao.get_Prospeccao()); + if (!renovacao.get_Selecionado()) + { + continue; + } + nums1.Add(renovacao.get_Prospeccao().get_Id()); + } + goto case 3; + } + finally + { + ((IDisposable)enumerator1).Dispose(); + } + break; + } + default: + { + goto case 3; + } + } + } + + private void Filtrar() + { + this.Seguradoras = Recursos.Seguradoras.Where((Seguradora x) => { + if (!x.get_Ativo()) + { + return false; + } + return x.get_Nome().Contains(this.Filtro); + }).OrderBy((Seguradora x) => x.get_Nome()).ToList(); + this.Ramos = Recursos.Ramos.Where((Ramo x) => { + if (!x.get_Ativo()) + { + return false; + } + return x.get_Nome().Contains(this.Filtro); + }).OrderBy((Ramo x) => x.get_Nome()).ToList(); + this.Estipulantes = Recursos.Estipulantes.Where((Estipulante x) => { + if (!x.get_Ativo()) + { + return false; + } + return x.get_Nome().Contains(this.Filtro); + }).OrderBy((Estipulante x) => x.get_Nome()).ToList(); + this.Vendedores = (this.Vinculo.Count > 0 ? Recursos.Vendedores.Where((Vendedor x) => { + if (!this.Vinculo.Any((VendedorUsuario y) => y.get_Vendedor().get_Id() == x.get_Id()) || !x.get_Nome().Contains(this.Filtro)) + { + return false; + } + return x.get_Ativo(); + }).OrderBy((Vendedor x) => x.get_Nome()).ToList() : Recursos.Vendedores.Where((Vendedor x) => { + if (!x.get_Nome().Contains(this.Filtro)) + { + return false; + } + if (this.Inativo) + { + return true; + } + return x.get_Ativo(); + }).OrderBy((Vendedor x) => x.get_Nome()).ToList()); + this.TipoVendedor = Recursos.TipoVendedor.Where((Gestor.Model.Domain.Seguros.TipoVendedor x) => { + if (!x.get_Ativo().GetValueOrDefault()) + { + return false; + } + return x.get_Descricao().Contains(this.Filtro); + }).OrderBy((Gestor.Model.Domain.Seguros.TipoVendedor x) => x.get_Descricao()).ToList(); + this.Produtos = Recursos.Produtos.Where((Gestor.Model.Domain.Seguros.Produto x) => { + if (!x.get_Ativo()) + { + return false; + } + return x.get_Nome().Contains(this.Filtro); + }).OrderBy((Gestor.Model.Domain.Seguros.Produto x) => x.get_Nome()).ToList(); + this.TipoSeguros = ( + from x in RelatorioViewModel.TipoSegurosList + where EnumHelper.GetDescription(x.get_Status()).Contains(this.Filtro) + orderby x.get_Status() + select x).ToList(); + this.Negocios = ( + from x in RelatorioViewModel.NegocioList + where EnumHelper.GetDescription(x.get_Negocio()).Contains(this.Filtro) + orderby x.get_Negocio() + select x).ToList(); + } + + internal async Task> Filtrar(string value) + { + List usuarios = await Task.Run>(() => this.FiltrarUsuario(value)); + return usuarios; + } + + private void FiltrarRamo() + { + List filtroPersonalizados = (this.RamosSelecionados == null ? new List() : this.RamosSelecionados.Select((Ramo x) => { + Gestor.Model.Domain.Relatorios.FiltroPersonalizado filtroPersonalizado = new Gestor.Model.Domain.Relatorios.FiltroPersonalizado(); + filtroPersonalizado.set_Nome(x.get_Nome()); + filtroPersonalizado.set_Propriedade("Ramo"); + filtroPersonalizado.set_Tipo(typeof(string)); + filtroPersonalizado.set_ValorIncial(x.get_Nome()); + filtroPersonalizado.set_SemValor(false); + filtroPersonalizado.set_Descricao(x.get_Nome()); + filtroPersonalizado.set_Diferente(true); + return filtroPersonalizado; + }).ToList()); + this.ClientesAtivosInativosFiltrado = new ObservableCollection(this.ClientesAtivosInativos.CustomNot(filtroPersonalizados)); + if (this.FiltroPersonalizadoSelecionado != null) + { + this.ClientesAtivosInativosFiltrado = new ObservableCollection(this.ClientesAtivosInativosFiltrado.ToList().CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), false)); + } + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ClientesAtivosInativosFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + } + + public List FiltrarUsuario(string filter) + { + this.UsuariosFiltrados = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection(this.Usuarios) : new ObservableCollection( + from x in this.Usuarios + where Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Nome().Trim()).ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(filter)) + orderby !x.get_Excluido() descending, x.get_Nome() + select x)); + return this.UsuariosFiltrados.ToList(); + } + + public async Task GerarExcel() + { + string str; + Gestor.Model.Common.Agrupamento agrupamento; + Gestor.Model.Common.Agrupamento agrupamento1; + List list; + List producaos; + List list1; + List producaos1; + List list2; + List producaos2; + List list3; + List producaos3; + List list4; + List producaos4; + List list5; + List producaos5; + List apolicePendentes; + List apolicePendentes1; + List apolicePendentes2; + List apolicePendentes3; + List apolicePendentes4; + List apolicePendentes5; + List list6; + List apolicePendentes6; + List list7; + List apolicePendentes7; + List list8; + List renovacaos; + List renovacaos1; + List renovacaos2; + List renovacaos3; + List renovacaos4; + List renovacaos5; + List renovacaos6; + List renovacaos7; + List renovacaos8; + List list9; + List renovacaos9; + List comissaos; + List comissaos1; + List comissaos2; + List comissaos3; + List comissaos4; + List comissaos5; + List comissaos6; + List comissaos7; + List comissaos8; + List comissaos9; + List list10; + List pendentes; + List pendentes1; + List pendentes2; + List pendentes3; + List pendentes4; + List pendentes5; + List pendentes6; + List pendentes7; + List pendentes8; + List pendentes9; + List pendentes10; + List auditorias; + List auditorias1; + List auditorias2; + List auditorias3; + List auditorias4; + List auditorias5; + List auditorias6; + List auditorias7; + List auditorias8; + List auditorias9; + List auditorias10; + List sinistros; + List sinistros1; + List sinistros2; + List sinistros3; + List sinistros4; + List sinistros5; + List sinistros6; + List sinistros7; + List sinistros8; + List sinistros9; + List sinistros10; + List faturaPendentes; + List extratoBaixadoRelatorios; + List metaSeguradoraRelatorios; + List metaVendedorRelatorios; + List licenciamentos; + List tarefas; + List notaFiscalRelatorios; + List logsEnvios; + List logAcaoRelatorios; + List apoliceCriticas; + List placas; + List placas1; + List placas2; + List placas3; + List placas4; + List placas5; + List placas6; + List placas7; + List placas8; + List endossos; + List classificacaos; + XLWorkbook xLWorkbook; + List producaos6; + List strs; + List apolicePendentes8; + List renovacaos10; + List comissaos10; + List list11; + List auditorias11; + List sinistros11; + List placas9; + string tempPath = ""; + string str1 = ""; + List configuracoes = Recursos.Configuracoes; + if (!configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 41)) + { + tempPath = Path.GetTempPath(); + str1 = string.Format("{0}{1}.xlsx", tempPath, Guid.NewGuid()); + } + else + { + using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) + { + if (DialogResult.OK == folderBrowserDialog.ShowDialog()) + { + tempPath = string.Concat(folderBrowserDialog.SelectedPath, "\\"); + Directory.CreateDirectory(tempPath); + } + else + { + str1 = null; + xLWorkbook = null; + strs = null; + return; + } + } + string[] description = new string[] { tempPath, EnumHelper.GetDescription(this.Relatorio), " ", null, null }; + DateTime date = Functions.GetNetworkTime().Date; + description[3] = date.ToShortDateString().Replace("/", ""); + description[4] = ".xlsx"; + str1 = string.Concat(description); + } + xLWorkbook = new XLWorkbook(); + int num = 1; + switch (this.Relatorio) + { + case 0: + case 1: + { + List clientesAtivosInativos = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ClientesAtivosInativosFiltrado == null || clientesAtivosInativos.Count == 0) + { + break; + } + else + { + List clientesAtivosInativos1 = clientesAtivosInativos; + if (clientesAtivosInativos1.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + List clientesAtivosInativos2 = clientesAtivosInativos; + list = ( + from x in clientesAtivosInativos2 + where x.get_Selecionado() + select x).ToList(); + } + else + { + list = clientesAtivosInativos; + } + List clientesAtivosInativos3 = list; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", clientesAtivosInativos3, this.Relatorio, true); + goto case 22; + } + } + case 2: + { + producaos6 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ProducaoFiltrado == null || producaos6.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List producaos7 = producaos6; + IOrderedEnumerable seguradora = + from x in producaos7 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str2 in strs) + { + if (string.IsNullOrWhiteSpace(str2)) + { + continue; + } + List producaos8 = producaos6; + if (producaos8.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + IEnumerable producaos9 = producaos6.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str2; + }); + producaos = ( + from x in producaos9 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable seguradora1 = + from x in producaos6 + where x.get_Seguradora() == str2 + select x; + producaos = ( + from x in seguradora1 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos10 = producaos; + if (producaos10.Count == 0) + { + continue; + } + string str3 = str2; + agrupamento1 = this.Agrupamento; + str = str3.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, producaos10, this.Relatorio, true); + } + goto Label1; + } + else + { + List producaos11 = producaos6; + if (producaos11.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + List producaos12 = producaos6; + List list12 = ( + from x in producaos12 + where x.get_Selecionado() + select x).ToList(); + list1 = ( + from x in list12 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + List producaos13 = producaos6; + list1 = ( + from x in producaos13 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos14 = list1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", producaos14, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List producaos15 = producaos6; + IOrderedEnumerable ramo = + from x in producaos15 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str4 in strs) + { + if (string.IsNullOrWhiteSpace(str4)) + { + continue; + } + List producaos16 = producaos6; + if (producaos16.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + IEnumerable producaos17 = producaos6.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str4; + }); + producaos1 = ( + from x in producaos17 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable ramo1 = + from x in producaos6 + where x.get_Ramo() == str4 + select x; + producaos1 = ( + from x in ramo1 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos18 = producaos1; + if (producaos18.Count == 0) + { + continue; + } + string str5 = str4; + agrupamento1 = this.Agrupamento; + str = str5.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, producaos18, this.Relatorio, true); + } + goto Label1; + } + else + { + List producaos19 = producaos6; + if (producaos19.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + List producaos20 = producaos6; + List list13 = ( + from x in producaos20 + where x.get_Selecionado() + select x).ToList(); + list2 = ( + from x in list13 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + List producaos21 = producaos6; + list2 = ( + from x in producaos21 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos22 = list2; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", producaos22, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List producaos23 = producaos6; + IOrderedEnumerable vendedor = + from x in producaos23 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str6 in strs) + { + if (string.IsNullOrWhiteSpace(str6)) + { + continue; + } + List producaos24 = producaos6; + if (producaos24.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + IEnumerable producaos25 = producaos6.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str6; + }); + producaos2 = ( + from x in producaos25 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable vendedor1 = + from x in producaos6 + where x.get_Vendedor() == str6 + select x; + producaos2 = ( + from x in vendedor1 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos26 = producaos2; + if (producaos26.Count == 0) + { + continue; + } + string str7 = str6; + agrupamento1 = this.Agrupamento; + str = str7.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, producaos26, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List producaos27 = producaos6; + if (producaos27.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + List producaos28 = producaos6; + List list14 = ( + from x in producaos28 + where x.get_Selecionado() + select x).ToList(); + list3 = ( + from x in list14 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + List producaos29 = producaos6; + list3 = ( + from x in producaos29 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos30 = list3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", producaos30, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List producaos31 = producaos6; + IOrderedEnumerable estipulante = + from x in producaos31 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str8 in strs) + { + if (string.IsNullOrWhiteSpace(str8)) + { + continue; + } + List producaos32 = producaos6; + if (producaos32.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + IEnumerable producaos33 = producaos6.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str8; + }); + producaos3 = ( + from x in producaos33 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable estipulante1 = + from x in producaos6 + where x.get_Estipulante() == str8 + select x; + producaos3 = ( + from x in estipulante1 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos34 = producaos3; + if (producaos34.Count == 0) + { + continue; + } + string str9 = str8; + agrupamento1 = this.Agrupamento; + str = str9.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, producaos34, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List producaos35 = producaos6; + if (producaos35.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + List producaos36 = producaos6; + List list15 = ( + from x in producaos36 + where x.get_Selecionado() + select x).ToList(); + list4 = ( + from x in list15 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + List producaos37 = producaos6; + list4 = ( + from x in producaos37 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos38 = list4; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", producaos38, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + List producaos39 = producaos6; + IOrderedEnumerable status = + from x in producaos39 + orderby x.get_Status() + select x; + strs = ( + from x in status + select x.get_Status()).Distinct().ToList(); + this.ColunasOcultas = await Funcoes.OcultarColunas(this.Relatorio); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str10 in strs) + { + if (string.IsNullOrWhiteSpace(str10)) + { + continue; + } + List producaos40 = producaos6; + if (producaos40.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + IEnumerable producaos41 = producaos6.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Status() == str10; + }); + producaos4 = ( + from x in producaos41 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable status1 = + from x in producaos6 + where x.get_Status() == str10 + select x; + producaos4 = ( + from x in status1 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos42 = producaos4; + if (producaos42.Count == 0) + { + continue; + } + string str11 = str10; + agrupamento1 = this.Agrupamento; + str = str11.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, producaos42, this.ColunasOcultas); + } + goto Label1; + } + else + { + List producaos43 = producaos6; + if (producaos43.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + List producaos44 = producaos6; + List list16 = ( + from x in producaos44 + where x.get_Selecionado() + select x).ToList(); + list5 = ( + from x in list16 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + List producaos45 = producaos6; + list5 = ( + from x in producaos45 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos46 = list5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", producaos46, this.ColunasOcultas); + goto Label1; + } + } + default: + { + List producaos47 = producaos6; + if (producaos47.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + List producaos48 = producaos6; + IEnumerable selecionado = + from x in producaos48 + where x.get_Selecionado() + select x; + producaos5 = ( + from x in selecionado + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + List producaos49 = producaos6; + producaos5 = ( + from x in producaos49 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List producaos50 = producaos5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", producaos50.ToList(), this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 3: + { + apolicePendentes8 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ApolicePendenteFiltrado == null || apolicePendentes8.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List apolicePendentes9 = apolicePendentes8; + IOrderedEnumerable seguradora2 = + from x in apolicePendentes9 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora2 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str12 in strs) + { + if (string.IsNullOrWhiteSpace(str12)) + { + continue; + } + List apolicePendentes10 = apolicePendentes8; + if (apolicePendentes10.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + IEnumerable apolicePendentes11 = apolicePendentes8.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str12; + }); + apolicePendentes = ( + from x in apolicePendentes11 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable seguradora3 = + from x in apolicePendentes8 + where x.get_Seguradora() == str12 + select x; + apolicePendentes = ( + from x in seguradora3 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List apolicePendentes12 = apolicePendentes; + if (apolicePendentes12.Count == 0) + { + continue; + } + string str13 = str12; + agrupamento1 = this.Agrupamento; + str = str13.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, apolicePendentes12, this.Relatorio, true); + } + goto Label1; + } + else + { + List apolicePendentes13 = apolicePendentes8; + if (apolicePendentes13.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + List apolicePendentes14 = apolicePendentes8; + apolicePendentes1 = ( + from x in apolicePendentes14 + where x.get_Selecionado() + select x).ToList(); + } + else + { + apolicePendentes1 = apolicePendentes8; + } + List apolicePendentes15 = apolicePendentes1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apolicePendentes15, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List apolicePendentes16 = apolicePendentes8; + IOrderedEnumerable ramo2 = + from x in apolicePendentes16 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo2 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str14 in strs) + { + if (string.IsNullOrWhiteSpace(str14)) + { + continue; + } + List apolicePendentes17 = apolicePendentes8; + if (apolicePendentes17.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + IEnumerable apolicePendentes18 = apolicePendentes8.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str14; + }); + apolicePendentes2 = ( + from x in apolicePendentes18 + orderby x.get_Seguradora() + select x).ToList(); + } + else + { + IEnumerable ramo3 = + from x in apolicePendentes8 + where x.get_Ramo() == str14 + select x; + apolicePendentes2 = ( + from x in ramo3 + orderby x.get_Seguradora() + select x).ToList(); + } + List apolicePendentes19 = apolicePendentes2; + if (apolicePendentes19.Count == 0) + { + continue; + } + string str15 = str14; + agrupamento1 = this.Agrupamento; + str = str15.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, apolicePendentes19, this.Relatorio, true); + } + goto Label1; + } + else + { + List apolicePendentes20 = apolicePendentes8; + if (apolicePendentes20.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + List apolicePendentes21 = apolicePendentes8; + apolicePendentes3 = ( + from x in apolicePendentes21 + where x.get_Selecionado() + select x).ToList(); + } + else + { + apolicePendentes3 = apolicePendentes8; + } + List apolicePendentes22 = apolicePendentes3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apolicePendentes22, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List apolicePendentes23 = apolicePendentes8; + IOrderedEnumerable vendedor2 = + from x in apolicePendentes23 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor2 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str16 in strs) + { + if (string.IsNullOrWhiteSpace(str16)) + { + continue; + } + List apolicePendentes24 = apolicePendentes8; + if (apolicePendentes24.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + IEnumerable apolicePendentes25 = apolicePendentes8.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str16; + }); + apolicePendentes4 = ( + from x in apolicePendentes25 + orderby x.get_Seguradora() + select x).ToList(); + } + else + { + IEnumerable vendedor3 = + from x in apolicePendentes8 + where x.get_Vendedor() == str16 + select x; + apolicePendentes4 = ( + from x in vendedor3 + orderby x.get_Seguradora() + select x).ToList(); + } + List apolicePendentes26 = apolicePendentes4; + if (apolicePendentes26.Count == 0) + { + continue; + } + string str17 = str16; + agrupamento1 = this.Agrupamento; + str = str17.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, apolicePendentes26, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List apolicePendentes27 = apolicePendentes8; + if (apolicePendentes27.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + List apolicePendentes28 = apolicePendentes8; + apolicePendentes5 = ( + from x in apolicePendentes28 + where x.get_Selecionado() + select x).ToList(); + } + else + { + apolicePendentes5 = apolicePendentes8; + } + List apolicePendentes29 = apolicePendentes5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apolicePendentes29, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List apolicePendentes30 = apolicePendentes8; + IOrderedEnumerable estipulante2 = + from x in apolicePendentes30 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante2 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str18 in strs) + { + if (string.IsNullOrWhiteSpace(str18)) + { + continue; + } + List apolicePendentes31 = apolicePendentes8; + if (apolicePendentes31.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + IEnumerable apolicePendentes32 = apolicePendentes8.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str18; + }); + list6 = ( + from x in apolicePendentes32 + orderby x.get_Seguradora() + select x).ToList(); + } + else + { + IEnumerable estipulante3 = + from x in apolicePendentes8 + where x.get_Estipulante() == str18 + select x; + list6 = ( + from x in estipulante3 + orderby x.get_Seguradora() + select x).ToList(); + } + List apolicePendentes33 = list6; + if (apolicePendentes33.Count == 0) + { + continue; + } + string str19 = str18; + agrupamento1 = this.Agrupamento; + str = str19.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, apolicePendentes33, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List apolicePendentes34 = apolicePendentes8; + if (apolicePendentes34.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + List apolicePendentes35 = apolicePendentes8; + apolicePendentes6 = ( + from x in apolicePendentes35 + where x.get_Selecionado() + select x).ToList(); + } + else + { + apolicePendentes6 = apolicePendentes8; + } + List apolicePendentes36 = apolicePendentes6; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apolicePendentes36, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + List apolicePendentes37 = apolicePendentes8; + IOrderedEnumerable status2 = + from x in apolicePendentes37 + orderby x.get_Status() + select x; + strs = ( + from x in status2 + select x.get_Status()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str20 in strs) + { + if (string.IsNullOrWhiteSpace(str20)) + { + continue; + } + List apolicePendentes38 = apolicePendentes8; + if (apolicePendentes38.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + IEnumerable apolicePendentes39 = apolicePendentes8.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Status() == str20; + }); + list7 = ( + from x in apolicePendentes39 + orderby x.get_Seguradora() + select x).ToList(); + } + else + { + IEnumerable status3 = + from x in apolicePendentes8 + where x.get_Status() == str20 + select x; + list7 = ( + from x in status3 + orderby x.get_Seguradora() + select x).ToList(); + } + List apolicePendentes40 = list7; + if (apolicePendentes40.Count == 0) + { + continue; + } + string str21 = str20; + agrupamento1 = this.Agrupamento; + str = str21.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, apolicePendentes40, this.ColunasOcultas); + } + goto Label1; + } + else + { + List apolicePendentes41 = apolicePendentes8; + if (apolicePendentes41.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + List apolicePendentes42 = apolicePendentes8; + apolicePendentes7 = ( + from x in apolicePendentes42 + where x.get_Selecionado() + select x).ToList(); + } + else + { + apolicePendentes7 = apolicePendentes8; + } + List apolicePendentes43 = apolicePendentes7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apolicePendentes43, this.ColunasOcultas); + goto Label1; + } + } + default: + { + List apolicePendentes44 = apolicePendentes8; + if (apolicePendentes44.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + List apolicePendentes45 = apolicePendentes8; + list8 = ( + from x in apolicePendentes45 + where x.get_Selecionado() + select x).ToList(); + } + else + { + list8 = apolicePendentes8; + } + List apolicePendentes46 = list8; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apolicePendentes46, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 4: + { + renovacaos10 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.RenovacaoFiltrado == null || renovacaos10.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List renovacaos11 = renovacaos10; + IOrderedEnumerable seguradora4 = + from x in renovacaos11 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora4 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str22 in strs) + { + if (string.IsNullOrWhiteSpace(str22)) + { + continue; + } + List renovacaos12 = renovacaos10; + if (renovacaos12.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + IEnumerable renovacaos13 = renovacaos10.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str22; + }); + renovacaos = ( + from x in renovacaos13 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + else + { + IEnumerable seguradora5 = + from x in renovacaos10 + where x.get_Seguradora() == str22 + select x; + renovacaos = ( + from x in seguradora5 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + List renovacaos14 = renovacaos; + if (renovacaos14.Count == 0) + { + continue; + } + string str23 = str22; + agrupamento1 = this.Agrupamento; + str = str23.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, renovacaos14, this.Relatorio, true); + } + goto Label1; + } + else + { + List renovacaos15 = renovacaos10; + if (renovacaos15.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List renovacaos16 = renovacaos10; + renovacaos1 = ( + from x in renovacaos16 + where x.get_Selecionado() + select x).ToList(); + } + else + { + renovacaos1 = renovacaos10.ToList(); + } + List renovacaos17 = renovacaos1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", renovacaos17, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List renovacaos18 = renovacaos10; + IOrderedEnumerable ramo4 = + from x in renovacaos18 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo4 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str24 in strs) + { + if (string.IsNullOrWhiteSpace(str24)) + { + continue; + } + List renovacaos19 = renovacaos10; + if (renovacaos19.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + IEnumerable renovacaos20 = renovacaos10.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str24; + }); + renovacaos2 = ( + from x in renovacaos20 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + else + { + IEnumerable ramo5 = + from x in renovacaos10 + where x.get_Ramo() == str24 + select x; + renovacaos2 = ( + from x in ramo5 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + List renovacaos21 = renovacaos2; + if (renovacaos21.Count == 0) + { + continue; + } + string str25 = str24; + agrupamento1 = this.Agrupamento; + str = str25.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, renovacaos21, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List renovacaos22 = renovacaos10; + if (renovacaos22.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List renovacaos23 = renovacaos10; + renovacaos3 = ( + from x in renovacaos23 + where x.get_Selecionado() + select x).ToList(); + } + else + { + renovacaos3 = renovacaos10.ToList(); + } + List renovacaos24 = renovacaos3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", renovacaos24, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List renovacaos25 = renovacaos10; + IOrderedEnumerable vendedor4 = + from x in renovacaos25 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor4 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str26 in strs) + { + if (string.IsNullOrWhiteSpace(str26)) + { + continue; + } + List renovacaos26 = renovacaos10; + if (renovacaos26.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + IEnumerable renovacaos27 = renovacaos10.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str26; + }); + renovacaos4 = ( + from x in renovacaos27 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + else + { + IEnumerable vendedor5 = + from x in renovacaos10 + where x.get_Vendedor() == str26 + select x; + renovacaos4 = ( + from x in vendedor5 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + List renovacaos28 = renovacaos4; + if (renovacaos28.Count == 0) + { + continue; + } + string str27 = str26; + agrupamento1 = this.Agrupamento; + str = str27.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, renovacaos28, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List renovacaos29 = renovacaos10; + if (renovacaos29.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List renovacaos30 = renovacaos10; + renovacaos5 = ( + from x in renovacaos30 + where x.get_Selecionado() + select x).ToList(); + } + else + { + renovacaos5 = renovacaos10.ToList(); + } + List renovacaos31 = renovacaos5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", renovacaos31, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List renovacaos32 = renovacaos10; + IOrderedEnumerable estipulante4 = + from x in renovacaos32 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante4 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str28 in strs) + { + if (string.IsNullOrWhiteSpace(str28)) + { + continue; + } + List renovacaos33 = renovacaos10; + if (renovacaos33.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + IEnumerable renovacaos34 = renovacaos10.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str28; + }); + renovacaos6 = ( + from x in renovacaos34 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + else + { + IEnumerable estipulante5 = + from x in renovacaos10 + where x.get_Estipulante() == str28 + select x; + renovacaos6 = ( + from x in estipulante5 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + List renovacaos35 = renovacaos6; + if (renovacaos35.Count == 0) + { + continue; + } + string str29 = str28; + agrupamento1 = this.Agrupamento; + str = str29.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, renovacaos35, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List renovacaos36 = renovacaos10; + if (renovacaos36.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List renovacaos37 = renovacaos10; + renovacaos7 = ( + from x in renovacaos37 + where x.get_Selecionado() + select x).ToList(); + } + else + { + renovacaos7 = renovacaos10.ToList(); + } + List renovacaos38 = renovacaos7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", renovacaos38, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + this.ColunasOcultas = await Funcoes.OcultarColunas(this.Relatorio); + List renovacaos39 = renovacaos10; + IOrderedEnumerable status4 = + from x in renovacaos39 + orderby x.get_Status() + select x; + strs = ( + from x in status4 + select x.get_Status()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str30 in strs) + { + if (string.IsNullOrWhiteSpace(str30)) + { + continue; + } + List renovacaos40 = renovacaos10; + if (renovacaos40.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + IEnumerable renovacaos41 = renovacaos10.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Status() == str30; + }); + renovacaos8 = ( + from x in renovacaos41 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + else + { + IEnumerable status5 = + from x in renovacaos10 + where x.get_Status() == str30 + select x; + renovacaos8 = ( + from x in status5 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + List renovacaos42 = renovacaos8; + if (renovacaos42.Count == 0) + { + continue; + } + string str31 = str30; + agrupamento1 = this.Agrupamento; + str = str31.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, renovacaos42, this.Relatorio, true); + } + goto Label1; + } + else + { + List renovacaos43 = renovacaos10; + if (renovacaos43.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List renovacaos44 = renovacaos10; + list9 = ( + from x in renovacaos44 + where x.get_Selecionado() + select x).ToList(); + } + else + { + list9 = renovacaos10.ToList(); + } + List renovacaos45 = list9; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", renovacaos45, this.Relatorio, true); + goto Label1; + } + } + default: + { + List renovacaos46 = renovacaos10; + if (renovacaos46.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + List renovacaos47 = renovacaos10; + renovacaos9 = ( + from x in renovacaos47 + where x.get_Selecionado() + select x).ToList(); + } + else + { + renovacaos9 = renovacaos10.ToList(); + } + List renovacaos48 = renovacaos9; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", renovacaos48, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 5: + { + comissaos10 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ComissaoFiltrado == null || comissaos10.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List comissaos11 = comissaos10; + IOrderedEnumerable seguradora6 = + from x in comissaos11 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora6 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str32 in strs) + { + if (string.IsNullOrWhiteSpace(str32)) + { + continue; + } + List comissaos12 = comissaos10; + if (comissaos12.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + IEnumerable comissaos13 = comissaos10.Where((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str32; + }); + comissaos = ( + from x in comissaos13 + orderby x.get_Recebimento() + select x).ToList(); + } + else + { + IEnumerable seguradora7 = + from x in comissaos10 + where x.get_Seguradora() == str32 + select x; + comissaos = ( + from x in seguradora7 + orderby x.get_Recebimento() + select x).ToList(); + } + List comissaos14 = comissaos; + if (comissaos14.Count == 0) + { + continue; + } + string str33 = str32; + agrupamento1 = this.Agrupamento; + str = str33.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, comissaos14, this.Relatorio, true); + } + goto Label1; + } + else + { + List comissaos15 = comissaos10; + if (comissaos15.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + List comissaos16 = comissaos10; + comissaos1 = ( + from x in comissaos16 + where x.get_Selecionado() + select x).ToList(); + } + else + { + comissaos1 = comissaos10; + } + List comissaos17 = comissaos1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", comissaos17, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List comissaos18 = comissaos10; + IOrderedEnumerable ramo6 = + from x in comissaos18 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo6 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str34 in strs) + { + if (string.IsNullOrWhiteSpace(str34)) + { + continue; + } + List comissaos19 = comissaos10; + if (comissaos19.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + IEnumerable comissaos20 = comissaos10.Where((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str34; + }); + comissaos2 = ( + from x in comissaos20 + orderby x.get_Recebimento() + select x).ToList(); + } + else + { + IEnumerable ramo7 = + from x in comissaos10 + where x.get_Ramo() == str34 + select x; + comissaos2 = ( + from x in ramo7 + orderby x.get_Recebimento() + select x).ToList(); + } + List comissaos21 = comissaos2; + if (comissaos21.Count == 0) + { + continue; + } + string str35 = str34; + agrupamento1 = this.Agrupamento; + str = str35.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, comissaos21, this.Relatorio, true); + } + goto Label1; + } + else + { + List comissaos22 = comissaos10; + if (comissaos22.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + List comissaos23 = comissaos10; + comissaos3 = ( + from x in comissaos23 + where x.get_Selecionado() + select x).ToList(); + } + else + { + comissaos3 = comissaos10; + } + List comissaos24 = comissaos3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", comissaos24, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List comissaos25 = comissaos10; + IOrderedEnumerable vendedor6 = + from x in comissaos25 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor6 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str36 in strs) + { + if (string.IsNullOrWhiteSpace(str36)) + { + continue; + } + List comissaos26 = comissaos10; + if (comissaos26.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + IEnumerable comissaos27 = comissaos10.Where((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str36; + }); + comissaos4 = ( + from x in comissaos27 + orderby x.get_Recebimento() + select x).ToList(); + } + else + { + IEnumerable vendedor7 = + from x in comissaos10 + where x.get_Vendedor() == str36 + select x; + comissaos4 = ( + from x in vendedor7 + orderby x.get_Recebimento() + select x).ToList(); + } + List comissaos28 = comissaos4; + if (comissaos28.Count == 0) + { + continue; + } + string str37 = str36; + agrupamento1 = this.Agrupamento; + str = str37.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, comissaos28, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List comissaos29 = comissaos10; + if (comissaos29.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + List comissaos30 = comissaos10; + comissaos5 = ( + from x in comissaos30 + where x.get_Selecionado() + select x).ToList(); + } + else + { + comissaos5 = comissaos10; + } + List comissaos31 = comissaos5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", comissaos31, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List comissaos32 = comissaos10; + IOrderedEnumerable estipulante6 = + from x in comissaos32 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante6 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str38 in strs) + { + if (string.IsNullOrWhiteSpace(str38)) + { + continue; + } + List comissaos33 = comissaos10; + if (comissaos33.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + IEnumerable comissaos34 = comissaos10.Where((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str38; + }); + comissaos6 = ( + from x in comissaos34 + orderby x.get_Recebimento() + select x).ToList(); + } + else + { + IEnumerable estipulante7 = + from x in comissaos10 + where x.get_Estipulante() == str38 + select x; + comissaos6 = ( + from x in estipulante7 + orderby x.get_Recebimento() + select x).ToList(); + } + List comissaos35 = comissaos6; + if (comissaos35.Count == 0) + { + continue; + } + string str39 = str38; + agrupamento1 = this.Agrupamento; + str = str39.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, comissaos35, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List comissaos36 = comissaos10; + if (comissaos36.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + List comissaos37 = comissaos10; + comissaos7 = ( + from x in comissaos37 + where x.get_Selecionado() + select x).ToList(); + } + else + { + comissaos7 = comissaos10; + } + List comissaos38 = comissaos7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", comissaos38, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + List comissaos39 = comissaos10; + IOrderedEnumerable status6 = + from x in comissaos39 + orderby x.get_Status() + select x; + strs = ( + from x in status6 + select x.get_Status()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str40 in strs) + { + if (string.IsNullOrWhiteSpace(str40)) + { + continue; + } + List comissaos40 = comissaos10; + if (comissaos40.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + IEnumerable comissaos41 = comissaos10.Where((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Status() == str40; + }); + comissaos8 = ( + from x in comissaos41 + orderby x.get_Recebimento() + select x).ToList(); + } + else + { + IEnumerable status7 = + from x in comissaos10 + where x.get_Status() == str40 + select x; + comissaos8 = ( + from x in status7 + orderby x.get_Recebimento() + select x).ToList(); + } + List comissaos42 = comissaos8; + if (comissaos42.Count == 0) + { + continue; + } + string str41 = str40; + agrupamento1 = this.Agrupamento; + str = str41.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, comissaos42, this.ColunasOcultas); + } + goto Label1; + } + else + { + List comissaos43 = comissaos10; + if (comissaos43.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + List comissaos44 = comissaos10; + comissaos9 = ( + from x in comissaos44 + where x.get_Selecionado() + select x).ToList(); + } + else + { + comissaos9 = comissaos10; + } + List comissaos45 = comissaos9; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", comissaos45, this.ColunasOcultas); + goto Label1; + } + } + default: + { + List comissaos46 = comissaos10; + if (comissaos46.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + List comissaos47 = comissaos10; + list10 = ( + from x in comissaos47 + where x.get_Selecionado() + select x).ToList(); + } + else + { + list10 = comissaos10; + } + List comissaos48 = list10; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", comissaos48, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 6: + case 16: + { + list11 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.PendenteFiltrado == null || list11.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List pendentes11 = list11; + IOrderedEnumerable seguradora8 = + from x in pendentes11 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora8 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str42 in strs) + { + if (string.IsNullOrWhiteSpace(str42)) + { + continue; + } + List pendentes12 = list11; + if (pendentes12.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + IEnumerable pendentes13 = list11.Where((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str42; + }); + pendentes = ( + from x in pendentes13 + orderby x.get_Vencimento() + select x).ToList(); + } + else + { + IEnumerable seguradora9 = + from x in list11 + where x.get_Seguradora() == str42 + select x; + pendentes = ( + from x in seguradora9 + orderby x.get_Vencimento() + select x).ToList(); + } + List pendentes14 = pendentes; + if (pendentes14.Count == 0) + { + continue; + } + string str43 = str42; + agrupamento1 = this.Agrupamento; + str = str43.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, pendentes14, this.Relatorio, true); + } + goto Label1; + } + else + { + List pendentes15 = list11; + if (pendentes15.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + List pendentes16 = list11; + pendentes1 = ( + from x in pendentes16 + where x.get_Selecionado() + select x).ToList(); + } + else + { + pendentes1 = list11; + } + List pendentes17 = pendentes1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", pendentes17, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List pendentes18 = list11; + IOrderedEnumerable ramo8 = + from x in pendentes18 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo8 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str44 in strs) + { + if (string.IsNullOrWhiteSpace(str44)) + { + continue; + } + List pendentes19 = list11; + if (pendentes19.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + IEnumerable pendentes20 = list11.Where((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str44; + }); + pendentes2 = ( + from x in pendentes20 + orderby x.get_Vencimento() + select x).ToList(); + } + else + { + IEnumerable ramo9 = + from x in list11 + where x.get_Ramo() == str44 + select x; + pendentes2 = ( + from x in ramo9 + orderby x.get_Vencimento() + select x).ToList(); + } + List pendentes21 = pendentes2; + if (pendentes21.Count == 0) + { + continue; + } + string str45 = str44; + agrupamento1 = this.Agrupamento; + str = str45.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, pendentes21, this.Relatorio, true); + } + goto Label1; + } + else + { + List pendentes22 = list11; + if (pendentes22.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + List pendentes23 = list11; + pendentes3 = ( + from x in pendentes23 + where x.get_Selecionado() + select x).ToList(); + } + else + { + pendentes3 = list11; + } + List pendentes24 = pendentes3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", pendentes24, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List pendentes25 = list11; + IOrderedEnumerable vendedor8 = + from x in pendentes25 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor8 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str46 in strs) + { + if (string.IsNullOrWhiteSpace(str46)) + { + continue; + } + List pendentes26 = list11; + if (pendentes26.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + IEnumerable pendentes27 = list11.Where((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str46; + }); + pendentes4 = ( + from x in pendentes27 + orderby x.get_Vencimento() + select x).ToList(); + } + else + { + IEnumerable vendedor9 = + from x in list11 + where x.get_Vendedor() == str46 + select x; + pendentes4 = ( + from x in vendedor9 + orderby x.get_Vencimento() + select x).ToList(); + } + List pendentes28 = pendentes4; + if (pendentes28.Count == 0) + { + continue; + } + string str47 = str46; + agrupamento1 = this.Agrupamento; + str = str47.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, pendentes28, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List pendentes29 = list11; + if (pendentes29.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + List pendentes30 = list11; + pendentes5 = ( + from x in pendentes30 + where x.get_Selecionado() + select x).ToList(); + } + else + { + pendentes5 = list11; + } + List pendentes31 = pendentes5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", pendentes31, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List pendentes32 = list11; + IOrderedEnumerable estipulante8 = + from x in pendentes32 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante8 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str48 in strs) + { + if (string.IsNullOrWhiteSpace(str48)) + { + continue; + } + List pendentes33 = list11; + if (pendentes33.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + IEnumerable pendentes34 = list11.Where((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str48; + }); + pendentes6 = ( + from x in pendentes34 + orderby x.get_Vencimento() + select x).ToList(); + } + else + { + IEnumerable estipulante9 = + from x in list11 + where x.get_Estipulante() == str48 + select x; + pendentes6 = ( + from x in estipulante9 + orderby x.get_Vencimento() + select x).ToList(); + } + List pendentes35 = pendentes6; + if (pendentes35.Count == 0) + { + continue; + } + string str49 = str48; + agrupamento1 = this.Agrupamento; + str = str49.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, pendentes35, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List pendentes36 = list11; + if (pendentes36.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + List pendentes37 = list11; + pendentes7 = ( + from x in pendentes37 + where x.get_Selecionado() + select x).ToList(); + } + else + { + pendentes7 = list11; + } + List pendentes38 = pendentes7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", pendentes38, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + List pendentes39 = list11; + IOrderedEnumerable status8 = + from x in pendentes39 + orderby x.get_Status() + select x; + strs = ( + from x in status8 + select x.get_Status()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str50 in strs) + { + if (string.IsNullOrWhiteSpace(str50)) + { + continue; + } + List pendentes40 = list11; + if (pendentes40.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + IEnumerable pendentes41 = list11.Where((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Status() == str50; + }); + pendentes8 = ( + from x in pendentes41 + orderby x.get_Vencimento() + select x).ToList(); + } + else + { + IEnumerable status9 = + from x in list11 + where x.get_Status() == str50 + select x; + pendentes8 = ( + from x in status9 + orderby x.get_Vencimento() + select x).ToList(); + } + List pendentes42 = pendentes8; + if (pendentes42.Count == 0) + { + continue; + } + string str51 = str50; + agrupamento1 = this.Agrupamento; + str = str51.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, pendentes42, this.ColunasOcultas); + } + goto Label1; + } + else + { + List pendentes43 = list11; + if (pendentes43.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + List pendentes44 = list11; + pendentes9 = ( + from x in pendentes44 + where x.get_Selecionado() + select x).ToList(); + } + else + { + pendentes9 = list11; + } + List pendentes45 = pendentes9; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", pendentes45, this.ColunasOcultas); + goto Label1; + } + } + default: + { + List pendentes46 = list11; + if (pendentes46.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + List pendentes47 = list11; + pendentes10 = ( + from x in pendentes47 + where x.get_Selecionado() + select x).ToList(); + } + else + { + pendentes10 = list11; + } + List pendentes48 = pendentes10; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", pendentes48, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 7: + { + if (this.Pagamentos != null) + { + List pagamentosSintetico = this.PagamentosSintetico; + List pagamentoSinteticos = ( + from x in pagamentosSintetico + orderby x.get_Titulo() descending + select x).ToList(); + foreach (PagamentoSintetico pagamentoSintetico in pagamentoSinteticos) + { + string titulo = pagamentoSintetico.get_Titulo(); + agrupamento = this.Agrupamento; + string str52 = titulo.ValidaNomePlanilha(agrupamento.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str52, pagamentoSintetico.get_Agrupamento().ToList(), this.Relatorio, true); + } + num = 1; + List pagamentos = this.Pagamentos; + List pagamentos1 = ( + from x in pagamentos + orderby x.get_Title() descending + select x).ToList(); + foreach (Pagamento pagamento in pagamentos1) + { + string title = pagamento.get_Title(); + agrupamento = this.Agrupamento; + string str53 = title.ValidaNomePlanilha(agrupamento.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str53, pagamento.get_Dados().ToList(), this.Relatorio, true); + num++; + } + List agrupamentoVendedors = new List(); + List pagamentos2 = this.Pagamentos; + foreach (Pagamento pagamento1 in + from x in pagamentos2 + orderby x.get_Title() + select x) + { + agrupamentoVendedors.Add(pagamento1.get_Vendedores()); + } + List agrupamentoVendedors1 = agrupamentoVendedors; + AgrupamentoVendedor agrupamentoVendedor = new AgrupamentoVendedor(); + agrupamentoVendedor.set_Vendedor("TOTAL"); + List agrupamentoVendedors2 = agrupamentoVendedors; + agrupamentoVendedor.set_Repasse(agrupamentoVendedors2.Sum((AgrupamentoVendedor p) => p.get_Repasse())); + List agrupamentoVendedors3 = agrupamentoVendedors; + agrupamentoVendedor.set_Debito(agrupamentoVendedors3.Sum((AgrupamentoVendedor p) => p.get_Debito())); + List agrupamentoVendedors4 = agrupamentoVendedors; + agrupamentoVendedor.set_Credito(agrupamentoVendedors4.Sum((AgrupamentoVendedor p) => p.get_Credito())); + List agrupamentoVendedors5 = agrupamentoVendedors; + agrupamentoVendedor.set_Desconto(agrupamentoVendedors5.Sum((AgrupamentoVendedor p) => p.get_Desconto())); + List agrupamentoVendedors6 = agrupamentoVendedors; + agrupamentoVendedor.set_Adiantamento(agrupamentoVendedors6.Sum((AgrupamentoVendedor p) => p.get_Adiantamento())); + List agrupamentoVendedors7 = agrupamentoVendedors; + agrupamentoVendedor.set_ValorLiquido(agrupamentoVendedors7.Sum((AgrupamentoVendedor p) => p.get_ValorLiquido())); + agrupamentoVendedors1.Add(agrupamentoVendedor); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "DADOS BANCÁRIOS", agrupamentoVendedors, this.Relatorio, false); + goto case 22; + } + else + { + break; + } + } + case 8: + { + auditorias11 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.AuditoriaFiltrado == null || auditorias11.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List auditorias12 = auditorias11; + IOrderedEnumerable seguradora10 = + from x in auditorias12 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora10 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str54 in strs) + { + if (string.IsNullOrWhiteSpace(str54)) + { + continue; + } + List auditorias13 = auditorias11; + if (auditorias13.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + IEnumerable auditorias14 = auditorias11.Where((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str54; + }); + auditorias = ( + from x in auditorias14 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable seguradora11 = + from x in auditorias11 + where x.get_Seguradora() == str54 + select x; + auditorias = ( + from x in seguradora11 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List auditorias15 = auditorias; + if (auditorias15.Count == 0) + { + continue; + } + string str55 = str54; + agrupamento1 = this.Agrupamento; + str = str55.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, auditorias15, this.Relatorio, true); + } + goto Label1; + } + else + { + List auditorias16 = auditorias11; + if (auditorias16.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + List auditorias17 = auditorias11; + auditorias1 = ( + from x in auditorias17 + where x.get_Selecionado() + select x).ToList(); + } + else + { + auditorias1 = auditorias11; + } + List auditorias18 = auditorias1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", auditorias18, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List auditorias19 = auditorias11; + IOrderedEnumerable ramo10 = + from x in auditorias19 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo10 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str56 in strs) + { + if (string.IsNullOrWhiteSpace(str56)) + { + continue; + } + List auditorias20 = auditorias11; + if (auditorias20.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + IEnumerable auditorias21 = auditorias11.Where((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str56; + }); + auditorias2 = ( + from x in auditorias21 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable ramo11 = + from x in auditorias11 + where x.get_Ramo() == str56 + select x; + auditorias2 = ( + from x in ramo11 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List auditorias22 = auditorias2; + if (auditorias22.Count == 0) + { + continue; + } + string str57 = str56; + agrupamento1 = this.Agrupamento; + str = str57.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, auditorias22, this.Relatorio, true); + } + goto Label1; + } + else + { + List auditorias23 = auditorias11; + if (auditorias23.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + List auditorias24 = auditorias11; + auditorias3 = ( + from x in auditorias24 + where x.get_Selecionado() + select x).ToList(); + } + else + { + auditorias3 = auditorias11; + } + List auditorias25 = auditorias3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", auditorias25, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List auditorias26 = auditorias11; + IOrderedEnumerable vendedor10 = + from x in auditorias26 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor10 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str58 in strs) + { + if (string.IsNullOrWhiteSpace(str58)) + { + continue; + } + List auditorias27 = auditorias11; + if (auditorias27.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + IEnumerable auditorias28 = auditorias11.Where((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str58; + }); + auditorias4 = ( + from x in auditorias28 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable vendedor11 = + from x in auditorias11 + where x.get_Vendedor() == str58 + select x; + auditorias4 = ( + from x in vendedor11 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List auditorias29 = auditorias4; + if (auditorias29.Count == 0) + { + continue; + } + string str59 = str58; + agrupamento1 = this.Agrupamento; + str = str59.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, auditorias29, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List auditorias30 = auditorias11; + if (auditorias30.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + List auditorias31 = auditorias11; + auditorias5 = ( + from x in auditorias31 + where x.get_Selecionado() + select x).ToList(); + } + else + { + auditorias5 = auditorias11; + } + List auditorias32 = auditorias5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", auditorias32, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List auditorias33 = auditorias11; + IOrderedEnumerable estipulante10 = + from x in auditorias33 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante10 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str60 in strs) + { + if (string.IsNullOrWhiteSpace(str60)) + { + continue; + } + List auditorias34 = auditorias11; + if (auditorias34.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + IEnumerable auditorias35 = auditorias11.Where((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str60; + }); + auditorias6 = ( + from x in auditorias35 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable estipulante11 = + from x in auditorias11 + where x.get_Estipulante() == str60 + select x; + auditorias6 = ( + from x in estipulante11 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List auditorias36 = auditorias6; + if (auditorias36.Count == 0) + { + continue; + } + string str61 = str60; + agrupamento1 = this.Agrupamento; + str = str61.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, auditorias36, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List auditorias37 = auditorias11; + if (auditorias37.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + List auditorias38 = auditorias11; + auditorias7 = ( + from x in auditorias38 + where x.get_Selecionado() + select x).ToList(); + } + else + { + auditorias7 = auditorias11; + } + List auditorias39 = auditorias7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", auditorias39, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + List auditorias40 = auditorias11; + IOrderedEnumerable status10 = + from x in auditorias40 + orderby x.get_Status() + select x; + strs = ( + from x in status10 + select x.get_Status()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str62 in strs) + { + if (string.IsNullOrWhiteSpace(str62)) + { + continue; + } + List auditorias41 = auditorias11; + if (auditorias41.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + IEnumerable auditorias42 = auditorias11.Where((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Status() == str62; + }); + auditorias8 = ( + from x in auditorias42 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + else + { + IEnumerable status11 = + from x in auditorias11 + where x.get_Status() == str62 + select x; + auditorias8 = ( + from x in status11 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + List auditorias43 = auditorias8; + if (auditorias43.Count == 0) + { + continue; + } + string str63 = str62; + agrupamento1 = this.Agrupamento; + str = str63.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, auditorias43, this.ColunasOcultas); + } + goto Label1; + } + else + { + List auditorias44 = auditorias11; + if (auditorias44.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + List auditorias45 = auditorias11; + auditorias9 = ( + from x in auditorias45 + where x.get_Selecionado() + select x).ToList(); + } + else + { + auditorias9 = auditorias11; + } + List auditorias46 = auditorias9; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", auditorias46, this.ColunasOcultas); + goto Label1; + } + } + default: + { + List auditorias47 = auditorias11; + if (auditorias47.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + List auditorias48 = auditorias11; + auditorias10 = ( + from x in auditorias48 + where x.get_Selecionado() + select x).ToList(); + } + else + { + auditorias10 = auditorias11; + } + List auditorias49 = auditorias10; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", auditorias49, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 9: + case 10: + { + sinistros11 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.SinistroFiltrado == null || sinistros11.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + IEnumerable sinistros12 = ((GridRelatorio)this.Report).DataGrid.Items.Cast(); + IOrderedEnumerable seguradora12 = + from x in sinistros12 + orderby x.get_Seguradora() + select x; + strs = ( + from x in seguradora12 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str64 in strs) + { + if (string.IsNullOrWhiteSpace(str64)) + { + continue; + } + List sinistros13 = sinistros11; + if (sinistros13.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + IEnumerable sinistros14 = sinistros11.Where((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str64; + }); + sinistros = ( + from x in sinistros14 + orderby x.get_DataSinistro() + select x).ToList(); + } + else + { + IEnumerable seguradora13 = + from x in sinistros11 + where x.get_Seguradora() == str64 + select x; + sinistros = ( + from x in seguradora13 + orderby x.get_DataSinistro() + select x).ToList(); + } + List sinistros15 = sinistros; + if (sinistros15.Count == 0) + { + continue; + } + string str65 = str64; + agrupamento1 = this.Agrupamento; + str = str65.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, sinistros15, this.Relatorio, true); + } + goto Label1; + } + else + { + List sinistros16 = sinistros11; + if (sinistros16.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + List sinistros17 = sinistros11; + sinistros1 = ( + from x in sinistros17 + where x.get_Selecionado() + select x).ToList(); + } + else + { + sinistros1 = sinistros11; + } + List sinistros18 = sinistros1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", sinistros18, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + IEnumerable sinistros19 = ((GridRelatorio)this.Report).DataGrid.Items.Cast(); + IOrderedEnumerable ramo12 = + from x in sinistros19 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo12 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str66 in strs) + { + if (string.IsNullOrWhiteSpace(str66)) + { + continue; + } + List sinistros20 = sinistros11; + if (sinistros20.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + IEnumerable sinistros21 = sinistros11.Where((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str66; + }); + sinistros2 = ( + from x in sinistros21 + orderby x.get_DataSinistro() + select x).ToList(); + } + else + { + IEnumerable ramo13 = + from x in sinistros11 + where x.get_Ramo() == str66 + select x; + sinistros2 = ( + from x in ramo13 + orderby x.get_DataSinistro() + select x).ToList(); + } + List sinistros22 = sinistros2; + if (sinistros22.Count == 0) + { + continue; + } + string str67 = str66; + agrupamento1 = this.Agrupamento; + str = str67.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, sinistros22, this.Relatorio, true); + } + goto Label1; + } + else + { + List sinistros23 = sinistros11; + if (sinistros23.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + List sinistros24 = sinistros11; + sinistros3 = ( + from x in sinistros24 + where x.get_Selecionado() + select x).ToList(); + } + else + { + sinistros3 = sinistros11; + } + List sinistros25 = sinistros3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", sinistros25, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + IEnumerable sinistros26 = ((GridRelatorio)this.Report).DataGrid.Items.Cast(); + IOrderedEnumerable vendedor12 = + from x in sinistros26 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor12 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str68 in strs) + { + if (string.IsNullOrWhiteSpace(str68)) + { + continue; + } + List sinistros27 = sinistros11; + if (sinistros27.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + IEnumerable sinistros28 = sinistros11.Where((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str68; + }); + sinistros4 = ( + from x in sinistros28 + orderby x.get_DataSinistro() + select x).ToList(); + } + else + { + IEnumerable vendedor13 = + from x in sinistros11 + where x.get_Vendedor() == str68 + select x; + sinistros4 = ( + from x in vendedor13 + orderby x.get_DataSinistro() + select x).ToList(); + } + List sinistros29 = sinistros4; + if (sinistros29.Count == 0) + { + continue; + } + string str69 = str68; + agrupamento1 = this.Agrupamento; + str = str69.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, sinistros29, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List sinistros30 = sinistros11; + if (sinistros30.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + List sinistros31 = sinistros11; + sinistros5 = ( + from x in sinistros31 + where x.get_Selecionado() + select x).ToList(); + } + else + { + sinistros5 = sinistros11; + } + List sinistros32 = sinistros5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", sinistros32, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + IEnumerable sinistros33 = ((GridRelatorio)this.Report).DataGrid.Items.Cast(); + IOrderedEnumerable estipulante12 = + from x in sinistros33 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante12 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str70 in strs) + { + if (string.IsNullOrWhiteSpace(str70)) + { + continue; + } + List sinistros34 = sinistros11; + if (sinistros34.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + IEnumerable sinistros35 = sinistros11.Where((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str70; + }); + sinistros6 = ( + from x in sinistros35 + orderby x.get_DataSinistro() + select x).ToList(); + } + else + { + IEnumerable estipulante13 = + from x in sinistros11 + where x.get_Estipulante() == str70 + select x; + sinistros6 = ( + from x in estipulante13 + orderby x.get_DataSinistro() + select x).ToList(); + } + List sinistros36 = sinistros6; + if (sinistros36.Count == 0) + { + continue; + } + string str71 = str70; + agrupamento1 = this.Agrupamento; + str = str71.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, sinistros36, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List sinistros37 = sinistros11; + if (sinistros37.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + List sinistros38 = sinistros11; + sinistros7 = ( + from x in sinistros38 + where x.get_Selecionado() + select x).ToList(); + } + else + { + sinistros7 = sinistros11; + } + List sinistros39 = sinistros7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", sinistros39, this.Relatorio, true); + goto Label1; + } + } + case 5: + { + IEnumerable sinistros40 = ((GridRelatorio)this.Report).DataGrid.Items.Cast(); + IOrderedEnumerable statusApolice = + from x in sinistros40 + orderby x.get_StatusApolice() + select x; + strs = ( + from x in statusApolice + select EnumHelper.GetDescription(x.get_StatusSinistro())).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str72 in strs) + { + if (string.IsNullOrWhiteSpace(str72)) + { + continue; + } + List sinistros41 = sinistros11; + if (sinistros41.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + IEnumerable sinistros42 = sinistros11.Where((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_StatusApolice() == str72; + }); + sinistros8 = ( + from x in sinistros42 + orderby x.get_DataSinistro() + select x).ToList(); + } + else + { + IEnumerable statusApolice1 = + from x in sinistros11 + where x.get_StatusApolice() == str72 + select x; + sinistros8 = ( + from x in statusApolice1 + orderby x.get_DataSinistro() + select x).ToList(); + } + List sinistros43 = sinistros8; + if (sinistros43.Count == 0) + { + continue; + } + string str73 = str72; + agrupamento1 = this.Agrupamento; + str = str73.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, sinistros43, this.ColunasOcultas); + } + goto Label1; + } + else + { + List sinistros44 = sinistros11; + if (sinistros44.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + List sinistros45 = sinistros11; + sinistros9 = ( + from x in sinistros45 + where x.get_Selecionado() + select x).ToList(); + } + else + { + sinistros9 = sinistros11; + } + List sinistros46 = sinistros9; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", sinistros46, this.ColunasOcultas); + goto Label1; + } + } + default: + { + List sinistros47 = sinistros11; + if (sinistros47.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + List sinistros48 = sinistros11; + sinistros10 = ( + from x in sinistros48 + where x.get_Selecionado() + select x).ToList(); + } + else + { + sinistros10 = sinistros11; + } + List sinistros49 = sinistros10; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", sinistros49, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 11: + { + List fechamentos = new List(); + if ((GridRelatorio)this.Report != null) + { + fechamentos = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + } + if (this.FechamentoFiltrado == null || fechamentos.Count == 0 && (GridRelatorio)this.Report != null) + { + break; + } + else + { + num = 1; + foreach (Fechamentos fechamento in this.Fechamento) + { + string title1 = fechamento.get_Title(); + agrupamento = this.Agrupamento; + string str74 = title1.ValidaNomePlanilha(agrupamento.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str74, fechamento.get_Fechamento().ToList(), this.Relatorio, true); + num++; + } + goto case 22; + } + } + case 12: + { + List faturaPendentes1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.FaturaPendenteFiltrado == null || faturaPendentes1.Count == 0) + { + break; + } + else + { + List faturaPendentes2 = faturaPendentes1; + if (faturaPendentes2.Any((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente x) => x.get_Selecionado())) + { + List faturaPendentes3 = faturaPendentes1; + faturaPendentes = ( + from x in faturaPendentes3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + faturaPendentes = faturaPendentes1; + } + List faturaPendentes4 = faturaPendentes; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", faturaPendentes4, this.Relatorio, true); + goto case 22; + } + } + case 13: + { + List extratoBaixadoRelatorios1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ExtratosFiltrado == null || extratoBaixadoRelatorios1.Count == 0) + { + break; + } + else + { + List extratoBaixadoRelatorios2 = extratoBaixadoRelatorios1; + if (extratoBaixadoRelatorios2.Any((ExtratoBaixadoRelatorio x) => x.get_Selecionado())) + { + List extratoBaixadoRelatorios3 = extratoBaixadoRelatorios1; + extratoBaixadoRelatorios = ( + from x in extratoBaixadoRelatorios3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + extratoBaixadoRelatorios = extratoBaixadoRelatorios1; + } + List extratoBaixadoRelatorios4 = extratoBaixadoRelatorios; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", extratoBaixadoRelatorios4, this.Relatorio, true); + goto case 22; + } + } + case 14: + { + List metaSeguradoraRelatorios1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.MetaSeguradoraFiltrado == null || metaSeguradoraRelatorios1.Count == 0) + { + break; + } + else + { + List metaSeguradoraRelatorios2 = metaSeguradoraRelatorios1; + if (metaSeguradoraRelatorios2.Any((MetaSeguradoraRelatorio x) => x.get_Selecionado())) + { + List metaSeguradoraRelatorios3 = metaSeguradoraRelatorios1; + metaSeguradoraRelatorios = ( + from x in metaSeguradoraRelatorios3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + metaSeguradoraRelatorios = metaSeguradoraRelatorios1; + } + List metaSeguradoraRelatorios4 = metaSeguradoraRelatorios; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", metaSeguradoraRelatorios4, this.Relatorio, true); + goto case 22; + } + } + case 15: + { + List metaVendedorRelatorios1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.MetaVendedorFiltrado == null || metaVendedorRelatorios1.Count == 0) + { + break; + } + else + { + List metaVendedorRelatorios2 = metaVendedorRelatorios1; + if (metaVendedorRelatorios2.Any((MetaVendedorRelatorio x) => x.get_Selecionado())) + { + List metaVendedorRelatorios3 = metaVendedorRelatorios1; + metaVendedorRelatorios = ( + from x in metaVendedorRelatorios3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + metaVendedorRelatorios = metaVendedorRelatorios1; + } + List metaVendedorRelatorios4 = metaVendedorRelatorios; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", metaVendedorRelatorios4, this.Relatorio, true); + goto case 22; + } + } + case 17: + { + List licenciamentos1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.LicenciamentoFiltrado == null || licenciamentos1.Count == 0) + { + break; + } + else + { + List licenciamentos2 = licenciamentos1; + if (licenciamentos2.Any((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => x.get_Selecionado())) + { + List licenciamentos3 = licenciamentos1; + licenciamentos = ( + from x in licenciamentos3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + licenciamentos = licenciamentos1; + } + List licenciamentos4 = licenciamentos; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", licenciamentos4, this.Relatorio, true); + goto case 22; + } + } + case 18: + { + List tarefas1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.TarefaFiltrado == null || tarefas1.Count == 0) + { + break; + } + else + { + List tarefas2 = tarefas1; + if (tarefas2.Any((Gestor.Model.Domain.Relatorios.Tarefa.Tarefa x) => x.get_Selecionado())) + { + List tarefas3 = tarefas1; + tarefas = ( + from x in tarefas3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + tarefas = tarefas1; + } + List tarefas4 = tarefas; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", tarefas4, this.Relatorio, true); + goto case 22; + } + } + case 19: + { + List notaFiscalRelatorios1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.NotaFiscalFiltrado == null || notaFiscalRelatorios1.Count == 0) + { + break; + } + else + { + List notaFiscalRelatorios2 = notaFiscalRelatorios1; + if (notaFiscalRelatorios2.Any((NotaFiscalRelatorio x) => x.get_Selecionado())) + { + List notaFiscalRelatorios3 = notaFiscalRelatorios1; + notaFiscalRelatorios = ( + from x in notaFiscalRelatorios3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + notaFiscalRelatorios = notaFiscalRelatorios1; + } + List notaFiscalRelatorios4 = notaFiscalRelatorios; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", notaFiscalRelatorios4, this.Relatorio, true); + goto case 22; + } + } + case 20: + { + if (this.PrevisaoFiltrado != null) + { + ObservableCollection previsaoSintetico = this.PrevisaoSintetico; + List previsaoPagamentoComissaoSinteticos = ( + from x in previsaoSintetico + orderby x.get_Titulo() descending + select x).ToList(); + foreach (PrevisaoPagamentoComissaoSintetico previsaoPagamentoComissaoSintetico in previsaoPagamentoComissaoSinteticos) + { + string titulo1 = previsaoPagamentoComissaoSintetico.get_Titulo(); + agrupamento = this.Agrupamento; + string str75 = titulo1.ValidaNomePlanilha(agrupamento.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str75, previsaoPagamentoComissaoSintetico.get_Agrupamento().ToList(), this.Relatorio, false); + } + num = 1; + foreach (PrevisaoPagamentoComissao previsao in this.Previsao) + { + string vendedor14 = previsao.get_Vendedor(); + agrupamento = this.Agrupamento; + string str76 = vendedor14.ValidaNomePlanilha(agrupamento.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str76, previsao.get_PrevisaoPagamento().ToList(), this.Relatorio, true); + num++; + } + goto case 22; + } + else + { + break; + } + } + case 21: + case 22: + { + Label1: + renovacaos10 = null; + producaos6 = null; + apolicePendentes8 = null; + comissaos10 = null; + list11 = null; + sinistros11 = null; + auditorias11 = null; + placas9 = null; + if (this.SinteticoRelatorio != null && this.SinteticoRelatorio.Count > 0) + { + xLWorkbook = await Funcoes.GerarXlsSintetico(xLWorkbook, "SINTÉTICO", this.Sintetic.ToList()); + } + if (this.FiltroRelatorioSelecionado != null && this.FiltroRelatorioSelecionado.Count > 0) + { + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "FILTROS", this.FiltroRelatorioSelecionado.ToList(), this.ColunasOcultas); + } + base.RegistrarAcao(string.Format("EMITIU EXCEL DO RELATÓRIO PERÍODO ENTRE {0:d} E {1:d}", this.Inicio, this.Fim), new Gestor.Model.Common.Relatorio?(this.Relatorio), this.Filtros); + xLWorkbook.SaveAs(str1); + Process.Start(str1); + break; + } + case 23: + { + List logsEnvios1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.LogsEnvioFiltrado == null || logsEnvios1.Count == 0) + { + break; + } + else + { + List logsEnvios2 = logsEnvios1; + if (logsEnvios2.Any((Gestor.Model.Domain.Relatorios.LogsEnvio.LogsEnvio x) => x.get_Selecionado())) + { + List logsEnvios3 = logsEnvios1; + logsEnvios = ( + from x in logsEnvios3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + logsEnvios = logsEnvios1; + } + List logsEnvios4 = logsEnvios; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", logsEnvios4, this.Relatorio, true); + goto case 22; + } + } + case 24: + case 25: + { + List logAcaoRelatorios1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.LogUtilizacaoFiltrado == null || logAcaoRelatorios1.Count == 0) + { + break; + } + else + { + List logAcaoRelatorios2 = logAcaoRelatorios1; + if (logAcaoRelatorios2.Any((LogAcaoRelatorio x) => x.get_Selecionado())) + { + List logAcaoRelatorios3 = logAcaoRelatorios1; + logAcaoRelatorios = ( + from x in logAcaoRelatorios3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + logAcaoRelatorios = logAcaoRelatorios1; + } + List logAcaoRelatorios4 = logAcaoRelatorios; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", logAcaoRelatorios4, this.Relatorio, true); + goto case 22; + } + } + case 26: + { + List apoliceCriticas1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ApoliceCriticaFiltrado == null || apoliceCriticas1.Count == 0) + { + break; + } + else + { + List apoliceCriticas2 = apoliceCriticas1; + if (apoliceCriticas2.Any((Gestor.Model.Domain.Relatorios.CriticaApolice.ApoliceCritica x) => x.get_Selecionado())) + { + List apoliceCriticas3 = apoliceCriticas1; + apoliceCriticas = ( + from x in apoliceCriticas3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + apoliceCriticas = apoliceCriticas1; + } + List apoliceCriticas4 = apoliceCriticas; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", apoliceCriticas4, this.Relatorio, true); + goto case 22; + } + } + case 27: + { + placas9 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.PlacaFiltrado == null || placas9.Count == 0) + { + break; + } + else + { + switch (this.Agrupamento) + { + case 1: + { + List placas10 = placas9; + IOrderedEnumerable placas11 = + from x in placas10 + orderby x.get_Seguradora() + select x; + strs = ( + from x in placas11 + select x.get_Seguradora()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str77 in strs) + { + if (string.IsNullOrWhiteSpace(str77)) + { + continue; + } + List placas12 = placas9; + placas = (placas12.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado()) ? placas9.Where((Gestor.Model.Domain.Relatorios.Placa.Placas x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Seguradora() == str77; + }).ToList() : ( + from x in placas9 + where x.get_Seguradora() == str77 + select x).ToList()); + List placas13 = placas; + if (placas13.Count == 0) + { + continue; + } + string str78 = str77; + agrupamento1 = this.Agrupamento; + str = str78.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, placas13, this.Relatorio, true); + } + goto Label1; + } + else + { + List placas14 = placas9; + if (placas14.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado())) + { + List placas15 = placas9; + placas1 = ( + from x in placas15 + where x.get_Selecionado() + select x).ToList(); + } + else + { + placas1 = placas9; + } + List placas16 = placas1; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", placas16, this.Relatorio, true); + goto Label1; + } + } + case 2: + { + List placas17 = placas9; + IOrderedEnumerable ramo14 = + from x in placas17 + orderby x.get_Ramo() + select x; + strs = ( + from x in ramo14 + select x.get_Ramo()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + foreach (string str79 in strs) + { + if (string.IsNullOrWhiteSpace(str79)) + { + continue; + } + List placas18 = placas9; + placas2 = (placas18.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado()) ? placas9.Where((Gestor.Model.Domain.Relatorios.Placa.Placas x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Ramo() == str79; + }).ToList() : ( + from x in placas9 + where x.get_Ramo() == str79 + select x).ToList()); + List placas19 = placas2; + if (placas19.Count == 0) + { + continue; + } + string str80 = str79; + agrupamento1 = this.Agrupamento; + str = str80.ValidaNomePlanilha(agrupamento1.ToString(), 0); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, placas19, this.Relatorio, true); + } + goto Label1; + } + else + { + List placas20 = placas9; + if (placas20.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado())) + { + List placas21 = placas9; + placas3 = ( + from x in placas21 + where x.get_Selecionado() + select x).ToList(); + } + else + { + placas3 = placas9; + } + List placas22 = placas3; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", placas22, this.Relatorio, true); + goto Label1; + } + } + case 3: + { + List placas23 = placas9; + IOrderedEnumerable vendedor15 = + from x in placas23 + orderby x.get_Vendedor() + select x; + strs = ( + from x in vendedor15 + select x.get_Vendedor()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str81 in strs) + { + if (string.IsNullOrWhiteSpace(str81)) + { + continue; + } + List placas24 = placas9; + placas4 = (placas24.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado()) ? placas9.Where((Gestor.Model.Domain.Relatorios.Placa.Placas x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Vendedor() == str81; + }).ToList() : ( + from x in placas9 + where x.get_Vendedor() == str81 + select x).ToList()); + List placas25 = placas4; + if (placas25.Count == 0) + { + continue; + } + string str82 = str81; + agrupamento1 = this.Agrupamento; + str = str82.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, placas25, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List placas26 = placas9; + if (placas26.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado())) + { + List placas27 = placas9; + placas5 = ( + from x in placas27 + where x.get_Selecionado() + select x).ToList(); + } + else + { + placas5 = placas9; + } + List placas28 = placas5; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", placas28, this.Relatorio, true); + goto Label1; + } + } + case 4: + { + List placas29 = placas9; + IOrderedEnumerable estipulante14 = + from x in placas29 + orderby x.get_Estipulante() + select x; + strs = ( + from x in estipulante14 + select x.get_Estipulante()).Distinct().ToList(); + if ((strs.Count != 2 || strs[0] != null || !(strs[1] == "")) && (strs.Count != 1 || strs[0] != null) && (strs.Count != 1 || !(strs[0] == ""))) + { + num = 1; + foreach (string str83 in strs) + { + if (string.IsNullOrWhiteSpace(str83)) + { + continue; + } + List placas30 = placas9; + placas6 = (placas30.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado()) ? placas9.Where((Gestor.Model.Domain.Relatorios.Placa.Placas x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Estipulante() == str83; + }).ToList() : ( + from x in placas9 + where x.get_Estipulante() == str83 + select x).ToList()); + List placas31 = placas6; + if (placas31.Count == 0) + { + continue; + } + string str84 = str83; + agrupamento1 = this.Agrupamento; + str = str84.ValidaNomePlanilha(agrupamento1.ToString(), num); + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, str, placas31, this.Relatorio, true); + num++; + } + goto Label1; + } + else + { + List placas32 = placas9; + if (placas32.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado())) + { + List placas33 = placas9; + placas7 = ( + from x in placas33 + where x.get_Selecionado() + select x).ToList(); + } + else + { + placas7 = placas9; + } + List placas34 = placas7; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", placas34, this.Relatorio, true); + goto Label1; + } + } + default: + { + List placas35 = placas9; + if (placas35.Any((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.get_Selecionado())) + { + List placas36 = placas9; + placas8 = ( + from x in placas36 + where x.get_Selecionado() + select x).ToList(); + } + else + { + placas8 = placas9; + } + List placas37 = placas8; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", placas37, this.Relatorio, true); + goto Label1; + } + } + } + break; + } + case 28: + { + List endossos1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.EndossoFiltrado == null || endossos1.Count == 0) + { + break; + } + else + { + List endossos2 = endossos1; + if (endossos2.Any((Endosso x) => x.get_Selecionado())) + { + List endossos3 = endossos1; + endossos = ( + from x in endossos3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + endossos = endossos1; + } + List endossos4 = endossos; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", endossos4, this.Relatorio, true); + goto case 22; + } + } + case 29: + { + List classificacaos1 = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ClassificacaoFiltrado == null || classificacaos1.Count == 0) + { + break; + } + else + { + List classificacaos2 = classificacaos1; + if (classificacaos2.Any((Gestor.Model.Domain.Relatorios.Classificacao.Classificacao x) => x.get_Selecionado())) + { + List classificacaos3 = classificacaos1; + classificacaos = ( + from x in classificacaos3 + where x.get_Selecionado() + select x).ToList(); + } + else + { + classificacaos = classificacaos1; + } + List classificacaos4 = classificacaos; + xLWorkbook = await Funcoes.GerarXls(xLWorkbook, "ANALÍTICO", classificacaos4, this.Relatorio, true); + goto case 22; + } + } + default: + { + goto case 22; + } + } + str1 = null; + xLWorkbook = null; + strs = null; + } + + public async Task GerarHtml(bool screen = false, bool pageBreak = false, ConfiguracaoImpressao config = null, bool portrait = false) + { + // + // Current member / type: System.Threading.Tasks.Task`1 Gestor.Application.ViewModels.Relatorios.RelatorioViewModel::GerarHtml(System.Boolean,System.Boolean,Gestor.Model.Common.ConfiguracaoImpressao,System.Boolean) + // File path: C:\AggerSeguros\Gestor.Application.exe + // + // Product version: 0.0.0.0 + // Exception in: System.Threading.Tasks.Task GerarHtml(System.Boolean,System.Boolean,Gestor.Model.Common.ConfiguracaoImpressao,System.Boolean) + // + // Object reference not set to an instance of an object. + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.FindLowestCommonAncestor(ICollection`1 typeNodes) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 526 + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.MergeWithLowestCommonAncestor() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 459 + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.ProcessSingleConstraints() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 378 + // at Telerik.JustDecompiler.Decompiler.TypeInference.TypeInferer.InferTypes() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\TypeInference\TypeInferer.cs:line 331 + // at Telerik.JustDecompiler.Decompiler.ExpressionDecompilerStep.Process(DecompilationContext theContext, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\ExpressionDecompilerStep.cs:line 104 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 + // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileStateMachine(MethodBody body, DecompilationContext enclosingContext, BaseStateMachineRemoverStep removeStateMachineStep, Func`2 stateMachineDataSelector, DecompilationContext& decompilationContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 112 + // at Telerik.JustDecompiler.Decompiler.Extensions.DecompileAsyncStateMachine(MethodBody body, DecompilationContext enclosingContext, AsyncData& asyncData) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 150 + // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.GetMoveNextStatements() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 161 + // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Match() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 76 + // at Telerik.JustDecompiler.Steps.RebuildAsyncStatementsStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAsyncStatementsStep.cs:line 36 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 + // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61 + // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133 + // + // mailto: JustDecompilePublicFeedback@telerik.com + + } + + private async Task GerarPagamento(List pagamentos) + { + ParcelaServico parcelaServico = new ParcelaServico(); + List pagamentos1 = pagamentos; + List list = pagamentos1.SelectMany((Pagamento x) => x.get_Dados()).ToList(); + List dadosRelatorios = list; + IEnumerable entidadeVendedorParcela = + from x in dadosRelatorios + where x.get_EntidadeVendedorParcela() != null + select x; + if (await parcelaServico.GerarPagamento(( + from x in entidadeVendedorParcela + select x.get_EntidadeVendedorParcela()).ToList())) + { + AdiantamentoServico adiantamentoServico = new AdiantamentoServico(); + List dadosRelatorios1 = list; + IEnumerable dadosRelatorios2 = dadosRelatorios1.Where((DadosRelatorio x) => { + if (x.get_EntidadeAdiantamento() == null) + { + return false; + } + return !x.get_DataPagamento().HasValue; + }); + await adiantamentoServico.GerarPagamento(( + from x in dadosRelatorios2 + select x.get_EntidadeAdiantamento()).ToList()); + base.RegistrarAcao(string.Format("GEROU EMISSÃO DE RECIBO ENTRE {0:d} E {1:d}", this.Inicio, this.Fim), new Gestor.Model.Common.Relatorio?(this.Relatorio), this.Filtros); + } + list = null; + } + + public async Task GerarPlanilhaCompleta() + { + List nums; + List planilhaCompletas; + bool restricao; + object list; + object obj; + bool count; + bool flag; + bool count1; + List list1; + object nums1; + object obj1; + object list2; + List nums2; + List nums3; + List planilhaCompletas1; + List planilhaCompletas2; + string str; + List restricaoUsuarios = await this.ServicoRestriUsuario.BuscarRestricoes(Recursos.Usuario.get_Id()); + RestricaoUsuario restricaoUsuario = restricaoUsuarios.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 99); + if (restricaoUsuario != null) + { + restricao = restricaoUsuario.get_Restricao(); + } + else + { + restricao = false; + } + if (restricao) + { + await base.ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA ACESSAR O PLANILHA COMPLETA", "OK", "", false); + } + else if ((this.Fim - this.Inicio).TotalDays <= 31) + { + base.Loading(true); + nums2 = new List(); + nums3 = new List(); + List configuracoes = Recursos.Configuracoes; + bool flag1 = configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 40); + bool flag2 = false; + Gestor.Model.Common.Relatorio relatorio = this.Relatorio; + if (relatorio == 2) + { + ObservableCollection producaoFiltrado = this.ProducaoFiltrado; + if (producaoFiltrado != null) + { + IEnumerable producaos = producaoFiltrado.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Tipo() != 2; + }); + list = ( + from x in producaos + select x.get_Documento().get_Id()).ToList(); + } + else + { + list = null; + } + if (list == null) + { + list = new List(); + } + nums = (List)list; + ObservableCollection observableCollection = this.ProducaoFiltrado; + if (observableCollection != null) + { + IEnumerable producaos1 = observableCollection.Where((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Tipo() == 2; + }); + obj = ( + from x in producaos1 + select x.get_Documento().get_Id()).ToList(); + } + else + { + obj = null; + } + if (obj == null) + { + obj = new List(); + } + nums3 = (List)obj; + if (nums.Count == 0 && nums3.Count == 0) + { + await base.ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM DOCUMENTO", "OK", "", false); + nums2 = null; + nums3 = null; + planilhaCompletas1 = null; + planilhaCompletas2 = null; + str = null; + return; + } + } + else if (relatorio == 4) + { + List configuracaoSistemas = Recursos.Configuracoes; + flag2 = configuracaoSistemas.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 31); + ObservableCollection renovacaoFiltrado = this.RenovacaoFiltrado; + if (renovacaoFiltrado != null) + { + ( + from x in renovacaoFiltrado + where x.get_Selecionado() + select x).ToList(); + } + else + { + } + ObservableCollection renovacaoFiltrado1 = this.RenovacaoFiltrado; + if (renovacaoFiltrado1 != null) + { + IEnumerable renovacaos = renovacaoFiltrado1.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado() || x.get_Documento() == null) + { + return false; + } + return !x.get_TipoPagamento().Equals("FATURA"); + }); + nums1 = ( + from x in renovacaos + select x.get_Documento().get_Id()).ToList(); + } + else + { + nums1 = null; + } + if (nums1 == null) + { + nums1 = new List(); + } + nums = (List)nums1; + ObservableCollection observableCollection1 = this.RenovacaoFiltrado; + if (observableCollection1 != null) + { + IEnumerable renovacaos1 = observableCollection1.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado() || x.get_Documento() == null) + { + return false; + } + return x.get_TipoPagamento().Equals("FATURA"); + }); + obj1 = ( + from x in renovacaos1 + select x.get_Documento().get_Id()).ToList(); + } + else + { + obj1 = null; + } + if (obj1 == null) + { + obj1 = new List(); + } + nums3 = (List)obj1; + ObservableCollection renovacaoFiltrado2 = this.RenovacaoFiltrado; + if (renovacaoFiltrado2 != null) + { + IEnumerable renovacaos2 = renovacaoFiltrado2.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (!x.get_Selecionado()) + { + return false; + } + return x.get_Prospeccao() != null; + }); + list2 = ( + from x in renovacaos2 + select x.get_Prospeccao().get_Id()).ToList(); + } + else + { + list2 = null; + } + if (list2 == null) + { + list2 = new List(); + } + nums2 = (List)list2; + if (nums.Count == 0 && nums3.Count == 0 && nums2.Count == 0) + { + await base.ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM DOCUMENTO", "OK", "", false); + nums2 = null; + nums3 = null; + planilhaCompletas1 = null; + planilhaCompletas2 = null; + str = null; + return; + } + } + else + { + base.Loading(false); + nums2 = null; + nums3 = null; + planilhaCompletas1 = null; + planilhaCompletas2 = null; + str = null; + return; + } + if (nums == null || nums.Count <= 0) + { + planilhaCompletas = new List(); + } + else + { + planilhaCompletas = await this._apoliceServico.BuscarPlanilhaCompleta(nums, flag1, flag2); + } + planilhaCompletas1 = planilhaCompletas; + List nums4 = nums3; + if (nums4 != null) + { + count = nums4.Count > 0; + } + else + { + count = false; + } + if (!count) + { + planilhaCompletas = new List(); + } + else + { + planilhaCompletas = await this._apoliceServico.BuscarPlanilhaCompletaFatura(nums3, this.Relatorio, this.Filtros.get_Inicio(), this.Filtros.get_Fim(), flag1, flag2); + } + planilhaCompletas2 = planilhaCompletas; + List nums5 = nums2; + if (nums5 != null) + { + flag = nums5.Count > 0; + } + else + { + flag = false; + } + if (!flag) + { + planilhaCompletas = new List(); + } + else + { + planilhaCompletas = await this._apoliceServico.BuscarPlanilhaCompletaProspeccao(nums2); + } + List planilhaCompletas3 = planilhaCompletas; + if (planilhaCompletas1 == null || planilhaCompletas2 == null || planilhaCompletas3 == null) + { + await base.ShowMessage("ERRO AO GERAR PLANILHA COMPLETA, TENTE NOVAMENTE MAIS TARDE.", "OK", "", false); + base.Loading(false); + } + else + { + planilhaCompletas1.AddRange(planilhaCompletas2); + planilhaCompletas1.AddRange(planilhaCompletas3); + List planilhaCompletas4 = planilhaCompletas1; + if (planilhaCompletas4 != null) + { + count1 = planilhaCompletas4.Count == 0; + } + else + { + count1 = false; + } + if (!count1) + { + if (this.Relatorio == 4) + { + List planilhaCompletas5 = planilhaCompletas1; + list1 = ( + from x in planilhaCompletas5 + orderby x.get_VigenciaFinal() + select x).ToList(); + } + else + { + List planilhaCompletas6 = planilhaCompletas1; + list1 = ( + from x in planilhaCompletas6 + orderby x.get_VigenciaInicial() + select x).ToList(); + } + planilhaCompletas1 = list1; + string tempPath = ""; + str = ""; + List configuracoes1 = Recursos.Configuracoes; + if (!configuracoes1.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 41)) + { + tempPath = Path.GetTempPath(); + str = string.Format("{0}{1}.xlsx", tempPath, Guid.NewGuid()); + } + else + { + using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) + { + if (DialogResult.OK == folderBrowserDialog.ShowDialog()) + { + tempPath = string.Concat(folderBrowserDialog.SelectedPath, "\\"); + Directory.CreateDirectory(tempPath); + } + else + { + nums2 = null; + nums3 = null; + planilhaCompletas1 = null; + planilhaCompletas2 = null; + str = null; + return; + } + } + string[] description = new string[] { tempPath, EnumHelper.GetDescription(this.Relatorio), " ", null, null }; + DateTime date = Functions.GetNetworkTime().Date; + description[3] = date.ToShortDateString().Replace("/", ""); + description[4] = ".xlsx"; + str = string.Concat(description); + } + await Funcoes.GerarXls(new XLWorkbook(), "PLANILHA COMPLETA", planilhaCompletas1, new List()).SaveAs(str); + Process.Start(str); + base.Loading(false); + } + else + { + await base.ShowMessage("NÃO HÁ DADOS PARA EMISSÃO DA PLANILHA COMPLETA.", "OK", "", false); + base.Loading(false); + } + } + } + else + { + await base.ShowMessage("NÃO É POSSÍVEL GERAR A PLANILHA COMPLETA COM INTERVALO MAIOR QUE 31 DIAS FILTRADOS.", "OK", "", false); + } + nums2 = null; + nums3 = null; + planilhaCompletas1 = null; + planilhaCompletas2 = null; + str = null; + } + + public async Task GerarRelatorio(DateTime? inicio, DateTime? fim) + { + // + // Current member / type: System.Threading.Tasks.Task`1 Gestor.Application.ViewModels.Relatorios.RelatorioViewModel::GerarRelatorio(System.Nullable`1,System.Nullable`1) + // File path: C:\AggerSeguros\Gestor.Application.exe + // + // Product version: 0.0.0.0 + // Exception in: System.Threading.Tasks.Task GerarRelatorio(System.Nullable,System.Nullable) + // + // An item with the same key has already been added. Key: Label0 + // at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) + // at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection>.Add(KeyValuePair`2 keyValuePair) + // at Telerik.JustDecompiler.Common.Extensions.AddRange[TKey,TValue](IDictionary`2 self, IDictionary`2 source) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Common\Extensions.cs:line 101 + // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.AnonymousDelegateRebuilder.VisitObjectCreationExpression(ObjectCreationExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 351 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit[TCollection,TElement](TCollection original) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 312 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitMethodInvocationExpression(MethodInvocationExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 500 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit[TCollection,TElement](TCollection original) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 312 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitMethodInvocationExpression(MethodInvocationExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 500 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitBinaryExpression(BinaryExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 531 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitExpressionStatement(ExpressionStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 384 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit[TCollection,TElement](TCollection original) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 312 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 338 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitIfStatement(IfStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 363 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit[TCollection,TElement](TCollection original) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 312 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 338 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitConditionCase(ConditionCase node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 452 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit[TCollection,TElement](TCollection original) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 312 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.VisitSwitchStatement(SwitchStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 470 + // at Telerik.JustDecompiler.Ast.BaseCodeTransformer.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeTransformer.cs:line 273 + // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.AnonymousDelegateRebuilder.Match(BlockStatement theBlock, Int32 index) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 74 + // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.VisitBlockStatement(BlockStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 33 + // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351 + // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.VisitTryStatement(TryStatement node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 510 + // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351 + // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(IEnumerable collection) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 384 + // at Telerik.JustDecompiler.Steps.RebuildAnonymousDelegatesStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\RebuildAnonymousDelegatesStep.cs:line 23 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100 + // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72 + // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61 + // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 133 + // + // mailto: JustDecompilePublicFeedback@telerik.com + + } + + public List GerarTarefas(Gestor.Model.Domain.Ferramentas.Tarefa tarefa) + { + List tarefas = new List(); + Usuario usuario = tarefa.get_Usuario(); + switch (this.Relatorio) + { + case 0: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + if (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa1 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa1.set_Entidade(2); + tarefa1.set_IdEntidade(x.get_Id()); + tarefa1.set_Agendamento(tarefa.get_Agendamento()); + tarefa1.set_Titulo(tarefa.get_Titulo()); + tarefa1.set_Descricao(tarefa.get_Anotacoes()); + tarefa1.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa1.set_Usuario(usuario); + tarefa1.set_UsuarioCadastro(Recursos.Usuario); + tarefa1.set_Cliente(x.get_Nome()); + tarefa1.set_IdCliente(x.get_Id()); + return tarefa1; + }).ToList(); + return tarefas; + } + } + return null; + } + case 1: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + if (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa2 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa2.set_Entidade(2); + tarefa2.set_IdEntidade(x.get_Id()); + tarefa2.set_Agendamento(tarefa.get_Agendamento()); + tarefa2.set_Titulo(tarefa.get_Titulo()); + tarefa2.set_Descricao(tarefa.get_Anotacoes()); + tarefa2.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa2.set_Usuario(usuario); + tarefa2.set_UsuarioCadastro(Recursos.Usuario); + tarefa2.set_Cliente(x.get_Nome()); + tarefa2.set_IdCliente(x.get_Id()); + return tarefa2; + }).ToList(); + return tarefas; + } + } + return null; + } + case 2: + case 7: + case 11: + case 12: + case 13: + { + if (this.ProducaoFiltrado != null && this.ProducaoFiltrado.Count != 0) + { + if (this.ProducaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.ProducaoFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa3 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa3.set_Entidade(0); + tarefa3.set_IdEntidade(x.get_Documento().get_Id()); + tarefa3.set_Agendamento(tarefa.get_Agendamento()); + tarefa3.set_Titulo(tarefa.get_Titulo()); + tarefa3.set_Descricao(tarefa.get_Anotacoes()); + tarefa3.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa3.set_Usuario(usuario); + tarefa3.set_UsuarioCadastro(Recursos.Usuario); + tarefa3.set_Cliente(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + tarefa3.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa3.set_Referencia((x.get_Documento().get_Tipo() != 0 || string.IsNullOrWhiteSpace(x.get_Documento().get_Apolice()) ? (x.get_Documento().get_Tipo() > 0 ? string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice(), " ENDOSSO ", x.get_Documento().get_Endosso()) : string.Concat("PROPOSTA NÚMERO ", x.get_Documento().get_Proposta())) : string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice()))); + return tarefa3; + }).ToList(); + return tarefas; + } + } + return null; + } + case 3: + { + if (this.ApolicePendenteFiltrado != null && this.ApolicePendenteFiltrado.Count != 0) + { + if (this.ApolicePendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.ApolicePendenteFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa4 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa4.set_Entidade(0); + tarefa4.set_IdEntidade(x.get_Documento().get_Id()); + tarefa4.set_Agendamento(tarefa.get_Agendamento()); + tarefa4.set_Titulo(tarefa.get_Titulo()); + tarefa4.set_Descricao(tarefa.get_Anotacoes()); + tarefa4.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa4.set_Usuario(usuario); + tarefa4.set_UsuarioCadastro(Recursos.Usuario); + tarefa4.set_Cliente(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + tarefa4.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa4.set_Referencia((x.get_Documento().get_Tipo() != 0 || string.IsNullOrWhiteSpace(x.get_Documento().get_Apolice()) ? (x.get_Documento().get_Tipo() > 0 ? string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice(), " ENDOSSO ", x.get_Documento().get_Endosso()) : string.Concat("PROPOSTA NÚMERO ", x.get_Documento().get_Proposta())) : string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice()))); + return tarefa4; + }).ToList(); + return tarefas; + } + } + return null; + } + case 4: + { + if (this.RenovacaoFiltrado != null && this.RenovacaoFiltrado.Count != 0) + { + if (this.RenovacaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + IEnumerable renovacaoFiltrado = + from x in this.RenovacaoFiltrado + where x.get_Documento() != null + select x; + IEnumerable renovacaos = + from x in this.RenovacaoFiltrado + where x.get_Prospeccao() != null + select x; + List list = new List(); + List tarefas1 = new List(); + Gestor.Model.Domain.Relatorios.Renovacao.Renovacao[] array = renovacaoFiltrado as Gestor.Model.Domain.Relatorios.Renovacao.Renovacao[] ?? renovacaoFiltrado.ToArray(); + if (array.Any()) + { + list = ( + from x in array + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa5 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa5.set_Entidade(0); + tarefa5.set_IdEntidade(x.get_Documento().get_Id()); + tarefa5.set_Agendamento(tarefa.get_Agendamento()); + tarefa5.set_Titulo(tarefa.get_Titulo()); + tarefa5.set_Descricao(tarefa.get_Anotacoes()); + tarefa5.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa5.set_Usuario(usuario); + tarefa5.set_UsuarioCadastro(Recursos.Usuario); + tarefa5.set_Cliente(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + tarefa5.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa5.set_Referencia((x.get_Documento().get_Tipo() != 0 || string.IsNullOrWhiteSpace(x.get_Documento().get_Apolice()) ? (x.get_Documento().get_Tipo() > 0 ? string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice(), " ENDOSSO ", x.get_Documento().get_Endosso()) : string.Concat("PROPOSTA NÚMERO ", x.get_Documento().get_Proposta())) : string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice()))); + return tarefa5; + }).ToList(); + } + Gestor.Model.Domain.Relatorios.Renovacao.Renovacao[] renovacaoArray = renovacaos as Gestor.Model.Domain.Relatorios.Renovacao.Renovacao[] ?? renovacaos.ToArray(); + if (renovacaoArray.Any()) + { + tarefas1 = ( + from x in renovacaoArray + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa6 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa6.set_Entidade(5); + tarefa6.set_IdEntidade(x.get_Prospeccao().get_Id()); + tarefa6.set_Agendamento(tarefa.get_Agendamento()); + tarefa6.set_Titulo(tarefa.get_Titulo()); + tarefa6.set_Descricao(tarefa.get_Anotacoes()); + tarefa6.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa6.set_Usuario(usuario); + tarefa6.set_UsuarioCadastro(Recursos.Usuario); + tarefa6.set_Cliente(x.get_Prospeccao().get_Nome()); + DateTime? vigenciaFinal = x.get_VigenciaFinal(); + tarefa6.set_Referencia(string.Concat("PROSPECÇÃO ", (vigenciaFinal.HasValue ? vigenciaFinal.GetValueOrDefault().ToString("d") : null))); + return tarefa6; + }).ToList(); + } + tarefas.AddRange(list); + tarefas.AddRange(tarefas1); + if (tarefas.Count <= 0) + { + return null; + } + return tarefas; + } + } + return null; + } + case 5: + { + if (this.ComissaoFiltrado != null && this.ComissaoFiltrado.Count != 0) + { + if (this.ComissaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.ComissaoFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa7 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa7.set_Entidade(3); + tarefa7.set_IdEntidade(x.get_ParcelaEntity().get_Id()); + tarefa7.set_Agendamento(tarefa.get_Agendamento()); + tarefa7.set_Titulo(tarefa.get_Titulo()); + tarefa7.set_Descricao(tarefa.get_Anotacoes()); + tarefa7.set_Usuario(usuario); + tarefa7.set_UsuarioCadastro(Recursos.Usuario); + tarefa7.set_Cliente(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + tarefa7.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa7.set_Referencia((x.get_Documento().get_Tipo() != 0 || string.IsNullOrWhiteSpace(x.get_Documento().get_Apolice()) ? (x.get_Documento().get_Tipo() > 0 ? string.Concat(new string[] { "PARCELA ", x.get_Parcela(), " DA APÓLICE ", x.get_Documento().get_Apolice(), " ENDOSSO ", x.get_Documento().get_Endosso() }) : string.Concat("PARCELA ", x.get_Parcela(), " DA PROPOSTA ", x.get_Documento().get_Proposta())) : string.Concat("PARCELA ", x.get_Parcela(), " DA APÓLICE ", x.get_Documento().get_Apolice()))); + tarefa7.set_Responsaveis(tarefa.get_Responsaveis()); + return tarefa7; + }).ToList(); + return tarefas; + } + } + return null; + } + case 6: + case 16: + { + if (this.PendenteFiltrado != null && this.PendenteFiltrado.Count != 0) + { + if (this.PendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.PendenteFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa8 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa8.set_Entidade(3); + tarefa8.set_IdEntidade(x.get_ParcelaEntity().get_Id()); + tarefa8.set_Agendamento(tarefa.get_Agendamento()); + tarefa8.set_Titulo(tarefa.get_Titulo()); + tarefa8.set_Descricao(tarefa.get_Anotacoes()); + tarefa8.set_Usuario(usuario); + tarefa8.set_UsuarioCadastro(Recursos.Usuario); + tarefa8.set_Cliente(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + tarefa8.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa8.set_Referencia((x.get_Documento().get_Tipo() != 0 || string.IsNullOrWhiteSpace(x.get_Documento().get_Apolice()) ? (x.get_Documento().get_Tipo() > 0 ? string.Format("PARCELA {0} DA APÓLICE {1} ENDOSSO {2}", x.get_ParcelaEntity().get_NumeroParcela(), x.get_Documento().get_Apolice(), x.get_Documento().get_Endosso()) : string.Format("PARCELA {0} DA PROPOSTA {1}", x.get_ParcelaEntity().get_NumeroParcela(), x.get_Documento().get_Proposta())) : string.Format("PARCELA {0} DA APÓLICE {1}", x.get_ParcelaEntity().get_NumeroParcela(), x.get_Documento().get_Apolice()))); + tarefa8.set_Responsaveis(tarefa.get_Responsaveis()); + return tarefa8; + }).ToList(); + return tarefas; + } + } + return null; + } + case 8: + { + if (this.AuditoriaFiltrado != null && this.AuditoriaFiltrado.Count != 0) + { + if (this.AuditoriaFiltrado.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.AuditoriaFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa9 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa9.set_Entidade(0); + tarefa9.set_IdEntidade(x.get_Documento().get_Id()); + tarefa9.set_Agendamento(tarefa.get_Agendamento()); + tarefa9.set_Titulo(tarefa.get_Titulo()); + tarefa9.set_Descricao(tarefa.get_Anotacoes()); + tarefa9.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa9.set_Usuario(usuario); + tarefa9.set_UsuarioCadastro(Recursos.Usuario); + tarefa9.set_Cliente(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + tarefa9.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa9.set_Referencia((x.get_Documento().get_Tipo() != 0 || string.IsNullOrWhiteSpace(x.get_Documento().get_Apolice()) ? (x.get_Documento().get_Tipo() > 0 ? string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice(), " ENDOSSO ", x.get_Documento().get_Endosso()) : string.Concat("PROPOSTA NÚMERO ", x.get_Documento().get_Proposta())) : string.Concat("APÓLICE NÚMERO ", x.get_Documento().get_Apolice()))); + return tarefa9; + }).ToList(); + return tarefas; + } + } + return null; + } + case 9: + case 10: + { + if (this.SinistroFiltrado != null && this.SinistroFiltrado.Count != 0) + { + if (this.SinistroFiltrado.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.SinistroFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa10 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa10.set_Entidade(4); + tarefa10.set_IdEntidade(x.get_EntidadeSinistro().get_Id()); + tarefa10.set_Agendamento(tarefa.get_Agendamento()); + tarefa10.set_Titulo(tarefa.get_Titulo()); + tarefa10.set_Descricao(tarefa.get_Anotacoes()); + tarefa10.set_Usuario(usuario); + tarefa10.set_UsuarioCadastro(Recursos.Usuario); + tarefa10.set_Cliente(x.get_Nome()); + tarefa10.set_IdCliente(x.get_EntidadeSinistro().get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa10.set_Referencia(string.Concat("SINISTRO ", x.get_NumeroSinistro(), " - ITEM ", x.get_Item())); + tarefa10.set_Responsaveis(tarefa.get_Responsaveis()); + return tarefa10; + }).ToList(); + return tarefas; + } + } + return null; + } + case 14: + { + if (this.MetaSeguradoraFiltrado != null && this.MetaSeguradoraFiltrado.Count != 0) + { + if (this.MetaSeguradoraFiltrado.Any((MetaSeguradoraRelatorio x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.MetaSeguradoraFiltrado + where x.get_Selecionado() + select x).Select((MetaSeguradoraRelatorio x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa11 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa11.set_Entidade(7); + tarefa11.set_IdEntidade(x.get_Id()); + tarefa11.set_Agendamento(tarefa.get_Agendamento()); + tarefa11.set_Titulo(tarefa.get_Titulo()); + tarefa11.set_Descricao(tarefa.get_Anotacoes()); + tarefa11.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa11.set_Usuario(usuario); + tarefa11.set_UsuarioCadastro(Recursos.Usuario); + tarefa11.set_Cliente(x.get_Seguradora()); + tarefa11.set_Referencia(string.Concat("SEGURADORA ", x.get_Seguradora())); + return tarefa11; + }).ToList(); + return tarefas; + } + } + return null; + } + case 15: + { + if (this.MetaVendedorFiltrado != null && this.MetaVendedorFiltrado.Count != 0) + { + if (this.MetaVendedorFiltrado.Any((MetaVendedorRelatorio x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.MetaVendedorFiltrado + where x.get_Selecionado() + select x).Select((MetaVendedorRelatorio x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa12 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa12.set_Entidade(6); + tarefa12.set_IdEntidade(x.get_Id()); + tarefa12.set_Agendamento(tarefa.get_Agendamento()); + tarefa12.set_Titulo(tarefa.get_Titulo()); + tarefa12.set_Descricao(tarefa.get_Anotacoes()); + tarefa12.set_Responsaveis(tarefa.get_Responsaveis()); + tarefa12.set_Usuario(usuario); + tarefa12.set_UsuarioCadastro(Recursos.Usuario); + tarefa12.set_Cliente(x.get_Vendedor()); + tarefa12.set_Referencia(string.Concat("VENDEDOR ", x.get_Vendedor())); + return tarefa12; + }).ToList(); + return tarefas; + } + } + return null; + } + case 17: + { + if (this.LicenciamentoFiltrado != null && this.LicenciamentoFiltrado.Count != 0) + { + if (this.LicenciamentoFiltrado.Any((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => x.get_Selecionado())) + { + tarefas = ( + from x in this.LicenciamentoFiltrado + where x.get_Selecionado() + select x).Select((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa13 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa13.set_Entidade(2); + tarefa13.set_IdEntidade(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa13.set_Agendamento(tarefa.get_Agendamento()); + tarefa13.set_Titulo(tarefa.get_Titulo()); + tarefa13.set_Descricao(tarefa.get_Anotacoes()); + tarefa13.set_Usuario(usuario); + tarefa13.set_UsuarioCadastro(Recursos.Usuario); + tarefa13.set_Cliente(x.get_Cliente()); + tarefa13.set_IdCliente(x.get_Documento().get_Controle().get_Cliente().get_Id()); + tarefa13.set_Referencia(string.Concat("VENCIMENTO CRLV ", x.get_Placa(), " - ITEM ", x.get_Item())); + tarefa13.set_Responsaveis(tarefa.get_Responsaveis()); + return tarefa13; + }).ToList(); + return tarefas; + } + } + return null; + } + default: + { + goto case 13; + } + } + } + + private static string JoinEmails(List emails) + { + if (emails == null) + { + return ""; + } + return string.Join(" | ", ( + from v in emails + where !string.IsNullOrEmpty(v.get_Email()) + select v.get_Email()).Distinct()); + } + + private static string JoinTelefones(List telefones) + { + if (telefones == null) + { + return ""; + } + return string.Join(" | ", + from v in telefones + select string.Concat(v.get_Prefixo(), " ", v.get_Numero())); + } + + public void LimparFiltros() + { + this._alterandoFiltros = true; + this.FiltroRelatorioSelecionado = null; + foreach (StatusRelatorio statusRelatorio in + from x in this.TipoSeguros + where x.get_Selecionado() + select x) + { + statusRelatorio.set_Selecionado(false); + } + foreach (Seguradora seguradora in + from x in this.Seguradoras + where x.get_Selecionado() + select x) + { + seguradora.set_Selecionado(false); + } + foreach (Ramo ramo in + from x in this.Ramos + where x.get_Selecionado() + select x) + { + ramo.set_Selecionado(false); + } + foreach (Estipulante estipulante in + from x in this.Estipulantes + where x.get_Selecionado() + select x) + { + estipulante.set_Selecionado(false); + } + foreach (Vendedor vendedor in + from x in this.Vendedores + where x.get_Selecionado() + select x) + { + vendedor.set_Selecionado(false); + } + foreach (Gestor.Model.Domain.Seguros.TipoVendedor tipoVendedor in + from x in this.TipoVendedor + where x.get_Selecionado() + select x) + { + tipoVendedor.set_Selecionado(false); + } + foreach (Gestor.Model.Domain.Seguros.Produto produto in + from x in this.Produtos + where x.get_Selecionado() + select x) + { + produto.set_Selecionado(false); + } + foreach (NegocioRelatorio negocioRelatorio in + from x in this.Negocios + where x.get_Selecionado() + select x) + { + negocioRelatorio.set_Selecionado(false); + } + this._alterandoFiltros = false; + } + + private void LimparFiltroUsuario() + { + ExtensionMethods.ForEach(this.UsuariosFiltrados, (Usuario x) => x.set_Selecionado(false)); + } + + public void LimparRelatorio() + { + this.RelatorioVisibility = false; + this.VisibilityFiltroPersonalizado = Visibility.Collapsed; + } + + private async Task LoadVendedores() + { + List list; + this.Vinculo = await base.VerificaVinculoVendedor(Recursos.Usuario); + RelatorioViewModel relatorioViewModel = this; + if (this.Vinculo.Count > 0) + { + IEnumerable vendedores = + from x in Recursos.Vendedores + where this.Vinculo.Any((VendedorUsuario y) => y.get_Vendedor().get_Id() == x.get_Id()) + select x; + list = ( + from x in vendedores + orderby x.get_Nome() + select x).ToList(); + } + else + { + List vendedors = Recursos.Vendedores; + IEnumerable vendedors1 = vendedors.Where((Vendedor x) => { + if (Recursos.Usuario.get_IdEmpresa() == (long)1) + { + return true; + } + return x.get_IdEmpresa() == Recursos.Usuario.get_IdEmpresa(); + }); + list = ( + from x in vendedors1 + orderby x.get_Nome() + select x).ToList(); + } + relatorioViewModel.Vendedores = list; + RelatorioViewModel list1 = this; + List usuarios = Recursos.Usuarios; + IEnumerable excluido = + from x in usuarios + where !x.get_Excluido() + select x; + list1.Usuarios = ( + from x in excluido + orderby x.get_Nome() + select x).ToList(); + this.UsuariosFiltrados = new ObservableCollection(this.Usuarios); + } + + public async void MostrarProtocolo() + { + switch (this.Relatorio) + { + case 2: + { + ObservableCollection producaoFiltrado = this.ProducaoFiltrado; + if (producaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado())) + { + RelatorioViewModel relatorioViewModel = this; + ObservableCollection observableCollection = this.ProducaoFiltrado; + IEnumerable selecionado = + from x in observableCollection + where x.get_Selecionado() + select x; + this.PrepararProtocolo(await relatorioViewModel.ShowProtocoloDialog(( + from x in selecionado + select x.get_Documento()).ToList())); + break; + } + else + { + await base.ShowMessage("NECESSÁRIO SELECIONAR OS DOCUMENTOS PARA EMISSÃO DE PROTOCOLO", "OK", "", false); + break; + } + } + case 3: + { + ObservableCollection apolicePendenteFiltrado = this.ApolicePendenteFiltrado; + if (apolicePendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado())) + { + RelatorioViewModel relatorioViewModel1 = this; + ObservableCollection apolicePendenteFiltrado1 = this.ApolicePendenteFiltrado; + IEnumerable apolicePendentes = + from x in apolicePendenteFiltrado1 + where x.get_Selecionado() + select x; + this.PrepararProtocolo(await relatorioViewModel1.ShowProtocoloDialog(( + from x in apolicePendentes + select x.get_Documento()).ToList())); + break; + } + else + { + await base.ShowMessage("NECESSÁRIO SELECIONAR OS DOCUMENTOS PARA EMISSÃO DE PROTOCOLO", "OK", "", false); + break; + } + } + case 4: + { + ObservableCollection renovacaoFiltrado = this.RenovacaoFiltrado; + if (renovacaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado())) + { + RelatorioViewModel relatorioViewModel2 = this; + ObservableCollection renovacaoFiltrado1 = this.RenovacaoFiltrado; + IEnumerable renovacaos = + from x in renovacaoFiltrado1 + where x.get_Selecionado() + select x; + this.PrepararProtocolo(await relatorioViewModel2.ShowProtocoloDialog(( + from x in renovacaos + select x.get_Documento()).ToList())); + break; + } + else + { + await base.ShowMessage("NECESSÁRIO SELECIONAR OS DOCUMENTOS PARA EMISSÃO DE PROTOCOLO", "OK", "", false); + break; + } + } + } + } + + private void NegocioOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(9); + } + + public void PesquisaPersonalizada() + { + switch (this.Relatorio) + { + case 0: + { + this.FiltrarRamo(); + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 1: + { + this.ClientesAtivosInativosFiltrado = new ObservableCollection(this.ClientesAtivosInativos.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ClientesAtivosInativosFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 2: + { + this.ProducaoFiltrado = new ObservableCollection(this.Producao.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ProducaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 3: + { + this.ApolicePendenteFiltrado = new ObservableCollection(this.ApolicePendente.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ApolicePendenteFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 4: + { + this.RenovacaoFiltrado = new ObservableCollection(this.Renovacao.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.RenovacaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 5: + { + this.ComissaoFiltrado = new ObservableCollection(this.Comissao.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ComissaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 6: + case 16: + { + this.PendenteFiltrado = new ObservableCollection(this.Pendente.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.PendenteFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 7: + case 11: + case 20: + case 21: + case 22: + { + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 8: + { + this.AuditoriaFiltrado = new ObservableCollection(this.Auditoria.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.AuditoriaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 9: + case 10: + { + this.SinistroFiltrado = new ObservableCollection(this.Sinistro.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.SinistroFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 12: + { + this.FaturaPendenteFiltrado = new ObservableCollection(this.FaturaPendente.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.FaturaPendenteFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 13: + { + this.ExtratosFiltrado = new ObservableCollection(this.Extratos.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ExtratosFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 14: + { + this.MetaSeguradoraFiltrado = new ObservableCollection(this.MetaSeguradora.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.MetaSeguradoraFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 15: + { + this.MetaVendedorFiltrado = new ObservableCollection(this.MetaVendedor.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.MetaVendedorFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 17: + { + this.LicenciamentoFiltrado = new ObservableCollection(this.Licenciamento.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.LicenciamentoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 18: + { + this.TarefaFiltrado = new ObservableCollection(this.Tarefa.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.TarefaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 19: + { + this.NotaFiscalFiltrado = new ObservableCollection(this.NotasFiscais.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.NotaFiscalFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 23: + { + this.LogsEnvioFiltrado = new ObservableCollection(this.LogsEnvio.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.LogsEnvioFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 24: + case 25: + { + this.LogUtilizacaoFiltrado = new ObservableCollection(this.LogUtilizacao.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.LogUtilizacaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 26: + { + this.ApoliceCriticaFiltrado = new ObservableCollection(this.ApoliceCritica.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ApoliceCriticaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 27: + { + this.PlacaFiltrado = new ObservableCollection(this.Placas.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.PlacaFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 28: + { + this.EndossoFiltrado = new ObservableCollection(this.Endossoo.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.EndossoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + case 29: + { + this.ClassificacaoFiltrado = new ObservableCollection(this.Classificacao.CustomWhere(this.FiltroPersonalizadoSelecionado.ToList(), this.ValorIgual)); + ((GridRelatorio)this.Report).DataGrid.ItemsSource = this.ClassificacaoFiltrado; + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + default: + { + ((GridRelatorio)this.Report).SinteticoGrid.ItemsSource = this.Sintetic; + return; + } + } + } + + private async void PopularRelatorio(string opcao) + { + bool restricao; + bool flag; + bool restricao1; + bool flag1; + bool restricao2; + bool flag2; + bool restricao3; + bool flag3; + bool restricao4; + bool flag4; + bool restricao5; + bool flag5; + bool restricao6; + bool flag6; + bool restricao7; + bool flag7; + bool restricao8; + bool flag8; + bool restricao9; + bool flag9; + bool restricao10; + bool flag10; + bool restricao11; + bool flag11; + bool restricao12; + bool flag12; + bool restricao13; + bool flag13; + this.Relatorios = new List(); + List restricaoUsuarios = await this.ServicoRestriUsuario.BuscarRestricoes(Recursos.Usuario.get_Id()); + Gestor.Model.Common.Relatorio[] values = (Gestor.Model.Common.Relatorio[])Enum.GetValues(typeof(Gestor.Model.Common.Relatorio)); + foreach (Gestor.Model.Common.Relatorio relatorio in + from x in values + orderby EnumHelper.GetDescription(x) + select x) + { + if (Gestor.Common.Validation.ValidationHelper.GetTipo(relatorio) != opcao) + { + continue; + } + switch (relatorio) + { + case 0: + { + List restricaoUsuarios1 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario = restricaoUsuarios1.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 30); + if (restricaoUsuario != null) + { + restricao = restricaoUsuario.get_Restricao(); + } + else + { + restricao = false; + } + if (restricao) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 1: + { + List restricaoUsuarios2 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario1 = restricaoUsuarios2.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 49); + if (restricaoUsuario1 != null) + { + flag = restricaoUsuario1.get_Restricao(); + } + else + { + flag = false; + } + if (flag) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 2: + { + List restricaoUsuarios3 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario2 = restricaoUsuarios3.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 23); + if (restricaoUsuario2 != null) + { + restricao1 = restricaoUsuario2.get_Restricao(); + } + else + { + restricao1 = false; + } + if (restricao1) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 3: + { + List restricaoUsuarios4 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario3 = restricaoUsuarios4.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 34); + if (restricaoUsuario3 != null) + { + flag1 = restricaoUsuario3.get_Restricao(); + } + else + { + flag1 = false; + } + if (flag1) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 4: + { + List restricaoUsuarios5 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario4 = restricaoUsuarios5.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 24); + if (restricaoUsuario4 != null) + { + restricao2 = restricaoUsuario4.get_Restricao(); + } + else + { + restricao2 = false; + } + if (restricao2) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 5: + { + List restricaoUsuarios6 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario5 = restricaoUsuarios6.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 27); + if (restricaoUsuario5 != null) + { + flag2 = restricaoUsuario5.get_Restricao(); + } + else + { + flag2 = false; + } + if (flag2) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 6: + { + List restricaoUsuarios7 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario6 = restricaoUsuarios7.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 29); + if (restricaoUsuario6 != null) + { + restricao3 = restricaoUsuario6.get_Restricao(); + } + else + { + restricao3 = false; + } + if (restricao3) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 7: + { + List restricaoUsuarios8 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario7 = restricaoUsuarios8.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 28); + if (restricaoUsuario7 != null) + { + flag3 = restricaoUsuario7.get_Restricao(); + } + else + { + flag3 = false; + } + if (flag3) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 8: + { + List restricaoUsuarios9 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario8 = restricaoUsuarios9.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 46); + if (restricaoUsuario8 != null) + { + restricao4 = restricaoUsuario8.get_Restricao(); + } + else + { + restricao4 = false; + } + if (restricao4) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 9: + { + List restricaoUsuarios10 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario9 = restricaoUsuarios10.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 25); + if (restricaoUsuario9 != null) + { + flag4 = restricaoUsuario9.get_Restricao(); + } + else + { + flag4 = false; + } + if (flag4) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 10: + { + List restricaoUsuarios11 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario10 = restricaoUsuarios11.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 26); + if (restricaoUsuario10 != null) + { + restricao5 = restricaoUsuario10.get_Restricao(); + } + else + { + restricao5 = false; + } + if (restricao5) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 11: + { + List restricaoUsuarios12 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario11 = restricaoUsuarios12.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 41); + if (restricaoUsuario11 != null) + { + flag5 = restricaoUsuario11.get_Restricao(); + } + else + { + flag5 = false; + } + if (flag5) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 12: + { + List restricaoUsuarios13 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario12 = restricaoUsuarios13.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 51); + if (restricaoUsuario12 != null) + { + restricao6 = restricaoUsuario12.get_Restricao(); + } + else + { + restricao6 = false; + } + if (restricao6) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 13: + { + List restricaoUsuarios14 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario13 = restricaoUsuarios14.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 50); + if (restricaoUsuario13 != null) + { + flag6 = restricaoUsuario13.get_Restricao(); + } + else + { + flag6 = false; + } + if (flag6) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 14: + { + List restricaoUsuarios15 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario14 = restricaoUsuarios15.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 52); + if (restricaoUsuario14 != null) + { + restricao7 = restricaoUsuario14.get_Restricao(); + } + else + { + restricao7 = false; + } + if (restricao7) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 15: + { + List restricaoUsuarios16 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario15 = restricaoUsuarios16.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 53); + if (restricaoUsuario15 != null) + { + flag7 = restricaoUsuario15.get_Restricao(); + } + else + { + flag7 = false; + } + if (flag7) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 16: + { + List restricaoUsuarios17 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario16 = restricaoUsuarios17.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 62); + if (restricaoUsuario16 != null) + { + restricao8 = restricaoUsuario16.get_Restricao(); + } + else + { + restricao8 = false; + } + if (restricao8) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 17: + { + List restricaoUsuarios18 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario17 = restricaoUsuarios18.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 63); + if (restricaoUsuario17 != null) + { + flag8 = restricaoUsuario17.get_Restricao(); + } + else + { + flag8 = false; + } + if (flag8) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 18: + { + List restricaoUsuarios19 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario18 = restricaoUsuarios19.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 31); + if (restricaoUsuario18 != null) + { + restricao9 = restricaoUsuario18.get_Restricao(); + } + else + { + restricao9 = false; + } + if (restricao9) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 19: + { + List restricaoUsuarios20 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario19 = restricaoUsuarios20.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 90); + if (restricaoUsuario19 != null) + { + flag9 = restricaoUsuario19.get_Restricao(); + } + else + { + flag9 = false; + } + if (flag9) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 20: + { + List restricaoUsuarios21 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario20 = restricaoUsuarios21.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 91); + if (restricaoUsuario20 != null) + { + restricao10 = restricaoUsuario20.get_Restricao(); + } + else + { + restricao10 = false; + } + if (restricao10) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 23: + { + List restricaoUsuarios22 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario21 = restricaoUsuarios22.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 96); + if (restricaoUsuario21 != null) + { + flag10 = restricaoUsuario21.get_Restricao(); + } + else + { + flag10 = false; + } + if (flag10) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 24: + { + List restricaoUsuarios23 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario22 = restricaoUsuarios23.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 98); + if (restricaoUsuario22 != null) + { + restricao11 = restricaoUsuario22.get_Restricao(); + } + else + { + restricao11 = false; + } + if (restricao11) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 25: + { + List restricaoUsuarios24 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario23 = restricaoUsuarios24.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 98); + if (restricaoUsuario23 != null) + { + flag11 = restricaoUsuario23.get_Restricao(); + } + else + { + flag11 = false; + } + if (flag11) + { + continue; + } + List configuracoes = Recursos.Configuracoes; + if (configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 22)) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 26: + { + List restricaoUsuarios25 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario24 = restricaoUsuarios25.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 107); + if (restricaoUsuario24 != null) + { + restricao12 = restricaoUsuario24.get_Restricao(); + } + else + { + restricao12 = false; + } + if (restricao12) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 27: + { + List restricaoUsuarios26 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario25 = restricaoUsuarios26.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 111); + if (restricaoUsuario25 != null) + { + flag12 = restricaoUsuario25.get_Restricao(); + } + else + { + flag12 = false; + } + if (flag12) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 28: + { + List restricaoUsuarios27 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario26 = restricaoUsuarios27.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 112); + if (restricaoUsuario26 != null) + { + restricao13 = restricaoUsuario26.get_Restricao(); + } + else + { + restricao13 = false; + } + if (restricao13) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + case 29: + { + List restricaoUsuarios28 = restricaoUsuarios; + RestricaoUsuario restricaoUsuario27 = restricaoUsuarios28.FirstOrDefault((RestricaoUsuario x) => x.get_Tipo() == 30); + if (restricaoUsuario27 != null) + { + flag13 = restricaoUsuario27.get_Restricao(); + } + else + { + flag13 = false; + } + if (flag13) + { + continue; + } + this.Relatorios.Add(relatorio); + continue; + } + default: + { + continue; + } + } + } + this.Relatorio = this.Relatorios.FirstOrDefault(); + } + + private async Task PostMonitor() + { + try + { + using (HttpClient httpClient = new HttpClient()) + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + httpClient.set_Timeout(TimeSpan.FromSeconds(10)); + object idFornecedor = ApplicationHelper.IdFornecedor; + object relatorio = (int)this.Relatorio; + DateTime universalTime = Funcoes.GetNetworkTime().ToUniversalTime(); + string str = string.Format("{0}:{1}:{2}", idFornecedor, relatorio, universalTime.Ticks).EncodeBase64(); + Uri apiMonitor = Address.get_ApiMonitor(); + string[] strArrays = new string[] { "report" }; + Uri uri = apiMonitor.Append(strArrays).AddQuery("reportQuery", str); + await httpClient.GetAsync(uri); + } + httpClient = null; + } + catch + { + } + } + + public async void PrepararProtocolo(List itens) + { + List> tuples; + if (itens != null) + { + this.Carregando = true; + base.IsEnabled = false; + if (await base.ShowMessage("DESEJA EMITIR O CHECKLIST?", "SIM", "NÃO", false)) + { + await base.EmitirCheckList(itens); + } + tuples = new List>(); + foreach (Documento iten in itens) + { + tuples.Add(new Tuple(iten.get_Id(), iten.get_ObsProtocolo())); + } + bool flag = await base.ShowMessage(string.Concat("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", false); + await base.EmitirProtocolos(tuples, flag, itens); + base.IsEnabled = true; + this.Carregando = false; + } + tuples = null; + } + + public async Task Print(bool pageBreak = false) + { + bool flag; + ConfiguracaoImpressao configuracaoImpressao; + string str = ""; + switch (this.Relatorio) + { + case 0: + case 1: + { + if (this.ClientesAtivosInativosFiltrado == null || this.ClientesAtivosInativosFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ClientesAtivosInativosFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 2: + { + if (this.ProducaoFiltrado == null || this.ProducaoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ProducaoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 3: + { + if (this.ApolicePendenteFiltrado == null || this.ApolicePendenteFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ApolicePendenteFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 4: + { + if (this.RenovacaoFiltrado == null || this.RenovacaoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.RenovacaoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 5: + { + if (this.ComissaoFiltrado == null || this.ComissaoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ComissaoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 6: + case 16: + { + if (this.PendenteFiltrado == null || this.PendenteFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.PendenteFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 7: + { + if (this.Pagamentos == null || this.Pagamentos.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.Pagamentos.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + List pagamentos = this.Pagamentos; + flag = (!pagamentos.All((Pagamento x) => x.get_Dados().Any((DadosRelatorio p) => !p.get_DataPagamento().HasValue)) ? false : this.SomenteNaoPagos); + bool flag1 = flag; + if (flag1) + { + flag1 = await base.ShowMessage(string.Concat("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", false); + } + if (flag1) + { + this.ReciboPagamento = true; + } + this.Carregando = true; + base.IsEnabled = false; + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + if (this.ReciboPagamento) + { + await this.GerarPagamento(this.Pagamentos.ToList()); + } + this.ReciboPagamento = false; + goto case 22; + } + } + } + case 8: + { + if (this.AuditoriaFiltrado == null || this.AuditoriaFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.AuditoriaFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 9: + case 10: + { + if (this.SinistroFiltrado == null || this.SinistroFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.SinistroFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 11: + { + if (this.FechamentoFiltrado == null || this.FechamentoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.FechamentoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 12: + { + if (this.FaturaPendenteFiltrado == null || this.FaturaPendenteFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.FaturaPendenteFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 13: + { + if (this.ExtratosFiltrado == null || this.ExtratosFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ExtratosFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 14: + { + if (this.MetaSeguradoraFiltrado == null || this.MetaSeguradoraFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.MetaSeguradoraFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 15: + { + if (this.MetaVendedorFiltrado == null || this.MetaVendedorFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.MetaVendedorFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 17: + { + if (this.LicenciamentoFiltrado == null || this.LicenciamentoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.LicenciamentoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 18: + { + if (this.TarefaFiltrado == null || this.TarefaFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.TarefaFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 19: + { + if (this.NotaFiscalFiltrado == null || this.NotaFiscalFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.NotaFiscalFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 20: + { + if (this.PrevisaoFiltrado == null || this.PrevisaoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.PrevisaoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 21: + case 22: + { + if (!string.IsNullOrEmpty(str)) + { + base.RegistrarAcao(string.Format("IMPRIMIU RELATÓRIO PERÍODO ENTRE {0:d} E {1:d}", this.Inicio, this.Fim), new Gestor.Model.Common.Relatorio?(this.Relatorio), this.Filtros); + string tempPath = Path.GetTempPath(); + string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (new Regex(string.Concat("[", Regex.Escape(string.Concat(new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars()))), "]"))).Replace(EnumHelper.GetDescription(this.Relatorio), ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8); + streamWriter.Write(str); + streamWriter.Close(); + int num = 0; + try + { + Process.Start(str1); + } + catch + { + num = 1; + } + if (num == 1) + { + await base.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.", "OK", "", false); + } + break; + } + else + { + break; + } + } + case 23: + { + if (this.LogsEnvioFiltrado == null || this.LogsEnvioFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.LogsEnvioFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 24: + case 25: + { + if (this.LogUtilizacaoFiltrado == null || this.LogUtilizacaoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.LogUtilizacaoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 26: + { + if (this.ApoliceCriticaFiltrado == null || this.ApoliceCriticaFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ApoliceCriticaFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 27: + { + if (this.PlacaFiltrado == null || this.PlacaFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.PlacaFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 28: + { + if (this.EndossoFiltrado == null || this.EndossoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.EndossoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + case 29: + { + if (this.ClassificacaoFiltrado == null || this.ClassificacaoFiltrado.Count == 0) + { + break; + } + else + { + configuracaoImpressao = await base.ShowDialogPrint(this.Relatorio, this.ClassificacaoFiltrado.First().GetType()); + if (configuracaoImpressao == null || !configuracaoImpressao.get_Campos().Any()) + { + break; + } + else + { + str = await this.GerarHtml(false, pageBreak, configuracaoImpressao, false); + goto case 22; + } + } + } + default: + { + goto case 22; + } + } + } + + private void ProdutoOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(5); + } + + private void RamoOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(1); + } + + public void RecheckAllLists() + { + for (int i = 0; i <= 9; i++) + { + this.RecheckAllSelected(i); + } + } + + public void RecheckAllSelected(int tipo) + { + bool? nullable; + if (this._allSelectedChanging) + { + return; + } + try + { + this._allSelectedChanging = true; + switch (tipo) + { + case 0: + { + if (this.Seguradoras.All((Seguradora e) => e.get_Selecionado())) + { + this.AllSelectedSeguradora = new bool?(true); + break; + } + else if (!this.Seguradoras.All((Seguradora e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedSeguradora = nullable; + break; + } + else + { + this.AllSelectedSeguradora = new bool?(false); + break; + } + } + case 1: + { + if (this.Ramos.All((Ramo e) => e.get_Selecionado())) + { + this.AllSelectedRamo = new bool?(true); + break; + } + else if (!this.Ramos.All((Ramo e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedRamo = nullable; + break; + } + else + { + this.AllSelectedRamo = new bool?(false); + break; + } + } + case 2: + { + if (this.Vendedores.All((Vendedor e) => e.get_Selecionado())) + { + this.AllSelectedVendedor = new bool?(true); + break; + } + else if (!this.Vendedores.All((Vendedor e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedVendedor = nullable; + break; + } + else + { + this.AllSelectedVendedor = new bool?(false); + break; + } + } + case 3: + { + if (this.TipoSeguros.All((StatusRelatorio e) => e.get_Selecionado())) + { + this.AllSelectedStatus = new bool?(true); + break; + } + else if (!this.TipoSeguros.All((StatusRelatorio e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedStatus = nullable; + break; + } + else + { + this.AllSelectedStatus = new bool?(false); + break; + } + } + case 4: + { + if (this.TipoVendedor.All((Gestor.Model.Domain.Seguros.TipoVendedor e) => e.get_Selecionado())) + { + this.AllSelectedTipoVendedor = new bool?(true); + break; + } + else if (!this.TipoVendedor.All((Gestor.Model.Domain.Seguros.TipoVendedor e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedTipoVendedor = nullable; + break; + } + else + { + this.AllSelectedTipoVendedor = new bool?(false); + break; + } + } + case 5: + { + if (this.Negocios.All((NegocioRelatorio e) => e.get_Selecionado())) + { + this.AllSelectedNegocio = new bool?(true); + break; + } + else if (!this.Negocios.All((NegocioRelatorio e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedNegocio = nullable; + break; + } + else + { + this.AllSelectedNegocio = new bool?(false); + break; + } + } + case 6: + { + if (this.Produtos.All((Gestor.Model.Domain.Seguros.Produto e) => e.get_Selecionado())) + { + this.AllSelectedProduto = new bool?(true); + break; + } + else if (!this.Produtos.All((Gestor.Model.Domain.Seguros.Produto e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedProduto = nullable; + break; + } + else + { + this.AllSelectedProduto = new bool?(false); + break; + } + } + case 7: + { + if (this.Estipulantes.All((Estipulante e) => e.get_Selecionado())) + { + this.AllSelectedEstipulante = new bool?(true); + break; + } + else if (!this.Estipulantes.All((Estipulante e) => !e.get_Selecionado())) + { + nullable = null; + this.AllSelectedEstipulante = nullable; + break; + } + else + { + this.AllSelectedEstipulante = new bool?(false); + break; + } + } + } + this.AdicionarFiltros(); + } + finally + { + this._allSelectedChanging = false; + } + } + + public void ReloadVendedores() + { + if (this.Inativo) + { + this.Vendedores = (this.Vinculo.Count > 0 ? ( + from x in Recursos.Vendedores + where this.Vinculo.Any((VendedorUsuario y) => y.get_Vendedor().get_Id() == x.get_Id()) + orderby x.get_Nome() + select x).ToList() : Recursos.Vendedores.Where((Vendedor x) => { + if (Recursos.Usuario.get_IdEmpresa() == (long)1) + { + return true; + } + return x.get_IdEmpresa() == Recursos.Usuario.get_IdEmpresa(); + }).OrderBy((Vendedor x) => x.get_Nome()).ToList()); + } + else + { + this.Vendedores = (this.Vinculo.Count > 0 ? Recursos.Vendedores.Where((Vendedor x) => { + if (!this.Vinculo.Any((VendedorUsuario y) => y.get_Vendedor().get_Id() == x.get_Id())) + { + return false; + } + return x.get_Ativo(); + }).OrderBy((Vendedor x) => x.get_Nome()).ToList() : Recursos.Vendedores.Where((Vendedor x) => { + if (Recursos.Usuario.get_IdEmpresa() != (long)1 && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa()) + { + return false; + } + return x.get_Ativo(); + }).OrderBy((Vendedor x) => x.get_Nome()).ToList()); + } + base.OnPropertyChanged("ReloadVendedores"); + } + + public void RemoverRamo(Ramo ramo) + { + if (ramo == null) + { + return; + } + if (this.RamosSelecionados.Any((Ramo x) => x.get_Id() == ramo.get_Id())) + { + this.RamosSelecionados.Remove(ramo); + } + this.FiltrarRamo(); + } + + internal async Task RemoverVinculo(Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente pendencia) + { + base.Loading(true); + VinculoDocumento vinculo = pendencia.get_Documento().get_Vinculo(); + if (vinculo != null && vinculo.get_Id() != 0) + { + await this._apoliceServico.ExcluirVinculo(vinculo.get_Id()); + Action recarregarRelatorios = Gestor.Application.Actions.Actions.RecarregarRelatorios; + if (recarregarRelatorios != null) + { + recarregarRelatorios(this.Sessao); + } + else + { + } + base.Loading(false); + } + } + + public async Task SalvarParametros() + { + bool flag; + if (!await (new ConfuguracoesServico()).Salvar(this.ParametrosRelatorioAdicionados.ToList(), this.ParametrosRelatorio.ToList())) + { + flag = false; + } + else if (await (new ConfuguracoesServico()).SalvarTotalizacoes(this.ParametrosTotalizacaoAdicionados.ToList(), this.ParametrosTotalizacao.ToList())) + { + base.RegistrarAcao("SALVOU CONFIGURAÇÃO DO RELATORIO", new Gestor.Model.Common.Relatorio?(this.Relatorio), this.Filtros); + await this.CarregarConfiguracoes(); + flag = true; + } + else + { + flag = false; + } + return flag; + } + + public async Task SalvarTarefas(List tarefas) + { + await (new TarefaServico()).Salvar(tarefas); + } + + public async Task SalvarTrilha(Trilha destino) + { + Trilha trilha; + List fases = destino.get_Fases(); + TarefaServico tarefaServico = new TarefaServico(); + List trilhas = await tarefaServico.BuscarTrilhas(); + if (!trilhas.Any((Trilha x) => x.get_Tipo() == destino.get_Tipo())) + { + Trilha trilha1 = await tarefaServico.Salvar(destino); + if (tarefaServico.Sucesso) + { + fases.ForEach((Fase x) => x.set_Trilha(trilha1)); + fases = await tarefaServico.Salvar(fases); + if (tarefaServico.Sucesso) + { + trilha1.set_Fases(fases); + trilha = trilha1; + } + else + { + trilha = null; + } + } + else + { + trilha = null; + } + } + else + { + Trilha trilha2 = trilhas.First((Trilha x) => x.get_Tipo() == destino.get_Tipo()); + Trilha trilha3 = trilha2; + List fases1 = await tarefaServico.BuscarFases(trilha2.get_Id()); + trilha3.set_Fases(fases1); + trilha3 = null; + trilha = trilha2; + } + fases = null; + tarefaServico = null; + return trilha; + } + + private void SeguradoraOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(0); + } + + public async Task Selecionar() + { + await Task.Run(() => { + Dispatcher dispatcher; + Dispatcher dispatcher1; + DispatcherOperation dispatcherOperation; + switch (this.Relatorio) + { + case 0: + case 1: + { + if (this.ClientesAtivosInativosFiltrado == null || this.ClientesAtivosInativosFiltrado.Count == 0) + { + return; + } + this.ClientesAtivosInativosFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.set_Selecionado(!x.get_Selecionado())); + this.ClientesAtivosInativosFiltrado = new ObservableCollection(this.ClientesAtivosInativosFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 2: + { + if (this.ProducaoFiltrado == null || this.ProducaoFiltrado.Count == 0) + { + return; + } + this.ProducaoFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.set_Selecionado(!x.get_Selecionado())); + this.ProducaoFiltrado = new ObservableCollection(this.ProducaoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 3: + { + if (this.ApolicePendenteFiltrado == null || this.ApolicePendenteFiltrado.Count == 0) + { + return; + } + this.ApolicePendenteFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.set_Selecionado(!x.get_Selecionado())); + this.ApolicePendenteFiltrado = new ObservableCollection(this.ApolicePendenteFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 4: + { + if (this.RenovacaoFiltrado == null || this.RenovacaoFiltrado.Count == 0) + { + return; + } + this.RenovacaoFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.set_Selecionado(!x.get_Selecionado())); + this.RenovacaoFiltrado = new ObservableCollection(this.RenovacaoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 5: + { + if (this.ComissaoFiltrado == null || this.ComissaoFiltrado.Count == 0) + { + return; + } + this.ComissaoFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.set_Selecionado(!x.get_Selecionado())); + this.ComissaoFiltrado = new ObservableCollection(this.ComissaoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 6: + case 16: + { + if (this.PendenteFiltrado == null || this.PendenteFiltrado.Count == 0) + { + return; + } + this.PendenteFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.set_Selecionado(!x.get_Selecionado())); + this.PendenteFiltrado = new ObservableCollection(this.PendenteFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 7: + case 11: + case 20: + case 21: + case 22: + { + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 8: + { + if (this.AuditoriaFiltrado == null || this.AuditoriaFiltrado.Count == 0) + { + return; + } + this.AuditoriaFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.set_Selecionado(!x.get_Selecionado())); + this.AuditoriaFiltrado = new ObservableCollection(this.AuditoriaFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 9: + case 10: + { + if (this.SinistroFiltrado == null || this.SinistroFiltrado.Count == 0) + { + return; + } + this.SinistroFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.set_Selecionado(!x.get_Selecionado())); + this.SinistroFiltrado = new ObservableCollection(this.SinistroFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 12: + { + if (this.FaturaPendenteFiltrado == null || this.FaturaPendenteFiltrado.Count == 0) + { + return; + } + this.FaturaPendenteFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente x) => x.set_Selecionado(!x.get_Selecionado())); + this.FaturaPendenteFiltrado = new ObservableCollection(this.FaturaPendenteFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 13: + { + if (this.ExtratosFiltrado == null || this.ExtratosFiltrado.Count == 0) + { + return; + } + this.ExtratosFiltrado.ToList().ForEach((ExtratoBaixadoRelatorio x) => x.set_Selecionado(!x.get_Selecionado())); + this.ExtratosFiltrado = new ObservableCollection(this.ExtratosFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 14: + { + if (this.MetaSeguradoraFiltrado == null || this.MetaSeguradoraFiltrado.Count == 0) + { + return; + } + this.MetaSeguradoraFiltrado.ToList().ForEach((MetaSeguradoraRelatorio x) => x.set_Selecionado(!x.get_Selecionado())); + this.MetaSeguradoraFiltrado = new ObservableCollection(this.MetaSeguradoraFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 15: + { + if (this.MetaVendedorFiltrado == null || this.MetaVendedorFiltrado.Count == 0) + { + return; + } + this.MetaVendedorFiltrado.ToList().ForEach((MetaVendedorRelatorio x) => x.set_Selecionado(!x.get_Selecionado())); + this.MetaVendedorFiltrado = new ObservableCollection(this.MetaVendedorFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 17: + { + if (this.LicenciamentoFiltrado == null || this.LicenciamentoFiltrado.Count == 0) + { + return; + } + this.LicenciamentoFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => x.set_Selecionado(!x.get_Selecionado())); + this.LicenciamentoFiltrado = new ObservableCollection(this.LicenciamentoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 18: + { + if (this.TarefaFiltrado == null || this.TarefaFiltrado.Count == 0) + { + return; + } + this.TarefaFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Tarefa.Tarefa x) => x.set_Selecionado(!x.get_Selecionado())); + this.TarefaFiltrado = new ObservableCollection(this.TarefaFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 19: + { + if (this.NotaFiscalFiltrado == null || this.NotaFiscalFiltrado.Count == 0) + { + return; + } + this.NotaFiscalFiltrado.ToList().ForEach((NotaFiscalRelatorio x) => x.set_Selecionado(!x.get_Selecionado())); + this.NotaFiscalFiltrado = new ObservableCollection(this.NotaFiscalFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 23: + { + if (this.LogsEnvioFiltrado == null || this.LogsEnvioFiltrado.Count == 0) + { + return; + } + this.LogsEnvioFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.LogsEnvio.LogsEnvio x) => x.set_Selecionado(!x.get_Selecionado())); + this.LogsEnvioFiltrado = new ObservableCollection(this.LogsEnvioFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 24: + case 25: + { + if (this.LogUtilizacaoFiltrado == null || this.LogUtilizacaoFiltrado.Count == 0) + { + return; + } + this.LogUtilizacaoFiltrado.ToList().ForEach((LogAcaoRelatorio x) => x.set_Selecionado(!x.get_Selecionado())); + this.LogUtilizacaoFiltrado = new ObservableCollection(this.LogUtilizacaoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 26: + { + if (this.ApoliceCriticaFiltrado == null || this.ApoliceCriticaFiltrado.Count == 0) + { + return; + } + this.ApoliceCriticaFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.CriticaApolice.ApoliceCritica x) => x.set_Selecionado(!x.get_Selecionado())); + this.ApoliceCriticaFiltrado = new ObservableCollection(this.ApoliceCriticaFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 27: + { + if (this.PlacaFiltrado == null || this.PlacaFiltrado.Count == 0) + { + return; + } + this.PlacaFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Placa.Placas x) => x.set_Selecionado(!x.get_Selecionado())); + this.PlacaFiltrado = new ObservableCollection(this.PlacaFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 28: + { + if (this.EndossoFiltrado == null || this.EndossoFiltrado.Count == 0) + { + return; + } + this.EndossoFiltrado.ToList().ForEach((Endosso x) => x.set_Selecionado(!x.get_Selecionado())); + this.EndossoFiltrado = new ObservableCollection(this.EndossoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + case 29: + { + if (this.ClassificacaoFiltrado == null || this.ClassificacaoFiltrado.Count == 0) + { + return; + } + this.ClassificacaoFiltrado.ToList().ForEach((Gestor.Model.Domain.Relatorios.Classificacao.Classificacao x) => x.set_Selecionado(!x.get_Selecionado())); + this.ClassificacaoFiltrado = new ObservableCollection(this.ClassificacaoFiltrado); + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + default: + { + dispatcher = System.Windows.Application.Current.Dispatcher; + if (dispatcher == null) + { + dispatcher1 = dispatcher; + return; + } + dispatcherOperation = dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(this.Bind)); + return; + } + } + }); + } + + public async Task Sincronizar() + { + List produtos = LicenseHelper.Produtos; + if (produtos.All((Licenca x) => x.get_Produto() != 77)) + { + List licencas = LicenseHelper.Produtos; + if (licencas.All((Licenca x) => x.get_Produto() != 84)) + { + await base.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.", "OK", "", false); + Process.Start("https://agger.com.br"); + return; + } + } + Gestor.Model.Common.Relatorio relatorio = this.Relatorio; + if (relatorio != 3) + { + if (relatorio == 16) + { + if (this.PendenteFiltrado == null || !this.PendenteFiltrado.Any()) + { + await base.ShowMessage("NÃO HÁ DADOS PARA SINCRONIZAÇÃO", "OK", "", false); + return; + } + else + { + ObservableCollection pendenteFiltrado = this.PendenteFiltrado; + List list = ( + from x in pendenteFiltrado + select x.get_ParcelaEntity().get_Id()).ToList(); + int[] numArray = await this._parcelaServico.Sincronizar(this.Inicio, list); + if (numArray[0] == 0) + { + await base.ShowMessage("NÃO HÁ PARCELAS PENDENTES NO PERIODO SELECIONADO.", "OK", "", false); + return; + } + else if (numArray[0] <= 0 || numArray[1] != 0) + { + Action recarregarRelatorios = Gestor.Application.Actions.Actions.RecarregarRelatorios; + if (recarregarRelatorios != null) + { + recarregarRelatorios(this.Sessao); + } + else + { + } + base.ToggleSnackBar(string.Format("{0} PARCELAS VINCULADAS", numArray[1]), true); + } + else + { + return; + } + } + } + } + else if (this.ApolicePendenteFiltrado == null || !this.ApolicePendenteFiltrado.Any()) + { + await base.ShowMessage("NÃO HÁ DADOS PARA SINCRONIZAÇÃO", "OK", "", false); + return; + } + else + { + ObservableCollection apolicePendenteFiltrado = this.ApolicePendenteFiltrado; + IEnumerable apolicePendentes = apolicePendenteFiltrado.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + long? idAggilizador; + bool hasValue; + bool vinculo; + long? nullable; + Documento documento = x.get_Documento(); + if (documento != null) + { + Controle controle = documento.get_Controle(); + if (controle != null) + { + Seguradora seguradora = controle.get_Seguradora(); + if (seguradora != null) + { + idAggilizador = seguradora.get_IdAggilizador(); + hasValue = idAggilizador.HasValue; + } + else + { + hasValue = false; + } + } + else + { + hasValue = false; + } + } + else + { + hasValue = false; + } + if (!hasValue) + { + return false; + } + Documento documento1 = x.get_Documento(); + if (documento1 != null) + { + vinculo = documento1.get_Vinculo(); + } + else + { + vinculo = false; + } + if (!vinculo) + { + return true; + } + Documento documento2 = x.get_Documento(); + if (documento2 == null) + { + return false; + } + VinculoDocumento vinculoDocumento = documento2.get_Vinculo(); + if (vinculoDocumento != null) + { + nullable = new long?(vinculoDocumento.get_IdApoliceDigital()); + } + else + { + nullable = null; + } + idAggilizador = nullable; + long num = (long)0; + return idAggilizador.GetValueOrDefault() == num & idAggilizador.HasValue; + }); + List dadosVinculos = apolicePendentes.Select((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + string proposta; + object placa; + DadosVinculo dadosVinculo = new DadosVinculo(); + dadosVinculo.set_Id(x.get_Documento().get_Id()); + if (x.get_Documento().get_Controle().get_Seguradora().get_IdAggilizador().Value != (long)1 || x.get_Documento().get_Controle().get_Ramo().get_Id() != (long)5) + { + proposta = x.get_Documento().get_Proposta(); + } + else + { + ObservableCollection result = Task.Run>(() => (new ItemServico()).BuscarItems(x.get_Documento().get_Id(), 2, false)).Result; + if (result != null) + { + Item item = result.FirstOrDefault(); + if (item != null) + { + placa = item.get_Auto().get_Placa(); + } + else + { + placa = null; + } + } + else + { + placa = null; + } + if (placa != null) + { + proposta = ((string)placa).Replace("-", string.Empty); + } + else + { + proposta = null; + } + } + dadosVinculo.set_Proposta(proposta); + dadosVinculo.set_Apolice(x.get_Documento().get_Apolice()); + dadosVinculo.set_Documento(x.get_Documento().get_Controle().get_Cliente().get_Documento()); + dadosVinculo.set_Endosso(x.get_Documento().get_PropostaEndosso()); + dadosVinculo.set_IdSeguradora(x.get_Documento().get_Controle().get_Seguradora().get_IdAggilizador().Value); + dadosVinculo.set_VigenciaInicial(x.get_Documento().get_Vigencia1()); + dadosVinculo.set_Vigenciafinal(x.get_Documento().get_Vigencia2()); + dadosVinculo.set_Vinculo(x.get_Documento().get_Vinculo()); + return dadosVinculo; + }).ToList(); + Gestor.Model.Domain.Relatorios.Filtros filtro = new Gestor.Model.Domain.Relatorios.Filtros(); + filtro.set_Inicio(this.Inicio); + filtro.set_Fim(this.Fim); + int num1 = await this._apoliceServico.Sincronizar(dadosVinculos, filtro); + Action action = Gestor.Application.Actions.Actions.RecarregarRelatorios; + if (action != null) + { + action(this.Sessao); + } + else + { + } + ObservableCollection observableCollection = this.ApolicePendenteFiltrado; + if (!observableCollection.All((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + long? nullable; + Documento documento = x.get_Documento(); + if (documento == null) + { + return false; + } + VinculoDocumento vinculo = documento.get_Vinculo(); + if (vinculo != null) + { + nullable = new long?(vinculo.get_IdApoliceDigital()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + long num = (long)0; + return nullable1.GetValueOrDefault() == num & nullable1.HasValue; + })) + { + if (num1 != 0) + { + base.ToggleSnackBar(string.Format("{0} DOCUMENTOS SINCRONIZADOS", num1), true); + RelatorioViewModel relatorioViewModel = this; + ObservableCollection apolicePendenteFiltrado1 = this.ApolicePendenteFiltrado; + if (!await relatorioViewModel.ShowMessage(string.Format("{0} DOCUMENTOS SINCRONIZADOS, DESEJA INICIAR A IMPORTAÇÃO DESSES DOCUMENTOS?", apolicePendenteFiltrado1.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + long? nullable; + Documento documento = x.get_Documento(); + if (documento == null) + { + return false; + } + VinculoDocumento vinculo = documento.get_Vinculo(); + if (vinculo != null) + { + nullable = new long?(vinculo.get_IdApoliceDigital()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + long num = (long)0; + return nullable1.GetValueOrDefault() > num & nullable1.HasValue; + })), "SIM", "NÃO", false)) + { + return; + } + } + else if (!await base.ShowMessage("NENHUM NOVO DOCUMENTO FOI SINCRONIZADO, DESEJA IMPORTAR OS DOCUMENTOS ANTERIORMENTE SINCRONIZADOS?", "SIM", "NÃO", false)) + { + return; + } + ObservableCollection observableCollection1 = this.ApolicePendenteFiltrado; + IEnumerable apolicePendentes1 = observableCollection1.Where((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + long? nullable; + Documento documento = x.get_Documento(); + if (documento == null) + { + return false; + } + VinculoDocumento vinculo = documento.get_Vinculo(); + if (vinculo != null) + { + nullable = new long?(vinculo.get_IdApoliceDigital()); + } + else + { + nullable = null; + } + long? nullable1 = nullable; + long num = (long)0; + return nullable1.GetValueOrDefault() > num & nullable1.HasValue; + }); + List nums = ( + from x in apolicePendentes1 + select x.get_Documento().get_Vinculo().get_IdApoliceDigital()).ToList(); + await base.DownloadAll(nums, 1); + Parameters parameter = new Parameters(); + parameter.set_Beta(false); + parameter.set_Type(4); + parameter.set_Application("Agger.ImportPDF.exe"); + parameter.set_Directory("Agger.Import"); + object[] id = new object[] { Recursos.Empresa.get_Id(), Recursos.Usuario.get_Id(), ApplicationHelper.Subkey, ApplicationHelper.NumeroSerial }; + parameter.set_Arguments(string.Format("{0} {1} NOVOGESTOR PERFIL:{2} SERIAL:{3}", id)); + parameter.set_Run(true); + (new DownloadWindow(parameter)).Show(); + } + else + { + await base.ShowMessage("NENHUM NOVO DOCUMENTO FOI SINCRONIZADO", "OK", "", false); + return; + } + } + } + + public async Task Sintetico() + { + List list = null; + if ((GridRelatorio)this.Report != null || this.Relatorio == 7 || this.Relatorio == 11) + { + switch (this.Relatorio) + { + case 2: + { + List producaos = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ProducaoFiltrado == null || producaos.Count == 0) + { + break; + } + else + { + if (this.Agrupamento == 3) + { + List producaos1 = producaos; + producaos = ( + from producao in producaos1 + where producao.get_Vendedor() != null + select producao).ToList(); + } + list = producaos.GroupBy((Gestor.Model.Domain.Relatorios.Producao.Producao x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento != 4) + { + return x.get_Status(); + } + return x.get_Estipulante(); + }).Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_PremioTotal(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_PremioTotal()))); + sintetico.set_PremioLiquido(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_PremioLiquido()))); + sintetico.set_MediaComissao(new decimal?((x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Comissao()) > decimal.Zero ? decimal.Round(x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Comissao()) / x.Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Comissao() > decimal.Zero), 2) * new decimal(100) : decimal.Zero))); + sintetico.set_ComissaoGerada(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => ((c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) * new decimal(1, 0, 0, false, 2)))); + sintetico.set_Cancelamentos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Situacao() == 3))); + sintetico.set_Novos(new int?(Funcoes.DistinctBy(x, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoNegociosNovos))); + sintetico.set_NegociosProprios(new int?(Funcoes.DistinctBy(x, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoNegociosProprios))); + sintetico.set_SegurosNovos(new int?(Funcoes.DistinctBy(x, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoSegurosNovos))); + sintetico.set_Renovacoes(new int?(Funcoes.DistinctBy(x, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoSegurosRenovacao))); + sintetico.set_Apolices(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Endossos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Faturas(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico.set_TotalLiquido(new int?(x.Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Situacao() != 3))); + sintetico.set_TotalGeral(new int?(x.Count())); + sintetico.set_MediaPonderada(new decimal?((x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_PremioLiquido()) > decimal.Zero ? decimal.Round(x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => (c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) / x.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_PremioLiquido()), 2) * new decimal(100) : decimal.Zero))); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 3: + { + List apolicePendentes = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ApolicePendenteFiltrado == null || apolicePendentes.Count == 0) + { + break; + } + else + { + IEnumerable> groupings = apolicePendentes.GroupBy((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento != 4) + { + return x.get_Status(); + } + return x.get_Estipulante(); + }); + list = groupings.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_Cancelamentos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Situacao() == 3))); + sintetico.set_Novos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico.set_Renovacoes(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico.set_Apolices(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Endossos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Faturas(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico.set_TotalGeral(new int?(x.Count())); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 4: + { + List renovacaos = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.RenovacaoFiltrado == null || renovacaos.Count == 0) + { + break; + } + else + { + List renovacaos1 = renovacaos; + IEnumerable> groupings1 = ( + from x in renovacaos1 + where x.get_Documento() != null + select x).GroupBy((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento != 4) + { + return x.get_Status(); + } + return x.get_Estipulante(); + }); + list = groupings1.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_PremioTotal(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_PremioTotal()))); + sintetico.set_PremioLiquido(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao p) => p.get_PremioLiquido()))); + sintetico.set_MediaComissao(new decimal?((x.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Comissao()) > decimal.Zero ? decimal.Round(x.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Comissao()) / x.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Comissao() > decimal.Zero), 2) * new decimal(100) : decimal.Zero))); + sintetico.set_ComissaoGerada(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => ((c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) * new decimal(1, 0, 0, false, 2)))); + sintetico.set_Cancelamentos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Situacao() == 3))); + sintetico.set_Novos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico.set_Renovacoes(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico.set_Apolices(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Endossos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Faturas(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico.set_TotalProspeccao(new int?(x.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Tipo() == 3))); + sintetico.set_TotalGeral(new int?(x.Count())); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 5: + { + List comissaos = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.ComissaoFiltrado == null || comissaos.Count == 0) + { + break; + } + else + { + IEnumerable> groupings2 = comissaos.GroupBy((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento != 4) + { + return x.get_Status(); + } + return x.get_Estipulante(); + }); + list = groupings2.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_Cancelamentos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Situacao() == 3))); + sintetico.set_Novos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico.set_Renovacoes(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico.set_Apolices(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => { + if (c.get_Documento().get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Endossos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => { + if (c.get_Documento().get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Faturas(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico.set_ComissaoRecebidaBruta(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_ComissaoBruta()))); + sintetico.set_ComissaoRecebidaLiquida(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_ComissaoRecebida()))); + sintetico.set_Repasse(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_Repasse()))); + sintetico.set_MediaComissao(new decimal?((x.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_ComissaoPerc() > decimal.Zero) ? decimal.Round(x.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_ComissaoPerc()) / x.Count((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_ComissaoPerc() > decimal.Zero), 2) : decimal.Zero) * new decimal(100))); + sintetico.set_ComissaoPrevista(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao c) => c.get_ValorLiquido()))); + sintetico.set_TotalGeral(new int?(x.Count())); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 6: + case 16: + { + if (this.PendenteFiltrado == null || this.PendenteFiltrado.Count == 0) + { + break; + } + else + { + IEnumerable> groupings3 = this.PendenteFiltrado.GroupBy((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento != 4) + { + return x.get_Status(); + } + return x.get_Estipulante(); + }); + list = groupings3.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_Cancelamentos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Situacao() == 3))); + sintetico.set_Novos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico.set_Renovacoes(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico.set_Apolices(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => { + if (c.get_Documento().get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Endossos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => { + if (c.get_Documento().get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Faturas(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico.set_ComissaoPrevista(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_ComissaoPrevista()))); + sintetico.set_TotalPrevista(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Pendente.Pendente c) => c.get_TotalPrevisto()))); + sintetico.set_TotalGeral(new int?(x.Count())); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 7: + { + if (this.Pagamentos == null || this.Pagamentos.Count == 0) + { + break; + } + else + { + List pagamentos = this.Pagamentos; + list = pagamentos.Select((Pagamento x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.get_Vendedores().get_Vendedor()); + sintetico.set_ValorLiquido(new decimal?(( + from c in x.get_Dados() + where c.get_Id() != (long)0 + select c).Sum((DadosRelatorio c) => c.get_ValorLiquido()))); + sintetico.set_ValorParcela(( + from c in x.get_Dados() + where c.get_Id() != (long)0 + select c).Sum((DadosRelatorio c) => c.get_ValorParcela())); + sintetico.set_Repasse(new decimal?(( + from c in x.get_Dados() + where c.get_Id() != (long)0 + select c).Sum((DadosRelatorio c) => c.get_Repasse()))); + sintetico.set_TotalGeral(new int?(x.get_Dados().Count((DadosRelatorio c) => c.get_Id() != (long)0))); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 8: + { + List auditorias = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.AuditoriaFiltrado == null || auditorias.Count == 0) + { + break; + } + else + { + IEnumerable> groupings4 = auditorias.GroupBy((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento != 4) + { + return x.get_Status(); + } + return x.get_Estipulante(); + }); + list = groupings4.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_PremioTotal(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_PremioTotal()))); + sintetico.set_PremioLiquido(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria p) => p.get_PremioLiquido()))); + sintetico.set_MediaComissao(new decimal?((x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Comissao()) > decimal.Zero ? decimal.Round(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Comissao()) / x.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Comissao() > decimal.Zero), 2) : decimal.Zero) * new decimal(100))); + sintetico.set_ComissaoGerada(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => ((c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) * new decimal(1, 0, 0, false, 2)))); + sintetico.set_ComissaoPrevista(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_ComissaoPrevista()))); + sintetico.set_ComissaoRecebidaBruta(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_ComissaoRecebida()))); + sintetico.set_ComissaoPendente(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_ComissaoPendente()))); + sintetico.set_Cancelamentos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Situacao() == 3))); + sintetico.set_Novos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico.set_Renovacoes(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico.set_Apolices(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Endossos(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico.set_Faturas(new int?(Funcoes.DistinctBy(x, (Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico.set_TotalLiquido(new int?(x.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Situacao() != 3))); + sintetico.set_TotalGeral(new int?(x.Count())); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 9: + case 10: + { + List sinistros = ((GridRelatorio)this.Report).DataGrid.Items.Cast().ToList(); + if (this.SinistroFiltrado == null || sinistros.Count == 0) + { + break; + } + else + { + list = sinistros.GroupBy((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (this.Agrupamento == 1) + { + return x.get_Seguradora(); + } + if (this.Agrupamento == 2) + { + return x.get_Ramo(); + } + if (this.Agrupamento == 3) + { + return x.get_Vendedor(); + } + if (this.Agrupamento == 4) + { + return x.get_Estipulante(); + } + return EnumHelper.GetDescription(x.get_StatusSinistro()); + }).Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_Liquidado((this.Relatorio == 9 ? null : new int?(( + from s in x + where s.get_Liquidacao().HasValue + select s.get_EntidadeSinistro().get_ControleSinistro().get_Id()).Distinct().Count()))); + sintetico.set_Valor(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_Valor()))); + sintetico.set_ValorOrcado(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_ValorOrcado()))); + sintetico.set_ValorLiberado(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_ValorLiberado()))); + sintetico.set_ValorPago(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_ValorPago()))); + sintetico.set_ValorLiquidado((this.Relatorio == 9 ? null : new decimal?(( + from s in x + where s.get_Liquidacao().HasValue + select s).Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_ValorPago())))); + sintetico.set_ValorSalvado(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_ValorSalvado()))); + sintetico.set_ValorFranquia(new decimal?(x.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro s) => s.get_ValorFranquia()))); + sintetico.set_Pendente(new int?(( + from s in x + where !s.get_Liquidacao().HasValue + select s.get_EntidadeSinistro().get_ControleSinistro().get_Id()).Distinct().Count())); + sintetico.set_TotalGeral(new int?(( + from s in x + select s.get_EntidadeSinistro().get_ControleSinistro().get_Id()).Distinct().Count())); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 11: + { + if (this.FechamentoFiltrado == null || this.FechamentoFiltrado.Count == 0) + { + break; + } + else + { + list = new List(); + Gestor.Model.Domain.Relatorios.Fechamento.Fechamento fechamento = this.FechamentoFiltrado.First().get_Fechamento().Last(); + Sintetico sintetico1 = new Sintetico(); + int year = this.Inicio.Year; + sintetico1.set_Agrupamento(string.Concat("ATUAL: ", year.ToString())); + sintetico1.set_TotalGeral(new int?(fechamento.get_Apolice())); + sintetico1.set_ValorPago(new decimal?(fechamento.get_Paga())); + sintetico1.set_ComissaoRecebidaBruta(new decimal?(fechamento.get_Recebida())); + sintetico1.set_ComissaoGerada(new decimal?(fechamento.get_Gerada())); + sintetico1.set_PremioLiquido(new decimal?(fechamento.get_PremioLiquido())); + sintetico1.set_PremioTotal(new decimal?(fechamento.get_PremioTotal())); + list.Add(sintetico1); + Sintetico sintetico2 = new Sintetico(); + year = this.Inicio.Year - 1; + sintetico2.set_Agrupamento(string.Concat("ANTERIOR: ", year.ToString())); + sintetico2.set_TotalGeral(new int?(fechamento.get_ApoliceAnterior())); + sintetico2.set_ValorPago(new decimal?(fechamento.get_PagaAnterior())); + sintetico2.set_ComissaoRecebidaBruta(new decimal?(fechamento.get_RecebidaAnterior())); + sintetico2.set_ComissaoGerada(new decimal?(fechamento.get_GeradaAnterior())); + sintetico2.set_PremioLiquido(new decimal?(fechamento.get_PremioLiquidoAnterior())); + sintetico2.set_PremioTotal(new decimal?(fechamento.get_PremioTotalAnterior())); + list.Add(sintetico2); + goto case 13; + } + } + case 12: + case 13: + { + if (list != null) + { + (new SinteticoView(list, EnumHelper.GetDescription(this.Relatorio), new DateTime?(this.Inicio), new DateTime?(this.Fim))).Show(); + break; + } + else + { + break; + } + } + case 14: + { + if (this.MetaSeguradora == null || this.MetaSeguradora.Count == 0) + { + break; + } + else + { + List metaSeguradora = this.MetaSeguradora; + IEnumerable> seguradora = + from g in metaSeguradora + group g by g.get_Seguradora(); + list = seguradora.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_Meta(new decimal?(Math.Round(( + from m in x + where m.get_MetaAtingir() > decimal.Zero + select m).Sum((MetaSeguradoraRelatorio m) => (m.get_MetaCumprida() * new decimal(100)) / m.get_MetaAtingir()) * new decimal(100), 2))); + sintetico.set_MetaAtingir(new decimal?(Math.Round(x.Sum((MetaSeguradoraRelatorio m) => m.get_MetaAtingir()), 2))); + sintetico.set_MetaCumprida(new decimal?(Math.Round(x.Sum((MetaSeguradoraRelatorio m) => m.get_MetaCumprida()), 2))); + return sintetico; + }).ToList(); + goto case 13; + } + } + case 15: + { + if (this.MetaVendedor == null || this.MetaVendedor.Count == 0) + { + break; + } + else + { + List metaVendedor = this.MetaVendedor; + IEnumerable> vendedor = + from g in metaVendedor + group g by g.get_Vendedor(); + list = vendedor.Select, Sintetico>((IGrouping x) => { + Sintetico sintetico = new Sintetico(); + sintetico.set_Agrupamento(x.Key); + sintetico.set_Meta(new decimal?(Math.Round(( + from m in x + where m.get_MetaAtingir() > decimal.Zero + select m).Sum((MetaVendedorRelatorio m) => (m.get_MetaCumprida() * new decimal(100)) / m.get_MetaAtingir()) * new decimal(100), 2))); + sintetico.set_MetaAtingir(new decimal?(Math.Round(x.Sum((MetaVendedorRelatorio m) => m.get_MetaAtingir()), 2))); + sintetico.set_MetaCumprida(new decimal?(Math.Round(x.Sum((MetaVendedorRelatorio m) => m.get_MetaCumprida()), 2))); + return sintetico; + }).ToList(); + goto case 13; + } + } + default: + { + goto case 13; + } + } + } + else + { + await base.ShowMessage("NECESSARIO GERAR UM RELATÓRIO COM DADOS PARA SINTETIZAR", "OK", "", false); + } + } + + public void SintetizarRelatorio() + { + this.SinteticoRelatorio = new ObservableCollection(); + switch (this.Relatorio) + { + case 0: + case 1: + { + if (this.ClientesAtivosInativosFiltrado == null || this.ClientesAtivosInativosFiltrado.Count == 0) + { + return; + } + List clientesAtivosInativos = (this.ClientesAtivosInativosFiltrado.Any((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Selecionado()) ? ( + from x in this.ClientesAtivosInativosFiltrado + where x.get_Selecionado() + select x).ToList() : this.ClientesAtivosInativosFiltrado.ToList()); + List sinteticos = new List(); + Sintetico sintetico = new Sintetico(); + sintetico.set_TotalClientes(new int?(clientesAtivosInativos.Count)); + sintetico.set_TotalClientesAtivos(new int?(clientesAtivosInativos.Count((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Ativo() == "SIM"))); + sintetico.set_TotalClientesInativos(new int?(clientesAtivosInativos.Count((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => x.get_Ativo() == "NÃO"))); + sinteticos.Add(sintetico); + this.SinteticoRelatorio = new ObservableCollection(sinteticos); + return; + } + case 2: + { + if (this.ProducaoFiltrado == null || this.ProducaoFiltrado.Count == 0) + { + return; + } + List producaos = (this.ProducaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Selecionado()) ? ( + from x in this.ProducaoFiltrado + where x.get_Selecionado() + select x).ToList() : this.ProducaoFiltrado.ToList()); + List sinteticos1 = new List(); + Sintetico sintetico1 = new Sintetico(); + sintetico1.set_PremioTotal(new decimal?(producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_PremioTotal()))); + sintetico1.set_PremioLiquido(new decimal?(producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_PremioLiquido()))); + sintetico1.set_MediaPonderada(new decimal?((producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_PremioLiquido()) > decimal.Zero ? decimal.Round(producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => (c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) / producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao p) => p.get_PremioLiquido()), 2) : decimal.Zero))); + sintetico1.set_MediaComissao(new decimal?((producaos.Any((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Comissao() > decimal.Zero) ? decimal.Round(producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Comissao()) / producaos.Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Comissao() > decimal.Zero), 2) : decimal.Zero))); + sintetico1.set_ComissaoGerada(new decimal?(producaos.Sum((Gestor.Model.Domain.Relatorios.Producao.Producao c) => ((c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) * new decimal(1, 0, 0, false, 2)))); + sintetico1.set_Cancelamentos(new int?(Funcoes.DistinctBy(producaos, (Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Documento().get_Controle().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Situacao() == 3))); + sintetico1.set_Novos(new int?(Funcoes.DistinctBy(producaos, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoNegociosNovos))); + sintetico1.set_NegociosProprios(new int?(Funcoes.DistinctBy(producaos, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoNegociosProprios))); + sintetico1.set_SegurosNovos(new int?(Funcoes.DistinctBy(producaos, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoSegurosNovos))); + sintetico1.set_Renovacoes(new int?(Funcoes.DistinctBy(producaos, this.funcProducaoDistinctByDocumentoId).Count(this.funcProducaoSegurosRenovacao))); + sintetico1.set_Apolices(new int?(Funcoes.DistinctBy(producaos, (Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico1.set_Endossos(new int?(Funcoes.DistinctBy(producaos, (Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico1.set_Faturas(new int?(Funcoes.DistinctBy(producaos, (Gestor.Model.Domain.Relatorios.Producao.Producao x) => x.get_Documento().get_Id()).Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico1.set_TotalGeral(new int?(producaos.Count)); + sintetico1.set_TotalLiquido(new int?(producaos.Count((Gestor.Model.Domain.Relatorios.Producao.Producao c) => c.get_Documento().get_Situacao() != 3))); + sinteticos1.Add(sintetico1); + this.SinteticoRelatorio = new ObservableCollection(sinteticos1); + return; + } + case 3: + { + if (this.ApolicePendenteFiltrado == null || this.ApolicePendenteFiltrado.Count == 0) + { + return; + } + List apolicePendentes = (this.ApolicePendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_Selecionado()) ? ( + from x in this.ApolicePendenteFiltrado + where x.get_Selecionado() + select x).ToList() : this.ApolicePendenteFiltrado.ToList()); + List sinteticos2 = new List(); + Sintetico sintetico2 = new Sintetico(); + sintetico2.set_PremioTotal(new decimal?(apolicePendentes.Sum((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => x.get_PremioTotal()))); + sintetico2.set_PremioLiquido(new decimal?(apolicePendentes.Sum((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente p) => p.get_PremioLiquido()))); + sintetico2.set_MediaComissao(new decimal?((apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Comissao() > decimal.Zero) > 0 ? decimal.Round(apolicePendentes.Sum((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Comissao()) / apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Comissao() > decimal.Zero), 2) : decimal.Zero))); + sintetico2.set_ComissaoGerada(new decimal?(apolicePendentes.Sum((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => ((c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) * new decimal(1, 0, 0, false, 2)))); + sintetico2.set_Cancelamentos(new int?(apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_Situacao() == 3))); + sintetico2.set_Novos(new int?(apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico2.set_Renovacoes(new int?(apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico2.set_Apolices(new int?(apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico2.set_Endossos(new int?(apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico2.set_Faturas(new int?(apolicePendentes.Count((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico2.set_TotalGeral(new int?(apolicePendentes.Count)); + sinteticos2.Add(sintetico2); + this.SinteticoRelatorio = new ObservableCollection(sinteticos2); + return; + } + case 4: + { + if (this.RenovacaoFiltrado == null || this.RenovacaoFiltrado.Count == 0) + { + return; + } + List renovacaos = (this.RenovacaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_Selecionado()) ? ( + from x in this.RenovacaoFiltrado + where x.get_Selecionado() + select x).ToList() : this.RenovacaoFiltrado.ToList()); + List sinteticos3 = new List(); + Sintetico sintetico3 = new Sintetico(); + sintetico3.set_PremioTotal(new decimal?(renovacaos.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => x.get_PremioTotal()))); + sintetico3.set_PremioLiquido(new decimal?(renovacaos.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao p) => p.get_PremioLiquido()))); + sintetico3.set_MediaComissao(new decimal?((renovacaos.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Comissao()) > decimal.Zero ? decimal.Round(renovacaos.Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Comissao()) / renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Comissao() > decimal.Zero), 2) : decimal.Zero))); + sintetico3.set_ComissaoGerada(new decimal?(renovacaos.Where((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => { + if (x.get_Tipo() == 3) + { + return false; + } + return x.get_Comissao() > decimal.Zero; + }).Sum((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => ((c.get_PremioLiquido() + (c.get_Documento().get_AdicionalComiss() ? c.get_Documento().get_PremioAdicional() : decimal.Zero)) * c.get_Comissao()) * new decimal(1, 0, 0, false, 2)))); + sintetico3.set_Cancelamentos(new int?(renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3) + { + return false; + } + return c.get_Documento().get_Situacao() == 3; + }))); + sintetico3.set_Novos(new int?(renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() != 3 && c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Tipo() == 3 || c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico3.set_Renovacoes(new int?(renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3 || c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico3.set_Apolices(new int?(renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico3.set_Endossos(null); + sintetico3.set_Faturas(new int?(renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2; + }))); + sintetico3.set_TotalProspeccao(new int?(renovacaos.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Tipo() == 3))); + sintetico3.set_TotalGeral(new int?(renovacaos.Count)); + sinteticos3.Add(sintetico3); + this.SinteticoRelatorio = new ObservableCollection(sinteticos3); + return; + } + case 5: + { + if (this.ComissaoFiltrado == null || this.ComissaoFiltrado.Count == 0) + { + return; + } + List comissaos = (this.ComissaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Selecionado()) ? ( + from x in this.ComissaoFiltrado + where x.get_Selecionado() + select x).ToList() : this.ComissaoFiltrado.ToList()); + List sinteticos4 = new List(); + Sintetico sintetico4 = new Sintetico(); + sintetico4.set_ComissaoRecebidaBruta(new decimal?(comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_ComissaoBruta()))); + sintetico4.set_ComissaoRecebidaLiquida(new decimal?(comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_ComissaoRecebida()))); + sintetico4.set_Impostos(new decimal?((comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Ir()) + comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Iss())) + comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Outros()))); + sintetico4.set_PremioLiquido(new decimal?(Funcoes.DistinctBy(comissaos, (Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Documento().get_Id()).Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_PremioLiquido()))); + sintetico4.set_PremioTotal(new decimal?(Funcoes.DistinctBy(comissaos, (Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Documento().get_Id()).Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_PremioTotal()))); + sintetico4.set_ComissaoPrevista(new decimal?(comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_ValorLiquido()))); + sintetico4.set_Repasse(new decimal?(comissaos.Sum((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => x.get_Repasse()))); + sinteticos4.Add(sintetico4); + this.SinteticoRelatorio = new ObservableCollection(sinteticos4); + return; + } + case 6: + case 16: + { + if (this.PendenteFiltrado == null || this.PendenteFiltrado.Count == 0) + { + return; + } + List pendentes = (this.PendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Selecionado()) ? ( + from x in this.PendenteFiltrado + where x.get_Selecionado() + select x).ToList() : this.PendenteFiltrado.ToList()); + List sinteticos5 = new List(); + Sintetico sintetico5 = new Sintetico(); + sintetico5.set_ComissaoPrevista(new decimal?(pendentes.Sum((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_ComissaoPrevista()))); + sintetico5.set_TotalPrevista(new decimal?(Funcoes.DistinctBy(pendentes, (Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_Documento().get_Id()).Sum((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_TotalPrevisto()))); + sintetico5.set_TotalGeral(new int?(pendentes.Count)); + sintetico5.set_TotalParcela(new decimal?(pendentes.Sum((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => x.get_ValorParcela()))); + sinteticos5.Add(sintetico5); + this.SinteticoRelatorio = new ObservableCollection(sinteticos5); + return; + } + case 7: + case 11: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + { + return; + } + case 8: + { + if (this.AuditoriaFiltrado == null || this.AuditoriaFiltrado.Count == 0) + { + return; + } + List auditorias = (this.AuditoriaFiltrado.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_Selecionado()) ? ( + from x in this.AuditoriaFiltrado + where x.get_Selecionado() + select x).ToList() : this.AuditoriaFiltrado.ToList()); + List sinteticos6 = new List(); + Sintetico sintetico6 = new Sintetico(); + sintetico6.set_PremioTotal(new decimal?(auditorias.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => x.get_PremioTotal()))); + sintetico6.set_PremioLiquido(new decimal?(auditorias.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria p) => p.get_PremioLiquido()))); + sintetico6.set_ComissaoRecebidaBruta(new decimal?(auditorias.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria p) => p.get_ComissaoRecebida()))); + sintetico6.set_MediaComissao(new decimal?((auditorias.Any((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Comissao() > decimal.Zero) ? decimal.Round(auditorias.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Comissao()) / auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Comissao() > decimal.Zero), 2) : decimal.Zero))); + sintetico6.set_ComissaoPrevista(new decimal?(auditorias.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_ComissaoPrevista()))); + sintetico6.set_ComissaoPendente(new decimal?(auditorias.Sum((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_ComissaoPendente()))); + sintetico6.set_Cancelamentos(new int?(auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_Situacao() == 3))); + sintetico6.set_Novos(new int?(auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico6.set_Renovacoes(new int?(auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico6.set_Apolices(new int?(auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico6.set_Endossos(new int?(auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => { + if (c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico6.set_Faturas(new int?(auditorias.Count((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico6.set_TotalGeral(new int?(auditorias.Count)); + sinteticos6.Add(sintetico6); + this.SinteticoRelatorio = new ObservableCollection(sinteticos6); + return; + } + case 9: + case 10: + { + if (this.SinistroFiltrado == null || this.SinistroFiltrado.Count == 0) + { + return; + } + List sinistros = (this.SinistroFiltrado.Any((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Selecionado()) ? ( + from x in this.SinistroFiltrado + where x.get_Selecionado() + select x).ToList() : this.SinistroFiltrado.ToList()); + List sinteticos7 = new List(); + Sintetico sintetico7 = new Sintetico(); + sintetico7.set_Liquidado(new int?(sinistros.Count((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => { + if (x.get_StatusSinistro() != 2) + { + return false; + } + return x.get_TipoSinistro() == 0; + }))); + sintetico7.set_Valor(new decimal?(sinistros.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_Valor()))); + sintetico7.set_ValorOrcado(new decimal?(sinistros.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_ValorOrcado()))); + sintetico7.set_ValorLiberado(new decimal?(sinistros.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_ValorLiberado()))); + sintetico7.set_ValorPago(new decimal?(sinistros.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_ValorPago()))); + sintetico7.set_ValorLiquidado(new decimal?(( + from x in sinistros + where x.get_StatusSinistro() == 2 + select x).Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_ValorPago()))); + sintetico7.set_ValorSalvado(new decimal?(sinistros.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_ValorSalvado()))); + sintetico7.set_ValorFranquia(new decimal?(sinistros.Sum((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_ValorFranquia()))); + sintetico7.set_Pendente(new int?(sinistros.Count((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => !x.get_Liquidacao().HasValue))); + sintetico7.set_TotalGeral(new int?(sinistros.Distinct().Count())); + sintetico7.set_TotalClientes(new int?(sinistros.Count((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_TipoSinistro() == 0))); + sintetico7.set_TotalTerceiros(new int?(sinistros.Count((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => x.get_TipoSinistro() == 1))); + sinteticos7.Add(sintetico7); + this.SinteticoRelatorio = new ObservableCollection(sinteticos7); + return; + } + case 12: + { + if (this.FaturaPendenteFiltrado == null || this.FaturaPendenteFiltrado.Count == 0) + { + return; + } + List faturaPendentes = (this.FaturaPendenteFiltrado.Any((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente x) => x.get_Selecionado()) ? ( + from x in this.FaturaPendenteFiltrado + where x.get_Selecionado() + select x).ToList() : this.FaturaPendenteFiltrado.ToList()); + List sinteticos8 = new List(); + Sintetico sintetico8 = new Sintetico(); + sintetico8.set_TotalClientes(new int?(( + from x in faturaPendentes + select x.get_Cliente()).Distinct().Count())); + sintetico8.set_Cancelamentos(new int?(faturaPendentes.Count((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente c) => c.get_Documento().get_Situacao() == 3))); + sintetico8.set_Novos(new int?(faturaPendentes.Count((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente c) => { + if (c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico8.set_Renovacoes(new int?(faturaPendentes.Count((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente c) => { + if (c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico8.set_Apolices(new int?(faturaPendentes.Count((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente c) => { + if (c.get_Documento().get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico8.set_Endossos(new int?(faturaPendentes.Count((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente c) => { + if (c.get_Documento().get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico8.set_Faturas(new int?(faturaPendentes.Count((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente c) => c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2))); + sintetico8.set_TotalGeral(new int?(faturaPendentes.Count)); + sinteticos8.Add(sintetico8); + this.SinteticoRelatorio = new ObservableCollection(sinteticos8); + return; + } + case 13: + { + if (this.ExtratosFiltrado == null || this.ExtratosFiltrado.Count == 0) + { + return; + } + List extratoBaixadoRelatorios = (this.ExtratosFiltrado.Any((ExtratoBaixadoRelatorio x) => x.get_Selecionado()) ? ( + from x in this.ExtratosFiltrado + where x.get_Selecionado() + select x).ToList() : this.ExtratosFiltrado.ToList()); + List sinteticos9 = new List(); + Sintetico sintetico9 = new Sintetico(); + sintetico9.set_TotalGeral(new int?(extratoBaixadoRelatorios.Count)); + sinteticos9.Add(sintetico9); + this.SinteticoRelatorio = new ObservableCollection(sinteticos9); + return; + } + case 14: + { + if (this.MetaSeguradoraFiltrado == null || this.MetaSeguradoraFiltrado.Count == 0) + { + return; + } + List metaSeguradoraRelatorios = (this.MetaSeguradoraFiltrado.Any((MetaSeguradoraRelatorio x) => x.get_Selecionado()) ? ( + from x in this.MetaSeguradoraFiltrado + where x.get_Selecionado() + select x).ToList() : this.MetaSeguradoraFiltrado.ToList()); + List sinteticos10 = new List(); + Sintetico sintetico10 = new Sintetico(); + sintetico10.set_MetaAtingir(new decimal?(metaSeguradoraRelatorios.Sum((MetaSeguradoraRelatorio x) => x.get_MetaAtingir()))); + sintetico10.set_MetaCumprida(new decimal?(metaSeguradoraRelatorios.Sum((MetaSeguradoraRelatorio p) => p.get_MetaCumprida()))); + sinteticos10.Add(sintetico10); + this.SinteticoRelatorio = new ObservableCollection(sinteticos10); + return; + } + case 15: + { + if (this.MetaVendedorFiltrado == null || this.MetaVendedorFiltrado.Count == 0) + { + return; + } + List metaVendedorRelatorios = (this.MetaVendedorFiltrado.Any((MetaVendedorRelatorio x) => x.get_Selecionado()) ? ( + from x in this.MetaVendedorFiltrado + where x.get_Selecionado() + select x).ToList() : this.MetaVendedorFiltrado.ToList()); + List sinteticos11 = new List(); + Sintetico sintetico11 = new Sintetico(); + sintetico11.set_MetaAtingir(new decimal?(metaVendedorRelatorios.Sum((MetaVendedorRelatorio x) => x.get_MetaAtingir()))); + sintetico11.set_MetaCumprida(new decimal?(metaVendedorRelatorios.Sum((MetaVendedorRelatorio p) => p.get_MetaCumprida()))); + sinteticos11.Add(sintetico11); + this.SinteticoRelatorio = new ObservableCollection(sinteticos11); + return; + } + case 17: + { + if (this.LicenciamentoFiltrado == null || this.LicenciamentoFiltrado.Count == 0) + { + return; + } + List licenciamentos = (this.LicenciamentoFiltrado.Any((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => x.get_Selecionado()) ? ( + from x in this.LicenciamentoFiltrado + where x.get_Selecionado() + select x).ToList() : this.LicenciamentoFiltrado.ToList()); + List sinteticos12 = new List(); + Sintetico sintetico12 = new Sintetico(); + sintetico12.set_TotalClientes(new int?(licenciamentos.Count)); + sinteticos12.Add(sintetico12); + this.SinteticoRelatorio = new ObservableCollection(sinteticos12); + return; + } + case 18: + { + if (this.TarefaFiltrado == null || this.TarefaFiltrado.Count == 0) + { + return; + } + List tarefas = (this.TarefaFiltrado.Any((Gestor.Model.Domain.Relatorios.Tarefa.Tarefa x) => x.get_Selecionado()) ? ( + from x in this.TarefaFiltrado + where x.get_Selecionado() + select x).ToList() : this.TarefaFiltrado.ToList()); + List sinteticos13 = new List(); + Sintetico sintetico13 = new Sintetico(); + sintetico13.set_TotalTarefas(new int?(tarefas.Count)); + sinteticos13.Add(sintetico13); + this.SinteticoRelatorio = new ObservableCollection(sinteticos13); + return; + } + case 19: + { + if (this.NotaFiscalFiltrado == null || this.NotaFiscalFiltrado.Count == 0) + { + return; + } + List notaFiscalRelatorios = (this.NotaFiscalFiltrado.Any((NotaFiscalRelatorio x) => x.get_Selecionado()) ? ( + from x in this.NotaFiscalFiltrado + where x.get_Selecionado() + select x).ToList() : this.NotaFiscalFiltrado.ToList()); + List sinteticos14 = new List(); + Sintetico sintetico14 = new Sintetico(); + sintetico14.set_PremioLiquido(new decimal?(notaFiscalRelatorios.Sum((NotaFiscalRelatorio p) => p.get_Liquido()))); + sintetico14.set_Iss(new decimal?(notaFiscalRelatorios.Sum((NotaFiscalRelatorio p) => p.get_Iss()))); + sintetico14.set_PremioTotal(new decimal?(notaFiscalRelatorios.Sum((NotaFiscalRelatorio x) => x.get_Bruto()))); + sintetico14.set_TotalGeral(new int?(notaFiscalRelatorios.Count)); + sinteticos14.Add(sintetico14); + this.SinteticoRelatorio = new ObservableCollection(sinteticos14); + return; + } + case 29: + { + if (this.ClassificacaoFiltrado == null || this.ClassificacaoFiltrado.Count == 0) + { + return; + } + if (this.ClassificacaoFiltrado.Any((Gestor.Model.Domain.Relatorios.Classificacao.Classificacao x) => x.get_Selecionado())) + { + ( + from x in this.ClassificacaoFiltrado + where x.get_Selecionado() + select x).ToList(); + } + else + { + this.ClassificacaoFiltrado.ToList(); + } + List sinteticos15 = new List(); + Sintetico sintetico15 = new Sintetico(); + sintetico15.set_TotalClientes(new int?(this.ClassificacaoFiltrado.Count())); + sinteticos15.Add(sintetico15); + this.SinteticoRelatorio = new ObservableCollection(sinteticos15); + return; + } + default: + { + return; + } + } + } + + private static Sintetico SintetizarRenovacao(string grupo, List sintetico) + { + Sintetico sintetico1 = new Sintetico(); + sintetico1.set_Agrupamento(grupo); + sintetico1.set_Cancelamentos(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3) + { + return false; + } + return c.get_Documento().get_Situacao() == 3; + }))); + sintetico1.set_Novos(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() != 3 && c.get_Documento().get_Situacao() == 1) + { + return true; + } + if (c.get_Tipo() == 3 || c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 2; + }))); + sintetico1.set_Renovacoes(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3 || c.get_Documento().get_Situacao() != 2) + { + return false; + } + return c.get_Documento().get_Negocio().GetValueOrDefault() == 1; + }))); + sintetico1.set_Apolices(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3 || c.get_Tipo() != 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico1.set_Endossos(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3 || c.get_Tipo() == 0) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 1; + }))); + sintetico1.set_Faturas(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => { + if (c.get_Tipo() == 3) + { + return false; + } + return c.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2; + }))); + sintetico1.set_TotalProspeccao(new int?(sintetico.Count((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao c) => c.get_Tipo() == 3))); + sintetico1.set_TotalGeral(new int?(sintetico.Count)); + return sintetico1; + } + + private void StatusOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(3); + } + + public void SubirParametro(Gestor.Model.Domain.Relatorios.ParametrosRelatorio parametro) + { + if (parametro == null) + { + return; + } + int num = this.ParametrosRelatorioAdicionados.IndexOf(parametro); + if (num == 0) + { + return; + } + this.ParametrosRelatorioAdicionados.Move(num, num - 1); + } + + private void TipoVendedorOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(4); + } + + private static string UltimaMovimentacaoSinistro(Gestor.Model.Domain.Seguros.Sinistro x) + { + x.get_IdUsuarioAlteracao(); + if (x.get_IdUsuarioAlteracao() != 0) + { + return string.Format("{0} / {1}", x.get_DataAlteracao(), Recursos.Usuarios.First((Usuario usuario) => usuario.get_Id() == x.get_IdUsuarioAlteracao()).get_Nome()); + } + x.get_IdUsuarioCriacao(); + if (x.get_IdUsuarioCriacao() == 0) + { + return ""; + } + return string.Format("{0} / {1}", x.get_DataCriacao(), Recursos.Usuarios.First((Usuario usuario) => usuario.get_Id() == x.get_IdUsuarioCriacao()).get_Nome()); + } + + public async Task ValidateTarefa() + { + bool flag; + bool flag1 = false; + await this.ServicoRestriUsuario.BuscarRestricoes(Recursos.Usuario.get_Id()); + switch (this.Relatorio) + { + case 0: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + ObservableCollection clientesAtivosInativosFiltrado = this.ClientesAtivosInativosFiltrado; + if (!clientesAtivosInativosFiltrado.All((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 1: + { + if (this.ClientesAtivosInativosFiltrado != null && this.ClientesAtivosInativosFiltrado.Count != 0) + { + ObservableCollection observableCollection = this.ClientesAtivosInativosFiltrado; + if (!observableCollection.All((Gestor.Model.Domain.Relatorios.ClientesAtivosInativos.ClientesAtivosInativos x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 2: + { + if (this.ProducaoFiltrado != null && this.ProducaoFiltrado.Count != 0) + { + ObservableCollection producaoFiltrado = this.ProducaoFiltrado; + if (!producaoFiltrado.All((Gestor.Model.Domain.Relatorios.Producao.Producao x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 3: + { + if (this.ApolicePendenteFiltrado != null && this.ApolicePendenteFiltrado.Count != 0) + { + ObservableCollection apolicePendenteFiltrado = this.ApolicePendenteFiltrado; + if (!apolicePendenteFiltrado.All((Gestor.Model.Domain.Relatorios.ApolicePendente.ApolicePendente x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 4: + { + if (this.RenovacaoFiltrado != null && this.RenovacaoFiltrado.Count != 0) + { + ObservableCollection renovacaoFiltrado = this.RenovacaoFiltrado; + if (!renovacaoFiltrado.All((Gestor.Model.Domain.Relatorios.Renovacao.Renovacao x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 5: + { + if (this.ComissaoFiltrado != null && this.ComissaoFiltrado.Count != 0) + { + ObservableCollection comissaoFiltrado = this.ComissaoFiltrado; + if (!comissaoFiltrado.All((Gestor.Model.Domain.Relatorios.Comissao.Comissao x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 6: + case 16: + { + if (this.PendenteFiltrado != null && this.PendenteFiltrado.Count != 0) + { + ObservableCollection pendenteFiltrado = this.PendenteFiltrado; + if (!pendenteFiltrado.All((Gestor.Model.Domain.Relatorios.Pendente.Pendente x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 7: + { + flag1 = true; + goto case 26; + } + case 8: + { + if (this.Auditoria != null && this.Auditoria.Count != 0) + { + List auditoria = this.Auditoria; + if (!auditoria.All((Gestor.Model.Domain.Relatorios.Auditoria.Auditoria x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 9: + case 10: + { + if (this.SinistroFiltrado != null && this.SinistroFiltrado.Count != 0) + { + ObservableCollection sinistroFiltrado = this.SinistroFiltrado; + if (!sinistroFiltrado.All((Gestor.Model.Domain.Relatorios.Sinistro.Sinistro x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 11: + case 20: + { + flag1 = true; + goto case 26; + } + case 12: + { + if (this.FaturaPendente != null && this.FaturaPendente.Count != 0) + { + List faturaPendente = this.FaturaPendente; + if (!faturaPendente.All((Gestor.Model.Domain.Relatorios.FaturaPendente.FaturaPendente x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 13: + { + if (this.ExtratosFiltrado != null && this.ExtratosFiltrado.Count != 0) + { + ObservableCollection extratosFiltrado = this.ExtratosFiltrado; + if (!extratosFiltrado.All((ExtratoBaixadoRelatorio x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 14: + { + if (this.MetaSeguradoraFiltrado != null && this.MetaSeguradoraFiltrado.Count != 0) + { + ObservableCollection metaSeguradoraFiltrado = this.MetaSeguradoraFiltrado; + if (!metaSeguradoraFiltrado.All((MetaSeguradoraRelatorio x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 15: + { + if (this.MetaVendedorFiltrado != null && this.MetaVendedorFiltrado.Count != 0) + { + ObservableCollection metaVendedorFiltrado = this.MetaVendedorFiltrado; + if (!metaVendedorFiltrado.All((MetaVendedorRelatorio x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 17: + { + if (this.LicenciamentoFiltrado != null && this.LicenciamentoFiltrado.Count != 0) + { + ObservableCollection licenciamentoFiltrado = this.LicenciamentoFiltrado; + if (!licenciamentoFiltrado.All((Gestor.Model.Domain.Relatorios.Licenciamento.Licenciamento x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + case 18: + case 19: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + { + if (flag1) + { + await base.ShowMessage("NECESSÁRIO SELECIONAR AO MENOS UM ITEM NA LISTA PARA GERAR TAREFAS.", "OK", "", false); + } + flag = flag1; + break; + } + case 27: + { + if (this.PlacaFiltrado != null && this.PlacaFiltrado.Count != 0) + { + ObservableCollection placaFiltrado = this.PlacaFiltrado; + if (!placaFiltrado.All((Gestor.Model.Domain.Relatorios.Placa.Placas x) => !x.get_Selecionado())) + { + goto case 26; + } + } + flag1 = true; + goto case 26; + } + default: + { + goto case 26; + } + } + return flag; + } + + private void VendedorOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (this._alterandoFiltros) + { + return; + } + this.RecheckAllSelected(2); + } + + private void WorkOnRelatorio(Gestor.Model.Common.Relatorio value) + { + bool id; + bool flag; + this.HtmlContent = string.Empty; + this.VisibilityHtml = false; + this.FiltroRelatorioSelecionado = new ObservableCollection(); + this.LimparFiltros(); + this.VisibilityFiltros = Visibility.Visible; + this.VisibilityMaisFiltros = Visibility.Visible; + this.VisibilityGridFiltros = Visibility.Collapsed; + this.VisibilityData = Visibility.Visible; + this.VisibilityOlho = Visibility.Visible; + this.VisibilityEspecial = Visibility.Collapsed; + this.VisibilityPagamento = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Visible; + this.VisibilityEtiqueta = Visibility.Visible; + this.VisibilityEmail = Visibility.Visible; + this.VisibilityAgrupamento = Visibility.Visible; + this.VisibilitySintetizar = Visibility.Visible; + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + id = usuario.get_Id() > (long)0; + } + else + { + id = false; + } + this.VisibilityTarefas = (id ? Visibility.Visible : Visibility.Collapsed); + this.VisibilityAcompanhamento = Visibility.Collapsed; + this.VisibilityReferencia = Visibility.Collapsed; + this.VisibiltyProtocolo = Visibility.Collapsed; + this.VisibilityMeta = Visibility.Collapsed; + this.VisibilityApolice = Visibility.Collapsed; + this.VisibiltySincronizar = (value == 3 || value == 16 ? Visibility.Visible : Visibility.Collapsed); + this.VisibilityComparativo = Visibility.Collapsed; + this.VisibilityCompleto = Visibility.Collapsed; + this.VisibilityNotaFiscalPorSeguradora = Visibility.Collapsed; + this.Agrupamento = 0; + this.NovosNegocios = false; + this.ExtratosEnabled = false; + this.PermitirFiltrosPersonalizados = (value == 11 ? false : value != 7); + this.VisibilityFiltroPersonalizadoButton = Visibility.Visible; + Usuario usuario1 = Recursos.Usuario; + if (usuario1 != null) + { + flag = usuario1.get_Id() > (long)0; + } + else + { + flag = false; + } + this.VisibilityConfigurar = (flag ? Visibility.Visible : Visibility.Collapsed); + this.VisibilityUsuarios = false; + this.VisibilityOrdem = Visibility.Collapsed; + this.VisibilityValor = Visibility.Collapsed; + this.PlanilhaVisibility = Visibility.Collapsed; + this.VisibilityDocumentoAtivo = Visibility.Collapsed; + this.LimparFiltroUsuario(); + this.InicioValor = 0; + this.FimValor = 0; + switch (value) + { + case 0: + { + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityData = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityFiltros = Visibility.Collapsed; + this.VisibilityCompleto = Visibility.Visible; + this.InfoVisibility = Visibility.Collapsed; + return; + } + case 1: + { + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityFiltros = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Collapsed; + this.Info = "O RELATÓRIO DE ANIVERSARIANTE CONSIDERA O DIA E MÊS FILTRADOS E DESCONSIDERA O ANO INFORMADO NA PESQUISA."; + this.InfoVisibility = Visibility.Visible; + return; + } + case 2: + { + this.VisibiltyProtocolo = Visibility.Visible; + FiltroRelatorio filtroRelatorio = new FiltroRelatorio(); + filtroRelatorio.set_Id((long)1); + filtroRelatorio.set_Descricao(EnumHelper.GetDescription(1)); + filtroRelatorio.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio); + FiltroRelatorio filtroRelatorio1 = new FiltroRelatorio(); + filtroRelatorio1.set_Id((long)2); + filtroRelatorio1.set_Descricao(EnumHelper.GetDescription(2)); + filtroRelatorio1.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio1); + this.Referencias = new ObservableCollection(new List() + { + "VIGÊNCIA INICIAL", + "EMISSÃO", + "TRANSMISSÃO PROPOSTA", + "DATA DE CADASTRO" + }); + this.Referencia = this.Referencias.First(); + this.VisibilityReferencia = Visibility.Visible; + this.VisibilityGridFiltros = Visibility.Visible; + this.VisibilityOlho = Visibility.Collapsed; + this.PlanilhaVisibility = Visibility.Visible; + return; + } + case 3: + { + this.VisibiltyProtocolo = Visibility.Visible; + this.VisibiltySincronizar = Visibility.Visible; + this.VisibilityExtratos = Visibility.Collapsed; + return; + } + case 4: + { + this.VisibiltyProtocolo = Visibility.Visible; + this.VisibilityAcompanhamento = Visibility.Visible; + this.PlanilhaVisibility = Visibility.Visible; + return; + } + case 5: + { + this.VisibilityExtratos = Visibility.Collapsed; + return; + } + case 6: + case 9: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.PlanilhaVisibility = Visibility.Collapsed; + return; + } + case 7: + { + this.ParcelasEspeciais[0].set_IsEnable(true); + this.VisibilityEspecial = Visibility.Visible; + this.VisibilityPagamento = Visibility.Visible; + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.SomenteNaoPagos = true; + this.ReciboPagamento = false; + this.VisibilityOrdem = (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 8) ? Visibility.Visible : Visibility.Collapsed); + this.Ordens = new ObservableCollection(new List() + { + "DATA RECEBIMENTO", + "NOME CLIENTE", + "SEGURADORA, RAMO" + }); + this.OrdemSelecionada = this.Ordens.First(); + this.VisibilityHtml = true; + return; + } + case 8: + { + this.ParcelasEspeciais[0].set_IsEnable(false); + this.VisibilityEspecial = Visibility.Visible; + this.VisibilityExtratos = Visibility.Collapsed; + this.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"; + this.InfoVisibility = Visibility.Visible; + FiltroRelatorio filtroRelatorio2 = new FiltroRelatorio(); + filtroRelatorio2.set_Id((long)1); + filtroRelatorio2.set_Descricao(EnumHelper.GetDescription(1)); + filtroRelatorio2.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio2); + FiltroRelatorio filtroRelatorio3 = new FiltroRelatorio(); + filtroRelatorio3.set_Id((long)2); + filtroRelatorio3.set_Descricao(EnumHelper.GetDescription(2)); + filtroRelatorio3.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio3); + FiltroRelatorio filtroRelatorio4 = new FiltroRelatorio(); + filtroRelatorio4.set_Id((long)3); + filtroRelatorio4.set_Descricao(EnumHelper.GetDescription(3)); + filtroRelatorio4.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio4); + FiltroRelatorio filtroRelatorio5 = new FiltroRelatorio(); + filtroRelatorio5.set_Id((long)4); + filtroRelatorio5.set_Descricao(EnumHelper.GetDescription(4)); + filtroRelatorio5.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio5); + FiltroRelatorio filtroRelatorio6 = new FiltroRelatorio(); + filtroRelatorio6.set_Id((long)5); + filtroRelatorio6.set_Descricao(EnumHelper.GetDescription(5)); + filtroRelatorio6.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio6); + FiltroRelatorio filtroRelatorio7 = new FiltroRelatorio(); + filtroRelatorio7.set_Id((long)6); + filtroRelatorio7.set_Descricao(EnumHelper.GetDescription(6)); + filtroRelatorio7.set_Tipo(5); + this.AdicionarFiltro(filtroRelatorio7); + return; + } + case 10: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilityReferencia = Visibility.Visible; + this.Referencias = new ObservableCollection(new List() + { + "DATA SINISTRO", + "DATA LIQUIDAÇÃO", + "DATA RECLAMAÇÃO" + }); + this.Referencia = this.Referencias.First(); + return; + } + case 11: + { + this.VisibilityComparativo = Visibility.Visible; + this.VisibilityEspecial = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Visible; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityReferencia = Visibility.Visible; + this.Referencias = new ObservableCollection(new List() + { + "VIGÊNCIA INICIAL", + "EMISSÃO" + }); + this.Referencia = this.Referencias.First(); + return; + } + case 12: + { + this.Referencias = new ObservableCollection(new List() + { + "VIGÊNCIA", + "VENCIMENTO" + }); + this.Referencia = this.Referencias.First(); + this.VisibilityReferencia = Visibility.Visible; + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + return; + } + case 13: + case 20: + { + this.Referencias = new ObservableCollection(new List() + { + "DATA IMPORTAÇÃO", + "DATA DO EXTRATO", + "DATA DO CRÉDITO" + }); + this.Referencia = this.Referencias.First(); + if (this.Relatorio == 13) + { + this.VisibilityReferencia = Visibility.Visible; + this.VisibilityMaisFiltros = Visibility.Collapsed; + } + this.VisibilityEspecial = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + return; + } + case 14: + case 15: + { + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityData = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Visible; + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilityMeta = Visibility.Visible; + this.Agrupamento = (this.Relatorio == 15 ? 3 : 1); + DateTime date = Funcoes.GetNetworkTime().Date; + this.SelectedMes = date.Month; + this.SelectedAno = date.Year; + return; + } + case 16: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.PlanilhaVisibility = Visibility.Collapsed; + this.VisibilityDocumentoAtivo = Visibility.Visible; + return; + } + case 17: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityData = Visibility.Collapsed; + this.VisibilityValor = Visibility.Visible; + this.InfoVisibility = Visibility.Collapsed; + return; + } + case 18: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + return; + } + case 19: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityNotaFiscalPorSeguradora = Visibility.Visible; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + return; + } + case 21: + case 22: + { + return; + } + case 23: + { + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Collapsed; + return; + } + case 24: + case 25: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Visible; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + return; + } + case 26: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.PlanilhaVisibility = Visibility.Collapsed; + return; + } + case 27: + { + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Collapsed; + return; + } + case 28: + { + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityEtiqueta = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityTarefas = Visibility.Collapsed; + this.VisibilityEmail = Visibility.Collapsed; + this.VisibilityExtratos = Visibility.Collapsed; + this.Referencias = new ObservableCollection(new List() + { + "VIGÊNCIA INICIAL", + "EMISSÃO", + "TRANSMISSÃO PROPOSTA", + "DATA DE CADASTRO" + }); + this.Referencia = this.Referencias.First(); + this.VisibilityReferencia = Visibility.Visible; + this.VisibilityGridFiltros = Visibility.Visible; + this.PlanilhaVisibility = Visibility.Visible; + return; + } + case 29: + { + this.VisibilityExtratos = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityAgrupamento = Visibility.Collapsed; + this.VisibilityData = Visibility.Collapsed; + this.VisibilitySintetizar = Visibility.Collapsed; + this.VisibilityMaisFiltros = Visibility.Collapsed; + this.VisibilityFiltros = Visibility.Collapsed; + this.VisibilityCompleto = Visibility.Collapsed; + this.InfoVisibility = Visibility.Collapsed; + this.Info = ""; + return; + } + default: + { + return; + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3