summaryrefslogtreecommitdiff
path: root/Gestor.Application/ViewModels/DashboardViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/ViewModels/DashboardViewModel.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Gestor.Application/ViewModels/DashboardViewModel.cs')
-rw-r--r--Gestor.Application/ViewModels/DashboardViewModel.cs1111
1 files changed, 0 insertions, 1111 deletions
diff --git a/Gestor.Application/ViewModels/DashboardViewModel.cs b/Gestor.Application/ViewModels/DashboardViewModel.cs
deleted file mode 100644
index 8ef9d41..0000000
--- a/Gestor.Application/ViewModels/DashboardViewModel.cs
+++ /dev/null
@@ -1,1111 +0,0 @@
-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.Common.Validation;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Ferramentas;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.Relatorios;
-using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos;
-using Gestor.Model.Domain.Relatorios.Dashboard;
-using Gestor.Model.Domain.Relatorios.Renovacao;
-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;
-
-namespace Gestor.Application.ViewModels
-{
- public class DashboardViewModel : BaseSegurosViewModel
- {
- private readonly TarefaServico _servico;
-
- private readonly ApoliceServico _apoliceServico;
-
- private readonly ClienteServico _clienteServico;
-
- private readonly SinistroServico _sinitrosServico;
-
- private readonly TarefaServico _tarefaServico;
-
- private bool _renovacoesEnabled;
-
- private bool _tarefasEnabled;
-
- private bool _aniversariantesEnabled;
-
- private bool _sinistrosEnabled;
-
- private bool _prospeccoesEnabled;
-
- private bool _notasEnabled;
-
- private bool _publica;
-
- private string _quantidadeRenovacoes = "0";
-
- private string _quantidadeAniversariantes = "0";
-
- private string _quantidadeProspeccao = "0";
-
- private string _quantidadeSinisto = "0";
-
- private string _quantidadeTarefas = "0";
-
- private List<string> _intervalo = new List<string>()
- {
- "HOJE",
- "PRÓXIMOS 3 DIAS",
- "PRÓXIMOS 7 DIAS"
- };
-
- private string _intervaloSelecionado = "HOJE";
-
- private bool _isProspectar;
-
- private ObservableCollection<Tarefa> _notas;
-
- private ObservableCollection<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>();
-
- private string _anotacoes = "";
-
- private ObservableCollection<Prospectar> _prospeccoes;
-
- private ObservableCollection<ClientesAtivosInativos> _aniversariantes;
-
- private ObservableCollection<Sinistro> _sinistros;
-
- private ObservableCollection<Renovacao> _renovacaoFiltrado;
-
- private ObservableCollection<Tarefa> _tarefas = new ObservableCollection<Tarefa>();
-
- private List<Ramo> _ramos;
-
- private Ramo _selectedRamo;
-
- private List<string> _referencias = new List<string>()
- {
- "VENCIMENTO DA ÚLTIMA PARCELA",
- "VIGÊNCIA INICIAL",
- "VIGÊNCIA FINAL"
- };
-
- private string _referencia = "VENCIMENTO DA ÚLTIMA PARCELA";
-
- private int _selectedTile = 1;
-
- private string _labelProspeccao;
-
- private List<string> _filtroCliente = new List<string>()
- {
- "AMBOS",
- "CNPJ",
- "CPF"
- };
-
- private string _filtroClientes;
-
- private Gestor.Model.Domain.Relatorios.Filtros _filtroAniversariantes
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Relatorios.Filtros _filtroProspectar
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Relatorios.Filtros _filtroRenovacao
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Relatorios.Filtros _filtroSinistros
- {
- get;
- set;
- }
-
- private Gestor.Model.Domain.Relatorios.Filtros _filtroTarefas
- {
- get;
- set;
- }
-
- public ObservableCollection<ClientesAtivosInativos> Aniversariantes
- {
- get
- {
- return this._aniversariantes;
- }
- set
- {
- this._aniversariantes = value;
- base.OnPropertyChanged("Aniversariantes");
- }
- }
-
- public bool AniversariantesEnabled
- {
- get
- {
- return this._aniversariantesEnabled;
- }
- set
- {
- this._aniversariantesEnabled = value;
- base.OnPropertyChanged("AniversariantesEnabled");
- }
- }
-
- public new string Anotacoes
- {
- get
- {
- return this._anotacoes;
- }
- set
- {
- this._anotacoes = value;
- base.OnPropertyChanged("Anotacoes");
- }
- }
-
- public List<string> FiltroCliente
- {
- get
- {
- return this._filtroCliente;
- }
- set
- {
- this._filtroCliente = value;
- base.OnPropertyChanged("FiltroCliente");
- }
- }
-
- public string FiltroClientes
- {
- get
- {
- return this._filtroClientes;
- }
- set
- {
- this._filtroClientes = value;
- base.OnPropertyChanged("FiltroClientes");
- }
- }
-
- public Gestor.Model.Domain.Relatorios.Filtros Filtros
- {
- get;
- set;
- }
-
- public List<string> Intervalo
- {
- get
- {
- return this._intervalo;
- }
- set
- {
- this._intervalo = value;
- base.OnPropertyChanged("Intervalo");
- }
- }
-
- public string IntervaloSelecionado
- {
- get
- {
- return this._intervaloSelecionado;
- }
- set
- {
- this._intervaloSelecionado = value;
- base.OnPropertyChanged("IntervaloSelecionado");
- }
- }
-
- public bool IsProspectar
- {
- get
- {
- return this._isProspectar;
- }
- set
- {
- this._isProspectar = value;
- base.OnPropertyChanged("IsProspectar");
- }
- }
-
- public string LabelProspeccao
- {
- get
- {
- return this._labelProspeccao;
- }
- set
- {
- this._labelProspeccao = value;
- base.OnPropertyChanged("LabelProspeccao");
- }
- }
-
- public bool Load { get; set; } = true;
-
- public ObservableCollection<Tarefa> Notas
- {
- get
- {
- return this._notas;
- }
- set
- {
- this._notas = value;
- base.OnPropertyChanged("Notas");
- }
- }
-
- public bool NotasEnabled
- {
- get
- {
- return this._notasEnabled;
- }
- set
- {
- this._notasEnabled = value;
- base.OnPropertyChanged("NotasEnabled");
- }
- }
-
- public List<PermissaoUsuario> Permissoes
- {
- get;
- set;
- }
-
- public ObservableCollection<Prospectar> Prospeccoes
- {
- get
- {
- return this._prospeccoes;
- }
- set
- {
- this._prospeccoes = value;
- base.OnPropertyChanged("Prospeccoes");
- }
- }
-
- public bool ProspeccoesEnabled
- {
- get
- {
- return this._prospeccoesEnabled;
- }
- set
- {
- this._prospeccoesEnabled = value;
- base.OnPropertyChanged("ProspeccoesEnabled");
- }
- }
-
- public bool Publica
- {
- get
- {
- return this._publica;
- }
- set
- {
- this._publica = value;
- base.OnPropertyChanged("Publica");
- }
- }
-
- public string QuantidadeAniversariantes
- {
- get
- {
- return this._quantidadeAniversariantes;
- }
- set
- {
- this._quantidadeAniversariantes = value;
- base.OnPropertyChanged("QuantidadeAniversariantes");
- }
- }
-
- public string QuantidadeProspeccao
- {
- get
- {
- return this._quantidadeProspeccao;
- }
- set
- {
- this._quantidadeProspeccao = value;
- base.OnPropertyChanged("QuantidadeProspeccao");
- }
- }
-
- public string QuantidadeRenovacoes
- {
- get
- {
- return this._quantidadeRenovacoes;
- }
- set
- {
- this._quantidadeRenovacoes = value;
- base.OnPropertyChanged("QuantidadeRenovacoes");
- }
- }
-
- public string QuantidadeSinistro
- {
- get
- {
- return this._quantidadeSinisto;
- }
- set
- {
- this._quantidadeSinisto = value;
- base.OnPropertyChanged("QuantidadeSinistro");
- }
- }
-
- public string QuantidadeTarefas
- {
- get
- {
- return this._quantidadeTarefas;
- }
- set
- {
- this._quantidadeTarefas = value;
- base.OnPropertyChanged("QuantidadeTarefas");
- }
- }
-
- public List<Ramo> Ramos
- {
- get
- {
- return this._ramos;
- }
- set
- {
- this._ramos = value;
- base.OnPropertyChanged("Ramos");
- }
- }
-
- public string Referencia
- {
- get
- {
- return this._referencia;
- }
- set
- {
- this._referencia = value;
- base.OnPropertyChanged("Referencia");
- }
- }
-
- public List<string> Referencias
- {
- get
- {
- return this._referencias;
- }
- set
- {
- this._referencias = value;
- base.OnPropertyChanged("Referencias");
- }
- }
-
- public ObservableCollection<Renovacao> RenovacaoFiltrado
- {
- get
- {
- return this._renovacaoFiltrado;
- }
- set
- {
- this._renovacaoFiltrado = value;
- base.OnPropertyChanged("RenovacaoFiltrado");
- }
- }
-
- public bool RenovacoesEnabled
- {
- get
- {
- return this._renovacoesEnabled;
- }
- set
- {
- this._renovacoesEnabled = value;
- base.OnPropertyChanged("RenovacoesEnabled");
- }
- }
-
- public List<RestricaoUsuario> Restricoes
- {
- get;
- set;
- }
-
- public Ramo SelectedRamo
- {
- get
- {
- return this._selectedRamo;
- }
- set
- {
- this._selectedRamo = value;
- base.OnPropertyChanged("SelectedRamo");
- }
- }
-
- public int SelectedTile
- {
- get
- {
- return this._selectedTile;
- }
- set
- {
- this._selectedTile = value;
- this.IsProspectar = (value == 4 ? true : value == 5);
- }
- }
-
- public ObservableCollection<Sinistro> Sinistros
- {
- get
- {
- return this._sinistros;
- }
- set
- {
- this._sinistros = value;
- base.OnPropertyChanged("Sinistros");
- }
- }
-
- public bool SinistrosEnabled
- {
- get
- {
- return this._sinistrosEnabled;
- }
- set
- {
- this._sinistrosEnabled = value;
- base.OnPropertyChanged("SinistrosEnabled");
- }
- }
-
- public ObservableCollection<Tarefa> Tarefas
- {
- get
- {
- return this._tarefas;
- }
- set
- {
- this._tarefas = value;
- base.OnPropertyChanged("Tarefas");
- }
- }
-
- public bool TarefasEnabled
- {
- get
- {
- return this._tarefasEnabled;
- }
- set
- {
- this._tarefasEnabled = value;
- base.OnPropertyChanged("TarefasEnabled");
- }
- }
-
- public ObservableCollection<ClienteTelefone> Telefones
- {
- get
- {
- return this._telefones;
- }
- set
- {
- this._telefones = value;
- base.OnPropertyChanged("Telefones");
- }
- }
-
- public DashboardViewModel()
- {
- this._servico = new TarefaServico();
- this._apoliceServico = new ApoliceServico();
- this._clienteServico = new ClienteServico();
- this._tarefaServico = new TarefaServico();
- this._sinitrosServico = new SinistroServico();
- }
-
- public async Task BuscarRestricoes()
- {
- this.Restricoes = await this.ServicoRestriUsuario.BuscarRestricoes(Recursos.Usuario.get_Id());
- this.Permissoes = new List<PermissaoUsuario>();
- PermissaoUsuario permissaoUsuario = await this.ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, 38);
- if (permissaoUsuario != null)
- {
- this.Permissoes.Add(permissaoUsuario);
- }
- }
-
- public async Task CarregarAniversariantes(bool force = false)
- {
- List<ClientesAtivosInativos> clientesAtivosInativos;
- this.AniversariantesEnabled = false;
- if (force || !this.CompararFiltros(this._filtroAniversariantes))
- {
- this._filtroAniversariantes = this.Filtros;
- List<VendedorUsuario> vendedorUsuarios = await base.VerificaVinculoVendedor(Recursos.Usuario);
- List<long> nums = new List<long>();
- vendedorUsuarios.ForEach((VendedorUsuario v) => nums.Add(v.get_Vendedor().get_Id()));
- clientesAtivosInativos = (vendedorUsuarios.Count <= 0 ? await this._clienteServico.BuscarAniversariantes(this.Filtros) : await this._clienteServico.BuscarAniversariantesVinculo(this.Filtros, vendedorUsuarios));
- List<ClientesAtivosInativos> clientesAtivosInativos1 = clientesAtivosInativos;
- this.QuantidadeAniversariantes = clientesAtivosInativos1.Count.ToString();
- if (clientesAtivosInativos1.Count != 0)
- {
- this.Aniversariantes = new ObservableCollection<ClientesAtivosInativos>(clientesAtivosInativos1);
- this.AniversariantesEnabled = true;
- }
- else
- {
- this.Aniversariantes = null;
- this.AniversariantesEnabled = true;
- }
- }
- else
- {
- this.AniversariantesEnabled = true;
- }
- }
-
- public async Task CarregarFiltros()
- {
- long num;
- List<long> nums = new List<long>();
- List<VendedorUsuario> vendedorUsuarios = await base.VerificaVinculoVendedor(Recursos.Usuario);
- if (vendedorUsuarios.Count > 0)
- {
- vendedorUsuarios.ForEach((VendedorUsuario x) => nums.Add(x.get_Vendedor().get_Id()));
- }
- DateTime today = DateTime.Today;
- DateTime dateTime = DateTime.Today;
- string intervaloSelecionado = this.IntervaloSelecionado;
- if (intervaloSelecionado == "PRÓXIMOS 3 DIAS")
- {
- dateTime = today.AddDays(3);
- }
- else if (intervaloSelecionado == "PRÓXIMOS 7 DIAS")
- {
- dateTime = today.AddDays(7);
- }
- DashboardViewModel dashboardViewModel = this;
- Gestor.Model.Domain.Relatorios.Filtros filtro = new Gestor.Model.Domain.Relatorios.Filtros();
- filtro.set_Inicio(today);
- filtro.set_Fim(dateTime);
- filtro.set_Vendedores(nums);
- num = (Recursos.Usuario.get_IdEmpresa() > (long)1 ? Recursos.Usuario.get_IdEmpresa() : (long)0);
- filtro.set_IdEmpresa(num);
- filtro.set_Status(new List<long>()
- {
- (long)1,
- (long)2
- });
- dashboardViewModel.Filtros = filtro;
- }
-
- public async Task CarregarNotas()
- {
- this.NotasEnabled = false;
- this.Notas = new ObservableCollection<Tarefa>(await this._servico.BuscarNotas(Recursos.Usuario.get_Id()));
- this.NotasEnabled = true;
- }
-
- public async Task CarregarProspect(DateTime inicio, DateTime fim)
- {
- this.ProspeccoesEnabled = false;
- Gestor.Model.Domain.Relatorios.Filtros filtro = new Gestor.Model.Domain.Relatorios.Filtros();
- filtro.set_Inicio(inicio);
- filtro.set_Fim(fim);
- filtro.set_Ramos(new List<long>()
- {
- this.SelectedRamo.get_Id()
- });
- filtro.set_Vendedores(this.Filtros.get_Vendedores());
- filtro.set_Referencia(this.Referencia);
- filtro.set_FiltrarDocumento(this.FiltroClientes);
- Gestor.Model.Domain.Relatorios.Filtros filtro1 = filtro;
- this.LabelProspeccao = string.Concat("CLIENTES QUE NÃO POSSUEM SEGUROS DO RAMO ", this.SelectedRamo.get_Nome(), " ");
- string referencia = this.Referencia;
- if (referencia == "VIGÊNCIA INICIAL")
- {
- this.LabelProspeccao = string.Concat(this.LabelProspeccao, "E QUE ESTÃO COM UMA APÓLICE INICIANDO NO PERÍODO");
- }
- else if (referencia == "VIGÊNCIA FINAL")
- {
- this.LabelProspeccao = string.Concat(this.LabelProspeccao, "E QUE ESTÃO COM UMA APÓLICE VENCENDO NO PERÍODO");
- }
- else
- {
- this.LabelProspeccao = string.Concat(this.LabelProspeccao, "E QUE ESTÃO COM A ULTIMA PARCELA VENCENDO NO PERÍODO");
- }
- if (this._filtroProspectar == null || !(this._filtroProspectar.get_Inicio() == filtro1.get_Inicio()) || !(this._filtroProspectar.get_Fim() == filtro1.get_Fim()) || this._filtroProspectar.get_Ramos() != filtro1.get_Ramos() || !(this._filtroProspectar.get_Referencia() == filtro1.get_Referencia()))
- {
- this._filtroProspectar = filtro1;
- List<Prospectar> prospectars = await this._clienteServico.BuscarProspect(filtro1);
- this.QuantidadeProspeccao = prospectars.Count.ToString();
- if (prospectars.Count == 0)
- {
- this.LabelProspeccao = "NÃO HÁ CLIENTES PARA PROSPECTAR";
- }
- this.Prospeccoes = new ObservableCollection<Prospectar>(prospectars);
- this.ProspeccoesEnabled = true;
- }
- else
- {
- this.ProspeccoesEnabled = true;
- }
- }
-
- public void CarregarRamos()
- {
- List<long> nums = new List<long>()
- {
- (long)1,
- (long)2,
- (long)6,
- (long)7
- };
- this.Ramos = (
- from x in Recursos.Ramos
- where nums.Contains(x.get_Id())
- select x).ToList<Ramo>();
- this.SelectedRamo = this.Ramos.Find((Ramo x) => x.get_Id() == (long)1);
- }
-
- public async Task CarregarRenovacoes(bool force = false)
- {
- List<Renovacao> list;
- this.RenovacoesEnabled = false;
- if (force || !this.CompararFiltros(this._filtroRenovacao))
- {
- this._filtroRenovacao = this.Filtros;
- List<Documento> documentos = await this._apoliceServico.BuscarApolicesVigenciaFinal(this.Filtros, false);
- IEnumerable<Documento> tipo =
- from x in documentos
- where x.get_Tipo() != 3
- select x;
- list = tipo.Select<Documento, Renovacao>((Documento x) => {
- object nome;
- object obj;
- string str;
- object nome1;
- object obj1;
- string str1;
- object nome2;
- Renovacao renovacao = new Renovacao();
- Cliente cliente = x.get_Controle().get_Cliente();
- if (cliente != null)
- {
- nome = cliente.get_Nome();
- }
- else
- {
- nome = null;
- }
- if (nome == null)
- {
- nome = "";
- }
- renovacao.set_Cliente((string)nome);
- renovacao.set_Apolice(x.get_Apolice() ?? "");
- renovacao.set_PremioLiquido(x.get_PremioLiquido());
- renovacao.set_PremioTotal(x.get_PremioTotal());
- Negocio? negocio = x.get_Negocio();
- renovacao.set_Negocio((string)((negocio.HasValue ? ValidationHelper.GetDescription(negocio.GetValueOrDefault()) : null) ?? ""));
- renovacao.set_VigenciaFinal(x.get_Vigencia2());
- Produto produto = x.get_Controle().get_Produto();
- if (produto != null)
- {
- obj = produto.get_Nome();
- }
- else
- {
- obj = null;
- }
- if (obj == null)
- {
- obj = "";
- }
- renovacao.set_Produto((string)obj);
- renovacao.set_Ramo(x.get_Controle().get_Ramo().get_Nome() ?? "");
- renovacao.set_Seguradora((!string.IsNullOrWhiteSpace(x.get_Controle().get_Seguradora().get_NomeSocial()) ? x.get_Controle().get_Seguradora().get_NomeSocial() : x.get_Controle().get_Seguradora().get_Nome()));
- renovacao.set_Status((x.get_Situacao() == 1 || x.get_Situacao() == 2 ? "NÃO TRABALHADO" : ValidationHelper.GetDescription(x.get_Situacao()) ?? ""));
- Vendedor vendedorPrincipal = x.get_VendedorPrincipal();
- if (vendedorPrincipal != null)
- {
- str = vendedorPrincipal.get_Nome();
- }
- else
- {
- str = null;
- }
- renovacao.set_Vendedor(str);
- Estipulante estipulante1 = x.get_Estipulante1();
- if (estipulante1 != null)
- {
- nome1 = estipulante1.get_Nome();
- }
- else
- {
- nome1 = null;
- }
- if (nome1 == null)
- {
- nome1 = "";
- }
- renovacao.set_Estipulante((string)nome1);
- renovacao.set_TodosVendedores((x.get_Vendedores() == null || x.get_Vendedores().Count == 0 ? "" : string.Join("; ",
- from v in x.get_Vendedores()
- select v.get_Nome())));
- renovacao.set_Tipo(x.get_Tipo());
- renovacao.set_Documento(x);
- renovacao.set_Comissao(x.get_Comissao());
- renovacao.set_Item((x.get_ItensAtivo() != null ? (x.get_ItensAtivo().Count > 1 ? "APÓLICE COLETIVA" : (x.get_ItensAtivo().Count == 1 ? x.get_ItensAtivo().First<Item>().get_Descricao() : "")) : ""));
- renovacao.set_TipoDocumento((x.get_Tipo() == 0 ? "APÓLICE" : (x.get_Tipo() == 1 ? "ENDOSSO" : "")));
- renovacao.set_Sinistro((x.get_Sinistro() ? "SIM" : "NÃO"));
- renovacao.set_DataControle(x.get_DataControle());
- Status status = x.get_Status();
- if (status != null)
- {
- obj1 = status.get_Nome();
- }
- else
- {
- obj1 = null;
- }
- if (obj1 == null)
- {
- obj1 = "";
- }
- renovacao.set_StatusApolice((string)obj1);
- renovacao.set_IdEmpresa(x.get_Controle().get_IdEmpresa());
- Empresa empresa = Recursos.Empresas.FirstOrDefault<Empresa>((Empresa e) => e.get_Id() == x.get_Controle().get_IdEmpresa());
- if (empresa != null)
- {
- str1 = empresa.get_Nome();
- }
- else
- {
- str1 = null;
- }
- renovacao.set_Empresa(str1);
- renovacao.set_QtdSinistro(x.get_ItensAtivo().Sum<Item>((Item s) => s.get_Sinistros().Count));
- Banco banco = x.get_Banco();
- if (banco != null)
- {
- nome2 = banco.get_Nome();
- }
- else
- {
- nome2 = null;
- }
- if (nome2 == null)
- {
- nome2 = "";
- }
- renovacao.set_Banco((string)nome2);
- renovacao.set_Conta(x.get_Conta());
- renovacao.set_Agencia(x.get_Agencia());
- renovacao.set_Pasta(x.get_Pasta());
- renovacao.set_PastaCliente(x.get_Controle().get_Cliente().get_Pasta());
- renovacao.set_Calculos(x.get_Calculos());
- return renovacao;
- }).ToList<Renovacao>();
- List<Prospeccao> prospeccaos = await (new ProspeccaoServico()).BuscarProspeccoes(this.Filtros);
- IEnumerable<Prospeccao> prospeccaos1 =
- from x in prospeccaos
- where x.get_Renovacao()
- select x;
- List<Renovacao> renovacaos = prospeccaos1.Select<Prospeccao, Renovacao>((Prospeccao x) => {
- string nome;
- string str;
- string nome1;
- Renovacao renovacao = new Renovacao();
- renovacao.set_Cliente(x.get_Nome() ?? "");
- renovacao.set_Apolice("PROSPECÇÃO");
- renovacao.set_VigenciaFinal(x.get_VigenciaFinal());
- Renovacao renovacao1 = renovacao;
- StatusProspeccao? status = x.get_Status();
- renovacao1.set_Status((string)((status.HasValue ? ValidationHelper.GetDescription(status.GetValueOrDefault()) : null) ?? ""));
- Renovacao renovacao2 = renovacao;
- Vendedor vendedor = x.get_Vendedor();
- if (vendedor != null)
- {
- nome = vendedor.get_Nome();
- }
- else
- {
- nome = null;
- }
- renovacao2.set_Vendedor(nome);
- Renovacao renovacao3 = renovacao;
- Vendedor vendedor1 = x.get_Vendedor();
- if (vendedor1 != null)
- {
- str = vendedor1.get_Nome();
- }
- else
- {
- str = null;
- }
- renovacao3.set_TodosVendedores(str);
- renovacao.set_Telefone(string.Concat(new string[] { x.get_Prefixo1(), " ", x.get_Telefone1(), " | ", x.get_Prefixo2(), " ", x.get_Telefone2() }));
- renovacao.set_Tipo(3);
- renovacao.set_TipoDocumento("PROSPECÇÃO");
- renovacao.set_Item(x.get_Item());
- Renovacao renovacao4 = renovacao;
- Produto produto = x.get_Produto();
- if (produto != null)
- {
- nome1 = produto.get_Nome();
- }
- else
- {
- nome1 = null;
- }
- renovacao4.set_Produto(nome1);
- renovacao.set_Prospeccao(x);
- return renovacao;
- }).ToList<Renovacao>();
- list.AddRange(renovacaos);
- this.QuantidadeRenovacoes = list.Count.ToString();
- if (list.Count != 0)
- {
- DashboardViewModel observableCollection = this;
- List<Renovacao> renovacaos1 = list;
- observableCollection.RenovacaoFiltrado = new ObservableCollection<Renovacao>((
- from x in renovacaos1
- orderby x.get_VigenciaFinal()
- select x).ToList<Renovacao>());
- this.RenovacoesEnabled = true;
- }
- else
- {
- this.RenovacaoFiltrado = null;
- this.RenovacoesEnabled = true;
- }
- }
- else
- {
- this.RenovacoesEnabled = true;
- }
- list = null;
- }
-
- public async Task CarregarSinistros(bool force = false)
- {
- this.SinistrosEnabled = false;
- if (force || !this.CompararFiltros(this._filtroSinistros))
- {
- this._filtroSinistros = this.Filtros;
- List<Sinistro> sinistros = await this._sinitrosServico.BuscarSinistroPendente(this.Filtros);
- this.QuantidadeSinistro = sinistros.Count.ToString();
- if (sinistros.Count != 0)
- {
- this.Sinistros = new ObservableCollection<Sinistro>(sinistros);
- this.SinistrosEnabled = true;
- }
- else
- {
- this.Sinistros = null;
- this.SinistrosEnabled = true;
- }
- }
- else
- {
- this.SinistrosEnabled = true;
- }
- }
-
- public async Task CarregarSinistros(DateTime inicio, DateTime fim)
- {
- this._filtroSinistros.set_Fim(fim);
- this._filtroSinistros.set_Inicio(inicio);
- List<Sinistro> sinistros = await this._sinitrosServico.BuscarSinistroPendente(this._filtroSinistros);
- this.QuantidadeSinistro = sinistros.Count.ToString();
- this.Sinistros = new ObservableCollection<Sinistro>(sinistros);
- }
-
- public async Task CarregarTarefas(bool force = false)
- {
- this.TarefasEnabled = false;
- if (force || !this.CompararFiltros(this._filtroTarefas))
- {
- this._filtroTarefas = this.Filtros;
- List<Tarefa> tarefas = await this._tarefaServico.BuscarTarefas(Recursos.Usuario.get_Id(), this._filtroTarefas.get_Inicio(), this._filtroTarefas.get_Fim(), new bool?(false));
- this.QuantidadeTarefas = tarefas.Count.ToString();
- if (tarefas.Count != 0)
- {
- DashboardViewModel observableCollection = this;
- List<Tarefa> tarefas1 = tarefas;
- IEnumerable<Tarefa> entidade =
- from x in tarefas1
- where x.get_Entidade() != 1
- select x;
- observableCollection.Tarefas = new ObservableCollection<Tarefa>(
- from x in entidade
- orderby x.get_Agendamento()
- select x);
- this.TarefasEnabled = true;
- }
- else
- {
- this.Tarefas = null;
- this.TarefasEnabled = true;
- }
- }
- else
- {
- this.TarefasEnabled = true;
- }
- }
-
- private bool CompararFiltros(Gestor.Model.Domain.Relatorios.Filtros comparacao)
- {
- if (comparacao == null)
- {
- return false;
- }
- if (this.Filtros == null)
- {
- return false;
- }
- if (comparacao.get_Inicio() != this.Filtros.get_Inicio())
- {
- return false;
- }
- if (comparacao.get_Fim() != this.Filtros.get_Fim())
- {
- return false;
- }
- return true;
- }
-
- public async Task ExcluirNota(Tarefa nota)
- {
- await this._servico.Excluir(nota.get_Id());
- }
-
- public async Task<bool> GerarCsv()
- {
- string str = string.Concat(Path.GetFileNameWithoutExtension(Path.GetTempFileName()), ".csv");
- List<Prospectar> list = this.Prospeccoes.ToList<Prospectar>();
- List<string> strs = new List<string>()
- {
- "Nome",
- "Documento",
- "Telefone"
- };
- string str1 = await Funcoes.GerarCsv<Prospectar>(list, strs);
- File.WriteAllText(str, str1.ToString(), Encoding.UTF8);
- Process.Start(str);
- bool flag = true;
- str = null;
- return flag;
- }
-
- public void LimparProspeccao()
- {
- }
-
- public async Task<List<KeyValuePair<string, string>>> Salvar(Tarefa destino)
- {
- List<KeyValuePair<string, string>> keyValuePairs;
- Tarefa tarefa = destino;
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- tarefa.set_AgendamentoRetroativo(configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 45));
- List<KeyValuePair<string, string>> keyValuePairs1 = destino.Validate();
- if (keyValuePairs1.Count <= 0)
- {
- await this._servico.Salvar(destino);
- if (this._servico.Sucesso)
- {
- if (this.Publica)
- {
- long id = destino.get_Usuario().get_Id();
- List<Usuario> usuarios = Recursos.Usuarios;
- List<Task> tasks = new List<Task>();
- foreach (Usuario usuario in usuarios)
- {
- if (id == usuario.get_Id())
- {
- continue;
- }
- Tarefa tarefa1 = (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<Tarefa> SalvarNota(Tarefa nota)
- {
- return await this._servico.Salvar(nota);
- }
- }
-} \ No newline at end of file