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 --- .../AdiantamentoViewModel.cs | 248 ++ .../AgendaViewModel.cs | 406 +++ .../ArquivoDigitalViewModel.cs | 1229 +++++++++ .../ExpedicaoViewModel.cs | 164 ++ .../ExtratosViewModel.cs | 2773 ++++++++++++++++++++ .../ImpostoViewModel.cs | 314 +++ .../InfoViewModel.cs | 175 ++ .../LogAcaoViewModel.cs | 97 + .../LogEmailViewModel.cs | 161 ++ .../LogSistemaAntigoViewModel.cs | 36 + .../LogViewModel.cs | 1458 ++++++++++ .../MetaSeguradoraViewModel.cs | 212 ++ .../MetaVendedorViewModel.cs | 209 ++ .../PermissaoUsuarioViewModel.cs | 1704 ++++++++++++ .../TarefaDrawerViewModel.cs | 1064 ++++++++ .../ValoresApoliceViewModel.cs | 306 +++ .../ValoresParcelaViewModel.cs | 490 ++++ .../VinculoVendedorViewModel.cs | 258 ++ 18 files changed, 11304 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/AdiantamentoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/AgendaViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ArquivoDigitalViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/LogAcaoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/LogEmailViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/LogSistemaAntigoViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/LogViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/MetaVendedorViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/PermissaoUsuarioViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ValoresApoliceViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs create mode 100644 Decompiler/Gestor.Application.ViewModels.Drawer/VinculoVendedorViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer') diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/AdiantamentoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/AdiantamentoViewModel.cs new file mode 100644 index 0000000..06cd656 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/AdiantamentoViewModel.cs @@ -0,0 +1,248 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Assinador.Infrastructure.Helpers; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class AdiantamentoViewModel : BaseSegurosViewModel +{ + private readonly AdiantamentoServico _servico; + + private readonly Vendedor _selectedVendedor; + + private bool _carregando; + + private ObservableCollection _adiantamento = new ObservableCollection(); + + private Adiantamento _selectedAdiantamento = new Adiantamento(); + + private bool _logEnabled; + + public Adiantamento CancelAdiantamento; + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public ObservableCollection Adiantamento + { + get + { + return _adiantamento; + } + set + { + _adiantamento = value; + OnPropertyChanged("Adiantamento"); + } + } + + public Adiantamento SelectedAdiantamento + { + get + { + return _selectedAdiantamento; + } + set + { + _selectedAdiantamento = value; + CancelAdiantamento = ((value != null && ((DomainBase)value).Id > 0) ? value : CancelAdiantamento); + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedAdiantamento"); + } + } + + public bool LogEnabled + { + get + { + return _logEnabled; + } + set + { + _logEnabled = value; + OnPropertyChanged("LogEnabled"); + } + } + + public AdiantamentoViewModel(Vendedor vendedor) + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_0016: Expected O, but got Unknown + _servico = new AdiantamentoServico(); + Seleciona(vendedor); + _selectedVendedor = vendedor; + } + + private async void Seleciona(Vendedor vendedor) + { + Loading(isLoading: true); + await PermissaoTela((TipoTela)15); + await SelecionaAdiantamento(vendedor); + Loading(isLoading: false); + } + + public void SelecionaAdiantamento(Adiantamento adiantamento) + { + SelectedAdiantamento = adiantamento; + } + + private async Task SelecionaAdiantamento(Vendedor vendedor) + { + Carregando = true; + List list = (from x in await new BaseServico().BuscarAdiantamentoAsync(vendedor) + orderby x.Pago, x.Valor + select x).ToList(); + Adiantamento = new ObservableCollection(list); + if (Adiantamento.Count > 0) + { + SelecionaAdiantamento(Adiantamento.First()); + LogEnabled = true; + } + else + { + SelectedAdiantamento = new Adiantamento(); + LogEnabled = false; + Alterar(alterar: false); + VerificarEnables(((DomainBase)SelectedAdiantamento).Id); + base.EnableMenu = false; + } + Carregando = false; + } + + public void Incluir() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + Adiantamento selectedAdiantamento = new Adiantamento(); + SelectedAdiantamento = selectedAdiantamento; + Alterar(alterar: true); + } + + public async Task>> Salvar() + { + if (string.IsNullOrWhiteSpace(SelectedAdiantamento.Historico)) + { + return new List> + { + new KeyValuePair("Historico|HISTÓRICO", "OBRIGATÓRIO") + }; + } + SelectedAdiantamento.Vendedor = _selectedVendedor; + string acao = ((((DomainBase)SelectedAdiantamento).Id == 0L) ? "INCLUIU" : "ALTEROU"); + Adiantamento value = await _servico.Save(SelectedAdiantamento); + if (!_servico.Sucesso) + { + return null; + } + RegistrarAcao(acao + " ADIANTAMENTO DO VENDEDOR \"" + value.Vendedor.Nome + "\"", ((DomainBase)value).Id, (TipoTela)36, string.Format("ID: {0}\nDATA: {1}\nVALOR: {2:c}\nTIPO PAGAMENTO: {3}\nPAGO: {4}", ((DomainBase)value).Id, (!value.Data.HasValue) ? "-" : $"{value.Data:d}", value.Valor, Functions.GetDescription((Enum)(object)value.TipoPagamento), value.Pago ? "SIM" : "NÃO")); + if (Adiantamento.Any((Adiantamento x) => ((DomainBase)x).Id == ((DomainBase)value).Id)) + { + DomainBase.Copy(Adiantamento.First((Adiantamento x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value); + } + else + { + Adiantamento.Add(value); + } + Adiantamento = new ObservableCollection(Adiantamento); + SelectedAdiantamento = Adiantamento.First((Adiantamento x) => ((DomainBase)x).Id == ((DomainBase)value).Id); + LogEnabled = true; + Alterar(alterar: false); + return null; + } + + public void CancelarAlteracao() + { + Carregando = true; + if (CancelAdiantamento != null && Adiantamento.Any((Adiantamento x) => ((DomainBase)x).Id == ((DomainBase)CancelAdiantamento).Id)) + { + DomainBase.Copy(Adiantamento.First((Adiantamento x) => ((DomainBase)x).Id == ((DomainBase)CancelAdiantamento).Id), CancelAdiantamento); + SelectedAdiantamento = Adiantamento.First((Adiantamento x) => ((DomainBase)x).Id == ((DomainBase)CancelAdiantamento).Id); + } + Alterar(alterar: false); + Carregando = false; + } + + public async Task Excluir() + { + if (SelectedAdiantamento == null || ((DomainBase)SelectedAdiantamento).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + if (!(await _servico.Delete(SelectedAdiantamento))) + { + return false; + } + RegistrarAcao("EXCLUIU O ADIANTAMENTO DO VENDEDOR \"" + SelectedAdiantamento.Vendedor.Nome + "\"", ((DomainBase)SelectedAdiantamento).Id, (TipoTela)36, string.Format("ID: {0}\nDATA: {1}\nVALOR: {2:c}\nTIPO PAGAMENTO: {3}\nPAGO: {4}", ((DomainBase)SelectedAdiantamento).Id, (!SelectedAdiantamento.Data.HasValue) ? "-" : $"{SelectedAdiantamento.Data:d}", SelectedAdiantamento.Valor, Functions.GetDescription((Enum)(object)SelectedAdiantamento.TipoPagamento), SelectedAdiantamento.Pago ? "SIM" : "NÃO")); + int num = Adiantamento.IndexOf(SelectedAdiantamento); + Adiantamento.Remove(SelectedAdiantamento); + Adiantamento.Remove(SelectedAdiantamento); + Adiantamento = new ObservableCollection(Adiantamento); + if (Adiantamento.Count > 0) + { + SelectedAdiantamento = ((num < Adiantamento.Count) ? Adiantamento.ElementAt(num) : Adiantamento.Last()); + LogEnabled = true; + } + else + { + SelectedAdiantamento = new Adiantamento(); + Alterar(alterar: false); + base.EnableMenu = false; + LogEnabled = false; + } + if (Adiantamento.Count > 0) + { + SelecionaAdiantamento((num < Adiantamento.Count) ? Adiantamento.ElementAt(num) : Adiantamento.Last()); + LogEnabled = true; + } + else + { + SelectedAdiantamento = new Adiantamento(); + LogEnabled = false; + Alterar(alterar: false); + } + Carregando = false; + return true; + } + + public async Task CarregarAdiantamento(int index) + { + Carregando = true; + Adiantamento = new ObservableCollection(await _servico.BuscarAdiantamentos(((DomainBase)_selectedVendedor).Id, index != 0)); + if (Adiantamento != null && Adiantamento.Count > 0) + { + SelectedAdiantamento = Adiantamento.First(); + LogEnabled = true; + } + else + { + LogEnabled = false; + } + Carregando = false; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/AgendaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/AgendaViewModel.cs new file mode 100644 index 0000000..57aebe2 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/AgendaViewModel.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; + +namespace Gestor.Application.ViewModels.Drawer; + +public class AgendaViewModel : BaseSegurosViewModel +{ + private readonly AgendaServico _servico; + + private Agenda _selectedAgenda; + + private ObservableCollection _telefones = new ObservableCollection(); + + private ObservableCollection _emails = new ObservableCollection(); + + private long _ultimoId; + + public Agenda CancelAgenda; + + private ObservableCollection _agendasFiltradas = new ObservableCollection(); + + private bool _carregando; + + public Agenda SelectedAgenda + { + get + { + return _selectedAgenda; + } + set + { + _selectedAgenda = value; + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedAgenda"); + } + } + + public ObservableCollection Telefones + { + get + { + return _telefones; + } + set + { + _telefones = value; + OnPropertyChanged("Telefones"); + } + } + + public ObservableCollection Emails + { + get + { + return _emails; + } + set + { + _emails = value; + OnPropertyChanged("Emails"); + } + } + + public ObservableCollection AgendasFiltradas + { + get + { + return _agendasFiltradas; + } + set + { + _agendasFiltradas = value; + OnPropertyChanged("AgendasFiltradas"); + } + } + + public List Agendas { get; set; } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public AgendaViewModel() + { + _servico = new AgendaServico(); + Seleciona(); + } + + private async void Seleciona() + { + Loading(isLoading: true); + await PermissaoTela((TipoTela)34); + await SelecionaAgendas(); + Loading(isLoading: false); + } + + private async Task SelecionaAgendas() + { + Carregando = true; + Agendas = (await new BaseServico().BuscarAgendasAsync()).OrderBy((Agenda x) => x.Nome).ToList(); + AgendasFiltradas = new ObservableCollection(Agendas); + SelectedAgenda = (Agenda)((AgendasFiltradas.Count > 0) ? ((object)AgendasFiltradas.First()) : ((object)new Agenda())); + Carregando = false; + } + + public void IncluirTelefone() + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Expected O, but got Unknown + if (SelectedAgenda != null) + { + if (Telefones == null) + { + Telefones = new ObservableCollection(); + } + AgendaTelefone item = new AgendaTelefone + { + Agenda = SelectedAgenda, + Tipo = (TipoTelefone)1 + }; + Telefones.Add(item); + OnPropertyChanged("IncluirTelefone"); + } + } + + public void ExcluirEmail(AgendaEmail email) + { + Emails.Remove(email); + } + + public void IncluirEmail() + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Expected O, but got Unknown + if (SelectedAgenda != null) + { + if (Emails == null) + { + Emails = new ObservableCollection(); + } + AgendaEmail item = new AgendaEmail + { + Agenda = SelectedAgenda + }; + Emails.Add(item); + OnPropertyChanged("IncluirEmail"); + } + } + + public void ExcluirTelefone(AgendaTelefone telefone) + { + Telefones.Remove(telefone); + } + + public void Incluir() + { + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_0024: Expected O, but got Unknown + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_003c: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Expected O, but got Unknown + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Expected O, but got Unknown + if (SelectedAgenda != null) + { + _ultimoId = ((DomainBase)SelectedAgenda).Id; + } + SelectedAgenda = new Agenda(); + Telefones = new ObservableCollection + { + new AgendaTelefone + { + Agenda = SelectedAgenda, + Tipo = (TipoTelefone)1 + } + }; + Emails = new ObservableCollection + { + new AgendaEmail + { + Agenda = SelectedAgenda + } + }; + Alterar(alterar: true); + } + + public async Task>> Salvar() + { + List> list = SelectedAgenda.Validate(); + List list2 = Telefones.Where((AgendaTelefone x) => !string.IsNullOrEmpty(((TelefoneBase)x).Numero)).ToList(); + List list3 = Emails.Where((AgendaEmail x) => !string.IsNullOrEmpty(((EmailBase)x).Email)).ToList(); + foreach (AgendaTelefone item in list2) + { + list.AddRange(item.Validate()); + } + foreach (AgendaEmail item2 in list3) + { + list.AddRange(item2.Validate()); + } + if (list.Count > 0) + { + return list; + } + SelectedAgenda.Telefones = new ObservableCollection(list2); + SelectedAgenda.Emails = new ObservableCollection(list3); + if (((DomainBase)SelectedAgenda).Id == 0L) + { + SelectedAgenda = await _servico.Save(SelectedAgenda); + if (!_servico.Sucesso) + { + return null; + } + Telefones = new ObservableCollection(SelectedAgenda.Telefones); + Emails = new ObservableCollection(SelectedAgenda.Emails); + Agendas.Add(SelectedAgenda); + AgendasFiltradas.Insert((_ultimoId != 0L) ? AgendasFiltradas.IndexOf(AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == _ultimoId)) : 0, SelectedAgenda); + } + else + { + SelectedAgenda = await _servico.Save(SelectedAgenda); + if (!_servico.Sucesso) + { + return null; + } + Telefones = new ObservableCollection(SelectedAgenda.Telefones); + Emails = new ObservableCollection(SelectedAgenda.Emails); + DomainBase.Copy(Agendas.First((Agenda x) => ((DomainBase)x).Id == ((DomainBase)SelectedAgenda).Id), SelectedAgenda); + if (AgendasFiltradas.Count > 0 && AgendasFiltradas.Any((Agenda x) => ((DomainBase)x).Id == ((DomainBase)SelectedAgenda).Id)) + { + DomainBase.Copy(AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == ((DomainBase)SelectedAgenda).Id), SelectedAgenda); + } + else + { + AgendasFiltradas.Add(SelectedAgenda); + } + } + AgendasFiltradas = new ObservableCollection(AgendasFiltradas); + SelectedAgenda = AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == ((DomainBase)SelectedAgenda).Id); + Alterar(alterar: false); + return null; + } + + public void CancelarAlteracao() + { + //IL_00cc: Unknown result type (might be due to invalid IL or missing references) + //IL_00d6: Expected O, but got Unknown + //IL_00dd: 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_00ee: Unknown result type (might be due to invalid IL or missing references) + //IL_00ff: Expected O, but got Unknown + //IL_010b: Unknown result type (might be due to invalid IL or missing references) + //IL_0110: Unknown result type (might be due to invalid IL or missing references) + //IL_0121: Expected O, but got Unknown + Carregando = true; + if (((DomainBase)SelectedAgenda).Id == 0L) + { + if (AgendasFiltradas.Count > 0 && AgendasFiltradas.Any((Agenda x) => ((DomainBase)x).Id == _ultimoId)) + { + SelectedAgenda = AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == _ultimoId); + } + else + { + if (Agendas.Count <= 0 || !Agendas.Any((Agenda x) => ((DomainBase)x).Id == _ultimoId)) + { + SelectedAgenda = new Agenda(); + Telefones = new ObservableCollection + { + new AgendaTelefone + { + Agenda = SelectedAgenda, + Tipo = (TipoTelefone)1 + } + }; + Emails = new ObservableCollection + { + new AgendaEmail + { + Agenda = SelectedAgenda + } + }; + Alterar(alterar: false); + Carregando = false; + return; + } + AgendasFiltradas.Add(Agendas.First((Agenda x) => ((DomainBase)x).Id == _ultimoId)); + SelectedAgenda = AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == _ultimoId); + } + } + else + { + DomainBase.Copy(Agendas.First((Agenda x) => ((DomainBase)x).Id == ((DomainBase)CancelAgenda).Id), CancelAgenda); + if (AgendasFiltradas.Count > 0 && AgendasFiltradas.Any((Agenda x) => ((DomainBase)x).Id == ((DomainBase)CancelAgenda).Id)) + { + DomainBase.Copy(AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == ((DomainBase)CancelAgenda).Id), CancelAgenda); + } + else + { + AgendasFiltradas.Add(CancelAgenda); + } + AgendasFiltradas = new ObservableCollection(AgendasFiltradas); + SelectedAgenda = AgendasFiltradas.First((Agenda x) => ((DomainBase)x).Id == ((DomainBase)CancelAgenda).Id); + } + Alterar(alterar: false); + Carregando = false; + } + + public async Task Excluir() + { + if (SelectedAgenda == null || ((DomainBase)SelectedAgenda).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + if (!(await _servico.Delete(SelectedAgenda))) + { + Alterar(alterar: false); + Carregando = false; + return false; + } + int num = AgendasFiltradas.IndexOf(SelectedAgenda); + Agendas.Remove(SelectedAgenda); + AgendasFiltradas.Remove(SelectedAgenda); + AgendasFiltradas = new ObservableCollection(AgendasFiltradas); + if (AgendasFiltradas.Count > 0) + { + if (num >= AgendasFiltradas.Count) + { + await SelecionaAgenda(AgendasFiltradas.Last()); + } + else + { + await SelecionaAgenda(AgendasFiltradas.ElementAt(num)); + } + } + else + { + SelectedAgenda = new Agenda(); + Telefones = new ObservableCollection(); + Emails = new ObservableCollection(); + Alterar(alterar: false); + } + Carregando = false; + return true; + } + + internal async Task> Filtrar(string value) + { + return await Task.Run(() => FiltrarAgenda(value)); + } + + public List FiltrarAgenda(string filter) + { + AgendasFiltradas = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection(Agendas) : new ObservableCollection(from x in Agendas + where ValidationHelper.RemoveDiacritics(x.Nome.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) + orderby x.Nome + select x)); + return AgendasFiltradas.ToList(); + } + + public async Task SelecionaAgenda(Agenda agenda = null) + { + Carregando = true; + SelectedAgenda = ((agenda == null) ? AgendasFiltradas.FirstOrDefault() : ((IEnumerable)AgendasFiltradas).FirstOrDefault((Func)((Agenda x) => ((DomainBase)x).Id == ((DomainBase)agenda).Id))); + if (SelectedAgenda != null) + { + Emails = await _servico.BuscarEmailsAsync(((DomainBase)SelectedAgenda).Id); + Telefones = await _servico.BuscarTelefonesAsync(((DomainBase)SelectedAgenda).Id); + } + else + { + Emails = null; + Telefones = null; + } + Carregando = false; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ArquivoDigitalViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ArquivoDigitalViewModel.cs new file mode 100644 index 0000000..a25f375 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ArquivoDigitalViewModel.cs @@ -0,0 +1,1229 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Assinador.Model.Domain; +using CsQuery.ExtensionMethods.Internal; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Application.Views.Ferramentas; +using Gestor.Common.Security; +using Gestor.Common.Validation; +using Gestor.Model.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.MalaDireta; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.Helper; +using Gestor.Model.License; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ArquivoDigitalViewModel : BaseSegurosViewModel +{ + private readonly ClienteServico _servico; + + private Visibility _assinarVisibility = (Visibility)2; + + private Visibility _visibilityWhatsApp = (Visibility)2; + + private bool _carregando; + + private bool _activated = true; + + private bool _adDocumento; + + private Visibility _adDocumentoVisibility; + + private bool _isVisibleSalvar; + + private Visibility _enviarSelecionadosVisibility; + + private Cliente _selectedCliente = new Cliente(); + + private ObservableCollection _telefones = new ObservableCollection(); + + private ObservableCollection _arquivos = new ObservableCollection(); + + private ObservableCollection _arquivosTela = new ObservableCollection(); + + private IndiceArquivoDigital _selectedArquivo = new IndiceArquivoDigital(); + + private ObservableCollection _arquivosAnexados = new ObservableCollection(); + + private ArquivoDigital _selectedAnexado = new ArquivoDigital(); + + private string _titulo = ""; + + private ObservableCollection _emails = new ObservableCollection(); + + private string _assunto; + + private string _corpo; + + private string _nome; + + private string _documento; + + private string _email; + + private string _licencas; + + private string _assinadorKey; + + private FiltroArquivoDigital Filtro { get; } + + public Visibility AssinarVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _assinarVisibility; + } + 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) + _assinarVisibility = value; + OnPropertyChanged("AssinarVisibility"); + } + } + + public Visibility VisibilityWhatsApp + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityWhatsApp; + } + 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) + _visibilityWhatsApp = value; + OnPropertyChanged("VisibilityWhatsApp"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + OnPropertyChanged("Carregando"); + } + } + + public bool Activated + { + get + { + return _activated; + } + set + { + _activated = value; + OnPropertyChanged("Activated"); + } + } + + public bool AdDocumento + { + get + { + return _adDocumento; + } + set + { + _adDocumento = value; + CarregarArquivos(); + OnPropertyChanged("AdDocumento"); + } + } + + public Visibility AdDocumentoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _adDocumentoVisibility; + } + 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) + _adDocumentoVisibility = value; + OnPropertyChanged("AdDocumentoVisibility"); + } + } + + public bool IsVisibleSalvar + { + get + { + return _isVisibleSalvar; + } + set + { + _isVisibleSalvar = value; + OnPropertyChanged("IsVisibleSalvar"); + } + } + + public Visibility EnviarSelecionadosVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _enviarSelecionadosVisibility; + } + set + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + _enviarSelecionadosVisibility = (Visibility)(Restricao((TipoRestricao)20) ? 2 : ((int)value)); + OnPropertyChanged("EnviarSelecionadosVisibility"); + } + } + + public Cliente SelectedCliente + { + get + { + return _selectedCliente; + } + set + { + _selectedCliente = value; + OnPropertyChanged("SelectedCliente"); + } + } + + public ObservableCollection Telefones + { + get + { + return _telefones; + } + set + { + _telefones = value; + OnPropertyChanged("Telefones"); + } + } + + public ObservableCollection Arquivos + { + get + { + return _arquivos; + } + set + { + _arquivos = value; + ArquivosTela = value; + OnPropertyChanged("Arquivos"); + } + } + + public ObservableCollection ArquivosTela + { + get + { + return _arquivosTela; + } + set + { + _arquivosTela = value; + OnPropertyChanged("ArquivosTela"); + } + } + + public IndiceArquivoDigital SelectedArquivo + { + get + { + return _selectedArquivo; + } + set + { + _selectedArquivo = value; + OnPropertyChanged("SelectedArquivo"); + } + } + + public ObservableCollection ArquivosAnexados + { + get + { + return _arquivosAnexados; + } + set + { + _arquivosAnexados = value; + IsVisibleSalvar = value != null && value.Count > 0; + OnPropertyChanged("ArquivosAnexados"); + } + } + + public ArquivoDigital SelectedAnexado + { + get + { + return _selectedAnexado; + } + set + { + _selectedAnexado = value; + OnPropertyChanged("SelectedAnexado"); + } + } + + public string Titulo + { + get + { + return _titulo; + } + set + { + _titulo = value; + OnPropertyChanged("Titulo"); + } + } + + public ObservableCollection Emails + { + get + { + return _emails; + } + set + { + _emails = value; + OnPropertyChanged("Emails"); + } + } + + public string Assunto + { + get + { + return _assunto; + } + set + { + _assunto = value; + OnPropertyChanged("Assunto"); + } + } + + public string Corpo + { + get + { + return _corpo; + } + set + { + _corpo = value; + OnPropertyChanged("Corpo"); + } + } + + public string Nome + { + get + { + return _nome; + } + set + { + _nome = value; + OnPropertyChanged("Nome"); + } + } + + public string Documento + { + get + { + return _documento; + } + set + { + _documento = value; + OnPropertyChanged("Documento"); + } + } + + public string Email + { + get + { + return _email; + } + set + { + _email = value?.Trim(); + OnPropertyChanged("Email"); + } + } + + public string Licencas + { + get + { + return _licencas; + } + set + { + _licencas = value; + OnPropertyChanged("Licencas"); + } + } + + public ArquivoDigitalViewModel(FiltroArquivoDigital filtro) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0009: Unknown result type (might be due to invalid IL or missing references) + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Expected O, but got Unknown + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Expected O, but got Unknown + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Expected O, but got Unknown + //IL_0098: Unknown result type (might be due to invalid IL or missing references) + //IL_009e: Invalid comparison between Unknown and I4 + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Invalid comparison between Unknown and I4 + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_00cc: Invalid comparison between Unknown and I4 + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00b0: Invalid comparison between Unknown and I4 + //IL_00cf: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Invalid comparison between Unknown and I4 + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Invalid comparison between Unknown and I4 + //IL_00d8: Unknown result type (might be due to invalid IL or missing references) + //IL_00de: Invalid comparison between Unknown and I4 + //IL_0108: Unknown result type (might be due to invalid IL or missing references) + //IL_010d: Unknown result type (might be due to invalid IL or missing references) + //IL_010e: Unknown result type (might be due to invalid IL or missing references) + //IL_015c: Expected I4, but got Unknown + Filtro = filtro; + _servico = new ClienteServico(); + CarregarArquivos(); + VisibilityWhatsApp = (Visibility)(((int)filtro.Tipo != 2 && (int)filtro.Tipo != 3 && (int)filtro.Tipo != 4 && (int)filtro.Tipo != 5) ? 2 : 0); + AdDocumentoVisibility = (Visibility)((((int)filtro.Tipo != 4 && (int)filtro.Tipo != 3 && (int)filtro.Tipo != 5) || !new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)2).Consultar) ? 2 : 0); + base.EnableMenu = true; + TipoArquivoDigital tipo = filtro.Tipo; + switch ((int)tipo) + { + default: + EnviarSelecionadosVisibility = (Visibility)0; + break; + case 0: + case 6: + case 7: + case 8: + case 9: + case 10: + case 12: + case 13: + case 14: + case 15: + case 17: + EnviarSelecionadosVisibility = (Visibility)2; + break; + } + } + + public async void CarregarArquivos() + { + await PermissaoTela((TipoTela)6); + await PermissaoArquivoDigital(Filtro.Tipo); + await CarregaArquivos(); + string licencas = "PRODUTO NÃO CONTRATADO"; + if (LicenseHelper.Produtos.Any((Licenca x) => (int)x.Produto == 86)) + { + _assinadorKey = await AssinadorHelper.Key(); + licencas = $"{await AssinadorHelper.Licencas(_assinadorKey)} LICENÇAS DISPONÍVEIS"; + } + Licencas = licencas; + VerificarEnables(0L); + } + + private void AtualizaEmpresa() + { + Recursos.Empresa = new BaseServico().BuscarEmpresa(Recursos.Usuario.IdEmpresa); + } + + public string CarregarMensagem() + { + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Invalid comparison between Unknown and I4 + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Invalid comparison between Unknown and I4 + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Expected I4, but got Unknown + //IL_016a: Unknown result type (might be due to invalid IL or missing references) + //IL_0170: Expected O, but got Unknown + //IL_0287: Unknown result type (might be due to invalid IL or missing references) + //IL_028e: Expected O, but got Unknown + //IL_0403: Unknown result type (might be due to invalid IL or missing references) + //IL_0409: Expected O, but got Unknown + //IL_0549: Unknown result type (might be due to invalid IL or missing references) + //IL_0550: Expected O, but got Unknown + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_009e: Invalid comparison between Unknown and I4 + AtualizaEmpresa(); + string text = (((int)Recursos.Empresa.TipoTelefone1 == 11) ? "0300" : (((int)Recursos.Empresa.TipoTelefone1 == 10) ? "0800" : "")); + text = text + " " + Recursos.Empresa.PrimeiroPrefixo + " " + Recursos.Empresa.PrimeiroTelefone; + TipoArquivoDigital tipo = Filtro.Tipo; + switch (tipo - 1) + { + default: + if ((int)tipo == 13) + { + return "Prezado(a) " + ValidationHelper.Captalize(SelectedCliente.Nome) + ", segue o(s) link(s) para download referente ao(s) seu(s) arquivo(s). " + Environment.NewLine + Environment.NewLine + "[*LINK*]" + Environment.NewLine + Environment.NewLine + "<|LINKASSINATURA|>" + Environment.NewLine + Environment.NewLine + "Para mais informações entre contato conosco pelo " + text + "." + Environment.NewLine + "Atenciosamente " + ValidationHelper.Captalize(Recursos.Empresa.Nome) + "."; + } + return "Prezado(a), segue o(s) link(s) para download referente ao(s) seu(s) arquivo(s)." + Environment.NewLine + Environment.NewLine + "[*LINK*]" + Environment.NewLine + Environment.NewLine + " Para mais informações entre contato conosco pelo " + text + "." + Environment.NewLine + "Atenciosamente " + ValidationHelper.Captalize(Recursos.Empresa.Nome) + "."; + case 0: + return "Prezado(a) " + ValidationHelper.Captalize(SelectedCliente.Nome) + ", segue o(s) link(s) para download referente ao(s) seu(s) arquivo(s). " + Environment.NewLine + Environment.NewLine + "[*LINK*]" + Environment.NewLine + Environment.NewLine + "<|LINKASSINATURA|>" + Environment.NewLine + Environment.NewLine + "Para mais informações entre contato conosco pelo " + text + "." + Environment.NewLine + "Atenciosamente " + ValidationHelper.Captalize(Recursos.Empresa.Nome) + "."; + case 1: + { + Documento documento = (Documento)Filtro.Parente; + string text2 = (string.IsNullOrWhiteSpace(documento.Apolice) ? ("Proposta Número " + documento.Proposta) : ("Apólice Número " + documento.Apolice)); + return "Prezado(a) " + ValidationHelper.Captalize(SelectedCliente.Nome) + " segue o(s) link(s) para download do(s) arquivo(s) referente ao seu seguro. " + Environment.NewLine + $"{ValidationHelper.Captalize(documento.Controle.Seguradora.Nome)}, {ValidationHelper.Captalize(documento.Controle.Ramo.Nome)}, {text2} de Vigências entre {documento.Vigencia1:d} e {documento.Vigencia2:d}. {Environment.NewLine}{Environment.NewLine}[*LINK*]{Environment.NewLine}{Environment.NewLine}<|LINKASSINATURA|>Para mais informações entre contato conosco pelo {text}.{Environment.NewLine}Atenciosamente {ValidationHelper.Captalize(Recursos.Empresa.Nome)}."; + } + case 2: + { + Parcela val2 = (Parcela)Filtro.Parente; + Documento documento = val2.Documento; + string text2 = (string.IsNullOrWhiteSpace(documento.Apolice) ? ("Proposta Número " + documento.Proposta) : ("Apólice Número " + documento.Apolice)); + return "Prezado(a) " + ValidationHelper.Captalize(SelectedCliente.Nome) + " segue o(s) link(s) para download do(s) arquivo(s) referente a sua parcela. " + Environment.NewLine + $"Parcela {val2.NumeroParcela} de {documento.NumeroParcelas}, valor {val2.Valor:C2} de vencimento {val2.Vencimento:d}. {Environment.NewLine}" + $"{ValidationHelper.Captalize(documento.Controle.Seguradora.Nome)}, {ValidationHelper.Captalize(documento.Controle.Ramo.Nome)}, {text2} de Vigências entre {documento.Vigencia1:d} e {documento.Vigencia2:d}. {Environment.NewLine}{Environment.NewLine}[*LINK*]{Environment.NewLine}{Environment.NewLine}<|LINKASSINATURA|>Para mais informações entre contato conosco pelo {text}.{Environment.NewLine}Atenciosamente {ValidationHelper.Captalize(Recursos.Empresa.Nome)}."; + } + case 3: + { + Item item = (Item)Filtro.Parente; + Documento documento = item.Documento; + string text2 = (string.IsNullOrWhiteSpace(documento.Apolice) ? ("Proposta Número " + documento.Proposta) : ("Apólice Número " + documento.Apolice)); + return "Prezado(a) " + ValidationHelper.Captalize(SelectedCliente.Nome) + " segue o(s) link(s) para download do(s) arquivo(s) referente ao seu seguro. " + Environment.NewLine + "Item " + item.Descricao + ". " + Environment.NewLine + $"{ValidationHelper.Captalize(documento.Controle.Seguradora.Nome)}, {ValidationHelper.Captalize(documento.Controle.Ramo.Nome)}, {text2} de Vigências entre {documento.Vigencia1:d} e {documento.Vigencia2:d}. {Environment.NewLine}{Environment.NewLine}[*LINK*]{Environment.NewLine}{Environment.NewLine}<|LINKASSINATURA|>Para mais informações entre contato conosco pelo {text}.{Environment.NewLine}Atenciosamente {ValidationHelper.Captalize(Recursos.Empresa.Nome)}."; + } + case 4: + { + Sinistro val = (Sinistro)Filtro.Parente; + Item item = val.ControleSinistro.Item; + Documento documento = item.Documento; + string text2 = (string.IsNullOrWhiteSpace(documento.Apolice) ? ("Proposta Número " + documento.Proposta) : ("Apólice Número " + documento.Apolice)); + return "Prezado(a) " + ValidationHelper.Captalize(SelectedCliente.Nome) + " segue o(s) link(s) para download do(s) arquivo(s) referente ao seu sinistro. " + Environment.NewLine + "Sinistro de número " + val.Numero + " Item sinistrado " + val.ItemSinistrado + ". " + Environment.NewLine + $"{ValidationHelper.Captalize(documento.Controle.Seguradora.Nome)}, {ValidationHelper.Captalize(documento.Controle.Ramo.Nome)}, {text2} de Vigências entre {documento.Vigencia1:d} e {documento.Vigencia2:d}. {Environment.NewLine}{Environment.NewLine}[*LINK*]{Environment.NewLine}{Environment.NewLine}<|LINKASSINATURA|>Para mais informações entre contato conosco pelo {text}.{Environment.NewLine}Atenciosamente {ValidationHelper.Captalize(Recursos.Empresa.Nome)}."; + } + } + } + + public async Task CarregaArquivos() + { + FiltroArquivoDigital filtro = Filtro; + if (filtro != null && filtro.Id == 0) + { + return; + } + Carregando = true; + base.IsVisible = (Visibility)2; + AssinarVisibility = (Visibility)2; + if (Filtro != null) + { + List arquivos = await ArquivoDigitalServico.BuscarPorTipo(Filtro.Tipo, Filtro.Id); + if (AdDocumento) + { + List list = arquivos; + list.AddRange(await ArquivoDigitalServico.BuscarPorTipo((TipoArquivoDigital)2, Filtro.IdApolice)); + } + Arquivos = new ObservableCollection(arquivos.OrderBy((IndiceArquivoDigital x) => x.Descricao)); + TipoArquivoDigital tipo = Filtro.Tipo; + switch (tipo - 2) + { + default: + SelectedCliente = (Cliente)Filtro.Parente; + Titulo = "ARQUIVO DIGITAL DO CLIENTE \"" + SelectedCliente.Nome + "\""; + break; + case 0: + { + AssinarVisibility = (Visibility)0; + Documento val13 = (Documento)Filtro.Parente; + SelectedCliente = val13.Controle.Cliente; + Titulo = ((val13.Apolice != string.Empty) ? ("ARQUIVO DIGITAL DA APÓLICE \"" + val13.Apolice + "\"") : ("ARQUIVO DIGITAL DA PROPOSTA \"" + val13.Proposta + "\"")); + break; + } + case 1: + { + AssinarVisibility = (Visibility)0; + Parcela val16 = (Parcela)Filtro.Parente; + SelectedCliente = val16.Documento.Controle.Cliente; + Titulo = ((val16.Documento.Apolice != string.Empty) ? $"ARQUIVO DIGITAL DA PARCELA \"{val16.NumeroParcela}\" DA APÓLICE \"{val16.Documento.Apolice}\"" : $"ARQUIVO DIGITAL DA PARCELA \"{val16.NumeroParcela}\" DA PROPOSTA \"{val16.Documento.Proposta}\""); + DetalheExtrato val17 = await new ServicoExtrato().FindByParcelaId(((DomainBase)val16).Id); + if (val17 != null) + { + arquivos = await ArquivoDigitalServico.BuscarPorTipo((TipoArquivoDigital)7, ((DomainBase)val17.Extrato).Id); + arquivos.ForEach(delegate(IndiceArquivoDigital x) + { + x.NaoExcluir = true; + }); + ExtensionMethods.AddRange((ICollection)Arquivos, (IEnumerable)new ObservableCollection(arquivos.OrderBy((IndiceArquivoDigital x) => x.Descricao))); + } + break; + } + case 2: + { + AssinarVisibility = (Visibility)0; + Item val15 = (Item)Filtro.Parente; + SelectedCliente = val15.Documento.Controle.Cliente; + Titulo = "ARQUIVO DIGITAL DO ITEM \"" + val15.Descricao + "\""; + break; + } + case 3: + { + AssinarVisibility = (Visibility)0; + Sinistro val14 = (Sinistro)Filtro.Parente; + SelectedCliente = val14.ControleSinistro.Item.Documento.Controle.Cliente; + Titulo = "ARQUIVO DIGITAL DO SINITRO \"" + val14.Numero + "\" DO ITEM \"" + val14.ControleSinistro.Item.Descricao + "\""; + break; + } + case 7: + { + Lancamento val12 = (Lancamento)Filtro.Parente; + if (val12.Historico.Equals("TRANSFERÊNCIA ENTRE CONTAS")) + { + await ShowMessage("NÃO É POSSIVEL INCLUIR ARQUIVOS EM TRANSFERÊNCIA ENTRE CONTAS"); + CloseDrawer(); + return; + } + SelectedCliente = new Cliente + { + Id = val12.Controle.Fornecedor.Id, + Nome = val12.Controle.Fornecedor.Nome + }; + Titulo = $"ARQUIVO DIGITAL DO LANCAMENTO {((DomainBase)val12).Id}, PLANO {val12.Controle.Plano.Nome}, CENTRO {val12.Controle.Centro.Descricao}"; + break; + } + case 8: + { + Fornecedor val11 = (Fornecedor)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = val11.Id, + Nome = val11.Nome + }; + Titulo = $"ARQUIVO DIGITAL DO FORNECEDOR {val11.Nome} {val11.Id}"; + break; + } + case 9: + { + Prospeccao val10 = (Prospeccao)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val10).Id, + Nome = val10.Nome + }; + Titulo = $"ARQUIVO DIGITAL DA PROSPECÇÃO {val10.Nome} {((DomainBase)val10).Id} {val10.Item}"; + break; + } + case 5: + { + Extrato val9 = (Extrato)Filtro.Parente; + SelectedCliente = new Cliente + { + Nome = "EXTRATO " + val9.Numero + }; + Titulo = $"ARQUIVO DIGITAL DO EXTRATO {val9.Numero} ID:{((DomainBase)val9).Id}"; + break; + } + case 6: + { + Seguradora val8 = (Seguradora)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val8).Id, + Nome = val8.Nome + }; + Titulo = $"ARQUIVO DIGITAL DA SEGURADORA {val8.Nome} {((DomainBase)val8).Id}"; + break; + } + case 4: + { + Vendedor val7 = (Vendedor)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val7).Id, + Nome = val7.Nome + }; + Titulo = $"ARQUIVO DIGITAL DO VENDEDOR {val7.Nome} {((DomainBase)val7).Id}"; + break; + } + case 10: + { + Usuario val6 = (Usuario)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val6).Id, + Nome = val6.Nome + }; + Titulo = $"ARQUIVO DIGITAL DO USUÁRIO {val6.Nome} {((DomainBase)val6).Id}"; + break; + } + case 11: + { + Empresa val5 = (Empresa)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val5).Id, + Nome = val5.Nome + }; + Titulo = $"ARQUIVO DIGITAL DA EMPRESA {val5.Nome} {((DomainBase)val5).Id}"; + break; + } + case 12: + { + Socio val4 = (Socio)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val4).Id, + Nome = val4.Nome + }; + Titulo = $"ARQUIVO DIGITAL DO SÓCIO {val4.Nome} {((DomainBase)val4).Id}"; + break; + } + case 13: + { + Tarefa val3 = (Tarefa)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val3).Id, + Nome = "TAREFA - " + val3.Titulo + }; + Titulo = $"ANEXO DA TAREFA {val3.Titulo} {((DomainBase)val3).Id}"; + break; + } + case 14: + { + NotaFiscal val2 = (NotaFiscal)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val2).Id, + Nome = $"NOTA FISCAL - {val2.Seguradora.NomeSocial} {val2.Data:d}" + }; + Titulo = $"ANEXO DA NOTA FISCAL {val2.Seguradora.NomeSocial} {val2.Data:d}"; + break; + } + case 15: + { + Estipulante val = (Estipulante)Filtro.Parente; + SelectedCliente = new Cliente + { + Id = ((DomainBase)val).Id, + Nome = "ESTIPULANTE - " + val.Nome + }; + Titulo = "ANEXO DO ESTIPULANTE " + val.Nome; + break; + } + } + } + if (Filtro != null) + { + TipoArquivoDigital tipo = Filtro.Tipo; + switch (tipo - 1) + { + default: + if ((int)tipo == 17) + { + Estipulante val20 = (Estipulante)Filtro.Parente; + Telefones = new ObservableCollection + { + new ClienteTelefone + { + Prefixo = val20.PrimeiroPrefixo, + Numero = val20.PrimeiroTelefone + }, + new ClienteTelefone + { + Prefixo = val20.SegundoPrefixo, + Numero = val20.SegundoTelefone + } + }; + } + break; + case 0: + case 1: + case 2: + case 3: + case 4: + { + Cliente cliente = await _servico.BuscarClienteAsync(((DomainBase)SelectedCliente).Id); + Telefones = await _servico.BuscarTelefonesAsync(((DomainBase)SelectedCliente).Id); + ObservableCollection source = await new ClienteServico().BuscarEmailsAsync(((DomainBase)SelectedCliente).Id); + if (SelectedCliente.Documento == null || ValidationHelper.OnlyNumber(SelectedCliente.Documento).Length <= 11) + { + ArquivoDigitalViewModel arquivoDigitalViewModel = this; + ClienteEmail? obj = source.FirstOrDefault(); + arquivoDigitalViewModel.Email = ((obj != null) ? ((EmailBase)obj).Email : null); + Nome = SelectedCliente.Nome; + Documento = SelectedCliente.Documento; + break; + } + ArquivoDigitalViewModel arquivoDigitalViewModel2 = this; + object obj2; + if (cliente == null) + { + obj2 = null; + } + else + { + ResponsavelAssinatura responsavelAssinatura = cliente.ResponsavelAssinatura; + obj2 = ((responsavelAssinatura != null) ? responsavelAssinatura.EmailResponsavel : null); + } + if (obj2 == null) + { + ClienteEmail? obj3 = source.FirstOrDefault(); + obj2 = ((obj3 != null) ? ((EmailBase)obj3).Email : null); + } + arquivoDigitalViewModel2.Email = (string)obj2; + ArquivoDigitalViewModel arquivoDigitalViewModel3 = this; + object obj4; + if (cliente == null) + { + obj4 = null; + } + else + { + ResponsavelAssinatura responsavelAssinatura2 = cliente.ResponsavelAssinatura; + obj4 = ((responsavelAssinatura2 != null) ? responsavelAssinatura2.NomeResponsavel : null); + } + if (obj4 == null) + { + obj4 = SelectedCliente.Nome; + } + arquivoDigitalViewModel3.Nome = (string)obj4; + ArquivoDigitalViewModel arquivoDigitalViewModel4 = this; + object obj5; + if (cliente == null) + { + obj5 = null; + } + else + { + ResponsavelAssinatura responsavelAssinatura3 = cliente.ResponsavelAssinatura; + obj5 = ((responsavelAssinatura3 != null) ? responsavelAssinatura3.DocumentoResponsavel : null); + } + if (obj5 == null) + { + obj5 = SelectedCliente.Documento; + } + arquivoDigitalViewModel4.Documento = (string)obj5; + break; + } + case 9: + { + Fornecedor val19 = (Fornecedor)Filtro.Parente; + Telefones = new ObservableCollection + { + new ClienteTelefone + { + Prefixo = val19.Prefixo1, + Numero = val19.Telefone1 + }, + new ClienteTelefone + { + Prefixo = val19.Prefixo2, + Numero = val19.Telefone2 + } + }; + break; + } + case 8: + { + Lancamento val18 = (Lancamento)Filtro.Parente; + Telefones = new ObservableCollection + { + new ClienteTelefone + { + Prefixo = val18.Controle.Fornecedor.Prefixo1, + Numero = val18.Controle.Fornecedor.Telefone1 + }, + new ClienteTelefone + { + Prefixo = val18.Controle.Fornecedor.Prefixo2, + Numero = val18.Controle.Fornecedor.Telefone2 + } + }; + break; + } + case 5: + case 6: + case 7: + break; + } + } + base.IsVisible = (Visibility)0; + Carregando = false; + } + + public void Baixar(IndiceArquivoDigital arquivo, bool abrir = false) + { + if (arquivo != null && arquivo.IdArquivoDigital != 0L) + { + Download(arquivo, abrir); + } + } + + public async Task Excluir(IndiceArquivoDigital arquivo) + { + if (arquivo != null && arquivo.IdArquivoDigital != 0L && await ArquivoDigitalServico.DeleteAttachment(arquivo)) + { + await CarregaArquivos(); + } + } + + public async void Editar(IndiceArquivoDigital arquivo) + { + if (arquivo != null && arquivo.IdArquivoDigital != 0L) + { + await ArquivoDigitalServico.Save(arquivo); + } + } + + public async Task BaixarTodos() + { + if (Arquivos == null || Arquivos.Count == 0) + { + return false; + } + return await DownloadAll(Arquivos.ToList(), Filtro.Id); + } + + public async void Anexar() + { + List attacheds = ((IEnumerable)Arquivos).Select((Func)((IndiceArquivoDigital x) => new ArquivoDigital + { + Descricao = x.Descricao, + Extensao = x.Extensao + })).ToList(); + List list = await AddAttachments(ArquivosAnexados.ToList(), attacheds); + if (list == null) + { + return; + } + if (!Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 47)) + { + list = await ShowDialogAnexar(list); + if (list == null) + { + return; + } + } + list.AddRange(ArquivosAnexados); + ArquivosAnexados = new ObservableCollection(list); + } + + public void Delete(ArquivoDigital arquivo) + { + if (SelectedAnexado != null) + { + ArquivoDigital item = ArquivosAnexados.First((ArquivoDigital x) => x.Descricao == arquivo.Descricao); + ArquivosAnexados.Remove(item); + ArquivosAnexados = new ObservableCollection(ArquivosAnexados); + } + } + + public async Task SalvarAnexos() + { + if (ArquivosAnexados != null && ArquivosAnexados.Count != 0) + { + Carregando = true; + List arquivos = ArquivosAnexados.ToList(); + if (!(await SalvarAttachments(arquivos, Filtro.Tipo, Filtro.Id))) + { + Carregando = false; + return; + } + await CarregaArquivos(); + ArquivosAnexados = new ObservableCollection(); + Carregando = false; + } + } + + public void LimparAnexos() + { + ArquivosAnexados = new ObservableCollection(); + } + + public async Task PrepararEnvio() + { + if (!Arquivos.Any((IndiceArquivoDigital x) => x.Selecionado)) + { + await ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM ARQUIVO PARA ENVIO."); + return null; + } + MalaDireta maladireta = new MalaDireta + { + Cliente = SelectedCliente, + ArquivoDigital = Arquivos.Where((IndiceArquivoDigital x) => x.Selecionado).ToList() + }; + TipoArquivoDigital tipo = Filtro.Tipo; + switch (tipo - 2) + { + default: + { + if ((int)tipo != 11) + { + SelectedCliente = (Cliente)Filtro.Parente; + Titulo = "ARQUIVO DIGITAL DO CLIENTE \"" + SelectedCliente.Nome + "\""; + break; + } + Prospeccao val5 = (maladireta.Prospeccao = (Prospeccao)Filtro.Parente); + ((DomainBase)maladireta.Cliente).Id = 0L; + Assunto = "DOCUMENTOS REFERENTES PROSPECÇÃO " + val5.Nome; + Corpo = ""; + maladireta.Tela = (TipoTela)33; + break; + } + case 0: + { + Documento apolice = (Documento)Filtro.Parente; + List list2 = await CarregarItem(((DomainBase)apolice.Controle).Id, (StatusItem)0); + maladireta.Item = (Item)((list2.Count <= 1) ? ((object)list2.FirstOrDefault()) : ((object)new Item + { + Id = 0L, + Descricao = "APÓLICE COLETIVA" + })); + maladireta.Apolice = apolice; + Assunto = ((apolice.Apolice != string.Empty) ? ("DOCUMENTOS REFERENTES A APÓLICE " + apolice.Apolice) : ("DOCUMENTOS REFERENTES A PROPOSTA " + apolice.Proposta)); + Corpo = "PREZADO CLIENTE " + SelectedCliente.Nome + ", EM ANEXO OS DOCUMENTOS REFERENTES AO SEU SEGURO."; + maladireta.Tela = (TipoTela)2; + break; + } + case 1: + { + Parcela parcela = (Parcela)Filtro.Parente; + maladireta.Apolice = parcela.Documento; + maladireta.Parcela = parcela; + List list = await CarregarItem(((DomainBase)parcela.Documento.Controle).Id, (StatusItem)0); + maladireta.Item = (Item)((list.Count <= 1) ? ((object)list.FirstOrDefault()) : ((object)new Item + { + Id = 0L, + Descricao = "APÓLICE COLETIVA" + })); + Assunto = ((parcela.Documento.Apolice != string.Empty) ? $"DOCUMENTOS REFERENTE A PARCELA {parcela.NumeroParcela} DA APÓLICE {parcela.Documento.Apolice}" : $"DOCUMENTOS REFERENTE A PARCELA {parcela.NumeroParcela} DA PROPOSTA {parcela.Documento.Proposta}"); + Corpo = "PREZADO CLIENTE " + SelectedCliente.Nome + ", EM ANEXO OS DOCUMENTOS REFERENTES AS PARCELAS DE SEU SEGURO."; + maladireta.Tela = (TipoTela)5; + break; + } + case 2: + { + Item val3 = (Item)Filtro.Parente; + maladireta.Apolice = val3.Documento; + maladireta.Item = val3; + Assunto = "DOCUMENTOS REFERENTES AO ITEM " + val3.Descricao; + Corpo = "PREZADO CLIENTE " + SelectedCliente.Nome + ", EM ANEXO OS DOCUMENTOS REFERENTES AO SEU BEM."; + maladireta.Tela = (TipoTela)3; + break; + } + case 3: + { + Sinistro val2 = (maladireta.Sinistro = (Sinistro)Filtro.Parente); + maladireta.Item = val2.ControleSinistro.Item; + maladireta.Apolice = val2.ControleSinistro.Item.Documento; + Titulo = "DOCUMENTOS REFERENTES AO SINITRO " + val2.Numero; + Corpo = "PREZADO CLIENTE " + SelectedCliente.Nome + ", EM ANEXO OS DOCUMENTOS REFERENTES SINISTRO DO ITEM " + val2.ControleSinistro.Item.Descricao + "."; + maladireta.Tela = (TipoTela)7; + break; + } + } + return maladireta; + } + + public async Task CreateLink(IndiceArquivoDigital indice) + { + string value = $"{Funcoes.GetNetworkTime().Ticks}:{ApplicationHelper.IdFornecedor}:F:{((DomainBase)indice).Id}".Base64Encode(); + return Recursos.ApiArquivo.AddQuery("search", value); + } + + public async Task EnviarParaAssinatura() + { + if (!ArquivosTela.Any((IndiceArquivoDigital x) => x.Assinar)) + { + await ShowMessage("É NECESSÁRIO SELECIONAR AO MENOS UM ARQUIVO PARA ENVIAR PARA ASSINATURA."); + return false; + } + if (!(await ShowMessage("DESEJA ENVIAR OS ARQUIVOS SELECIONADOS PARA ASSINATURA ELETRÔNICA DO SEGURADO?", "SIM", "NÃO"))) + { + return false; + } + if (Email.EndsWith(";")) + { + await ShowMessage("É NECESSÁRIO QUE O ASSINANTE POSSUA UM E-MAIL VÁLIDO"); + return false; + } + Loading(isLoading: true); + _assinadorKey = await AssinadorHelper.Key(); + int licencasDisponiveis = await AssinadorHelper.Licencas(_assinadorKey); + if (licencasDisponiveis < Arquivos.Count((IndiceArquivoDigital x) => x.Assinar && !x.EnviadoAssinatura)) + { + if (Restricao((TipoRestricao)113)) + { + await ShowMessage("VOCÊ NÃO POSSUI MAIS LICENÇAS DISPONÍVEIS E O USUÁRIO NÃO PODE CONTRATAR, ENTRE EM CONTATO COM O ADMINISTRADOR DO SISTEMA."); + Loading(isLoading: false); + return false; + } + if (!(await ShowMessage("VOCÊ NÃO POSSUI MAIS LICENÇAS DISPONÍVEIS, DESEJA CONTRATAR MAIS?", "SIM", "NÃO"))) + { + Loading(isLoading: false); + return false; + } + string arguments = new Token().Encrypt(string.Format("{0}:{1}:{2}:{3}", ApplicationHelper.NumeroSerial, ApplicationHelper.IdFornecedor, ((DomainBase)Recursos.Usuario).Id, ApplicationHelper.Beta ? "1" : "0")); + ((Window)new DownloadWindow(new Parameters + { + Beta = ApplicationHelper.Beta, + Type = 8, + Application = "Assinador.Application.exe", + Directory = "Assinador.Application", + Arguments = arguments, + Run = true + })).Show(); + Loading(isLoading: false); + return false; + } + AssinadorHelper.Parametros = await AssinaturaServico.BuscarParametrosAssinatura(Recursos.Usuario.IdEmpresa); + int arquivosEnviados = 0; + int arquivosSelecionados = ArquivosTela.Where((IndiceArquivoDigital x) => x.Assinar).Count(); + foreach (IndiceArquivoDigital indice in ArquivosTela.Where((IndiceArquivoDigital x) => x.Assinar)) + { + if (indice.Assinado) + { + continue; + } + if (indice.EnviadoAssinatura) + { + await new AssinaturaServico().Reenviar(((DomainBase)indice).Id); + continue; + } + ArquivoParaAssinaturaAssinador val = await Assinar(indice); + if (val != null) + { + licencasDisponiveis--; + indice.EnviadoAssinatura = true; + indice.UrlAssinatura = val.UrlAssinatura; + arquivosEnviados++; + } + } + Loading(isLoading: false); + Arquivos = new ObservableCollection(Arquivos); + await ShowMessage($"{arquivosEnviados} DE {arquivosSelecionados} ARQUIVOS FORAM ENVIADOS PARA ASSINATURA. VOCÊ SERÁ NOTIFICADO QUANDO OS DOCUMENTOS FOREM ASSINADOS"); + return true; + } + + public async Task Assinar(IndiceArquivoDigital indice, bool lote = false) + { + try + { + AssinaturaServico servico = new AssinaturaServico(); + ArquivoDigitalServico servicoArquivo = new ArquivoDigitalServico(); + if (await servico.VerificarAssinado(((DomainBase)indice).Id)) + { + if (!lote) + { + await ShowMessage("ARQUIVO JÁ ASSINADO"); + } + return null; + } + if (await servico.VerificarEnviado(((DomainBase)indice).Id)) + { + return await servico.Reenviar(((DomainBase)indice).Id); + } + if (Nome == null || string.IsNullOrWhiteSpace(Nome)) + { + if (!lote) + { + await ShowMessage("É NECESSÁRIO QUE O ASSINANTE POSSUA UM NOME VÁLIDO"); + } + return null; + } + if (Documento == null || !ValidationHelper.ValidateDocument(Documento)) + { + if (!lote) + { + await ShowMessage("É NECESSÁRIO QUE O ASSINANTE POSSUA UM DOCUMENTO VÁLIDO"); + } + return null; + } + if (Documento.Length > 14) + { + if (!lote) + { + await ShowMessage("O DOCUMENTO DO ASSINANTE DEVE SER CPF E NÃO CNPJ"); + } + return null; + } + if (Email == null || !ValidationHelper.ValidacaoEmail(Email)) + { + if (!lote) + { + await ShowMessage("É NECESSÁRIO QUE O ASSINANTE POSSUA UM E-MAIL VÁLIDO"); + } + return null; + } + ArquivoDigital arquivoDigital = await servicoArquivo.BuscarPorId(indice.IdArquivoDigital, indice.Bd); + new Documento(); + TipoArquivoDigital tipo = Filtro.Tipo; + long id; + switch (tipo - 2) + { + default: + return null; + case 3: + id = ((DomainBase)((Sinistro)Filtro.Parente).ControleSinistro.Item.Documento).Id; + break; + case 1: + id = ((DomainBase)((Parcela)Filtro.Parente).Documento).Id; + break; + case 2: + id = ((DomainBase)((Item)Filtro.Parente).Documento).Id; + break; + case 0: + id = ((DomainBase)(Documento)Filtro.Parente).Id; + break; + } + return await servico.Save(await servico.Assinar(arquivoDigital, new ApoliceAssinador + { + ArquivoId = ((DomainBase)indice).Id, + ClienteId = ((DomainBase)SelectedCliente).Id, + Cliente = Nome, + Email = Email, + Documento = Documento, + Id = id + })); + } + catch (Exception ex) + { + await ShowMessage("ERRO AO ENVIAR PARA ASSINATURA" + Environment.NewLine + ex.Message + Environment.NewLine + "POR FAVOR CONTATE A AGGER ATRAVÉS DO PAINEL DE ATENDIMENTOS"); + return null; + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs new file mode 100644 index 0000000..d4633e7 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ExpedicaoViewModel.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ExpedicaoViewModel : BaseSegurosViewModel +{ + private readonly ExpedicaoServico _servico; + + private readonly Documento _documento; + + private bool _carregando; + + private Expedicao _selectedExpedicao = new Expedicao(); + + private ObservableCollection _expedicoes = new ObservableCollection(); + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public Expedicao SelectedExpedicao + { + get + { + return _selectedExpedicao; + } + set + { + _selectedExpedicao = value; + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedExpedicao"); + } + } + + public ObservableCollection Expedicoes + { + get + { + return _expedicoes; + } + set + { + _expedicoes = value; + OnPropertyChanged("Expedicoes"); + } + } + + public ExpedicaoViewModel(Documento documento) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + _servico = new ExpedicaoServico(); + _documento = documento; + Seleciona(documento); + } + + private async void Seleciona(Documento documento) + { + Carregando = true; + await PermissaoTela((TipoTela)46); + await Carregar(documento); + if (Expedicoes.Count > 0) + { + SelectedExpedicao = Expedicoes.First(); + } + else + { + SelectedExpedicao = new Expedicao(); + Alterar(alterar: false); + base.EnableMenu = false; + } + Carregando = false; + } + + private async Task Carregar(Documento documento) + { + Expedicoes = new ObservableCollection(await _servico.BuscarExpedicoes(documento)); + } + + public void Incluir() + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Expected O, but got Unknown + SelectedExpedicao = new Expedicao + { + Apolice = _documento + }; + Alterar(alterar: true); + } + + public async Task>> Salvar() + { + SelectedExpedicao = await _servico.Save(SelectedExpedicao); + if (!_servico.Sucesso) + { + return null; + } + long id = ((DomainBase)SelectedExpedicao).Id; + await Carregar(SelectedExpedicao.Apolice); + SelectedExpedicao = ((IEnumerable)Expedicoes).FirstOrDefault((Func)((Expedicao x) => ((DomainBase)x).Id == id)); + Alterar(alterar: false); + return null; + } + + public async void CancelarAlteracao() + { + Carregando = true; + long id = ((DomainBase)SelectedExpedicao).Id; + await Carregar(SelectedExpedicao.Apolice); + SelectedExpedicao = (Expedicao)((Expedicoes.Count > 0 && id > 0) ? ((IEnumerable)Expedicoes).FirstOrDefault((Func)((Expedicao x) => ((DomainBase)x).Id == id)) : ((Expedicoes.Count > 0 && id == 0L) ? ((object)Expedicoes.First()) : ((object)new Expedicao()))); + Alterar(alterar: false); + Carregando = false; + } + + public async Task Excluir() + { + if (SelectedExpedicao == null || ((DomainBase)SelectedExpedicao).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + if (!(await _servico.Delete(SelectedExpedicao))) + { + Carregando = false; + return false; + } + int num = Expedicoes.IndexOf(SelectedExpedicao); + Expedicoes.Remove(SelectedExpedicao); + if (Expedicoes.Count > 0) + { + SelectedExpedicao = ((num < Expedicoes.Count) ? Expedicoes.ElementAt(num) : Expedicoes.Last()); + } + else + { + SelectedExpedicao = new Expedicao(); + } + Carregando = false; + return true; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs new file mode 100644 index 0000000..c04d349 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ExtratosViewModel.cs @@ -0,0 +1,2773 @@ +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 System.Windows; +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Seguros; +using NReco.PdfGenerator; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ExtratosViewModel : BaseSegurosViewModel +{ + private readonly ClienteServico _clienteServico = new ClienteServico(); + + private List _documentos; + + private List _prospeccoes; + + private List _clientes; + + private bool _tipoExtratoEnabled = true; + + private bool _extratoResumido; + + private bool _segurosVigentes; + + private Visibility _clientePorPaginaVisibility; + + private bool _clientePorPagina; + + private bool _extratoPorPagina; + + private bool _clientePorPaginaEnabled = true; + + private bool _obsCliente; + + private bool _comissaoDocumento; + + private bool _premioParcela; + + private bool _obsApolice; + + private bool _beneficiariosItens; + + private bool _selecionarItens; + + private bool _endossos; + + private bool _somenteEndosso; + + private Visibility _selecionarItensVisibility; + + private Visibility _endossoVisibility; + + private Visibility _obsDocVisibility; + + private Visibility _segurosVigentesVisibility; + + private bool _obsItem; + + private bool _separarPagina; + + private bool _perfilCondutor; + + private bool _obsClienteEnabled = true; + + private bool _comissaoDocumentoEnabled; + + private bool _obsApoliceEnabled; + + private bool _beneficiariosItensEnabled; + + private bool _obsItemEnabled; + + private bool _separarPaginaEnabled; + + private bool _coberturasEnabled; + + private bool _coberturas; + + private bool _perfilCondutorEnabled; + + private bool _endossoEnabled; + + private bool _esconderResumido; + + private bool _clienteVisibility; + + private bool _documentoVisibility; + + private bool _itemVisibility; + + private bool _perfilVisibility; + + private TipoExtrato _selectedTipoExtrato; + + private bool _carregando; + + private List _itensSelecionados; + + internal Relatorio? TipoDeRelatorio; + + public List Documentos + { + get + { + return _documentos; + } + set + { + _documentos = value; + OnPropertyChanged("Documentos"); + } + } + + public List Prospeccoes + { + get + { + return _prospeccoes; + } + set + { + _prospeccoes = value; + OnPropertyChanged("Prospeccoes"); + } + } + + public List Clientes + { + get + { + return _clientes; + } + set + { + _clientes = value; + OnPropertyChanged("Clientes"); + } + } + + public bool TipoExtratoEnabled + { + get + { + return _tipoExtratoEnabled; + } + set + { + _tipoExtratoEnabled = value; + OnPropertyChanged("TipoExtratoEnabled"); + } + } + + public bool ExtratoResumido + { + get + { + return _extratoResumido; + } + set + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + _extratoResumido = value; + if (value) + { + ClienteVisibility = false; + DocumentoVisibility = false; + ItemVisibility = CoberturasEnabled; + SelecionarItensVisibility = (Visibility)2; + BeneficiariosItensEnabled = false; + ObsItemEnabled = false; + SepararPaginaEnabled = false; + } + else + { + ClienteVisibility = true; + DocumentoVisibility = true; + ItemVisibility = true; + AjustaTipoSelecionado(SelectedTipoExtrato); + } + OnPropertyChanged("ExtratoResumido"); + } + } + + public bool SegurosVigentes + { + get + { + return _segurosVigentes; + } + set + { + _segurosVigentes = value; + OnPropertyChanged("SegurosVigentes"); + } + } + + public Visibility ClientePorPaginaVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _clientePorPaginaVisibility; + } + 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) + _clientePorPaginaVisibility = value; + OnPropertyChanged("ClientePorPaginaVisibility"); + } + } + + public bool ClientePorPagina + { + get + { + return _clientePorPagina; + } + set + { + _clientePorPagina = value; + OnPropertyChanged("ClientePorPagina"); + } + } + + public bool ExtratoPorPagina + { + get + { + return _extratoPorPagina; + } + set + { + _extratoPorPagina = value; + OnPropertyChanged("ExtratoPorPagina"); + } + } + + public bool ClientePorPaginaEnabled + { + get + { + return _clientePorPaginaEnabled; + } + set + { + _clientePorPaginaEnabled = value; + OnPropertyChanged("ClientePorPaginaEnabled"); + } + } + + public bool ObsCliente + { + get + { + return _obsCliente; + } + set + { + _obsCliente = value; + OnPropertyChanged("ObsCliente"); + } + } + + public bool ComissaoDocumento + { + get + { + return _comissaoDocumento; + } + set + { + _comissaoDocumento = value; + OnPropertyChanged("ComissaoDocumento"); + } + } + + public bool PremioParcela + { + get + { + return _premioParcela; + } + set + { + _premioParcela = value; + OnPropertyChanged("PremioParcela"); + } + } + + public bool ObsApolice + { + get + { + return _obsApolice; + } + set + { + _obsApolice = value; + OnPropertyChanged("ObsApolice"); + } + } + + public bool BeneficiariosItens + { + get + { + return _beneficiariosItens; + } + set + { + _beneficiariosItens = value; + OnPropertyChanged("BeneficiariosItens"); + } + } + + public bool SelecionarItens + { + get + { + return _selecionarItens; + } + set + { + _selecionarItens = value; + if (!value) + { + _itensSelecionados = new List(); + } + OnPropertyChanged("SelecionarItens"); + } + } + + public bool Endossos + { + get + { + return _endossos; + } + set + { + _endossos = value; + if (SomenteEndossos != !value) + { + SomenteEndossos = !value; + } + OnPropertyChanged("Endossos"); + } + } + + public bool SomenteEndossos + { + get + { + return _somenteEndosso; + } + set + { + _somenteEndosso = value; + if (Endossos != !value) + { + Endossos = !value; + } + OnPropertyChanged("SomenteEndossos"); + } + } + + public Visibility SelecionarItensVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selecionarItensVisibility; + } + 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) + _selecionarItensVisibility = value; + OnPropertyChanged("SelecionarItensVisibility"); + } + } + + public Visibility EndossoVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _endossoVisibility; + } + 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) + _endossoVisibility = value; + OnPropertyChanged("EndossoVisibility"); + } + } + + public Visibility ObsDocVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _obsDocVisibility; + } + 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) + _obsDocVisibility = value; + OnPropertyChanged("ObsDocVisibility"); + } + } + + public Visibility SegurosVigentesVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _segurosVigentesVisibility; + } + 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) + _segurosVigentesVisibility = value; + OnPropertyChanged("SegurosVigentesVisibility"); + } + } + + public bool ObsItem + { + get + { + return _obsItem; + } + set + { + _obsItem = value; + OnPropertyChanged("ObsItem"); + } + } + + public bool SepararPagina + { + get + { + return _separarPagina; + } + set + { + _separarPagina = value; + OnPropertyChanged("SepararPagina"); + } + } + + public bool PerfilCondutor + { + get + { + return _perfilCondutor; + } + set + { + _perfilCondutor = value; + OnPropertyChanged("PerfilCondutor"); + } + } + + public bool ObsClienteEnabled + { + get + { + return _obsClienteEnabled; + } + set + { + _obsClienteEnabled = value; + OnPropertyChanged("ObsClienteEnabled"); + } + } + + public bool ComissaoDocumentoEnabled + { + get + { + return _comissaoDocumentoEnabled; + } + set + { + _comissaoDocumentoEnabled = value; + OnPropertyChanged("ComissaoDocumentoEnabled"); + } + } + + public bool ObsApoliceEnabled + { + get + { + return _obsApoliceEnabled; + } + set + { + _obsApoliceEnabled = value; + OnPropertyChanged("ObsApoliceEnabled"); + } + } + + public bool BeneficiariosItensEnabled + { + get + { + return _beneficiariosItensEnabled; + } + set + { + _beneficiariosItensEnabled = value; + OnPropertyChanged("BeneficiariosItensEnabled"); + } + } + + public bool ObsItemEnabled + { + get + { + return _obsItemEnabled; + } + set + { + _obsItemEnabled = value; + OnPropertyChanged("ObsItemEnabled"); + } + } + + public bool SepararPaginaEnabled + { + get + { + return _separarPaginaEnabled; + } + set + { + _separarPaginaEnabled = value; + OnPropertyChanged("SepararPaginaEnabled"); + } + } + + public bool CoberturasEnabled + { + get + { + return _coberturasEnabled; + } + set + { + _coberturasEnabled = value; + OnPropertyChanged("CoberturasEnabled"); + } + } + + public bool Coberturas + { + get + { + return _coberturas; + } + set + { + _coberturas = value; + OnPropertyChanged("Coberturas"); + } + } + + public bool PerfilCondutorEnabled + { + get + { + return _perfilCondutorEnabled; + } + set + { + _perfilCondutorEnabled = value; + OnPropertyChanged("PerfilCondutorEnabled"); + } + } + + public bool EndossoEnabled + { + get + { + return _endossoEnabled; + } + set + { + _endossoEnabled = value; + OnPropertyChanged("EndossoEnabled"); + } + } + + public bool EsconderResumido + { + get + { + return _esconderResumido; + } + set + { + _esconderResumido = value; + OnPropertyChanged("EsconderResumido"); + } + } + + public bool ClienteVisibility + { + get + { + return _clienteVisibility; + } + set + { + _clienteVisibility = value; + OnPropertyChanged("ClienteVisibility"); + } + } + + public bool DocumentoVisibility + { + get + { + return _documentoVisibility; + } + set + { + _documentoVisibility = value; + OnPropertyChanged("DocumentoVisibility"); + } + } + + public bool ItemVisibility + { + get + { + return _itemVisibility; + } + set + { + _itemVisibility = value; + OnPropertyChanged("ItemVisibility"); + } + } + + public bool PerfilVisibility + { + get + { + return _perfilVisibility; + } + set + { + _perfilVisibility = value; + OnPropertyChanged("PerfilVisibility"); + } + } + + public TipoExtrato SelectedTipoExtrato + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _selectedTipoExtrato; + } + 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) + _selectedTipoExtrato = value; + AjustaTipoSelecionado(value); + OnPropertyChanged("SelectedTipoExtrato"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public void AjustaTipoSelecionado(TipoExtrato tipoExtrato) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Expected I4, but got Unknown + switch ((int)tipoExtrato) + { + case 0: + ClienteVisibility = true; + ClientePorPaginaVisibility = (Visibility)1; + DocumentoVisibility = false; + ItemVisibility = false; + PerfilVisibility = false; + EsconderResumido = true; + SelecionarItensVisibility = (Visibility)2; + SegurosVigentesVisibility = (Visibility)2; + SegurosVigentes = false; + EndossoVisibility = (Visibility)2; + ObsDocVisibility = (Visibility)2; + ExtratoCliente(); + break; + case 1: + ClienteVisibility = true; + ClientePorPaginaVisibility = (Visibility)0; + DocumentoVisibility = true; + ItemVisibility = true; + PerfilVisibility = true; + EsconderResumido = false; + SelecionarItensVisibility = (Visibility)(TipoDeRelatorio.HasValue ? 2 : 0); + SegurosVigentesVisibility = (Visibility)2; + SegurosVigentes = false; + EndossoVisibility = (Visibility)0; + ObsDocVisibility = (Visibility)0; + ApoliceSelecionada(); + break; + case 2: + ClienteVisibility = false; + ClientePorPaginaVisibility = (Visibility)2; + DocumentoVisibility = true; + ItemVisibility = false; + PerfilVisibility = true; + EsconderResumido = false; + SelecionarItensVisibility = (Visibility)2; + SegurosVigentesVisibility = (Visibility)0; + EndossoVisibility = (Visibility)2; + ObsDocVisibility = (Visibility)2; + RelacaoApolices(); + break; + } + } + + private void SetAllFalse() + { + ObsClienteEnabled = false; + ClientePorPaginaEnabled = false; + ComissaoDocumentoEnabled = false; + ObsApoliceEnabled = false; + BeneficiariosItensEnabled = false; + ObsItemEnabled = false; + SepararPaginaEnabled = false; + CoberturasEnabled = false; + PerfilCondutorEnabled = false; + EndossoEnabled = false; + } + + private void ExtratoCliente() + { + SetAllFalse(); + ObsClienteEnabled = true; + } + + private void ApoliceSelecionada() + { + SetAllFalse(); + ObsClienteEnabled = true; + ClientePorPaginaEnabled = true; + ComissaoDocumentoEnabled = true; + ObsApoliceEnabled = true; + BeneficiariosItensEnabled = true; + ObsItemEnabled = true; + SepararPaginaEnabled = true; + PerfilCondutorEnabled = true; + EndossoEnabled = true; + CoberturasEnabled = true; + } + + private void RelacaoApolices() + { + SetAllFalse(); + ComissaoDocumentoEnabled = true; + PerfilCondutorEnabled = true; + } + + public async Task Gerar(Relatorio? tipoRelatorio = null, bool pdf = false) + { + string html = ""; + string title; + if (Clientes != null && Documentos == null) + { + html += ""; + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE"; + html += title; + html += "
"; + html += ""; + long idCli = 0L; + Clientes.ForEach(delegate(Cliente x) + { + //IL_0353: Unknown result type (might be due to invalid IL or missing references) + //IL_0359: Invalid comparison between Unknown and I4 + //IL_080c: Unknown result type (might be due to invalid IL or missing references) + //IL_0812: Invalid comparison between Unknown and I4 + //IL_0988: Unknown result type (might be due to invalid IL or missing references) + //IL_098e: Invalid comparison between Unknown and I4 + //IL_0bb7: Unknown result type (might be due to invalid IL or missing references) + //IL_0bbd: Invalid comparison between Unknown and I4 + //IL_0d17: Unknown result type (might be due to invalid IL or missing references) + //IL_0d1d: Invalid comparison between Unknown and I4 + //IL_0d97: Unknown result type (might be due to invalid IL or missing references) + //IL_0d9d: Invalid comparison between Unknown and I4 + //IL_1351: Unknown result type (might be due to invalid IL or missing references) + //IL_12a2: Unknown result type (might be due to invalid IL or missing references) + //IL_12a8: Invalid comparison between Unknown and I4 + //IL_0a09: Unknown result type (might be due to invalid IL or missing references) + //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) + //IL_11e8: Unknown result type (might be due to invalid IL or missing references) + //IL_11ee: Invalid comparison between Unknown and I4 + //IL_0ea0: Unknown result type (might be due to invalid IL or missing references) + //IL_0ea5: Unknown result type (might be due to invalid IL or missing references) + //IL_1030: Unknown result type (might be due to invalid IL or missing references) + //IL_1035: Unknown result type (might be due to invalid IL or missing references) + int num6 = 0; + if (idCli != ((DomainBase)x).Id) + { + idCli = ((DomainBase)x).Id; + html += ((ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + html += "

"; + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + x.Nome; + html = html + title + "


"; + string text25 = ((x.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + bool pessoaFisica3 = x.PessoaFisica; + html = html + ""; + if (pessoaFisica3) + { + html = html + ""; + } + else + { + num6++; + } + html += ""; + if (x.Atividade != null) + { + html = html + ""; + if (!pessoaFisica3) + { + num6++; + } + } + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + if (pessoaFisica3) + { + html = html + ""; + } + html = html + ""; + } + if (pessoaFisica3) + { + html = html + ""; + } + if (!string.IsNullOrWhiteSpace(x.Identidade)) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + TipoTelefone valueOrDefault3; + if ((x.Telefones != null || x.Emails != null) && (int)SelectedTipoExtrato != 2) + { + html += ""; + if (x.Telefones != null) + { + string text26 = ""; + foreach (ClienteTelefone telefone in x.Telefones) + { + string[] obj32 = new string[7] { text26, "
", null, null, null, null, null }; + TipoTelefone? tipo2 = ((TelefoneBase)telefone).Tipo; + object obj33; + if (!tipo2.HasValue) + { + obj33 = null; + } + else + { + valueOrDefault3 = tipo2.GetValueOrDefault(); + obj33 = ((object)(TipoTelefone)(ref valueOrDefault3)).ToString().ToUpper(); + } + obj32[2] = (string)obj33; + obj32[3] = " ("; + obj32[4] = ((TelefoneBase)telefone).Prefixo; + obj32[5] = ") "; + obj32[6] = ((TelefoneBase)telefone).Numero; + text26 = string.Concat(obj32); + } + html = html + "
"; + } + if (x.Emails != null && !ExtratoResumido) + { + string text27 = ""; + foreach (ClienteEmail email in x.Emails) + { + text27 = text27 + "
" + ((EmailBase)email).Email; + } + html = html + "
"; + } + num6++; + html += ""; + } + if (x.Enderecos != null && (int)SelectedTipoExtrato != 2) + { + string text28 = ""; + foreach (ClienteEndereco endereco in x.Enderecos) + { + text28 = text28 + "
" + ((EnderecoBase)endereco).Endereco + ", " + ((EnderecoBase)endereco).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco).Complemento) ? "" : (((EnderecoBase)endereco).Complemento + ", ")) + ((EnderecoBase)endereco).Bairro + " - " + ((EnderecoBase)endereco).Cidade + " - " + ((EnderecoBase)endereco).Estado + " - " + ((EnderecoBase)endereco).Cep; + } + html = html + "
"; + } + if (x.Profissao != null && (int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + if (x.Contatos != null && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + string text29 = ""; + foreach (MaisContato contato in x.Contatos) + { + string[] obj34 = new string[15] + { + text29, + "
NOME: ", + contato.Nome, + (!string.IsNullOrWhiteSpace(contato.Documento)) ? (", DOCUMENTO: " + contato.Documento) : "", + contato.Nascimento.HasValue ? (", NASCIMENTO: " + contato.Nascimento?.ToShortDateString()) : "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + object obj35; + if (!contato.Parentesco.HasValue) + { + obj35 = ""; + } + else + { + Parentesco? parentesco2 = contato.Parentesco; + object obj36; + if (!parentesco2.HasValue) + { + obj36 = null; + } + else + { + Parentesco valueOrDefault4 = parentesco2.GetValueOrDefault(); + obj36 = ((object)(Parentesco)(ref valueOrDefault4)).ToString().ToUpper(); + } + obj35 = ", PARENTESCO: " + (string?)obj36; + } + obj34[5] = (string)obj35; + obj34[6] = ((!string.IsNullOrWhiteSpace(contato.Banco) || !string.IsNullOrWhiteSpace(contato.Agencia) || !string.IsNullOrWhiteSpace(contato.Conta)) ? "
" : ""); + obj34[7] = ((!string.IsNullOrWhiteSpace(contato.Banco)) ? ("BANCO: " + contato.Banco) : ""); + obj34[8] = ((!string.IsNullOrWhiteSpace(contato.Agencia)) ? (((!string.IsNullOrWhiteSpace(contato.Banco)) ? ", AGÊNCIA: " : "AGÊNCIA: ") + contato.Agencia) : ""); + obj34[9] = ((!string.IsNullOrWhiteSpace(contato.Conta)) ? (((!string.IsNullOrWhiteSpace(contato.Banco) || !string.IsNullOrWhiteSpace(contato.Agencia)) ? ", CONTA: " : "CONTA: ") + contato.Conta) : ""); + obj34[10] = ((contato.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone)) || !string.IsNullOrWhiteSpace(contato.Email)) ? "
" : ""); + object obj37; + if (!contato.Tipo.HasValue) + { + obj37 = ""; + } + else + { + TipoTelefone? tipo2 = contato.Tipo; + object obj38; + if (!tipo2.HasValue) + { + obj38 = null; + } + else + { + valueOrDefault3 = tipo2.GetValueOrDefault(); + obj38 = ((object)(TipoTelefone)(ref valueOrDefault3)).ToString().ToUpper(); + } + obj37 = "TIPO DO TELEFONE: " + (string?)obj38; + } + obj34[11] = (string)obj37; + obj34[12] = ((!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone)) ? ((contato.Tipo.HasValue ? ", TELEFONE: (" : "TELEFONE: (") + contato.Prefixo + ") " + contato.Telefone) : ""); + obj34[13] = ((!string.IsNullOrWhiteSpace(contato.Email)) ? (((contato.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato.Prefixo) && !string.IsNullOrWhiteSpace(contato.Telefone))) ? ", EMAIL: " : "EMAIL: ") + contato.Email) : ""); + obj34[14] = "
"; + text29 = string.Concat(obj34); + } + html = html + "
"; + } + if (ObsCliente && ClienteVisibility && ObsClienteEnabled && !string.IsNullOrWhiteSpace(x.Observacao) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + x.Observacao = "
" + x.Observacao.Replace("\r\n", "
"); + html = html + "
"; + } + if (!string.IsNullOrWhiteSpace(x.Pasta) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + html += "

CLIENTE: " + x.Nome + "

CPF/CNPJ: " + x.Documento + "

" + text25 + ": " + x.Nascimento?.ToShortDateString() + "

FALECIDO: " + (x.Falecido ? "SIM" : "NÃO") + "

RAMO DE ATIVIDADE: " + x.Atividade.Nome + "

ESTADO CIVIL: " + (x.EstadoCivil.HasValue ? x.EstadoCivil.ToString().ToUpper() : "-") + "

SEXO: " + (x.Sexo.HasValue ? x.Sexo.ToString().ToUpper() : "-") + "

CLIENTE DESDE: " + ((!x.ClienteDesde.HasValue) ? "-" : x.ClienteDesde?.ToShortDateString()) + "

HABILITAÇÃO: " + ((!string.IsNullOrWhiteSpace(x.Habilitacao)) ? x.Habilitacao : "-") + "

CATEGORIA: " + ((!string.IsNullOrWhiteSpace(x.CategoriaHabilitacao)) ? x.CategoriaHabilitacao : "-") + "

1ª HAB.: " + ((!x.PrimeiraHabilitacao.HasValue) ? "-" : x.PrimeiraHabilitacao?.ToShortDateString()) + "

VENCIMENTO: " + ((!x.VencimentoHabilitacao.HasValue) ? "-" : x.VencimentoHabilitacao?.ToShortDateString()) + "

RG: " + ((!string.IsNullOrWhiteSpace(x.Identidade)) ? x.Identidade : "-") + "

ORGÃO EMISSOR: " + ((!string.IsNullOrWhiteSpace(x.Emissor)) ? x.Emissor : "-") + "

ESTADO EMISSOR: " + ((!string.IsNullOrWhiteSpace(x.EstadoEmissor)) ? x.EstadoEmissor : "-") + "

EXPEDIÇÃO: " + ((!x.Expedicao.HasValue) ? "-" : x.Expedicao?.ToShortDateString()) + "

BANCO: " + ((x.Banco != null) ? x.Banco.Nome : "-") + "

AGÊNCIA: " + ((!string.IsNullOrWhiteSpace(x.Agencia)) ? x.Agencia : "-") + "

CONTA: " + ((!string.IsNullOrWhiteSpace(x.Conta)) ? x.Conta : "-") + "

TIPO: " + ((!string.IsNullOrWhiteSpace(x.TipoConta)) ? x.TipoConta : "-") + "

CONTATOS: " + text26 + "

EMAILS: " + text27 + "

ENDEREÇOS: " + text28 + "

PROFISSÃO: " + x.Profissao.Nome + "

MAIS CONTATOS: " + text29 + "

OBSERVAÇÕES: " + x.Observacao + "

PASTA: " + x.Pasta + "

"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + } + }); + DateTime networkTime = Funcoes.GetNetworkTime(); + html = html + "

" + Recursos.Usuario.Nome + " - " + networkTime.Date.ToShortDateString() + "
"; + string tempPath = Path.GetTempPath(); + string text = $"{tempPath}{(object)(TipoExtrato)0}_{networkTime:ddMMyyyyhhmmss}.html"; + if (pdf) + { + text = $"{tempPath}{(object)(TipoExtrato)0}_{networkTime:ddMMyyyyhhmmss}.pdf"; + byte[] bytes = ((HtmlToPdfConverter)new NRecoHtmlToPdfConverter()).GeneratePdf(html); + File.WriteAllBytes(text, bytes); + } + else + { + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(html); + streamWriter.Close(); + } + Process.Start(text); + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Clientes == null) ? "" : ((Clientes.Count > 1) ? $"DE {Clientes.Count} CLIENTES" : ("DO CLIENTE " + Clientes[0].Nome))), 0L, (TipoTela)23, "NOMES DOS CLIENTES:\n" + string.Join("\n", Clientes.Select((Cliente x) => x.Nome)) + GerarOpcoes()); + Documentos = null; + Clientes = null; + } + else + { + if ((Documentos == null && Prospeccoes == null) || Clientes != null) + { + return; + } + html = ""; + title = ""; + TipoExtrato selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 0: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE"; + break; + case 1: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE SELECIONADA"; + if (tipoRelatorio.HasValue && (int)tipoRelatorio.GetValueOrDefault() == 4) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO RELATÓRIO DE RENOVAÇÕES"; + } + break; + case 2: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DE RELAÇÃO DE APÓLICES"; + break; + } + html += title; + html += "
"; + List sDocumento = new List(); + if (Documentos != null && Documentos.Count > 0) + { + bool configEndosso = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 42); + foreach (Documento documento2 in Documentos) + { + Documento val = documento2; + val.Parcelas = await new ParcelaServico().BuscarParcelasAsync(((DomainBase)documento2).Id); + Controle controle = documento2.Controle; + controle.Cliente = await _clienteServico.BuscarCliente(((DomainBase)documento2.Controle.Cliente).Id); + Cliente cliente = documento2.Controle.Cliente; + cliente.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)documento2.Controle.Cliente).Id); + cliente = documento2.Controle.Cliente; + cliente.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)documento2.Controle.Cliente).Id); + } + bool primeiro = true; + foreach (Documento documento in Documentos) + { + List itensDocumentos = new List(); + List list = ((!Endossos) ? (await new ItemServico().BuscarItens(((DomainBase)documento.Controle).Id, (StatusItem)0)).ToList() : (await new ItemServico().BuscarItens(((DomainBase)documento).Id, (StatusItem)2)).ToList()); + List list2 = list; + if (_itensSelecionados != null && _itensSelecionados.Count > 0) + { + list2.ForEach(delegate(Item x) + { + if (_itensSelecionados.Any((Item y) => ((DomainBase)y).Id == ((DomainBase)x).Id)) + { + itensDocumentos.Add(x); + } + }); + } + else + { + itensDocumentos.AddRange(list2); + } + List source = await new PerfilServico().BuscarPerfis(((DomainBase)documento.Controle).Id); + long num = 0L; + int color = 0; + if (!primeiro) + { + html += (ExtratoPorPagina ? "
" : ""); + } + if (num != ((DomainBase)documento.Controle.Cliente).Id) + { + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled && !ExtratoPorPagina) ? "
" : ""); + html += "

"; + selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 0: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + documento.Controle.Cliente.Nome; + break; + case 1: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE SELECIONADA: " + documento.Apolice; + if (tipoRelatorio.HasValue && (int)tipoRelatorio.GetValueOrDefault() == 4) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DA APÓLICE: " + documento.Apolice; + } + if (!string.IsNullOrEmpty(documento.Endosso) && !documento.Endosso.Equals("0")) + { + title = title + " E DO ENDOSSO: " + documento.Endosso; + } + if (SomenteEndossos) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO ENDOSSO: " + documento.Endosso; + } + break; + case 2: + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DE RELAÇÃO DE APÓLICES"; + break; + } + html = html + title + "


"; + html += ""; + TipoTelefone valueOrDefault; + if (ExtratoResumido) + { + bool pessoaFisica = documento.Controle.Cliente.PessoaFisica; + if ((!Endossos || !SomenteEndossos) && !sDocumento.Any((long x) => x == ((DomainBase)documento.Controle).Id)) + { + html = html + ""; + if (pessoaFisica) + { + html = html + ""; + } + html = html + ""; + if ((int)SelectedTipoExtrato != 2) + { + string text2 = ((documento.Controle.Cliente.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + html = html + ""; + } + else + { + color++; + } + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + string text3 = ""; + if (documento.Controle.Cliente.Telefones != null) + { + foreach (ClienteTelefone telefone2 in documento.Controle.Cliente.Telefones) + { + string[] obj = new string[7] { text3, "
", null, null, null, null, null }; + TipoTelefone? tipo = ((TelefoneBase)telefone2).Tipo; + object obj2; + if (!tipo.HasValue) + { + obj2 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj2 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj[2] = (string)obj2; + obj[3] = " ("; + obj[4] = ((TelefoneBase)telefone2).Prefixo; + obj[5] = ") "; + obj[6] = ((TelefoneBase)telefone2).Numero; + text3 = string.Concat(obj); + } + } + html = html + "
"; + string text4 = ""; + if (documento.Controle.Cliente.Emails != null) + { + foreach (ClienteEmail email2 in documento.Controle.Cliente.Emails) + { + text4 = text4 + "
" + ((EmailBase)email2).Email; + } + } + html = html + "
"; + string text5 = ""; + if (documento.Controle.Cliente.Enderecos != null) + { + foreach (ClienteEndereco endereco2 in documento.Controle.Cliente.Enderecos) + { + text5 = text5 + "
" + ((EnderecoBase)endereco2).Endereco + ", " + ((EnderecoBase)endereco2).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco2).Complemento) ? "" : (((EnderecoBase)endereco2).Complemento + ", ")) + ((EnderecoBase)endereco2).Bairro + " - " + ((EnderecoBase)endereco2).Cidade + " - " + ((EnderecoBase)endereco2).Estado + " - " + ((EnderecoBase)endereco2).Cep; + } + } + html = html + "
"; + html += ""; + } + html += "

CLIENTE: " + documento.Controle.Cliente.Nome + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

" + text2 + ": " + documento.Controle.Cliente.Nascimento?.ToShortDateString() + "

"; + if (pessoaFisica) + { + html = html + "

ESTADO CIVIL: " + (documento.Controle.Cliente.EstadoCivil.HasValue ? documento.Controle.Cliente.EstadoCivil.ToString().ToUpper() : "-") + "

SEXO: " + (documento.Controle.Cliente.Sexo.HasValue ? documento.Controle.Cliente.Sexo.ToString().ToUpper() : "-") + "

BANCO: " + ((documento.Controle.Cliente.Banco != null) ? documento.Controle.Cliente.Banco.Nome : "-") + "

AGÊNCIA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Agencia)) ? documento.Controle.Cliente.Agencia : "-") + "

CONTA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Conta)) ? documento.Controle.Cliente.Conta : "-") + "

TIPO: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.TipoConta)) ? documento.Controle.Cliente.TipoConta : "-") + "

CONTATOS: " + (string.IsNullOrEmpty(text3) ? "-" : text3) + "

EMAILS: " + (string.IsNullOrEmpty(text4) ? "-" : text4) + "

ENDEREÇOS: " + (string.IsNullOrEmpty(text5) ? "-" : text5) + "

"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + } + else + { + html = html + "

CLIENTE: " + documento.Controle.Cliente.Nome + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

"; + } + if ((int)SelectedTipoExtrato == 0) + { + return; + } + color = 0; + Documento val2 = documento.Controle.Documentos?.LastOrDefault((Func)((Documento x) => !x.Excluido && x.Ordem != 0)); + html = html + "
"; + if (!documento.NegocioCorretora.HasValue) + { + documento.NegocioCorretora = (NegocioCorretora)(((int)documento.Situacao == 2 && documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + html = html + ""; + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + string text6 = ""; + if (documento.Estipulante1 != null) + { + text6 = text6 + documento.Estipulante1.Nome + ", "; + } + if (documento.Estipulante2 != null) + { + text6 = text6 + documento.Estipulante2.Nome + ", "; + } + if (documento.Estipulante3 != null) + { + text6 = text6 + documento.Estipulante3.Nome + ", "; + } + if (documento.Estipulante4 != null) + { + text6 = text6 + documento.Estipulante4.Nome + ", "; + } + if (documento.Estipulante5 != null) + { + text6 = text6 + documento.Estipulante5.Nome + ", "; + } + if (!string.IsNullOrWhiteSpace(text6)) + { + int startIndex = text6.LastIndexOf(", ", StringComparison.Ordinal); + text6 = text6.Remove(startIndex, 2).Insert(startIndex, "."); + } + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + else + { + html = html + ""; + } + html = html + ""; + html += "

RAMO: " + documento.Controle.Ramo.Nome + "

VIGÊNCIA INICIAL: " + documento.Vigencia1.ToShortDateString() + "

VIGÊNCIA FINAL: " + ((!documento.Vigencia2.HasValue) ? "-" : documento.Vigencia2?.ToShortDateString()) + "

CONTRATO: " + (string.IsNullOrWhiteSpace(documento.Apolice) ? "-" : documento.Apolice) + "

POSSUI ENDOSSO? " + (documento.TemEndosso ? "SIM" : "NÃO") + "

ADITAMENTO: " + ((!string.IsNullOrWhiteSpace(documento.Endosso)) ? documento.Endosso : ((configEndosso && val2 != null) ? val2.Endosso : "-")) + "

NEGÓCIO CORRETORA: " + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "

STATUS DO SEGURO: " + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "

VENDEDOR: " + ((documento.VendedorPrincipal == null) ? "-" : documento.VendedorPrincipal.Nome) + "

ESTIPULANTE(S): " + (string.IsNullOrWhiteSpace(text6) ? "-" : text6) + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

APÓLICE SINISTRADA: " + (documento.Sinistro ? "SIM" : "NÃO") + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

FORMA PAGAMENTO: " + ValidationHelper.GetDescription((Enum)(object)documento.FormaPagamento) + "

"; + if (PremioParcela || ExtratoResumido) + { + html += ""; + if ((ComissaoDocumento && ComissaoDocumentoEnabled) || ExtratoResumido) + { + html = html + ""; + } + html = html + ""; + html += "

COMISSÃO: " + $"{Math.Round(documento.Comissao, 2):n2}%" + "

PRÊMIO LÍQUIDO: " + $"{Math.Round(documento.PremioLiquido, 2):c}" + "

ADICIONAL: " + $"{Math.Round(documento.PremioAdicional, 2):c}" + "

CUSTO APÓLICE: " + $"{Math.Round(documento.Custo, 2):c}" + "

I.O.F.: " + $"{Math.Round(documento.Iof, 2):c}" + "

PRÊMIO TOTAL: " + $"{Math.Round(documento.PremioTotal, 2):c}" + "

Nº PARCELAS: " + documento.NumeroParcelas + "

"; + } + if (PerfilCondutor && PerfilVisibility && ((DomainBase)documento.Controle.Ramo).Id == 5 && PerfilCondutorEnabled) + { + List list3 = source.ToList(); + foreach (Perfil item3 in list3) + { + color = 0; + if (!string.IsNullOrEmpty(item3.Nome)) + { + html = html + "

" + $"CONDUTOR {list3.IndexOf(item3) + 1}: " + "" + item3.Nome + "

CPF: " + (string.IsNullOrWhiteSpace(item3.Cpf) ? "-" : item3.Cpf) + "

NASCIMENTO: " + ((!item3.Nascimento.HasValue) ? "-" : item3.Nascimento?.ToShortDateString()) + "

ESTADO CIVIL: " + ((!item3.EstadoCivil.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.EstadoCivil)) + "

SEXO: " + ((!item3.Sexo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.Sexo)) + "

RELAÇÃO SEGURADO/CONDUTOR: " + ValidationHelper.GetDescription((Enum)(object)item3.Relacao) + "

GARAGEM NA RESIDÊNCIA: " + ((!item3.GaragemResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemResidencia)) + "

GARAGEM NO TRABALHO: " + ((!item3.GaragemTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemTrabalho)) + "

GARAGEM NO ESTUDO: " + ((!item3.GaragemEstudo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.GaragemEstudo)) + "

TIPO DE RESIDÊNCIA: " + ((!item3.TipoResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.TipoResidencia)) + "

DISTÂNCIA ATÉ O TRABALHO: " + ((!item3.DistanciaResidenciaTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.DistanciaResidenciaTrabalho)) + "

USO PROFISSIONAL: " + ((item3.UsoProfissional.HasValue && item3.UsoProfissional.Value) ? "SIM" : "NÃO") + "

USO POR DEPENDENTES: " + ((!item3.UsoDependentes.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item3.UsoDependentes)) + "

ISENÇÃO DE IMPOSTOS: " + ((item3.Isencao.HasValue && item3.Isencao.Value) ? "SIM" : "NÃO") + "

"; + } + } + } + List itens2 = itensDocumentos.ToList(); + if (itens2.Count == 0) + { + html += "

ESTA APÓLICE NÃO POSSUI ITENS

"; + } + else + { + color = 0; + foreach (Item item2 in itens2) + { + if (item2.Sinistros.Count > 0) + { + Item val3 = item2; + val3.Sinistros = await new SinistroServico().BuscarControles(((DomainBase)item2).Id); + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + html += (((int)SelectedTipoExtrato != 2 || itens2.IndexOf(item2) == 0) ? "
" : ""); + html += ""; + html += ""; + html += ""; + if ((int)SelectedTipoExtrato == 2) + { + html = html + ""; + } + else + { + switch (((DomainBase)documento.Controle.Ramo).Id) + { + case 1L: + case 2L: + case 3L: + case 15L: + case 18L: + { + Item val3 = item2; + val3.Patrimonial = await new ItemServico().BuscaPatrimonial(((DomainBase)item2).Id); + html = html + ""; + break; + } + case 5L: + case 37L: + { + Item val3 = item2; + val3.Auto = await new ItemServico().BuscaAuto(((DomainBase)item2).Id); + string[] obj3 = new string[26] + { + html, + ""; + html = string.Concat(obj3); + break; + } + default: + html = html + ""; + break; + } + } + if (item2.Sinistros.Count > 0) + { + Item obj4 = item2; + DateTime? obj5; + if (obj4 == null) + { + obj5 = null; + } + else + { + IList sinistros = obj4.Sinistros; + if (sinistros == null) + { + obj5 = null; + } + else + { + ControleSinistro? obj6 = sinistros.LastOrDefault(); + if (obj6 == null) + { + obj5 = null; + } + else + { + List sinistros2 = obj6.Sinistros; + if (sinistros2 == null) + { + obj5 = null; + } + else + { + Sinistro? obj7 = sinistros2.LastOrDefault(); + obj5 = ((obj7 != null) ? obj7.DataReclamacao : null); + } + } + } + } + DateTime? dateTime = obj5; + string text7 = (dateTime.HasValue ? dateTime.Value.ToShortDateString() : "-"); + string[] obj8 = new string[14] + { + html, ""; + html = string.Concat(obj8); + } + html += ""; + if ((int)SelectedTipoExtrato != 2) + { + string[] obj9 = new string[6] { html, ""; + html = string.Concat(obj9); + long id = ((DomainBase)documento.Controle.Ramo).Id; + long num3 = id - 1; + if ((ulong)num3 <= 58uL) + { + switch (num3) + { + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + case 4L: + case 36L: + { + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + string[] array = new string[26]; + array[0] = html; + array[1] = ""; + html = string.Concat(array); + break; + } + case 5L: + case 6L: + case 8L: + case 9L: + case 52L: + { + Item val3 = item2; + val3.Vida = await new ItemServico().BuscaVida(((DomainBase)item2).Id); + if (!item2.Sinistrado || !BeneficiariosItens || !BeneficiariosItensEnabled) + { + break; + } + html = html + ""; + break; + } + case 3L: + case 7L: + case 15L: + case 16L: + case 18L: + case 22L: + case 23L: + case 25L: + case 27L: + case 30L: + case 32L: + case 38L: + case 40L: + case 43L: + case 48L: + case 58L: + { + Item val3 = item2; + val3.RiscosDiversos = await new ItemServico().BuscaRiscosDiversos(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 12L: + { + Item val3 = item2; + val3.Aeronautico = await new ItemServico().BuscaAeronautico(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 19L: + { + Item val3 = item2; + val3.Granizo = await new ItemServico().BuscaGranizo(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + } + } + } + html += "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

" + $"ITEM {item2.Ordem}: " + "" + ((EnderecoBase)item2.Patrimonial).Endereco + ", " + ((EnderecoBase)item2.Patrimonial).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)item2.Patrimonial).Complemento) ? "" : (((EnderecoBase)item2.Patrimonial).Complemento + ", ")) + ((EnderecoBase)item2.Patrimonial).Bairro + " - " + ((EnderecoBase)item2.Patrimonial).Cidade + " - " + ((EnderecoBase)item2.Patrimonial).Estado + " - " + ((EnderecoBase)item2.Patrimonial).Cep + "

", + $"ITEM {item2.Ordem}: ", + "
", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + Fabricante fabricante = item2.Auto.Fabricante; + obj3[6] = ((fabricante != null) ? fabricante.Descricao : null); + obj3[7] = " "; + obj3[8] = item2.Auto.Modelo; + obj3[9] = " ("; + obj3[10] = item2.Auto.AnoFabricacao; + obj3[11] = "/"; + obj3[12] = item2.Auto.AnoModelo; + obj3[13] = ")
PLACA: "; + obj3[14] = item2.Auto.Placa; + obj3[15] = ", CHASSI: "; + obj3[16] = item2.Auto.Chassi; + obj3[17] = "
C.I.: "; + obj3[18] = item2.Auto.Ci; + obj3[19] = ", RENAVAM: "; + obj3[20] = item2.Auto.Renavam; + obj3[21] = ", CEP PERNOITE: "; + obj3[22] = item2.Auto.CepPernoite; + obj3[23] = "
FINANCIADO: "; + obj3[24] = (item2.Auto.Financiado.GetValueOrDefault() ? "SIM" : "NÃO"); + obj3[25] = "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

SINISTRO STATUS: "; + obj8[4] = ValidationHelper.GetDescription((Enum)(object)item2.Sinistros.LastOrDefault().Sinistros.LastOrDefault().StatusSinistro); + obj8[5] = "

DATA: "; + obj8[8] = text7; + obj8[9] = "

VALOR: "; + obj8[12] = ValidationHelper.ToCurrency(item2.Sinistros.LastOrDefault().Sinistros.LastOrDefault().Valor, "pt-BR"); + obj8[13] = "

ATIVO: "; + obj9[4] = ((!item2.Substituido.HasValue) ? "SIM" : "NÃO"); + obj9[5] = "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Patrimonial.Bens) ? "-" : item2.Patrimonial.Bens) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Auto.Observacao) ? "-" : item2.Auto.Observacao) + "

COBERTURA PADRÃO: "; + TipoCobertura? tipoCobertura = item2.Auto.TipoCobertura; + array[4] = (tipoCobertura.HasValue ? ValidationHelper.GetDescription((Enum)(object)tipoCobertura.GetValueOrDefault()) : null); + array[5] = "

BÔNUS: "; + array[8] = item2.Auto.Bonus.ToString(); + array[9] = "

REGIÃO DE CIRCULAÇÃO: "; + array[12] = (string.IsNullOrWhiteSpace(item2.Auto.RegiaoCirculacao) ? "-" : item2.Auto.RegiaoCirculacao); + array[13] = "

TABELA DE REFERÊNCIA: "; + TabelaReferencia? tabelaReferencia = item2.Auto.TabelaReferencia; + array[16] = (tabelaReferencia.HasValue ? ValidationHelper.GetDescription((Enum)(object)tabelaReferencia.GetValueOrDefault()) : null); + array[17] = "

FIPE: "; + array[20] = (string.IsNullOrWhiteSpace(item2.Auto.Fipe) ? "-" : item2.Auto.Fipe); + array[21] = "

% DE REFERÊNCIA: "; + array[24] = $"{item2.Auto.PorcentagemReferencia}%"; + array[25] = "

BENEFICIÁRIOS: "; + string text8 = ""; + foreach (ControleSinistro sinistro in item2.Sinistros) + { + if (sinistro.Sinistros == null) + { + continue; + } + foreach (Sinistro sinistro2 in sinistro.Sinistros) + { + if (!string.IsNullOrWhiteSpace(sinistro2.SinistroVida.Beneficiario)) + { + text8 = text8 + sinistro2.SinistroVida.Beneficiario + ", "; + } + } + } + if (!string.IsNullOrWhiteSpace(text8)) + { + int startIndex2 = text8.LastIndexOf(", ", StringComparison.Ordinal); + text8 = text8.Remove(startIndex2, 2).Insert(startIndex2, "."); + } + html = html + text8 + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.RiscosDiversos.Observacao) ? "-" : item2.RiscosDiversos.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Aeronautico.Observacao) ? "-" : item2.Aeronautico.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Granizo.Observacao) ? "-" : item2.Granizo.Observacao) + "

"; + if ((int)SelectedTipoExtrato != 2) + { + ObservableCollection observableCollection = await new ItemServico().BuscarCoberturasPorItemAsync(((DomainBase)item2).Id); + if (observableCollection.Count > 0 && Coberturas) + { + html += "
"; + foreach (Cobertura item4 in observableCollection) + { + color++; + html = html + ""; + } + html += "

COBERTURA

FRANQUIA

LMI

PRÊMIO

" + item4.Observacao + "

" + $"{item4.Franquia:c}" + "

" + $"{item4.Lmi:c}" + "

" + $"{item4.Premio:c}" + "

"; + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + } + if ((int)SelectedTipoExtrato != 2) + { + color = 0; + } + } + } + } + else + { + if ((!Endossos || !SomenteEndossos) && !sDocumento.Any((long x) => x == ((DomainBase)documento.Controle).Id)) + { + string text9 = ((documento.Controle.Cliente.Atividade == null) ? "NASCIMENTO" : "ABERTURA"); + bool pessoaFisica2 = documento.Controle.Cliente.PessoaFisica; + html = html + ""; + if (pessoaFisica2) + { + html = html + ""; + } + else + { + color++; + } + html += ""; + if (documento.Controle.Cliente.Atividade != null) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + if (documento.Controle.Cliente.Profissao != null && (int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + else + { + color++; + } + html += ""; + } + if (pessoaFisica2) + { + html = html + ""; + } + if (!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) + { + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + if ((documento.Controle.Cliente.Telefones != null || documento.Controle.Cliente.Emails != null) && (int)SelectedTipoExtrato != 2) + { + html += ""; + if (documento.Controle.Cliente.Telefones != null) + { + string text10 = ""; + foreach (ClienteTelefone telefone3 in documento.Controle.Cliente.Telefones) + { + string[] obj10 = new string[10] { text10, "
", null, null, null, null, null, null, null, null }; + TipoTelefone? tipo = ((TelefoneBase)telefone3).Tipo; + object obj11; + if (!tipo.HasValue) + { + obj11 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj11 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj10[2] = (string)obj11; + obj10[3] = " ("; + obj10[4] = ((TelefoneBase)telefone3).Prefixo; + obj10[5] = ") "; + obj10[6] = ((TelefoneBase)telefone3).Numero; + obj10[7] = " ("; + obj10[8] = telefone3.Observacao; + obj10[9] = ") "; + text10 = string.Concat(obj10); + } + html = html + "
"; + } + if (documento.Controle.Cliente.Emails != null && !ExtratoResumido) + { + string text11 = ""; + foreach (ClienteEmail email3 in documento.Controle.Cliente.Emails) + { + text11 = text11 + "
" + ((EmailBase)email3).Email; + } + html = html + "
"; + } + else if (documento.Controle.Cliente.Enderecos != null && (int)SelectedTipoExtrato != 2) + { + string text12 = ""; + foreach (ClienteEndereco endereco3 in documento.Controle.Cliente.Enderecos) + { + text12 = text12 + "
" + ((EnderecoBase)endereco3).Endereco + ", " + ((EnderecoBase)endereco3).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco3).Complemento) ? "" : (((EnderecoBase)endereco3).Complemento + ", ")) + ((EnderecoBase)endereco3).Bairro + " - " + ((EnderecoBase)endereco3).Cidade + " - " + ((EnderecoBase)endereco3).Estado + " - " + ((EnderecoBase)endereco3).Cep; + } + html = html + "
"; + } + color++; + html += ""; + } + if (documento.Controle.Cliente.Enderecos != null && (int)SelectedTipoExtrato != 2 && documento.Controle.Cliente.Emails == null && ExtratoResumido) + { + string text13 = ""; + foreach (ClienteEndereco endereco4 in documento.Controle.Cliente.Enderecos) + { + text13 = text13 + "
" + ((EnderecoBase)endereco4).Endereco + ", " + ((EnderecoBase)endereco4).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco4).Complemento) ? "" : (((EnderecoBase)endereco4).Complemento + ", ")) + ((EnderecoBase)endereco4).Bairro + " - " + ((EnderecoBase)endereco4).Cidade + " - " + ((EnderecoBase)endereco4).Estado + " - " + ((EnderecoBase)endereco4).Cep; + } + html = html + "
"; + } + if (documento.Controle.Cliente.Contatos != null && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + string text14 = ""; + foreach (MaisContato contato2 in documento.Controle.Cliente.Contatos) + { + string[] obj12 = new string[15] + { + text14, + "
NOME: ", + contato2.Nome, + (!string.IsNullOrWhiteSpace(contato2.Documento)) ? (", DOCUMENTO: " + contato2.Documento) : "", + contato2.Nascimento.HasValue ? (", NASCIMENTO: " + contato2.Nascimento?.ToShortDateString()) : "", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + object obj13; + if (!contato2.Parentesco.HasValue) + { + obj13 = ""; + } + else + { + Parentesco? parentesco = contato2.Parentesco; + object obj14; + if (!parentesco.HasValue) + { + obj14 = null; + } + else + { + Parentesco valueOrDefault2 = parentesco.GetValueOrDefault(); + obj14 = ((object)(Parentesco)(ref valueOrDefault2)).ToString().ToUpper(); + } + obj13 = ", PARENTESCO: " + (string?)obj14; + } + obj12[5] = (string)obj13; + obj12[6] = ((!string.IsNullOrWhiteSpace(contato2.Banco) || !string.IsNullOrWhiteSpace(contato2.Agencia) || !string.IsNullOrWhiteSpace(contato2.Conta)) ? "
" : ""); + obj12[7] = ((!string.IsNullOrWhiteSpace(contato2.Banco)) ? ("BANCO: " + contato2.Banco) : ""); + obj12[8] = ((!string.IsNullOrWhiteSpace(contato2.Agencia)) ? (((!string.IsNullOrWhiteSpace(contato2.Banco)) ? ", AGÊNCIA: " : "AGÊNCIA: ") + contato2.Agencia) : ""); + obj12[9] = ((!string.IsNullOrWhiteSpace(contato2.Conta)) ? (((!string.IsNullOrWhiteSpace(contato2.Banco) || !string.IsNullOrWhiteSpace(contato2.Agencia)) ? ", CONTA: " : "CONTA: ") + contato2.Conta) : ""); + obj12[10] = ((contato2.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone)) || !string.IsNullOrWhiteSpace(contato2.Email)) ? "
" : ""); + object obj15; + if (!contato2.Tipo.HasValue) + { + obj15 = ""; + } + else + { + TipoTelefone? tipo = contato2.Tipo; + object obj16; + if (!tipo.HasValue) + { + obj16 = null; + } + else + { + valueOrDefault = tipo.GetValueOrDefault(); + obj16 = ((object)(TipoTelefone)(ref valueOrDefault)).ToString().ToUpper(); + } + obj15 = "TIPO DO TELEFONE: " + (string?)obj16; + } + obj12[11] = (string)obj15; + obj12[12] = ((!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone)) ? ((contato2.Tipo.HasValue ? ", TELEFONE: (" : "TELEFONE: (") + contato2.Prefixo + ") " + contato2.Telefone) : ""); + obj12[13] = ((!string.IsNullOrWhiteSpace(contato2.Email)) ? (((contato2.Tipo.HasValue || (!string.IsNullOrWhiteSpace(contato2.Prefixo) && !string.IsNullOrWhiteSpace(contato2.Telefone))) ? ", EMAIL: " : "EMAIL: ") + contato2.Email) : ""); + obj12[14] = "
"; + text14 = string.Concat(obj12); + } + html = html + "
"; + } + if (documento.Controle.Cliente.Enderecos != null && !ExtratoResumido) + { + string text15 = ""; + foreach (ClienteEndereco endereco5 in documento.Controle.Cliente.Enderecos) + { + text15 = text15 + "
" + ((EnderecoBase)endereco5).Endereco + ", " + ((EnderecoBase)endereco5).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)endereco5).Complemento) ? "" : (((EnderecoBase)endereco5).Complemento + ", ")) + ((EnderecoBase)endereco5).Bairro + " - " + ((EnderecoBase)endereco5).Cidade + " - " + ((EnderecoBase)endereco5).Estado + " - " + ((EnderecoBase)endereco5).Cep; + } + html = html + "
"; + } + if (ObsCliente && ClienteVisibility && ObsClienteEnabled && !string.IsNullOrWhiteSpace(documento.Controle.Cliente.Observacao) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + documento.Controle.Cliente.Observacao = "
" + documento.Controle.Cliente.Observacao.Replace("\r\n", "
"); + html = html + "
"; + } + if (!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Pasta) && (int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html = html + ""; + } + html += "

CLIENTE: " + documento.Controle.Cliente.Nome + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

" + text9 + ": " + documento.Controle.Cliente.Nascimento?.ToShortDateString() + "

FALECIDO: " + (documento.Controle.Cliente.Falecido ? "SIM" : "NÃO") + "

RAMO DE ATIVIDADE: " + documento.Controle.Cliente.Atividade.Nome + "

"; + if (pessoaFisica2) + { + html = html + "ESTADO CIVIL: " + (documento.Controle.Cliente.EstadoCivil.HasValue ? documento.Controle.Cliente.EstadoCivil.ToString().ToUpper() : "-") + "

SEXO: " + (documento.Controle.Cliente.Sexo.HasValue ? documento.Controle.Cliente.Sexo.ToString().ToUpper() : "-") + "

"; + } + html = html + "

CLIENTE DESDE: " + ((!documento.Controle.Cliente.ClienteDesde.HasValue) ? "-" : documento.Controle.Cliente.ClienteDesde?.ToShortDateString()) + "

PROFISSÃO: " + documento.Controle.Cliente.Profissao.Nome + "

HABILITAÇÃO: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Habilitacao)) ? documento.Controle.Cliente.Habilitacao : "-") + "

CATEGORIA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.CategoriaHabilitacao)) ? documento.Controle.Cliente.CategoriaHabilitacao : "-") + "

1ª HAB.: " + ((!documento.Controle.Cliente.PrimeiraHabilitacao.HasValue) ? "-" : documento.Controle.Cliente.PrimeiraHabilitacao?.ToShortDateString()) + "

VENCIMENTO: " + ((!documento.Controle.Cliente.VencimentoHabilitacao.HasValue) ? "-" : documento.Controle.Cliente.VencimentoHabilitacao?.ToShortDateString()) + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

ORGÃO EMISSOR: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Emissor)) ? documento.Controle.Cliente.Emissor : "-") + "

ESTADO EMISSOR: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.EstadoEmissor)) ? documento.Controle.Cliente.EstadoEmissor : "-") + "

EXPEDIÇÃO: " + ((!documento.Controle.Cliente.Expedicao.HasValue) ? "-" : documento.Controle.Cliente.Expedicao?.ToShortDateString()) + "

BANCO: " + ((documento.Controle.Cliente.Banco != null) ? documento.Controle.Cliente.Banco.Nome : "-") + "

AGÊNCIA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Agencia)) ? documento.Controle.Cliente.Agencia : "-") + "

CONTA: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Conta)) ? documento.Controle.Cliente.Conta : "-") + "

TIPO: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.TipoConta)) ? documento.Controle.Cliente.TipoConta : "-") + "

CONTATOS: " + text10 + "

EMAILS: " + text11 + "

ENDEREÇOS: " + text12 + "

ENDEREÇOS: " + text13 + "

MAIS CONTATOS: " + text14 + "

ENDEREÇOS: " + text15 + "

OBSERVAÇÕES: " + documento.Controle.Cliente.Observacao + "

PASTA: " + documento.Controle.Cliente.Pasta + "

"; + if (!primeiro) + { + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + } + } + else + { + html = html + "

CLIENTE: " + documento.Controle.Cliente.Nome + "

RG: " + ((!string.IsNullOrWhiteSpace(documento.Controle.Cliente.Identidade)) ? documento.Controle.Cliente.Identidade : "-") + "

CPF/CNPJ: " + documento.Controle.Cliente.Documento + "

"; + } + if ((int)SelectedTipoExtrato == 0) + { + return; + } + color = 0; + html = html + "
"; + if (!documento.NegocioCorretora.HasValue) + { + documento.NegocioCorretora = (NegocioCorretora)(((int)documento.Situacao == 2 && documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); + } + if (ComissaoDocumento && ComissaoDocumentoEnabled) + { + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + else + { + html = html + ""; + } + } + else if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + } + html = html + ""; + if ((int)SelectedTipoExtrato != 2 && !ExtratoResumido) + { + html += ""; + string text16 = ""; + if (documento.Estipulante1 != null) + { + text16 = text16 + documento.Estipulante1.Nome + ", "; + } + if (documento.Estipulante2 != null) + { + text16 = text16 + documento.Estipulante2.Nome + ", "; + } + if (documento.Estipulante3 != null) + { + text16 = text16 + documento.Estipulante3.Nome + ", "; + } + if (documento.Estipulante4 != null) + { + text16 = text16 + documento.Estipulante4.Nome + ", "; + } + if (documento.Estipulante5 != null) + { + text16 = text16 + documento.Estipulante5.Nome + ", "; + } + if (!string.IsNullOrWhiteSpace(text16)) + { + int startIndex3 = text16.LastIndexOf(", ", StringComparison.Ordinal); + text16 = text16.Remove(startIndex3, 2).Insert(startIndex3, "."); + } + html = html + ""; + } + if ((int)SelectedTipoExtrato != 2) + { + html = html + ""; + if (documento.Controle.SeguradoraAnterior != null && !ExtratoResumido) + { + html = html + ""; + } + } + else + { + html = html + ""; + } + html += "

RAMO: " + documento.Controle.Ramo.Nome + "

VIGÊNCIA INICIAL: " + documento.Vigencia1.ToShortDateString() + "

VIGÊNCIA FINAL: " + ((!documento.Vigencia2.HasValue) ? "-" : documento.Vigencia2?.ToShortDateString()) + "

CONTRATO: " + (string.IsNullOrWhiteSpace(documento.Apolice) ? "-" : documento.Apolice) + "

POSSUI ENDOSSO? " + (documento.TemEndosso ? "SIM" : "NÃO") + "

ADITAMENTO: " + ((!string.IsNullOrWhiteSpace(documento.Endosso)) ? documento.Endosso : ((configEndosso && documento.Controle.Documentos.Where((Documento x) => !x.Excluido && x.Ordem != 0).ToList().Count > 0) ? documento.Controle.Documentos.Last((Documento x) => !x.Excluido && x.Ordem != 0).Endosso : "-")) + "

APÓLICE ANTERIOR: " + (string.IsNullOrWhiteSpace(documento.ApoliceAnterior) ? "-" : documento.ApoliceAnterior) + "

BANCO: " + ((documento.Banco == null) ? "-" : documento.Banco.Nome) + "

AGÊNCIA: " + (string.IsNullOrWhiteSpace(documento.Agencia) ? "-" : documento.Agencia) + "

CONTA: " + (string.IsNullOrWhiteSpace(documento.Conta) ? "-" : documento.Conta) + "

NUMERO CARTÃO: " + (string.IsNullOrWhiteSpace(documento.NumeroCartao) ? "-" : documento.NumeroCartao) + "

VENCIMENTO: " + (string.IsNullOrWhiteSpace(documento.VencimentoCartao) ? "-" : documento.VencimentoCartao) + "

BANDEIRA: " + ((!documento.Bandeira.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)documento.Bandeira)) + "

TITULAR/PROPONENTE: " + (string.IsNullOrWhiteSpace(documento.NomeProponente) ? "-" : documento.NomeProponente) + "

NEGÓCIO CORRETORA: " + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "

STATUS DO SEGURO: " + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "

COMISSÃO: " + $"{documento.Comissao}%" + "

COMISSÃO: " + $"{documento.Comissao}%" + "

NEGÓCIO CORRETORA: " + ValidationHelper.GetDescription((Enum)(object)documento.NegocioCorretora) + "

STATUS DO SEGURO: " + ValidationHelper.GetDescription((Enum)(object)documento.Situacao) + "

VENDEDOR: " + ((documento.VendedorPrincipal == null) ? "-" : documento.VendedorPrincipal.Nome) + "

REMESSA: " + ((!documento.Remessa.HasValue) ? "-" : documento.Remessa?.ToShortDateString()) + "

EMISSÃO: " + ((!documento.Emissao.HasValue) ? "-" : documento.Emissao?.ToShortDateString()) + "

ESTIPULANTE(S): " + (string.IsNullOrWhiteSpace(text16) ? "-" : text16) + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

APÓLICE SINISTRADA: " + (documento.Sinistro ? "SIM" : "NÃO") + "

SEGURADORA ANTERIOR: " + documento.Controle.SeguradoraAnterior.Nome + "

SEGURADORA: " + documento.Controle.Seguradora.Nome + "

"; + if (!ExtratoResumido && (PremioParcela || ObsApoliceEnabled)) + { + html += ""; + if (PremioParcela) + { + html = html + ""; + html += ""; + html += "

PRÊMIO LÍQUIDO:
" + documento.PremioLiquido.ToString("c") + "

ADICIONAL:
" + documento.PremioAdicional.ToString("c") + "

CUSTO APÓLICE:
" + documento.Custo.ToString("c") + "

I.O.F.:
" + documento.Iof.ToString("c") + "

PRÊMIO TOTAL:
" + documento.PremioTotal.ToString("c") + "


"; + ObservableCollection parcelas = documento.Parcelas; + if (parcelas != null && parcelas.Count > 0) + { + html += ""; + foreach (Parcela parcela in documento.Parcelas) + { + html = html + ""; + } + } + } + if (ObsApolice && ObsApoliceEnabled) + { + html = html + ""; + } + html += "

PARCELA

VENCIMENTO

VALOR

FORMA DE PAGAMENTO

" + parcela.NumeroParcela + "

" + parcela.Vencimento.ToShortDateString() + "

" + $"{parcela.Valor:c}" + "

" + ValidationHelper.GetDescription((Enum)(object)documento.FormaPagamento) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(documento.Observacao) ? "-" : documento.Observacao) + "

"; + } + if (PerfilCondutor && PerfilVisibility && ((DomainBase)documento.Controle.Ramo).Id == 5 && PerfilCondutorEnabled) + { + List list4 = source.ToList(); + foreach (Perfil item5 in list4) + { + color = 0; + if (!string.IsNullOrEmpty(item5.Nome)) + { + html = html + "

" + $"CONDUTOR {list4.IndexOf(item5) + 1}: " + "" + item5.Nome + "

CPF: " + (string.IsNullOrWhiteSpace(item5.Cpf) ? "-" : item5.Cpf) + "

NASCIMENTO: " + ((!item5.Nascimento.HasValue) ? "-" : item5.Nascimento?.ToShortDateString()) + "

ESTADO CIVIL: " + ((!item5.EstadoCivil.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.EstadoCivil)) + "

SEXO: " + ((!item5.Sexo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.Sexo)) + "

RELAÇÃO SEGURADO/CONDUTOR: " + ValidationHelper.GetDescription((Enum)(object)item5.Relacao) + "

HABILITAÇÃO: " + (string.IsNullOrWhiteSpace(item5.Habilitacao) ? "-" : item5.Habilitacao) + "

TEMPO DE HABILITAÇÃO: " + ((!item5.TempoHabilitacao.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.TempoHabilitacao)) + "

QUATIDADE DE VEÍCULOS: " + ((!item5.VeiculoResidencia.HasValue) ? "-" : item5.VeiculoResidencia.Value.ToString()) + "

GARAGEM NA RESIDÊNCIA: " + ((!item5.GaragemResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemResidencia)) + "

GARAGEM NO TRABALHO: " + ((!item5.GaragemTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemTrabalho)) + "

GARAGEM NO ESTUDO: " + ((!item5.GaragemEstudo.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.GaragemEstudo)) + "

TIPO DE RESIDÊNCIA: " + ((!item5.TipoResidencia.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.TipoResidencia)) + "

QUILOMETRAGEM MENSAL: " + (string.IsNullOrWhiteSpace(item5.KmMensal) ? "-" : item5.KmMensal) + "

DISTÂNCIA ATÉ O TRABALHO: " + ((!item5.DistanciaResidenciaTrabalho.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.DistanciaResidenciaTrabalho)) + "

USO PROFISSIONAL: " + ((item5.UsoProfissional.HasValue && item5.UsoProfissional.Value) ? "SIM" : "NÃO") + "

USO POR DEPENDENTES: " + ((!item5.UsoDependentes.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.UsoDependentes)) + "

OCUPAÇÃO: " + ((!item5.Ocupacao.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item5.Ocupacao)) + "

SEGURO VIDA: " + ((item5.SeguroVida.HasValue && item5.SeguroVida.Value) ? "SIM" : "NÃO") + "

ISENÇÃO DE IMPOSTOS: " + ((item5.Isencao.HasValue && item5.Isencao.Value) ? "SIM" : "NÃO") + "

ANTIFURTO: " + (item5.AntiFurto.HasValue ? ValidationHelper.GetDescription((Enum)(object)item5.AntiFurto) : "") + "

COBERTURA ESTENDIDA PARA RESIDENTES HABILITADOS: " + ((item5.EstenderCobertura.HasValue && item5.EstenderCobertura.Value) ? "SIM" : "NÃO") + "

"; + } + } + } + List itens2 = itensDocumentos.ToList(); + if (itens2.Count == 0) + { + html += "

ESTA APÓLICE NÃO POSSUI ITENS

"; + } + else + { + color = 0; + foreach (Item item2 in itens2) + { + if (item2.Sinistros.Count > 0) + { + Item val3 = item2; + val3.Sinistros = await new SinistroServico().BuscarControles(((DomainBase)item2).Id); + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + html += (((int)SelectedTipoExtrato != 2 || itens2.IndexOf(item2) == 0) ? "
" : ""); + html += ""; + html += ""; + html += ""; + if ((int)SelectedTipoExtrato == 2) + { + html = html + ""; + } + else + { + switch (((DomainBase)documento.Controle.Ramo).Id) + { + case 1L: + case 2L: + case 3L: + case 15L: + case 18L: + { + Item val3 = item2; + val3.Patrimonial = await new ItemServico().BuscaPatrimonial(((DomainBase)item2).Id); + html = html + ""; + break; + } + case 5L: + case 37L: + { + Item val3 = item2; + val3.Auto = await new ItemServico().BuscaAuto(((DomainBase)item2).Id); + string[] obj17 = new string[26] + { + html, + ""; + html = string.Concat(obj17); + break; + } + default: + html = html + ""; + break; + } + } + if (item2.Sinistros.Count > 0) + { + Item obj18 = item2; + DateTime? obj19; + if (obj18 == null) + { + obj19 = null; + } + else + { + IList sinistros3 = obj18.Sinistros; + if (sinistros3 == null) + { + obj19 = null; + } + else + { + ControleSinistro? obj20 = sinistros3.LastOrDefault(); + if (obj20 == null) + { + obj19 = null; + } + else + { + List sinistros4 = obj20.Sinistros; + if (sinistros4 == null) + { + obj19 = null; + } + else + { + Sinistro? obj21 = sinistros4.LastOrDefault(); + obj19 = ((obj21 != null) ? obj21.DataReclamacao : null); + } + } + } + } + DateTime? dateTime2 = obj19; + string text17 = (dateTime2.HasValue ? dateTime2.Value.ToShortDateString() : "-"); + string[] obj22 = new string[18] + { + html, ""; + html = string.Concat(obj22); + } + html += ""; + if ((int)SelectedTipoExtrato != 2) + { + string[] obj31 = new string[10] { html, ""; + html = string.Concat(obj31); + long id = ((DomainBase)documento.Controle.Ramo).Id; + long num4 = id - 1; + if ((ulong)num4 <= 58uL) + { + switch (num4) + { + case 0L: + case 1L: + case 2L: + case 14L: + case 17L: + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + case 4L: + case 36L: + { + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + string[] array2 = new string[30]; + array2[0] = html; + array2[1] = ""; + html = string.Concat(array2); + break; + } + case 5L: + case 6L: + case 8L: + case 9L: + case 52L: + { + Item val3 = item2; + val3.Vida = await new ItemServico().BuscaVida(((DomainBase)item2).Id); + if (!item2.Sinistrado || !BeneficiariosItens || !BeneficiariosItensEnabled) + { + break; + } + html = html + ""; + break; + } + case 3L: + case 7L: + case 15L: + case 16L: + case 18L: + case 22L: + case 23L: + case 25L: + case 27L: + case 30L: + case 32L: + case 38L: + case 40L: + case 43L: + case 48L: + case 58L: + { + Item val3 = item2; + val3.RiscosDiversos = await new ItemServico().BuscaRiscosDiversos(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 12L: + { + Item val3 = item2; + val3.Aeronautico = await new ItemServico().BuscaAeronautico(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + case 19L: + { + Item val3 = item2; + val3.Granizo = await new ItemServico().BuscaGranizo(((DomainBase)item2).Id); + if (ObsItem && ObsItemEnabled) + { + html = html + ""; + } + break; + } + } + } + } + html += "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

" + $"ITEM {item2.Ordem}: " + "" + ((EnderecoBase)item2.Patrimonial).Endereco + ", " + ((EnderecoBase)item2.Patrimonial).Numero + ", " + (string.IsNullOrWhiteSpace(((EnderecoBase)item2.Patrimonial).Complemento) ? "" : (((EnderecoBase)item2.Patrimonial).Complemento + ", ")) + ((EnderecoBase)item2.Patrimonial).Bairro + " - " + ((EnderecoBase)item2.Patrimonial).Cidade + " - " + ((EnderecoBase)item2.Patrimonial).Estado + " - " + ((EnderecoBase)item2.Patrimonial).Cep + "

", + $"ITEM {item2.Ordem}: ", + "
", + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + }; + Fabricante fabricante2 = item2.Auto.Fabricante; + obj17[6] = ((fabricante2 != null) ? fabricante2.Descricao : null); + obj17[7] = " "; + obj17[8] = item2.Auto.Modelo; + obj17[9] = " ("; + obj17[10] = item2.Auto.AnoFabricacao; + obj17[11] = "/"; + obj17[12] = item2.Auto.AnoModelo; + obj17[13] = ")
PLACA: "; + obj17[14] = item2.Auto.Placa; + obj17[15] = ", CHASSI: "; + obj17[16] = item2.Auto.Chassi; + obj17[17] = "
C.I.: "; + obj17[18] = item2.Auto.Ci; + obj17[19] = ", RENAVAM: "; + obj17[20] = item2.Auto.Renavam; + obj17[21] = ", CEP PERNOITE: "; + obj17[22] = item2.Auto.CepPernoite; + obj17[23] = "
FINANCIADO: "; + obj17[24] = (item2.Auto.Financiado.GetValueOrDefault() ? "SIM" : "NÃO"); + obj17[25] = "

" + $"ITEM {item2.Ordem}: " + "" + item2.Descricao + "

QTDE SINISTRO(S): " + item2.Sinistros.Count + "

SINISTRO STATUS: "; + Item obj23 = item2; + object obj24; + if (obj23 == null) + { + obj24 = null; + } + else + { + IList sinistros5 = obj23.Sinistros; + if (sinistros5 == null) + { + obj24 = null; + } + else + { + ControleSinistro? obj25 = sinistros5.LastOrDefault(); + if (obj25 == null) + { + obj24 = null; + } + else + { + List sinistros6 = obj25.Sinistros; + if (sinistros6 == null) + { + obj24 = null; + } + else + { + Sinistro? obj26 = sinistros6.LastOrDefault(); + obj24 = ((obj26 != null) ? ValidationHelper.GetDescription((Enum)(object)obj26.StatusSinistro) : null); + } + } + } + } + obj22[4] = (string)obj24; + obj22[5] = "

DATA: "; + obj22[8] = text17; + obj22[9] = "

VALOR: "; + Item obj27 = item2; + object obj28; + if (obj27 == null) + { + obj28 = null; + } + else + { + IList sinistros7 = obj27.Sinistros; + if (sinistros7 == null) + { + obj28 = null; + } + else + { + ControleSinistro? obj29 = sinistros7.LastOrDefault(); + if (obj29 == null) + { + obj28 = null; + } + else + { + List sinistros8 = obj29.Sinistros; + if (sinistros8 == null) + { + obj28 = null; + } + else + { + Sinistro? obj30 = sinistros8.LastOrDefault(); + obj28 = ((obj30 != null) ? ValidationHelper.ToCurrency(obj30.Valor, "pt-BR") : null); + } + } + } + } + obj22[12] = (string)obj28; + obj22[13] = "

QTDE SINISTRO(S): "; + obj22[16] = item2.Sinistros.Count.ToString(); + obj22[17] = "

STATUS: "; + obj31[4] = (string.IsNullOrWhiteSpace(item2.Status) ? item2.StatusInclusao : item2.Status); + obj31[5] = "

ATIVO: "; + obj31[8] = ((!item2.Substituido.HasValue) ? "SIM" : "NÃO"); + obj31[9] = "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Patrimonial.Item.Observacao) ? "-" : item2.Patrimonial.Item.Observacao) + "

BENS E INFORMAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Patrimonial.Bens) ? "-" : item2.Patrimonial.Bens) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Auto.Observacao) ? "-" : item2.Auto.Observacao) + "

COBERTURA PADRÃO: "; + TipoCobertura? tipoCobertura = item2.Auto.TipoCobertura; + array2[4] = (tipoCobertura.HasValue ? ValidationHelper.GetDescription((Enum)(object)tipoCobertura.GetValueOrDefault()) : null); + array2[5] = "

BÔNUS: "; + array2[8] = item2.Auto.Bonus.ToString(); + array2[9] = "

REGIÃO DE CIRCULAÇÃO: "; + array2[12] = (string.IsNullOrWhiteSpace(item2.Auto.RegiaoCirculacao) ? "-" : item2.Auto.RegiaoCirculacao); + array2[13] = "

TABELA DE REFERÊNCIA: "; + TabelaReferencia? tabelaReferencia = item2.Auto.TabelaReferencia; + array2[16] = (tabelaReferencia.HasValue ? ValidationHelper.GetDescription((Enum)(object)tabelaReferencia.GetValueOrDefault()) : null); + array2[17] = "

% DE REFERÊNCIA: "; + array2[20] = $"{item2.Auto.PorcentagemReferencia}%"; + array2[21] = "

CÓDIGO FIPE: "; + array2[24] = (string.IsNullOrWhiteSpace(item2.Auto.Fipe) ? "-" : item2.Auto.Fipe); + array2[25] = "

COR DO VEÍCULO: "; + array2[28] = ((!item2.Auto.Cor.HasValue) ? "-" : ValidationHelper.GetDescription((Enum)(object)item2.Auto.Cor)); + array2[29] = "

BENEFICIÁRIOS: "; + string text18 = ""; + foreach (ControleSinistro sinistro3 in item2.Sinistros) + { + if (sinistro3.Sinistros == null) + { + continue; + } + foreach (Sinistro sinistro4 in sinistro3.Sinistros) + { + if (!string.IsNullOrWhiteSpace(sinistro4.SinistroVida.Beneficiario)) + { + text18 = text18 + sinistro4.SinistroVida.Beneficiario + ", "; + } + } + } + if (!string.IsNullOrWhiteSpace(text18)) + { + int startIndex4 = text18.LastIndexOf(", ", StringComparison.Ordinal); + text18 = text18.Remove(startIndex4, 2).Insert(startIndex4, "."); + } + html = html + text18 + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.RiscosDiversos.Observacao) ? "-" : item2.RiscosDiversos.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Aeronautico.Observacao) ? "-" : item2.Aeronautico.Observacao) + "

OBSERVAÇÕES: " + (string.IsNullOrWhiteSpace(item2.Granizo.Observacao) ? "-" : item2.Granizo.Observacao) + "

"; + if ((int)SelectedTipoExtrato != 2) + { + ObservableCollection observableCollection2 = await new ItemServico().BuscarCoberturasPorItemAsync(((DomainBase)item2).Id); + if (observableCollection2.Count > 0 && Coberturas) + { + html += "
"; + foreach (Cobertura item6 in observableCollection2) + { + html = html + ""; + } + html += "

COBERTURA

FRANQUIA

L.M.I.

PRÊMIO

" + item6.Observacao + "

" + $"{item6.Franquia:c}" + "

" + $"{item6.Lmi:c}" + "

" + $"{item6.Premio:c}" + "

"; + } + html += ((SepararPagina && SepararPaginaEnabled) ? "
" : ""); + } + if ((int)SelectedTipoExtrato != 2) + { + color = 0; + } + } + } + } + } + sDocumento.Add(((DomainBase)documento.Controle).Id); + primeiro = false; + } + } + if (Prospeccoes != null && Prospeccoes.Count > 0) + { + foreach (Prospeccao prospecco in Prospeccoes) + { + int num5 = 0; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + html += "

"; + if ((int)SelectedTipoExtrato == 0) + { + title = "EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " DO CLIENTE: " + prospecco.Nome; + } + html = html + title + "


"; + html += ""; + if (ExtratoResumido) + { + html = html + ""; + if ((int)SelectedTipoExtrato != 2) + { + html += ""; + string text19 = ""; + if (prospecco.Telefone1 != null) + { + text19 = text19 + "
(" + prospecco.Prefixo1 + ") " + prospecco.Telefone1; + } + if (prospecco.Telefone2 != null) + { + text19 = text19 + "
(" + prospecco.Prefixo2 + ") " + prospecco.Telefone2; + } + html = html + "
"; + string text20 = ""; + if (prospecco.Email != null) + { + text20 = "
" + prospecco.Email; + } + html = html + "
"; + } + html += "

CLIENTE: " + prospecco.Nome + "

CPF/CNPJ: " + prospecco.Documento + "

CONTATOS: " + (string.IsNullOrEmpty(text19) ? "-" : text19) + "

EMAILS: " + (string.IsNullOrEmpty(text20) ? "-" : text20) + "

"; + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "
" : ""); + if ((int)SelectedTipoExtrato == 0) + { + return; + } + num5 = 0; + html = html + "
"; + html = html + ""; + html += "

VIGÊNCIA FINAL: " + ((!prospecco.VigenciaFinal.HasValue) ? "-" : prospecco.VigenciaFinal?.ToShortDateString()) + "

VENDEDOR: " + ((prospecco.Vendedor == null) ? "-" : prospecco.Vendedor.Nome) + "

"; + continue; + } + string text21 = "NASCIMENTO"; + html = html + ""; + if ((prospecco.Telefone1 != null || prospecco.Email != null) && (int)SelectedTipoExtrato != 2) + { + html += ""; + if (prospecco.Telefone1 != null) + { + string text22 = ""; + text22 = text22 + "
(" + prospecco.Prefixo1 + ") " + prospecco.Telefone1; + if (prospecco.Telefone2 != null) + { + text22 = text22 + "
(" + prospecco.Prefixo2 + ") " + prospecco.Telefone2; + } + html = html + "
"; + } + if (prospecco.Email != null && !ExtratoResumido) + { + string text23 = ""; + text23 = text23 + "
" + prospecco.Email; + html = html + "
"; + } + html += ""; + } + html += (((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) ? "" : ""); + if ((int)SelectedTipoExtrato == 0) + { + return; + } + num5 = 0; + html = html + "

CLIENTE: " + prospecco.Nome + "

CPF/CNPJ: " + prospecco.Documento + "

" + text21 + ": " + prospecco.Nascimento?.ToShortDateString() + "

CONTATOS: " + text22 + "

EMAILS: " + text23 + "

"; + html = html + ""; + html += "

VIGÊNCIA FINAL: " + ((!prospecco.VigenciaFinal.HasValue) ? "-" : prospecco.VigenciaFinal?.ToShortDateString()) + "

VENDEDOR: " + ((prospecco.Vendedor == null) ? "-" : prospecco.Vendedor.Nome) + "

"; + } + } + DateTime networkTime2 = Funcoes.GetNetworkTime(); + html = html + "

" + Recursos.Usuario.Nome + " - " + networkTime2.Date.ToShortDateString() + "
"; + string tempPath2 = Path.GetTempPath(); + string text24 = $"{tempPath2}{(object)(TipoExtrato)0}_{networkTime2:ddMMyyyyhhmmss}.html"; + if (pdf) + { + text24 = $"{tempPath2}{(object)(TipoExtrato)0}_{networkTime2:ddMMyyyyhhmmss}.pdf"; + byte[] bytes2 = ((HtmlToPdfConverter)new NRecoHtmlToPdfConverter()).GeneratePdf(html); + File.WriteAllBytes(text24, bytes2); + } + else + { + StreamWriter streamWriter2 = new StreamWriter(text24, append: true, Encoding.UTF8); + streamWriter2.Write(html); + streamWriter2.Close(); + } + Process.Start(text24); + if (Documentos != null && Documentos.Count > 1) + { + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Documentos == null) ? "" : ((Documentos.Count > 1) ? $"DE {Documentos.Count} DOCUMENTOS" : $"DO DOCUMENTO {((DomainBase)Documentos[0]).Id}")), 0L, (TipoTela)23, "IDS DOS DOCUMENTOS:\n" + string.Join("\n", Documentos.Select((Documento x) => ((DomainBase)x).Id)) + GerarOpcoes()); + } + if (Prospeccoes != null && Prospeccoes.Count > 1) + { + RegistrarAcao("GEROU O EXTRATO" + (ExtratoResumido ? " RESUMIDO" : "") + " " + ((Prospeccoes == null) ? "" : ((Prospeccoes.Count > 1) ? $"DE {Prospeccoes.Count} PROSPECÇÕES" : $"DA PROSPÇÃO{((DomainBase)Prospeccoes[0]).Id}")), 0L, (TipoTela)23, "IDS DOS DOCUMENTOS:\n" + string.Join("\n", Prospeccoes.Select((Prospeccao x) => ((DomainBase)x).Id)) + GerarOpcoes()); + } + Documentos = null; + Clientes = null; + Prospeccoes = null; + } + } + + public string GerarOpcoes() + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + string text = ""; + if (ClienteVisibility && ObsCliente && ObsClienteEnabled) + { + text += "\nOBSERVAÇÕES DO CLIENTE"; + } + if ((int)ClientePorPaginaVisibility == 0 && ClientePorPagina && ClientePorPaginaEnabled) + { + text += "\nSEPARAR CLIENTES POR PÁGINA"; + } + if (DocumentoVisibility) + { + if (ComissaoDocumentoEnabled && ComissaoDocumento) + { + text += "\nCOMISSÕES DO DOCUMENTO"; + } + if (ObsApoliceEnabled && ObsApolice) + { + text += "\nOBSERVAÇÕES DA APÓLICE"; + } + if ((int)SegurosVigentesVisibility == 0 && SegurosVigentes) + { + text += "\nAPENAS SEGUROS VIGENTES"; + } + } + if (ItemVisibility) + { + if ((int)SelecionarItensVisibility == 0 && SelecionarItens) + { + text += "\nSELECIONAR ITENS"; + } + if (BeneficiariosItensEnabled && BeneficiariosItens) + { + text += "\nBENEFICIÁRIOS DOS ITENS"; + } + if (ObsItemEnabled && ObsItem) + { + text += "\nOBSERVAÇÕES DO ITEM"; + } + if (SepararPaginaEnabled && SepararPagina) + { + text += "\nSEPARAR ITENS POR PÁGINA"; + } + } + if (PerfilCondutor && PerfilVisibility && PerfilCondutorEnabled) + { + text += "\nPERFIL DO CONDUTOR"; + } + if (string.IsNullOrWhiteSpace(text)) + { + return ""; + } + return "\n\nOPÇÕES:" + text; + } + + public async Task PrepararExtrato(List clientes, List documentos, List prospeccoes, Relatorio? tipoRelatorio = null, List selecionadosDoc = null, List selecionadosPros = null, bool pdf = false) + { + Carregando = true; + if (tipoRelatorio == (Relatorio?)0 || (int)tipoRelatorio.GetValueOrDefault() == 1) + { + if (clientes == null || clientes.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM CLIENTE"); + Carregando = false; + return; + } + if (clientes.Count > 200 && !(await ShowMessage("A SELEÇÃO DE MUITOS EXTRATOS PODE DEMORAR MAIS DE 30 MINUTOS! CONTINUAR?", "SIM", "NÃO"))) + { + Carregando = false; + return; + } + List listaCli = new List(); + foreach (ClientesAtivosInativos item2 in clientes.Where((ClientesAtivosInativos x) => x.Selecionado)) + { + Cliente cli = await new ClienteServico().BuscarCliente(item2.Id); + Cliente val = cli; + val.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)cli).Id); + val = cli; + val.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)cli).Id); + val = cli; + val.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)cli).Id); + val = cli; + val.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)cli).Id); + val = cli; + val.Vinculos = await _clienteServico.BuscarVinculosAsync(((DomainBase)cli).Id); + listaCli.Add(cli); + } + Clientes = listaCli; + goto IL_16a4; + } + if ((documentos == null || documentos.Count == 0) && (prospeccoes == null || prospeccoes.Count == 0)) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO OU PROSPECÇÃO"); + Carregando = false; + return; + } + if (documentos == null || documentos.Count <= 200) + { + if (prospeccoes == null || prospeccoes.Count <= 200) + { + goto IL_0741; + } + } + if (!(await ShowMessage("A SELEÇÃO DE MUITOS EXTRATOS PODE DEMORAR MAIS DE 30 MINUTOS! CONTINUAR?", "SIM", "NÃO"))) + { + Carregando = false; + return; + } + goto IL_0741; + IL_16a4: + if ((int)SegurosVigentesVisibility == 0 && SegurosVigentes) + { + Documentos = Documentos.Where((Documento x) => (x.Vigencia2 > Funcoes.GetNetworkTime().Date.AddDays(-5.0) || !x.Vigencia2.HasValue) && (int)x.Situacao != 7).ToList(); + } + await Gerar(tipoRelatorio, pdf); + Carregando = false; + return; + IL_0741: + TipoExtrato selectedTipoExtrato = SelectedTipoExtrato; + switch ((int)selectedTipoExtrato) + { + case 2: + { + List listaEndossos = new List(); + ApoliceServico apoliceServico = new ApoliceServico(); + long id = ((DomainBase)documentos.First().Controle.Cliente).Id; + FiltroStatusDocumento statusSelecionado = MainViewModel.StatusSelecionado; + Documentos = new List(await apoliceServico.BuscarApolicesAsync(id, statusSelecionado, await VerificaVinculoVendedor(Recursos.Usuario))); + foreach (Documento documento in Documentos) + { + foreach (Documento documento2 in documento.Controle.Documentos) + { + if (documento2.Tipo == 1) + { + listaEndossos.Add(documento2); + documento.TemEndosso = true; + } + } + } + Documentos.AddRange(listaEndossos); + break; + } + case 1: + if ((selecionadosDoc == null || selecionadosDoc.Count == 0) && (selecionadosPros == null || selecionadosPros.Count == 0)) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + Carregando = false; + return; + } + Documentos = new List(); + Prospeccoes = new List(); + if (selecionadosDoc != null) + { + foreach (long item3 in selecionadosDoc) + { + Documento doc = await new ApoliceServico().BuscarApoliceAsync(item3, itens: false, sinistrosPorControle: true); + List listDoc = ((SomenteEndossos && doc.Ordem != 1) ? new List() : new List { doc }); + if (SomenteEndossos) + { + IEnumerable enumerable = doc.Controle.Documentos.Where((Documento x) => !x.Excluido && x.Ordem != 0 && !listDoc.Any((Documento y) => ((DomainBase)y).Id == ((DomainBase)x).Id)); + foreach (Documento item4 in enumerable) + { + item4.Sinistro = doc.Sinistro; + } + listDoc.AddRange(enumerable); + } + else if (Endossos) + { + IEnumerable enumerable2 = doc.Controle.Documentos.Where((Documento x) => ((DomainBase)x).Id != ((DomainBase)doc).Id && !x.Excluido); + foreach (Documento item5 in enumerable2) + { + item5.Sinistro = doc.Sinistro; + } + listDoc.AddRange(enumerable2); + } + if (doc.Controle.Documentos.Any((Documento x) => ((DomainBase)x).Id != ((DomainBase)doc).Id && !x.Excluido && x.Ordem > doc.Ordem)) + { + doc.TemEndosso = true; + } + if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 31) && doc.TemEndosso) + { + doc.PremioTotal = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioTotal); + doc.Iof = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.Iof); + doc.Custo = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.Custo); + doc.PremioLiquido = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioLiquido); + doc.PremioAdicional = doc.Controle.Documentos.Where((Documento x) => !x.Excluido).Sum((Documento x) => x.PremioAdicional); + } + Documentos.AddRange(listDoc.OrderBy((Documento x) => x.Ordem).ToList()); + } + } + if (selecionadosPros != null) + { + foreach (long selecionadosPro in selecionadosPros) + { + Prospeccao item = await new ProspeccaoServico().BuscarProspeccao(selecionadosPro); + Prospeccoes.Add(item); + } + } + if ((int)SelecionarItensVisibility == 0 && SelecionarItens && Documentos != null && Documentos.Count > 0) + { + _itensSelecionados = (await ShowSelecionarItensDialog(((DomainBase)Documentos.First().Controle).Id)).Where((Item x) => x.Selecionado).ToList(); + } + if ((Documentos == null || Documentos.Count == 0) && (Prospeccoes == null || Prospeccoes.Count == 0)) + { + if (!SomenteEndossos) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO OU PROSPECÇÃO SELECIONADO"); + } + else + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM ENDOSSO OU PROSPECÇÃO SELECIONADO"); + } + Carregando = false; + return; + } + break; + case 0: + { + if (selecionadosDoc == null || selecionadosDoc.Count == 0) + { + await ShowMessage("É NECESSÁRIO HAVER AO MENOS UM DOCUMENTO SELECIONADO"); + Carregando = false; + return; + } + List listaCli = new List(); + foreach (Documento documento3 in documentos) + { + Cliente cli = await new ClienteServico().BuscarCliente(((DomainBase)documento3.Controle.Cliente).Id); + Cliente val = cli; + val.Enderecos = await _clienteServico.BuscarEnderecosAsync(((DomainBase)cli).Id); + val = cli; + val.Emails = await _clienteServico.BuscarEmailsAsync(((DomainBase)cli).Id); + val = cli; + val.Telefones = await _clienteServico.BuscarTelefonesAsync(((DomainBase)cli).Id); + val = cli; + val.Contatos = await _clienteServico.BuscarContatosAsync(((DomainBase)cli).Id); + val = cli; + val.Vinculos = await _clienteServico.BuscarVinculosAsync(((DomainBase)cli).Id); + listaCli.Add(cli); + } + Clientes = listaCli; + Prospeccoes = prospeccoes; + break; + } + } + goto IL_16a4; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs new file mode 100644 index 0000000..a00c4be --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ImpostoViewModel.cs @@ -0,0 +1,314 @@ +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.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ImpostoViewModel : BaseViewModel +{ + private bool _carregando; + + private bool _apelido; + + public int Tipo; + + private List _seguradoras; + + private List _ramos; + + private ObservableCollection _impostos = new ObservableCollection(); + + private Imposto _selectedImposto = new Imposto(); + + private Ramo _selectedRamo = new Ramo(); + + private Seguradora _selectedSeguradora = new Seguradora(); + + private ImpostoServico Servico { get; } + + public bool? Ativo { get; set; } = true; + + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + OnPropertyChanged("Carregando"); + } + } + + public bool Apelido + { + get + { + return _apelido; + } + set + { + _apelido = value; + OnPropertyChanged("Apelido"); + } + } + + public List Seguradoras + { + get + { + return _seguradoras; + } + set + { + _seguradoras = value; + OnPropertyChanged("Seguradoras"); + } + } + + public List Ramos + { + get + { + return _ramos; + } + set + { + _ramos = value; + OnPropertyChanged("Ramos"); + } + } + + public ObservableCollection Impostos + { + get + { + return _impostos; + } + set + { + _impostos = value; + OnPropertyChanged("Impostos"); + } + } + + public Imposto SelectedImposto + { + get + { + return _selectedImposto; + } + set + { + _selectedImposto = value; + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedImposto"); + } + } + + public Ramo SelectedRamo + { + get + { + return _selectedRamo; + } + set + { + _selectedRamo = value; + OnPropertyChanged("SelectedRamo"); + } + } + + public Seguradora SelectedSeguradora + { + get + { + return _selectedSeguradora; + } + set + { + _selectedSeguradora = value; + OnPropertyChanged("SelectedSeguradora"); + } + } + + public ImpostoViewModel() + { + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Expected O, but got Unknown + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Expected O, but got Unknown + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Expected O, but got Unknown + Servico = new ImpostoServico(); + Apelido = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 6); + } + + public async Task Carregar(int tipo, long id) + { + Tipo = tipo; + await PermissaoTela((TipoTela)56); + List list = (from x in Recursos.Seguradoras + where x.Ativo || (tipo == 0 && ((DomainBase)x).Id == id) + orderby (!Apelido) ? x.Nome : x.NomeSocial + select x).ToList(); + list.Insert(0, new Seguradora + { + Nome = "TODAS SEGURADORAS", + NomeSocial = "TODAS SEGURADORAS", + Id = 0L + }); + Seguradoras = list; + SelectedSeguradora = Seguradoras.First(); + List list2 = (from x in Recursos.Ramos + where x.Ativo || (tipo == 1 && ((DomainBase)x).Id == id) + orderby x.Nome + select x).ToList(); + list2.Insert(0, new Ramo + { + Nome = "TODOS OS RAMOS", + Id = 0L + }); + Ramos = list2; + SelectedRamo = Ramos.First(); + string text = ((tipo == 1) ? ("O RAMO \"" + Ramos.First((Ramo x) => ((DomainBase)x).Id == id).Nome + "\"") : ("A SEGURADORA \"" + Seguradoras.First((Seguradora x) => ((DomainBase)x).Id == id).Nome + "\"")); + RegistrarAcao("ACESSOU IMPOSTOS D" + text, id, (TipoTela)56, $"ID: {id}"); + List source = await Servico.Buscar(true); + if (tipo != 1) + { + source = source.Where((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == id && x.Ramo == null).ToList(); + SelectedSeguradora = Seguradoras.Find((Seguradora x) => ((DomainBase)x).Id == id); + } + else + { + source = source.Where((Imposto x) => x.Ramo != null && ((DomainBase)x.Ramo).Id == id && x.Seguradora == null).ToList(); + SelectedRamo = Ramos.Find((Ramo x) => ((DomainBase)x).Id == id); + } + Impostos = new ObservableCollection(source.OrderByDescending((Imposto x) => x.Ativo)); + SelectedImposto = Impostos.FirstOrDefault(); + } + + public async Task Carregar(long id = 0L) + { + List source = await Servico.Buscar(Ativo); + if (((DomainBase)SelectedSeguradora).Id == 0L) + { + source = source.Where((Imposto x) => x.Seguradora == null).ToList(); + } + if (((DomainBase)SelectedSeguradora).Id > 0) + { + source = source.Where((Imposto x) => x.Seguradora != null && ((DomainBase)x.Seguradora).Id == ((DomainBase)SelectedSeguradora).Id).ToList(); + } + if (((DomainBase)SelectedRamo).Id == 0L) + { + source = source.Where((Imposto x) => x.Ramo == null).ToList(); + } + if (((DomainBase)SelectedRamo).Id > 0) + { + source = source.Where((Imposto x) => x.Ramo != null && ((DomainBase)x.Ramo).Id == ((DomainBase)SelectedRamo).Id).ToList(); + } + Impostos = new ObservableCollection(source.Where((Imposto x) => !Ativo.HasValue || x.Ativo == Ativo.Value).ToList()); + SelectedImposto = ((id == 0L) ? Impostos.FirstOrDefault() : ((IEnumerable)Impostos).FirstOrDefault((Func)((Imposto x) => ((DomainBase)x).Id == id))); + } + + public void Incluir() + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Expected O, but got Unknown + SelectedImposto = new Imposto + { + Seguradora = ((((DomainBase)SelectedSeguradora).Id > 0) ? SelectedSeguradora : null), + Ramo = ((((DomainBase)SelectedRamo).Id > 0) ? SelectedRamo : null), + Ativo = true + }; + Alterar(alterar: true); + } + + public void AlterarImposto() + { + Alterar(alterar: true); + } + + public async Task Cancelar() + { + Imposto selectedImposto = SelectedImposto; + long id = ((selectedImposto != null) ? ((DomainBase)selectedImposto).Id : 0); + Alterar(alterar: false); + await Carregar(id); + } + + public async Task>> Salvar() + { + List> list = SelectedImposto.Validate(); + list.AddRange(Validate(SelectedImposto)); + if (list.Count > 0) + { + return list; + } + string acao = ((((DomainBase)SelectedImposto).Id == 0L) ? "INCLUIU" : "ALTEROU"); + Imposto val = await Servico.Salvar(SelectedImposto); + if (!Servico.Sucesso) + { + return new List> + { + new KeyValuePair("GRAVAR", "HOUVE UM ERRO AO SALVAR O IMPOSTO SELECIONADO.") + }; + } + string text = ((val.Seguradora == null) ? "TODAS AS SEGURADORAS" : (" SEGURADORA " + val.Seguradora.Nome)); + string text2 = ((val.Ramo == null) ? "TODOS OS RAMOS" : (" RAMO " + val.Ramo.Nome)); + string text3 = " " + text + " E " + text2; + RegistrarAcao(acao + " IMPOSTO PARA " + text3, ((DomainBase)val).Id, (TipoTela)31, string.Format("ID: {0}{1}{2}\nSTATUS: {3}\nIR: {4:p2}\nISS: {5:p2}\nOUTROS: {6:p2}\nDESCONTO: {7:p2}", ((DomainBase)val).Id, text, text2, val.Ativo ? "ATIVO" : "INATIVO", val.Ir, val.Iss, val.Outros, val.Desconto)); + Alterar(alterar: false); + await Carregar(((DomainBase)val).Id); + return null; + } + + public List> Validate(Imposto imposto) + { + List> list = new List>(); + if (imposto == null) + { + return list; + } + if (imposto.Ativo && Impostos.Any(delegate(Imposto x) + { + if (((DomainBase)x).Id != ((DomainBase)imposto).Id) + { + Seguradora seguradora = x.Seguradora; + long? num = ((seguradora != null) ? new long?(((DomainBase)seguradora).Id) : null); + Seguradora seguradora2 = imposto.Seguradora; + if (num == ((seguradora2 != null) ? new long?(((DomainBase)seguradora2).Id) : null)) + { + Ramo ramo = x.Ramo; + long? num2 = ((ramo != null) ? new long?(((DomainBase)ramo).Id) : null); + Ramo ramo2 = imposto.Ramo; + if (num2 == ((ramo2 != null) ? new long?(((DomainBase)ramo2).Id) : null)) + { + return x.Ativo; + } + } + } + return false; + })) + { + list.Add(new KeyValuePair("IMPOSTO DUPLICADO", "NÃO É POSSIVEL INSERIR UM NOVO PARAMETRO DE IMPOSTO, POIS JÁ EXISTEM PARAMETROS PARA A MESMA SEGURADORA E RAMO")); + } + return list.Distinct().ToList(); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs new file mode 100644 index 0000000..20fb507 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/InfoViewModel.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Seguros; +using Gestor.Application.Servicos.Seguros.Itens; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class InfoViewModel : BaseViewModel +{ + private ObservableCollection _contatos = new ObservableCollection(); + + private ObservableCollection _itens = new ObservableCollection(); + + private ObservableCollection _parcelas = new ObservableCollection(); + + private Documento _documento; + + private Visibility _ocultarInfos; + + private bool _carregando; + + public ObservableCollection Contatos + { + get + { + return _contatos; + } + set + { + _contatos = value; + OnPropertyChanged("Contatos"); + } + } + + public ObservableCollection Itens + { + get + { + return _itens; + } + set + { + _itens = value; + OnPropertyChanged("Itens"); + } + } + + public ObservableCollection Parcelas + { + get + { + return _parcelas; + } + set + { + _parcelas = value; + OnPropertyChanged("Parcelas"); + } + } + + public Documento Documento + { + get + { + return _documento; + } + set + { + _documento = value; + OnPropertyChanged("Documento"); + } + } + + public Visibility OcultarInfos + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _ocultarInfos; + } + 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) + _ocultarInfos = value; + OnPropertyChanged("OcultarInfos"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public InfoViewModel(Documento documento, bool ocultarInfos) + { + Documento = documento; + OcultarInfos = (Visibility)(ocultarInfos ? 2 : 0); + Seleciona(); + } + + public async void Seleciona() + { + Carregando = true; + if (Documento != null) + { + Documento = await new ApoliceServico().BuscarApoliceAsync(((DomainBase)Documento).Id); + } + if ((int)OcultarInfos == 0 && Documento != null) + { + ObservableCollection observableCollection = await new ParcelaServico().BuscarParcelasAsync(((DomainBase)Documento).Id); + Parcelas = (((int)Documento.TipoRecebimento.GetValueOrDefault() == 2) ? new ObservableCollection(observableCollection.OrderByDescending((Parcela x) => x.VigenciaIncial)) : observableCollection); + } + Documento documento = Documento; + if (((documento != null) ? documento.Controle : null) != null) + { + Itens = await new ItemServico().BuscarItens(((DomainBase)Documento.Controle).Id, (StatusItem)0); + List contatos = new List(); + ClienteServico servico = new ClienteServico(); + if (Documento.Controle.Cliente != null) + { + ObservableCollection telefones = await servico.BuscarTelefonesAsync(((DomainBase)Documento.Controle.Cliente).Id); + ObservableCollection observableCollection2 = await servico.BuscarEmailsAsync(((DomainBase)Documento.Controle.Cliente).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 (observableCollection2 != null) + { + contatos.AddRange(((IEnumerable)observableCollection2).Select((Func)((ClienteEmail x) => new Contato + { + Tipo = (TipoContato)1, + TipoTelefone = null, + Numero = ((EmailBase)x).Email + })).Take(1).ToList()); + } + } + Contatos = new ObservableCollection(contatos); + } + Carregando = false; + } + + public string GerarObs(Documento doc) + { + if (doc.Tipo != 0) + { + return $"CLIENTE: {doc.Controle.Cliente.Nome}{Environment.NewLine}CÓDIGO: {((DomainBase)doc).Id}{Environment.NewLine}PROPOSTA: {doc.Proposta}{Environment.NewLine}APÓLICE: {doc.Apolice}{Environment.NewLine}PROPOSTA DE ENDOSSO: {doc.PropostaEndosso}{Environment.NewLine}ENDOSSO: {doc.Endosso}"; + } + return $"CLIENTE: {doc.Controle.Cliente.Nome}{Environment.NewLine}CÓDIGO: {((DomainBase)doc).Id}{Environment.NewLine}PROPOSTA: {doc.Proposta}{Environment.NewLine}APÓLICE: {doc.Apolice}"; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/LogAcaoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/LogAcaoViewModel.cs new file mode 100644 index 0000000..b69bec0 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/LogAcaoViewModel.cs @@ -0,0 +1,97 @@ +using System; +using System.Linq; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.ViewModels.Drawer; + +public class LogAcaoViewModel : BaseViewModel +{ + private RegistroAcao _log; + + private string _obs; + + private Relatorio Relatorio { get; set; } + + public RegistroAcao Log + { + get + { + return _log; + } + set + { + _log = value; + OnPropertyChanged("Log"); + } + } + + public string Obs + { + get + { + return _obs; + } + set + { + _obs = value; + OnPropertyChanged("Obs"); + } + } + + public LogAcaoViewModel(RegistroAcao registro, Relatorio relatorio) + { + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + Relatorio = relatorio; + CarregarLog(registro); + } + + private void CarregarLog(RegistroAcao registro) + { + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Invalid comparison between Unknown and I4 + if (!registro.Tela.HasValue && !string.IsNullOrEmpty(registro.Observacao) && (int)Relatorio != 25) + { + Log = registro; + Filtros filtros = JsonConvert.DeserializeObject(registro.Observacao); + string text = ((filtros.Seguradoras == null || filtros.Seguradoras.Count == 0) ? "" : ("SEGURADORAS FILTRADAS: " + Environment.NewLine + string.Join(Environment.NewLine, from x in Recursos.Seguradoras + where filtros.Seguradoras.Contains(((DomainBase)x).Id) + select x.NomeSocial) + Environment.NewLine + Environment.NewLine)); + string text2 = ((filtros.Status == null || filtros.Status.Count == 0) ? "" : ("STATUS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, filtros.Status.Select((long x) => (TipoSeguro)x)) + Environment.NewLine + Environment.NewLine)); + string text3 = ((filtros.Ramos == null || filtros.Ramos.Count == 0) ? "" : ("RAMOS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, from x in Recursos.Ramos + where filtros.Ramos.Contains(((DomainBase)x).Id) + select x.Nome) + Environment.NewLine + Environment.NewLine)); + string text4 = ((filtros.Vendedores == null || filtros.Vendedores.Count == 0) ? "" : ("VENDEDORES FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, from x in Recursos.Vendedores + where filtros.Vendedores.Contains(((DomainBase)x).Id) + select x.Nome) + Environment.NewLine + Environment.NewLine)); + string text5 = ((filtros.Estipulantes == null || filtros.Estipulantes.Count == 0) ? "" : ("ESTIPULANTES FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, from x in Recursos.Estipulantes + where filtros.Estipulantes.Contains(((DomainBase)x).Id) + select x.Nome) + Environment.NewLine + Environment.NewLine)); + string text6 = ((filtros.Produtos == null || filtros.Produtos.Count == 0) ? "" : ("PRODUTOS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, from x in Recursos.Produtos + where filtros.Produtos.Contains(((DomainBase)x).Id) + select x.Nome) + Environment.NewLine + Environment.NewLine)); + string text7 = ((filtros.Negocio == null || filtros.Negocio.Count == 0) ? "" : ("TIPOS DE NEGÓCIOS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, filtros.Negocio.Select((long x) => (NegocioCorretora)x)) + Environment.NewLine + Environment.NewLine)); + string text8 = ((filtros.Usuarios == null || filtros.Usuarios.Count == 0) ? "" : ("USUÁRIOS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, from x in Recursos.Usuarios + where filtros.Usuarios.Contains(((DomainBase)x).Id) + select x.Nome) + Environment.NewLine + Environment.NewLine)); + string text9 = ((filtros.Telas == null || filtros.Telas.Count == 0) ? "" : ("TELAS FILTRADAS: " + Environment.NewLine + string.Join(Environment.NewLine, filtros.Telas.Select((long x) => (TipoTela)x)) + Environment.NewLine + Environment.NewLine)); + string text10 = ((filtros.Relatorios == null || filtros.Relatorios.Count == 0) ? "" : ("RELATÓRIOS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, filtros.Relatorios.Select((long x) => (Relatorio)x)) + Environment.NewLine + Environment.NewLine)); + string text11 = ((filtros.ParcelasEspeciais == null || !filtros.ParcelasEspeciais.Any((FiltroTipoParcela x) => x.Selecionado)) ? "" : ("TIPOS DE PARCELAS FILTRADOS: " + Environment.NewLine + string.Join(Environment.NewLine, filtros.ParcelasEspeciais.Select((FiltroTipoParcela x) => x.Tipo)) + Environment.NewLine + Environment.NewLine)); + string text12 = ((filtros.IdEmpresa == 0L) ? "" : ("EMPRESA: " + Environment.NewLine + Recursos.Empresas.Find((Empresa x) => ((DomainBase)x).Id == filtros.IdEmpresa).Nome + Environment.NewLine + Environment.NewLine)); + _ = $"PERÍODO DE {filtros.Inicio:d} ATÉ {filtros.Fim:d}"; + Obs = ValidationHelper.GetDescription((Enum)(object)registro.Relatorio) + Environment.NewLine + Environment.NewLine + text12 + text + text3 + text6 + text4 + text5 + text2 + text7 + text11 + text8 + text9 + text10; + } + else + { + Log = registro; + Obs = registro.Observacao; + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/LogEmailViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/LogEmailViewModel.cs new file mode 100644 index 0000000..5086554 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/LogEmailViewModel.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class LogEmailViewModel : BaseSegurosViewModel +{ + private readonly LogServico _servico; + + private Visibility _visibilityDetalhesLog = (Visibility)1; + + private bool _mostrarMensagem; + + private ObservableCollection _logs = new ObservableCollection(); + + private LogEmail _selectedLog; + + private List _lists = new List(); + + public Visibility VisiblityDetalhesLog + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityDetalhesLog; + } + 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) + _visibilityDetalhesLog = value; + OnPropertyChanged("VisiblityDetalhesLog"); + } + } + + public bool MostrarMensagem + { + get + { + return _mostrarMensagem; + } + set + { + _mostrarMensagem = value; + OnPropertyChanged("MostrarMensagem"); + } + } + + public ObservableCollection Logs + { + get + { + return _logs; + } + set + { + _logs = value; + OnPropertyChanged("Logs"); + } + } + + public LogEmail SelectedLog + { + get + { + return _selectedLog; + } + set + { + _selectedLog = value; + List lists = SelectedLog.CriarLogEmail(); + Lists = lists; + OnPropertyChanged("SelectedLog"); + } + } + + public List Lists + { + get + { + return _lists; + } + set + { + _lists = value; + OnPropertyChanged("Lists"); + } + } + + public LogEmailViewModel(TipoTela tela, long id, bool singleMode) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + _servico = new LogServico(); + VisiblityDetalhesLog = (Visibility)(!Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 55)); + Seleciona(tela, id, singleMode); + } + + private async void Seleciona(TipoTela tela, long id, bool singleMode) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + Loading(isLoading: true); + if (singleMode) + { + Logs = await _servico.FindById(id); + } + else + { + Logs = await _servico.FindByEntity(tela, id); + } + if (Logs.Count > 0) + { + SelectedLog = Logs[0]; + } + else + { + MostrarMensagem = true; + } + Loading(isLoading: false); + } + + public void Imprimir() + { + string text = "LOGS
LOG ENVIO DE E-MAIL"; + foreach (TupleList list in Lists) + { + foreach (Tuple tuple in list.Tuples) + { + if (tuple == list.Tuples.First()) + { + text += ""; + text += "
DESCRIÇÃOE-MAIL ENVIADO
"; + } + bool flag = tuple.Item1.Contains("$"); + text = text + ""; + text += "
" + tuple.Item1.Replace(" ", " ").Replace("$", "") + "" + tuple.Item2 + "
"; + } + } + text += "
"; + string tempPath = Path.GetTempPath(); + string text2 = $"{tempPath}{(object)(TipoExtrato)0}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html"; + StreamWriter streamWriter = new StreamWriter(text2, append: true, Encoding.UTF8); + streamWriter.Write(text); + streamWriter.Close(); + Process.Start(text2); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/LogSistemaAntigoViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/LogSistemaAntigoViewModel.cs new file mode 100644 index 0000000..3e52eea --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/LogSistemaAntigoViewModel.cs @@ -0,0 +1,36 @@ +using Gestor.Application.ViewModels.Generic; + +namespace Gestor.Application.ViewModels.Drawer; + +public class LogSistemaAntigoViewModel : BaseViewModel +{ + private string _descricao; + + private string _log; + + public string Descricao + { + get + { + return _descricao; + } + set + { + _descricao = value; + OnPropertyChanged("Descricao"); + } + } + + public string Log + { + get + { + return _log; + } + set + { + _log = value; + OnPropertyChanged("Log"); + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/LogViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/LogViewModel.cs new file mode 100644 index 0000000..bc49853 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/LogViewModel.cs @@ -0,0 +1,1458 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows; +using ControlzEx; +using CsQuery.ExtensionMethods.Internal; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Configuracoes; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.Validation; +using MaterialDesignThemes.Wpf; +using Newtonsoft.Json; + +namespace Gestor.Application.ViewModels.Drawer; + +public class LogViewModel : BaseSegurosViewModel +{ + private readonly LogServico _servico; + + private readonly TipoTela _tipoTela; + + private readonly long _id; + + private Visibility _visibilityDetalhesLog = (Visibility)1; + + private bool _mostrar; + + private bool _mostrarMensagem; + + private string _mostrarToolTip = "MOSTRAR TODAS OS CAMPOS"; + + private long _mostrarColuna = 120L; + + private PackIcon _mostrarIcone; + + private ObservableCollection _logs; + + private string _currentDescription; + + private RegistroLog _selectedLog; + + private List _lists; + + private ObservableCollection _listsAlterados; + + private ObservableCollection _listsAdicionados; + + private ObservableCollection _listsRemovidos; + + private string _textAdicoes; + + public Visibility VisiblityDetalhesLog + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityDetalhesLog; + } + 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) + _visibilityDetalhesLog = value; + OnPropertyChanged("VisiblityDetalhesLog"); + } + } + + public bool Mostrar + { + get + { + return _mostrar; + } + set + { + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Expected O, but got Unknown + //IL_0066: Expected O, but got Unknown + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0027: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Expected O, but got Unknown + //IL_0037: Expected O, but got Unknown + _mostrar = value; + if (value) + { + MostrarColuna = 240L; + MostrarToolTip = "ESCONDER CAMPOS INALTERADOS"; + PackIcon val = new PackIcon(); + ((PackIconBase)val).Kind = (PackIconKind)1492; + MostrarIcone = val; + } + else + { + MostrarColuna = 240L; + MostrarToolTip = "MOSTRAR TODOS OS CAMPOS"; + PackIcon val2 = new PackIcon(); + ((PackIconBase)val2).Kind = (PackIconKind)1497; + MostrarIcone = val2; + } + OnPropertyChanged("Mostrar"); + } + } + + public bool MostrarMensagem + { + get + { + return _mostrarMensagem; + } + set + { + _mostrarMensagem = value; + OnPropertyChanged("MostrarMensagem"); + } + } + + public string MostrarToolTip + { + get + { + return _mostrarToolTip; + } + set + { + _mostrarToolTip = value; + OnPropertyChanged("MostrarToolTip"); + } + } + + public long MostrarColuna + { + get + { + return _mostrarColuna; + } + set + { + _mostrarColuna = value; + OnPropertyChanged("MostrarColuna"); + } + } + + public PackIcon MostrarIcone + { + get + { + return _mostrarIcone; + } + set + { + _mostrarIcone = value; + OnPropertyChanged("MostrarIcone"); + } + } + + public ObservableCollection Logs + { + get + { + return _logs; + } + set + { + _logs = value; + OnPropertyChanged("Logs"); + } + } + + public string CurrentDescription + { + get + { + return _currentDescription; + } + set + { + _currentDescription = value; + OnPropertyChanged("CurrentDescription"); + } + } + + public RegistroLog SelectedLog + { + get + { + return _selectedLog; + } + set + { + //IL_01d7: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Unknown result type (might be due to invalid IL or missing references) + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0171: Expected I4, but got Unknown + //IL_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Expected I4, but got Unknown + //IL_090b: Unknown result type (might be due to invalid IL or missing references) + //IL_08b5: Unknown result type (might be due to invalid IL or missing references) + //IL_08ba: Unknown result type (might be due to invalid IL or missing references) + //IL_08c6: Expected O, but got Unknown + //IL_0733: Unknown result type (might be due to invalid IL or missing references) + //IL_0738: Unknown result type (might be due to invalid IL or missing references) + //IL_0744: Expected O, but got Unknown + _selectedLog = value; + List list = new List(); + try + { + if (value.ModeloNovo) + { + TipoAcao acao = value.Acao; + switch ((int)acao) + { + case 0: + case 2: + list = JsonConvert.DeserializeObject>(SelectedLog.Descricao).LogList(Restricao((TipoRestricao)14)); + break; + case 1: + list = JsonConvert.DeserializeObject>(SelectedLog.Descricao).LogList(Restricao((TipoRestricao)14)); + break; + } + } + else + { + TipoTela tipoTela = _tipoTela; + switch (tipoTela - 1) + { + case 1: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(Restricao((TipoRestricao)14)); + break; + case 4: + try + { + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(Restricao((TipoRestricao)14), Restricao((TipoRestricao)95)); + } + catch + { + list = DefaultLog(SelectedLog.Descricao, SelectedLog.Acao); + } + break; + case 36: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(Restricao((TipoRestricao)14), Restricao((TipoRestricao)95)); + break; + case 0: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 2: + { + Item val = JsonConvert.DeserializeObject(SelectedLog.Descricao); + if (val.Aeronautico != null) + { + list = Aeronautico.Log(val); + } + else if (val.Auto != null) + { + list = Auto.Log(val); + } + else if (val.Granizo != null) + { + list = Granizo.Log(val); + } + else if (val.Patrimonial != null) + { + list = Patrimonial.Log(val); + } + else if (val.RiscosDiversos != null) + { + list = RiscosDiversos.Log(val); + } + else if (val.Vida != null) + { + list = Vida.Log(val); + } + break; + } + case 12: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 11: + { + Ramo ramo = JsonConvert.DeserializeObject(SelectedLog.Descricao); + List list5 = (from x in Recursos.Coberturas + where x.IdRamo == ((DomainBase)ramo).Id + orderby x.Padrao descending, x.Descricao + select x).ToList(); + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(list5); + break; + } + case 9: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 8: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 14: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 13: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 15: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 16: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 17: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 21: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 23: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 25: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 27: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 28: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 3: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 32: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 37: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 33: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 18: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 40: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 41: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 35: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 29: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 10: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 30: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 45: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 6: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 42: + { + List>>>>> list4 = JsonConvert.DeserializeObject>>>>>>(SelectedLog.Descricao); + List list3 = new List(); + foreach (Tuple>>>> item in list4) + { + ObservableCollection> observableCollection = new ObservableCollection> + { + new Tuple(item.Item1 + "$", "", "") + }; + foreach (Tuple>> item2 in item.Item2) + { + observableCollection.Add(new Tuple(" " + item2.Item1 + "$", "", "")); + foreach (Tuple item3 in item2.Item2) + { + observableCollection.Add(new Tuple(" " + item3.Item1, item3.Item2, "")); + } + } + list3.Add(new TupleList + { + Tuples = observableCollection + }); + } + foreach (TupleList item4 in list3) + { + list.Add(item4); + } + break; + } + case 47: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 51: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 53: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 54: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 55: + list = JsonConvert.DeserializeObject(SelectedLog.Descricao).Log(); + break; + case 44: + { + List list2 = JsonConvert.DeserializeObject>(SelectedLog.Descricao); + List list3 = new List(); + ObservableCollection> observableCollection = new ObservableCollection> + { + new Tuple("VENDEDORES VINCULADOS$", "", "") + }; + foreach (Vendedor item5 in list2) + { + observableCollection.Add(new Tuple($" VENDEDOR {list2.IndexOf(item5) + 1}", item5.Nome, "")); + } + list3.Add(new TupleList + { + Tuples = observableCollection + }); + foreach (TupleList item6 in list3) + { + list.Add(item6); + } + break; + } + default: + list = DefaultLog(SelectedLog.Descricao, SelectedLog.Acao); + break; + } + } + } + catch (Exception) + { + } + Lists = list; + OnPropertyChanged("SelectedLog"); + } + } + + public List Lists + { + get + { + return _lists; + } + set + { + _lists = value; + SetListaFiltrada(value); + OnPropertyChanged("Lists"); + } + } + + public ObservableCollection ListsAlterados + { + get + { + return _listsAlterados; + } + set + { + _listsAlterados = value; + OnPropertyChanged("ListsAlterados"); + } + } + + public ObservableCollection ListsAdicionados + { + get + { + return _listsAdicionados; + } + set + { + _listsAdicionados = value; + OnPropertyChanged("ListsAdicionados"); + } + } + + public ObservableCollection ListsRemovidos + { + get + { + return _listsRemovidos; + } + set + { + _listsRemovidos = value; + if (ListsAlterados == null && ListsAdicionados == null && value == null) + { + MostrarMensagem = true; + } + else + { + MostrarMensagem = false; + } + OnPropertyChanged("ListsRemovidos"); + } + } + + public string TextAdicoes + { + get + { + return _textAdicoes; + } + set + { + _textAdicoes = value; + OnPropertyChanged("TextAdicoes"); + } + } + + public LogViewModel(TipoTela tela, long id, List parcelas = null, int numparcela = 0) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Expected O, but got Unknown + //IL_0031: Expected O, but got Unknown + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_00e8: Unknown result type (might be due to invalid IL or missing references) + PackIcon val = new PackIcon(); + ((PackIconBase)val).Kind = (PackIconKind)1497; + _mostrarIcone = val; + _logs = new ObservableCollection(); + _currentDescription = ""; + _lists = new List(); + _listsAlterados = new ObservableCollection(); + _listsAdicionados = new ObservableCollection(); + _listsRemovidos = new ObservableCollection(); + _textAdicoes = "INCLUSÃO"; + base._002Ector(); + _servico = new LogServico(); + _tipoTela = tela; + _id = id; + VisiblityDetalhesLog = (Visibility)(!Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 55)); + base.EnableMenu = true; + if (parcelas != null) + { + LogParcelas(id, parcelas, numparcela); + } + else + { + Seleciona(tela, id); + } + } + + private static List DefaultLog(string log, TipoAcao acao) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Expected O, but got Unknown + return new List + { + new TupleList + { + Tuples = new ObservableCollection> + { + new Tuple(Funcoes.GetDescription((Enum)(object)acao), log, "") + } + } + }; + } + + public int BuscaNumeroParcela(string json) + { + try + { + if (!int.TryParse(json.Split(new char[1] { '}' }).FirstOrDefault((string x) => x.Contains("NumeroParcela")).Split(new char[1] { ':' })[^1].Replace("\"", ""), out var result)) + { + return 0; + } + return result; + } + catch + { + return 0; + } + } + + private async void LogParcelas(long documento, List parcelas, int numparcela) + { + Loading(isLoading: true); + List list = new List(); + list.AddRange(parcelas); + list.Add(documento); + Logs = new ObservableCollection(await _servico.BuscaLogParcelas(list)); + ObservableCollection observableCollection = new ObservableCollection(); + List list2 = Logs.Where((RegistroLog x) => !x.ModeloNovo && x.EntidadeId == documento).ToList(); + for (int num = list2.Count - 1; num >= 0; num--) + { + ObservableCollection observableCollection2 = new ObservableCollection(); + try + { + int num2 = num; + while (num2 >= 0 && list2[num2].DataHora < list2[num].DataHora.AddSeconds(4.0)) + { + Parcela val = JsonConvert.DeserializeObject(Logs[num2].Descricao); + if (val != null && (numparcela == 0 || BuscaNumeroParcela(Logs[num2].Descricao) == numparcela)) + { + observableCollection2.Add(val); + } + num = num2; + num2--; + } + } + catch (Exception) + { + try + { + List list3 = JsonConvert.DeserializeObject>(Logs[num].Descricao); + if (list3 != null && (numparcela == 0 || BuscaNumeroParcela(Logs[num].Descricao) == numparcela)) + { + ExtensionMethods.AddRange((ICollection)observableCollection2, (IEnumerable)list3); + } + goto end_IL_01b0; + } + catch (Exception) + { + Logs[num].Descricao = Logs[num].Descricao ?? ""; + observableCollection.Insert(0, Logs[num]); + } + continue; + end_IL_01b0:; + } + observableCollection2 = new ObservableCollection(observableCollection2.OrderBy((Parcela x) => x.NumeroParcela)); + if (observableCollection2 != null && observableCollection2.Count != 0 && observableCollection2[0].Documento != null) + { + list2[num].Descricao = JsonConvert.SerializeObject((object)new Parcelas + { + ParcelasList = observableCollection2, + TipoRecebimento = observableCollection2[0].Documento.TipoRecebimento + }, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }); + observableCollection.Insert(0, list2[num]); + } + } + List list4 = new List(); + List list5 = Logs.Where((RegistroLog x) => x.ModeloNovo).ToList(); + if (numparcela == 0) + { + list4.AddRange(list5); + } + else + { + foreach (RegistroLog item in list5) + { + int num3 = BuscaNumeroParcela(item.Descricao); + if ((num3 != 0 && num3 == numparcela) || (numparcela != 0 && parcelas.Count == 1 && item.EntidadeId != documento)) + { + list4.Add(item); + } + } + } + Logs = observableCollection; + ExtensionMethods.AddRange((ICollection)Logs, (IEnumerable)list4); + if (Logs.Count > 0) + { + SelectedLog = Logs[0]; + } + else + { + SetListaFiltrada(Lists); + } + Loading(isLoading: false); + } + + private async void Seleciona(TipoTela tela, long id, List parcelas = null, long? parcela = null) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + Loading(isLoading: true); + Logs = new ObservableCollection(await _servico.FindByEntityId(tela, id)); + if ((int)tela == 37) + { + ObservableCollection observableCollection = new ObservableCollection(); + List list = Logs.Where((RegistroLog x) => !x.ModeloNovo).ToList(); + for (int num = list.Count - 1; num >= 0; num--) + { + ObservableCollection observableCollection2 = new ObservableCollection(); + int num2 = num; + while (num2 >= 0 && list[num2].DataHora < list[num].DataHora.AddSeconds(4.0)) + { + observableCollection2.Add(JsonConvert.DeserializeObject(list[num2].Descricao)); + num = num2; + num2--; + } + observableCollection2 = new ObservableCollection(observableCollection2.OrderBy((VendedorParcela x) => ((DomainBase)x).Id)); + list[num].Descricao = JsonConvert.SerializeObject((object)new VendedorParcelas + { + VendedorParcelasList = observableCollection2 + }, new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }); + observableCollection.Insert(0, list[num]); + } + List list2 = Logs.Where((RegistroLog x) => x.ModeloNovo).ToList(); + Logs = observableCollection; + ExtensionMethods.AddRange((ICollection)Logs, (IEnumerable)list2); + } + if (Logs.Count > 0) + { + SelectedLog = Logs[0]; + } + else + { + SetListaFiltrada(Lists); + } + Loading(isLoading: false); + } + + public void SetListaFiltrada(List listAtual) + { + //IL_0036: Unknown result type (might be due to invalid IL or missing references) + //IL_003c: Invalid comparison between Unknown and I4 + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_00ca: Unknown result type (might be due to invalid IL or missing references) + //IL_00d0: Invalid comparison between Unknown and I4 + //IL_0173: Unknown result type (might be due to invalid IL or missing references) + //IL_0178: Unknown result type (might be due to invalid IL or missing references) + //IL_017a: Unknown result type (might be due to invalid IL or missing references) + //IL_017d: Unknown result type (might be due to invalid IL or missing references) + //IL_0263: Expected I4, but got Unknown + //IL_0e13: Unknown result type (might be due to invalid IL or missing references) + //IL_0e18: Unknown result type (might be due to invalid IL or missing references) + //IL_0e28: Expected O, but got Unknown + //IL_0d23: Unknown result type (might be due to invalid IL or missing references) + //IL_0d28: Unknown result type (might be due to invalid IL or missing references) + //IL_0d34: Expected O, but got Unknown + //IL_0b11: Unknown result type (might be due to invalid IL or missing references) + //IL_0b16: Unknown result type (might be due to invalid IL or missing references) + //IL_0b22: Expected O, but got Unknown + //IL_1026: Unknown result type (might be due to invalid IL or missing references) + //IL_102b: Unknown result type (might be due to invalid IL or missing references) + //IL_103b: Expected O, but got Unknown + //IL_13d8: Unknown result type (might be due to invalid IL or missing references) + //IL_13dd: Unknown result type (might be due to invalid IL or missing references) + //IL_13ed: Expected O, but got Unknown + //IL_1770: Unknown result type (might be due to invalid IL or missing references) + //IL_1775: Unknown result type (might be due to invalid IL or missing references) + //IL_1785: Expected O, but got Unknown + if (Logs.Count == 0) + { + ListsAlterados = null; + ListsAdicionados = null; + ListsRemovidos = null; + return; + } + if (SelectedLog.ModeloNovo && (int)SelectedLog.Acao == 1) + { + TextAdicoes = "ALTERAÇÕES"; + ListsAdicionados = null; + ListsRemovidos = null; + ListsAlterados = new ObservableCollection(Lists); + MostrarMensagem = false; + return; + } + if (SelectedLog.ModeloNovo && (int)SelectedLog.Acao == 0) + { + TextAdicoes = "INCLUSÕES"; + ListsAlterados = null; + ListsRemovidos = null; + ListsAdicionados = new ObservableCollection(listAtual); + MostrarMensagem = false; + return; + } + if (SelectedLog.ModeloNovo && (int)SelectedLog.Acao == 2) + { + TextAdicoes = "EXCLUSÕES"; + ListsAlterados = null; + ListsAdicionados = null; + ListsRemovidos = new ObservableCollection(listAtual); + MostrarMensagem = false; + return; + } + if (Mostrar || Logs.Last() == SelectedLog) + { + TextAdicoes = ((Logs.Last() != SelectedLog) ? "LOG COMPLETO" : "INCLUSÃO"); + ListsAlterados = null; + ListsAdicionados = new ObservableCollection(listAtual); + ListsRemovidos = null; + return; + } + TextAdicoes = "INCLUSÃO"; + List list = new List(); + try + { + TipoTela tipoTela = _tipoTela; + switch (tipoTela - 1) + { + case 1: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(Restricao((TipoRestricao)14)); + break; + case 4: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(Restricao((TipoRestricao)14), Restricao((TipoRestricao)95)); + break; + case 36: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(Restricao((TipoRestricao)14), Restricao((TipoRestricao)95)); + break; + case 0: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 2: + { + Item val = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao); + if (val.Aeronautico != null) + { + list = Aeronautico.Log(val); + } + else if (val.Auto != null) + { + list = Auto.Log(val); + } + else if (val.Granizo != null) + { + list = Granizo.Log(val); + } + else if (val.Patrimonial != null) + { + list = Patrimonial.Log(val); + } + else if (val.RiscosDiversos != null) + { + list = RiscosDiversos.Log(val); + } + else if (val.Vida != null) + { + list = Vida.Log(val); + } + break; + } + case 12: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 11: + { + Ramo ramo = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao); + List list5 = (from x in Recursos.Coberturas + where x.IdRamo == ((DomainBase)ramo).Id + orderby x.Padrao descending, x.Descricao + select x).ToList(); + list = ramo.Log(list5); + break; + } + case 9: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 8: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 14: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 13: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 15: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 16: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 17: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 21: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 23: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 25: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 27: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 28: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 3: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 32: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 37: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 33: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 18: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 40: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 41: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 35: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 29: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 10: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 30: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 45: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 6: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 42: + { + List>>>>> list4 = JsonConvert.DeserializeObject>>>>>>(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao); + List list3 = new List(); + foreach (Tuple>>>> item in list4) + { + ObservableCollection> observableCollection = new ObservableCollection> + { + new Tuple(item.Item1 + "$", "", "") + }; + foreach (Tuple>> item2 in item.Item2) + { + observableCollection.Add(new Tuple(" " + item2.Item1 + "$", "", "")); + foreach (Tuple item3 in item2.Item2) + { + observableCollection.Add(new Tuple(" " + item3.Item1, item3.Item2, "")); + } + } + list3.Add(new TupleList + { + Tuples = observableCollection + }); + } + foreach (TupleList item4 in list3) + { + list.Add(item4); + } + break; + } + case 47: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 51: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 53: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 54: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 55: + list = JsonConvert.DeserializeObject(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao).Log(); + break; + case 44: + { + List list2 = JsonConvert.DeserializeObject>(Logs[Logs.IndexOf(SelectedLog) + 1].Descricao); + List list3 = new List(); + ObservableCollection> observableCollection = new ObservableCollection> + { + new Tuple("VENDEDORES VINCULADOS$", "", "") + }; + foreach (Vendedor item5 in list2) + { + observableCollection.Add(new Tuple($" VENDEDOR {list2.IndexOf(item5) + 1}", item5.Nome, "")); + } + list3.Add(new TupleList + { + Tuples = observableCollection + }); + foreach (TupleList item6 in list3) + { + list.Add(item6); + } + break; + } + case 5: + case 7: + case 19: + case 20: + case 22: + case 24: + case 26: + case 31: + case 34: + case 38: + case 39: + case 43: + case 46: + case 48: + case 49: + case 50: + case 52: + break; + } + } + catch (Exception) + { + } + ObservableCollection observableCollection2 = new ObservableCollection(); + foreach (TupleList item7 in listAtual) + { + int num = -1; + if (list.Count - 1 < listAtual.IndexOf(item7)) + { + continue; + } + for (int i = 0; i < item7.Tuples.Count; i++) + { + Tuple tuple = item7.Tuples[i]; + if (QntEspaco(tuple.Item1) == 0) + { + if (tuple.Item2 != list[listAtual.IndexOf(item7)].Tuples[item7.Tuples.IndexOf(tuple)].Item2) + { + if (num < listAtual.IndexOf(item7)) + { + observableCollection2.Add(new TupleList + { + Tuples = new ObservableCollection>() + }); + num = listAtual.IndexOf(item7); + } + observableCollection2.Last().Tuples.Add(new Tuple(tuple.Item1, tuple.Item2, list[listAtual.IndexOf(item7)].Tuples[item7.Tuples.IndexOf(tuple)].Item2)); + } + continue; + } + List list6 = new List(); + int num2 = QntEspaco(tuple.Item1); + for (int num3 = i; num3 >= 0; num3--) + { + if (QntEspaco(item7.Tuples[num3].Item1) <= num2) + { + list6.Insert(0, item7.Tuples[num3].Item1); + num2 = QntEspaco(item7.Tuples[num3].Item1); + } + } + bool flag = false; + int num4 = 0; + foreach (string item8 in list6) + { + if (flag) + { + break; + } + for (int j = num4; j < list[listAtual.IndexOf(item7)].Tuples.Count; j++) + { + if (j == list[listAtual.IndexOf(item7)].Tuples.Count - 1 && item8 != list[listAtual.IndexOf(item7)].Tuples[j].Item1) + { + flag = true; + break; + } + if (item8 == list[listAtual.IndexOf(item7)].Tuples[j].Item1) + { + num4 = j; + break; + } + } + } + if (flag || !(tuple.Item2 != list[listAtual.IndexOf(item7)].Tuples[num4].Item2)) + { + continue; + } + if (num < listAtual.IndexOf(item7)) + { + observableCollection2.Add(new TupleList + { + Tuples = new ObservableCollection>() + }); + num = listAtual.IndexOf(item7); + } + int count = observableCollection2.Last().Tuples.Count; + int num5 = QntEspaco(tuple.Item1); + for (int num6 = i - 1; num6 >= 0; num6--) + { + if (QntEspaco(item7.Tuples[num6].Item1) < QntEspaco(tuple.Item1) && QntEspaco(item7.Tuples[num6].Item1) < num5) + { + bool flag2 = false; + for (int num7 = observableCollection2.Last().Tuples.Count - 1; num7 >= 0; num7--) + { + if (observableCollection2.Last().Tuples[num7].Item1 == item7.Tuples[num6].Item1) + { + flag2 = true; + break; + } + } + if (flag2) + { + break; + } + num5 = QntEspaco(item7.Tuples[num6].Item1); + observableCollection2.Last().Tuples.Insert(count, new Tuple(item7.Tuples[num6].Item1, item7.Tuples[num6].Item2, "")); + } + } + observableCollection2.Last().Tuples.Add(new Tuple(tuple.Item1, tuple.Item2, list[listAtual.IndexOf(item7)].Tuples[num4].Item2)); + } + } + ListsAlterados = ((observableCollection2.Count == 0) ? null : observableCollection2); + observableCollection2 = new ObservableCollection(); + foreach (TupleList item9 in listAtual) + { + int num8 = -1; + if (list.Count - 1 < listAtual.IndexOf(item9)) + { + continue; + } + for (int k = 0; k < item9.Tuples.Count; k++) + { + Tuple tuple2 = item9.Tuples[k]; + if (QntEspaco(tuple2.Item1) <= 0) + { + continue; + } + List list7 = new List(); + int num9 = QntEspaco(tuple2.Item1); + for (int num10 = k; num10 >= 0; num10--) + { + if (QntEspaco(item9.Tuples[num10].Item1) <= num9) + { + list7.Insert(0, item9.Tuples[num10].Item1); + num9 = QntEspaco(item9.Tuples[num10].Item1); + } + } + bool flag3 = false; + int num11 = 0; + foreach (string item10 in list7) + { + if (flag3) + { + break; + } + for (int l = num11; l < list[listAtual.IndexOf(item9)].Tuples.Count; l++) + { + if (l == list[listAtual.IndexOf(item9)].Tuples.Count - 1 && item10 != list[listAtual.IndexOf(item9)].Tuples[l].Item1) + { + flag3 = true; + break; + } + if (item10 == list[listAtual.IndexOf(item9)].Tuples[l].Item1) + { + num11 = l; + break; + } + } + } + if (!flag3) + { + continue; + } + if (num8 < listAtual.IndexOf(item9)) + { + observableCollection2.Add(new TupleList + { + Tuples = new ObservableCollection>() + }); + num8 = listAtual.IndexOf(item9); + } + int count2 = observableCollection2.Last().Tuples.Count; + int num12 = QntEspaco(tuple2.Item1); + for (int num13 = k - 1; num13 >= 0; num13--) + { + if (QntEspaco(item9.Tuples[num13].Item1) < QntEspaco(tuple2.Item1) && QntEspaco(item9.Tuples[num13].Item1) < num12) + { + bool flag4 = false; + for (int num14 = observableCollection2.Last().Tuples.Count - 1; num14 >= 0; num14--) + { + if (observableCollection2.Last().Tuples[num14].Item1 == item9.Tuples[num13].Item1) + { + flag4 = true; + break; + } + } + if (flag4) + { + break; + } + num12 = QntEspaco(item9.Tuples[num13].Item1); + observableCollection2.Last().Tuples.Insert(count2, new Tuple(item9.Tuples[num13].Item1, item9.Tuples[num13].Item2, "")); + } + } + observableCollection2.Last().Tuples.Add(new Tuple(tuple2.Item1, tuple2.Item2, "")); + } + } + ListsAdicionados = ((observableCollection2.Count == 0) ? null : observableCollection2); + observableCollection2 = new ObservableCollection(); + foreach (TupleList item11 in list) + { + int num15 = -1; + for (int m = 0; m < item11.Tuples.Count; m++) + { + Tuple tuple3 = item11.Tuples[m]; + if (QntEspaco(tuple3.Item1) <= 0) + { + continue; + } + List list8 = new List(); + int num16 = QntEspaco(tuple3.Item1); + for (int num17 = m; num17 >= 0; num17--) + { + if (QntEspaco(item11.Tuples[num17].Item1) <= num16) + { + list8.Insert(0, item11.Tuples[num17].Item1); + num16 = QntEspaco(item11.Tuples[num17].Item1); + } + } + bool flag5 = false; + int num18 = 0; + foreach (string item12 in list8) + { + if (flag5) + { + break; + } + if (listAtual.Count - 1 < list.IndexOf(item11)) + { + continue; + } + for (int n = num18; n < listAtual[list.IndexOf(item11)].Tuples.Count; n++) + { + if (n == listAtual[list.IndexOf(item11)].Tuples.Count - 1 && item12 != listAtual[list.IndexOf(item11)].Tuples[n].Item1) + { + flag5 = true; + break; + } + if (item12 == listAtual[list.IndexOf(item11)].Tuples[n].Item1) + { + num18 = n; + break; + } + } + } + if (!flag5) + { + continue; + } + if (num15 < list.IndexOf(item11)) + { + observableCollection2.Add(new TupleList + { + Tuples = new ObservableCollection>() + }); + num15 = list.IndexOf(item11); + } + int count3 = observableCollection2.Last().Tuples.Count; + int num19 = QntEspaco(tuple3.Item1); + for (int num20 = m - 1; num20 >= 0; num20--) + { + if (QntEspaco(item11.Tuples[num20].Item1) < QntEspaco(tuple3.Item1) && QntEspaco(item11.Tuples[num20].Item1) < num19) + { + bool flag6 = false; + for (int num21 = observableCollection2.Last().Tuples.Count - 1; num21 >= 0; num21--) + { + if (observableCollection2.Last().Tuples[num21].Item1 == item11.Tuples[num20].Item1) + { + flag6 = true; + break; + } + } + if (flag6) + { + break; + } + num19 = QntEspaco(item11.Tuples[num20].Item1); + observableCollection2.Last().Tuples.Insert(count3, new Tuple(item11.Tuples[num20].Item1, item11.Tuples[num20].Item2, "")); + } + } + observableCollection2.Last().Tuples.Add(new Tuple(tuple3.Item1, "", tuple3.Item2)); + } + } + ListsRemovidos = ((observableCollection2.Count == 0) ? null : observableCollection2); + } + + private static int QntEspaco(string str) + { + return Regex.Match(str, "[^\\s]").Index; + } + + public void MostrarCampos() + { + if (SelectedLog != null && !SelectedLog.ModeloNovo) + { + Mostrar = !Mostrar; + Lists = Lists; + } + } + + public void Imprimir() + { + //IL_063c: Unknown result type (might be due to invalid IL or missing references) + //IL_0662: Unknown result type (might be due to invalid IL or missing references) + //IL_067d: Unknown result type (might be due to invalid IL or missing references) + string text = "LOGS
"; + ObservableCollection listsAlterados = ListsAlterados; + if (listsAlterados != null && listsAlterados.Count > 0) + { + text += "ALTERAÇÃO"; + } + if (ListsAlterados != null) + { + foreach (TupleList listsAlterado in ListsAlterados) + { + foreach (Tuple tuple in listsAlterado.Tuples) + { + if (tuple == listsAlterado.Tuples.First()) + { + text = text + ""; + if (!Mostrar) + { + text += ""; + } + text += "
DESCRIÇÃOVALOR LOG SELECIONADOVALOR LOG ANTERIOR
"; + } + bool flag = tuple.Item1.Contains("$"); + text = text + ""; + if (!Mostrar) + { + text = text + ""; + } + text += "
" + tuple.Item1.Replace(" ", " ").Replace("$", "") + "" + tuple.Item2 + "" + tuple.Item3 + "
"; + } + if (listsAlterado != ListsAlterados.Last()) + { + text += "
"; + } + } + } + ObservableCollection listsAdicionados = ListsAdicionados; + if (listsAdicionados != null && listsAdicionados.Count > 0) + { + ObservableCollection listsAlterados2 = ListsAlterados; + if (listsAlterados2 != null && listsAlterados2.Count > 0) + { + text += "


"; + } + text += "INCLUSÃO"; + } + if (ListsAdicionados != null) + { + foreach (TupleList listsAdicionado in ListsAdicionados) + { + foreach (Tuple tuple2 in listsAdicionado.Tuples) + { + if (tuple2 == listsAdicionado.Tuples.First()) + { + text = text + ""; + if (!Mostrar) + { + text += ""; + } + text += "
DESCRIÇÃOVALOR LOG SELECIONADOVALOR LOG ANTERIOR
"; + } + bool flag2 = tuple2.Item1.Contains("$"); + text = text + ""; + if (!Mostrar) + { + text = text + ""; + } + text += "
" + tuple2.Item1.Replace(" ", " ").Replace("$", "") + "" + tuple2.Item2 + "" + tuple2.Item3 + "
"; + } + if (listsAdicionado != ListsAdicionados.Last()) + { + text += "
"; + } + } + } + ObservableCollection listsRemovidos = ListsRemovidos; + if (listsRemovidos != null && listsRemovidos.Count > 0) + { + ObservableCollection listsAlterados3 = ListsAlterados; + if (listsAlterados3 == null || listsAlterados3.Count <= 0) + { + ObservableCollection listsAdicionados2 = ListsAdicionados; + if (listsAdicionados2 == null || listsAdicionados2.Count <= 0) + { + goto IL_0428; + } + } + text += "


"; + goto IL_0428; + } + goto IL_0434; + IL_0434: + if (ListsRemovidos != null) + { + foreach (TupleList listsRemovido in ListsRemovidos) + { + foreach (Tuple tuple3 in listsRemovido.Tuples) + { + if (tuple3 == listsRemovido.Tuples.First()) + { + text = text + ""; + if (!Mostrar) + { + text += ""; + } + text += "
DESCRIÇÃOVALOR LOG SELECIONADOVALOR LOG ANTERIOR
"; + } + bool flag3 = tuple3.Item1.Contains("$"); + text = text + ""; + if (!Mostrar) + { + text = text + ""; + } + text += "
" + tuple3.Item1.Replace(" ", " ").Replace("$", "") + "" + tuple3.Item2 + "" + tuple3.Item3 + "
"; + } + if (listsRemovido != ListsRemovidos.Last()) + { + text += "
"; + } + } + } + text += "
"; + string tempPath = Path.GetTempPath(); + string text2 = $"{tempPath}{(object)(TipoExtrato)0}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html"; + StreamWriter streamWriter = new StreamWriter(text2, append: true, Encoding.UTF8); + streamWriter.Write(text); + streamWriter.Close(); + Process.Start(text2); + RegistrarAcao($"IMPRIMIU O LOG DE ALTERAÇÕES DE {Funcoes.GetDescription((Enum)(object)_tipoTela)} DO ID \"{_id}\"", _id, _tipoTela, $"ID ENTIDADE: {_id}\nTIPO: {Funcoes.GetDescription((Enum)(object)_tipoTela)}"); + return; + IL_0428: + text += "EXCLUSÃO"; + goto IL_0434; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs new file mode 100644 index 0000000..4e162a9 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/MetaSeguradoraViewModel.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Assinador.Infrastructure.Helpers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class MetaSeguradoraViewModel : BaseSegurosViewModel +{ + private readonly MetaSeguradoraServico _servico; + + private readonly Seguradora _selectedSeguradora; + + private MetaSeguradora _selectedMetaSeguradora = new MetaSeguradora(); + + private ObservableCollection _metasSeguradora = new ObservableCollection(); + + private bool _carregando; + + public MetaSeguradora CancelMetaSeguradora; + + public MetaSeguradora SelectedMetaSeguradora + { + get + { + return _selectedMetaSeguradora; + } + set + { + _selectedMetaSeguradora = value; + CancelMetaSeguradora = ((value != null && ((DomainBase)value).Id > 0) ? value : CancelMetaSeguradora); + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedMetaSeguradora"); + } + } + + public ObservableCollection MetasSeguradora + { + get + { + return _metasSeguradora; + } + set + { + _metasSeguradora = value; + OnPropertyChanged("MetasSeguradora"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public MetaSeguradoraViewModel(Seguradora seguradora) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + _servico = new MetaSeguradoraServico(); + Seleciona(seguradora); + _selectedSeguradora = seguradora; + } + + private async void Seleciona(Seguradora seguradora) + { + Loading(isLoading: true); + await PermissaoTela((TipoTela)31); + await SelecionaMetasSeguradora(seguradora); + Loading(isLoading: false); + } + + public void SelecionaMetaSeguradora(MetaSeguradora metaSeguradora) + { + SelectedMetaSeguradora = metaSeguradora; + } + + private async Task SelecionaMetasSeguradora(Seguradora seguradora) + { + Carregando = true; + await CarregarMetas(seguradora); + if (MetasSeguradora.Count > 0) + { + SelecionaMetaSeguradora(MetasSeguradora.First()); + } + else + { + SelectedMetaSeguradora = new MetaSeguradora(); + Alterar(alterar: false); + base.EnableMenu = false; + base.EnableAlterar = false; + base.EnableExcluir = false; + } + Carregando = false; + } + + public void Incluir() + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Expected O, but got Unknown + DateTime date = Funcoes.GetNetworkTime().Date; + SelectedMetaSeguradora = new MetaSeguradora + { + Ano = date.Year, + Mes = (Mes)date.Month + }; + Alterar(alterar: true); + } + + public async Task>> Salvar() + { + SelectedMetaSeguradora.Seguradora = _selectedSeguradora; + string acao = ((((DomainBase)SelectedMetaSeguradora).Id == 0L) ? "INCLUIU" : "ALTEROU"); + MetaSeguradora value = await _servico.Save(SelectedMetaSeguradora); + if (!_servico.Sucesso) + { + return null; + } + RegistrarAcao(acao + " META DA SEGURADORA \"" + value.Seguradora.Nome + "\"", ((DomainBase)value).Id, (TipoTela)31, $"ID: {((DomainBase)value).Id}\nVALOR: {value.Valor:C}\nMÊS: {Functions.GetDescription((Enum)(object)value.Mes)}\nANO: {value.Ano}"); + if (MetasSeguradora.Any((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id)) + { + DomainBase.Copy(MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value); + } + else + { + MetasSeguradora.Add(value); + } + MetasSeguradora = new ObservableCollection(MetasSeguradora); + SelectedMetaSeguradora = MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)value).Id); + Alterar(alterar: false); + return null; + } + + public async Task Excluir() + { + if (SelectedMetaSeguradora == null || ((DomainBase)SelectedMetaSeguradora).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + if (!(await _servico.Delete(SelectedMetaSeguradora))) + { + Carregando = false; + Alterar(alterar: false); + return false; + } + MetaSeguradoraViewModel metaSeguradoraViewModel = this; + Seguradora seguradora = SelectedMetaSeguradora.Seguradora; + metaSeguradoraViewModel.RegistrarAcao("EXCLUIU META DA SEGURADORA \"" + ((seguradora != null) ? seguradora.Nome : null) + "\"", ((DomainBase)SelectedMetaSeguradora).Id, (TipoTela)31, $"ID: {((DomainBase)SelectedMetaSeguradora).Id}\nVALOR: {SelectedMetaSeguradora.Valor:C}\nMÊS: {Functions.GetDescription((Enum)(object)SelectedMetaSeguradora.Mes)}\nANO: {SelectedMetaSeguradora.Ano}"); + int num = MetasSeguradora.IndexOf(SelectedMetaSeguradora); + MetasSeguradora.Remove(SelectedMetaSeguradora); + MetasSeguradora.Remove(SelectedMetaSeguradora); + MetasSeguradora = new ObservableCollection(MetasSeguradora); + if (MetasSeguradora.Count > 0) + { + SelectedMetaSeguradora = ((num < MetasSeguradora.Count) ? MetasSeguradora.ElementAt(num) : MetasSeguradora.Last()); + } + else + { + SelectedMetaSeguradora = new MetaSeguradora(); + Alterar(alterar: false); + base.EnableMenu = false; + base.EnableAlterar = false; + base.EnableExcluir = false; + } + Carregando = false; + return true; + } + + public void CancelarAlteracao() + { + Carregando = true; + if (CancelMetaSeguradora != null && MetasSeguradora.Any((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaSeguradora).Id)) + { + DomainBase.Copy(MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaSeguradora).Id), CancelMetaSeguradora); + SelectedMetaSeguradora = MetasSeguradora.First((MetaSeguradora x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaSeguradora).Id); + } + Alterar(alterar: false); + Carregando = false; + } + + private async Task CarregarMetas(Seguradora seguradora) + { + MetasSeguradora = new ObservableCollection(from x in await new BaseServico().BuscarMetaSeguradoraAsync(seguradora) + orderby x.Mes, x.Valor + select x); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/MetaVendedorViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/MetaVendedorViewModel.cs new file mode 100644 index 0000000..55f706c --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/MetaVendedorViewModel.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Assinador.Infrastructure.Helpers; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class MetaVendedorViewModel : BaseSegurosViewModel +{ + private readonly MetaVendedorServico _servico; + + private readonly Vendedor _selectedVendedor; + + private MetaVendedor _selectedMetaVendedor = new MetaVendedor(); + + private ObservableCollection _metasVendedor = new ObservableCollection(); + + private bool _carregando; + + public MetaVendedor CancelMetaVendedor; + + public MetaVendedor SelectedMetaVendedor + { + get + { + return _selectedMetaVendedor; + } + set + { + _selectedMetaVendedor = value; + CancelMetaVendedor = ((value != null && ((DomainBase)value).Id > 0) ? value : CancelMetaVendedor); + VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null); + OnPropertyChanged("SelectedMetaVendedor"); + } + } + + public ObservableCollection MetasVendedor + { + get + { + return _metasVendedor; + } + set + { + _metasVendedor = value; + OnPropertyChanged("MetasVendedor"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public MetaVendedorViewModel(Vendedor vendedor) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Expected O, but got Unknown + _servico = new MetaVendedorServico(); + Seleciona(vendedor); + _selectedVendedor = vendedor; + } + + private async void Seleciona(Vendedor vendedor) + { + Loading(isLoading: true); + await PermissaoTela((TipoTela)30); + await SelecionaMetasVendedor(vendedor); + Loading(isLoading: false); + } + + public void SelecionaMetaVendedor(MetaVendedor metaVendedor) + { + SelectedMetaVendedor = metaVendedor; + } + + private async Task SelecionaMetasVendedor(Vendedor vendedor) + { + Carregando = true; + await CarregarMetas(vendedor); + if (MetasVendedor.Count > 0) + { + SelecionaMetaVendedor(MetasVendedor.First()); + } + else + { + SelectedMetaVendedor = new MetaVendedor(); + Alterar(alterar: false); + base.EnableMenu = false; + } + Carregando = false; + } + + public void Incluir() + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Expected O, but got Unknown + DateTime date = Funcoes.GetNetworkTime().Date; + SelectedMetaVendedor = new MetaVendedor + { + Ano = date.Year, + Mes = (Mes)date.Month + }; + Alterar(alterar: true); + } + + public async Task>> Salvar() + { + SelectedMetaVendedor.Vendedor = _selectedVendedor; + _servico.Sucesso = true; + string acao = ((((DomainBase)SelectedMetaVendedor).Id == 0L) ? "INCLUIU" : "ALTEROU"); + MetaVendedor value = await _servico.Save(SelectedMetaVendedor); + if (!_servico.Sucesso) + { + return null; + } + RegistrarAcao(acao + " META DO VENDEDOR \"" + value.Vendedor.Nome + "\"", ((DomainBase)value).Id, (TipoTela)30, $"ID: {((DomainBase)value).Id}\nVALOR: {value.Valor:C}\nMÊS: {Functions.GetDescription((Enum)(object)value.Mes)}\nANO: {value.Ano}"); + if (MetasVendedor.Any((MetaVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id)) + { + DomainBase.Copy(MetasVendedor.First((MetaVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id), value); + } + else + { + MetasVendedor.Add(value); + } + MetasVendedor = new ObservableCollection(MetasVendedor); + SelectedMetaVendedor = MetasVendedor.First((MetaVendedor x) => ((DomainBase)x).Id == ((DomainBase)value).Id); + Alterar(alterar: false); + return null; + } + + public async Task Excluir() + { + if (SelectedMetaVendedor == null || ((DomainBase)SelectedMetaVendedor).Id == 0L) + { + return false; + } + if (!(await ShowMessage("DESEJA EXCLUIR?", "SIM", "NÃO"))) + { + return false; + } + Carregando = true; + string log = "EXCLUIU META DO VENDEDOR \"" + _selectedVendedor.Nome + "\""; + long id = ((DomainBase)SelectedMetaVendedor).Id; + string descricao = $"ID: {((DomainBase)SelectedMetaVendedor).Id}\nVALOR: {SelectedMetaVendedor.Valor:C}\nMÊS: {Functions.GetDescription((Enum)(object)SelectedMetaVendedor.Mes)}\nANO: {SelectedMetaVendedor.Ano}"; + if (!(await _servico.Delete(SelectedMetaVendedor))) + { + Carregando = false; + Alterar(alterar: false); + return false; + } + RegistrarAcao(log, id, (TipoTela)30, descricao); + await CarregarMetas(_selectedVendedor); + if (MetasVendedor.Count > 0) + { + SelectedMetaVendedor = MetasVendedor.First(); + } + else + { + SelectedMetaVendedor = new MetaVendedor(); + Alterar(alterar: false); + base.EnableMenu = false; + base.EnableAlterar = false; + base.EnableExcluir = false; + } + Carregando = false; + return true; + } + + public void CancelarAlteracao() + { + Carregando = true; + if (CancelMetaVendedor != null && MetasVendedor.Any((MetaVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaVendedor).Id)) + { + DomainBase.Copy(MetasVendedor.First((MetaVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaVendedor).Id), CancelMetaVendedor); + SelectedMetaVendedor = MetasVendedor.First((MetaVendedor x) => ((DomainBase)x).Id == ((DomainBase)CancelMetaVendedor).Id); + } + Alterar(alterar: false); + Carregando = false; + } + + private async Task CarregarMetas(Vendedor vendedor) + { + MetasVendedor = new ObservableCollection((from x in await new BaseServico().BuscarMetaVendedorAsync(vendedor) + orderby x.Mes, x.Valor + select x).ToList()); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/PermissaoUsuarioViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/PermissaoUsuarioViewModel.cs new file mode 100644 index 0000000..393faa6 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/PermissaoUsuarioViewModel.cs @@ -0,0 +1,1704 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Gestor.Application.Actions; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Relatorios.ApolicePendente; +using Gestor.Model.Domain.Relatorios.Auditoria; +using Gestor.Model.Domain.Relatorios.ClientesAtivosInativos; +using Gestor.Model.Domain.Relatorios.Comissao; +using Gestor.Model.Domain.Relatorios.ExtratoBaixado; +using Gestor.Model.Domain.Relatorios.FaturaPendente; +using Gestor.Model.Domain.Relatorios.Fechamento; +using Gestor.Model.Domain.Relatorios.Licenciamento; +using Gestor.Model.Domain.Relatorios.LogsEnvio; +using Gestor.Model.Domain.Relatorios.MetaSeguradora; +using Gestor.Model.Domain.Relatorios.MetaVendedor; +using Gestor.Model.Domain.Relatorios.NotaFiscal; +using Gestor.Model.Domain.Relatorios.Pendente; +using Gestor.Model.Domain.Relatorios.Placa; +using Gestor.Model.Domain.Relatorios.PrevisaoPagamentoComissao; +using Gestor.Model.Domain.Relatorios.Producao; +using Gestor.Model.Domain.Relatorios.Renovacao; +using Gestor.Model.Domain.Relatorios.Sinistro; +using Gestor.Model.Domain.Relatorios.Tarefa; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class PermissaoUsuarioViewModel : BaseSegurosViewModel +{ + private readonly UsuarioServico _servicoUsuario; + + private Usuario _selectedUsuario; + + private bool _expandedBis; + + private bool _expandedSeguros; + + private bool _expandedRelatorios; + + private bool _expandedCampos; + + private bool _expandedTotalizacoes; + + private bool _expandedFinanceiros; + + private bool _expandedFerramentas; + + private bool _expandedAjudas; + + private ObservableCollection _seguros; + + private ObservableCollection _ferramentas; + + private ObservableCollection _arquivosDigitais; + + private bool _enableAlterarPermiss = true; + + private ObservableCollection _restricoesBisFiltradas; + + private ObservableCollection _restricoesSegurosFiltradas; + + private ObservableCollection _restricoesRelatoriosFiltrados; + + private ObservableCollection _restricoesTotalizacoesRelatoriosFiltrados; + + private ObservableCollection _restricoesCamposRelatoriosFiltrados; + + private ObservableCollection _restricoesFinanceirosFiltradas; + + private ObservableCollection _restricoesFerramentasFiltradas; + + private ObservableCollection _restricoesAjudasFiltrados; + + private List _restricoesBis; + + private List _restricoesSeguros; + + private List _restricoesRelatorios; + + private List _restricoesTotalizacoesRelatorios; + + private List _restricoesCamposRelatorios; + + private List _restricoesFinanceiros; + + private List _restricoesFerramentas; + + private List _restricoesAjudas; + + private Visibility _restricoesBisVisibility; + + private Visibility _restricoesSegurosVisibility; + + private Visibility _restricoesRelatoriosVisibility; + + private Visibility _restricoesTotalizacoesRelatoriosVisibility; + + private Visibility _restricoesCamposRelatoriosVisibility; + + private Visibility _restricoesFinanceirosVisibility; + + private Visibility _restricoesFerramentasVisibility; + + private Visibility _restricoesAjudasVisibility; + + private List _permissaoAggilizador; + + private PermissaoAggilizador _selectedPermissao; + + private bool _admUsuario; + + private bool _importarEnabled; + + private bool _carregando; + + private bool _ativarDesativarPermissoesBool = true; + + private bool _ativarDesativarRestricoesBool = true; + + public Usuario SelectedUsuario + { + get + { + return _selectedUsuario; + } + set + { + _selectedUsuario = value; + OnPropertyChanged("SelectedUsuario"); + } + } + + public bool Carregado { get; set; } + + public bool ExpandedBis + { + get + { + return _expandedBis; + } + set + { + _expandedBis = value; + OnPropertyChanged("ExpandedBis"); + } + } + + public bool ExpandedSeguros + { + get + { + return _expandedSeguros; + } + set + { + _expandedSeguros = value; + OnPropertyChanged("ExpandedSeguros"); + } + } + + public bool ExpandedRelatorios + { + get + { + return _expandedRelatorios; + } + set + { + _expandedRelatorios = value; + OnPropertyChanged("ExpandedRelatorios"); + } + } + + public bool ExpandedCampos + { + get + { + return _expandedCampos; + } + set + { + _expandedCampos = value; + OnPropertyChanged("ExpandedCampos"); + } + } + + public bool ExpandedTotalizacoes + { + get + { + return _expandedTotalizacoes; + } + set + { + _expandedTotalizacoes = value; + OnPropertyChanged("ExpandedTotalizacoes"); + } + } + + public bool ExpandedFinanceiros + { + get + { + return _expandedFinanceiros; + } + set + { + _expandedFinanceiros = value; + OnPropertyChanged("ExpandedFinanceiros"); + } + } + + public bool ExpandedFerramentas + { + get + { + return _expandedFerramentas; + } + set + { + _expandedFerramentas = value; + OnPropertyChanged("ExpandedFerramentas"); + } + } + + public bool ExpandedAjudas + { + get + { + return _expandedAjudas; + } + set + { + _expandedAjudas = value; + OnPropertyChanged("ExpandedAjudas"); + } + } + + public ObservableCollection Seguros + { + get + { + return _seguros; + } + set + { + _seguros = value; + OnPropertyChanged("Seguros"); + if (value != null && Ferramentas != null && value.All((PermissaoUsuario x) => ((int)x.Tela == 21 && x.Consultar) || ((int)x.Tela == 5 && x.Alterar && x.Incluir && x.Excluir) || ((int)x.Tela != 21 && (int)x.Tela != 5 && x.Consultar && x.Alterar && x.Incluir && x.Excluir)) && Ferramentas.All((PermissaoUsuario x) => ((int)x.Tela == 18 && x.Consultar && x.Alterar) || ((int)x.Tela == 10 && x.Consultar && x.Alterar && x.Incluir) || ((int)x.Tela == 12 && x.Consultar && x.Alterar) || ((int)x.Tela == 13 && x.Consultar && x.Alterar && x.Incluir) || ((int)x.Tela != 18 && (int)x.Tela != 10 && (int)x.Tela != 12 && (int)x.Tela != 13 && x.Consultar && x.Alterar && x.Incluir && x.Excluir))) + { + AtivarDesativarPermissoesBool = false; + } + Gestor.Application.Actions.Actions.OcultarTogglesSeguros(); + } + } + + public ObservableCollection Ferramentas + { + get + { + return _ferramentas; + } + set + { + _ferramentas = value; + OnPropertyChanged("Ferramentas"); + if (value != null && Seguros != null && value.All((PermissaoUsuario x) => ((int)x.Tela == 18 && x.Consultar && x.Alterar) || ((int)x.Tela == 10 && x.Consultar && x.Alterar && x.Incluir) || ((int)x.Tela == 12 && x.Consultar && x.Alterar) || ((int)x.Tela == 13 && x.Consultar && x.Alterar && x.Incluir) || ((int)x.Tela != 18 && (int)x.Tela != 10 && (int)x.Tela != 12 && (int)x.Tela != 13 && x.Consultar && x.Alterar && x.Incluir && x.Excluir)) && Seguros.All((PermissaoUsuario x) => ((int)x.Tela == 21 && x.Consultar) || ((int)x.Tela == 5 && x.Alterar && x.Incluir && x.Excluir) || ((int)x.Tela != 21 && (int)x.Tela != 5 && x.Consultar && x.Alterar && x.Incluir && x.Excluir))) + { + AtivarDesativarPermissoesBool = false; + } + Gestor.Application.Actions.Actions.OcultarTogglesFerramentas(); + } + } + + public ObservableCollection ArquivosDigitais + { + get + { + return _arquivosDigitais; + } + set + { + _arquivosDigitais = value; + OnPropertyChanged("ArquivosDigitais"); + Gestor.Application.Actions.Actions.OcultarTogglesArquivoDigital(); + } + } + + public bool EnableAlterarPermiss + { + get + { + return _enableAlterarPermiss; + } + set + { + _enableAlterarPermiss = value; + OnPropertyChanged("EnableAlterarPermiss"); + } + } + + public ObservableCollection RestricoesBisFiltradas + { + get + { + return _restricoesBisFiltradas; + } + set + { + RestricoesBisVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesBisFiltradas = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesBisFiltradas"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesSegurosFiltradas + { + get + { + return _restricoesSegurosFiltradas; + } + set + { + RestricoesSegurosVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesSegurosFiltradas = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesSegurosFiltradas"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesRelatoriosFiltrados + { + get + { + return _restricoesRelatoriosFiltrados; + } + set + { + RestricoesRelatoriosVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesRelatoriosFiltrados = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesRelatoriosFiltrados"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesTotalizacoesRelatoriosFiltrados + { + get + { + return _restricoesTotalizacoesRelatoriosFiltrados; + } + set + { + RestricoesTotalizacoesRelatoriosVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesTotalizacoesRelatoriosFiltrados = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesTotalizacoesRelatoriosFiltrados"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesCamposRelatoriosFiltrados + { + get + { + return _restricoesCamposRelatoriosFiltrados; + } + set + { + RestricoesCamposRelatoriosVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesCamposRelatoriosFiltrados = new ObservableCollection(from x in value.ToList() + orderby x.Relatorio, x.Campo + select x); + OnPropertyChanged("RestricoesCamposRelatoriosFiltrados"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesFinanceirosFiltradas + { + get + { + return _restricoesFinanceirosFiltradas; + } + set + { + RestricoesFinanceirosVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesFinanceirosFiltradas = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesFinanceirosFiltradas"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesFerramentasFiltradas + { + get + { + return _restricoesFerramentasFiltradas; + } + set + { + RestricoesFerramentasVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesFerramentasFiltradas = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesFerramentasFiltradas"); + AtivarDesativarRestricoes(); + } + } + + public ObservableCollection RestricoesAjudasFiltrados + { + get + { + return _restricoesAjudasFiltrados; + } + set + { + RestricoesAjudasVisibility = (Visibility)((value == null || value.Count <= 0) ? 2 : 0); + _restricoesAjudasFiltrados = new ObservableCollection(from x in value.ToList() + orderby ValidationHelper.GetDescription((Enum)(object)x.Tipo) + select x); + OnPropertyChanged("RestricoesAjudasFiltrados"); + AtivarDesativarRestricoes(); + } + } + + public List RestricoesBis + { + get + { + return _restricoesBis; + } + set + { + _restricoesBis = value; + OnPropertyChanged("RestricoesBis"); + } + } + + public List RestricoesSeguros + { + get + { + return _restricoesSeguros; + } + set + { + _restricoesSeguros = value; + OnPropertyChanged("RestricoesSeguros"); + } + } + + public List RestricoesRelatorios + { + get + { + return _restricoesRelatorios; + } + set + { + _restricoesRelatorios = value; + OnPropertyChanged("RestricoesRelatorios"); + } + } + + public List RestricoesTotalizacoesRelatorios + { + get + { + return _restricoesTotalizacoesRelatorios; + } + set + { + _restricoesTotalizacoesRelatorios = value; + OnPropertyChanged("RestricoesTotalizacoesRelatorios"); + } + } + + public List RestricoesCamposRelatorios + { + get + { + return _restricoesCamposRelatorios; + } + set + { + _restricoesCamposRelatorios = value; + OnPropertyChanged("RestricoesCamposRelatorios"); + } + } + + public List RestricoesFinanceiros + { + get + { + return _restricoesFinanceiros; + } + set + { + _restricoesFinanceiros = value; + OnPropertyChanged("RestricoesFinanceiros"); + } + } + + public List RestricoesFerramentas + { + get + { + return _restricoesFerramentas; + } + set + { + _restricoesFerramentas = value; + OnPropertyChanged("RestricoesFerramentas"); + } + } + + public List RestricoesAjudas + { + get + { + return _restricoesAjudas; + } + set + { + _restricoesAjudas = value; + OnPropertyChanged("RestricoesAjudas"); + } + } + + public Visibility RestricoesBisVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesBisVisibility; + } + 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) + _restricoesBisVisibility = value; + OnPropertyChanged("RestricoesBisVisibility"); + } + } + + public Visibility RestricoesSegurosVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesSegurosVisibility; + } + 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) + _restricoesSegurosVisibility = value; + OnPropertyChanged("RestricoesSegurosVisibility"); + } + } + + public Visibility RestricoesRelatoriosVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesRelatoriosVisibility; + } + 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) + _restricoesRelatoriosVisibility = value; + OnPropertyChanged("RestricoesRelatoriosVisibility"); + } + } + + public Visibility RestricoesTotalizacoesRelatoriosVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesTotalizacoesRelatoriosVisibility; + } + 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) + _restricoesTotalizacoesRelatoriosVisibility = value; + OnPropertyChanged("RestricoesTotalizacoesRelatoriosVisibility"); + } + } + + public Visibility RestricoesCamposRelatoriosVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesCamposRelatoriosVisibility; + } + 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) + _restricoesCamposRelatoriosVisibility = value; + OnPropertyChanged("RestricoesCamposRelatoriosVisibility"); + } + } + + public Visibility RestricoesFinanceirosVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesFinanceirosVisibility; + } + 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) + _restricoesFinanceirosVisibility = value; + OnPropertyChanged("RestricoesFinanceirosVisibility"); + } + } + + public Visibility RestricoesFerramentasVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesFerramentasVisibility; + } + 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) + _restricoesFerramentasVisibility = value; + OnPropertyChanged("RestricoesFerramentasVisibility"); + } + } + + public Visibility RestricoesAjudasVisibility + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _restricoesAjudasVisibility; + } + 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) + _restricoesAjudasVisibility = value; + OnPropertyChanged("RestricoesAjudasVisibility"); + } + } + + public List PermissaoAggilizador + { + get + { + return _permissaoAggilizador; + } + set + { + _permissaoAggilizador = value; + OnPropertyChanged("PermissaoAggilizador"); + } + } + + public PermissaoAggilizador SelectedPermissao + { + get + { + return _selectedPermissao; + } + set + { + _selectedPermissao = value; + OnPropertyChanged("SelectedPermissao"); + } + } + + public bool AdmUsuario + { + get + { + return _admUsuario; + } + set + { + _admUsuario = value; + ImportarEnabled = !value; + SelectedUsuario.Administrador = value; + if (value && !Carregando) + { + AtivarDesativarPermissoes(permiss: true); + AtivarDesativarRestricoes(restricao: false); + } + OnPropertyChanged("AdmUsuario"); + } + } + + public bool ImportarEnabled + { + get + { + return _importarEnabled; + } + set + { + _importarEnabled = value; + OnPropertyChanged("ImportarEnabled"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + OnPropertyChanged("Carregando"); + } + } + + public bool AtivarDesativarPermissoesBool + { + get + { + return _ativarDesativarPermissoesBool; + } + set + { + _ativarDesativarPermissoesBool = value; + OnPropertyChanged("AtivarDesativarPermissoesBool"); + } + } + + public bool AtivarDesativarRestricoesBool + { + get + { + return _ativarDesativarRestricoesBool; + } + set + { + _ativarDesativarRestricoesBool = value; + OnPropertyChanged("AtivarDesativarRestricoesBool"); + } + } + + public PermissaoUsuarioViewModel(Usuario usuario) + { + SelectedUsuario = usuario; + _servicoUsuario = new UsuarioServico(); + CarregarModulos(usuario); + EnableAlterarPermiss = ((DomainBase)Recursos.Usuario).Id > 0; + } + + private async void CarregarModulos(Usuario usuario) + { + await Modulos(usuario); + Carregado = true; + } + + private async Task Modulos(Usuario usuario) + { + Carregando = true; + usuario = await _servicoUsuario.BuscarUsuarioPorId(((DomainBase)usuario).Id); + Seguros = new ObservableCollection(await GetPermissoes(usuario, "seguros")); + Ferramentas = new ObservableCollection(await GetPermissoes(usuario, "ferramentas")); + ArquivosDigitais = new ObservableCollection(await GetPermissoesArquivoDigital(usuario)); + PermissaoAggilizador = new List(await _servicoUsuario.BuscarPermissaoAggilizador()); + RestricoesBis = await GetRestricoes(usuario, "b.i."); + RestricoesBisFiltradas = new ObservableCollection(RestricoesBis); + RestricoesSeguros = await GetRestricoes(usuario, "seguros"); + RestricoesSegurosFiltradas = new ObservableCollection(RestricoesSeguros); + RestricoesRelatorios = await GetRestricoes(usuario, "relatorios"); + RestricoesRelatoriosFiltrados = new ObservableCollection(RestricoesRelatorios); + RestricoesFinanceiros = await GetRestricoes(usuario, "financeiro"); + RestricoesFinanceirosFiltradas = new ObservableCollection(RestricoesFinanceiros); + RestricoesFerramentas = await GetRestricoes(usuario, "ferramentas"); + RestricoesFerramentasFiltradas = new ObservableCollection(RestricoesFerramentas); + RestricoesAjudas = await GetRestricoes(usuario, "ajuda"); + RestricoesAjudasFiltrados = new ObservableCollection(RestricoesAjudas); + RestricoesTotalizacoesRelatorios = await GetRestricoes(usuario, "totalizacoesRelatorios"); + RestricoesTotalizacoesRelatoriosFiltrados = new ObservableCollection(RestricoesTotalizacoesRelatorios); + RestricoesCamposRelatorios = await GetRestricoesCamposRelatorios(usuario); + RestricoesCamposRelatoriosFiltrados = new ObservableCollection(RestricoesCamposRelatorios); + Carregando = false; + AdmUsuario = usuario.Administrador; + SelectedPermissao = ((!usuario.PermissaoAggilizador.HasValue) ? ((IEnumerable)PermissaoAggilizador).FirstOrDefault((Func)((PermissaoAggilizador x) => ((DomainBase)x).Id == 2)) : ((IEnumerable)PermissaoAggilizador).FirstOrDefault((Func)((PermissaoAggilizador x) => ((DomainBase)x).Id == usuario.PermissaoAggilizador))); + } + + private async Task> GetPermissoesArquivoDigital(Usuario usuario) + { + List list = new List(); + List telas = (from TipoArquivoDigital v in Enum.GetValues(typeof(TipoArquivoDigital)) + select ((object)(TipoArquivoDigital)(ref v)).ToString() into x + orderby x + select x).ToList(); + List permissoes = await ServicoPermissArquivoDigital.PermissArquivoDigital(usuario); + telas.ForEach(delegate(string x) + { + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_00ca: Unknown result type (might be due to invalid IL or missing references) + //IL_00cf: Unknown result type (might be due to invalid IL or missing references) + //IL_00d6: Unknown result type (might be due to invalid IL or missing references) + //IL_00d8: 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_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_00fa: Expected O, but got Unknown + TipoArquivoDigital tela = (TipoArquivoDigital)Enum.Parse(typeof(TipoArquivoDigital), x); + long id = 0L; + bool consultar = true; + bool incluir = true; + bool excluir = true; + if (permissoes.Count > 0 && permissoes.Any((PermissaoArquivoDigital y) => y.Tela == tela)) + { + id = ((DomainBase)permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela)).Id; + consultar = permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela).Consultar; + incluir = permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela).Incluir; + excluir = permissoes.First((PermissaoArquivoDigital y) => y.Tela == tela).Excluir; + } + PermissaoArquivoDigital item = new PermissaoArquivoDigital + { + Id = id, + Tela = tela, + Consultar = consultar, + Incluir = incluir, + Excluir = excluir + }; + list.Add(item); + }); + return list; + } + + private async Task> GetPermissoes(Usuario usuario, string modulo) + { + List list = new List(); + List telas = (from TipoTela v in Enum.GetValues(typeof(TipoTela)) + select ((object)(TipoTela)(ref v)).ToString() into x + orderby x + select x).ToList(); + List permissoes = await ServicoPermissUsuario.PermissUsuario(usuario); + telas.ForEach(delegate(string x) + { + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_010d: Unknown result type (might be due to invalid IL or missing references) + //IL_0112: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_011b: Unknown result type (might be due to invalid IL or missing references) + //IL_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_012c: Unknown result type (might be due to invalid IL or missing references) + //IL_0133: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Unknown result type (might be due to invalid IL or missing references) + //IL_0145: Expected O, but got Unknown + TipoTela tela = (TipoTela)Enum.Parse(typeof(TipoTela), x); + if (string.Equals(ValidationHelper.GetCategory((Enum)(object)tela), modulo, StringComparison.CurrentCultureIgnoreCase)) + { + long id = 0L; + bool consultar = true; + bool incluir = true; + bool alterar = true; + bool excluir = true; + if (permissoes.Count > 0 && permissoes.Any((PermissaoUsuario y) => y.Tela == tela)) + { + id = ((DomainBase)permissoes.First((PermissaoUsuario y) => y.Tela == tela)).Id; + consultar = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Consultar; + incluir = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Incluir; + alterar = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Alterar; + excluir = permissoes.First((PermissaoUsuario y) => y.Tela == tela).Excluir; + } + PermissaoUsuario item = new PermissaoUsuario + { + Id = id, + Tela = tela, + Consultar = consultar, + Incluir = incluir, + Alterar = alterar, + Excluir = excluir + }; + list.Add(item); + } + }); + return list; + } + + private async Task> GetRestricoes(Usuario usuario, string modulo) + { + List list = new List(); + List tipos = (from TipoRestricao v in Enum.GetValues(typeof(TipoRestricao)) + select ((object)(TipoRestricao)(ref v)).ToString() into x + orderby x + select x).ToList(); + List restricoesUsuario = await ServicoRestriUsuario.BuscarRestricoes(((DomainBase)usuario).Id); + tipos.ForEach(delegate(string x) + { + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_00b7: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00c3: Unknown result type (might be due to invalid IL or missing references) + //IL_00c5: Unknown result type (might be due to invalid IL or missing references) + //IL_00cf: Unknown result type (might be due to invalid IL or missing references) + //IL_00d6: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Expected O, but got Unknown + TipoRestricao tipo = (TipoRestricao)Enum.Parse(typeof(TipoRestricao), x); + if (string.Equals(ValidationHelper.GetCategory((Enum)(object)tipo), modulo, StringComparison.CurrentCultureIgnoreCase)) + { + string help = ValidationHelper.GetHelp((Enum)(object)tipo); + long id = 0L; + bool restricao = false; + if (restricoesUsuario.Count > 0 && restricoesUsuario.Any((RestricaoUsuario y) => y.Tipo == tipo)) + { + id = ((DomainBase)restricoesUsuario.First((RestricaoUsuario y) => y.Tipo == tipo)).Id; + restricao = restricoesUsuario.First((RestricaoUsuario y) => y.Tipo == tipo).Restricao; + } + RestricaoUsuario item = new RestricaoUsuario + { + Id = id, + Tipo = tipo, + Restricao = restricao, + Ajuda = help + }; + list.Add(item); + } + }); + return list; + } + + private async Task> GetRestricoesCamposRelatorios(Usuario usuario) + { + List list = new List(); + List parametros = new List(); + foreach (Relatorio item2 in Enum.GetValues(typeof(Relatorio)).Cast()) + { + switch ((int)item2) + { + case 0: + case 1: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 2: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 3: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 18: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 4: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 5: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 6: + case 16: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 9: + case 10: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 23: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 8: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 13: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 12: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 14: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 15: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 11: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 17: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 27: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 7: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 19: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + case 20: + parametros.AddRange(Funcoes.ColunasRelatorio(item2, new List())); + break; + } + } + List restricoesUsuario = await ServicoRestriUsuario.BuscarRestricoesCamposRelatorios(((DomainBase)usuario).Id); + parametros.ForEach(delegate(ParametrosRelatorio x) + { + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Expected O, but got Unknown + long id = 0L; + bool restricao = false; + if (restricoesUsuario.Count > 0 && restricoesUsuario.Any((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Header && y.Relatorio == x.Relatorio)) + { + id = ((DomainBase)restricoesUsuario.First((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Header && y.Relatorio == x.Relatorio)).Id; + restricao = restricoesUsuario.First((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Header && y.Relatorio == x.Relatorio).Restricao; + } + RestricaoUsuarioCamposRelatorios item = new RestricaoUsuarioCamposRelatorios + { + Id = id, + Campo = x.Header, + Relatorio = x.Relatorio, + Restricao = restricao + }; + list.Add(item); + }); + return list; + } + + public async Task Salvar(long? idUsuario = null, bool registrar = true) + { + PermissaoUsuario obj = ServicoPermissUsuario.BuscarPermissao(Recursos.Usuario, (TipoTela)43); + if (obj != null && !obj.Alterar && !Recursos.Usuario.Administrador) + { + await ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA ALTERAR PERMISSÕES!"); + return false; + } + Usuario usuario = await _servicoUsuario.BuscarUsuarioPorId(idUsuario ?? ((DomainBase)_selectedUsuario).Id); + List prevPer = new List(); + List list = prevPer; + list.AddRange(await GetPermissoes(usuario, "seguros")); + list = prevPer; + list.AddRange(await GetPermissoes(usuario, "ferramentas")); + List prevPerArquivoDigital = new List(); + List list2 = prevPerArquivoDigital; + list2.AddRange(await GetPermissoesArquivoDigital(usuario)); + List permissao = ((IEnumerable)ArquivosDigitais).Select((Func)((PermissaoArquivoDigital x) => new PermissaoArquivoDigital + { + Id = ((prevPerArquivoDigital.Count == 0) ? 0 : ((DomainBase)prevPerArquivoDigital.First((PermissaoArquivoDigital y) => y.Tela == x.Tela)).Id), + Tela = x.Tela, + Consultar = x.Consultar, + Incluir = x.Incluir, + Excluir = x.Excluir, + Usuario = usuario + })).ToList(); + List permissoes = new List(); + List collection = ((IEnumerable)Seguros).Select((Func)((PermissaoUsuario x) => new PermissaoUsuario + { + Id = ((prevPer.Count == 0) ? 0 : ((DomainBase)prevPer.First((PermissaoUsuario y) => y.Tela == x.Tela)).Id), + Tela = x.Tela, + Consultar = x.Consultar, + Incluir = x.Incluir, + Alterar = x.Alterar, + Excluir = x.Excluir, + Usuario = usuario + })).ToList(); + permissoes.AddRange(collection); + collection = ((IEnumerable)Ferramentas).Select((Func)((PermissaoUsuario x) => new PermissaoUsuario + { + Id = ((prevPer.Count == 0) ? 0 : ((DomainBase)prevPer.First((PermissaoUsuario y) => y.Tela == x.Tela)).Id), + Tela = x.Tela, + Consultar = x.Consultar, + Incluir = x.Incluir, + Alterar = x.Alterar, + Excluir = x.Excluir, + Usuario = usuario + })).ToList(); + permissoes.AddRange(collection); + Usuario obj2 = usuario; + PermissaoAggilizador selectedPermissao = SelectedPermissao; + obj2.PermissaoAggilizador = ((selectedPermissao != null) ? ((DomainBase)selectedPermissao).Id : 0); + usuario.Administrador = AdmUsuario; + await ServicoPermissArquivoDigital.SavePermiss(permissao, prevPerArquivoDigital); + if (!ServicoPermissArquivoDigital.Sucesso) + { + return false; + } + await ServicoPermissUsuario.SavePermiss(permissoes, prevPer); + if (!ServicoPermissUsuario.Sucesso) + { + return false; + } + await _servicoUsuario.Save(usuario); + if (!_servicoUsuario.Sucesso) + { + return false; + } + if (((DomainBase)Recursos.Usuario).Id == ((DomainBase)_selectedUsuario).Id) + { + Recursos.Usuario = usuario; + } + List prevRes = new List(); + List list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "b.i.")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "seguros")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "relatorios")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "financeiro")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "ferramentas")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "ajuda")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "totalizacoesRelatorios")); + list3 = prevRes; + list3.AddRange(await GetRestricoes(usuario, "camposRelatorios")); + List prevResCamposRelatorios = new List(); + List list4 = prevResCamposRelatorios; + list4.AddRange(await GetRestricoesCamposRelatorios(usuario)); + List list5 = new List(); + List restricoesCamposRelatorios = new List(); + List collection2 = ((IEnumerable)RestricoesBis).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + collection2 = ((IEnumerable)RestricoesSeguros).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + collection2 = ((IEnumerable)RestricoesRelatorios).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + collection2 = ((IEnumerable)RestricoesTotalizacoesRelatorios).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + collection2 = ((IEnumerable)RestricoesFinanceiros).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + collection2 = ((IEnumerable)RestricoesFerramentas).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + collection2 = ((IEnumerable)RestricoesAjudas).Select((Func)((RestricaoUsuario x) => new RestricaoUsuario + { + Id = ((prevRes.Count == 0) ? 0 : ((DomainBase)prevRes.First((RestricaoUsuario y) => y.Tipo == x.Tipo)).Id), + Tipo = x.Tipo, + Restricao = x.Restricao, + Usuario = usuario + })).ToList(); + list5.AddRange(collection2); + List collection3 = ((IEnumerable)RestricoesCamposRelatorios).Select((Func)((RestricaoUsuarioCamposRelatorios x) => new RestricaoUsuarioCamposRelatorios + { + Id = ((prevResCamposRelatorios.Count == 0) ? 0 : ((DomainBase)prevResCamposRelatorios.First((RestricaoUsuarioCamposRelatorios y) => y.Campo == x.Campo && y.Relatorio == x.Relatorio)).Id), + Campo = x.Campo, + Restricao = x.Restricao, + Relatorio = x.Relatorio, + Usuario = usuario + })).ToList(); + restricoesCamposRelatorios.AddRange(collection3); + await ServicoRestriUsuario.SaveRestri(list5, prevRes); + if (!ServicoRestriUsuario.Sucesso) + { + return false; + } + await ServicoRestriUsuario.SaveRestriCamposRelatorios(restricoesCamposRelatorios, prevResCamposRelatorios); + if (!ServicoRestriUsuario.Sucesso) + { + return false; + } + if (registrar) + { + RegistrarAcao("ALTEROU PERMISSÕES/RESTRIÇÕES DO USUÁRIO \"" + SelectedUsuario.Nome + "\"", ((DomainBase)SelectedUsuario).Id, (TipoTela)43, "ACESSE O LOG DE ALTERAÇÕES NA TELA DE PERMISSÕES/RESTRIÇÕES PARA VER EXATAMENTE O QUE FOI ALTERADO."); + } + return true; + } + + internal async Task> FiltrarRestricoesBi(string value) + { + return await Task.Run(() => FiltrarRestricoesBis(value)); + } + + internal async Task> FiltrarRestricoesSeguro(string value) + { + return await Task.Run(() => FiltrarRestricoesSeguros(value)); + } + + internal async Task> FiltrarRestricoesRelatorio(string value) + { + return await Task.Run(() => FiltrarRestricoesRelatorios(value)); + } + + internal async Task> FiltrarRestricoesTotalizacoesRelatorio(string value) + { + return await Task.Run(() => FiltrarRestricoesTotalizacoesRelatorios(value)); + } + + internal async Task> FiltrarRestricoesCamposRelatorio(string value) + { + return await Task.Run(() => FiltrarRestricoesCamposRelatorios(value)); + } + + internal async Task> FiltrarRestricoesFinanceiro(string value) + { + return await Task.Run(() => FiltrarRestricoesFinanceiros(value)); + } + + internal async Task> FiltrarRestricoesFerramenta(string value) + { + return await Task.Run(() => FiltrarRestricoesFerramentas(value)); + } + + internal async Task> FiltrarRestricoesAjuda(string value) + { + return await Task.Run(() => FiltrarRestricoesAjudas(value)); + } + + public List FiltrarRestricoesBis(string filter) + { + RestricoesBisFiltradas = ((filter == "") ? new ObservableCollection(RestricoesBis) : new ObservableCollection(RestricoesBis.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedBis = RestricoesBisFiltradas.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesBisFiltradas.ToList(); + } + return null; + } + + public List FiltrarRestricoesSeguros(string filter) + { + RestricoesSegurosFiltradas = ((filter == "") ? new ObservableCollection(RestricoesSeguros) : new ObservableCollection(RestricoesSeguros.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedSeguros = RestricoesSegurosFiltradas.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesSegurosFiltradas.ToList(); + } + return null; + } + + public List FiltrarRestricoesRelatorios(string filter) + { + RestricoesRelatoriosFiltrados = ((filter == "") ? new ObservableCollection(RestricoesRelatorios) : new ObservableCollection(RestricoesRelatorios.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedRelatorios = RestricoesRelatoriosFiltrados.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesRelatoriosFiltrados.ToList(); + } + return null; + } + + public List FiltrarRestricoesTotalizacoesRelatorios(string filter) + { + RestricoesTotalizacoesRelatoriosFiltrados = ((filter == "") ? new ObservableCollection(RestricoesTotalizacoesRelatorios) : new ObservableCollection(RestricoesTotalizacoesRelatorios.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedTotalizacoes = RestricoesTotalizacoesRelatoriosFiltrados.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesTotalizacoesRelatoriosFiltrados.ToList(); + } + return null; + } + + public List FiltrarRestricoesCamposRelatorios(string filter) + { + RestricoesCamposRelatoriosFiltrados = ((filter == "") ? new ObservableCollection(RestricoesCamposRelatorios) : new ObservableCollection(RestricoesCamposRelatorios.Where((RestricaoUsuarioCamposRelatorios x) => ValidationHelper.RemoveDiacritics(x.Campo.ToUpper().Trim()).Contains(filter.ToUpper()) || ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Relatorio).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedCampos = RestricoesCamposRelatoriosFiltrados.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesCamposRelatoriosFiltrados.ToList(); + } + return null; + } + + public List FiltrarRestricoesFinanceiros(string filter) + { + RestricoesFinanceirosFiltradas = ((filter == "") ? new ObservableCollection(RestricoesFinanceiros) : new ObservableCollection(RestricoesFinanceiros.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedFinanceiros = RestricoesFinanceirosFiltradas.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesFinanceirosFiltradas.ToList(); + } + return null; + } + + public List FiltrarRestricoesFerramentas(string filter) + { + RestricoesFerramentasFiltradas = ((filter == "") ? new ObservableCollection(RestricoesFerramentas) : new ObservableCollection(RestricoesFerramentas.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedFerramentas = RestricoesFerramentasFiltradas.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesFerramentasFiltradas.ToList(); + } + return null; + } + + public List FiltrarRestricoesAjudas(string filter) + { + RestricoesAjudasFiltrados = ((filter == "") ? new ObservableCollection(RestricoesAjudas) : new ObservableCollection(RestricoesAjudas.Where((RestricaoUsuario x) => ValidationHelper.RemoveDiacritics(ValidationHelper.GetDescription((Enum)(object)x.Tipo).Trim()).ToUpper().Contains(filter.ToUpper())))); + ExpandedAjudas = RestricoesAjudasFiltrados.Count > 0 && filter != ""; + if (!(filter == "")) + { + return RestricoesAjudasFiltrados.ToList(); + } + return null; + } + + public bool CopiarPermissoes(Tuple, Usuario, List, List, List> copiarPermiss) + { + if (copiarPermiss.Item1.Count > 0) + { + copiarPermiss.Item1.ForEach(delegate(PermissaoUsuario x) + { + Seguros.ToList().ForEach(delegate(PermissaoUsuario y) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + if (x.Tela == y.Tela) + { + y.Consultar = x.Consultar; + y.Incluir = x.Incluir; + y.Alterar = x.Alterar; + y.Excluir = x.Excluir; + y.Usuario = _selectedUsuario; + } + }); + Ferramentas.ToList().ForEach(delegate(PermissaoUsuario y) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + if (x.Tela == y.Tela) + { + y.Consultar = x.Consultar; + y.Incluir = x.Incluir; + y.Alterar = x.Alterar; + y.Excluir = x.Excluir; + y.Usuario = _selectedUsuario; + } + }); + }); + } + else + { + Seguros.ToList().ForEach(delegate(PermissaoUsuario x) + { + x.Consultar = false; + x.Incluir = false; + x.Alterar = false; + x.Excluir = false; + x.Usuario = _selectedUsuario; + }); + Ferramentas.ToList().ForEach(delegate(PermissaoUsuario x) + { + x.Consultar = false; + x.Incluir = false; + x.Alterar = false; + x.Excluir = false; + x.Usuario = _selectedUsuario; + }); + } + if (copiarPermiss.Item4.Count > 0) + { + copiarPermiss.Item4.ForEach(delegate(PermissaoArquivoDigital x) + { + ArquivosDigitais.ToList().ForEach(delegate(PermissaoArquivoDigital y) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + if (x.Tela == y.Tela) + { + y.Consultar = x.Consultar; + y.Incluir = x.Incluir; + y.Excluir = x.Excluir; + y.Usuario = _selectedUsuario; + } + }); + }); + } + else + { + ArquivosDigitais.ToList().ForEach(delegate(PermissaoArquivoDigital x) + { + x.Consultar = false; + x.Incluir = false; + x.Excluir = false; + x.Usuario = _selectedUsuario; + }); + } + SelectedPermissao = (copiarPermiss.Item2.PermissaoAggilizador.HasValue ? ((IEnumerable)PermissaoAggilizador).FirstOrDefault((Func)((PermissaoAggilizador x) => ((DomainBase)x).Id == copiarPermiss.Item2.PermissaoAggilizador)) : null); + copiarPermiss.Item3.ForEach(delegate(RestricaoUsuario x) + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Unknown result type (might be due to invalid IL or missing references) + //IL_01a4: Unknown result type (might be due to invalid IL or missing references) + //IL_0201: Unknown result type (might be due to invalid IL or missing references) + //IL_0207: Unknown result type (might be due to invalid IL or missing references) + //IL_0264: Unknown result type (might be due to invalid IL or missing references) + //IL_026a: Unknown result type (might be due to invalid IL or missing references) + foreach (RestricaoUsuario restricoesBi in RestricoesBis) + { + if (restricoesBi.Tipo == x.Tipo) + { + restricoesBi.Restricao = x.Restricao; + restricoesBi.Usuario = _selectedUsuario; + } + } + foreach (RestricaoUsuario restricoesSeguro in RestricoesSeguros) + { + if (restricoesSeguro.Tipo == x.Tipo) + { + restricoesSeguro.Restricao = x.Restricao; + restricoesSeguro.Usuario = _selectedUsuario; + } + } + foreach (RestricaoUsuario restricoesRelatorio in RestricoesRelatorios) + { + if (restricoesRelatorio.Tipo == x.Tipo) + { + restricoesRelatorio.Restricao = x.Restricao; + restricoesRelatorio.Usuario = _selectedUsuario; + } + } + foreach (RestricaoUsuario restricoesTotalizacoesRelatorio in RestricoesTotalizacoesRelatorios) + { + if (restricoesTotalizacoesRelatorio.Tipo == x.Tipo) + { + restricoesTotalizacoesRelatorio.Restricao = x.Restricao; + restricoesTotalizacoesRelatorio.Usuario = _selectedUsuario; + } + } + foreach (RestricaoUsuario restricoesFinanceiro in RestricoesFinanceiros) + { + if (restricoesFinanceiro.Tipo == x.Tipo) + { + restricoesFinanceiro.Restricao = x.Restricao; + restricoesFinanceiro.Usuario = _selectedUsuario; + } + } + foreach (RestricaoUsuario restricoesFerramenta in RestricoesFerramentas) + { + if (restricoesFerramenta.Tipo == x.Tipo) + { + restricoesFerramenta.Restricao = x.Restricao; + restricoesFerramenta.Usuario = _selectedUsuario; + } + } + foreach (RestricaoUsuario restricoesAjuda in RestricoesAjudas) + { + if (restricoesAjuda.Tipo == x.Tipo) + { + restricoesAjuda.Restricao = x.Restricao; + restricoesAjuda.Usuario = _selectedUsuario; + } + } + }); + copiarPermiss.Item5.ForEach(delegate(RestricaoUsuarioCamposRelatorios x) + { + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + foreach (RestricaoUsuarioCamposRelatorios restricoesCamposRelatorio in RestricoesCamposRelatorios) + { + if (restricoesCamposRelatorio.Campo == x.Campo && restricoesCamposRelatorio.Relatorio == x.Relatorio) + { + restricoesCamposRelatorio.Restricao = x.Restricao; + restricoesCamposRelatorio.Usuario = _selectedUsuario; + } + } + }); + RegistrarAcao("IMPORTOU PERMISSÕES/RESTRIÇÕES DO USUÁRIO \"" + copiarPermiss.Item2.Nome + "\"", ((DomainBase)SelectedUsuario).Id, (TipoTela)43, $"ID USUÁRIO: {((DomainBase)copiarPermiss.Item2).Id}"); + return true; + } + + public async Task ExportarPermissoes(List usuarios) + { + foreach (Usuario item in usuarios.Where((Usuario x) => x.Selecionado)) + { + await Salvar(((DomainBase)item).Id, registrar: false); + } + RegistrarAcao(string.Format("EXPORTOU PERMISSÕES/RESTRIÇÕES DO USUÁRIO \"{0}\" PARA {1} USUÁRIO{2}", SelectedUsuario.Nome, usuarios.Count, (usuarios.Count == 1) ? "" : "S"), ((DomainBase)SelectedUsuario).Id, (TipoTela)43, "IDS E NOMES DOS USUÁRIOS: " + string.Join("\n", usuarios.Select((Usuario x) => $"{((DomainBase)x).Id}: \"{x.Nome}\""))); + return true; + } + + public void AtivarDesativarPermissoes(bool permiss) + { + AtivarDesativarPermissoesBool = !permiss; + Seguros.ToList().ForEach(delegate(PermissaoUsuario x) + { + x.Consultar = permiss; + x.Incluir = permiss; + x.Alterar = permiss; + x.Excluir = permiss; + }); + Ferramentas.ToList().ForEach(delegate(PermissaoUsuario x) + { + x.Consultar = permiss; + x.Incluir = permiss; + x.Alterar = permiss; + x.Excluir = permiss; + }); + ArquivosDigitais.ToList().ForEach(delegate(PermissaoArquivoDigital x) + { + x.Consultar = permiss; + x.Incluir = permiss; + x.Excluir = permiss; + }); + SelectedPermissao = (permiss ? ((IEnumerable)PermissaoAggilizador).FirstOrDefault((Func)((PermissaoAggilizador x) => x.Descricao == "ADMINISTRADOR")) : null); + Seguros = new ObservableCollection(Seguros); + Ferramentas = new ObservableCollection(Ferramentas); + ArquivosDigitais = new ObservableCollection(ArquivosDigitais); + } + + public void AtivarDesativarRestricoes(bool restricao) + { + AtivarDesativarRestricoesBool = !restricao; + foreach (RestricaoUsuario restricoesBisFiltrada in RestricoesBisFiltradas) + { + restricoesBisFiltrada.Restricao = restricao; + } + foreach (RestricaoUsuario restricoesSegurosFiltrada in RestricoesSegurosFiltradas) + { + restricoesSegurosFiltrada.Restricao = restricao; + } + foreach (RestricaoUsuario restricoesRelatoriosFiltrado in RestricoesRelatoriosFiltrados) + { + restricoesRelatoriosFiltrado.Restricao = restricao; + } + foreach (RestricaoUsuario restricoesTotalizacoesRelatoriosFiltrado in RestricoesTotalizacoesRelatoriosFiltrados) + { + restricoesTotalizacoesRelatoriosFiltrado.Restricao = restricao; + } + foreach (RestricaoUsuarioCamposRelatorios restricoesCamposRelatoriosFiltrado in RestricoesCamposRelatoriosFiltrados) + { + restricoesCamposRelatoriosFiltrado.Restricao = restricao; + } + foreach (RestricaoUsuario restricoesFinanceirosFiltrada in RestricoesFinanceirosFiltradas) + { + restricoesFinanceirosFiltrada.Restricao = restricao; + } + foreach (RestricaoUsuario restricoesFerramentasFiltrada in RestricoesFerramentasFiltradas) + { + restricoesFerramentasFiltrada.Restricao = restricao; + } + foreach (RestricaoUsuario restricoesAjudasFiltrado in RestricoesAjudasFiltrados) + { + restricoesAjudasFiltrado.Restricao = restricao; + } + RestricoesBisFiltradas = new ObservableCollection(RestricoesBisFiltradas); + RestricoesSegurosFiltradas = new ObservableCollection(RestricoesSegurosFiltradas); + RestricoesRelatoriosFiltrados = new ObservableCollection(RestricoesRelatoriosFiltrados); + RestricoesTotalizacoesRelatoriosFiltrados = new ObservableCollection(RestricoesTotalizacoesRelatoriosFiltrados); + RestricoesCamposRelatoriosFiltrados = new ObservableCollection(RestricoesCamposRelatoriosFiltrados); + RestricoesFinanceirosFiltradas = new ObservableCollection(RestricoesFinanceirosFiltradas); + RestricoesFerramentasFiltradas = new ObservableCollection(RestricoesFerramentasFiltradas); + RestricoesAjudasFiltrados = new ObservableCollection(RestricoesAjudasFiltrados); + } + + public void AtivarDesativarRestricoes() + { + if (RestricoesBisFiltradas != null && RestricoesAjudasFiltrados != null && RestricoesSegurosFiltradas != null && RestricoesRelatoriosFiltrados != null && RestricoesFinanceirosFiltradas != null && RestricoesFerramentasFiltradas != null && RestricoesTotalizacoesRelatoriosFiltrados != null && RestricoesCamposRelatoriosFiltrados != null && RestricoesBisFiltradas.All((RestricaoUsuario x) => x.Restricao) && RestricoesAjudasFiltrados.All((RestricaoUsuario x) => x.Restricao) && RestricoesSegurosFiltradas.All((RestricaoUsuario x) => x.Restricao) && RestricoesRelatoriosFiltrados.All((RestricaoUsuario x) => x.Restricao) && RestricoesFinanceirosFiltradas.All((RestricaoUsuario x) => x.Restricao) && RestricoesFerramentasFiltradas.All((RestricaoUsuario x) => x.Restricao) && RestricoesTotalizacoesRelatoriosFiltrados.All((RestricaoUsuario x) => x.Restricao) && RestricoesCamposRelatoriosFiltrados.All((RestricaoUsuarioCamposRelatorios x) => x.Restricao)) + { + AtivarDesativarRestricoesBool = false; + } + } + + public void DesabilitarArquivoDigital(PermissaoArquivoDigital desabilitar) + { + PermissaoArquivoDigital val = ArquivosDigitais.First((PermissaoArquivoDigital x) => x.Tela == desabilitar.Tela); + if (val.Incluir || val.Excluir) + { + val.Incluir = false; + val.Excluir = false; + ArquivosDigitais = new ObservableCollection(ArquivosDigitais); + } + } + + public void DesabilitarConsulta(PermissaoUsuario desabilitar, string source) + { + if (!(source == "Ferramentas")) + { + PermissaoUsuario val = Seguros.First((PermissaoUsuario x) => x.Tela == desabilitar.Tela); + if (val.Incluir || val.Alterar || val.Excluir) + { + val.Alterar = false; + val.Incluir = false; + val.Excluir = false; + Seguros = new ObservableCollection(Seguros); + } + } + else + { + PermissaoUsuario val2 = Ferramentas.First((PermissaoUsuario x) => x.Tela == desabilitar.Tela); + if (val2.Incluir || val2.Alterar || val2.Excluir) + { + val2.Alterar = false; + val2.Incluir = false; + val2.Excluir = false; + Ferramentas = new ObservableCollection(Ferramentas); + } + } + } + + public void HabilitarArquivoDigital(PermissaoArquivoDigital habilitar) + { + PermissaoArquivoDigital val = ArquivosDigitais.First((PermissaoArquivoDigital x) => x.Tela == habilitar.Tela); + if (!val.Consultar) + { + val.Consultar = true; + ArquivosDigitais = new ObservableCollection(ArquivosDigitais); + } + } + + public void HabilitarConsulta(PermissaoUsuario habilitar, string source) + { + if (!(source == "Ferramentas")) + { + PermissaoUsuario val = Seguros.First((PermissaoUsuario x) => x.Tela == habilitar.Tela); + if (!val.Consultar) + { + val.Consultar = true; + Seguros = new ObservableCollection(Seguros); + } + } + else + { + PermissaoUsuario val2 = Ferramentas.First((PermissaoUsuario x) => x.Tela == habilitar.Tela); + if (!val2.Consultar) + { + val2.Consultar = true; + Ferramentas = new ObservableCollection(Ferramentas); + } + } + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs new file mode 100644 index 0000000..4231c90 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs @@ -0,0 +1,1064 @@ +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 System.Windows; +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.Seguros; +using Gestor.Model.Helper; + +namespace Gestor.Application.ViewModels.Drawer; + +public class TarefaDrawerViewModel : BaseTarefaViewModel +{ + private bool _enableMenu = true; + + private GridLength _dados = new GridLength(0.0, (GridUnitType)1); + + private GridLength _grid = new GridLength(1.0, (GridUnitType)2); + + private GridLength _anotacoesLength = new GridLength(0.0, (GridUnitType)1); + + private GridLength _descricaoLength = new GridLength(1.0, (GridUnitType)2); + + private GridLength _anotacoesInternasLength = new GridLength(0.0, (GridUnitType)1); + + private GridLength _descricaoInternaLength = new GridLength(1.0, (GridUnitType)2); + + private bool _enableAlterarTarefa = true; + + private Visibility _visibilityMenu; + + private bool _isVisibleDescricao; + + private bool _isSelected; + + private bool _concluido; + + private bool _carregando; + + private string _tituloTarefas; + + private string _titulo; + + private string _subTitulo; + + private Tarefa _tarefa = new Tarefa(); + + private ObservableCollection _tarefasFiltradas = new ObservableCollection(); + + private List _tarefas = new List(); + + private bool _isAnotacoes = true; + + private Tarefa _selectedTarefa; + + private ObservableCollection _usuarios; + + private ObservableCollection _tiposTarefa; + + private List _telefones; + + private DateTime _dataAgendamento = Funcoes.GetNetworkTime(); + + private DateTime _horaAgendamento = Funcoes.GetNetworkTime(); + + private Usuario _selectedUsuario; + + private TipoDeTarefa _selectedTipoTarefa; + + private ArquivoDigital _selectedAnexado = new ArquivoDigital(); + + private ObservableCollection _arquivosAnexados = new ObservableCollection(); + + private List _arquivosFinais = new List(); + + private bool _inclusaoArquivoDigitalEnable = true; + + private new TarefaServico Servico { get; } + + public GridLength Dados + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _dados; + } + 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) + _dados = value; + OnPropertyChanged("Dados"); + } + } + + public GridLength Grid + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _grid; + } + 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) + _grid = value; + OnPropertyChanged("Grid"); + } + } + + public GridLength AnotacoesLength + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _anotacoesLength; + } + 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) + _anotacoesLength = value; + OnPropertyChanged("AnotacoesLength"); + } + } + + public GridLength DescricaoLength + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _descricaoLength; + } + 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) + _descricaoLength = value; + OnPropertyChanged("DescricaoLength"); + } + } + + public GridLength AnotacoesInternasLength + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _anotacoesInternasLength; + } + 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) + _anotacoesInternasLength = value; + OnPropertyChanged("AnotacoesInternasLength"); + } + } + + public GridLength DescricaoInternaLength + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _descricaoInternaLength; + } + 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) + _descricaoInternaLength = value; + OnPropertyChanged("DescricaoInternaLength"); + } + } + + public override bool EnableAlterarTarefa + { + get + { + return _enableAlterarTarefa; + } + set + { + _enableAlterarTarefa = _alterarPermissEnabled && value; + OnPropertyChanged("EnableAlterarTarefa"); + } + } + + public long IdCliente { get; set; } + + private int Index { get; set; } = 1; + + + public Visibility VisibilityMenu + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _visibilityMenu; + } + 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) + _visibilityMenu = value; + OnPropertyChanged("VisibilityMenu"); + } + } + + public bool IsVisibleDescricao + { + get + { + return _isVisibleDescricao; + } + set + { + _isVisibleDescricao = value; + OnPropertyChanged("IsVisibleDescricao"); + } + } + + public bool IsSelected + { + get + { + return _isSelected; + } + set + { + _isSelected = value; + OnPropertyChanged("IsSelected"); + } + } + + public bool Concluido + { + get + { + return _concluido; + } + set + { + _concluido = value; + OnPropertyChanged("Concluido"); + } + } + + public bool Carregando + { + get + { + return _carregando; + } + set + { + _carregando = value; + base.IsEnabled = !value; + OnPropertyChanged("Carregando"); + } + } + + public string TituloTarefas + { + get + { + return _tituloTarefas; + } + set + { + _tituloTarefas = value; + OnPropertyChanged("TituloTarefas"); + } + } + + public string Titulo + { + get + { + return _titulo; + } + set + { + _titulo = value; + OnPropertyChanged("Titulo"); + } + } + + public string SubTitulo + { + get + { + return _subTitulo; + } + set + { + _subTitulo = value; + OnPropertyChanged("SubTitulo"); + } + } + + public Tarefa Tarefa + { + get + { + return _tarefa; + } + set + { + _tarefa = value; + OnPropertyChanged("Tarefa"); + } + } + + public ObservableCollection TarefasFiltradas + { + get + { + return _tarefasFiltradas; + } + set + { + _tarefasFiltradas = value; + OnPropertyChanged("TarefasFiltradas"); + } + } + + public List Tarefas + { + get + { + return _tarefas; + } + set + { + _tarefas = value; + OnPropertyChanged("Tarefas"); + } + } + + public bool IsAnotacoes + { + get + { + return _isAnotacoes; + } + set + { + _isAnotacoes = value; + OnPropertyChanged("IsAnotacoes"); + } + } + + public override Tarefa SelectedTarefa + { + get + { + return _selectedTarefa; + } + set + { + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Invalid comparison between Unknown and I4 + //IL_0147: Unknown result type (might be due to invalid IL or missing references) + //IL_015c: Unknown result type (might be due to invalid IL or missing references) + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_00eb: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_0102: Expected O, but got Unknown + //IL_01cc: Unknown result type (might be due to invalid IL or missing references) + //IL_01bb: Unknown result type (might be due to invalid IL or missing references) + DateTime networkTime = Funcoes.GetNetworkTime(); + IsSelected = value != null; + _selectedTarefa = value; + Tarefa obj = value; + DataAgendamento = ((obj != null) ? obj.Agendamento : networkTime); + Tarefa obj2 = value; + HoraAgendamento = ((obj2 != null) ? obj2.Agendamento : networkTime); + IsVisibleDescricao = value != null; + Tarefa obj3 = value; + Concluido = obj3 != null && (int)obj3.Status == 2; + base.Responsaveis = ((value == null) ? new ObservableCollection() : ((value.Responsaveis == null) ? new ObservableCollection() : new ObservableCollection(value.Responsaveis))); + if (!base.Responsaveis.Any()) + { + Tarefa obj4 = value; + base.Responsaveis = ((((obj4 != null) ? obj4.Usuario : null) == null) ? new ObservableCollection() : new ObservableCollection((IEnumerable)(object)new ResponsavelTarefa[1] + { + new ResponsavelTarefa + { + Usuario = value.Usuario + } + })); + } + if (value != null && ((DomainBase)value).Id > 0) + { + AlterarTamanho(alterar: false); + } + if (value != null) + { + AnotacoesLength = new GridLength(0.0, (GridUnitType)1); + AnotacoesInternasLength = new GridLength(0.0, (GridUnitType)1); + DescricaoLength = (string.IsNullOrWhiteSpace(value.Descricao) ? new GridLength(0.0, (GridUnitType)1) : new GridLength(1.0, (GridUnitType)2)); + DescricaoInternaLength = (string.IsNullOrWhiteSpace(value.DescricaoInterna) ? new GridLength(0.0, (GridUnitType)1) : new GridLength(1.0, (GridUnitType)2)); + } + Tarefa obj5 = value; + if (((obj5 != null) ? obj5.TipoDeTarefa : null) != null) + { + if (TiposTarefa.All((TipoDeTarefa x) => ((DomainBase)x).Id != ((DomainBase)value).Id) && !value.TipoDeTarefa.Ativo) + { + TiposTarefa.Add(value.TipoDeTarefa); + } + else + { + TiposTarefa = new ObservableCollection(TiposTarefa.Where((TipoDeTarefa x) => x.Ativo).ToList()); + } + } + Tarefa obj6 = value; + SelectedTipoTarefa = ((obj6 != null) ? obj6.TipoDeTarefa : null); + if (base.EnableIncluir || base.EnableFields || base.EnableButtons) + { + Tarefa obj7 = value; + VerificarEnables((obj7 != null) ? new long?(((DomainBase)obj7).Id) : null); + } + ValidaPermissaoParaEditarTarefa(); + OnPropertyChanged("SelectedTarefa"); + } + } + + public ObservableCollection Usuarios + { + get + { + return _usuarios; + } + set + { + _usuarios = value; + OnPropertyChanged("Usuarios"); + } + } + + public ObservableCollection TiposTarefa + { + get + { + return _tiposTarefa; + } + set + { + _tiposTarefa = value; + OnPropertyChanged("TiposTarefa"); + } + } + + public List Telefones + { + get + { + return _telefones; + } + set + { + _telefones = value; + OnPropertyChanged("Telefones"); + } + } + + public DateTime DataAgendamento + { + get + { + return _dataAgendamento; + } + set + { + _dataAgendamento = value; + if (SelectedTarefa != null) + { + SelectedTarefa.Agendamento = DateTime.Parse($"{value:d} {SelectedTarefa.Agendamento:T}"); + } + OnPropertyChanged("DataAgendamento"); + } + } + + public DateTime HoraAgendamento + { + get + { + return _horaAgendamento; + } + set + { + _horaAgendamento = value; + if (SelectedTarefa != null) + { + SelectedTarefa.Agendamento = DateTime.Parse($"{SelectedTarefa.Agendamento:d} {value:T}"); + } + OnPropertyChanged("HoraAgendamento"); + } + } + + public Usuario SelectedUsuario + { + get + { + return _selectedUsuario; + } + set + { + _selectedUsuario = value; + OnPropertyChanged("SelectedUsuario"); + } + } + + public TipoDeTarefa SelectedTipoTarefa + { + get + { + return _selectedTipoTarefa; + } + set + { + _selectedTipoTarefa = value; + OnPropertyChanged("SelectedTipoTarefa"); + } + } + + public ArquivoDigital SelectedAnexado + { + get + { + return _selectedAnexado; + } + set + { + _selectedAnexado = value; + OnPropertyChanged("SelectedAnexado"); + } + } + + public ObservableCollection ArquivosAnexados + { + get + { + return _arquivosAnexados; + } + set + { + _arquivosAnexados = value; + OnPropertyChanged("ArquivosAnexados"); + } + } + + public List ArquivosFinais + { + get + { + return _arquivosFinais; + } + set + { + _arquivosFinais = value; + OnPropertyChanged("ArquivosFinais"); + } + } + + public bool InclusaoArquivoDigitalEnable + { + get + { + return _inclusaoArquivoDigitalEnable; + } + set + { + _inclusaoArquivoDigitalEnable = value; + OnPropertyChanged("InclusaoArquivoDigitalEnable"); + } + } + + public TarefaDrawerViewModel(Tarefa tarefa, bool enableMenu) + { + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0027: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + //IL_003c: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: 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_009e: Expected O, but got Unknown + //IL_00d2: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Expected O, but got Unknown + Servico = new TarefaServico(); + Tarefa = tarefa; + _enableMenu = enableMenu; + CarregarUsuarios(); + TiposTarefa = new ObservableCollection(Recursos.TiposTarefa.Where((TipoDeTarefa x) => x.Ativo).ToList()); + SelecionarTarefas(tarefa, tarefa.Conclusao.HasValue); + TituloTarefas = (tarefa.Conclusao.HasValue ? "TAREFAS CONCLUÍDAS" : "TAREFAS PENDENTES"); + base.EnableMenu = true; + } + + private void CarregarUsuarios() + { + Usuarios = new ObservableCollection((from x in Recursos.Usuarios + where (Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 36) || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && !x.Excluido && x.PermissaoAggilizador != 4 + orderby x.Nome + select x).ToList()); + } + + public async void SelecionarTarefas(Tarefa tarefa, bool? concluido) + { + await PermissaoTela((TipoTela)38); + CarregarInformacoes(tarefa); + await CarregarTarefas(tarefa, concluido); + if (((DomainBase)tarefa).Id != 0L && !_enableMenu) + { + VisibilityMenu = (Visibility)2; + } + } + + public async void CarregarInformacoes(Tarefa tarefa) + { + ClienteServico clienteServico = new ClienteServico(); + SubTitulo = ((tarefa.IdEntidade != 0L) ? "TODAS AS TAREFAS PENDENTES DO CLIENTE" : ""); + IdCliente = tarefa.IdCliente; + Titulo = tarefa.Cliente; + Telefones = (await clienteServico.BuscarTelefonesAsync(tarefa.IdCliente)).Where((ClienteTelefone x) => ValidationHelper.ValidacaoTelefone(((TelefoneBase)x).Numero)).Select((Func)((ClienteTelefone x) => new TelefoneBase + { + Tipo = ((TelefoneBase)x).Tipo, + Id = ((DomainBase)x).Id, + Numero = ((TelefoneBase)x).Numero, + Prefixo = ((TelefoneBase)x).Prefixo + })).ToList(); + if (tarefa.IdEntidade == 0L) + { + return; + } + TipoTarefa entidade = tarefa.Entidade; + if ((int)entidade != 0) + { + if ((int)entidade != 4) + { + return; + } + Sinistro val = await new SinistroServico().BuscarSinistro(tarefa.IdEntidade); + if (val != null) + { + IdCliente = ((DomainBase)val.ControleSinistro.Item.Documento.Controle.Cliente).Id; + Titulo = val.ControleSinistro.Item.Documento.Controle.Cliente.Nome; + SubTitulo = "SINISTRO " + val.Numero + " ITEM " + val.ItemSinistrado; + Telefones = (await clienteServico.BuscarTelefonesAsync(IdCliente)).Where((ClienteTelefone x) => ValidationHelper.ValidacaoTelefone(((TelefoneBase)x).Numero)).Select((Func)((ClienteTelefone x) => new TelefoneBase + { + Tipo = ((TelefoneBase)x).Tipo, + Id = ((DomainBase)x).Id, + Numero = ((TelefoneBase)x).Numero, + Prefixo = ((TelefoneBase)x).Prefixo + })).ToList(); + } + } + else + { + Documento val2 = await new ApoliceServico().BuscarApoliceAsync(tarefa.IdEntidade); + IdCliente = ((DomainBase)val2.Controle.Cliente).Id; + Titulo = val2.Controle.Cliente.Nome; + SubTitulo = ((val2.Tipo == 0 && !string.IsNullOrWhiteSpace(val2.Apolice)) ? ("APÓLICE NÚMERO " + val2.Apolice) : ((val2.Tipo > 0) ? ("APÓLICE NÚMERO " + val2.Apolice + " ENDOSSO " + val2.Endosso) : ("PROPOSTA NÚMERO " + val2.Proposta))); + Telefones = (await clienteServico.BuscarTelefonesAsync(((DomainBase)val2.Controle.Cliente).Id)).Where((ClienteTelefone x) => ValidationHelper.ValidacaoTelefone(((TelefoneBase)x).Numero)).Select((Func)((ClienteTelefone x) => new TelefoneBase + { + Tipo = ((TelefoneBase)x).Tipo, + Id = ((DomainBase)x).Id, + Numero = ((TelefoneBase)x).Numero, + Prefixo = ((TelefoneBase)x).Prefixo + })).ToList(); + } + } + + public async Task CarregarTarefas(int index) + { + if (Tarefa.IdEntidade != 0L) + { + Carregando = true; + Tarefa tarefa = new Tarefa + { + Cliente = Tarefa.Cliente, + IdCliente = Tarefa.IdCliente, + Entidade = Tarefa.Entidade, + IdEntidade = Tarefa.IdEntidade + }; + Index = index; + List source; + switch (index) + { + default: + CarregarInformacoes(tarefa); + source = await Servico.BuscarTarefas(Tarefa.Entidade, Tarefa.IdEntidade, true); + break; + case 1: + CarregarInformacoes(tarefa); + source = await Servico.BuscarTarefas(Tarefa.Entidade, Tarefa.IdEntidade, false); + break; + case 2: + tarefa.Entidade = (TipoTarefa)2; + CarregarInformacoes(tarefa); + source = await Servico.BuscarTarefasCliente(Tarefa.IdCliente); + break; + } + Tarefas = source.OrderByDescending((Tarefa x) => x.Agendamento).ToList(); + TarefasFiltradas = new ObservableCollection(Tarefas); + SelectedTarefa = (Tarefa)((TarefasFiltradas == null || TarefasFiltradas.Count == 0) ? null : ((((DomainBase)tarefa).Id != 0L) ? ((object)((IEnumerable)TarefasFiltradas).FirstOrDefault((Func)((Tarefa x) => ((DomainBase)x).Id == ((DomainBase)tarefa).Id))) : ((object)TarefasFiltradas.First()))); + Carregando = false; + } + } + + public async Task CarregarTarefas(Tarefa tarefa, bool? concluido) + { + Carregando = true; + if (tarefa.IdEntidade != 0L) + { + Tarefas = (await Servico.BuscarTarefas(tarefa.Entidade, tarefa.IdEntidade, concluido)).OrderBy((Tarefa x) => x.Agendamento).ToList(); + TarefasFiltradas = new ObservableCollection(Tarefas); + SelectedTarefa = (Tarefa)((TarefasFiltradas == null || TarefasFiltradas.Count == 0) ? null : ((((DomainBase)tarefa).Id != 0L) ? ((object)((IEnumerable)TarefasFiltradas).FirstOrDefault((Func)((Tarefa x) => ((DomainBase)x).Id == ((DomainBase)tarefa).Id))) : ((object)TarefasFiltradas.First()))); + } + else if (((DomainBase)tarefa).Id > 0) + { + SelectedTarefa = await Servico.BuscarTarefa(((DomainBase)tarefa).Id); + } + Carregando = false; + } + + public async Task Incluir() + { + CarregarUsuarios(); + base.Responsaveis = new ObservableCollection(); + SelectedTarefa = new Tarefa + { + IdCliente = IdCliente, + Cliente = Titulo, + Referencia = SubTitulo, + Entidade = Tarefa.Entidade, + IdEntidade = Tarefa.IdEntidade, + Trilha = Tarefa.Trilha, + Status = (StatusTarefa)0, + Agendamento = Funcoes.GetNetworkTime().AddHours(1.0), + UsuarioCadastro = Recursos.Usuario, + Usuario = ((IEnumerable)Usuarios).FirstOrDefault((Func)((Usuario x) => ((DomainBase)x).Id == ((DomainBase)Recursos.Usuario).Id)), + Restrito = false, + Responsaveis = base.Responsaveis.ToList() + }; + ArquivosFinais = new List(); + AlterarTamanho(alterar: true); + TituloTarefas += " (INCLUINDO)"; + Alterar(alterar: true); + AnotacoesLength = new GridLength(1.0, (GridUnitType)2); + AnotacoesInternasLength = new GridLength(1.0, (GridUnitType)2); + DescricaoLength = new GridLength(0.0, (GridUnitType)1); + DescricaoInternaLength = new GridLength(0.0, (GridUnitType)1); + EnableAlterarTarefa = false; + } + + public void AlterarTamanho(bool alterar) + { + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a6: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + if (!alterar) + { + if (TituloTarefas.Contains("TODAS")) + { + TituloTarefas = "TODAS TAREFAS DO CLIENTE"; + } + else if (TituloTarefas.Contains("PENDENTES")) + { + TituloTarefas = "TAREFAS PENDENTES"; + } + else if (TituloTarefas.Contains("CONCLUÍDAS")) + { + TituloTarefas = "TAREFAS CONCLUÍDAS"; + } + } + Grid = (alterar ? new GridLength(0.0, (GridUnitType)2) : new GridLength(1.0, (GridUnitType)2)); + Dados = (alterar ? new GridLength(1.0, (GridUnitType)2) : new GridLength(360.0, (GridUnitType)1)); + } + + public async Task>> Salvar(string anotacoes, string anotacoesInternas) + { + DateTime networkTime = Funcoes.GetNetworkTime(); + if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 45) && (int)SelectedTarefa.Status != 2 && SelectedTarefa.Agendamento < networkTime) + { + SelectedTarefa.Agendamento = networkTime; + } + if ((int)SelectedTarefa.Status == 2) + { + SelectedTarefa.Conclusao = networkTime; + } + if ((int)SelectedTarefa.Status == 0) + { + SelectedTarefa.Conclusao = null; + } + SelectedTarefa.Responsaveis = base.Responsaveis.ToList(); + Tarefa selectedTarefa = SelectedTarefa; + ResponsavelTarefa? obj = base.Responsaveis.FirstOrDefault(); + selectedTarefa.Usuario = ((obj != null) ? obj.Usuario : null); + SelectedTarefa.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45); + List> list = SelectedTarefa.Validate(); + if (SelectedTarefa.Descricao == null && string.IsNullOrWhiteSpace(anotacoes) && string.IsNullOrWhiteSpace(anotacoesInternas)) + { + list.Add(new KeyValuePair("ANOTAÇÕES", "OBRIGATÓRIO")); + } + if (list.Count > 0) + { + return list; + } + if (!string.IsNullOrWhiteSpace(anotacoes)) + { + SelectedTarefa.Anotacoes = Funcoes.AdicionarLog(SelectedTarefa.Anotacoes); + SelectedTarefa.Descricao = SelectedTarefa.Anotacoes + "

" + SelectedTarefa.Descricao + "

"; + } + if (!string.IsNullOrWhiteSpace(anotacoesInternas)) + { + SelectedTarefa.AnotacoesInternas = Funcoes.AdicionarLog(SelectedTarefa.AnotacoesInternas); + SelectedTarefa.DescricaoInterna = SelectedTarefa.AnotacoesInternas + "

" + SelectedTarefa.DescricaoInterna + "

"; + } + SelectedTarefa.TipoDeTarefa = SelectedTipoTarefa; + bool inclusao = ((DomainBase)SelectedTarefa).Id == 0; + SelectedTarefa = await Servico.Salvar(SelectedTarefa); + string text = (inclusao ? "INCLUIU" : "ALTEROU"); + RegistrarAcao(text + " TAREFA", ((DomainBase)SelectedTarefa).Id, (TipoTela)38, $"TAREFA \"{SelectedTarefa.Titulo}\", ID: {((DomainBase)SelectedTarefa).Id}"); + if (inclusao) + { + foreach (ArquivoDigital arquivosFinai in ArquivosFinais) + { + arquivosFinai.IdTarefa = ((DomainBase)SelectedTarefa).Id; + } + await ArquivoDigitalServico.Insert(ArquivosFinais); + } + if (!Servico.Sucesso) + { + return null; + } + long id = ((DomainBase)SelectedTarefa).Id; + await CarregarTarefas(Index); + SelectedTarefa = ((IEnumerable)TarefasFiltradas).FirstOrDefault((Func)((Tarefa x) => ((DomainBase)x).Id == id)); + return null; + } + + public void AlterarTarefa() + { + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_0098: Unknown result type (might be due to invalid IL or missing references) + //IL_00e8: Unknown result type (might be due to invalid IL or missing references) + //IL_00d7: Unknown result type (might be due to invalid IL or missing references) + CarregarUsuarios(); + if (SelectedTarefa != null) + { + EnableAlterarTarefa = false; + AlterarTamanho(alterar: true); + TituloTarefas = TituloTarefas + " (ALTERANDO \"" + SelectedTarefa.Titulo + "\")"; + Alterar(alterar: true); + AnotacoesLength = new GridLength(1.0, (GridUnitType)2); + AnotacoesInternasLength = new GridLength(1.0, (GridUnitType)2); + Tarefa selectedTarefa = SelectedTarefa; + DescricaoLength = (string.IsNullOrWhiteSpace((selectedTarefa != null) ? selectedTarefa.Descricao : null) ? new GridLength(0.0, (GridUnitType)1) : new GridLength(1.0, (GridUnitType)2)); + Tarefa selectedTarefa2 = SelectedTarefa; + DescricaoInternaLength = (string.IsNullOrWhiteSpace((selectedTarefa2 != null) ? selectedTarefa2.DescricaoInterna : null) ? new GridLength(0.0, (GridUnitType)1) : new GridLength(1.0, (GridUnitType)2)); + TarefasFiltradas = new ObservableCollection { SelectedTarefa }; + ListaUsuariosResponsaveis(); + base.Responsaveis.ToList().ForEach(delegate(ResponsavelTarefa x) + { + Usuarios.Remove(x.Usuario); + }); + } + } + + public async Task Cancelar() + { + CarregarUsuarios(); + AlterarTamanho(alterar: false); + Tarefa selectedTarefa = SelectedTarefa; + long id = ((selectedTarefa != null) ? ((DomainBase)selectedTarefa).Id : 0); + await CarregarTarefas(Index); + Alterar(alterar: false); + await ValidaPermissaoParaEditarTarefa(); + if (id != 0L) + { + SelectedTarefa = ((IEnumerable)TarefasFiltradas).FirstOrDefault((Func)((Tarefa x) => ((DomainBase)x).Id == id)); + } + } + + public async Task Excluir(Tarefa item) + { + if ((int)VisibilityMenu == 2) + { + await ShowMessage("NÃO É POSSÍVEL EXCLUIR TAREFA PELO RELATÓRIO!"); + return false; + } + if (!(await ShowMessage("DESEJA REALMENTE EXCLUIR A TAREFA " + item.Titulo + "?" + Environment.NewLine + "ESSE PROCEDIMENTO É IRREVERSÍVEL", "SIM", "NÃO"))) + { + return false; + } + string titulo = item.Titulo; + long id = ((DomainBase)item).Id; + if (!(await Servico.Excluir(((DomainBase)item).Id))) + { + Alterar(alterar: false); + return true; + } + RegistrarAcao("EXCLUIU TAREFA", ((DomainBase)item).Id, (TipoTela)38, $"TAREFA \"{titulo}\", ID: {id}"); + await CarregarTarefas(Index); + Alterar(alterar: false); + return true; + } + + public void AdcionarResponsavel() + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Unknown result type (might be due to invalid IL or missing references) + //IL_0036: Expected O, but got Unknown + if (SelectedUsuario != null) + { + base.Responsaveis.Add(new ResponsavelTarefa + { + Usuario = SelectedUsuario, + IdTarefa = ((DomainBase)SelectedTarefa).Id + }); + Usuarios.Remove(SelectedUsuario); + SelectedUsuario = null; + } + } + + public async void Editar(IndiceArquivoDigital arquivo) + { + if (arquivo != null && arquivo.IdArquivoDigital != 0L) + { + await ArquivoDigitalServico.Save(arquivo); + } + } + + public void Delete(ArquivoDigital arquivo) + { + if (SelectedAnexado != null) + { + ArquivoDigital item = ArquivosAnexados.First((ArquivoDigital x) => x.Descricao == arquivo.Descricao); + ArquivosAnexados.Remove(item); + ArquivosAnexados = new ObservableCollection(ArquivosAnexados); + } + } + + public async void Anexar() + { + InclusaoArquivoDigitalEnable = false; + List arquivos = await AddAttachments(ArquivosAnexados.ToList(), new List()); + await Task.Run(async delegate + { + await Task.Delay(200); + InclusaoArquivoDigitalEnable = true; + }); + if (arquivos != null) + { + arquivos.AddRange(ArquivosAnexados); + ArquivosAnexados = new ObservableCollection(arquivos); + } + } + + public void SalvarAnexos() + { + ArquivosFinais = ArquivosAnexados.ToList(); + } + + public void LimparAnexos() + { + ArquivosAnexados = new ObservableCollection(); + } + + public void Print() + { + string value = GerarHtml(); + string tempPath = Path.GetTempPath(); + string text = $"{tempPath}{(object)(TipoTela)38}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html"; + StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8); + streamWriter.Write(value); + streamWriter.Close(); + Process.Start(text); + RegistrarAcao("IMPRIMIU A TAREFA", ((DomainBase)SelectedTarefa).Id, (TipoTela)38, $"TAREFA \"{SelectedTarefa.Titulo}\", ID: {((DomainBase)SelectedTarefa).Id}"); + } + + public string GerarHtml() + { + //IL_0205: Unknown result type (might be due to invalid IL or missing references) + string text = " TAREFA
"; + text += "
"; + text += "

"; + text += "TAREFA


"; + text += ""; + int num = 0; + text = text + ""; + text = text + ""; + text = text + ""; + text = text + ""; + text = text + ""; + text = text + ""; + string[] obj = new string[6] + { + text, + ""; + text = string.Concat(obj); + text += "

CLIENTE: " + SelectedTarefa.Cliente + "

REFERÊNCIA: " + SelectedTarefa.Referencia + "

TÍTULO: " + SelectedTarefa.Titulo + "

AGENDAMENTO: " + SelectedTarefa.Agendamento.ToString() + "

RESPONSÁVEL PRINCIPAL: " + SelectedTarefa.Usuario.Nome + "

STATUS: " + ValidationHelper.GetDescription((Enum)(object)SelectedTarefa.Status) + "

TIPO DE TAREFA: ", + null, + null + }; + TipoDeTarefa selectedTipoTarefa = SelectedTipoTarefa; + obj[4] = ((selectedTipoTarefa != null) ? selectedTipoTarefa.Nome : null); + obj[5] = "

"; + if (base.Responsaveis != null && base.Responsaveis.Count > 0) + { + text += "

RESPONSÁVEIS VINCULADOS

"; + text += "
"; + text += ""; + List list = new List(); + foreach (ResponsavelTarefa responsavei in base.Responsaveis) + { + list.Add(responsavei.Usuario.Nome.Trim().ToUpper()); + } + text = text + ""; + text += "

" + string.Join(", ", list) + "

"; + text += "

"; + } + text += "

"; + if (SelectedTarefa.Descricao != null) + { + text += "

ANOTAÇÕES

"; + text += "
"; + text += ""; + text = text + ""; + text += "

" + SelectedTarefa.Descricao.Replace("", "").Replace("", "") + "

"; + text += "

"; + } + return text + "
"; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresApoliceViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresApoliceViewModel.cs new file mode 100644 index 0000000..e27a291 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresApoliceViewModel.cs @@ -0,0 +1,306 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ValoresApoliceViewModel : BaseSegurosViewModel +{ + private Visibility _isVisibleEspecial; + + private Visibility _isVisibleVendedores; + + private decimal _prevista; + + private decimal _recebida; + + private decimal _recebidaEspecial; + + private decimal _pendente; + + private decimal _repasse; + + private decimal _repasseEspecial; + + private decimal _paga; + + private decimal _pagaEspecial; + + private string _apoliceLabel = "DESCRIÇÃO DE VALORES"; + + private string _apoliceDescricao = "VALORES BASEADOS NO DOCUMENTO SELECIONADO ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS."; + + private Documento _selectedDocumento; + + private ObservableCollection _pagamentos; + + public Visibility IsVisibleEspecial + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _isVisibleEspecial; + } + 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) + _isVisibleEspecial = value; + OnPropertyChanged("IsVisibleEspecial"); + } + } + + public Visibility IsVisibleVendedores + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _isVisibleVendedores; + } + 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) + _isVisibleVendedores = value; + OnPropertyChanged("IsVisibleVendedores"); + } + } + + public decimal Prevista + { + get + { + return _prevista; + } + set + { + _prevista = value; + OnPropertyChanged("Prevista"); + } + } + + public decimal Recebida + { + get + { + return _recebida; + } + set + { + _recebida = value; + OnPropertyChanged("Recebida"); + } + } + + public decimal RecebidaEspecial + { + get + { + return _recebidaEspecial; + } + set + { + _recebidaEspecial = value; + OnPropertyChanged("RecebidaEspecial"); + } + } + + public decimal Pendente + { + get + { + return _pendente; + } + set + { + _pendente = value; + OnPropertyChanged("Pendente"); + } + } + + public decimal Repasse + { + get + { + return _repasse; + } + set + { + _repasse = value; + OnPropertyChanged("Repasse"); + } + } + + public decimal RepasseEspecial + { + get + { + return _repasseEspecial; + } + set + { + _repasseEspecial = value; + OnPropertyChanged("RepasseEspecial"); + } + } + + public decimal Paga + { + get + { + return _paga; + } + set + { + _paga = value; + OnPropertyChanged("Paga"); + } + } + + public decimal PagaEspecial + { + get + { + return _pagaEspecial; + } + set + { + _pagaEspecial = value; + OnPropertyChanged("PagaEspecial"); + } + } + + public string ApoliceLabel + { + get + { + return _apoliceLabel; + } + set + { + _apoliceLabel = value; + OnPropertyChanged("ApoliceLabel"); + } + } + + public string ApoliceDescricao + { + get + { + return _apoliceDescricao; + } + set + { + _apoliceDescricao = value; + OnPropertyChanged("ApoliceDescricao"); + } + } + + public Documento SelectedDocumento + { + get + { + return _selectedDocumento; + } + set + { + _selectedDocumento = value; + OnPropertyChanged("SelectedDocumento"); + } + } + + public ObservableCollection Pagamentos + { + get + { + return _pagamentos; + } + set + { + _pagamentos = value; + OnPropertyChanged("Pagamentos"); + } + } + + public ValoresApoliceViewModel(Documento documento) + { + base.EnableMenu = true; + Seleciona(documento); + } + + public void Seleciona(Documento documento) + { + SelectedDocumento = documento; + if (SelectedDocumento.Tipo != 1) + { + ApoliceLabel = ((!SelectedDocumento.Emissao.HasValue) ? ("VALORES DA PROPOSTA " + SelectedDocumento.Proposta) : ("VALORES DA APÓLICE " + SelectedDocumento.Apolice)); + ApoliceDescricao = ((!SelectedDocumento.Emissao.HasValue) ? ("VALORES BASEADOS NA PROPOSTA " + SelectedDocumento.Proposta + " ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS.") : ("VALORES BASEADOS NA APÓLICE " + SelectedDocumento.Apolice + " ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS.")); + } + CalculaComissao(); + CalculaEspecial(); + CalculaRepasse(); + RegistrarAcao($"CONSULTOU MAIS INFORMAÇÕES DOS VALORES DO DOCUMENTO DE ID {((DomainBase)documento).Id}", ((DomainBase)documento).Id, (TipoTela)21); + } + + private void CalculaRepasse() + { + if (SelectedDocumento.Pagamentos.All((VendedorParcela x) => x.Vendedor.Corretora)) + { + IsVisibleVendedores = (Visibility)2; + return; + } + List list = (from x in SelectedDocumento.Pagamentos + where !x.Vendedor.Corretora + group x by ((DomainBase)x.Vendedor).Id).Select((Func, VendedorParcela>)((IGrouping x) => new VendedorParcela + { + Repasse = x.First().Repasse, + Documento = SelectedDocumento, + ValorTotal = x.First().ValorTotal, + Vendedor = x.First().Vendedor, + ValorTotalPago = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo == 1 && y.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse), + ValorRepasseB = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo != 1).Sum((VendedorParcela y) => y.ValorRepasse), + ValorRepasse = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo != 1 && y.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse), + PorcentagemRepasse = x.First().PorcentagemRepasse / (decimal?)100, + TipoVendedor = x.First().TipoVendedor + })).ToList(); + Pagamentos = new ObservableCollection(list); + } + + private void CalculaComissao() + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Invalid comparison between Unknown and I4 + if ((int)SelectedDocumento.TipoRecebimento.GetValueOrDefault() == 1) + { + decimal num = (SelectedDocumento.AdicionalComiss ? (SelectedDocumento.PremioLiquido + SelectedDocumento.PremioAdicional) : SelectedDocumento.PremioLiquido); + decimal num2 = SelectedDocumento.Comissao * 0.01m; + Prevista = num * num2; + } + else + { + Prevista = SelectedDocumento.Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).Sum((Parcela x) => x.ValorLiquidoFatura * ((x.Comissao < 1m) ? x.Comissao : ((x.Comissao > 100m) ? 1m : (x.Comissao * 0.01m)))); + } + Recebida = SelectedDocumento.Parcelas.Where((Parcela x) => (int)x.SubTipo == 1).Sum((Parcela x) => x.ValorComissao); + Pendente = Prevista - Recebida; + Repasse = SelectedDocumento.Pagamentos.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()); + Paga = SelectedDocumento.Pagamentos.Where((VendedorParcela x) => (int)x.Parcela.SubTipo == 1 && x.DataPrePagamento.HasValue).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()); + } + + private void CalculaEspecial() + { + if (SelectedDocumento.Parcelas.All((Parcela x) => (int)x.SubTipo == 1)) + { + IsVisibleEspecial = (Visibility)2; + return; + } + RecebidaEspecial = SelectedDocumento.Parcelas.Where((Parcela x) => (int)x.SubTipo != 1).Sum((Parcela x) => x.ValorComissao); + RepasseEspecial = SelectedDocumento.Pagamentos.Where((VendedorParcela x) => (int)x.Parcela.SubTipo != 1).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()); + PagaEspecial = SelectedDocumento.Pagamentos.Where((VendedorParcela x) => (int)x.Parcela.SubTipo != 1 && x.DataPrePagamento.HasValue).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()); + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs new file mode 100644 index 0000000..49cbccc --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/ValoresParcelaViewModel.cs @@ -0,0 +1,490 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Common; +using Gestor.Model.Domain.Aggilizador; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; + +namespace Gestor.Application.ViewModels.Drawer; + +public class ValoresParcelaViewModel : BaseSegurosViewModel +{ + private ParcelaPendente _pendecia; + + private Visibility _isVisiblePendencia = (Visibility)2; + + private Visibility _isVisibleFatura; + + private Visibility _isVisibleVendedores; + + private decimal _prevista; + + private decimal _ir; + + private decimal _iss; + + private string _repassePago; + + private decimal _recebidaLiquida; + + private decimal _recebida; + + private decimal _recebidaEspecial; + + private decimal _pendente; + + private decimal _repasse; + + private decimal _repasseEspecial; + + private decimal _paga; + + private decimal _pagaEspecial; + + private string _apoliceLabel = "DESCRIÇÃO DE VALORES"; + + private string _apoliceDescricao = "VALORES BASEADOS NO DOCUMENTO SELECIONADO ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS."; + + private Parcela _selectedParcela; + + private string _statusBaixa; + + private string _statusParc; + + private Visibility _isVisiblestatusparc = (Visibility)2; + + private ObservableCollection _pagamentos; + + public ParcelaPendente Pendecia + { + get + { + return _pendecia; + } + set + { + _pendecia = value; + IsVisiblePendencia = (Visibility)((value == null) ? 2 : 0); + OnPropertyChanged("Pendecia"); + } + } + + public Visibility IsVisiblePendencia + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _isVisiblePendencia; + } + 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) + _isVisiblePendencia = value; + OnPropertyChanged("IsVisiblePendencia"); + } + } + + public Visibility IsVisibleFatura + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _isVisibleFatura; + } + 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) + _isVisibleFatura = value; + OnPropertyChanged("IsVisibleFatura"); + } + } + + public Visibility IsVisibleVendedores + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _isVisibleVendedores; + } + 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) + _isVisibleVendedores = value; + OnPropertyChanged("IsVisibleVendedores"); + } + } + + public decimal Prevista + { + get + { + return _prevista; + } + set + { + _prevista = value; + OnPropertyChanged("Prevista"); + } + } + + public decimal Ir + { + get + { + return _ir; + } + set + { + _ir = value; + OnPropertyChanged("Ir"); + } + } + + public decimal Iss + { + get + { + return _iss; + } + set + { + _iss = value; + OnPropertyChanged("Iss"); + } + } + + public string RepassePago + { + get + { + return _repassePago; + } + set + { + _repassePago = value; + OnPropertyChanged("RepassePago"); + } + } + + public decimal RecebidaLiquida + { + get + { + return _recebidaLiquida; + } + set + { + _recebidaLiquida = value; + OnPropertyChanged("RecebidaLiquida"); + } + } + + public decimal Recebida + { + get + { + return _recebida; + } + set + { + _recebida = value; + OnPropertyChanged("Recebida"); + } + } + + public decimal RecebidaEspecial + { + get + { + return _recebidaEspecial; + } + set + { + _recebidaEspecial = value; + OnPropertyChanged("RecebidaEspecial"); + } + } + + public decimal Pendente + { + get + { + return _pendente; + } + set + { + if (value < 0.01m) + { + _pendente = default(decimal); + } + else + { + _pendente = value; + } + OnPropertyChanged("Pendente"); + } + } + + public decimal Repasse + { + get + { + return _repasse; + } + set + { + _repasse = value; + OnPropertyChanged("Repasse"); + } + } + + public decimal RepasseEspecial + { + get + { + return _repasseEspecial; + } + set + { + _repasseEspecial = value; + OnPropertyChanged("RepasseEspecial"); + } + } + + public decimal Paga + { + get + { + return _paga; + } + set + { + _paga = value; + OnPropertyChanged("Paga"); + } + } + + public decimal PagaEspecial + { + get + { + return _pagaEspecial; + } + set + { + _pagaEspecial = value; + OnPropertyChanged("PagaEspecial"); + } + } + + public string ApoliceLabel + { + get + { + return _apoliceLabel; + } + set + { + _apoliceLabel = value; + OnPropertyChanged("ApoliceLabel"); + } + } + + public string ApoliceDescricao + { + get + { + return _apoliceDescricao; + } + set + { + _apoliceDescricao = value; + OnPropertyChanged("ApoliceDescricao"); + } + } + + public Parcela SelectedParcela + { + get + { + return _selectedParcela; + } + set + { + _selectedParcela = value; + OnPropertyChanged("SelectedParcela"); + } + } + + public string StatusBaixa + { + get + { + return _statusBaixa; + } + set + { + _statusBaixa = value; + OnPropertyChanged("StatusBaixa"); + } + } + + public string StatusParc + { + get + { + return _statusParc; + } + set + { + _statusParc = value; + OnPropertyChanged("StatusParc"); + } + } + + public Visibility IsVisibleStatusParc + { + get + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + return _isVisiblestatusparc; + } + 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) + _isVisiblestatusparc = value; + OnPropertyChanged("IsVisibleStatusParc"); + } + } + + public ObservableCollection Pagamentos + { + get + { + return _pagamentos; + } + set + { + _pagamentos = value; + OnPropertyChanged("Pagamentos"); + } + } + + public ValoresParcelaViewModel(Parcela parcela, Documento documento) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + Seleciona(parcela, documento); + } + + public async void Seleciona(Parcela parcela, Documento documento) + { + SelectedParcela = parcela; + IsVisibleFatura = (Visibility)(((int)SelectedParcela.Documento.TipoRecebimento.GetValueOrDefault() != 2) ? 2 : 0); + ApoliceLabel = $"VALORES DA PARCELA {SelectedParcela.NumeroParcela} VENCIMENTO {parcela.Vencimento:d}"; + ApoliceDescricao = $"VALORES BASEADOS NA PARCELA {SelectedParcela.NumeroParcela} ATÉ O MOMENTO, OS VALORES PODEM SER DIFERENTES EM CASO DE ALTERAÇÕES POR OUTROS USUÁRIOS."; + StatusBaixa = "PENDENTE"; + RepassePago = "REPASSE A SER PAGO"; + if (SelectedParcela.DataRecebimento.HasValue) + { + StatusBaixa = (((int)SelectedParcela.Documento.TipoRecebimento.GetValueOrDefault() == 2) ? "BAIXA MANUAL" : ((SelectedParcela.ValorRealizado == 0m) ? "BAIXA ESGOTAMENTO" : "BAIXA MANUAL")); + DetalheExtrato val = await new ServicoExtrato().FindByParcelaId(((DomainBase)SelectedParcela).Id); + if (val != null) + { + StatusParcela? status = val.Status; + if (status.HasValue) + { + StatusParcela valueOrDefault = status.GetValueOrDefault(); + if ((int)valueOrDefault != 1) + { + if ((int)valueOrDefault == 5) + { + goto IL_021c; + } + switch (valueOrDefault - 10) + { + case 0: + case 3: + break; + case 2: + goto IL_021c; + default: + goto IL_0232; + } + } + IsVisibleStatusParc = (Visibility)0; + StatusParc = ValidationHelper.GetDescription((Enum)(object)val.Status); + RepassePago = "REPASSE PAGO"; + StatusBaixa = ((SelectedParcela.ValorRealizado == 0m) ? "BAIXA AUTOMATICA ESGOTAMENTO" : "BAIXA AUTOMATICA"); + } + } + } + goto IL_0232; + IL_021c: + RepassePago = "REPASSE PAGO"; + StatusBaixa = "BAIXA MANUAL"; + goto IL_0232; + IL_0232: + CalculaComissao(documento); + CalculaRepasse(); + if (SelectedParcela.IdParcelaPendente > 0 && SelectedParcela.StatusPagamento != (StatusPagamento?)0) + { + BuscarPendencia(); + } + } + + private async void BuscarPendencia() + { + Pendecia = await new BaseServico().BuscarParcelaPendente(SelectedParcela.IdParcelaPendente); + } + + private void CalculaRepasse() + { + if (SelectedParcela.Vendedores.All((VendedorParcela x) => x.Vendedor.Corretora)) + { + IsVisibleVendedores = (Visibility)2; + return; + } + List list = (from x in SelectedParcela.Vendedores + where !x.Vendedor.Corretora + group x by ((DomainBase)x.Vendedor).Id).Select((Func, VendedorParcela>)((IGrouping x) => new VendedorParcela + { + Repasse = x.First().Repasse, + Documento = SelectedParcela.Documento, + ValorTotal = x.First().ValorTotal, + Vendedor = x.First().Vendedor, + ValorTotalPago = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo == 1 && y.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse), + ValorRepasseB = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo != 1).Sum((VendedorParcela y) => y.ValorRepasse), + ValorRepasse = x.Where((VendedorParcela y) => (int)y.Parcela.SubTipo != 1 && y.DataPrePagamento.HasValue).Sum((VendedorParcela y) => y.ValorRepasse), + PorcentagemRepasse = x.First().PorcentagemRepasse / (decimal?)100, + TipoVendedor = x.First().TipoVendedor + })).ToList(); + Pagamentos = new ObservableCollection(list); + } + + private void CalculaComissao(Documento documento) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000c: Invalid comparison between Unknown and I4 + decimal num = (((int)SelectedParcela.SubTipo != 1) ? SelectedParcela.Valor : ((documento.NumeroParcelas == 0m) ? 0m : (documento.AdicionalComiss ? ((documento.PremioLiquido + documento.PremioAdicional) / documento.NumeroParcelas) : (documento.PremioLiquido / documento.NumeroParcelas)))); + Prevista = ((SelectedParcela.ValorLiquidoFatura != 0m) ? (SelectedParcela.ValorLiquidoFatura * SelectedParcela.Comissao * 0.01m) : (num * SelectedParcela.Comissao * 0.01m)); + Recebida = SelectedParcela.ValorComissao; + Pendente = Prevista - Recebida; + Repasse = SelectedParcela.Vendedores.Where((VendedorParcela x) => ((int)SelectedParcela.SubTipo != 1) ? ((int)x.Parcela.SubTipo != 1) : ((int)x.Parcela.SubTipo == 1)).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()); + Paga = SelectedParcela.Vendedores.Where((VendedorParcela x) => ((int)SelectedParcela.SubTipo != 1) ? ((int)x.Parcela.SubTipo != 1 && x.DataPrePagamento.HasValue) : ((int)x.Parcela.SubTipo == 1)).Sum((VendedorParcela x) => x.ValorRepasse.GetValueOrDefault()); + Ir = SelectedParcela.Irr; + Iss = SelectedParcela.Iss; + RecebidaLiquida = SelectedParcela.ValorComDesconto; + } +} diff --git a/Decompiler/Gestor.Application.ViewModels.Drawer/VinculoVendedorViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Drawer/VinculoVendedorViewModel.cs new file mode 100644 index 0000000..849ec7f --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Drawer/VinculoVendedorViewModel.cs @@ -0,0 +1,258 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.Servicos.Ferramentas; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; + +namespace Gestor.Application.ViewModels.Drawer; + +public class VinculoVendedorViewModel : BaseSegurosViewModel +{ + private readonly VendedorUsuarioServico _servicoVendedorUsuario; + + private readonly VendedorServico _servicoVendedor; + + public readonly Usuario SelectedUsuario; + + private bool _isVisibleVinculado; + + private bool _enableAlterarVinculo; + + private bool _isVisibleVendedor = true; + + private List _vinculado; + + private List _vinculadoFiltro; + + private List _vendedor; + + private List _vendedorFiltro; + + public bool IsVisibleVinculado + { + get + { + return _isVisibleVinculado; + } + set + { + _isVisibleVinculado = value; + OnPropertyChanged("IsVisibleVinculado"); + } + } + + public bool EnableAlterarVinculo + { + get + { + return _enableAlterarVinculo; + } + set + { + _enableAlterarVinculo = value; + OnPropertyChanged("EnableAlterarVinculo"); + } + } + + public bool IsVisibleVendedor + { + get + { + return _isVisibleVendedor; + } + set + { + _isVisibleVendedor = value; + OnPropertyChanged("IsVisibleVendedor"); + } + } + + public List Vinculado + { + get + { + return _vinculado; + } + set + { + _vinculado = value; + IsVisibleVinculado = value != null && value.Count > 0; + OnPropertyChanged("Vinculado"); + } + } + + public List VinculadoFiltro + { + get + { + return _vinculadoFiltro; + } + set + { + _vinculadoFiltro = value; + OnPropertyChanged("VinculadoFiltro"); + } + } + + public List Vendedor + { + get + { + return _vendedor; + } + set + { + _vendedor = value; + IsVisibleVendedor = value != null && value.Count > 0; + OnPropertyChanged("Vendedor"); + } + } + + public List VendedorFiltro + { + get + { + return _vendedorFiltro; + } + set + { + _vendedorFiltro = value; + OnPropertyChanged("VendedorFiltro"); + } + } + + public VinculoVendedorViewModel(Usuario usuario) + { + SelectedUsuario = usuario; + _servicoVendedorUsuario = new VendedorUsuarioServico(); + _servicoVendedor = new VendedorServico(); + Load(usuario); + EnableAlterarVinculo = ((DomainBase)Recursos.Usuario).Id > 0; + base.EnableMenu = true; + } + + private async void Load(Usuario usuario) + { + await AwaitLoad(usuario); + } + + private async Task AwaitLoad(Usuario usuario) + { + Vinculado = await GetVinculo(usuario); + Vendedor = await GetVendedor(usuario); + VinculadoFiltro = Vinculado; + VendedorFiltro = Vendedor; + } + + private async Task> GetVinculo(Usuario usuario) + { + List vinculado = new List(); + (await _servicoVendedorUsuario.FindByVinculo(usuario)).ForEach(delegate(VendedorUsuario x) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Expected O, but got Unknown + VinculoVendedor item = new VinculoVendedor + { + Id = ((DomainBase)x).Id, + Vendedor = x.Vendedor, + Vinculado = true + }; + vinculado.Add(item); + }); + return vinculado; + } + + private async Task> GetVendedor(Usuario usuario) + { + List list = (await _servicoVendedor.BuscarVendedoresAtivosAsync())?.Where((Vendedor x) => x.IdEmpresa == usuario.IdEmpresa).ToList(); + return (list == null || list.Count == 0) ? null : list.Where((Vendedor vendedor) => Vinculado.All((VinculoVendedor x) => ((DomainBase)x.Vendedor).Id != ((DomainBase)vendedor).Id)).Select((Func)((Vendedor vendedor) => new VinculoVendedor + { + Id = 0L, + Vendedor = vendedor, + Vinculado = false + })).ToList(); + } + + internal async Task BuscarVinculoVendedor(string value) + { + await Task.Run(delegate + { + FiltrarVinculoVendedor(value); + }); + } + + internal void FiltrarVinculoVendedor(string filter) + { + Vinculado = (string.IsNullOrEmpty(filter) ? VinculadoFiltro : new List(VinculadoFiltro.Where((VinculoVendedor x) => ValidationHelper.RemoveDiacritics(x.Vendedor.Nome.ToUpper().Trim()).Contains(filter.ToUpper())))); + Vendedor = (string.IsNullOrEmpty(filter) ? VendedorFiltro : new List(VendedorFiltro.Where((VinculoVendedor x) => ValidationHelper.RemoveDiacritics(x.Vendedor.Nome.ToUpper().Trim()).Contains(filter.ToUpper())))); + } + + public async Task Salvar() + { + List list = Vinculado.Where((VinculoVendedor x) => !x.Vinculado).Select((Func)((VinculoVendedor x) => new VendedorUsuario + { + Id = ((DomainBase)x).Id, + Vendedor = x.Vendedor, + Usuario = SelectedUsuario + })).ToList(); + if (list.Count > 0 && !(await _servicoVendedorUsuario.Delete(list))) + { + return; + } + List list2 = Vendedor.Where((VinculoVendedor x) => x.Vinculado).Select((Func)((VinculoVendedor x) => new VendedorUsuario + { + Id = ((DomainBase)x).Id, + Vendedor = x.Vendedor, + Usuario = SelectedUsuario + })).ToList(); + if (list2.Count > 0) + { + await _servicoVendedorUsuario.SaveOrUpdate(list2); + } + await AwaitLoad(SelectedUsuario); + UnitOfWork commited = Instancia.Commited; + try + { + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog keyValues = new RegistroLog + { + Acao = (TipoAcao)0, + Usuario = Recursos.Usuario, + DataHora = Funcoes.GetNetworkTime(), + Descricao = JsonConvert.SerializeObject((object)Vinculado.Select((VinculoVendedor x) => x.Vendedor).ToList(), new JsonSerializerSettings + { + ReferenceLoopHandling = (ReferenceLoopHandling)1 + }), + EntidadeId = ((DomainBase)SelectedUsuario).Id, + Tela = (TipoTela)45, + Versao = LoginViewModel.VersaoAtual, + NomeMaquina = Environment.MachineName, + UsuarioMaquina = Environment.UserName, + Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() + }; + _servicoVendedorUsuario.SaveLog(keyValues, commited); + ((GenericUnitOfWork)commited).Commit(); + } + finally + { + ((IDisposable)commited)?.Dispose(); + } + RegistrarAcao("ALTEROU VÍNCULOS DE VENDEDOR DO USUÁRIO \"" + SelectedUsuario.Nome + "\"", ((DomainBase)SelectedUsuario).Id, (TipoTela)45, $"ID: {((DomainBase)SelectedUsuario).Id}\n\nACESSE O LOG DE ALTERAÇÕES NA TELA DE VÍNCULO DE VENDEDOR PARA VER EXATAMENTE O QUE FOI ALTERADO."); + } +} -- cgit v1.2.3