From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/BI/BISeriesViewModel.cs | 70 + .../ViewModels/BI/NotasViewModel.cs | 311 ++++ .../ViewModels/BI/PainelBiViewModel.cs | 1590 ++++++++++++++++++++ .../ViewModels/BI/ProspeccaoViewModel.cs | 553 +++++++ .../ViewModels/BI/TarefaBIViewModel.cs | 1453 ++++++++++++++++++ 5 files changed, 3977 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/BI/BISeriesViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/BI/NotasViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/BI/PainelBiViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/BI/ProspeccaoViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/BI/TarefaBIViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/BI') diff --git a/Codemerx/Gestor.Application/ViewModels/BI/BISeriesViewModel.cs b/Codemerx/Gestor.Application/ViewModels/BI/BISeriesViewModel.cs new file mode 100644 index 0000000..0d5a5f0 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/BI/BISeriesViewModel.cs @@ -0,0 +1,70 @@ +using Gestor.Application.ViewModels.Generic; +using LiveCharts; +using System; + +namespace Gestor.Application.ViewModels.BI +{ + public class BISeriesViewModel : BaseSegurosViewModel + { + private int _indice; + + private string _titulo; + + private SeriesCollection _serie; + + public int Indice + { + get + { + return this._indice; + } + set + { + if (this._indice == value) + { + return; + } + this._indice = value; + base.OnPropertyChanged("Indice"); + } + } + + public SeriesCollection Serie + { + get + { + return this._serie; + } + set + { + if ((object)this._serie == (object)value) + { + return; + } + this._serie = value; + base.OnPropertyChanged("Serie"); + } + } + + public string Titulo + { + get + { + return this._titulo; + } + set + { + if (this._titulo == value) + { + return; + } + this._titulo = value; + base.OnPropertyChanged("Titulo"); + } + } + + public BISeriesViewModel() + { + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/BI/NotasViewModel.cs b/Codemerx/Gestor.Application/ViewModels/BI/NotasViewModel.cs new file mode 100644 index 0000000..dca2d31 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/BI/NotasViewModel.cs @@ -0,0 +1,311 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.ViewModels.BI +{ + public class NotasViewModel : BaseSegurosViewModel + { + private readonly TarefaServico _servico; + + private bool _enableIncluirNota = true; + + private bool _ocultarUsuarios; + + private ObservableCollection _usuarios; + + private Usuario _selectedUsuario; + + private Gestor.Model.Domain.Ferramentas.Tarefa _tarefa; + + private ObservableCollection _notas; + + private ObservableCollection _notasConcluidas; + + private Gestor.Model.Domain.Ferramentas.Tarefa _selectedNota; + + private bool _ocultarNotasConcluidas = true; + + public bool EnableIncluirNota + { + get + { + return this._enableIncluirNota; + } + set + { + this._enableIncluirNota = value; + base.OnPropertyChanged("EnableIncluirNota"); + } + } + + public ObservableCollection Notas + { + get + { + return this._notas; + } + set + { + this._notas = value; + base.OnPropertyChanged("Notas"); + } + } + + public ObservableCollection NotasConcluidas + { + get + { + return this._notasConcluidas; + } + set + { + this._notasConcluidas = value; + base.OnPropertyChanged("NotasConcluidas"); + } + } + + public bool OcultarNotasConcluidas + { + get + { + return this._ocultarNotasConcluidas; + } + set + { + this._ocultarNotasConcluidas = value; + base.OnPropertyChanged("OcultarNotasConcluidas"); + } + } + + public bool OcultarUsuarios + { + get + { + return this._ocultarUsuarios; + } + set + { + this._ocultarUsuarios = value; + base.OnPropertyChanged("OcultarUsuarios"); + } + } + + public Gestor.Model.Domain.Ferramentas.Tarefa SelectedNota + { + get + { + return this._selectedNota; + } + set + { + this._selectedNota = value; + base.OnPropertyChanged("SelectedNota"); + } + } + + public Usuario SelectedUsuario + { + get + { + return this._selectedUsuario; + } + set + { + this._selectedUsuario = value; + this.Carregar(); + base.OnPropertyChanged("SelectedUsuario"); + } + } + + public Gestor.Model.Domain.Ferramentas.Tarefa Tarefa + { + get + { + return this._tarefa; + } + set + { + this._tarefa = value; + base.OnPropertyChanged("Tarefa"); + } + } + + public ObservableCollection Usuarios + { + get + { + return this._usuarios; + } + set + { + this._usuarios = value; + base.OnPropertyChanged("Usuarios"); + } + } + + public NotasViewModel() + { + bool administrador; + bool id; + this._servico = new TarefaServico(); + this.Usuarios = new ObservableCollection(Recursos.Usuarios.Where((Usuario x) => { + if (Recursos.Usuario.get_IdEmpresa() != (long)1 && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa()) + { + return false; + } + return !x.get_Excluido(); + }).OrderBy((Usuario x) => x.get_Nome()).ToList()); + this.SelectedUsuario = this.Usuarios.FirstOrDefault((Usuario x) => x.get_Id() == Recursos.Usuario.get_Id()); + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + administrador = usuario.get_Administrador(); + } + else + { + administrador = false; + } + this.OcultarUsuarios = administrador; + Usuario usuario1 = Recursos.Usuario; + if (usuario1 != null) + { + id = usuario1.get_Id() > (long)0; + } + else + { + id = false; + } + this.EnableIncluirNota = id; + } + + public async Task AdicionarNota() + { + Gestor.Model.Domain.Ferramentas.Tarefa tarefa; + if (this.Notas != null) + { + ObservableCollection notas = this.Notas; + if (notas.Any((Gestor.Model.Domain.Ferramentas.Tarefa x) => { + if (x.get_Titulo() != "TÍTULO") + { + return false; + } + return x.get_Descricao() == "DESCRIÇÃO"; + })) + { + await base.ShowMessage("PARA ADICIONAR OUTRA NOTA, INSERIR TÍTULO E DESCRIÇÃO DA NOTA JÁ ADICIONADA", "OK", "", false); + tarefa = null; + return; + } + } + Gestor.Model.Domain.Ferramentas.Tarefa tarefa1 = new Gestor.Model.Domain.Ferramentas.Tarefa(); + tarefa1.set_Agendamento(Funcoes.GetNetworkTime()); + tarefa1.set_Titulo("TÍTULO"); + tarefa1.set_Anotacoes("DESCRIÇÃO"); + tarefa1.set_Usuario(this.Usuarios.First((Usuario x) => x.get_Id() == this.SelectedUsuario.get_Id())); + tarefa1.set_UsuarioCadastro(Recursos.Usuario); + tarefa1.set_Entidade(1); + tarefa1.set_Status(0); + tarefa = tarefa1; + tarefa = await this._servico.Salvar(tarefa); + await this.CarregarNotas(); + this.SelectedNota = tarefa; + tarefa = null; + } + + public async void Carregar() + { + await this.CarregarNotas(); + } + + public async Task CarregarNotas() + { + if (this.SelectedUsuario != null) + { + List tarefas = await this._servico.BuscarNotas(this.SelectedUsuario.get_Id()); + List tarefas1 = tarefas; + tarefas1.ForEach((Gestor.Model.Domain.Ferramentas.Tarefa x) => { + if (x.get_Titulo() == "TÍTULO" && x.get_Descricao() == "DESCRIÇÃO") + { + x.set_HabilitarPublica(true); + } + }); + this.Notas = new ObservableCollection(tarefas); + this.NotasConcluidas = new ObservableCollection(await this._servico.BuscarNotasConcluidas(this.SelectedUsuario.get_Id())); + } + } + + public async Task ExcluirNota(Gestor.Model.Domain.Ferramentas.Tarefa nota) + { + await this._servico.Excluir(nota.get_Id()); + } + + public async Task>> Salvar(Gestor.Model.Domain.Ferramentas.Tarefa destino) + { + List> keyValuePairs; + Gestor.Model.Domain.Ferramentas.Tarefa tarefa = destino; + List configuracoes = Recursos.Configuracoes; + tarefa.set_AgendamentoRetroativo(configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 45)); + List> keyValuePairs1 = destino.Validate(); + if (keyValuePairs1.Count <= 0) + { + bool publica = destino.get_Publica(); + await this._servico.Salvar(destino); + if (this._servico.Sucesso) + { + if (publica) + { + long id = destino.get_Usuario().get_Id(); + List usuarios = Recursos.Usuarios; + List tasks = new List(); + foreach (Usuario usuario in usuarios) + { + if (id == usuario.get_Id()) + { + continue; + } + Gestor.Model.Domain.Ferramentas.Tarefa tarefa1 = (Gestor.Model.Domain.Ferramentas.Tarefa)destino.Clone(); + tarefa1.set_Id((long)0); + tarefa1.set_Usuario(usuario); + tasks.Add(this._servico.Salvar(tarefa1)); + } + await Task.WhenAll(tasks); + } + await this.CarregarNotas(); + keyValuePairs = null; + } + else + { + keyValuePairs = null; + } + } + else + { + keyValuePairs = keyValuePairs1; + } + return keyValuePairs; + } + + public async Task SalvarNota(Gestor.Model.Domain.Ferramentas.Tarefa nota) + { + return await this._servico.Salvar(nota); + } + + public void ToggleNotasConcluidas() + { + this.OcultarNotasConcluidas = !this.OcultarNotasConcluidas; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/BI/PainelBiViewModel.cs b/Codemerx/Gestor.Application/ViewModels/BI/PainelBiViewModel.cs new file mode 100644 index 0000000..99695e4 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/BI/PainelBiViewModel.cs @@ -0,0 +1,1590 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.Model; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.BI; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Seguros; +using LiveCharts; +using LiveCharts.Defaults; +using LiveCharts.Definitions.Series; +using LiveCharts.Helpers; +using LiveCharts.Wpf; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; + +namespace Gestor.Application.ViewModels.BI +{ + public class PainelBiViewModel : BaseSegurosViewModel + { + private readonly ClienteServico _clienteServico; + + private readonly ApoliceServico _apoliceServico; + + private readonly ParcelaServico _parcelaServico; + + private Visibility _isVisibleProducao = Visibility.Collapsed; + + private Visibility _isVisibleClientes = Visibility.Collapsed; + + private Visibility _isVisiblePendencia = Visibility.Collapsed; + + private Visibility _isVisibleVencimento = Visibility.Collapsed; + + private DateTime _inicio; + + private DateTime _fim; + + private DateTime _inicioClientes; + + private DateTime _fimClientes; + + private DateTime _inicioVencimento; + + private DateTime _fimVencimento; + + private Grafico _producao; + + private Grafico _fechamento; + + private int _aniversariantes; + + private int _vencimentoCnh; + + private int _vencimentos; + + private int _parcelasPendentes; + + private int _parcelasAVencer; + + private int _cotacoes; + + private List _parcelasPendencia; + + private List _parcelasVencimento; + + private List _documentosVencimento; + + private List _clientesAniversariantes; + + private List _clientesCnh; + + private int _quatidadeProducao; + + private int _endossos; + + private int _faturas; + + private int _apolicesPendentes; + + private int _novosNegocios; + + private int _renovacoes; + + private int _cancelamentos; + + private decimal _producaoTotal; + + private decimal _producaoTotalAnterior; + + private decimal _comissaoTotal; + + private List _documentosProducao; + + private List _documentosPendentes; + + private List _documentosFechamento; + + private Grafico _gerada; + + private Grafico _mediaComissao; + + private Func _yFormatter; + + private Func _xFormatter; + + public int Aniversariantes + { + get + { + return this._aniversariantes; + } + set + { + this._aniversariantes = value; + base.OnPropertyChanged("Aniversariantes"); + } + } + + public int ApolicesPendentes + { + get + { + return this._apolicesPendentes; + } + set + { + this._apolicesPendentes = value; + base.OnPropertyChanged("ApolicesPendentes"); + } + } + + public int Cancelamentos + { + get + { + return this._cancelamentos; + } + set + { + this._cancelamentos = value; + base.OnPropertyChanged("Cancelamentos"); + } + } + + public decimal ComissaoTotal + { + get + { + return this._comissaoTotal; + } + set + { + this._comissaoTotal = value; + base.OnPropertyChanged("ComissaoTotal"); + } + } + + public int Cotacoes + { + get + { + return this._cotacoes; + } + set + { + this._cotacoes = value; + base.OnPropertyChanged("Cotacoes"); + } + } + + public int Endossos + { + get + { + return this._endossos; + } + set + { + this._endossos = value; + base.OnPropertyChanged("Endossos"); + } + } + + public int Faturas + { + get + { + return this._faturas; + } + set + { + this._faturas = value; + base.OnPropertyChanged("Faturas"); + } + } + + public Grafico Fechamento + { + get + { + return this._fechamento; + } + set + { + this._fechamento = value; + base.OnPropertyChanged("Fechamento"); + } + } + + public DateTime Fim + { + get + { + return this._fim; + } + set + { + this._fim = value; + base.OnPropertyChanged("Fim"); + } + } + + public DateTime FimClientes + { + get + { + return this._fimClientes; + } + set + { + this._fimClientes = value; + base.OnPropertyChanged("FimClientes"); + } + } + + public DateTime FimVencimento + { + get + { + return this._fimVencimento; + } + set + { + this._fimVencimento = value; + base.OnPropertyChanged("FimVencimento"); + } + } + + public Grafico Gerada + { + get + { + return this._gerada; + } + set + { + this._gerada = value; + base.OnPropertyChanged("Gerada"); + } + } + + public DateTime Inicio + { + get + { + return this._inicio; + } + set + { + this._inicio = value; + base.OnPropertyChanged("Inicio"); + } + } + + public DateTime InicioClientes + { + get + { + return this._inicioClientes; + } + set + { + this._inicioClientes = value; + base.OnPropertyChanged("InicioClientes"); + } + } + + public DateTime InicioVencimento + { + get + { + return this._inicioVencimento; + } + set + { + this._inicioVencimento = value; + base.OnPropertyChanged("InicioVencimento"); + } + } + + public Visibility IsVisibleClientes + { + get + { + return this._isVisibleClientes; + } + set + { + this._isVisibleClientes = value; + base.OnPropertyChanged("IsVisibleClientes"); + } + } + + public Visibility IsVisiblePendencia + { + get + { + return this._isVisiblePendencia; + } + set + { + this._isVisiblePendencia = value; + base.OnPropertyChanged("IsVisiblePendencia"); + } + } + + public Visibility IsVisibleProducao + { + get + { + return this._isVisibleProducao; + } + set + { + this._isVisibleProducao = value; + base.OnPropertyChanged("IsVisibleProducao"); + } + } + + public Visibility IsVisibleVencimento + { + get + { + return this._isVisibleVencimento; + } + set + { + this._isVisibleVencimento = value; + base.OnPropertyChanged("IsVisibleVencimento"); + } + } + + public Grafico MediaComissao + { + get + { + return this._mediaComissao; + } + set + { + this._mediaComissao = value; + base.OnPropertyChanged("MediaComissao"); + } + } + + public int NovosNegocios + { + get + { + return this._novosNegocios; + } + set + { + this._novosNegocios = value; + base.OnPropertyChanged("NovosNegocios"); + } + } + + public int ParcelasAVencer + { + get + { + return this._parcelasAVencer; + } + set + { + this._parcelasAVencer = value; + base.OnPropertyChanged("ParcelasAVencer"); + } + } + + public int ParcelasPendentes + { + get + { + return this._parcelasPendentes; + } + set + { + this._parcelasPendentes = value; + base.OnPropertyChanged("ParcelasPendentes"); + } + } + + public Grafico Producao + { + get + { + return this._producao; + } + set + { + this._producao = value; + base.OnPropertyChanged("Producao"); + } + } + + public decimal ProducaoTotal + { + get + { + return this._producaoTotal; + } + set + { + this._producaoTotal = value; + base.OnPropertyChanged("ProducaoTotal"); + } + } + + public decimal ProducaoTotalAnterior + { + get + { + return this._producaoTotalAnterior; + } + set + { + this._producaoTotalAnterior = value; + base.OnPropertyChanged("ProducaoTotalAnterior"); + } + } + + public int QuatidadeProducao + { + get + { + return this._quatidadeProducao; + } + set + { + this._quatidadeProducao = value; + base.OnPropertyChanged("QuatidadeProducao"); + } + } + + public int Renovacoes + { + get + { + return this._renovacoes; + } + set + { + this._renovacoes = value; + base.OnPropertyChanged("Renovacoes"); + } + } + + public int VencimentoCnh + { + get + { + return this._vencimentoCnh; + } + set + { + this._vencimentoCnh = value; + base.OnPropertyChanged("VencimentoCnh"); + } + } + + public int Vencimentos + { + get + { + return this._vencimentos; + } + set + { + this._vencimentos = value; + base.OnPropertyChanged("Vencimentos"); + } + } + + public Func XFormatter + { + get + { + return this._xFormatter; + } + set + { + this._xFormatter = value; + base.OnPropertyChanged("XFormatter"); + } + } + + public Func YFormatter + { + get + { + return this._yFormatter; + } + set + { + this._yFormatter = value; + base.OnPropertyChanged("YFormatter"); + } + } + + public PainelBiViewModel() + { + this._isVisibleProducao = Visibility.Collapsed; + this._isVisibleClientes = Visibility.Collapsed; + this._isVisiblePendencia = Visibility.Collapsed; + this._isVisibleVencimento = Visibility.Collapsed; + DateTime date = Funcoes.GetNetworkTime().Date; + this._inicio = date.AddDays(-7); + this._fim = Funcoes.GetNetworkTime().Date; + date = Funcoes.GetNetworkTime().Date; + this._inicioClientes = date.AddDays(-7); + this._fimClientes = Funcoes.GetNetworkTime().Date; + this._inicioVencimento = Funcoes.GetNetworkTime().Date; + date = Funcoes.GetNetworkTime().Date; + this._fimVencimento = date.AddDays(7); + base(); + this._clienteServico = new ClienteServico(); + this._apoliceServico = new ApoliceServico(); + this._parcelaServico = new ParcelaServico(); + this.LoadInicial(); + } + + public async void Detalhar(int tipo) + { + List list; + string str = ""; + string str1 = "APOLICES"; + List strs = new List() + { + "Nome", + "Apolice", + "Endosso", + "Status", + "Negocio", + "VigenciaInicial", + "VigenciaFinal", + "Comissao", + "PremioLiquido", + "PremioTotal", + "Seguradora", + "Ramo" + }; + List strs1 = strs; + switch (tipo) + { + case 1: + { + str = "COMPARATIVO"; + List documentos = this._documentosProducao; + List documentos1 = this._documentosFechamento; + List documentos2 = new List(); + documentos2.AddRange(documentos); + documentos2.AddRange(documentos1); + IOrderedEnumerable vigencia1 = + from x in documentos2 + orderby x.get_Vigencia1() + select x; + list = vigencia1.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 2: + { + str = "NOVOS NEGÓCIOS"; + List documentos3 = this._documentosProducao; + IEnumerable documentos4 = documentos3.Where((Documento x) => { + if (x.get_Tipo() != 0) + { + return false; + } + if (x.get_Situacao() == 1) + { + return true; + } + if (x.get_Situacao() != 2) + { + return false; + } + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + return negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue; + }); + IOrderedEnumerable vigencia11 = + from x in documentos4 + orderby x.get_Vigencia1() + select x; + list = vigencia11.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 3: + { + str = "RENOVAÇÕES"; + List documentos5 = this._documentosProducao; + IEnumerable documentos6 = documentos5.Where((Documento x) => { + if (x.get_Tipo() != 0) + { + return false; + } + if (x.get_Situacao() != 2) + { + return false; + } + if (x.get_NegocioCorretora().GetValueOrDefault() == 1) + { + return true; + } + return x.get_Negocio().GetValueOrDefault() == 1; + }); + IOrderedEnumerable vigencia12 = + from x in documentos6 + orderby x.get_Vigencia1() + select x; + list = vigencia12.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 4: + { + str = "CANCELAMENTOS"; + List documentos7 = this._documentosProducao; + IEnumerable documentos8 = documentos7.Where((Documento x) => { + if (x.get_Situacao() != 3) + { + return false; + } + return x.get_Tipo() == 1; + }); + IOrderedEnumerable vigencia13 = + from x in documentos8 + orderby x.get_Vigencia1() + select x; + list = vigencia13.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 5: + { + str1 = "CLIENTES"; + List strs2 = new List() + { + "Nome", + "DocumentoCliente", + "Dia/Mês", + "Nascimento", + "TipoPessoa", + "Cidade", + "Uf", + "Cep", + "Telefone", + "E-mail", + "Profissão" + }; + strs1 = strs2; + List clientesAtivosInativos = this._clientesAniversariantes; + list = clientesAtivosInativos.Select((ClientesAtivosInativos x) => { + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Nome() ?? ""); + analitico.set_DocumentoCliente(x.get_Documento()); + analitico.set_DiaMes(x.get_Aniversario()); + analitico.set_TipoPessoa((ValidationHelper.OnlyNumber(x.get_Documento()).Length > 11 ? "JURÍDICA" : "FÍSICA")); + analitico.set_Nascimento(x.get_Nascimento()); + analitico.set_VencimentoHabilitacao(x.get_VencimentoCnh()); + analitico.set_Cliente(x); + analitico.set_Cidade(x.get_Cidade()); + analitico.set_Uf(x.get_Estado()); + analitico.set_Cep(x.get_Cep()); + analitico.set_Telefone(x.get_Telefone()); + analitico.set_Email(x.get_Email()); + analitico.set_Profissao(x.get_Profissao()); + return analitico; + }).ToList(); + break; + } + case 6: + { + str1 = "CLIENTES"; + strs1 = new List() + { + "Nome", + "DocumentoCliente", + "Nascimento", + "VencimentoHabilitacao" + }; + List clientesAtivosInativos1 = this._clientesCnh; + list = clientesAtivosInativos1.Select((ClientesAtivosInativos x) => { + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Nome() ?? ""); + analitico.set_DocumentoCliente(x.get_Documento()); + analitico.set_Nascimento(x.get_Nascimento()); + analitico.set_VencimentoHabilitacao(x.get_VencimentoCnh()); + analitico.set_Cliente(x); + return analitico; + }).ToList(); + break; + } + case 7: + { + str = "APÓLICES À VENCER"; + List documentos9 = this._documentosVencimento; + IOrderedEnumerable vigencia14 = + from x in documentos9 + orderby x.get_Vigencia1() + select x; + list = vigencia14.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 8: + { + List strs3 = new List() + { + "Nome", + "Apolice", + "Endosso", + "Seguradora", + "Comissao", + "Vencimento", + "Recebimento", + "Valor", + "ComissaoGerada", + "NumeroParcela", + "Ramo" + }; + strs1 = strs3; + str = "PARCELAS À VENCER"; + str1 = "PARCELAS"; + List parcelas = this._parcelasVencimento; + IOrderedEnumerable vencimento = + from x in parcelas + orderby x.get_Vencimento() + select x; + list = vencimento.Select((Parcela x) => { + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Documento().get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Documento().get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + analitico.set_Seguradora(x.get_Documento().get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + analitico.set_Vencimento(x.get_Vencimento()); + analitico.set_Recebimento(x.get_DataRecebimento()); + analitico.set_Valor(x.get_Valor()); + analitico.set_ValorComissao(x.get_ValorComDesconto()); + analitico.set_NumeroParcela(x.get_NumeroParcela()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x.get_Documento()); + analitico.set_Parcela(x); + return analitico; + }).ToList(); + break; + } + case 9: + { + str = "APÓLICES PENDENTES"; + List documentos10 = this._documentosPendentes; + IEnumerable documentos11 = documentos10.Where((Documento x) => { + if (!string.IsNullOrEmpty(x.get_Apolice())) + { + return false; + } + return x.get_Tipo() != 2; + }); + IOrderedEnumerable vigencia15 = + from x in documentos11 + orderby x.get_Vigencia1() + select x; + list = vigencia15.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 10: + { + List strs4 = new List() + { + "Nome", + "Apolice", + "Endosso", + "Seguradora", + "Comissao", + "Vencimento", + "Valor", + "NumeroParcela", + "Ramo" + }; + strs1 = strs4; + str = "PARCELAS PENDENTES"; + str1 = "PARCELAS"; + List parcelas1 = this._parcelasPendencia; + IOrderedEnumerable vencimento1 = + from x in parcelas1 + orderby x.get_Vencimento() + select x; + list = vencimento1.Select((Parcela x) => { + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Documento().get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Documento().get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + analitico.set_Seguradora(x.get_Documento().get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Documento().get_Controle().get_Ramo().get_Nome()); + analitico.set_Vencimento(x.get_Vencimento()); + analitico.set_Recebimento(x.get_DataRecebimento()); + analitico.set_Valor(x.get_Valor()); + analitico.set_ValorComissao(x.get_ValorComissao()); + analitico.set_NumeroParcela(x.get_NumeroParcela()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Documento().get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Documento().get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x.get_Documento()); + analitico.set_Parcela(x); + return analitico; + }).ToList(); + break; + } + case 11: + { + str = "ENDOSSOS"; + List documentos12 = this._documentosProducao; + IEnumerable documentos13 = + from x in documentos12 + where x.get_Tipo() == 1 + select x; + IOrderedEnumerable vigencia16 = + from x in documentos13 + orderby x.get_Vigencia1() + select x; + list = vigencia16.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 12: + { + str = "FATURAS"; + List documentos14 = this._documentosProducao; + IEnumerable documentos15 = + from x in documentos14 + where x.get_Tipo() == 2 + select x; + IOrderedEnumerable vigencia17 = + from x in documentos15 + orderby x.get_Vigencia1() + select x; + list = vigencia17.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 13: + { + str = "TOTAL DOCUMENTOS"; + List documentos16 = this._documentosProducao; + IEnumerable documentos17 = + from x in documentos16 + where x.get_Tipo() != 2 + select x; + IOrderedEnumerable vigencia18 = + from x in documentos17 + orderby x.get_Vigencia1() + select x; + list = vigencia18.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + case 14: + { + str = "PRODUÇÃO ANTERIOR"; + List documentos18 = this._documentosFechamento; + list = documentos18.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + default: + { + str = "PRODUÇÃO"; + List documentos19 = this._documentosProducao; + list = documentos19.Select((Documento x) => { + object description; + Analitico analitico = new Analitico(); + analitico.set_Nome(x.get_Controle().get_Cliente().get_Nome() ?? ""); + analitico.set_Apolice(x.get_Apolice() ?? ""); + analitico.set_Endosso(x.get_Endosso() ?? ""); + analitico.set_Comissao(x.get_Comissao()); + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + if (!negocioCorretora.HasValue) + { + description = ValidationHelper.GetDescription(x.get_Negocio()); + } + else + { + negocioCorretora = x.get_NegocioCorretora(); + description = (negocioCorretora.HasValue ? ValidationHelper.GetDescription(negocioCorretora.GetValueOrDefault()) : null) ?? ""; + } + analitico.set_Negocio((string)description); + analitico.set_PremioLiquido(x.get_PremioLiquido()); + analitico.set_PremioTotal(x.get_PremioTotal()); + analitico.set_VigenciaFinal(x.get_Vigencia2()); + analitico.set_VigenciaInicial(x.get_Vigencia1()); + analitico.set_Status(ValidationHelper.GetDescription(x.get_Situacao()) ?? ""); + analitico.set_Seguradora(x.get_Controle().get_Seguradora().get_NomeSocial()); + analitico.set_Ramo(x.get_Controle().get_Ramo().get_Nome()); + ClientesAtivosInativos clientesAtivosInativo = new ClientesAtivosInativos(); + clientesAtivosInativo.set_Id(x.get_Controle().get_Cliente().get_Id()); + clientesAtivosInativo.set_Nome(x.get_Controle().get_Cliente().get_Nome()); + analitico.set_Cliente(clientesAtivosInativo); + analitico.set_Documento(x); + return analitico; + }).ToList(); + break; + } + } + if (list.Count != 0) + { + (new HosterWindow(new DialogAnaliticoBi(str, list, str1, strs1), "ANALÍTICO", new double?((double)1260), new double?((double)500), false)).Show(); + } + else + { + await base.ShowMessage("NÃO FOI POSSÍVEL DETALHAR POIS NÃO HÁ DADOS", "OK", "", false); + } + } + + public async Task GerarClientes() + { + long num; + this.IsVisibleClientes = Visibility.Collapsed; + Filtros filtro = new Filtros(); + filtro.set_Inicio(this.InicioClientes); + filtro.set_Fim(this.FimClientes); + num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + filtro.set_IdEmpresa(num); + Filtros filtro1 = filtro; + this._clientesAniversariantes = await this._clienteServico.BuscarAniversariantes(filtro1); + this.Aniversariantes = this._clientesAniversariantes.Count; + this._clientesCnh = await this._clienteServico.BuscarVencimentosCnh(filtro1); + this.VencimentoCnh = this._clientesCnh.Count; + this.IsVisibleClientes = Visibility.Visible; + filtro1 = null; + } + + public async Task GerarPendencia() + { + long num; + this.IsVisiblePendencia = Visibility.Collapsed; + List vendedorUsuarios = await (new VendedorUsuarioServico()).FindByVinculo(Recursos.Usuario); + Filtros filtro = new Filtros(); + filtro.set_Inicio(this.Inicio); + filtro.set_Fim(this.Fim); + num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + filtro.set_IdEmpresa(num); + List vendedorUsuarios1 = vendedorUsuarios; + filtro.set_Vendedores(( + from x in vendedorUsuarios1 + select x.get_Vendedor().get_Id()).ToList()); + List parcelas = await this._parcelaServico.BuscarParcelasPendentes(filtro, false); + PainelBiViewModel list = this; + List parcelas1 = parcelas; + list._parcelasPendencia = ( + from x in parcelas1 + where x.get_Documento().get_Situacao() != 7 + select x).ToList(); + this.ParcelasPendentes = this._parcelasPendencia.Count; + this.IsVisiblePendencia = Visibility.Visible; + } + + public async Task GerarProducao() + { + long num2; + long num3; + this.IsVisibleProducao = Visibility.Collapsed; + PainelBiViewModel painelBiViewModel = this; + Grafico grafico = new Grafico() + { + Series = new SeriesCollection(), + Formatter = (double value) => value.ToString("C0") + }; + painelBiViewModel.Producao = grafico; + PainelBiViewModel painelBiViewModel1 = this; + Grafico grafico1 = new Grafico() + { + Series = new SeriesCollection(), + Formatter = (double value) => value.ToString("C2") + }; + painelBiViewModel1.Gerada = grafico1; + PainelBiViewModel painelBiViewModel2 = this; + Grafico grafico2 = new Grafico() + { + Series = new SeriesCollection(), + Formatter = (double value) => value.ToString("P2") + }; + painelBiViewModel2.MediaComissao = grafico2; + PainelBiViewModel painelBiViewModel3 = this; + Grafico grafico3 = new Grafico() + { + Series = new SeriesCollection(), + Formatter = (double value) => value.ToString("C2") + }; + painelBiViewModel3.Fechamento = grafico3; + List vendedorUsuarios = await (new VendedorUsuarioServico()).FindByVinculo(Recursos.Usuario); + Filtros filtro = new Filtros(); + filtro.set_Inicio(this.Inicio); + filtro.set_Fim(this.Fim); + num2 = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + filtro.set_IdEmpresa(num2); + List vendedorUsuarios1 = vendedorUsuarios; + filtro.set_Vendedores(( + from x in vendedorUsuarios1 + select x.get_Vendedor().get_Id()).ToList()); + Filtros filtro1 = filtro; + Filtros filtro2 = new Filtros(); + DateTime inicio = this.Inicio; + filtro2.set_Inicio(inicio.AddYears(-1)); + inicio = this.Fim; + filtro2.set_Fim(inicio.AddYears(-1)); + num3 = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + filtro2.set_IdEmpresa(num3); + List vendedorUsuarios2 = vendedorUsuarios; + filtro2.set_Vendedores(( + from x in vendedorUsuarios2 + select x.get_Vendedor().get_Id()).ToList()); + Filtros filtro3 = filtro2; + List documentos = await this._apoliceServico.BuscarApolices(filtro1, false, true); + PainelBiViewModel list = this; + List documentos1 = documentos; + list._documentosProducao = ( + from x in documentos1 + where x.get_Situacao() != 7 + select x).ToList(); + this._documentosPendentes = await this._apoliceServico.BuscarApolicesPendentes(filtro1); + List documentos2 = await this._parcelaServico.BuscarFaturas(filtro1, false, true); + List documentos3 = this._documentosProducao; + List documentos4 = documentos2; + documentos3.AddRange( + from x in documentos4 + where x.get_Situacao() != 7 + select x); + PainelBiViewModel painelBiViewModel4 = this; + List documentos5 = this._documentosPendentes; + painelBiViewModel4.ApolicesPendentes = documentos5.Count((Documento x) => { + if (!string.IsNullOrEmpty(x.get_Apolice())) + { + return false; + } + return x.get_Tipo() != 2; + }); + await this.GerarPendencia(); + List documentos6 = await this._apoliceServico.BuscarApolices(filtro3, false, true); + PainelBiViewModel list1 = this; + List documentos7 = documentos6; + list1._documentosFechamento = ( + from x in documentos7 + where x.get_Situacao() != 7 + select x).ToList(); + List documentos8 = await this._parcelaServico.BuscarFaturas(filtro3, false, true); + List documentos9 = this._documentosFechamento; + List documentos10 = documentos8; + documentos9.AddRange( + from x in documentos10 + where x.get_Situacao() != 7 + select x); + this.Cotacoes = await this._apoliceServico.Cotacoes(filtro1); + PainelBiViewModel painelBiViewModel5 = this; + List documentos11 = this._documentosProducao; + painelBiViewModel5.QuatidadeProducao = documentos11.Count((Documento x) => x.get_Tipo() != 2); + PainelBiViewModel painelBiViewModel6 = this; + List documentos12 = this._documentosProducao; + painelBiViewModel6.Faturas = documentos12.Count((Documento x) => x.get_Tipo() == 2); + PainelBiViewModel painelBiViewModel7 = this; + List documentos13 = this._documentosProducao; + painelBiViewModel7.NovosNegocios = documentos13.Count((Documento x) => { + if (x.get_Tipo() != 0) + { + return false; + } + if (x.get_Situacao() == 1) + { + return true; + } + if (x.get_Situacao() != 2) + { + return false; + } + NegocioCorretora? negocioCorretora = x.get_NegocioCorretora(); + return negocioCorretora.GetValueOrDefault() == 0 & negocioCorretora.HasValue; + }); + PainelBiViewModel painelBiViewModel8 = this; + List documentos14 = this._documentosProducao; + painelBiViewModel8.Renovacoes = documentos14.Count((Documento x) => { + if (x.get_Tipo() != 0) + { + return false; + } + if (x.get_Situacao() != 2) + { + return false; + } + if (x.get_NegocioCorretora().GetValueOrDefault() == 1) + { + return true; + } + return x.get_Negocio().GetValueOrDefault() == 1; + }); + PainelBiViewModel painelBiViewModel9 = this; + List documentos15 = this._documentosProducao; + IEnumerable documentos16 = documentos15.Where((Documento x) => { + if (x.get_Situacao() != 3) + { + return false; + } + return x.get_Tipo() == 1; + }); + painelBiViewModel9.Cancelamentos = ( + from x in documentos16 + select x.get_Controle().get_Id()).Distinct().Count(); + PainelBiViewModel painelBiViewModel10 = this; + List documentos17 = this._documentosProducao; + painelBiViewModel10.Endossos = documentos17.Count((Documento x) => x.get_Tipo() == 1); + PainelBiViewModel painelBiViewModel11 = this; + List documentos18 = this._documentosProducao; + painelBiViewModel11.ProducaoTotal = documentos18.Sum((Documento x) => x.get_PremioLiquido()); + PainelBiViewModel painelBiViewModel12 = this; + List documentos19 = this._documentosFechamento; + painelBiViewModel12.ProducaoTotalAnterior = documentos19.Sum((Documento x) => x.get_PremioLiquido()); + PainelBiViewModel painelBiViewModel13 = this; + List documentos20 = this._documentosProducao; + painelBiViewModel13.ComissaoTotal = documentos20.Sum((Documento x) => ((x.get_PremioLiquido() + (x.get_AdicionalComiss() ? x.get_PremioAdicional() : decimal.Zero)) * x.get_Comissao()) * new decimal(1, 0, 0, false, 2)); + List documentos21 = this._documentosProducao; + IEnumerable> nomeSocial = + from x in documentos21 + group x by x.get_Controle().get_Seguradora().get_NomeSocial(); + ( + from x in nomeSocial + orderby x.Sum((Documento p) => p.get_PremioLiquido()) descending + select x).ToList>().ForEach((IGrouping x) => { + ColumnSeries columnSeries = new ColumnSeries(); + columnSeries.set_Title(x.Key); + ChartValues chartValue = new ChartValues(); + chartValue.Add(x.Sum((Documento p) => p.get_PremioLiquido())); + columnSeries.set_Values(chartValue); + columnSeries.set_LabelPoint((ChartPoint chartPoint) => { + IGrouping strs = x; + Func u003cu003e9_13631 = PainelBiViewModel.u003cu003ec.u003cu003e9__136_31; + if (u003cu003e9_13631 == null) + { + u003cu003e9_13631 = (Documento p) => p.get_PremioLiquido(); + PainelBiViewModel.u003cu003ec.u003cu003e9__136_31 = u003cu003e9_13631; + } + return string.Concat("R$ ", strs.Sum(u003cu003e9_13631).ToString("N2")); + }); + columnSeries.set_MaxColumnWidth(double.PositiveInfinity); + this.Producao.Series.Add(columnSeries); + decimal num = x.Sum((Documento p) => ((p.get_PremioLiquido() + (p.get_AdicionalComiss() ? p.get_PremioAdicional() : decimal.Zero)) * p.get_Comissao()) * new decimal(1, 0, 0, false, 2)); + PieSeries pieSeries = new PieSeries(); + pieSeries.set_Title(x.Key); + ChartValues chartValue1 = new ChartValues(); + chartValue1.Add((num > decimal.Zero ? num : num * decimal.MinusOne)); + pieSeries.set_Values(chartValue1); + pieSeries.set_DataLabels(false); + pieSeries.set_LabelPoint((ChartPoint chartPoint) => string.Concat("R$ ", num.ToString("N2"))); + this.Gerada.Series.Add(pieSeries); + decimal num1 = Math.Round(x.Sum((Documento p) => p.get_Comissao()) / x.Count(), 2); + PieSeries pieSeries1 = new PieSeries(); + pieSeries1.set_Title(x.Key); + ChartValues chartValue2 = new ChartValues(); + chartValue2.Add(num1); + pieSeries1.set_Values(chartValue2); + pieSeries1.set_DataLabels(false); + pieSeries1.set_LabelPoint((ChartPoint chartPoint) => string.Format(" Media de Comissão {0}% ", num1)); + this.MediaComissao.Series.Add(pieSeries1); + }); + TimeSpan fim = filtro1.get_Fim() - filtro1.get_Inicio(); + double totalDays = fim.TotalDays; + ChartValues chartValue3 = new ChartValues(); + ChartValues chartValue4 = new ChartValues(); + for (int i = 0; (double)i <= totalDays; i++) + { + inicio = filtro1.get_Inicio(); + DateTime dateTime = inicio.AddDays((double)i); + DateTime dateTime1 = dateTime.AddYears(-1); + IEnumerable vigencia1 = + from s in this._documentosFechamento + where s.get_Vigencia1() == dateTime1 + select s; + decimal num4 = vigencia1.Sum((Documento s) => s.get_PremioLiquido()); + IEnumerable vigencia11 = + from s in this._documentosProducao + where s.get_Vigencia1() == dateTime + select s; + decimal num5 = vigencia11.Sum((Documento s) => s.get_PremioLiquido()); + chartValue3.Add(new DateTimePoint(dateTime, (double)((double)num4))); + chartValue4.Add(new DateTimePoint(dateTime, (double)((double)num5))); + } + LineSeries lineSeries = new LineSeries(); + inicio = filtro3.get_Inicio(); + lineSeries.set_Title(string.Format("{0}", inicio.Year)); + lineSeries.set_Values(chartValue3); + LineSeries lineSeries1 = lineSeries; + LineSeries lineSeries2 = new LineSeries(); + inicio = filtro1.get_Inicio(); + lineSeries2.set_Title(string.Format("{0}", inicio.Year)); + lineSeries2.set_Values(chartValue4); + LineSeries lineSeries3 = lineSeries2; + this.Fechamento.Series.Add(lineSeries1); + this.Fechamento.Series.Add(lineSeries3); + PainelBiViewModel str = this; + str.XFormatter = (double val) => (new DateTime((long)val)).ToString("dd/MM"); + PainelBiViewModel str1 = this; + str1.YFormatter = (double val) => val.ToString("C2"); + this.IsVisibleProducao = Visibility.Visible; + filtro1 = null; + filtro3 = null; + } + + public async Task GerarVencimento() + { + long num; + this.IsVisibleVencimento = Visibility.Collapsed; + List vendedorUsuarios = await (new VendedorUsuarioServico()).FindByVinculo(Recursos.Usuario); + Filtros filtro = new Filtros(); + filtro.set_Inicio(this.InicioVencimento); + filtro.set_Fim(this.FimVencimento); + num = (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa()); + filtro.set_IdEmpresa(num); + List vendedorUsuarios1 = vendedorUsuarios; + filtro.set_Vendedores(( + from x in vendedorUsuarios1 + select x.get_Vendedor().get_Id()).ToList()); + Filtros filtro1 = filtro; + List documentos = await this._apoliceServico.BuscarApolicesVigenciaFinal(filtro1, false); + PainelBiViewModel list = this; + List documentos1 = documentos; + list._documentosVencimento = ( + from x in documentos1 + where x.get_Situacao() != 7 + select x).ToList(); + this.Vencimentos = this._documentosVencimento.Count; + List parcelas = await this._parcelaServico.BuscarParcelas(filtro1, false); + PainelBiViewModel painelBiViewModel = this; + List parcelas1 = parcelas; + painelBiViewModel._parcelasVencimento = ( + from x in parcelas1 + where x.get_Documento().get_Situacao() != 7 + select x).ToList(); + this.ParcelasAVencer = this._parcelasVencimento.Count; + this.IsVisibleVencimento = Visibility.Visible; + filtro1 = null; + } + + private async void LoadInicial() + { + await this.GerarProducao(); + await this.GerarVencimento(); + await this.GerarClientes(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/BI/ProspeccaoViewModel.cs b/Codemerx/Gestor.Application/ViewModels/BI/ProspeccaoViewModel.cs new file mode 100644 index 0000000..4839d95 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/BI/ProspeccaoViewModel.cs @@ -0,0 +1,553 @@ +using ClosedXML.Excel; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Gestor.Application.ViewModels.BI +{ + public class ProspeccaoViewModel : BaseViewModel + { + private readonly ProspeccaoServico _servico; + + private PermissaoUsuario SelectedPermissaoUsuario; + + private ObservableCollection _vendedores; + + private Vendedor _selectedVendedor = new Vendedor(); + + private List _searchStatus = new List() + { + "TODOS", + ValidationHelper.GetDescription((StatusProspeccao)1), + ValidationHelper.GetDescription((StatusProspeccao)5), + ValidationHelper.GetDescription((StatusProspeccao)2), + ValidationHelper.GetDescription((StatusProspeccao)4), + ValidationHelper.GetDescription((StatusProspeccao)3) + }; + + private string _selectedStatusSearch = "AGENDANDO"; + + private StatusProspeccao? _selectedStatus; + + private ObservableCollection _statusProspeccaoPersonalizado; + + private DateTime _inicio = Funcoes.GetNetworkTime().Date; + + private DateTime _fim = Funcoes.GetNetworkTime().Date.AddDays(7); + + private ObservableCollection _prospeccoesFiltradas; + + private Gestor.Model.Domain.Seguros.Prospeccao _selectedProspeccao; + + private ObservableCollection _prospeccao; + + private bool _naoHaDados; + + public DateTime Fim + { + get + { + return this._fim; + } + set + { + this._fim = value; + base.OnPropertyChanged("Fim"); + } + } + + public DateTime Inicio + { + get + { + return this._inicio; + } + set + { + this._inicio = value; + base.OnPropertyChanged("Inicio"); + } + } + + public bool NaoHaDados + { + get + { + return this._naoHaDados; + } + set + { + this._naoHaDados = value; + base.OnPropertyChanged("NaoHaDados"); + } + } + + public ObservableCollection Prospeccao + { + get + { + return this._prospeccao; + } + set + { + this._prospeccao = value; + this.NaoHaDados = (value == null ? true : value.Count == 0); + base.OnPropertyChanged("Prospeccao"); + } + } + + public AutoCompleteFilterPredicate ProspeccaoItemFilter + { + get + { + AutoCompleteFilterPredicate u003cu003e9_530 = ProspeccaoViewModel.u003cu003ec.u003cu003e9__53_0; + if (u003cu003e9_530 == null) + { + u003cu003e9_530 = new AutoCompleteFilterPredicate(ProspeccaoViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { + if (((Gestor.Model.Domain.Seguros.Prospeccao)obj).get_Nome().ToUpper().Contains(searchText.ToUpper()) || ((Gestor.Model.Domain.Seguros.Prospeccao)obj).get_Documento().ToString().ToUpper().Contains(searchText.ToUpper()) || ((Gestor.Model.Domain.Seguros.Prospeccao)obj).get_Telefone1().ToString().ToUpper().Contains(searchText.ToUpper()) || ((Gestor.Model.Domain.Seguros.Prospeccao)obj).get_Telefone2().ToString().ToUpper().Contains(searchText.ToUpper()) || ((Gestor.Model.Domain.Seguros.Prospeccao)obj).get_Email().ToString().ToUpper().Contains(searchText.ToUpper())) + { + return true; + } + return ((Gestor.Model.Domain.Seguros.Prospeccao)obj).get_VigenciaFinal().ToString().ToUpper().Contains(searchText.ToUpper()); + }); + ProspeccaoViewModel.u003cu003ec.u003cu003e9__53_0 = u003cu003e9_530; + } + return u003cu003e9_530; + } + } + + public List Prospeccoes + { + get; + set; + } + + public ObservableCollection ProspeccoesFiltradas + { + get + { + return this._prospeccoesFiltradas; + } + set + { + this._prospeccoesFiltradas = value; + base.OnPropertyChanged("ProspeccoesFiltradas"); + } + } + + public List SearchStatus + { + get + { + return this._searchStatus; + } + set + { + this._searchStatus = value; + this.SelectedStatusSearch = value[1]; + base.OnPropertyChanged("SearchStatus"); + } + } + + public Gestor.Model.Domain.Seguros.Prospeccao SelectedProspeccao + { + get + { + return this._selectedProspeccao; + } + set + { + this._selectedProspeccao = value; + base.OnPropertyChanged("SelectedProspeccao"); + } + } + + public StatusProspeccao? SelectedStatus + { + get + { + return this._selectedStatus; + } + set + { + this._selectedStatus = value; + base.OnPropertyChanged("SelectedStatus"); + } + } + + public string SelectedStatusSearch + { + get + { + return this._selectedStatusSearch; + } + set + { + this._selectedStatusSearch = value; + if (value == "AGENDADO") + { + this.SelectedStatus = new StatusProspeccao?(1); + } + else if (value == "GANHO") + { + this.SelectedStatus = new StatusProspeccao?(2); + } + else if (value == "PERDIDO") + { + this.SelectedStatus = new StatusProspeccao?(3); + } + else if (value == "NÃO TRABALHADO") + { + this.SelectedStatus = new StatusProspeccao?(4); + } + else if (value == "EM ANDAMENTO") + { + this.SelectedStatus = new StatusProspeccao?(5); + } + else + { + this.SelectedStatus = null; + } + base.OnPropertyChanged("SelectedStatusSearch"); + } + } + + public Vendedor SelectedVendedor + { + get + { + return this._selectedVendedor; + } + set + { + this._selectedVendedor = value; + base.OnPropertyChanged("SelectedVendedor"); + } + } + + public ObservableCollection StatusProspeccaoPersonalizado + { + get + { + return this._statusProspeccaoPersonalizado; + } + set + { + this._statusProspeccaoPersonalizado = value; + base.OnPropertyChanged("StatusProspeccaoPersonalizado"); + } + } + + public ObservableCollection Vendedores + { + get + { + return this._vendedores; + } + set + { + this._vendedores = value; + base.OnPropertyChanged("Vendedores"); + } + } + + public ProspeccaoViewModel() + { + this._servico = new ProspeccaoServico(); + this.StatusProspeccaoPersonalizado = new ObservableCollection(( + from x in Recursos.StatusProspeccao + where x.get_Ativo() + select x).ToList()); + this.CarregaVendedores(); + this.SelectedStatusSearch = this.SearchStatus[1]; + this.CarregaProspeccoes(); + } + + public async Task BuscaPermissao(string Tipo) + { + bool flag; + ProspeccaoViewModel prospeccaoViewModel = this; + if (Recursos.Usuario.get_Administrador()) + { + flag = true; + } + else if (Tipo == "Alterar" && prospeccaoViewModel.SelectedPermissaoUsuario != null && !prospeccaoViewModel.SelectedPermissaoUsuario.get_Alterar()) + { + flag = false; + } + else if (!(Tipo == "Excluir") || prospeccaoViewModel.SelectedPermissaoUsuario == null || prospeccaoViewModel.SelectedPermissaoUsuario.get_Excluir()) + { + flag = (!(Tipo == "Incluir") || prospeccaoViewModel.SelectedPermissaoUsuario == null || prospeccaoViewModel.SelectedPermissaoUsuario.get_Incluir() ? true : false); + } + else + { + flag = false; + } + return flag; + } + + public async Task CarregaProspeccao() + { + ProspeccaoViewModel observableCollection = this; + if (observableCollection.ProspeccoesFiltradas != null) + { + observableCollection.ProspeccoesFiltradas = new ObservableCollection(observableCollection.ProspeccoesFiltradas.ToList()); + } + } + + public async void CarregaProspeccoes() + { + await this.CarregarProspeccoes(); + } + + public async Task CarregarPermissao() + { + this.SelectedPermissaoUsuario = await this.ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, 60); + } + + public async Task CarregarProspeccoes() + { + if (this.Inicio <= this.Fim) + { + base.Loading(true); + base.IsVisible = Visibility.Collapsed; + this.Prospeccoes = await this._servico.BuscarProspeccoes(this.SelectedVendedor.get_Id(), this.Inicio, this.Fim, this.SelectedStatus); + ProspeccaoViewModel observableCollection = this; + List prospeccoes = this.Prospeccoes; + observableCollection.ProspeccoesFiltradas = new ObservableCollection( + from x in prospeccoes + orderby x.get_VigenciaFinal() + select x); + this.SelectedProspeccao = this.ProspeccoesFiltradas.FirstOrDefault(); + base.IsVisible = Visibility.Visible; + base.Loading(false); + } + } + + public async Task CarregarVendedores() + { + List vendedorUsuarios = await (new VendedorUsuarioServico()).FindByVinculo(Recursos.Usuario); + List list = ( + from x in vendedorUsuarios + select x.get_Vendedor().get_Id()).ToList(); + List vendedors = new List(); + if (list.Count <= 0 || Recursos.Usuario.get_Administrador()) + { + Vendedor vendedor = new Vendedor(); + vendedor.set_Id((long)0); + vendedor.set_Nome("TODOS OS VENDEDORES"); + vendedors.Add(vendedor); + List vendedors1 = vendedors; + List vendedores = Recursos.Vendedores; + IEnumerable vendedors2 = vendedores.Where((Vendedor x) => { + if (Recursos.Usuario.get_IdEmpresa() != (long)1 && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa()) + { + return false; + } + return x.get_Ativo(); + }); + vendedors1.AddRange(( + from x in vendedors2 + orderby x.get_Nome() + select x).ToList()); + } + else + { + List vendedors3 = vendedors; + IEnumerable vendedors4 = Recursos.Vendedores.Where((Vendedor x) => { + if (Recursos.Usuario.get_IdEmpresa() != (long)1 && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa() || !x.get_Ativo()) + { + return false; + } + return list.Contains(x.get_Id()); + }); + vendedors3.AddRange(( + from x in vendedors4 + orderby x.get_Nome() + select x).ToList()); + } + this.Vendedores = new ObservableCollection(vendedors); + this.SelectedVendedor = this.Vendedores.FirstOrDefault(); + } + + public async void CarregaVendedores() + { + await this.CarregarVendedores(); + } + + public async void Excluir(Gestor.Model.Domain.Seguros.Prospeccao prospeccao) + { + if (await this.BuscaPermissao("Excluir")) + { + if (prospeccao != null) + { + bool tarefa = prospeccao.get_Tarefa() == null; + if (tarefa) + { + tarefa = !await base.ShowMessage("DESEJA EXCLUIR ESSA PROSPECÇÃO?", "SIM", "NÃO", false); + } + bool flag = tarefa; + if (!flag) + { + bool tarefa1 = prospeccao.get_Tarefa() != null; + if (tarefa1) + { + tarefa1 = !await base.ShowMessage(string.Concat("HÁ UMA TAREFA ANEXADA A ESSA PROSPECÇÃO. ESSE PROCEDIMENTO IRÁ EXCLUIR A TAREFA ANEXADA.", Environment.NewLine, "DESEJA REALMENTE PROSSEGUIR?"), "SIM", "NÃO", false); + } + flag = tarefa1; + } + if (!flag) + { + if (await this._servico.Delete(prospeccao)) + { + base.RegistrarAcao(string.Format("EXCLUIU PROSPECÇÃO DO ID: {0}", prospeccao.get_Id()), prospeccao.get_Id(), new TipoTela?(33), string.Format("CLIENTE \"{0}\", ID: {1}", prospeccao.get_Nome(), prospeccao.get_Id())); + await this.CarregarProspeccoes(); + base.ToggleSnackBar("PROSPECÇÃO EXCLUÍDA COM SUCESSO", true); + } + } + } + } + } + + public List Filtrar(string filter) + { + if (this.Prospeccoes == null) + { + return null; + } + this.ProspeccoesFiltradas = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection(this.Prospeccoes) : new ObservableCollection(this.Prospeccoes.Where((Gestor.Model.Domain.Seguros.Prospeccao x) => { + if (ValidationHelper.RemoveDiacritics(ValidationHelper.RemoveDiacritics(x.get_Nome()).ToUpper().Trim()).Contains(filter) || x.get_Documento() != null && ValidationHelper.RemoveDiacritics(x.get_Documento().Trim()).Contains(filter) || x.get_Telefone1() != null && ValidationHelper.RemoveDiacritics(x.get_Telefone1().Trim()).Contains(filter) || x.get_Telefone2() != null && ValidationHelper.RemoveDiacritics(x.get_Telefone2().Trim()).Contains(filter) || x.get_Email() != null && ValidationHelper.RemoveDiacritics(x.get_Email().Trim()).Contains(filter)) + { + return true; + } + if (!x.get_VigenciaFinal().HasValue) + { + return false; + } + return ValidationHelper.RemoveDiacritics(x.get_VigenciaFinal().ToString().Trim()).Contains(filter); + }).OrderBy((Gestor.Model.Domain.Seguros.Prospeccao x) => x.get_VigenciaFinal()))); + return this.ProspeccoesFiltradas.ToList(); + } + + internal async Task> FiltrarProspecao(string value) + { + List prospeccaos = await Task.Run>(() => this.Filtrar(value)); + return prospeccaos; + } + + public async Task GerarExcel() + { + string str; + if (this.ProspeccoesFiltradas != null) + { + List prospeccaoToPrints = new List(); + this.ProspeccoesFiltradas.AsEnumerable().ToList().ForEach((Gestor.Model.Domain.Seguros.Prospeccao x) => { + ProspeccaoToPrint prospeccaoToPrint = new ProspeccaoToPrint(); + prospeccaoToPrint.set_Nome(x.get_Nome()); + prospeccaoToPrint.set_Documento(x.get_Documento() ?? ""); + prospeccaoToPrint.set_Nascimento(x.get_Nascimento()); + prospeccaoToPrint.set_Prefixo1(x.get_Prefixo1() ?? ""); + prospeccaoToPrint.set_Telefone1(x.get_Telefone1() ?? ""); + prospeccaoToPrint.set_Email(x.get_Email() ?? ""); + prospeccaoToPrint.set_VigenciaFinal(x.get_VigenciaFinal()); + prospeccaoToPrint.set_Item(x.get_Item() ?? ""); + prospeccaoToPrint.set_Status(x.get_Status()); + prospeccaoToPrint.set_StatusPersonalizadotoPrint((x.get_StatusPersonalizado() == null ? "" : x.get_StatusPersonalizado().get_Nome())); + prospeccaoToPrint.set_Tipo(x.get_Tipo() ?? ""); + object nome = x.get_Vendedor().get_Nome(); + if (nome == null) + { + nome = null; + } + prospeccaoToPrint.set_Vendedor((string)nome); + prospeccaoToPrint.set_Valor(x.get_Valor()); + prospeccaoToPrints.Add(prospeccaoToPrint); + }); + string tempPath = ""; + str = ""; + tempPath = Path.GetTempPath(); + str = string.Format("{0}{1}.xlsx", tempPath, Guid.NewGuid()); + string str1 = "PROSPECÇÃO"; + await Funcoes.GerarXls(new XLWorkbook(), str1, prospeccaoToPrints, new List()).SaveAs(str); + Process.Start(str); + } + else + { + base.ShowMessage("NÃO HÁ DADOS PARA A IMPRESSÃO EM EXCEL", "OK", "", false); + } + str = null; + } + + public async Task Print() + { + if (this.ProspeccoesFiltradas != null) + { + List prospeccaoToPrints = new List(); + this.ProspeccoesFiltradas.AsEnumerable().ToList().ForEach((Gestor.Model.Domain.Seguros.Prospeccao x) => { + ProspeccaoToPrint prospeccaoToPrint = new ProspeccaoToPrint(); + prospeccaoToPrint.set_Nome(x.get_Nome()); + prospeccaoToPrint.set_Documento(x.get_Documento() ?? ""); + prospeccaoToPrint.set_Nascimento(x.get_Nascimento()); + prospeccaoToPrint.set_Prefixo1(x.get_Prefixo1() ?? ""); + prospeccaoToPrint.set_Telefone1(x.get_Telefone1() ?? ""); + prospeccaoToPrint.set_Email(x.get_Email() ?? ""); + prospeccaoToPrint.set_VigenciaFinal(x.get_VigenciaFinal()); + prospeccaoToPrint.set_Item(x.get_Item() ?? ""); + prospeccaoToPrint.set_Status(x.get_Status()); + prospeccaoToPrint.set_StatusPersonalizadotoPrint((x.get_StatusPersonalizado() == null ? "" : x.get_StatusPersonalizado().get_Nome())); + prospeccaoToPrint.set_Tipo(x.get_Tipo() ?? ""); + object nome = x.get_Vendedor().get_Nome(); + if (nome == null) + { + nome = null; + } + prospeccaoToPrint.set_Vendedor((string)nome); + prospeccaoToPrint.set_Valor(x.get_Valor()); + prospeccaoToPrints.Add(prospeccaoToPrint); + }); + List prospeccaoToPrints1 = prospeccaoToPrints; + prospeccaoToPrints = ( + from x in prospeccaoToPrints1 + orderby x.get_Vendedor() + select x).ToList(); + string str = await Funcoes.GenerateTable(prospeccaoToPrints.ToList(), new List(), false, false, "", null); + if (!string.IsNullOrEmpty(str)) + { + TipoRelatorio tipoRelatorio = new TipoRelatorio(); + tipoRelatorio.set_Inicio(this.Inicio); + tipoRelatorio.set_Fim(this.Fim); + tipoRelatorio.set_Nome(string.Concat("PROSPECÇÕES - ", this.SelectedVendedor.get_Nome())); + str = Funcoes.ExportarHtml(tipoRelatorio, str, "60", "landscaoe", false, ""); + string tempPath = Path.GetTempPath(); + string str1 = string.Format("{0}PROSPECÇÃO_{1:ddMMyyyyhhmmss}.html", tempPath, Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8); + streamWriter.Write(str); + streamWriter.Close(); + Process.Start(str1); + } + } + } + + public async Task>> Salvar(Gestor.Model.Domain.Seguros.Prospeccao prospecao) + { + return await base.SalvarProspeccao(prospecao); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/BI/TarefaBIViewModel.cs b/Codemerx/Gestor.Application/ViewModels/BI/TarefaBIViewModel.cs new file mode 100644 index 0000000..33d1096 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/BI/TarefaBIViewModel.cs @@ -0,0 +1,1453 @@ +using Gestor.Application.Actions; +using Gestor.Application.Drawers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Generic; +using Gestor.Application.Views.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.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.Seguros; +using Gestor.Model.Helper; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace Gestor.Application.ViewModels.BI +{ + public class TarefaBIViewModel : BaseTarefaViewModel + { + private bool _enableAlterarTarefa = true; + + private bool _administrador; + + private DateTime _inicio; + + private DateTime _fim; + + private List _status; + + private string _selectedStatus; + + private Visibility _isVisibleCliente; + + private Visibility _isVisibleApolice; + + private Visibility _isVisibleArquivoDigital; + + private Visibility _isVisibleSinistro; + + private ObservableCollection _usuariosFiltro; + + private ObservableCollection _usuarios; + + private ObservableCollection _tiposTarefa; + + private TipoDeTarefa _selectedTipoTarefa; + + private Usuario _selectedUsuarioFiltro; + + private Usuario _selectedUsuario; + + private DateTime _dataAgendamento; + + private DateTime _horaAgendamento; + + private bool _isAnotacoes; + + private string _descricao; + + private string _historicoInterno; + + private ObservableCollection _tarefas; + + private Tarefa _selectedTarefa; + + private ObservableCollection _telefones; + + private long _cancelTarefa; + + private ObservableCollection _tarefasFiltradas; + + private string _filtro; + + private ObservableCollection _filtroTarefa; + + private GridLength _columnUsuarioPrincipal; + + private GridLength _columnUsuarios; + + public bool Administrador + { + get + { + return this._administrador; + } + set + { + this._administrador = value; + base.OnPropertyChanged("Administrador"); + } + } + + private Gestor.Application.Servicos.Seguros.ClienteServico ClienteServico + { + get; + } + + public GridLength ColumnUsuarioPrincipal + { + get + { + return this._columnUsuarioPrincipal; + } + set + { + this._columnUsuarioPrincipal = value; + base.OnPropertyChanged("ColumnUsuarioPrincipal"); + } + } + + public GridLength ColumnUsuarios + { + get + { + return this._columnUsuarios; + } + set + { + this._columnUsuarios = value; + base.OnPropertyChanged("ColumnUsuarios"); + } + } + + public DateTime DataAgendamento + { + get + { + return this._dataAgendamento; + } + set + { + this._dataAgendamento = value; + if (this.SelectedTarefa != null) + { + this.SelectedTarefa.set_Agendamento(DateTime.Parse(string.Format("{0:d} {1:T}", value, this.SelectedTarefa.get_Agendamento()))); + } + base.OnPropertyChanged("DataAgendamento"); + } + } + + public string Descricao + { + get + { + return this._descricao; + } + set + { + this._descricao = value; + base.OnPropertyChanged("Descricao"); + } + } + + public override bool EnableAlterarTarefa + { + get + { + return this._enableAlterarTarefa; + } + set + { + this._enableAlterarTarefa = this._alterarPermissEnabled & value; + base.OnPropertyChanged("EnableAlterarTarefa"); + } + } + + public string Filtro + { + get + { + return this._filtro; + } + set + { + this._filtro = value; + base.OnPropertyChanged("Filtro"); + } + } + + public ObservableCollection FiltroTarefa + { + get + { + return this._filtroTarefa; + } + set + { + this._filtroTarefa = value; + base.OnPropertyChanged("FiltroTarefa"); + } + } + + public DateTime Fim + { + get + { + return this._fim; + } + set + { + this._fim = value; + this.CarregaTarefas(false); + base.OnPropertyChanged("Fim"); + } + } + + public string HistoricoInterno + { + get + { + return this._historicoInterno; + } + set + { + this._historicoInterno = value; + base.OnPropertyChanged("HistoricoInterno"); + } + } + + public DateTime HoraAgendamento + { + get + { + return this._horaAgendamento; + } + set + { + this._horaAgendamento = value; + if (this.SelectedTarefa != null) + { + this.SelectedTarefa.set_Agendamento(DateTime.Parse(string.Format("{0:d} {1:T}", this.SelectedTarefa.get_Agendamento(), value))); + } + base.OnPropertyChanged("HoraAgendamento"); + } + } + + public DateTime Inicio + { + get + { + return this._inicio; + } + set + { + this._inicio = value; + this.CarregaTarefas(false); + base.OnPropertyChanged("Inicio"); + } + } + + public bool IsAnotacoes + { + get + { + return this._isAnotacoes; + } + set + { + this._isAnotacoes = value; + base.OnPropertyChanged("IsAnotacoes"); + } + } + + public Visibility IsVisibleApolice + { + get + { + return this._isVisibleApolice; + } + set + { + this._isVisibleApolice = value; + base.OnPropertyChanged("IsVisibleApolice"); + } + } + + public Visibility IsVisibleArquivoDigital + { + get + { + return this._isVisibleArquivoDigital; + } + set + { + this._isVisibleArquivoDigital = value; + base.OnPropertyChanged("IsVisibleArquivoDigital"); + } + } + + public Visibility IsVisibleCliente + { + get + { + return this._isVisibleCliente; + } + set + { + this._isVisibleCliente = value; + base.OnPropertyChanged("IsVisibleCliente"); + } + } + + public Visibility IsVisibleSinistro + { + get + { + return this._isVisibleSinistro; + } + set + { + this._isVisibleSinistro = value; + base.OnPropertyChanged("IsVisibleSinistro"); + } + } + + public string SelectedStatus + { + get + { + return this._selectedStatus; + } + set + { + this._selectedStatus = value; + this.CarregaTarefas(false); + base.OnPropertyChanged("SelectedStatus"); + } + } + + public override Tarefa SelectedTarefa + { + get + { + return this._selectedTarefa; + } + set + { + long? nullable; + this._cancelTarefa = (value != null ? value.get_Id() : (long)0); + this.WorkOnSelectedTarefa(value); + if (value != null) + { + nullable = new long?(value.get_Id()); + } + else + { + nullable = null; + } + base.VerificarEnables(nullable); + this._selectedTarefa = value; + base.ValidaPermissaoParaEditarTarefa(); + base.OnPropertyChanged("SelectedTarefa"); + } + } + + public TipoDeTarefa SelectedTipoTarefa + { + get + { + return this._selectedTipoTarefa; + } + set + { + this._selectedTipoTarefa = value; + base.OnPropertyChanged("SelectedTipoTarefa"); + } + } + + public Usuario SelectedUsuario + { + get + { + return this._selectedUsuario; + } + set + { + this._selectedUsuario = value; + base.OnPropertyChanged("SelectedUsuario"); + } + } + + public Usuario SelectedUsuarioFiltro + { + get + { + return this._selectedUsuarioFiltro; + } + set + { + this._selectedUsuarioFiltro = value; + this.CarregaTarefas(false); + base.OnPropertyChanged("SelectedUsuarioFiltro"); + } + } + + private new TarefaServico Servico + { + get; + } + + public List Status + { + get + { + return this._status; + } + set + { + this._status = value; + this.CarregaTarefas(false); + base.OnPropertyChanged("Status"); + } + } + + public ObservableCollection Tarefas + { + get + { + return this._tarefas; + } + set + { + this._tarefas = value; + base.OnPropertyChanged("Tarefas"); + } + } + + public ObservableCollection TarefasFiltradas + { + get + { + return this._tarefasFiltradas; + } + set + { + this._tarefasFiltradas = value; + base.IsVisible = (value.Count > 0 ? Visibility.Visible : Visibility.Collapsed); + base.OnPropertyChanged("TarefasFiltradas"); + } + } + + public ObservableCollection Telefones + { + get + { + return this._telefones; + } + set + { + this._telefones = value; + base.OnPropertyChanged("Telefones"); + } + } + + public ObservableCollection TiposTarefa + { + get + { + return this._tiposTarefa; + } + set + { + this._tiposTarefa = value; + base.OnPropertyChanged("TiposTarefa"); + } + } + + public ObservableCollection Usuarios + { + get + { + return this._usuarios; + } + set + { + this._usuarios = value; + base.OnPropertyChanged("Usuarios"); + } + } + + public ObservableCollection UsuariosFiltro + { + get + { + return this._usuariosFiltro; + } + set + { + this._usuariosFiltro = value; + base.OnPropertyChanged("UsuariosFiltro"); + } + } + + public TarefaBIViewModel() + { + this._enableAlterarTarefa = true; + DateTime date = Funcoes.GetNetworkTime().Date; + this._inicio = date.AddDays(-4); + date = Funcoes.GetNetworkTime().Date; + this._fim = date.AddDays(4); + this._status = new List() + { + "TODAS AS TAREFAS", + Gestor.Common.Validation.ValidationHelper.GetDescription((StatusTarefa)0), + Gestor.Common.Validation.ValidationHelper.GetDescription((StatusTarefa)2) + }; + this._isVisibleCliente = Visibility.Collapsed; + this._isVisibleApolice = Visibility.Collapsed; + this._isVisibleArquivoDigital = Visibility.Collapsed; + this._isVisibleSinistro = Visibility.Collapsed; + this._selectedUsuarioFiltro = new Usuario(); + this._selectedUsuario = new Usuario(); + this._dataAgendamento = Funcoes.GetNetworkTime(); + this._horaAgendamento = Funcoes.GetNetworkTime(); + this._isAnotacoes = true; + this._descricao = ""; + this._historicoInterno = ""; + this._tarefasFiltradas = new ObservableCollection(); + this._filtro = ""; + this._filtroTarefa = new ObservableCollection(); + this._columnUsuarioPrincipal = new GridLength(1, GridUnitType.Star); + this._columnUsuarios = new GridLength(0, GridUnitType.Pixel); + base(); + this.Servico = new TarefaServico(); + this.ClienteServico = new Gestor.Application.Servicos.Seguros.ClienteServico(); + this.Administrador = (Recursos.Usuario.get_Id() == 0 ? true : Recursos.Usuario.get_Administrador()); + this.CarregarUsuarios(); + List list = Recursos.Usuarios.Where((Usuario x) => { + if (!Recursos.Configuracoes.Any((ConfiguracaoSistema c) => c.get_Configuracao() == 36) && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa()) + { + return false; + } + return !x.get_Excluido(); + }).OrderBy((Usuario x) => x.get_Nome()).ToList(); + Usuario usuario = new Usuario(); + usuario.set_Nome("TODOS OS USUÁRIOS"); + usuario.set_Id((long)0); + list.Insert(0, usuario); + this.UsuariosFiltro = new ObservableCollection(list); + this.TiposTarefa = new ObservableCollection(( + from x in Recursos.TiposTarefa + where x.get_Ativo() + select x).ToList()); + this.SelectedUsuarioFiltro = this.UsuariosFiltro.FirstOrDefault((Usuario x) => x.get_Id() == Recursos.Usuario.get_Id()) ?? this.UsuariosFiltro.FirstOrDefault(); + this.SelectedStatus = this.Status[1]; + this.CarregaTarefas(true); + } + + public async void Abrir(TipoTarefa tipo) + { + double? nullable; + long? nullable1; + long? nullable2; + switch (tipo) + { + case 0: + { + long idEntidade = this.SelectedTarefa.get_IdEntidade(); + if (this.SelectedTarefa.get_Entidade() == 4) + { + Sinistro sinistro = await base.CarregaSinistroApolice(this.SelectedTarefa.get_IdEntidade()); + if (sinistro != null) + { + ControleSinistro controleSinistro = sinistro.get_ControleSinistro(); + if (controleSinistro != null) + { + Item item = controleSinistro.get_Item(); + if (item != null) + { + Documento documento = item.get_Documento(); + if (documento != null) + { + nullable2 = new long?(documento.get_Id()); + } + else + { + nullable1 = null; + nullable2 = nullable1; + } + } + else + { + nullable1 = null; + nullable2 = nullable1; + } + } + else + { + nullable1 = null; + nullable2 = nullable1; + } + } + else + { + nullable1 = null; + nullable2 = nullable1; + } + nullable1 = nullable2; + idEntidade = nullable1.GetValueOrDefault(); + } + if (idEntidade != 0) + { + nullable = null; + double? nullable3 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(await base.CarregaApolice(idEntidade), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", this.SelectedTarefa.get_Cliente()), nullable3, nullable, false)).Show(); + goto case 1; + } + else + { + break; + } + } + case 1: + { + break; + } + case 2: + { + nullable = null; + double? nullable4 = nullable; + nullable = null; + (new HosterWindow(new ClienteView(await base.CarregaCliente(this.SelectedTarefa.get_IdCliente()), true, null), string.Concat("CADASTRO DE CLIENTES - ", this.SelectedTarefa.get_Cliente()), nullable4, nullable, false)).Show(); + goto case 1; + } + case 3: + { + nullable = null; + double? nullable5 = nullable; + nullable = null; + (new HosterWindow(new ApoliceView(await base.CarregaApoliceParcela(this.SelectedTarefa.get_IdEntidade()), true, false, 0, (long)0, false), string.Concat("CADASTRO DE APÓLICES - ", this.SelectedTarefa.get_Cliente(), " - ", this.SelectedTarefa.get_Referencia()), nullable5, nullable, false)).Show(); + goto case 1; + } + case 4: + { + Sinistro sinistro1 = await base.CarregaSinistroApolice(this.SelectedTarefa.get_IdEntidade()); + if (sinistro1 != null) + { + nullable = null; + double? nullable6 = nullable; + nullable = null; + (new HosterWindow(new SinistroView(sinistro1.get_ControleSinistro().get_Item(), false), string.Concat("CADASTRO DE SINISTROS - ", this.SelectedTarefa.get_Cliente(), " - ", this.SelectedTarefa.get_Referencia()), nullable6, nullable, false)).Show(); + goto case 1; + } + else + { + await base.ShowMessage("SINISTRO NÃO ENCONTRADO!", "OK", "", false); + break; + } + } + default: + { + goto case 1; + } + } + } + + public async void AbrirArquivoDigital() + { + FiltroArquivoDigital filtroArquivoDigital; + if (this.SelectedTarefa.get_IdEntidade() != 0) + { + filtroArquivoDigital = new FiltroArquivoDigital(); + switch (this.SelectedTarefa.get_Entidade()) + { + case 0: + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 2).get_Consultar()) + { + Documento documento = await base.CarregaApolice(this.SelectedTarefa.get_IdEntidade()); + filtroArquivoDigital.set_Id(documento.get_Id()); + filtroArquivoDigital.set_Tipo(2); + filtroArquivoDigital.set_Parente(documento); + goto case 7; + } + else + { + await base.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)2), "."), "OK", "", false); + break; + } + } + case 1: + case 6: + case 7: + { + base.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + break; + } + case 2: + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 1).get_Consultar()) + { + Cliente cliente = await base.CarregaCliente(this.SelectedTarefa.get_IdCliente()); + filtroArquivoDigital.set_Id(cliente.get_Id()); + filtroArquivoDigital.set_Tipo(1); + filtroArquivoDigital.set_Parente(cliente); + goto case 7; + } + else + { + await base.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)1), "."), "OK", "", false); + break; + } + } + case 3: + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 3).get_Consultar()) + { + Parcela parcela = await base.CarregaParcela(this.SelectedTarefa.get_IdEntidade()); + filtroArquivoDigital.set_Id(parcela.get_Id()); + filtroArquivoDigital.set_Tipo(3); + filtroArquivoDigital.set_Parente(parcela); + filtroArquivoDigital.set_IdApolice(parcela.get_Documento().get_Id()); + goto case 7; + } + else + { + await base.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)3), "."), "OK", "", false); + break; + } + } + case 4: + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 5).get_Consultar()) + { + Sinistro sinistro = await base.CarregaSinistroApolice(this.SelectedTarefa.get_IdEntidade()); + filtroArquivoDigital.set_Id(sinistro.get_Id()); + filtroArquivoDigital.set_Tipo(5); + filtroArquivoDigital.set_Parente(sinistro); + filtroArquivoDigital.set_IdApolice(sinistro.get_ControleSinistro().get_Item().get_Documento().get_Id()); + goto case 7; + } + else + { + await base.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)5), "."), "OK", "", false); + break; + } + } + case 5: + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 11).get_Consultar()) + { + Prospeccao prospeccao = await base.CarregarProspeccao(this.SelectedTarefa.get_IdEntidade()); + filtroArquivoDigital.set_Id(prospeccao.get_Id()); + filtroArquivoDigital.set_Tipo(11); + filtroArquivoDigital.set_Parente(prospeccao); + goto case 7; + } + else + { + await base.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", Gestor.Common.Validation.ValidationHelper.GetDescription((TipoArquivoDigital)11), "."), "OK", "", false); + break; + } + } + case 8: + { + break; + } + default: + { + goto case 7; + } + } + } + filtroArquivoDigital = null; + } + + public void AdcionarFiltro() + { + if (string.IsNullOrEmpty(this.Filtro)) + { + return; + } + if (this.FiltroTarefa == null) + { + this.FiltroTarefa = new ObservableCollection(); + } + this.FiltroTarefa.Add(this.Filtro); + this.Filtro = string.Empty; + this.FiltrarTarefa(); + } + + public async Task AdcionarResponsavel() + { + if (!await base.ValidaPermissaoParaEditarTarefa()) + { + await base.ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EXCLUIR ESSA TAREFA!", "OK", "", false); + } + else if (this.SelectedUsuario != null) + { + ObservableCollection responsaveis = base.Responsaveis; + ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa(); + responsavelTarefa.set_Usuario(this.SelectedUsuario); + responsavelTarefa.set_IdTarefa(this.SelectedTarefa.get_Id()); + responsaveis.Add(responsavelTarefa); + this.Usuarios.Remove(this.SelectedUsuario); + this.SelectedUsuario = null; + } + } + + public async Task AlterarTarefa() + { + GridLength gridLength; + GridLength gridLength1; + if (this.SelectedTarefa != null) + { + if (await base.ValidaPermissaoParaEditarTarefa()) + { + this.CarregarUsuarios(); + base.Alterar(true); + TarefaBIViewModel tarefaBIViewModel = this; + gridLength = (base.EnableFields ? new GridLength(0, GridUnitType.Pixel) : new GridLength(1, GridUnitType.Star)); + tarefaBIViewModel.ColumnUsuarioPrincipal = gridLength; + TarefaBIViewModel tarefaBIViewModel1 = this; + gridLength1 = (base.EnableFields ? new GridLength(1, GridUnitType.Star) : new GridLength(0, GridUnitType.Pixel)); + tarefaBIViewModel1.ColumnUsuarios = gridLength1; + base.ListaUsuariosResponsaveis(); + base.HasResponsaveis = true; + this.SelectedUsuario = null; + base.Responsaveis.ToList().ForEach((ResponsavelTarefa x) => this.Usuarios.Remove(this.Usuarios.FirstOrDefault((Usuario u) => u.get_Id() == x.get_Usuario().get_Id()))); + } + else + { + await base.ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EXCLUIR ESSA TAREFA!", "OK", "", false); + } + } + } + + public async Task Cancelar() + { + if (this._cancelTarefa != 0) + { + long num = this._cancelTarefa; + await this.CarregarTarefas(); + this.SelectedTarefa = this.TarefasFiltradas.FirstOrDefault((Tarefa x) => x.get_Id() == num); + base.Alterar(false); + } + } + + public async Task CarregarTarefas() + { + long id; + bool? nullable; + this.ColumnUsuarioPrincipal = new GridLength(1, GridUnitType.Star); + this.ColumnUsuarios = new GridLength(0, GridUnitType.Pixel); + this.Filtro = string.Empty; + TarefaServico servico = this.Servico; + Usuario selectedUsuarioFiltro = this.SelectedUsuarioFiltro; + if (selectedUsuarioFiltro != null) + { + id = selectedUsuarioFiltro.get_Id(); + } + else + { + id = (long)0; + } + DateTime inicio = this.Inicio; + DateTime fim = this.Fim; + if (this.SelectedStatus == "TODAS AS TAREFAS") + { + nullable = null; + } + else + { + nullable = new bool?(this.SelectedStatus != "PENDENTE"); + } + List tarefas = await servico.BuscarTarefas(id, inicio, fim, nullable); + TarefaBIViewModel observableCollection = this; + List tarefas1 = tarefas; + IEnumerable entidade = + from x in tarefas1 + where x.get_Entidade() != 1 + select x; + observableCollection.Tarefas = new ObservableCollection( + from x in entidade + orderby x.get_Agendamento() + select x); + this.TarefasFiltradas = this.Tarefas; + this.SelectedTarefa = this.TarefasFiltradas.FirstOrDefault(); + if (this.FiltroTarefa.Count > 0) + { + this.FiltrarTarefa(); + } + } + + private void CarregarUsuarios() + { + this.Usuarios = new ObservableCollection(Recursos.Usuarios.Where((Usuario x) => { + if (!Recursos.Configuracoes.Any((ConfiguracaoSistema c) => c.get_Configuracao() == 36) && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa()) + { + return false; + } + return !x.get_Excluido(); + }).OrderBy((Usuario x) => x.get_Nome()).ToList()); + } + + public async void CarregaTarefas(bool permissoes = false) + { + if (permissoes) + { + await base.PermissaoTela(38); + base.Alterar(false); + } + await this.CarregarTarefas(); + } + + public async Task ConcluirTarefa(Tarefa tarefa) + { + Tarefa tarefa1; + if (await base.ValidaPermissaoParaEditarTarefa()) + { + tarefa1 = await this.Servico.Salvar(tarefa); + } + else + { + await base.ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EDITAR ESSA TAREFA!", "OK", "", false); + tarefa1 = null; + } + return tarefa1; + } + + public async Task CriarMalaDireta(TipoTarefa tipo) + { + MalaDireta malaDiretum; + switch (tipo) + { + case 0: + { + Documento documento = await base.CarregaApolice(this.SelectedTarefa.get_IdEntidade()); + MalaDireta malaDiretum1 = new MalaDireta(); + malaDiretum1.set_Cliente(documento.get_Controle().get_Cliente()); + malaDiretum1.set_Apolice(documento); + malaDiretum1.set_Tela(2); + malaDiretum = malaDiretum1; + break; + } + case 1: + case 6: + case 7: + { + malaDiretum = null; + break; + } + case 2: + { + Cliente cliente = await base.CarregaCliente(this.SelectedTarefa.get_IdCliente()); + MalaDireta malaDiretum2 = new MalaDireta(); + malaDiretum2.set_Cliente(cliente); + malaDiretum2.set_Tela(1); + malaDiretum = malaDiretum2; + break; + } + case 3: + { + Documento documento1 = await base.CarregaApoliceParcela(this.SelectedTarefa.get_IdEntidade()); + MalaDireta malaDiretum3 = new MalaDireta(); + malaDiretum3.set_Cliente(documento1.get_Controle().get_Cliente()); + malaDiretum3.set_Apolice(documento1); + malaDiretum3.set_Tela(5); + malaDiretum = malaDiretum3; + break; + } + case 4: + { + Sinistro sinistro = await base.CarregaSinistroApolice(this.SelectedTarefa.get_IdEntidade()); + MalaDireta malaDiretum4 = new MalaDireta(); + malaDiretum4.set_Cliente(sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente()); + malaDiretum4.set_Apolice(sinistro.get_ControleSinistro().get_Item().get_Documento()); + malaDiretum4.set_Sinistro(sinistro); + malaDiretum4.set_Tela(7); + malaDiretum = malaDiretum4; + break; + } + case 5: + { + Prospeccao prospeccao = await base.CarregarProspeccao(this.SelectedTarefa.get_IdEntidade()); + MalaDireta malaDiretum5 = new MalaDireta(); + malaDiretum5.set_Prospeccao(prospeccao); + malaDiretum5.set_Tela(33); + malaDiretum = malaDiretum5; + break; + } + case 8: + { + malaDiretum = null; + break; + } + default: + { + goto case 7; + } + } + return malaDiretum; + } + + public async Task Excluir() + { + bool id; + string titulo; + Tarefa selectedTarefa = this.SelectedTarefa; + if (selectedTarefa != null) + { + id = selectedTarefa.get_Id() == (long)0; + } + else + { + id = false; + } + if (!id) + { + TarefaBIViewModel tarefaBIViewModel = this; + string[] newLine = new string[] { "DESEJA REALMENTE EXCLUIR A TAREFA ", null, null, null, null }; + Tarefa tarefa = this.SelectedTarefa; + if (tarefa != null) + { + titulo = tarefa.get_Titulo(); + } + else + { + titulo = null; + } + newLine[1] = titulo; + newLine[2] = "?"; + newLine[3] = Environment.NewLine; + newLine[4] = "ESSE PROCEDIMENTO É IRREVERSÍVEL"; + if (await tarefaBIViewModel.ShowMessage(string.Concat(newLine), "SIM", "NÃO", false)) + { + if (await this.Servico.Excluir(this.SelectedTarefa.get_Id())) + { + await this.CarregarTarefas(); + Action atualizaTrilhas = Gestor.Application.Actions.Actions.AtualizaTrilhas; + if (atualizaTrilhas != null) + { + atualizaTrilhas(); + } + else + { + } + base.Alterar(false); + } + else + { + base.Alterar(false); + } + } + } + } + + public void ExcluirFiltro(string filtro) + { + this.FiltroTarefa.Remove(filtro); + this.FiltrarTarefa(); + } + + private List Filtrar() + { + List list = this.Tarefas.ToList(); + this.FiltroTarefa.ToList().ForEach((string f) => list = list.Where((Tarefa x) => { + if (Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Titulo()).ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f)) || Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Cliente()).ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f)) || Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_Referencia()).ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f)) || x.get_Agendamento().ToString("d").ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f)) || x.get_Id().ToString().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f)) || x.get_TipoDeTarefa() != null && Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(x.get_TipoDeTarefa().get_Nome()).ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f))) + { + return true; + } + if (x.get_Usuario() == null) + { + return false; + } + return x.get_Usuario().get_Nome().ToUpper().Contains(Gestor.Common.Validation.ValidationHelper.RemoveDiacritics(f)); + }).ToList()); + return list; + } + + public void FiltrarTarefa() + { + this.TarefasFiltradas = new ObservableCollection(this.Filtrar()); + this.SelectedTarefa = this.TarefasFiltradas.FirstOrDefault(); + } + + public string GerarHtml() + { + string nome; + string str = " TAREFA
"; + str = string.Concat(str, "
"); + str = string.Concat(str, "

"); + str = string.Concat(str, "TAREFA


"); + str = string.Concat(str, ""); + int num = 0; + string[] cliente = new string[] { str, ""; + str = string.Concat(cliente); + string[] referencia = new string[] { str, ""; + str = string.Concat(referencia); + string[] titulo = new string[] { str, ""; + str = string.Concat(titulo); + string[] strArrays = new string[] { str, ""; + str = string.Concat(strArrays); + string[] nome1 = new string[] { str, ""; + str = string.Concat(nome1); + string[] description = new string[] { str, ""; + str = string.Concat(description); + string[] strArrays1 = new string[] { str, ""; + str = string.Concat(strArrays1); + str = string.Concat(str, "

CLIENTE: "; + cliente[4] = this.SelectedTarefa.get_Cliente(); + cliente[5] = "

REFERÊNCIA: "; + referencia[4] = this.SelectedTarefa.get_Referencia(); + referencia[5] = "

TÍTULO: "; + titulo[4] = this.SelectedTarefa.get_Titulo(); + titulo[5] = "

AGENDAMENTO: "; + DateTime agendamento = this.SelectedTarefa.get_Agendamento(); + strArrays[4] = agendamento.ToString(); + strArrays[5] = "

RESPONSÁVEL PRINCIPAL: "; + nome1[4] = this.SelectedTarefa.get_Usuario().get_Nome(); + nome1[5] = "

STATUS: "; + description[4] = Gestor.Common.Validation.ValidationHelper.GetDescription(this.SelectedTarefa.get_Status()); + description[5] = "

TIPO DE TAREFA: "; + TipoDeTarefa selectedTipoTarefa = this.SelectedTipoTarefa; + if (selectedTipoTarefa != null) + { + nome = selectedTipoTarefa.get_Nome(); + } + else + { + nome = null; + } + strArrays1[4] = nome; + strArrays1[5] = "

"); + if (base.Responsaveis != null && base.Responsaveis.Count > 0) + { + str = string.Concat(str, "

RESPONSÁVEIS VINCULADOS

"); + str = string.Concat(str, "
"); + str = string.Concat(str, ""); + List strs = new List(); + foreach (ResponsavelTarefa responsavei in base.Responsaveis) + { + strs.Add(responsavei.get_Usuario().get_Nome().Trim().ToUpper()); + } + str = string.Concat(str, ""); + str = string.Concat(str, "

", string.Join(", ", strs), "

"); + str = string.Concat(str, "

"); + } + str = string.Concat(str, "

"); + if (this.SelectedTarefa.get_Descricao() != null) + { + str = string.Concat(str, "

ANOTAÇÕES

"); + str = string.Concat(str, "
"); + str = string.Concat(str, ""); + str = string.Concat(str, ""); + str = string.Concat(str, "

", this.SelectedTarefa.get_Descricao().Replace("", "").Replace("", ""), "

"); + str = string.Concat(str, "

"); + } + str = string.Concat(str, "
"); + return str; + } + + public void Print() + { + string str = this.GerarHtml(); + string tempPath = Path.GetTempPath(); + string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (TipoTela)38, Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8); + streamWriter.Write(str); + streamWriter.Close(); + Process.Start(str1); + } + + public async Task>> Salvar(string titulo) + { + List> keyValuePairs; + Usuario usuario; + string str; + if (this.SelectedTarefa != null) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + List configuracoes = Recursos.Configuracoes; + if (configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 45) && this.SelectedTarefa.get_Status() != 2 && this.SelectedTarefa.get_Agendamento() < networkTime) + { + this.SelectedTarefa.set_Agendamento(networkTime); + } + if (this.SelectedTarefa.get_Status() == 2) + { + this.SelectedTarefa.set_Conclusao(new DateTime?(networkTime)); + } + this.SelectedTarefa.set_Responsaveis(base.Responsaveis.ToList()); + Tarefa selectedTarefa = this.SelectedTarefa; + ResponsavelTarefa responsavelTarefa = base.Responsaveis.FirstOrDefault(); + if (responsavelTarefa != null) + { + usuario = responsavelTarefa.get_Usuario(); + } + else + { + usuario = null; + } + selectedTarefa.set_Usuario(usuario); + Tarefa tarefa = this.SelectedTarefa; + List configuracaoSistemas = Recursos.Configuracoes; + tarefa.set_AgendamentoRetroativo(configuracaoSistemas.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 45)); + List> keyValuePairs1 = this.SelectedTarefa.Validate(); + string text = Funcoes.GetText(this.SelectedTarefa.get_Anotacoes()); + string text1 = Funcoes.GetText(this.SelectedTarefa.get_AnotacoesInternas()); + if (string.IsNullOrEmpty(text) && string.IsNullOrEmpty(text1)) + { + keyValuePairs1.Add(new KeyValuePair("Anotações", "OBRIGATÓRIO")); + } + if (keyValuePairs1.Count <= 0) + { + this.SelectedTarefa.set_Anotacoes(Funcoes.AdicionarLog(this.SelectedTarefa.get_Anotacoes())); + this.SelectedTarefa.set_Descricao(string.Concat(this.SelectedTarefa.get_Anotacoes(), "

", this.Descricao, "

")); + Tarefa selectedTarefa1 = this.SelectedTarefa; + str = (string.IsNullOrWhiteSpace(this.SelectedTarefa.get_AnotacoesInternas()) ? this.HistoricoInterno : string.Concat(this.SelectedTarefa.get_AnotacoesInternas(), "

", this.HistoricoInterno, "

")); + selectedTarefa1.set_DescricaoInterna(str); + this.SelectedTarefa.set_TipoDeTarefa(this.SelectedTipoTarefa); + this.SelectedTarefa.set_Titulo(titulo); + this.SelectedTarefa = await this.Servico.Salvar(this.SelectedTarefa); + if (this.Servico.Sucesso) + { + long id = this.SelectedTarefa.get_Id(); + await this.CarregarTarefas(); + TarefaBIViewModel tarefaBIViewModel = this; + Tarefa tarefa1 = this.TarefasFiltradas.FirstOrDefault((Tarefa x) => x.get_Id() == id); + if (tarefa1 == null) + { + tarefa1 = this.TarefasFiltradas.FirstOrDefault(); + } + tarefaBIViewModel.SelectedTarefa = tarefa1; + keyValuePairs = null; + } + else + { + keyValuePairs = null; + } + } + else + { + keyValuePairs = keyValuePairs1; + } + } + else + { + keyValuePairs = null; + } + return keyValuePairs; + } + + private async void WorkOnSelectedTarefa(Tarefa value) + { + Usuario usuario; + ObservableCollection observableCollection; + TipoTelefone tipoTelefone; + TipoTelefone tipoTelefone1; + bool flag; + ObservableCollection observableCollection1; + if (value != null) + { + TarefaBIViewModel tarefaBIViewModel = this; + if (value.get_Usuario() != null) + { + usuario = this.Usuarios.FirstOrDefault((Usuario x) => x.get_Id() == value.get_Usuario().get_Id()); + } + else + { + usuario = null; + } + tarefaBIViewModel.SelectedUsuario = usuario; + this.DataAgendamento = value.get_Agendamento(); + this.HoraAgendamento = value.get_Agendamento(); + this.Descricao = value.get_Descricao(); + this.HistoricoInterno = value.get_DescricaoInterna(); + TarefaBIViewModel tarefaBIViewModel1 = this; + if (value == null) + { + observableCollection = new ObservableCollection(); + } + else + { + observableCollection = (value.get_Responsaveis() == null ? new ObservableCollection() : new ObservableCollection(value.get_Responsaveis())); + } + tarefaBIViewModel1.Responsaveis = observableCollection; + if (!base.Responsaveis.Any()) + { + TarefaBIViewModel tarefaBIViewModel2 = this; + Tarefa tarefa = value; + if (tarefa != null) + { + flag = tarefa.get_Usuario(); + } + else + { + flag = false; + } + if (!flag) + { + observableCollection1 = new ObservableCollection(); + } + else + { + ResponsavelTarefa[] responsavelTarefaArray = new ResponsavelTarefa[1]; + ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa(); + responsavelTarefa.set_Usuario(value.get_Usuario()); + responsavelTarefaArray[0] = responsavelTarefa; + observableCollection1 = new ObservableCollection(responsavelTarefaArray); + } + tarefaBIViewModel2.Responsaveis = observableCollection1; + } + if (value.get_TipoDeTarefa() != null) + { + if (!this.TiposTarefa.All((TipoDeTarefa x) => x.get_Id() != value.get_Id()) || value.get_TipoDeTarefa().get_Ativo()) + { + TarefaBIViewModel observableCollection2 = this; + ObservableCollection tiposTarefa = this.TiposTarefa; + observableCollection2.TiposTarefa = new ObservableCollection(( + from x in tiposTarefa + where x.get_Ativo() + select x).ToList()); + } + else + { + this.TiposTarefa.Add(value.get_TipoDeTarefa()); + } + } + this.SelectedTipoTarefa = value.get_TipoDeTarefa(); + this.IsVisibleCliente = Visibility.Collapsed; + this.IsVisibleApolice = Visibility.Collapsed; + this.IsVisibleSinistro = Visibility.Collapsed; + this.IsVisibleArquivoDigital = Visibility.Collapsed; + TipoTarefa entidade = value.get_Entidade(); + switch (entidade) + { + case 0: + case 3: + { + this.IsVisibleCliente = Visibility.Visible; + this.IsVisibleApolice = Visibility.Visible; + this.IsVisibleArquivoDigital = Visibility.Visible; + goto case 1; + } + case 1: + { + entidade = value.get_Entidade(); + if (entidade == 5) + { + Prospeccao prospeccao = await (new ProspeccaoServico()).BuscarProspeccao(value.get_IdEntidade()); + this.Telefones = new ObservableCollection(); + if (prospeccao != null && prospeccao.get_Telefone1() != null) + { + ObservableCollection telefones = this.Telefones; + TelefoneBase telefoneBase1 = new TelefoneBase(); + tipoTelefone1 = (prospeccao.get_Telefone1().StartsWith("9") ? 3 : 7); + telefoneBase1.set_Tipo(new TipoTelefone?(tipoTelefone1)); + telefoneBase1.set_Numero(prospeccao.get_Telefone1()); + telefoneBase1.set_Prefixo(prospeccao.get_Prefixo1()); + telefones.Add(telefoneBase1); + } + if (prospeccao != null && prospeccao.get_Telefone2() != null) + { + ObservableCollection telefones1 = this.Telefones; + TelefoneBase telefoneBase2 = new TelefoneBase(); + tipoTelefone = (prospeccao.get_Telefone2().StartsWith("9") ? 3 : 7); + telefoneBase2.set_Tipo(new TipoTelefone?(tipoTelefone)); + telefoneBase2.set_Numero(prospeccao.get_Telefone2()); + telefoneBase2.set_Prefixo(prospeccao.get_Prefixo2()); + telefones1.Add(telefoneBase2); + } + } + else if (entidade == 8) + { + this.Telefones = new ObservableCollection(); + } + else + { + ObservableCollection observableCollection3 = await this.ClienteServico.BuscarTelefonesAsync(value.get_IdCliente()); + TarefaBIViewModel tarefaBIViewModel3 = this; + ObservableCollection observableCollection4 = observableCollection3; + IEnumerable clienteTelefones = + from x in observableCollection4 + where Gestor.Model.Helper.ValidationHelper.ValidacaoTelefone(x.get_Numero()) + select x; + tarefaBIViewModel3.Telefones = new ObservableCollection(clienteTelefones.Select((ClienteTelefone x) => { + TelefoneBase telefoneBase = new TelefoneBase(); + telefoneBase.set_Tipo(x.get_Tipo()); + telefoneBase.set_Id(x.get_Id()); + telefoneBase.set_Numero(x.get_Numero()); + telefoneBase.set_Prefixo(x.get_Prefixo()); + return telefoneBase; + }).ToList()); + } + break; + } + case 2: + { + this.IsVisibleCliente = Visibility.Visible; + this.IsVisibleArquivoDigital = Visibility.Visible; + goto case 1; + } + case 4: + { + this.IsVisibleCliente = Visibility.Visible; + this.IsVisibleApolice = Visibility.Visible; + this.IsVisibleSinistro = Visibility.Visible; + this.IsVisibleArquivoDigital = Visibility.Visible; + goto case 1; + } + default: + { + goto case 1; + } + } + } + else + { + base.Responsaveis = new ObservableCollection(); + } + } + } +} \ No newline at end of file -- cgit v1.2.3