From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../AnaliticoViewModel.cs | 172 ++++ .../Gestor.Application.ViewModels/Arquivo.cs | 8 + .../CoberturaViewModel.cs | 179 ++++ .../DashboardViewModel.cs | 925 +++++++++++++++++ .../ImportViewModel.cs | 103 ++ .../LoginImageModel.cs | 8 + .../LoginViewModel.cs | 866 ++++++++++++++++ .../Gestor.Application.ViewModels/MainViewModel.cs | 1061 ++++++++++++++++++++ .../MenuBIViewModel.cs | 7 + .../MenuFerramentasViewModel.cs | 79 ++ .../MenuItemViewModel.cs | 798 +++++++++++++++ .../TrilhaViewModel.cs | 259 +++++ .../TutorialViewModel.cs | 480 +++++++++ 13 files changed, 4945 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels/AnaliticoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/Arquivo.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/DashboardViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/LoginImageModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/LoginViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/MainViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/MenuBIViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/MenuFerramentasViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/MenuItemViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/TrilhaViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels/TutorialViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels') diff --git a/Decompiler/Gestor.Application.ViewModels/AnaliticoViewModel.cs b/Decompiler/Gestor.Application.ViewModels/AnaliticoViewModel.cs new file mode 100644 index 0000000..da3773b --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/AnaliticoViewModel.cs @@ -0,0 +1,172 @@ +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows.Data; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.BI; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; + +namespace Gestor.Application.ViewModels; + +internal class AnaliticoViewModel : BaseSegurosViewModel +{ + private string _head; + + public TipoTela Tela { get; set; } = (TipoTela)1; + + + public string Tipo { get; set; } + + public string Head + { + get + { + return _head; + } + set + { + _head = value; + OnPropertyChanged("Head"); + } + } + + public AnaliticoViewModel(string tipo) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + Tipo = tipo; + string tipo2 = Tipo; + if (!(tipo2 == "PARCELAS")) + { + if (!(tipo2 == "APOLICES")) + { + Tela = (TipoTela)1; + } + else + { + Tela = (TipoTela)2; + } + } + else + { + Tela = (TipoTela)5; + } + } + + public async Task Save(List tarefas) + { + await new TarefaServico().Salvar(tarefas); + } + + public async Task Salvar(Trilha destino) + { + List fases2 = destino.Fases; + TarefaServico servico = new TarefaServico(); + Trilha trilha = await servico.Salvar(destino); + if (!servico.Sucesso) + { + return null; + } + fases2.ForEach(delegate(Fase x) + { + x.Trilha = trilha; + }); + fases2 = await servico.Salvar(fases2); + if (!servico.Sucesso) + { + return null; + } + trilha.Fases = fases2; + return trilha; + } + + public async Task> Validar(List analitico, Trilha trilha) + { + TarefaServico tarefaServico = new TarefaServico(); + List ids; + switch (Tipo) + { + case "CLIENTES": + ids = analitico.Select((Analitico x) => x.Cliente.Id).ToList(); + break; + default: + ids = analitico.Select((Analitico x) => ((DomainBase)x.Documento).Id).ToList(); + break; + case "PARCELAS": + case "COMISSÃO": + ids = analitico.Select((Analitico x) => ((DomainBase)x.Parcela).Id).ToList(); + break; + } + List excluirIds = await tarefaServico.Validar(ids, ((DomainBase)trilha).Id); + List second; + switch (Head) + { + case "CLIENTES": + second = analitico.Where((Analitico x) => excluirIds.Contains(x.Cliente.Id)).ToList(); + break; + default: + second = analitico.Where((Analitico x) => excluirIds.Contains(((DomainBase)x.Documento).Id)).ToList(); + break; + case "PARCELAS": + case "COMISSÃO": + second = analitico.Where((Analitico x) => excluirIds.Contains(((DomainBase)x.Parcela).Id)).ToList(); + break; + } + return analitico.Except(second).ToList(); + } + + private async Task GerarHtml(DataGrid grid) + { + List first = (from x in typeof(Analitico).GetProperties() + select x.Name).ToList(); + List list = new List(); + for (int i = 0; i < grid.Columns.Count; i++) + { + if (!(grid.Columns[i] is DataGridTemplateColumn)) + { + DataGridColumn obj = grid.Columns[i]; + BindingBase binding = ((DataGridBoundColumn)((obj is DataGridBoundColumn) ? obj : null)).Binding; + Binding val = (Binding)(object)((binding is Binding) ? binding : null); + list.Add(val.Path.Path); + } + } + List colunasOcultas = first.Except(list).ToList(); + string text = Funcoes.CreateCard("", await Funcoes.GenerateTable((from Analitico x in (IEnumerable)((ItemsControl)grid).Items + where x.Selecionado + select x).ToList(), colunasOcultas, grafico: false, propertyName: true)); + return Funcoes.ExportarHtml(new TipoRelatorio + { + Nome = "ANALÍTICO - " + Head + }, text ?? ""); + } + + public async Task Print(DataGrid grid) + { + if (!((IEnumerable)((ItemsControl)grid).Items).Cast().Any((Analitico x) => x.Selecionado)) + { + await ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM DOCUMENTO"); + return; + } + string value = await GerarHtml(grid); + if (!string.IsNullOrEmpty(value)) + { + string tempPath = Path.GetTempPath(); + string text = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, new Regex("[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]").Replace(Head, ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(value); + streamWriter.Close(); + Process.Start(text); + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/Arquivo.cs b/Decompiler/Gestor.Application.ViewModels/Arquivo.cs new file mode 100644 index 0000000..9e73979 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/Arquivo.cs @@ -0,0 +1,8 @@ +namespace Gestor.Application.ViewModels; + +public class Arquivo +{ + public string Nome { get; set; } + + public int Processo { get; set; } +} diff --git a/Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs b/Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs new file mode 100644 index 0000000..47f386d --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/CoberturaViewModel.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels; + +public class CoberturaViewModel : BaseSegurosViewModel +{ + private readonly ItemServico _itemServico; + + private Cobertura _selectedCobertura = new Cobertura(); + + private List _coberturasPadrao; + + private ObservableCollection _coberturas; + + private readonly IComparer _comparerCobertura = Comparer.Create(delegate(Cobertura item1, Cobertura item2) + { + if (((DomainBase)item1).Id > ((DomainBase)item2).Id) + { + return 1; + } + return (((DomainBase)item1).Id < ((DomainBase)item2).Id) ? (-1) : 0; + }); + + public Item Item { get; set; } + + public Ramo Ramo { get; set; } + + public Cobertura SelectedCobertura + { + get + { + return _selectedCobertura; + } + set + { + _selectedCobertura = value; + OnPropertyChanged("SelectedCobertura"); + } + } + + public List CoberturasPadrao + { + get + { + return _coberturasPadrao; + } + set + { + _coberturasPadrao = value; + OnPropertyChanged("CoberturasPadrao"); + } + } + + public ObservableCollection Coberturas + { + get + { + return _coberturas; + } + set + { + _coberturas = value; + OnPropertyChanged("Coberturas"); + } + } + + public CoberturaViewModel(Ramo ramo = null, Item item = null) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + Item = item ?? ConsultaViewModel.ItemSelecionado; + object obj = ramo; + if (obj == null) + { + Documento documentoSelecionado = ConsultaViewModel.DocumentoSelecionado; + if (documentoSelecionado == null) + { + obj = null; + } + else + { + Controle controle = documentoSelecionado.Controle; + obj = ((controle != null) ? controle.Ramo : null); + } + } + Ramo = (Ramo)obj; + _itemServico = new ItemServico(); + } + + public async Task SelectionaCoberturas() + { + if (Ramo != null) + { + CoberturasPadrao = Recursos.Coberturas.Where((CoberturaPadrao x) => x.IdRamo == ((DomainBase)Ramo).Id).ToList(); + if (Item != null) + { + Coberturas = await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)Item).Id); + } + } + } + + internal async Task> BuscarCobertura(string value) + { + return await Task.Run(() => CoberturasPadrao?.Where((CoberturaPadrao x) => ValidationHelper.RemoveDiacritics(x.Descricao.ToUpper().Trim()).Contains(value.ToUpper())).ToList()); + } + + public void AdicionaCobertura() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Expected O, but got Unknown + Cobertura val = new Cobertura + { + Item = Item + }; + ValidationHelper.AddSorted(Coberturas, val, _comparerCobertura); + SelectedCobertura = val; + } + + public async void ExcluirCobertura(Cobertura cobertura) + { + if (cobertura != null && await ShowMessage("DESEJA REALMENTE EXCLUIR A COBERTURA" + Environment.NewLine + "\"" + cobertura.Observacao + "\"?", "SIM", "NÃO")) + { + Coberturas.Remove(cobertura); + } + } + + public async Task> LimpaCoberturas() + { + bool flag = Coberturas != null && Coberturas.Any((Cobertura x) => x.Franquia == 0m && x.Lmi == 0m && x.Premio == 0m); + if (flag) + { + flag = await ShowMessage("DESEJA LIMPAR AS COBERTURAS SEM VALOR DE FRANQUIA, LMI E PRÊMIO?", "SIM", "NÃO"); + } + return (!flag) ? Coberturas?.ToList() : Coberturas?.Where((Cobertura x) => !string.IsNullOrEmpty(x.Observacao) && (x.Franquia != 0m || x.Lmi != 0m || x.Premio != 0m)).ToList(); + } + + public async Task CancelarAlteracao() + { + if (Item != null) + { + Coberturas = await _itemServico.BuscarCoberturasPorItemAsync(((DomainBase)Item).Id); + } + } + + public void CarregaPadrao() + { + List list = CoberturasPadrao?.Where((CoberturaPadrao x) => x.Padrao).Select((Func)((CoberturaPadrao x) => new Cobertura + { + CoberturaPadrao = x, + Observacao = x.Descricao + })).ToList(); + if (list != null) + { + Coberturas = new ObservableCollection(list); + } + } + + public ObservableCollection CarregaCoberturaPadrao() + { + List list = CoberturasPadrao?.Where((CoberturaPadrao x) => x.Padrao).Select((Func)((CoberturaPadrao x) => new Cobertura + { + CoberturaPadrao = x, + Observacao = x.Descricao + })).ToList(); + return Coberturas = new ObservableCollection(list); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/DashboardViewModel.cs b/Decompiler/Gestor.Application.ViewModels/DashboardViewModel.cs new file mode 100644 index 0000000..be683d2 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/DashboardViewModel.cs @@ -0,0 +1,925 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +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; + +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 _intervalo = new List { "HOJE", "PRÓXIMOS 3 DIAS", "PRÓXIMOS 7 DIAS" }; + + private string _intervaloSelecionado = "HOJE"; + + private bool _isProspectar; + + private ObservableCollection _notas; + + private ObservableCollection _telefones = new ObservableCollection(); + + private string _anotacoes = ""; + + private ObservableCollection _prospeccoes; + + private ObservableCollection _aniversariantes; + + private ObservableCollection _sinistros; + + private ObservableCollection _renovacaoFiltrado; + + private ObservableCollection _tarefas = new ObservableCollection(); + + private List _ramos; + + private Ramo _selectedRamo; + + private List _referencias = new List { "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 _filtroCliente = new List { "AMBOS", "CNPJ", "CPF" }; + + private string _filtroClientes; + + public bool RenovacoesEnabled + { + get + { + return _renovacoesEnabled; + } + set + { + _renovacoesEnabled = value; + OnPropertyChanged("RenovacoesEnabled"); + } + } + + public bool TarefasEnabled + { + get + { + return _tarefasEnabled; + } + set + { + _tarefasEnabled = value; + OnPropertyChanged("TarefasEnabled"); + } + } + + public bool AniversariantesEnabled + { + get + { + return _aniversariantesEnabled; + } + set + { + _aniversariantesEnabled = value; + OnPropertyChanged("AniversariantesEnabled"); + } + } + + public bool SinistrosEnabled + { + get + { + return _sinistrosEnabled; + } + set + { + _sinistrosEnabled = value; + OnPropertyChanged("SinistrosEnabled"); + } + } + + public bool ProspeccoesEnabled + { + get + { + return _prospeccoesEnabled; + } + set + { + _prospeccoesEnabled = value; + OnPropertyChanged("ProspeccoesEnabled"); + } + } + + public bool NotasEnabled + { + get + { + return _notasEnabled; + } + set + { + _notasEnabled = value; + OnPropertyChanged("NotasEnabled"); + } + } + + public bool Load { get; set; } = true; + + + public int SelectedTile + { + get + { + return _selectedTile; + } + set + { + _selectedTile = value; + IsProspectar = value == 4 || value == 5; + } + } + + public bool Publica + { + get + { + return _publica; + } + set + { + _publica = value; + OnPropertyChanged("Publica"); + } + } + + public string QuantidadeRenovacoes + { + get + { + return _quantidadeRenovacoes; + } + set + { + _quantidadeRenovacoes = value; + OnPropertyChanged("QuantidadeRenovacoes"); + } + } + + public string QuantidadeAniversariantes + { + get + { + return _quantidadeAniversariantes; + } + set + { + _quantidadeAniversariantes = value; + OnPropertyChanged("QuantidadeAniversariantes"); + } + } + + public string QuantidadeProspeccao + { + get + { + return _quantidadeProspeccao; + } + set + { + _quantidadeProspeccao = value; + OnPropertyChanged("QuantidadeProspeccao"); + } + } + + public string QuantidadeSinistro + { + get + { + return _quantidadeSinisto; + } + set + { + _quantidadeSinisto = value; + OnPropertyChanged("QuantidadeSinistro"); + } + } + + public string QuantidadeTarefas + { + get + { + return _quantidadeTarefas; + } + set + { + _quantidadeTarefas = value; + OnPropertyChanged("QuantidadeTarefas"); + } + } + + public List Intervalo + { + get + { + return _intervalo; + } + set + { + _intervalo = value; + OnPropertyChanged("Intervalo"); + } + } + + public string IntervaloSelecionado + { + get + { + return _intervaloSelecionado; + } + set + { + _intervaloSelecionado = value; + OnPropertyChanged("IntervaloSelecionado"); + } + } + + public bool IsProspectar + { + get + { + return _isProspectar; + } + set + { + _isProspectar = value; + OnPropertyChanged("IsProspectar"); + } + } + + public ObservableCollection Notas + { + get + { + return _notas; + } + set + { + _notas = value; + OnPropertyChanged("Notas"); + } + } + + public ObservableCollection Telefones + { + get + { + return _telefones; + } + set + { + _telefones = value; + OnPropertyChanged("Telefones"); + } + } + + public new string Anotacoes + { + get + { + return _anotacoes; + } + set + { + _anotacoes = value; + OnPropertyChanged("Anotacoes"); + } + } + + public ObservableCollection Prospeccoes + { + get + { + return _prospeccoes; + } + set + { + _prospeccoes = value; + OnPropertyChanged("Prospeccoes"); + } + } + + public List Restricoes { get; set; } + + public List Permissoes { get; set; } + + public ObservableCollection Aniversariantes + { + get + { + return _aniversariantes; + } + set + { + _aniversariantes = value; + OnPropertyChanged("Aniversariantes"); + } + } + + public ObservableCollection Sinistros + { + get + { + return _sinistros; + } + set + { + _sinistros = value; + OnPropertyChanged("Sinistros"); + } + } + + public Filtros Filtros { get; set; } + + private Filtros _filtroRenovacao { get; set; } + + private Filtros _filtroAniversariantes { get; set; } + + private Filtros _filtroTarefas { get; set; } + + private Filtros _filtroSinistros { get; set; } + + public ObservableCollection RenovacaoFiltrado + { + get + { + return _renovacaoFiltrado; + } + set + { + _renovacaoFiltrado = value; + OnPropertyChanged("RenovacaoFiltrado"); + } + } + + public ObservableCollection Tarefas + { + get + { + return _tarefas; + } + set + { + _tarefas = value; + OnPropertyChanged("Tarefas"); + } + } + + private Filtros _filtroProspectar { get; set; } + + public List Ramos + { + get + { + return _ramos; + } + set + { + _ramos = value; + OnPropertyChanged("Ramos"); + } + } + + public Ramo SelectedRamo + { + get + { + return _selectedRamo; + } + set + { + _selectedRamo = value; + OnPropertyChanged("SelectedRamo"); + } + } + + public List Referencias + { + get + { + return _referencias; + } + set + { + _referencias = value; + OnPropertyChanged("Referencias"); + } + } + + public string Referencia + { + get + { + return _referencia; + } + set + { + _referencia = value; + OnPropertyChanged("Referencia"); + } + } + + public string LabelProspeccao + { + get + { + return _labelProspeccao; + } + set + { + _labelProspeccao = value; + OnPropertyChanged("LabelProspeccao"); + } + } + + public List FiltroCliente + { + get + { + return _filtroCliente; + } + set + { + _filtroCliente = value; + OnPropertyChanged("FiltroCliente"); + } + } + + public string FiltroClientes + { + get + { + return _filtroClientes; + } + set + { + _filtroClientes = value; + OnPropertyChanged("FiltroClientes"); + } + } + + public DashboardViewModel() + { + _servico = new TarefaServico(); + _apoliceServico = new ApoliceServico(); + _clienteServico = new ClienteServico(); + _tarefaServico = new TarefaServico(); + _sinitrosServico = new SinistroServico(); + } + + public async Task BuscarRestricoes() + { + Restricoes = await ServicoRestriUsuario.BuscarRestricoes(((DomainBase)Recursos.Usuario).Id); + Permissoes = new List(); + PermissaoUsuario val = await ServicoPermissUsuario.VerificarPermissao(Recursos.Usuario, (TipoTela)38); + if (val != null) + { + Permissoes.Add(val); + } + } + + public async Task CarregarAniversariantes(bool force = false) + { + AniversariantesEnabled = false; + if (!force && CompararFiltros(_filtroAniversariantes)) + { + AniversariantesEnabled = true; + return; + } + _filtroAniversariantes = Filtros; + List list = await VerificaVinculoVendedor(Recursos.Usuario); + List vinculoVendedores = new List(); + list.ForEach(delegate(VendedorUsuario v) + { + vinculoVendedores.Add(((DomainBase)v.Vendedor).Id); + }); + List list2 = ((list.Count <= 0) ? (await _clienteServico.BuscarAniversariantes(Filtros)) : (await _clienteServico.BuscarAniversariantesVinculo(Filtros, list))); + List list3 = list2; + QuantidadeAniversariantes = list3.Count.ToString(); + if (list3.Count == 0) + { + Aniversariantes = null; + AniversariantesEnabled = true; + } + else + { + Aniversariantes = new ObservableCollection(list3); + AniversariantesEnabled = true; + } + } + + public async Task CarregarSinistros(bool force = false) + { + SinistrosEnabled = false; + if (!force && CompararFiltros(_filtroSinistros)) + { + SinistrosEnabled = true; + return; + } + _filtroSinistros = Filtros; + List list = await _sinitrosServico.BuscarSinistroPendente(Filtros); + QuantidadeSinistro = list.Count.ToString(); + if (list.Count == 0) + { + Sinistros = null; + SinistrosEnabled = true; + } + else + { + Sinistros = new ObservableCollection(list); + SinistrosEnabled = true; + } + } + + public async Task CarregarSinistros(DateTime inicio, DateTime fim) + { + _filtroSinistros.Fim = fim; + _filtroSinistros.Inicio = inicio; + List list = await _sinitrosServico.BuscarSinistroPendente(_filtroSinistros); + QuantidadeSinistro = list.Count.ToString(); + Sinistros = new ObservableCollection(list); + } + + public async Task CarregarFiltros() + { + List vendedores = new List(); + List list = await VerificaVinculoVendedor(Recursos.Usuario); + if (list.Count > 0) + { + list.ForEach(delegate(VendedorUsuario x) + { + vendedores.Add(((DomainBase)x.Vendedor).Id); + }); + } + DateTime today = DateTime.Today; + DateTime fim = DateTime.Today; + string intervaloSelecionado = IntervaloSelecionado; + if (!(intervaloSelecionado == "PRÓXIMOS 3 DIAS")) + { + if (intervaloSelecionado == "PRÓXIMOS 7 DIAS") + { + fim = today.AddDays(7.0); + } + } + else + { + fim = today.AddDays(3.0); + } + Filtros = new Filtros + { + Inicio = today, + Fim = fim, + Vendedores = vendedores, + IdEmpresa = ((Recursos.Usuario.IdEmpresa > 1) ? Recursos.Usuario.IdEmpresa : 0), + Status = new List { 1L, 2L } + }; + } + + private bool CompararFiltros(Filtros comparacao) + { + if (comparacao == null) + { + return false; + } + if (Filtros == null) + { + return false; + } + if (comparacao.Inicio != Filtros.Inicio) + { + return false; + } + if (comparacao.Fim != Filtros.Fim) + { + return false; + } + return true; + } + + public async Task CarregarRenovacoes(bool force = false) + { + RenovacoesEnabled = false; + if (!force && CompararFiltros(_filtroRenovacao)) + { + RenovacoesEnabled = true; + return; + } + _filtroRenovacao = Filtros; + List analiticoRenovacao = (await _apoliceServico.BuscarApolicesVigenciaFinal(Filtros)).Where((Documento x) => x.Tipo != 3).Select((Func)delegate(Documento x) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0079: Unknown result type (might be due to invalid IL or missing references) + //IL_0094: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00c2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ed: Unknown result type (might be due to invalid IL or missing references) + //IL_0111: Unknown result type (might be due to invalid IL or missing references) + //IL_015f: Unknown result type (might be due to invalid IL or missing references) + //IL_0166: Unknown result type (might be due to invalid IL or missing references) + //IL_016c: Invalid comparison between Unknown and I4 + //IL_0174: Unknown result type (might be due to invalid IL or missing references) + //IL_017a: Invalid comparison between Unknown and I4 + //IL_01a6: Unknown result type (might be due to invalid IL or missing references) + //IL_0182: Unknown result type (might be due to invalid IL or missing references) + //IL_01c3: Unknown result type (might be due to invalid IL or missing references) + //IL_01e9: Unknown result type (might be due to invalid IL or missing references) + //IL_024e: Unknown result type (might be due to invalid IL or missing references) + //IL_025f: Unknown result type (might be due to invalid IL or missing references) + //IL_026b: Unknown result type (might be due to invalid IL or missing references) + //IL_027c: Unknown result type (might be due to invalid IL or missing references) + //IL_02df: Unknown result type (might be due to invalid IL or missing references) + //IL_0313: Unknown result type (might be due to invalid IL or missing references) + //IL_0332: Unknown result type (might be due to invalid IL or missing references) + //IL_0343: Unknown result type (might be due to invalid IL or missing references) + //IL_0369: Unknown result type (might be due to invalid IL or missing references) + //IL_037f: Unknown result type (might be due to invalid IL or missing references) + //IL_03a7: Unknown result type (might be due to invalid IL or missing references) + //IL_03dc: Unknown result type (might be due to invalid IL or missing references) + //IL_0402: Unknown result type (might be due to invalid IL or missing references) + //IL_0413: Unknown result type (might be due to invalid IL or missing references) + //IL_0424: Unknown result type (might be due to invalid IL or missing references) + //IL_0435: Unknown result type (might be due to invalid IL or missing references) + //IL_0450: Unknown result type (might be due to invalid IL or missing references) + //IL_0462: Expected O, but got Unknown + Renovacao val2 = new Renovacao(); + Cliente cliente = x.Controle.Cliente; + val2.Cliente = ((cliente != null) ? cliente.Nome : null) ?? ""; + val2.Apolice = x.Apolice ?? ""; + val2.PremioLiquido = x.PremioLiquido; + val2.PremioTotal = x.PremioTotal; + Negocio? negocio = x.Negocio; + val2.Negocio = (negocio.HasValue ? ValidationHelper.GetDescription((Enum)(object)negocio.GetValueOrDefault()) : null) ?? ""; + val2.VigenciaFinal = x.Vigencia2; + Produto produto2 = x.Controle.Produto; + val2.Produto = ((produto2 != null) ? produto2.Nome : null) ?? ""; + val2.Ramo = x.Controle.Ramo.Nome ?? ""; + val2.Seguradora = ((!string.IsNullOrWhiteSpace(x.Controle.Seguradora.NomeSocial)) ? x.Controle.Seguradora.NomeSocial : x.Controle.Seguradora.Nome); + val2.Status = (((int)x.Situacao == 1 || (int)x.Situacao == 2) ? "NÃO TRABALHADO" : (ValidationHelper.GetDescription((Enum)(object)x.Situacao) ?? "")); + Vendedor vendedorPrincipal = x.VendedorPrincipal; + val2.Vendedor = ((vendedorPrincipal != null) ? vendedorPrincipal.Nome : null); + Estipulante estipulante = x.Estipulante1; + val2.Estipulante = ((estipulante != null) ? estipulante.Nome : null) ?? ""; + val2.TodosVendedores = ((x.Vendedores == null || x.Vendedores.Count == 0) ? "" : string.Join("; ", x.Vendedores.Select((Vendedor v) => v.Nome))); + val2.Tipo = x.Tipo; + val2.Documento = x; + val2.Comissao = x.Comissao; + val2.Item = ((x.ItensAtivo == null) ? "" : ((x.ItensAtivo.Count > 1) ? "APÓLICE COLETIVA" : ((x.ItensAtivo.Count == 1) ? x.ItensAtivo.First().Descricao : ""))); + val2.TipoDocumento = ((x.Tipo == 0) ? "APÓLICE" : ((x.Tipo == 1) ? "ENDOSSO" : "")); + val2.Sinistro = (x.Sinistro ? "SIM" : "NÃO"); + val2.DataControle = x.DataControle; + Status status2 = x.Status; + val2.StatusApolice = ((status2 != null) ? status2.Nome : null) ?? ""; + val2.IdEmpresa = x.Controle.IdEmpresa; + Empresa? obj = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa e) => ((DomainBase)e).Id == x.Controle.IdEmpresa)); + val2.Empresa = ((obj != null) ? obj.Nome : null); + val2.QtdSinistro = x.ItensAtivo.Sum((Item s) => s.Sinistros.Count); + Banco banco = x.Banco; + val2.Banco = ((banco != null) ? banco.Nome : null) ?? ""; + val2.Conta = x.Conta; + val2.Agencia = x.Agencia; + val2.Pasta = x.Pasta; + val2.PastaCliente = x.Controle.Cliente.Pasta; + val2.Calculos = x.Calculos; + return val2; + }).ToList(); + List collection = (await new ProspeccaoServico().BuscarProspeccoes(Filtros)).Where((Prospeccao x) => x.Renovacao).Select(delegate(Prospeccao x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + Renovacao val = new Renovacao(); + val.Cliente = x.Nome ?? ""; + val.Apolice = "PROSPECÇÃO"; + val.VigenciaFinal = x.VigenciaFinal; + StatusProspeccao? status = x.Status; + val.Status = (status.HasValue ? ValidationHelper.GetDescription((Enum)(object)status.GetValueOrDefault()) : null) ?? ""; + Vendedor vendedor = x.Vendedor; + val.Vendedor = ((vendedor != null) ? vendedor.Nome : null); + Vendedor vendedor2 = x.Vendedor; + val.TodosVendedores = ((vendedor2 != null) ? vendedor2.Nome : null); + val.Telefone = x.Prefixo1 + " " + x.Telefone1 + " | " + x.Prefixo2 + " " + x.Telefone2; + val.Tipo = 3; + val.TipoDocumento = "PROSPECÇÃO"; + val.Item = x.Item; + Produto produto = x.Produto; + val.Produto = ((produto != null) ? produto.Nome : null); + val.Prospeccao = x; + return val; + }).ToList(); + analiticoRenovacao.AddRange(collection); + QuantidadeRenovacoes = analiticoRenovacao.Count.ToString(); + if (analiticoRenovacao.Count == 0) + { + RenovacaoFiltrado = null; + RenovacoesEnabled = true; + return; + } + RenovacaoFiltrado = new ObservableCollection(analiticoRenovacao.OrderBy((Renovacao x) => x.VigenciaFinal).ToList()); + RenovacoesEnabled = true; + } + + public async Task CarregarNotas() + { + NotasEnabled = false; + Notas = new ObservableCollection(await _servico.BuscarNotas(((DomainBase)Recursos.Usuario).Id)); + NotasEnabled = true; + } + + public async Task>> Salvar(Tarefa destino) + { + destino.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45); + List> list = destino.Validate(); + if (list.Count > 0) + { + return list; + } + await _servico.Salvar(destino); + if (!_servico.Sucesso) + { + return null; + } + if (Publica) + { + long id = ((DomainBase)destino.Usuario).Id; + List usuarios = Recursos.Usuarios; + List list2 = new List(); + foreach (Usuario item in usuarios) + { + if (id != ((DomainBase)item).Id) + { + Tarefa val = (Tarefa)((DomainBase)destino).Clone(); + ((DomainBase)val).Id = 0L; + val.Usuario = item; + list2.Add(_servico.Salvar(val)); + } + } + await Task.WhenAll(list2); + } + await CarregarNotas(); + return null; + } + + public async Task SalvarNota(Tarefa nota) + { + return await _servico.Salvar(nota); + } + + public async Task ExcluirNota(Tarefa nota) + { + await _servico.Excluir(((DomainBase)nota).Id); + } + + public async Task CarregarTarefas(bool force = false) + { + TarefasEnabled = false; + if (!force && CompararFiltros(_filtroTarefas)) + { + TarefasEnabled = true; + return; + } + _filtroTarefas = Filtros; + List list = await _tarefaServico.BuscarTarefas(((DomainBase)Recursos.Usuario).Id, _filtroTarefas.Inicio, _filtroTarefas.Fim, false); + QuantidadeTarefas = list.Count.ToString(); + if (list.Count == 0) + { + Tarefas = null; + TarefasEnabled = true; + return; + } + Tarefas = new ObservableCollection(from x in list + where (int)x.Entidade != 1 + orderby x.Agendamento + select x); + TarefasEnabled = true; + } + + public async Task CarregarProspect(DateTime inicio, DateTime fim) + { + ProspeccoesEnabled = false; + Filtros val = new Filtros + { + Inicio = inicio, + Fim = fim, + Ramos = new List { ((DomainBase)SelectedRamo).Id }, + Vendedores = Filtros.Vendedores, + Referencia = Referencia, + FiltrarDocumento = FiltroClientes + }; + LabelProspeccao = "CLIENTES QUE NÃO POSSUEM SEGUROS DO RAMO " + SelectedRamo.Nome + " "; + string referencia = Referencia; + if (!(referencia == "VIGÊNCIA INICIAL")) + { + if (!(referencia == "VIGÊNCIA FINAL")) + { + LabelProspeccao += "E QUE ESTÃO COM A ULTIMA PARCELA VENCENDO NO PERÍODO"; + } + else + { + LabelProspeccao += "E QUE ESTÃO COM UMA APÓLICE VENCENDO NO PERÍODO"; + } + } + else + { + LabelProspeccao += "E QUE ESTÃO COM UMA APÓLICE INICIANDO NO PERÍODO"; + } + if (_filtroProspectar != null && _filtroProspectar.Inicio == val.Inicio && _filtroProspectar.Fim == val.Fim && _filtroProspectar.Ramos == val.Ramos && _filtroProspectar.Referencia == val.Referencia) + { + ProspeccoesEnabled = true; + return; + } + _filtroProspectar = val; + List list = await _clienteServico.BuscarProspect(val); + QuantidadeProspeccao = list.Count.ToString(); + if (list.Count == 0) + { + LabelProspeccao = "NÃO HÁ CLIENTES PARA PROSPECTAR"; + } + Prospeccoes = new ObservableCollection(list); + ProspeccoesEnabled = true; + } + + public void LimparProspeccao() + { + } + + public void CarregarRamos() + { + List ids = new List { 1L, 2L, 6L, 7L }; + Ramos = Recursos.Ramos.Where((Ramo x) => ids.Contains(((DomainBase)x).Id)).ToList(); + SelectedRamo = Ramos.Find((Ramo x) => ((DomainBase)x).Id == 1); + } + + public async Task GerarCsv() + { + string fileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".csv"; + File.WriteAllText(fileName, (await Funcoes.GerarCsv(Prospeccoes.ToList(), new List { "Nome", "Documento", "Telefone" })).ToString(), Encoding.UTF8); + Process.Start(fileName); + return true; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs b/Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs new file mode 100644 index 0000000..34daacf --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Domain.Generic; +using Microsoft.Win32; + +namespace Gestor.Application.ViewModels; + +public class ImportViewModel : BaseViewModel +{ + private ObservableCollection _arquivos = new ObservableCollection(); + + public ObservableCollection Arquivos + { + get + { + return _arquivos; + } + set + { + _arquivos = value; + OnPropertyChanged("Arquivos"); + } + } + + public void CarregarArquivos() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Expected O, but got Unknown + OpenFileDialog val = new OpenFileDialog + { + Title = "Selecione o PDF", + Filter = "Arquivos PDF|*.pdf", + Multiselect = true + }; + if (((CommonDialog)val).ShowDialog().GetValueOrDefault()) + { + Arquivos = new ObservableCollection(); + ((FileDialog)val).FileNames.ToList().ForEach(delegate(string x) + { + Arquivos.Add(new Arquivo + { + Nome = x, + Processo = 0 + }); + }); + } + } + + public void Importar() + { + new TaskFactory().StartNew(() => Importar(Arquivos.ToList())); + } + + public async Task Importar(List arquivos) + { + arquivos.ForEach(async delegate(Arquivo x) + { + await Import(x); + }); + return true; + } + + public async Task Import(Arquivo arquivo) + { + await Task.Run(delegate + { + try + { + Process process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "C:\\AggerSeguros\\Agger.Import201911261630\\Agger.ImportPDF.exe", + Arguments = $" {((DomainBase)Recursos.Empresa).Id} {((DomainBase)Recursos.Usuario).Id} NOVOGESTOR {arquivo.Nome}", + UseShellExecute = false, + RedirectStandardOutput = true, + CreateNoWindow = true + } + }; + process.Start(); + process.WaitForExit(); + string text = process.StandardError.ReadToEnd(); + string text2 = process.StandardOutput.ReadToEnd(); + if (process.ExitCode != 0) + { + throw new Exception("netsh exit code: " + process.ExitCode + " " + ((!string.IsNullOrEmpty(text)) ? (" " + text) : "") + " " + ((!string.IsNullOrEmpty(text2)) ? (" " + text2) : "")); + } + } + catch (Exception) + { + } + }); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/LoginImageModel.cs b/Decompiler/Gestor.Application.ViewModels/LoginImageModel.cs new file mode 100644 index 0000000..774c664 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/LoginImageModel.cs @@ -0,0 +1,8 @@ +namespace Gestor.Application.ViewModels; + +public class LoginImageModel +{ + public string Imagem { get; set; } + + public string UrlFixa { get; set; } +} diff --git a/Decompiler/Gestor.Application.ViewModels/LoginViewModel.cs b/Decompiler/Gestor.Application.ViewModels/LoginViewModel.cs new file mode 100644 index 0000000..4298f27 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/LoginViewModel.cs @@ -0,0 +1,866 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Reflection; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using Agger.Registro; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Command; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Security; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Gestor.Application.ViewModels; + +internal class LoginViewModel : BaseSegurosViewModel +{ + private class AggerAccess + { + public long Id { get; set; } + + public Client Usuario { get; set; } + + public string Ip { get; set; } + + public string Acao { get; set; } + + public string Serial { get; set; } + + public DateTime? Data { get; set; } + + public string Log { get; set; } + } + + private class Client + { + public long Id { get; set; } + + public string Name { get; set; } + + public string Login { get; set; } + + public string Password { get; set; } + + public string Email { get; set; } + + public bool Deleted { get; set; } + + public bool AttendancePrivate { get; set; } + + public DateTime? DateLoginStart { get; set; } + + public DateTime? DateLoginFinal { get; set; } + + public DateTime? ExpirationPassDate { get; set; } + } + + private bool _enableRegistro; + + private bool _enableTrocaSenha; + + private bool _aggerUser; + + private string _imagemLink = "https://calendly.com/treinamentocs"; + + private string _imagem = "https://docs.agger.com.br/treinamentoprimeirasemana.png"; + + private string _head; + + private string _login; + + private string _novaNovaSenha; + + private string _senha; + + private string _confirmacaoSenha; + + private Usuario _usuario; + + private string userJson = AppDomain.CurrentDomain.BaseDirectory + "user.json"; + + private LoginImageModel _selectedImage; + + private int _selectedIndex; + + private string _version; + + private string _labelVersion = ""; + + private bool _loadingVisibility; + + private bool _fieldsVisibility; + + private string _errorLogin = "DADOS DE ACESSO INVÁLIDOS"; + + private Visibility _errorLoginVisibility = (Visibility)1; + + private Visibility _acessoVisibility = (Visibility)2; + + private Visibility _trocaSenhaVisibility = (Visibility)2; + + private Visibility _loginVisibility; + + private Visibility _registrarVisibility = (Visibility)2; + + private Visibility _visibilityCancelarRegitro = (Visibility)2; + + private string _chave; + + private string _mensagem; + + private string _centralAtendimento = Address.CentralAtendimento.ToString(); + + public static string VersaoAtual { get; set; } + + public bool EnableRegistro + { + get + { + return _enableRegistro; + } + set + { + _enableRegistro = value; + OnPropertyChanged("EnableRegistro"); + } + } + + public bool EnableTrocaSenha + { + get + { + return _enableTrocaSenha; + } + set + { + _enableTrocaSenha = value; + OnPropertyChanged("EnableTrocaSenha"); + } + } + + public bool AggerUser + { + get + { + return _aggerUser; + } + set + { + _aggerUser = value; + OnPropertyChanged("AggerUser"); + } + } + + public string ImagemLink + { + get + { + return _imagemLink; + } + set + { + _imagemLink = value; + OnPropertyChanged("ImagemLink"); + } + } + + public string Imagem + { + get + { + return _imagem; + } + set + { + _imagem = value; + OnPropertyChanged("Imagem"); + } + } + + public string Head + { + get + { + return _head; + } + set + { + _head = value?.ToUpper(); + OnPropertyChanged("Head"); + } + } + + public string Login + { + get + { + return _login; + } + set + { + _login = value; + string login = Login; + AggerUser = (login != null && login.ToUpper().StartsWith("AGGER@")) || (Senha?.ToUpper().StartsWith("AGGER@") ?? false); + OnPropertyChanged("Login"); + } + } + + public string NovaSenha + { + get + { + return _novaNovaSenha; + } + set + { + _novaNovaSenha = value; + EnableTrocaSenha = ValidationHelper.IsNotNullOrEmpty(NovaSenha) && ValidationHelper.IsNotNullOrEmpty(ConfirmacaoSenha) && NovaSenha.Equals(ConfirmacaoSenha); + OnPropertyChanged("NovaSenha"); + } + } + + public string Senha + { + get + { + return _senha; + } + set + { + _senha = value; + string login = Login; + AggerUser = (login != null && login.ToUpper().StartsWith("AGGER@")) || (Senha?.ToUpper().StartsWith("AGGER@") ?? false); + OnPropertyChanged("Senha"); + } + } + + public string ConfirmacaoSenha + { + get + { + return _confirmacaoSenha; + } + set + { + _confirmacaoSenha = value; + EnableTrocaSenha = ValidationHelper.IsNotNullOrEmpty(NovaSenha) && ValidationHelper.IsNotNullOrEmpty(ConfirmacaoSenha) && NovaSenha.Equals(ConfirmacaoSenha); + OnPropertyChanged("ConfirmacaoSenha"); + } + } + + public Usuario Usuario + { + get + { + return _usuario; + } + set + { + _usuario = value; + OnPropertyChanged("Usuario"); + } + } + + public ObservableCollection LoginImages { get; set; } = new ObservableCollection(); + + + public LoginImageModel SelectedImage + { + get + { + return _selectedImage; + } + set + { + _selectedImage = value; + OnPropertyChanged("SelectedImage"); + } + } + + public int SelectedIndex + { + get + { + return _selectedIndex; + } + set + { + _selectedIndex = value; + SelectedImage = LoginImages.ElementAtOrDefault(value); + OnPropertyChanged("SelectedIndex"); + } + } + + public ICommand ImageClickCommand => new RelayCommand(delegate + { + LoginImageModel selectedImage = SelectedImage; + if (selectedImage != null && ValidationHelper.IsNotNullOrEmpty(selectedImage.UrlFixa)) + { + Process.Start(new ProcessStartInfo + { + FileName = SelectedImage.UrlFixa, + UseShellExecute = true + }); + } + }); + + public string Version + { + get + { + return _version; + } + set + { + _version = value; + OnPropertyChanged("Version"); + } + } + + public string LabelVersion + { + get + { + return _labelVersion; + } + set + { + _labelVersion = value; + OnPropertyChanged("LabelVersion"); + } + } + + public bool LoadingVisibility + { + get + { + return _loadingVisibility; + } + set + { + _loadingVisibility = value; + OnPropertyChanged("LoadingVisibility"); + } + } + + public bool FieldsVisibility + { + get + { + return _fieldsVisibility; + } + set + { + _fieldsVisibility = value; + OnPropertyChanged("FieldsVisibility"); + } + } + + public string ErrorLogin + { + get + { + return _errorLogin; + } + set + { + _errorLogin = value; + OnPropertyChanged("ErrorLogin"); + } + } + + public Visibility ErrorLoginVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _errorLoginVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _errorLoginVisibility = value; + OnPropertyChanged("ErrorLoginVisibility"); + } + } + + public Visibility AcessoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _acessoVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _acessoVisibility = value; + OnPropertyChanged("AcessoVisibility"); + } + } + + public Visibility TrocaSenhaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _trocaSenhaVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _trocaSenhaVisibility = value; + OnPropertyChanged("TrocaSenhaVisibility"); + } + } + + public Visibility LoginVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _loginVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _loginVisibility = value; + OnPropertyChanged("LoginVisibility"); + } + } + + public Visibility RegistrarVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _registrarVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _registrarVisibility = value; + OnPropertyChanged("RegistrarVisibility"); + } + } + + public Visibility VisibilityCancelarRegitro + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityCancelarRegitro; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibilityCancelarRegitro = value; + OnPropertyChanged("VisibilityCancelarRegitro"); + } + } + + public string Chave + { + get + { + return _chave; + } + set + { + _chave = value; + EnableRegistro = ValidationHelper.IsNotNullOrEmpty(Chave); + OnPropertyChanged("Chave"); + } + } + + public string Mensagem + { + get + { + return _mensagem; + } + set + { + _mensagem = value; + OnPropertyChanged("Mensagem"); + } + } + + public string CentralAtendimento + { + get + { + return _centralAtendimento; + } + set + { + _centralAtendimento = value; + OnPropertyChanged("CentralAtendimento"); + } + } + + public LoginViewModel() + { + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + base.EnableButtons = true; + ApplicationHelper.Versao = Assembly.GetExecutingAssembly().GetName().Version; + Version = ApplicationHelper.Versao.ToString(); + LabelVersion = "Gestor " + Version; + VersaoAtual = LabelVersion; + if (File.Exists(userJson)) + { + Usuario val = JsonConvert.DeserializeObject(File.ReadAllText(userJson)); + Login = ((val != null) ? val.Login : null); + } + } + + public async Task Load() + { + return await Task.Run(async delegate + { + try + { + return await new BaseServico().LoadInicialParameters(); + } + catch (Exception) + { + return false; + } + }); + } + + public async Task Validate(string login, string password) + { + ErrorLoginVisibility = (Visibility)1; + if (login.Contains("AGGER@")) + { + string[] array = login.Split(new char[1] { '@' }); + AggerAccess keyValues = new AggerAccess + { + Usuario = new Client + { + Login = array[1], + Password = new Token().AggerEncrypt(password) + }, + Acao = "AggerAccessNovoGestor", + Log = "ANG - " + ApplicationHelper.NumeroSerial, + Serial = ApplicationHelper.NumeroSerial + }; + AggerAccess aggerAccess = await Connection.Post("Access/AggerLogin", keyValues); + if (aggerAccess == null || !(aggerAccess.Usuario?.Id > 0)) + { + ErrorLoginVisibility = (Visibility)0; + return false; + } + Recursos.Usuario = new Usuario + { + Nome = "ACESSO AGGER - USUÁRIO " + aggerAccess.Usuario.Name, + Login = aggerAccess.Usuario.Login, + IdEmpresa = 1L, + PermissaoAggilizador = 1L + }; + Recursos.Empresa = new BaseServico().BuscarEmpresa(Recursos.Usuario.IdEmpresa); + return true; + } + Usuario usuario = await new BaseServico().BuscarUsuario(login, password); + string text = ((usuario != null) ? (await VerificarAcesso(((DomainBase)usuario).Id)) : "DADOS DE ACESSO INVÁLIDOS"); + string text2 = text; + if (text2 != null) + { + ErrorLogin = text2; + ErrorLoginVisibility = (Visibility)0; + return false; + } + Recursos.Usuario = usuario; + Recursos.Empresa = new BaseServico().BuscarEmpresa(Recursos.Usuario.IdEmpresa); + Recursos.Usuario.Senha = string.Empty; + File.WriteAllText(userJson, JsonConvert.SerializeObject((object)usuario)); + return true; + } + + public void AcessoNegado(string message) + { + Mensagem = message; + RegistrarVisibility = (Visibility)2; + LoginVisibility = (Visibility)2; + AcessoVisibility = (Visibility)0; + } + + public void AbrirRegistro() + { + LoginVisibility = (Visibility)2; + AcessoVisibility = (Visibility)2; + RegistrarVisibility = (Visibility)0; + VisibilityCancelarRegitro = (Visibility)((ApplicationHelper.IdFornecedor == 0L) ? 2 : 0); + Chave = string.Empty; + } + + public void FecharRegistro() + { + RegistrarVisibility = (Visibility)2; + LoginVisibility = (Visibility)0; + Chave = string.Empty; + } + + public async Task AbrirTrocaSenha() + { + UsuarioServico usuarioServico = new UsuarioServico(); + bool flag = ValidationHelper.IsNullOrEmpty(Senha) || ValidationHelper.IsNullOrEmpty(Login); + if (!flag) + { + bool flag2 = ValidationHelper.IsNotNullOrEmpty(Login); + if (flag2) + { + Usuario val2 = (Usuario = await usuarioServico.BuscarLogin(Login)); + flag2 = val2 == null; + } + flag = flag2; + } + if (flag) + { + await ShowMessage("NECESSÁRIO INSERIR UM USUÁRIO E SENHA VÁLIDOS PARA REALIZAR A TROCA DE SENHA."); + return; + } + TrocaSenhaVisibility = (Visibility)0; + LoginVisibility = (Visibility)2; + } + + public async Task TrocaSenha() + { + if (string.IsNullOrEmpty(Senha)) + { + await ShowMessage("NECESSÁRIO PREENCHER A SENHA ANTERIOR PARA REALIZAR A TROCA DE SENHA."); + return false; + } + if (string.IsNullOrEmpty(NovaSenha)) + { + await ShowMessage("NECESSÁRIO PREENCHER A NOVA SENHA PARA REALIZAR A TROCA DE SENHA."); + return false; + } + Token token = new Token(); + if (Senha == NovaSenha) + { + await ShowMessage("A NOVA SENHA NÃO PODE SER IGUAL A SENHA ANTERIOR."); + return false; + } + if (NovaSenha != ConfirmacaoSenha) + { + await ShowMessage("A SENHA E A CONFIRMAÇÃO DA SENHA DEVEM SER IGUAIS."); + return false; + } + if (Senha.ToUpper().Contains("AGGER@")) + { + string[] array = Senha.Split(new char[1] { '@' }); + if (array.Length < 3) + { + await ShowMessage("SENHA ANTERIOR INVÁLIDA."); + return false; + } + AggerAccess keyValues = new AggerAccess + { + Usuario = new Client + { + Login = array[1].ToUpper(), + Password = new Token().AggerEncrypt(array[2]) + }, + Acao = $"TrocaSenha - {((DomainBase)Usuario).Id}|{Usuario.Login}", + Log = "ANG - " + ApplicationHelper.NumeroSerial, + Serial = ApplicationHelper.NumeroSerial + }; + AggerAccess acesso; + try + { + acesso = await Connection.Post("Access/AggerLogin", keyValues); + } + catch (Exception ex) + { + _ = ex; + await ShowMessage("SENHA ANTERIOR INVÁLIDA."); + return false; + } + if (acesso == null || !(acesso.Usuario?.Id > 0)) + { + await ShowMessage("SENHA ANTERIOR INVÁLIDA."); + return false; + } + } + else if (ValidationHelper.IsNotNullOrEmpty(Usuario.Senha) && Senha != token.AggerDecrypt(Usuario.Senha)) + { + await ShowMessage("SENHA ANTERIOR INVÁLIDA."); + return false; + } + UsuarioServico servico = new UsuarioServico(); + Usuario.SenhaAnterior = token.AggerEncrypt(Senha); + Usuario.Senha = token.AggerEncrypt(NovaSenha); + await servico.Save(Usuario); + if (servico.Sucesso) + { + Senha = NovaSenha; + return true; + } + Usuario.SenhaAnterior = string.Empty; + Usuario.Senha = string.Empty; + await ShowMessage("VERIFIQUE OS DADOS DIGITADOS E TENTE NOVAMENTE."); + return false; + } + + public async Task GetImagesFromJson() + { + _ = 1; + try + { + HttpClient client = new HttpClient(); + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + client.Timeout = TimeSpan.FromSeconds(30.0); + HttpResponseMessage val; + try + { + val = await client.GetAsync(Address.LoginJson); + val.EnsureSuccessStatusCode(); + } + catch + { + return; + } + if (val.IsSuccessStatusCode) + { + JObject obj2 = JObject.Parse(await val.Content.ReadAsStringAsync()); + JToken obj3 = obj2["Imagem"]; + string text = ((obj3 != null) ? Extensions.Value((IEnumerable)obj3) : null); + JToken obj4 = obj2["Url"]; + string text2 = ((obj4 != null) ? Extensions.Value((IEnumerable)obj4) : null); + if (ValidationHelper.IsNotNullOrEmpty(text) && ValidationHelper.IsNotNullOrEmpty(text2)) + { + Imagem = text; + ImagemLink = text2; + } + } + } + finally + { + ((IDisposable)client)?.Dispose(); + } + } + catch + { + } + } + + public async Task GetCfgJson() + { + _ = 2; + try + { + HttpClient client = new HttpClient(); + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + client.Timeout = TimeSpan.FromSeconds(30.0); + HttpResponseMessage result; + try + { + result = await client.GetAsync(Address.JsonGestor); + result.EnsureSuccessStatusCode(); + } + catch + { + result = await client.GetAsync(Address.JsonGestorAzure); + } + if (result.IsSuccessStatusCode) + { + JObject obj2 = JObject.Parse(await result.Content.ReadAsStringAsync()); + JToken obj3 = obj2["ApiGestor"]; + string text = ((obj3 != null) ? Extensions.Value((IEnumerable)obj3) : null); + JToken obj4 = obj2["ApiGestorBeta"]; + string text2 = ((obj4 != null) ? Extensions.Value((IEnumerable)obj4) : null); + JToken obj5 = obj2["ApiAssinador"]; + string text3 = ((obj5 != null) ? Extensions.Value((IEnumerable)obj5) : null); + JToken obj6 = obj2["ApiAssinadorBeta"]; + string text4 = ((obj6 != null) ? Extensions.Value((IEnumerable)obj6) : null); + JToken obj7 = obj2["ApiCard"]; + string text5 = ((obj7 != null) ? Extensions.Value((IEnumerable)obj7) : null); + JToken obj8 = obj2["ApiAssistencia"]; + string text6 = ((obj8 != null) ? Extensions.Value((IEnumerable)obj8) : null); + JToken obj9 = obj2["ApiAD"]; + string text7 = ((obj9 != null) ? Extensions.Value((IEnumerable)obj9) : null); + JToken obj10 = obj2["ApiAttachment"]; + string text8 = ((obj10 != null) ? Extensions.Value((IEnumerable)obj10) : null); + JToken obj11 = obj2["ApiFipe"]; + string text9 = ((obj11 != null) ? Extensions.Value((IEnumerable)obj11) : null); + JToken obj12 = obj2["ApiSso"]; + string text10 = ((obj12 != null) ? Extensions.Value((IEnumerable)obj12) : null); + JToken obj13 = obj2["ApiCep"]; + string text11 = ((obj13 != null) ? Extensions.Value((IEnumerable)obj13) : null); + JToken obj14 = obj2["ApiMonitor"]; + string text12 = ((obj14 != null) ? Extensions.Value((IEnumerable)obj14) : null); + JToken obj15 = obj2["LoginJson"]; + string text13 = ((obj15 != null) ? Extensions.Value((IEnumerable)obj15) : null); + JToken obj16 = obj2["PromoJson"]; + string text14 = ((obj16 != null) ? Extensions.Value((IEnumerable)obj16) : null); + JToken obj17 = obj2["BetaPromoJson"]; + string text15 = ((obj17 != null) ? Extensions.Value((IEnumerable)obj17) : null); + JToken obj18 = obj2["SurveyJson"]; + string text16 = ((obj18 != null) ? Extensions.Value((IEnumerable)obj18) : null); + JToken obj19 = obj2["CentralAtendimento"]; + string text17 = ((obj19 != null) ? Extensions.Value((IEnumerable)obj19) : null); + JToken obj20 = obj2["UsarApis"]; + if (obj20 != null) + { + Extensions.Value((IEnumerable)obj20); + } + Address.ApiGestorOficial = text?.ToUri() ?? Address.ApiGestorOficial; + Address.ApiGestorBeta = text2?.ToUri() ?? Address.ApiGestorBeta; + Address.AssinadorApiOficial = text3?.ToUri() ?? Address.AssinadorApiOficial; + Address.AssinadorApiBeta = text4?.ToUri() ?? Address.AssinadorApiBeta; + Address.Card = text5?.ToUri() ?? Address.Card; + Address.Assistance = text6?.ToUri() ?? Address.Assistance; + Address.ApiAD = text7?.ToUri() ?? Address.ApiAD; + Address.ApiArquivo = text8?.ToUri() ?? Address.ApiArquivo; + Address.ApiFipe = text9?.ToUri() ?? Address.ApiFipe; + Address.ApiSso = text10?.ToUri() ?? Address.ApiSso; + Address.ApiMonitor = text12?.ToUri() ?? Address.ApiMonitor; + Address.ApiCep = text11?.ToUri() ?? Address.ApiCep; + Address.LoginJson = text13?.ToUri() ?? Address.LoginJson; + Address.SurveyJson = text16?.ToUri() ?? Address.SurveyJson; + Address.Promo = text14?.ToUri() ?? Address.Promo; + Address.BetaPromo = text15?.ToUri() ?? Address.BetaPromo; + Address.CentralAtendimento = text17?.ToUri() ?? Address.CentralAtendimento; + return true; + } + } + finally + { + ((IDisposable)client)?.Dispose(); + } + } + catch + { + } + return false; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs b/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs new file mode 100644 index 0000000..f9a9093 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/MainViewModel.cs @@ -0,0 +1,1061 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Threading; +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Financeiro; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Card; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; + +namespace Gestor.Application.ViewModels; + +public class MainViewModel : BaseSegurosViewModel +{ + public FinanceiroView FinanceiroView; + + public ConsultaViewModel ConsultaViewModel; + + public ClienteViewModel ClienteViewModel; + + private readonly ClienteServico _servico; + + public DashboardViewModel DashboardViewModel; + + private List _boletos; + + private BitmapImage _qrCode; + + private string _code; + + private Geometry _maximizeRestore = Geometry.Parse((string)Application.Current.Resources[(object)"Restore"]); + + private object _content; + + private double _headMaxWidth; + + private string _head; + + private string _tela; + + private TipoTela? _telaAberta; + + private string _versao; + + private long _selectedRamo = 5L; + + public bool PesquisaAvançada; + + private Cliente _selectedCliente; + + private bool _isEnableDocumento; + + private bool _isEnableItens; + + private TipoDocumento _tipoDocumento; + + private string _documentoPrincipal = ""; + + private ObservableCollection _ajuda = new ObservableCollection(); + + private bool _matrizFilial = LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 2 && x.Status == 1); + + private readonly bool _temEpic = LicenseHelper.Produtos.Any((Licenca produto) => (int)produto.Produto == 83 && produto.Status == 1); + + private bool _carregandoAjuda; + + private string _empresa = ""; + + private ObservableCollection _contatos = new ObservableCollection(); + + private int _liquido; + + private int _mediaComissao; + + private int _resultado; + + private Visibility _visibleChaveInstalacao = (Visibility)2; + + private Visibility _visibleSeguros = (Visibility)2; + + private Visibility _visibleBi = (Visibility)2; + + private FiltroStatusDocumento _selectedStatus; + + private TipoFiltroCliente _selectedFiltroCliente = (TipoFiltroCliente)1; + + private bool _buscaNome = true; + + private bool _enableSeguros; + + private bool _enableBuscar; + + private Visibility _visibilityVoltar = (Visibility)2; + + private int _notasBadge; + + private int _tarefasBadge; + + private int _badges; + + private int _ultimoUpdate; + + private Visibility _mensagemTarefasVisibility = (Visibility)2; + + private string _mensagemTarefas = ""; + + private string _pesquisa = ""; + + private int _medalhaCor; + + private Visibility _medalhaVisibility = (Visibility)2; + + private string _placeHolderAutoComplete = "PESQUISAR CLIENTE POR NOME OU NOME SOCIAL"; + + public static string ViewAberta { get; set; } + + public static Cliente ClienteSelecionado { get; set; } + + public static FiltroStatusDocumento StatusSelecionado { get; set; } + + public List Boletos + { + get + { + return _boletos; + } + set + { + _boletos = value; + OnPropertyChanged("Boletos"); + } + } + + public BitmapImage QrCode + { + get + { + return _qrCode; + } + set + { + _qrCode = value; + OnPropertyChanged("QrCode"); + } + } + + public string Code + { + get + { + return _code; + } + set + { + _code = value; + OnPropertyChanged("Code"); + } + } + + public Geometry MaximizeRestore + { + get + { + return _maximizeRestore; + } + set + { + _maximizeRestore = value; + OnPropertyChanged("MaximizeRestore"); + } + } + + public object Content + { + get + { + return _content; + } + set + { + _content = value; + OnPropertyChanged("Content"); + } + } + + public double HeadMaxWidth + { + get + { + return _headMaxWidth; + } + set + { + _headMaxWidth = value; + OnPropertyChanged("HeadMaxWidth"); + } + } + + public string Head + { + get + { + return _head; + } + set + { + _head = value; + OnPropertyChanged("Head"); + } + } + + public string Tela + { + get + { + return _tela; + } + set + { + _tela = value; + OnPropertyChanged("Tela"); + } + } + + public TipoTela? TelaAberta + { + get + { + return _telaAberta; + } + set + { + _telaAberta = value; + OnPropertyChanged("TelaAberta"); + } + } + + public string Versao + { + get + { + return _versao; + } + set + { + _versao = value; + OnPropertyChanged("Versao"); + } + } + + public long SelectedRamo + { + get + { + return _selectedRamo; + } + set + { + _selectedRamo = value; + OnPropertyChanged("SelectedRamo"); + } + } + + public bool Invoke { get; set; } = true; + + + public Cliente SelectedCliente + { + get + { + return _selectedCliente; + } + set + { + if (Invoke) + { + if (value != null) + { + long id = ((DomainBase)value).Id; + Cliente selectedCliente = SelectedCliente; + if (id == ((selectedCliente != null) ? new long?(((DomainBase)selectedCliente).Id) : null)) + { + goto IL_004a; + } + } + ClienteSelecionado = value; + } + goto IL_004a; + IL_004a: + _selectedCliente = value; + OnPropertyChanged("SelectedCliente"); + } + } + + public bool Isdropped { get; set; } + + public bool IsPopulating { get; set; } + + public List ClientesFiltrados { get; set; } + + public bool IsEnableDocumento + { + get + { + return _isEnableDocumento; + } + set + { + _isEnableDocumento = value; + OnPropertyChanged("IsEnableDocumento"); + } + } + + public bool IsEnableItens + { + get + { + return _isEnableItens; + } + set + { + _isEnableItens = value; + OnPropertyChanged("IsEnableItens"); + } + } + + public TipoDocumento TipoDocumento + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _tipoDocumento; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _tipoDocumento = value; + OnPropertyChanged("TipoDocumento"); + } + } + + public string DocumentoPrincipal + { + get + { + return _documentoPrincipal; + } + set + { + _documentoPrincipal = value; + OnPropertyChanged("DocumentoPrincipal"); + } + } + + public ObservableCollection Ajuda + { + get + { + return _ajuda; + } + set + { + _ajuda = value; + OnPropertyChanged("Ajuda"); + } + } + + public bool MatrizFilial + { + get + { + return _matrizFilial; + } + set + { + _matrizFilial = value; + OnPropertyChanged("MatrizFilial"); + } + } + + public Visibility TemEpic + { + get + { + if (_temEpic) + { + return (Visibility)0; + } + return (Visibility)2; + } + } + + public bool CarregandoAjuda + { + get + { + return _carregandoAjuda; + } + set + { + _carregandoAjuda = value; + OnPropertyChanged("CarregandoAjuda"); + } + } + + public string Empresa + { + get + { + return _empresa; + } + set + { + _empresa = value; + OnPropertyChanged("Empresa"); + } + } + + public ObservableCollection Contatos + { + get + { + return _contatos; + } + set + { + _contatos = value; + OnPropertyChanged("Contatos"); + } + } + + public List VendedorUsuario { get; set; } + + public Visibility VisibleChaveInstalacao + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibleChaveInstalacao; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibleChaveInstalacao = value; + OnPropertyChanged("VisibleChaveInstalacao"); + } + } + + public Visibility VisibleSeguros + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibleSeguros; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibleSeguros = value; + OnPropertyChanged("VisibleSeguros"); + } + } + + public Visibility VisibleBi + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibleBi; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibleBi = value; + OnPropertyChanged("VisibleBi"); + } + } + + public FiltroStatusDocumento SelectedStatus + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selectedStatus; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + _selectedStatus = value; + WorkOnSelectedStatus(value); + OnPropertyChanged("SelectedStatus"); + } + } + + public TipoFiltroCliente SelectedFiltroCliente + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selectedFiltroCliente; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Invalid comparison between Unknown and I4 + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + _selectedFiltroCliente = value; + BuscaNome = (int)value == 1; + PlaceHolderAutoComplete = (((int)_selectedFiltroCliente == 0) ? "PESQUISAR CLIENTE POR NOME OU SOBRENOME" : "PESQUISAR CLIENTE POR NOME OU DOCUMENTO"); + OnPropertyChanged("SelectedFiltroCliente"); + } + } + + public bool BuscaNome + { + get + { + return _buscaNome; + } + set + { + _buscaNome = value; + OnPropertyChanged("BuscaNome"); + } + } + + public bool EnableSeguros + { + get + { + return _enableSeguros; + } + set + { + _enableSeguros = value; + OnPropertyChanged("EnableSeguros"); + } + } + + public bool EnableBuscar + { + get + { + return _enableBuscar; + } + set + { + _enableBuscar = value; + OnPropertyChanged("EnableBuscar"); + } + } + + public Visibility VisibilityVoltar + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityVoltar; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibilityVoltar = value; + OnPropertyChanged("VisibilityVoltar"); + } + } + + public int NotasBadge + { + get + { + return _notasBadge; + } + set + { + _notasBadge = value; + Badges = value + TarefasBadge; + OnPropertyChanged("NotasBadge"); + } + } + + public int TarefasBadge + { + get + { + return _tarefasBadge; + } + set + { + _tarefasBadge = value; + Badges = value + NotasBadge; + OnPropertyChanged("TarefasBadge"); + } + } + + public int Badges + { + get + { + return _badges; + } + set + { + _badges = value; + OnPropertyChanged("Badges"); + } + } + + public Visibility MensagemTarefasVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _mensagemTarefasVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _mensagemTarefasVisibility = value; + OnPropertyChanged("MensagemTarefasVisibility"); + } + } + + public string MensagemTarefas + { + get + { + return _mensagemTarefas; + } + set + { + _mensagemTarefas = value; + OnPropertyChanged("MensagemTarefas"); + } + } + + public string Pesquisa + { + get + { + return _pesquisa; + } + set + { + _pesquisa = value; + OnPropertyChanged("Pesquisa"); + } + } + + public int MedalhaCor + { + get + { + return _medalhaCor; + } + set + { + _medalhaCor = value; + OnPropertyChanged("MedalhaCor"); + } + } + + public Visibility MedalhaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _medalhaVisibility; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _medalhaVisibility = value; + OnPropertyChanged("MedalhaVisibility"); + } + } + + public string PlaceHolderAutoComplete + { + get + { + return _placeHolderAutoComplete; + } + set + { + _placeHolderAutoComplete = value; + OnPropertyChanged("PlaceHolderAutoComplete"); + } + } + + public List ClientesEncontrados { get; set; } + + public MainViewModel() + { + //IL_00bf: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00d4: Unknown result type (might be due to invalid IL or missing references) + //IL_00e2: Unknown result type (might be due to invalid IL or missing references) + //IL_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + //IL_0225: Unknown result type (might be due to invalid IL or missing references) + //IL_0254: Unknown result type (might be due to invalid IL or missing references) + Gestor.Application.Actions.Actions.AtualizaBadges = AtualizarBadges; + Gestor.Application.Actions.Actions.LimparCliente = LimparCliente; + _servico = new ClienteServico(); + Gestor.Application.Actions.Actions.UpdateDocumento = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.UpdateDocumento, new Action(UpdateRamoIcon)); + Gestor.Application.Actions.Actions.SelectCliente = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.SelectCliente, new Action(SelectCliente)); + Gestor.Application.Actions.Actions.AtualizaContatos = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.AtualizaContatos, new Action(AtualizarContatos)); + Gestor.Application.Actions.Actions.EnableItens = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.EnableItens, new Action(EnableItens)); + Gestor.Application.Actions.Actions.EnableDocumento = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.EnableDocumento, new Action(EnableDocumento)); + Versao = Recursos.Empresa.Nome + " | " + LoginViewModel.VersaoAtual; + Usuario usuario = Recursos.Usuario; + SelectedFiltroCliente = ((usuario != null) ? usuario.FiltroInicial : null).GetValueOrDefault(); + new DispatcherTimer(TimeSpan.FromHours(1.0), (DispatcherPriority)4, (EventHandler)delegate + { + AtualizarBadges(); + }, ((DispatcherObject)Application.Current).Dispatcher).Start(); + } + + private void SelectCliente(Cliente cliente) + { + SelectedCliente = cliente; + if (Pesquisa != ((cliente == null) ? null : cliente.NomeSocial?.Trim())) + { + Pesquisa = ((cliente == null) ? null : cliente.NomeSocial?.Trim()); + } + } + + private void EnableItens(bool enabled) + { + IsEnableItens = enabled; + } + + private void EnableDocumento(bool enabled) + { + IsEnableDocumento = enabled; + } + + public async Task SelecionarCliente(Cliente value) + { + IsEnableDocumento = false; + IsEnableItens = false; + LimparDocumentos(); + if (value != null) + { + if (Invoke) + { + ClienteSelecionado = value; + } + await WorkOnSelectedCliente(value); + IsEnableDocumento = true; + } + } + + private async Task WorkOnSelectedCliente(Cliente value) + { + base.IsEnabled = false; + List contatos = new List(); + ObservableCollection telefones = await _servico.BuscarTelefonesAsync(((DomainBase)value).Id); + ObservableCollection observableCollection = await _servico.BuscarEmailsAsync(((DomainBase)value).Id); + if (telefones != null) + { + contatos.AddRange(((IEnumerable)telefones).Select((Func)((ClienteTelefone x) => new Contato + { + Tipo = (TipoContato)0, + TipoTelefone = ((TelefoneBase)x).Tipo.GetValueOrDefault((TipoTelefone)1), + Numero = ((TelefoneBase)x).Prefixo + " " + ((TelefoneBase)x).Numero + })).Take(2).ToList()); + } + if (observableCollection != null) + { + contatos.AddRange(((IEnumerable)observableCollection).Select((Func)((ClienteEmail x) => new Contato + { + Tipo = (TipoContato)1, + TipoTelefone = null, + Numero = ((EmailBase)x).Email + })).Take(1).ToList()); + } + Contatos = new ObservableCollection(contatos); + TipoDocumento = value.DocumentoPrincipal.GetValueOrDefault(); + MainViewModel mainViewModel = this; + Empresa? obj = ((IEnumerable)Recursos.Empresas).FirstOrDefault((Func)((Empresa x) => ((DomainBase)x).Id == value.IdEmpresa)); + mainViewModel.Empresa = ((obj != null) ? obj.Nome : null) ?? Recursos.Empresa.Nome; + TipoDocumento tipoDocumento = TipoDocumento; + switch ((int)tipoDocumento) + { + case 0: + DocumentoPrincipal = value.Documento ?? ""; + break; + case 1: + DocumentoPrincipal = value.Rne ?? ""; + break; + case 2: + DocumentoPrincipal = value.Cei ?? ""; + break; + case 3: + DocumentoPrincipal = value.Caepf ?? ""; + break; + } + if (ClienteSelecionado != null) + { + ClienteSelecionado.Telefones = telefones; + ClienteSelecionado.Emails = observableCollection; + } + string viewAberta = ViewAberta; + if (!(viewAberta == "ConsultaOriginalView")) + { + if (viewAberta == "ClienteView") + { + ClienteViewModel?.SelecionaCliente(SelectedCliente); + MainViewModel mainViewModel2 = this; + string descricao = "ACESSOU CLIENTE \"" + SelectedCliente.Nome + "\""; + long id = ((DomainBase)SelectedCliente).Id; + TipoTela? tela = (TipoTela)1; + Cliente selectedCliente = SelectedCliente; + mainViewModel2.RegistrarAcao(descricao, id, tela, $"ID CLIENTE: {((selectedCliente != null) ? new long?(((DomainBase)selectedCliente).Id) : null)}"); + } + } + else if (ConsultaViewModel != null) + { + await (ConsultaViewModel?.SelecionaCliente(value)); + AtualizarMedalha(ConsultaViewModel.Apolices.ToList()); + } + base.IsEnabled = true; + MainViewModel mainViewModel3 = this; + Cliente selectedCliente2 = SelectedCliente; + mainViewModel3.Pesquisa = ((selectedCliente2 != null) ? selectedCliente2.NomeSocial : null); + } + + private async void AtualizarMedalha(List apolices) + { + Qualificacao val = await _servico.BuscarQualificacaoAsync(); + if (((DomainBase)val).Id == 0L) + { + val = new Qualificacao + { + Liquido1 = 0m, + Liquido2 = 1000m, + Liquido3 = 5000m, + Comissao1 = 10m, + Comissao2 = 15m, + Comissao3 = 20m, + Resultado1 = 100m, + Resultado2 = 200m, + Resultado3 = 300m, + Id = 1L + }; + } + _liquido = 0; + _mediaComissao = 0; + _resultado = 0; + decimal num = apolices.Sum((Documento p) => p.PremioLiquido); + if (num >= val.Liquido3) + { + _liquido = 3; + } + else if (num >= val.Liquido2) + { + _liquido = 2; + } + else if (num >= val.Liquido1) + { + _liquido = 1; + } + decimal num2 = (apolices.Any((Documento c) => c.Comissao > 0m) ? decimal.Round(apolices.Sum((Documento c) => c.Comissao) / (decimal)apolices.Count((Documento c) => c.Comissao > 0m), 2) : 0m); + if (num2 >= val.Comissao3) + { + _mediaComissao = 3; + } + else if (num2 >= val.Comissao2) + { + _mediaComissao = 2; + } + else if (num2 >= val.Comissao1) + { + _mediaComissao = 1; + } + decimal num3 = apolices.Sum((Documento p) => (p.PremioLiquido + (p.AdicionalComiss ? p.PremioAdicional : 0m)) * p.Comissao * 0.01m); + if (num3 >= val.Resultado3) + { + _resultado = 3; + } + else if (num3 >= val.Resultado2) + { + _resultado = 2; + } + else if (num3 >= val.Resultado1) + { + _resultado = 1; + } + MedalhaCor = (int)Math.Round(((float)_liquido + (float)_mediaComissao + (float)_resultado) / 3f); + MedalhaVisibility = (Visibility)0; + } + + public async void Medalha() + { + await ShowMedalha(_liquido, _mediaComissao, _resultado, MedalhaCor); + } + + private async void AtualizarContatos() + { + List contatos = new List(); + if (SelectedCliente == null) + { + return; + } + ObservableCollection telefones = await _servico.BuscarTelefonesAsync(((DomainBase)SelectedCliente).Id); + ObservableCollection observableCollection = await _servico.BuscarEmailsAsync(((DomainBase)SelectedCliente).Id); + if (telefones != null) + { + contatos.AddRange(((IEnumerable)telefones).Select((Func)((ClienteTelefone x) => new Contato + { + Tipo = (TipoContato)0, + TipoTelefone = ((TelefoneBase)x).Tipo.GetValueOrDefault((TipoTelefone)1), + Numero = ((TelefoneBase)x).Prefixo + " " + ((TelefoneBase)x).Numero + })).Take(2).ToList()); + } + if (observableCollection != null) + { + contatos.AddRange(((IEnumerable)observableCollection).Select((Func)((ClienteEmail x) => new Contato + { + Tipo = (TipoContato)1, + TipoTelefone = null, + Numero = ((EmailBase)x).Email + })).Take(1).ToList()); + } + Contatos = new ObservableCollection(contatos); + } + + private void WorkOnSelectedStatus(FiltroStatusDocumento value) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + StatusSelecionado = value; + if (SelectedCliente == null || !Invoke) + { + return; + } + string viewAberta = ViewAberta; + if (!(viewAberta == "ConsultaOriginalView")) + { + if (viewAberta == "ClienteView") + { + ClienteViewModel?.SelecionaCliente(SelectedCliente); + } + } + else + { + ConsultaViewModel?.SelecionarCliente(SelectedCliente); + } + } + + private void UpdateRamoIcon(Documento documento) + { + if (documento != null && ((DomainBase)documento).Id != 0L) + { + SelectedRamo = ((DomainBase)documento.Controle.Ramo).Id; + } + } + + private async void AtualizarBadges() + { + try + { + int[] array = await new TarefaServico().AtualizarNotasTarefas(); + NotasBadge = array[0]; + TarefasBadge = array[1]; + if (array[1] > _ultimoUpdate) + { + MensagemTarefas = string.Format("{0} NOVA{1} TAREFA{2}", array[1], (array[1] > 1) ? "S" : "", (array[1] > 1) ? "S" : ""); + MensagemTarefasVisibility = (Visibility)0; + } + _ultimoUpdate = array[1]; + } + catch + { + } + } + + public async void LimparDocumentos() + { + Contatos = null; + DocumentoPrincipal = ""; + string viewAberta = ViewAberta; + if (!(viewAberta == "ConsultaOriginalView")) + { + if (viewAberta == "ClienteView") + { + ClienteViewModel?.SelecionaCliente(null); + } + } + else if (ConsultaViewModel != null) + { + await (ConsultaViewModel?.SelecionaCliente(null)); + } + } + + private void LimparCliente() + { + SelectedCliente = null; + Contatos = null; + DocumentoPrincipal = ""; + Pesquisa = ""; + } + + public async Task CarregarAjuda() + { + if (TelaAberta.HasValue && !Ajuda.Any((AjudaTela x) => (TipoTela?)x.Tela == TelaAberta)) + { + CarregandoAjuda = true; + Ajuda = new ObservableCollection(await Connection.Get>($"Help/{(int)TelaAberta.Value}")); + CarregandoAjuda = false; + } + } + + public List FiltrarClientes(string value) + { + return FilterCliente(ClientesEncontrados, value); + } + + public async void VerificarLogo() + { + if (string.IsNullOrEmpty(Recursos.Empresa.LogoId) && Recursos.Empresa.Logo != null) + { + Logo val = new Logo + { + CustomId = ApplicationHelper.NumeroSerial, + Data = Recursos.Empresa.Logo + }; + Empresa empresa = Recursos.Empresa; + empresa.LogoId = await Funcoes.Criarlogo(val); + new EmpresaServico().AtualizarLogoId(((DomainBase)Recursos.Empresa).Id, Recursos.Empresa.LogoId); + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/MenuBIViewModel.cs b/Decompiler/Gestor.Application.ViewModels/MenuBIViewModel.cs new file mode 100644 index 0000000..1f33a00 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/MenuBIViewModel.cs @@ -0,0 +1,7 @@ +using Gestor.Application.ViewModels.Generic; + +namespace Gestor.Application.ViewModels; + +public class MenuBIViewModel : BaseSegurosViewModel +{ +} diff --git a/Decompiler/Gestor.Application.ViewModels/MenuFerramentasViewModel.cs b/Decompiler/Gestor.Application.ViewModels/MenuFerramentasViewModel.cs new file mode 100644 index 0000000..2193e34 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/MenuFerramentasViewModel.cs @@ -0,0 +1,79 @@ +using System.Windows; +using Gestor.Application.ViewModels.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels; + +internal class MenuFerramentasViewModel : BaseSegurosViewModel +{ + private Usuario _selectedUsuario = new Usuario(); + + private Visibility _visibilityUsuario; + + private Visibility _visibilityEmpresa; + + private object _content; + + public UsuarioViewModel UsuarioViewModel { get; set; } + + public static Usuario UsuarioSelecionado { get; set; } + + public Usuario SelectedUsuario + { + get + { + return _selectedUsuario; + } + set + { + _selectedUsuario = value; + OnPropertyChanged("SelectedUsuario"); + } + } + + public Visibility VisibilityUsuario + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityUsuario; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibilityUsuario = value; + OnPropertyChanged("VisibilityUsuario"); + } + } + + public Visibility VisibilityEmpresa + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityEmpresa; + } + set + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + _visibilityEmpresa = value; + OnPropertyChanged("VisibilityEmpresa"); + } + } + + public object Content + { + get + { + return _content; + } + set + { + _content = value; + OnPropertyChanged("Content"); + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/MenuItemViewModel.cs b/Decompiler/Gestor.Application.ViewModels/MenuItemViewModel.cs new file mode 100644 index 0000000..10e8bf1 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/MenuItemViewModel.cs @@ -0,0 +1,798 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.ViewModels.Seguros; +using Gestor.Application.Views.Seguros.Itens; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels; + +public class MenuItemViewModel : BaseSegurosViewModel +{ + private readonly ItemServico _servico; + + private string _acaoItens = "MANTER"; + + private readonly Documento _documentoSelecionado; + + public bool AlterandoSelectedItem; + + private bool _endossoRenovacao; + + private ObservableCollection _itens = new ObservableCollection(); + + private ObservableCollection _itensFiltrados = new ObservableCollection(); + + private Item _selectedItem = new Item(); + + private bool _mostrarLista; + + private bool _isExpanded = true; + + private ManutencaoItem _manutencao; + + private object _view; + + private bool _allSelectedChanging; + + private bool? _allSelected = false; + + private string _manterTodosText = "MANTER TODOS OS ITENS"; + + private string _manterText = "MANTER ITENS"; + + public long Ramo { get; set; } + + public bool EndossoRenovacao + { + get + { + return _endossoRenovacao; + } + set + { + _endossoRenovacao = value; + OnPropertyChanged("EndossoRenovacao"); + } + } + + public ObservableCollection Itens + { + get + { + return _itens; + } + set + { + _itens = value; + OnPropertyChanged("Itens"); + } + } + + public ObservableCollection ItensFiltrados + { + get + { + return _itensFiltrados; + } + set + { + _itensFiltrados = value; + IsExpanded = value != null && value.Count > 0; + foreach (Item itensFiltrado in ItensFiltrados) + { + itensFiltrado.PropertyChanged += EntryOnPropertyChanged; + } + OnPropertyChanged("ItensFiltrados"); + } + } + + public Item SelectedItem + { + get + { + return _selectedItem; + } + set + { + WorkOnSelectedItem(value); + _selectedItem = value; + OnPropertyChanged("SelectedItem"); + } + } + + public bool MostrarLista + { + get + { + return _mostrarLista; + } + set + { + _mostrarLista = value; + OnPropertyChanged("MostrarLista"); + } + } + + public bool IsExpanded + { + get + { + return _isExpanded; + } + set + { + _isExpanded = value; + OnPropertyChanged("IsExpanded"); + } + } + + public ManutencaoItem Manutencao + { + get + { + return _manutencao; + } + set + { + _manutencao = value; + OnPropertyChanged("Manutencao"); + } + } + + public object View + { + get + { + return _view; + } + set + { + _view = value; + OnPropertyChanged("View"); + } + } + + private bool Carregando { get; set; } + + public bool? AllSelected + { + get + { + return _allSelected; + } + set + { + if (value != _allSelected) + { + _allSelected = value; + AllSelectedChanged(); + Itens = new ObservableCollection(Itens); + OnPropertyChanged("AllSelected"); + } + } + } + + public string ManterTodosText + { + get + { + return _manterTodosText; + } + set + { + _manterTodosText = value; + OnPropertyChanged("ManterTodosText"); + } + } + + public string ManterText + { + get + { + return _manterText; + } + set + { + _manterText = value; + OnPropertyChanged("ManterText"); + } + } + + public MenuItemViewModel(long ramo, ManutencaoItem manutencao) + { + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Expected O, but got Unknown + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: Invalid comparison between Unknown and I4 + if (ramo == 6 || ramo == 7 || ramo == 9 || ramo == 10 || ramo == 53 || ramo == 66) + { + _acaoItens = "MOVER"; + } + _manterTodosText = _acaoItens + " TODOS OS ITENS"; + _manterText = _acaoItens + " ITEM"; + Ramo = ramo; + _servico = new ItemServico(); + _documentoSelecionado = ((manutencao == null) ? ConsultaViewModel.DocumentoSelecionado : manutencao.Documento); + if (manutencao != null && (int)manutencao.Tipo == 2) + { + ConsultaViewModel.FiltrarItens = 4; + } + Seleciona(manutencao == null); + if (manutencao != null) + { + Manutencao = manutencao; + MostrarLista = true; + } + } + + public async void Seleciona(bool item = true) + { + if (!item || ConsultaViewModel.ItemSelecionado != null) + { + await SelecionaItens(ConsultaViewModel.FiltrarItens, ConsultaViewModel.ItemSelecionado); + } + else + { + Load(); + } + } + + public async void RecarregarItens(Item item) + { + ManutencaoItem manutencao = Manutencao; + if (manutencao != null && (int)manutencao.Tipo == 0) + { + ItensFiltrados.Remove(SelectedItem); + Itens.Remove(SelectedItem); + if (ItensFiltrados.Count == 0) + { + Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); + return; + } + AllSelected = false; + ManterTodosText = _acaoItens + " TODOS OS ITENS"; + SelecionaItem(ItensFiltrados.First()); + return; + } + ManutencaoItem manutencao2 = Manutencao; + if (manutencao2 != null && (int)manutencao2.Tipo == 2) + { + ConsultaViewModel.FiltrarItens = 4; + } + await SelecionaItens(ConsultaViewModel.FiltrarItens, (Item)(((object)item) ?? ((object)new Item + { + Id = 0L + }))); + AlterandoSelectedItem = true; + SelectedItem = (Item)((item != null) ? ((object)(((IEnumerable)Itens).FirstOrDefault((Func)((Item x) => ((DomainBase)x).Id == ((DomainBase)item).Id)) ?? Itens.FirstOrDefault())) : ((object)((Itens.Count > 0) ? Itens[0] : null))); + AlterandoSelectedItem = false; + } + + public async Task SelecionaItens(int type, Item item = null) + { + Loading(isLoading: true); + Carregando = true; + switch (type) + { + default: + Itens = await _servico.BuscarItens(((DomainBase)_documentoSelecionado.Controle).Id, (StatusItem)0); + break; + case 1: + case 2: + Itens = await _servico.BuscarItens(((DomainBase)_documentoSelecionado).Id, (StatusItem)2); + break; + case 3: + Itens = await _servico.BuscarItens(((DomainBase)_documentoSelecionado.Controle).Id, (StatusItem)1); + break; + case 4: + Itens = await _servico.BuscarItens(((DomainBase)_documentoSelecionado.Controle).Id, (StatusItem)3); + break; + } + ItensFiltrados = Itens; + if (item != null && ((DomainBase)item).Id > 0) + { + AlterandoSelectedItem = true; + SelectedItem = ((ItensFiltrados != null && ItensFiltrados.Count > 0) ? ((IEnumerable)ItensFiltrados).FirstOrDefault((Func)((Item x) => ((DomainBase)x).Id == ((DomainBase)item).Id)) : null); + Gestor.Application.Actions.Actions.ScrollToItem?.Invoke(); + AlterandoSelectedItem = false; + } + MenuItemViewModel menuItemViewModel = this; + int mostrarLista; + if (!MostrarLista) + { + ObservableCollection itens = Itens; + mostrarLista = ((itens != null && itens.Count > 1) ? 1 : 0); + } + else + { + mostrarLista = 1; + } + menuItemViewModel.MostrarLista = (byte)mostrarLista != 0; + Carregando = false; + Loading(isLoading: false); + } + + private void WorkOnSelectedItem(Item value) + { + ConsultaViewModel.ItemSelecionado = value; + Load(); + } + + private async void Load(bool substituir = false, ManutencaoItem manutencao = null) + { + long ramo = Ramo; + if (ramo <= 38) + { + long num = ramo - 1; + if ((ulong)num <= 19uL) + { + switch (num) + { + case 4L: + goto IL_00f3; + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + goto IL_01e8; + case 12L: + goto IL_02dd; + case 19L: + goto IL_03d2; + case 5L: + case 6L: + case 8L: + case 9L: + goto IL_04c7; + case 3L: + case 7L: + case 10L: + case 11L: + case 13L: + case 15L: + case 16L: + case 18L: + goto IL_06b1; + } + } + if (ramo == 30) + { + goto IL_01e8; + } + long num2 = ramo - 36; + if ((ulong)num2 <= 2uL) + { + switch (num2) + { + case 1L: + break; + case 2L: + goto IL_01e8; + case 0L: + goto IL_05bc; + default: + goto IL_06b1; + } + goto IL_00f3; + } + } + else if (ramo == 47 || ramo == 53 || ramo == 66) + { + goto IL_04c7; + } + goto IL_06b1; + IL_00f3: + if (View != null && View.GetType() == typeof(AutoView)) + { + await ((AutoView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((AutoView)View).Substituir(); + } + if (manutencao != null) + { + ((AutoView)View).Manter(manutencao); + } + return; + } + View = new AutoView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + IL_06b1: + if (View != null && View.GetType() == typeof(RiscosDiversosView)) + { + await ((RiscosDiversosView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((RiscosDiversosView)View).Substituir(); + } + if (manutencao != null) + { + ((RiscosDiversosView)View).Manter(manutencao); + } + return; + } + View = new RiscosDiversosView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + IL_05bc: + if (View != null && View.GetType() == typeof(ConsorcioView)) + { + await ((ConsorcioView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((ConsorcioView)View).Substituir(); + } + if (manutencao != null) + { + ((ConsorcioView)View).Manter(manutencao); + } + return; + } + View = new ConsorcioView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + IL_079e: + base.IsVisible = (Visibility)0; + return; + IL_01e8: + if (View != null && View.GetType() == typeof(PatrimonialView)) + { + await ((PatrimonialView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((PatrimonialView)View).Substituir(); + } + if (manutencao != null) + { + ((PatrimonialView)View).Manter(manutencao); + } + return; + } + View = new PatrimonialView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + IL_02dd: + if (View != null && View.GetType() == typeof(AeronauticoView)) + { + await ((AeronauticoView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((AeronauticoView)View).Substituir(); + } + if (manutencao != null) + { + ((AeronauticoView)View).Manter(manutencao); + } + return; + } + View = new AeronauticoView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + IL_04c7: + if (View != null && View.GetType() == typeof(VidaView)) + { + await ((VidaView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((VidaView)View).Substituir(); + } + if (manutencao != null) + { + ((VidaView)View).Manter(manutencao); + } + return; + } + View = new VidaView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + IL_03d2: + if (View != null && View.GetType() == typeof(GranizoView)) + { + await ((GranizoView)View).Selecionar(ConsultaViewModel.ItemSelecionado); + if (substituir) + { + ((GranizoView)View).Substituir(); + } + if (manutencao != null) + { + ((GranizoView)View).Manter(manutencao); + } + return; + } + View = new GranizoView(this, lockInsert: false, substituir, manutencao, null, null, EndossoRenovacao); + goto IL_079e; + } + + public void SelecionaItem(Item item) + { + if (!Carregando) + { + AlterandoSelectedItem = true; + SelectedItem = item; + ConsultaViewModel.ItemSelecionado = SelectedItem; + AlterandoSelectedItem = false; + } + } + + internal async Task> Filtrar(string value) + { + return await Task.Run(() => FiltrarItem(value)); + } + + public List FiltrarItem(string filter) + { + ItensFiltrados = (string.IsNullOrWhiteSpace(filter) ? Itens : new ObservableCollection(from x in Itens + where ValidationHelper.RemoveDiacritics(x.Descricao.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) + orderby x.Ordem + select x)); + return ItensFiltrados.ToList(); + } + + public async void CancelarItem(Item item) + { + if (item != null) + { + Loading(isLoading: true); + await _servico.Cancelar(item, $"CANCELADO NO ENDOSSO ORDEM {Manutencao.Documento.Ordem}", ((DomainBase)Manutencao.Documento).Id); + ToggleSnackBar("ITEM CANCELADO COM SUCESSO"); + Loading(isLoading: false); + RecarregarItens(item); + } + } + + public void Substituir(Item item) + { + Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: false); + ConsultaViewModel.ItemSelecionado = item; + Load(substituir: true); + } + + public void Manter(Item item) + { + Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: false); + ConsultaViewModel.ItemSelecionado = item; + Load(substituir: false, Manutencao); + } + + public async void ManterItens() + { + Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: false); + Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: false); + Loading(isLoading: true); + int ordem = 1; + foreach (Item item in (ManterTodosText == _acaoItens + " TODOS OS ITENS") ? new List(Itens) : new List(Itens.Where((Item x) => x.Selecionado))) + { + Item itemManter = await _servico.BuscarItemPorIdAsync(((DomainBase)item).Id); + Item val = itemManter; + val.Coberturas = await _servico.BuscarCoberturasPorItemAsync(((DomainBase)item).Id); + bool moverTitulares = false; + ((DomainBase)itemManter).Id = 0L; + itemManter.Sinistrado = false; + itemManter.Sinistros = null; + itemManter.Documento = ConsultaViewModel.DocumentoSelecionado; + itemManter.Ordem = ordem; + ordem++; + foreach (Cobertura cobertura in itemManter.Coberturas) + { + ((DomainBase)cobertura).Id = 0L; + cobertura.Item = itemManter; + } + long ramo = Ramo; + if (ramo <= 36) + { + long num = ramo - 1; + if ((ulong)num <= 19uL) + { + switch (num) + { + case 4L: + goto IL_0385; + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + goto IL_0537; + case 12L: + goto IL_0608; + case 19L: + goto IL_06d9; + case 5L: + case 6L: + case 8L: + case 9L: + goto IL_07aa; + case 3L: + case 7L: + case 10L: + case 11L: + case 13L: + case 15L: + case 16L: + case 18L: + goto IL_0953; + } + } + if (ramo == 36) + { + val = itemManter; + val.Consorcio = await _servico.BuscaConsorcio(((DomainBase)item).Id); + itemManter.Consorcio.Item = itemManter; + ((DomainBase)itemManter.Consorcio).Id = 0L; + goto IL_0a20; + } + } + else + { + if (ramo == 37) + { + goto IL_0385; + } + if (ramo == 53 || ramo == 66) + { + goto IL_07aa; + } + } + goto IL_0953; + IL_0a20: + itemManter.Status = ""; + item.Substituido = null; + itemManter = await _servico.Save(itemManter); + if (moverTitulares && ((DomainBase)itemManter).Id != ((DomainBase)item).Id) + { + List list = await _servico.BuscaTitularesVida(((DomainBase)item).Id); + if (list.Count > 0) + { + list.ForEach(delegate(TitularesVida t) + { + t.IdItem = ((DomainBase)itemManter).Id; + }); + await _servico.SaveTitulares(list); + } + } + ItensFiltrados.Remove(item); + Itens.Remove(item); + continue; + IL_07aa: + val = itemManter; + val.Vida = await _servico.BuscaVida(((DomainBase)item).Id); + itemManter.Vida.Item = itemManter; + ((DomainBase)itemManter.Vida).Id = 0L; + moverTitulares = true; + goto IL_0a20; + IL_0385: + val = itemManter; + val.Auto = await _servico.BuscaAuto(((DomainBase)item).Id); + itemManter.Auto.Item = itemManter; + ((DomainBase)itemManter.Auto).Id = 0L; + if (itemManter.Auto != null && itemManter.Auto.Placa == null) + { + await ShowMessage($"ITEM {itemManter.Ordem} ENCONTRADO SEM PLACA."); + Loading(isLoading: false); + Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: true); + Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: true); + return; + } + goto IL_0a20; + IL_0953: + val = itemManter; + val.RiscosDiversos = await _servico.BuscaRiscosDiversos(((DomainBase)item).Id); + itemManter.RiscosDiversos.Item = itemManter; + ((DomainBase)itemManter.RiscosDiversos).Id = 0L; + goto IL_0a20; + IL_06d9: + val = itemManter; + val.Granizo = await _servico.BuscaGranizo(((DomainBase)item).Id); + itemManter.Granizo.Item = itemManter; + ((DomainBase)itemManter.Granizo).Id = 0L; + goto IL_0a20; + IL_0608: + val = itemManter; + val.Aeronautico = await _servico.BuscaAeronautico(((DomainBase)item).Id); + itemManter.Aeronautico.Item = itemManter; + ((DomainBase)itemManter.Aeronautico).Id = 0L; + goto IL_0a20; + IL_0537: + val = itemManter; + val.Patrimonial = await _servico.BuscaPatrimonial(((DomainBase)item).Id); + itemManter.Patrimonial.Item = itemManter; + ((DomainBase)itemManter.Patrimonial).Id = 0L; + goto IL_0a20; + } + Loading(isLoading: false); + Gestor.Application.Actions.Actions.EnableMenu?.Invoke(obj: true); + Gestor.Application.Actions.Actions.EnableMainMenu?.Invoke(obj: true); + if (ItensFiltrados.Count == 0) + { + Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); + return; + } + AllSelected = false; + ManterTodosText = _acaoItens + " TODOS OS ITENS"; + SelecionaItem(ItensFiltrados.First()); + } + + public async void Reativar(Item item) + { + if (item != null) + { + Loading(isLoading: true); + await _servico.Reativar(item, "ITEM REATIVADO PELO USUARIO " + Recursos.Usuario.Nome); + ToggleSnackBar("ITEM REATIVADO COM SUCESSO"); + Loading(isLoading: false); + RecarregarItens(item); + } + } + + private void AllSelectedChanged() + { + if (_allSelectedChanging) + { + return; + } + try + { + _allSelectedChanging = true; + if (!AllSelected.HasValue) + { + return; + } + ManterTodosText = (AllSelected.Value ? (_acaoItens + " ITENS SELECIONADOS") : (_acaoItens + " TODOS OS ITENS")); + foreach (Item iten in Itens) + { + iten.Selecionado = AllSelected.Value; + } + } + finally + { + _allSelectedChanging = false; + } + } + + private void EntryOnPropertyChanged(object sender, PropertyChangedEventArgs args) + { + if (args.PropertyName == "Selecionado") + { + RecheckAllSelected(); + } + } + + private void RecheckAllSelected() + { + if (_allSelectedChanging) + { + return; + } + try + { + _allSelectedChanging = true; + if (Itens.All((Item e) => e.Selecionado)) + { + AllSelected = true; + ManterTodosText = _acaoItens + " ITENS SELECIONADOS"; + } + else if (Itens.All((Item e) => !e.Selecionado)) + { + AllSelected = false; + ManterTodosText = _acaoItens + " TODOS OS ITENS"; + } + else + { + AllSelected = null; + ManterTodosText = _acaoItens + " ITENS SELECIONADOS"; + } + } + finally + { + _allSelectedChanging = false; + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/TrilhaViewModel.cs b/Decompiler/Gestor.Application.ViewModels/TrilhaViewModel.cs new file mode 100644 index 0000000..2c6d1d6 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/TrilhaViewModel.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +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; + +namespace Gestor.Application.ViewModels; + +public class TrilhaViewModel : BaseSegurosViewModel +{ + private ObservableCollection _trilhas = new ObservableCollection(); + + private ObservableCollection _fases = new ObservableCollection(); + + private Trilha _selectedTrilha = new Trilha(); + + private Tarefa _selectedTarefa; + + private ObservableCollection _usuarios; + + private Usuario _selectedUsuario = new Usuario(); + + private TarefaServico Servico { get; } + + public ObservableCollection Trilhas + { + get + { + return _trilhas; + } + set + { + _trilhas = value; + OnPropertyChanged("Trilhas"); + } + } + + public ObservableCollection Fases + { + get + { + return _fases; + } + set + { + _fases = value; + OnPropertyChanged("Fases"); + } + } + + public Trilha SelectedTrilha + { + get + { + return _selectedTrilha; + } + set + { + _selectedTrilha = value; + OnPropertyChanged("SelectedTrilha"); + } + } + + public Tarefa SelectedTarefa + { + get + { + return _selectedTarefa; + } + set + { + _selectedTarefa = value; + OnPropertyChanged("SelectedTarefa"); + } + } + + public ObservableCollection Usuarios + { + get + { + return _usuarios; + } + set + { + _usuarios = value; + OnPropertyChanged("Usuarios"); + } + } + + public Usuario SelectedUsuario + { + get + { + return _selectedUsuario; + } + set + { + _selectedUsuario = value; + OnPropertyChanged("SelectedUsuario"); + } + } + + public TrilhaViewModel() + { + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Expected O, but got Unknown + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Expected O, but got Unknown + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_0060: Expected O, but got Unknown + Servico = new TarefaServico(); + List list = new List + { + new Usuario + { + Id = 0L, + Nome = "TODOS OS USUÁRIOS" + } + }; + list.AddRange((from x in Recursos.Usuarios + where (Recursos.Usuario.IdEmpresa == 1 || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && !x.Excluido + orderby x.Nome + select x).ToList()); + Usuarios = new ObservableCollection(list); + SelectedUsuario = Usuarios.First(); + Gestor.Application.Actions.Actions.AtualizaTrilhas = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.AtualizaTrilhas, new Action(AtualizarTrilhas)); + CarregaTrilhas(); + } + + public void AtualizarTrilhas() + { + CarregaTrilhas(); + } + + public async void CarregaTrilhas() + { + await CarregarTrilhas(); + } + + public async Task CarregarTrilhas(Trilha trilha = null) + { + List list = await Servico.BuscarTrilhas(); + Trilhas = new ObservableCollection(list); + await CarregarTrilha((trilha != null) ? ((IEnumerable)Trilhas).FirstOrDefault((Func)((Trilha x) => ((DomainBase)x).Id == ((DomainBase)trilha).Id)) : list.FirstOrDefault()); + } + + public async Task CarregarTrilha(Trilha trilha) + { + if (trilha == null || ((DomainBase)trilha).Id == 0L) + { + return; + } + SelectedTrilha = trilha; + List tarefas = await Servico.BuscarTarefas(((DomainBase)trilha).Id); + List obj = await Servico.BuscarFases(((DomainBase)trilha).Id); + Fases = new ObservableCollection(); + obj.ForEach(delegate(Fase x) + { + x.Tarefas = tarefas.Where((Tarefa t) => (SelectedUsuario == null || ((DomainBase)SelectedUsuario).Id == 0L || ((DomainBase)SelectedUsuario).Id == ((DomainBase)t.Usuario).Id) && ((DomainBase)t.Fase).Id == ((DomainBase)x).Id && (int)t.Status != 2).ToList(); + Fases.Add(x); + }); + } + + public void Excluir(Fase origem, Tarefa data) + { + Tarefa item = Fases.First((Fase x) => ((DomainBase)x).Id == ((DomainBase)origem).Id).Tarefas.First((Tarefa x) => ((DomainBase)x).Id == ((DomainBase)data).Id); + Fases.First((Fase x) => ((DomainBase)x).Id == ((DomainBase)origem).Id).Tarefas.Remove(item); + } + + public async Task Excluir(Tarefa tarefa) + { + if (((DomainBase)tarefa).Id != 0L && await ShowMessage("DESEJA REALMENTE EXCLUIR A TAREFA " + tarefa.Titulo + "?" + Environment.NewLine + "ESSE PROCEDIMENTO É IRREVERSÍVEL", "SIM", "NÃO")) + { + if (!(await Servico.Excluir(((DomainBase)tarefa).Id))) + { + Alterar(alterar: false); + return; + } + await CarregarTrilha(SelectedTrilha); + Alterar(alterar: false); + } + } + + public void Inserir(Fase origem, Tarefa data, int index, bool aberto = false) + { + data.Aberto = aberto; + data.Fase = origem; + Fases.First((Fase x) => ((DomainBase)x).Id == ((DomainBase)origem).Id).Tarefas.Insert((index != -1) ? index : 0, data); + TrocarFase(data); + } + + public void Update() + { + Fases = new ObservableCollection(Fases); + } + + public async Task>> Salvar(Tarefa destino) + { + destino.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45); + List> list = destino.Validate(); + if (list.Count > 0) + { + return list; + } + await Servico.Salvar(destino); + if (!Servico.Sucesso) + { + return null; + } + await CarregarTrilha(SelectedTrilha); + return null; + } + + public async Task Salvar(Trilha destino) + { + SelectedTrilha = null; + Fases = null; + List fases = destino.Fases; + Trilha trilha = await Servico.Salvar(destino); + if (!Servico.Sucesso) + { + return; + } + if (fases != null) + { + fases.ForEach(delegate(Fase x) + { + x.Trilha = trilha; + }); + await Servico.Salvar(fases); + if (!Servico.Sucesso) + { + return; + } + } + await CarregarTrilhas(trilha); + } + + public async Task Cancelar() + { + await CarregarTrilha(SelectedTrilha); + Alterar(alterar: false); + } + + private async void TrocarFase(Tarefa tarefa) + { + await Servico.Salvar(tarefa); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels/TutorialViewModel.cs b/Decompiler/Gestor.Application.ViewModels/TutorialViewModel.cs new file mode 100644 index 0000000..8cd84c8 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/TutorialViewModel.cs @@ -0,0 +1,480 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Security; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; + +namespace Gestor.Application.ViewModels; + +public class TutorialViewModel : BaseViewModel +{ + private bool _fase1; + + private bool _fase2; + + private bool _fase3; + + private string _mensagem = "ESTAMOS PREPARANDO TUDO PRA VOCÊ INICIAR"; + + private string _nome; + + private string _usuario; + + private string _senha; + + private string _confirmacaoSenha; + + private ObservableCollection _seguradoras = new ObservableCollection(); + + private ObservableCollection _ramos = new ObservableCollection(); + + private bool _loadingVisibility; + + public bool Fase1 + { + get + { + return _fase1; + } + set + { + _fase1 = value; + OnPropertyChanged("Fase1"); + } + } + + public bool Fase2 + { + get + { + return _fase2; + } + set + { + _fase2 = value; + OnPropertyChanged("Fase2"); + } + } + + public bool Fase3 + { + get + { + return _fase3; + } + set + { + _fase3 = value; + OnPropertyChanged("Fase3"); + } + } + + public string Mensagem + { + get + { + return _mensagem; + } + set + { + _mensagem = value; + OnPropertyChanged("Mensagem"); + } + } + + private long _idUsuario { get; set; } = -1L; + + + public string Nome + { + get + { + return _nome; + } + set + { + _nome = value; + OnPropertyChanged("Nome"); + } + } + + public string Usuario + { + get + { + return _usuario; + } + set + { + _usuario = value; + OnPropertyChanged("Usuario"); + } + } + + public string Senha + { + get + { + return _senha; + } + set + { + _senha = value; + OnPropertyChanged("Senha"); + } + } + + public string ConfirmacaoSenha + { + get + { + return _confirmacaoSenha; + } + set + { + _confirmacaoSenha = value; + OnPropertyChanged("ConfirmacaoSenha"); + } + } + + public ObservableCollection Seguradoras + { + get + { + return _seguradoras; + } + set + { + _seguradoras = value; + OnPropertyChanged("Seguradoras"); + } + } + + public ObservableCollection Ramos + { + get + { + return _ramos; + } + set + { + _ramos = value; + OnPropertyChanged("Ramos"); + } + } + + private Customer Empresa { get; set; } + + public bool LoadingVisibility + { + get + { + return _loadingVisibility; + } + set + { + _loadingVisibility = value; + OnPropertyChanged("LoadingVisibility"); + } + } + + public TutorialViewModel() + { + base.EnableFields = true; + } + + public async Task IniciarConfiguracoes() + { + base.EnableButtons = false; + ConnectionHelper connectionHelper = new ConnectionHelper(); + EmpresaServico servicoEmpresa = new EmpresaServico(); + Empresa savedEmpresa = await servicoEmpresa.BuscarEmpresaPorId(1L); + Empresa = await Connection.Get($"Customer/{ApplicationHelper.IdFornecedor}"); + if (savedEmpresa == null) + { + await servicoEmpresa.Save(Empresa); + } + BaseServico servico = new BaseServico(); + ControleArquivoDigital val = (ControleArquivoDigital)(((object)(await servico.BuscarControle())) ?? ((object)new ControleArquivoDigital + { + Catalogo = Connection.Catalog, + Tabela = "Arquivos" + })); + if (((DomainBase)val).Id == 0L) + { + await servico.SalvarControle(val); + } + VendedorServico vendedorServico = new VendedorServico(); + Vendedor val2 = (Vendedor)(((object)(await vendedorServico.BuscarCorretora())) ?? ((object)new Vendedor + { + IdEmpresa = 1L, + Nome = Empresa.Name, + Ativo = true, + Corretora = true + })); + if (((DomainBase)val2).Id == 0L) + { + Repasse repasse = new Repasse + { + Forma = (FormaRepasse)1, + Incidencia = (TipoIncidencia)1, + Ativo = true, + Tipo = (TipoRepasse)2, + ValorNovo = 0m, + ValorRenovacao = 0m + }; + await vendedorServico.Save(val2, repasse); + if (!vendedorServico.Sucesso) + { + return; + } + } + await new ArquivoDigitalServico().Criar(); + string text = await connectionHelper.AtualizarBanco(); + if (text != null) + { + await ShowMessage(text); + return; + } + List seguradora = await new SeguradoraServico().BuscarSeguradoras(); + List source = await new RamoServico().BuscarRamos(); + Seguradoras = new ObservableCollection(seguradora.OrderBy((Seguradora x) => x.Nome)); + Ramos = new ObservableCollection(source.OrderBy((Ramo x) => x.Nome)); + base.EnableButtons = true; + } + + public async Task ValidarLogin() + { + Fase1 = false; + Mensagem = "ESTAMOS VALIDANDO AS INFORMAÇÕES"; + if (string.IsNullOrEmpty(Usuario) || string.IsNullOrEmpty(Senha) || string.IsNullOrEmpty(ConfirmacaoSenha) || string.IsNullOrEmpty(Nome)) + { + await ShowMessage("NECESSÁRIO PREENCHER O NOME COMPLETO, USUÁRIO, SENHA E CONFIRMAÇÃO DA SENHA PARA PROSSEGUIR."); + Fase1 = true; + return true; + } + if (!string.IsNullOrEmpty(Usuario) && !Regex.IsMatch(Usuario, "^(?!.*(@.*@|@\\.|\\.@|--|\\.\\.|-\\.|\\.-|-@|@-))[a-zA-Z0-9](?:[a-zA-Z0-9@.-]*[a-zA-Z0-9])?(?: [a-zA-Z0-9](?:[a-zA-Z0-9@.-]*[a-zA-Z0-9])?)?$")) + { + await ShowMessage("USUÁRIO DEVE CONTER APENAS LETRAS E NÚMEROS," + Environment.NewLine + "NÃO DEVE CONTER MAIS DE UM ESPAÇO," + Environment.NewLine + "NÃO DEVE TER ESPAÇO NO INICIO E NO FIM." + Environment.NewLine + "EXEMPLO VALIDO:" + Environment.NewLine + "USUARIO01 OU USUARIO 02 OU USUARIO.03"); + Fase1 = true; + return true; + } + if (Usuario.Length > 30) + { + await ShowMessage("USUÁRIO SOMENTE DEVE CONTER NO MÁXIMO 30 CARACTERES"); + Fase1 = true; + return true; + } + if (Senha != ConfirmacaoSenha) + { + await ShowMessage("A SENHA E A CONFIRMAÇÃO DA SENHA ESTÃO DIFERENTES, CORRIJA PARA PROSSEGUIR."); + Fase1 = true; + return true; + } + if (!(await UsuarioInicial())) + { + return false; + } + while (Seguradoras.Count == 0) + { + await Task.Delay(25); + } + Fase1 = false; + Fase2 = true; + return true; + } + + public async Task CriarBanco() + { + string text = await new ConnectionHelper().VerifyConnection(); + if (text == null) + { + Instancia.ExcluirCfg(); + return await VerificaEmpresa(); + } + return text; + } + + public async Task VerificaEmpresa() + { + ConnectionHelper connectionHelper = new ConnectionHelper(); + Empresa = await Connection.Get($"Customer/{ApplicationHelper.IdFornecedor}"); + EmpresaServico servico = new EmpresaServico(); + if (!connectionHelper.ExisteEmpresa()) + { + await servico.Save(Empresa); + if (!servico.Sucesso) + { + return "ERRO AO CRIAR BANCO DE DADOS"; + } + } + else if (!connectionHelper.BDConvertido()) + { + return "HOUVE UM ERRO NO ACESSO! REINICIE O SISTEMA!"; + } + return null; + } + + public void DesativarRamos() + { + foreach (Ramo ramo in Ramos) + { + ramo.Ativo = false; + } + Ramos = new ObservableCollection(Ramos); + } + + public void DesativarSeguradoras() + { + foreach (Seguradora seguradora in Seguradoras) + { + seguradora.Ativo = false; + } + Seguradoras = new ObservableCollection(Seguradoras); + } + + public async Task Concluir() + { + Fase3 = false; + if (Ramos.All((Ramo x) => !x.Ativo)) + { + await ShowMessage("NECESSÁRIO AO MENOS UM RAMO ATIVO PARA PROSSEGUIR."); + Fase3 = true; + return false; + } + Mensagem = "ESTAMOS TERMINANDO AS CONFIGURAÇÕES INICIAIS E LOGO MAIS VOCÊ PODERÁ UTILIZAR."; + if (!(await UsuarioInicial())) + { + return false; + } + SeguradoraServico seguradoraServico = new SeguradoraServico(); + foreach (Seguradora seguradora in Seguradoras) + { + await seguradoraServico.Save(seguradora, null, primeiroAcesso: true); + if (!seguradoraServico.Sucesso) + { + return false; + } + } + RamoServico ramoServico = new RamoServico(); + foreach (Ramo ramo in Ramos) + { + await ramoServico.Save(ramo, null); + if (!ramoServico.Sucesso) + { + return false; + } + } + await new BaseServico().LoadInicialParameters(); + return true; + } + + public async Task UsuarioInicial() + { + Usuario val = await new UsuarioServico().BuscaUsuarioInicial(Usuario, Senha); + if (val == null) + { + await ShowMessage("USUÁRIO JÁ EXISTE E A SENHA ESTÁ INCORRETA, REINICIE O SISTEMA!"); + return false; + } + await SalvarUsuario(val); + return true; + } + + private async Task SalvarUsuario(Usuario verificaUsuario) + { + _idUsuario = ((verificaUsuario != null) ? ((DomainBase)verificaUsuario).Id : 0); + Usuario val = new Usuario + { + Id = _idUsuario, + Nome = Nome, + Login = Usuario, + Senha = new Token().AggerEncrypt(Senha), + Administrador = true, + Excluido = false, + IdEmpresa = 1L, + PermissaoAggilizador = 1L + }; + val.SsoId = ((verificaUsuario != null) ? verificaUsuario.SsoId : null); + Usuario usuario = val; + usuario = await new UsuarioServico().Save(usuario); + _idUsuario = ((DomainBase)usuario).Id; + Recursos.Usuario = usuario; + } + + public async Task ValidarSeguradoras() + { + Fase2 = false; + if (Seguradoras.All((Seguradora x) => !x.Ativo)) + { + await ShowMessage("NECESSÁRIO AO MENOS UMA SEGURADORA ATIVA PARA PROSSEGUIR."); + Fase2 = true; + } + else + { + Fase2 = false; + Fase3 = true; + } + } + + public async Task VerificarUsuario() + { + Instancia.ExcluirCfg(); + Usuario val = await new UsuarioServico().BuscarUsuarioPorId(1L); + if (val != null) + { + Nome = val.Nome; + Usuario = val.Login; + _idUsuario = ((DomainBase)val).Id; + } + } + + public async Task VerificaAcesso() + { + LicenseHelper license = new LicenseHelper(); + bool registrar = false; + if (!(await license.VerificarMaquina())) + { + Loading(isLoading: false); + while (!registrar) + { + List licencas = await license.GetInstalacoes(); + if (licencas.Count == 0) + { + await ShowMessage("ACESSO NEGADO, NÃO EXISTEM LICENÇAS VÁLIDAS."); + return false; + } + Instalacao instalacaoUsuario = ((IEnumerable)licencas.OrderByDescending((Instalacao x) => x.UltimoAcesso)).FirstOrDefault((Func)((Instalacao x) => x.UsuarioId == ((DomainBase)Recursos.Usuario).Id)); + bool flag = instalacaoUsuario != null; + if (flag) + { + flag = await ShowMessage("SEU ULTIMO ACESSO FOI NA MAQUINA " + instalacaoUsuario.NomeMaquina + ". DESEJA SUBSTITUIR A LICENÇA PARA ESSA MAQUINA?", "SIM", "NÃO"); + } + Instalacao val = ((!flag) ? (await ShowInstalacoes(licencas)) : instalacaoUsuario); + Instalacao val2 = val; + if (val2 == null) + { + await ShowMessage("MÁQUINA NÃO REGISTRADA"); + return false; + } + await new AjudaServico().ExcluirInstalacao(((DomainBase)val2).Id); + registrar = await license.VerificarMaquina(); + } + } + return true; + } +} -- cgit v1.2.3