diff options
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/ArquivoDigitalViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels.Drawer/ArquivoDigitalViewModel.cs | 1229 |
1 files changed, 1229 insertions, 0 deletions
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<ClienteTelefone> _telefones = new ObservableCollection<ClienteTelefone>(); + + private ObservableCollection<IndiceArquivoDigital> _arquivos = new ObservableCollection<IndiceArquivoDigital>(); + + private ObservableCollection<IndiceArquivoDigital> _arquivosTela = new ObservableCollection<IndiceArquivoDigital>(); + + private IndiceArquivoDigital _selectedArquivo = new IndiceArquivoDigital(); + + private ObservableCollection<ArquivoDigital> _arquivosAnexados = new ObservableCollection<ArquivoDigital>(); + + private ArquivoDigital _selectedAnexado = new ArquivoDigital(); + + private string _titulo = ""; + + private ObservableCollection<ClienteEmail> _emails = new ObservableCollection<ClienteEmail>(); + + 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<ClienteTelefone> Telefones + { + get + { + return _telefones; + } + set + { + _telefones = value; + OnPropertyChanged("Telefones"); + } + } + + public ObservableCollection<IndiceArquivoDigital> Arquivos + { + get + { + return _arquivos; + } + set + { + _arquivos = value; + ArquivosTela = value; + OnPropertyChanged("Arquivos"); + } + } + + public ObservableCollection<IndiceArquivoDigital> ArquivosTela + { + get + { + return _arquivosTela; + } + set + { + _arquivosTela = value; + OnPropertyChanged("ArquivosTela"); + } + } + + public IndiceArquivoDigital SelectedArquivo + { + get + { + return _selectedArquivo; + } + set + { + _selectedArquivo = value; + OnPropertyChanged("SelectedArquivo"); + } + } + + public ObservableCollection<ArquivoDigital> 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<ClienteEmail> 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<IndiceArquivoDigital> arquivos = await ArquivoDigitalServico.BuscarPorTipo(Filtro.Tipo, Filtro.Id); + if (AdDocumento) + { + List<IndiceArquivoDigital> list = arquivos; + list.AddRange(await ArquivoDigitalServico.BuscarPorTipo((TipoArquivoDigital)2, Filtro.IdApolice)); + } + Arquivos = new ObservableCollection<IndiceArquivoDigital>(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<IndiceArquivoDigital>((ICollection<IndiceArquivoDigital>)Arquivos, (IEnumerable<IndiceArquivoDigital>)new ObservableCollection<IndiceArquivoDigital>(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<ClienteTelefone> + { + 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<ClienteEmail> 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<ClienteTelefone> + { + 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<ClienteTelefone> + { + 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<bool> BaixarTodos() + { + if (Arquivos == null || Arquivos.Count == 0) + { + return false; + } + return await DownloadAll(Arquivos.ToList(), Filtro.Id); + } + + public async void Anexar() + { + List<ArquivoDigital> attacheds = ((IEnumerable<IndiceArquivoDigital>)Arquivos).Select((Func<IndiceArquivoDigital, ArquivoDigital>)((IndiceArquivoDigital x) => new ArquivoDigital + { + Descricao = x.Descricao, + Extensao = x.Extensao + })).ToList(); + List<ArquivoDigital> 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<ArquivoDigital>(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<ArquivoDigital>(ArquivosAnexados); + } + } + + public async Task SalvarAnexos() + { + if (ArquivosAnexados != null && ArquivosAnexados.Count != 0) + { + Carregando = true; + List<ArquivoDigital> arquivos = ArquivosAnexados.ToList(); + if (!(await SalvarAttachments(arquivos, Filtro.Tipo, Filtro.Id))) + { + Carregando = false; + return; + } + await CarregaArquivos(); + ArquivosAnexados = new ObservableCollection<ArquivoDigital>(); + Carregando = false; + } + } + + public void LimparAnexos() + { + ArquivosAnexados = new ObservableCollection<ArquivoDigital>(); + } + + public async Task<MalaDireta> 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<Item> 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<Item> 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<Uri> CreateLink(IndiceArquivoDigital indice) + { + string value = $"{Funcoes.GetNetworkTime().Ticks}:{ApplicationHelper.IdFornecedor}:F:{((DomainBase)indice).Id}".Base64Encode(); + return Recursos.ApiArquivo.AddQuery("search", value); + } + + public async Task<bool> 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<IndiceArquivoDigital>(Arquivos); + await ShowMessage($"{arquivosEnviados} DE {arquivosSelecionados} ARQUIVOS FORAM ENVIADOS PARA ASSINATURA. VOCÊ SERÁ NOTIFICADO QUANDO OS DOCUMENTOS FOREM ASSINADOS"); + return true; + } + + public async Task<ArquivoParaAssinaturaAssinador> 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; + } + } +} |