From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Drawer/Ajuda/AtendimentosViewModel.cs | 514 +++++++++++++++++++++ .../Drawer/Ajuda/BoletosNotasViewModel.cs | 122 +++++ .../ViewModels/Drawer/Ajuda/ContratosViewModel.cs | 112 +++++ .../ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs | 281 +++++++++++ 4 files changed, 1029 insertions(+) create mode 100644 Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/AtendimentosViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/BoletosNotasViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/ContratosViewModel.cs create mode 100644 Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs (limited to 'Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda') diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/AtendimentosViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/AtendimentosViewModel.cs new file mode 100644 index 0000000..6adad6a --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/AtendimentosViewModel.cs @@ -0,0 +1,514 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Model.Ajuda; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.API; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.Helper; +using Gestor.Model.Resources; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows; + +namespace Gestor.Application.ViewModels.Drawer.Ajuda +{ + public class AtendimentosViewModel : BaseViewModel + { + private readonly AjudaServico _ajudaServico; + + private List _status; + + private string _webbody; + + private Visibility _envioEmailVisibility = Visibility.Collapsed; + + private Visibility _atendimentoVisibility; + + private ObservableCollection _atendimentos; + + private Atendimento _selectedAtendimento; + + private string _nome; + + private string _ddd; + + private string _telefone; + + private string _email; + + private string _assunto; + + private string _idacesso; + + private string _corpo; + + private string _senhaacesso; + + private ObservableCollection _arquivosAnexados = new ObservableCollection(); + + private Gestor.Model.Domain.Common.ArquivoDigital _selectedAnexado = new Gestor.Model.Domain.Common.ArquivoDigital(); + + private string _head; + + public ObservableCollection ArquivosAnexados + { + get + { + return this._arquivosAnexados; + } + set + { + this._arquivosAnexados = value; + base.OnPropertyChanged("ArquivosAnexados"); + } + } + + public string Assunto + { + get + { + return this._assunto; + } + set + { + this._assunto = value; + base.OnPropertyChanged("Assunto"); + } + } + + public ObservableCollection Atendimentos + { + get + { + return this._atendimentos; + } + set + { + this._atendimentos = value; + base.OnPropertyChanged("Atendimentos"); + } + } + + public Visibility AtendimentoVisibility + { + get + { + return this._atendimentoVisibility; + } + set + { + this._atendimentoVisibility = value; + base.OnPropertyChanged("AtendimentoVisibility"); + } + } + + public string Corpo + { + get + { + return this._corpo; + } + set + { + this._corpo = value; + base.OnPropertyChanged("Corpo"); + } + } + + public string Ddd + { + get + { + return this._ddd; + } + set + { + this._ddd = value; + base.OnPropertyChanged("Ddd"); + } + } + + public string Email + { + get + { + return this._email; + } + set + { + this._email = value; + base.OnPropertyChanged("Email"); + } + } + + public Visibility EnvioEmailVisibility + { + get + { + return this._envioEmailVisibility; + } + set + { + this._envioEmailVisibility = value; + base.OnPropertyChanged("EnvioEmailVisibility"); + } + } + + public string Head + { + get + { + return this._head; + } + set + { + this._head = value; + base.OnPropertyChanged("Head"); + } + } + + public Gestor.Model.API.HorarioAtendimento HorarioAtendimento + { + get; + set; + } + + public string IdAcesso + { + get + { + return this._idacesso; + } + set + { + this._idacesso = value; + base.OnPropertyChanged("IdAcesso"); + } + } + + public string Nome + { + get + { + return this._nome; + } + set + { + this._nome = value; + base.OnPropertyChanged("Nome"); + } + } + + public Gestor.Model.Domain.Common.ArquivoDigital SelectedAnexado + { + get + { + return this._selectedAnexado; + } + set + { + this._selectedAnexado = value; + base.OnPropertyChanged("SelectedAnexado"); + } + } + + public Atendimento SelectedAtendimento + { + get + { + return this._selectedAtendimento; + } + set + { + this._selectedAtendimento = value; + this.WorkOnSelectedAtendimento(value); + base.OnPropertyChanged("SelectedAtendimento"); + } + } + + public string SenhaAcesso + { + get + { + return this._senhaacesso; + } + set + { + this._senhaacesso = value; + base.OnPropertyChanged("SenhaAcesso"); + } + } + + public List Status + { + get + { + return this._status; + } + set + { + this._status = value; + base.OnPropertyChanged("Status"); + } + } + + public string Telefone + { + get + { + return this._telefone; + } + set + { + this._telefone = value; + base.OnPropertyChanged("Telefone"); + } + } + + public string WebBody + { + get + { + string str = this._webbody; + if (str == null) + { + return null; + } + return str.ToUpper().Trim(); + } + set + { + this._webbody = value; + base.OnPropertyChanged("WebBody"); + } + } + + public AtendimentosViewModel() + { + base.EnableButtons = true; + this._ajudaServico = new AjudaServico(); + this.LoadCombo(); + this.InitialLoad(); + } + + public async void Anexar() + { + List arquivoDigitals = await base.AddAttachments(new List(), new List()); + if (arquivoDigitals != null) + { + arquivoDigitals.AddRange(this.ArquivosAnexados); + this.ArquivosAnexados = new ObservableCollection(arquivoDigitals); + } + } + + public void Delete(Gestor.Model.Domain.Common.ArquivoDigital arquivo) + { + if (this.SelectedAnexado == null) + { + return; + } + Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital = this.ArquivosAnexados.First((Gestor.Model.Domain.Common.ArquivoDigital x) => x.get_Descricao() == arquivo.get_Descricao()); + this.ArquivosAnexados.Remove(arquivoDigital); + this.ArquivosAnexados = new ObservableCollection(this.ArquivosAnexados); + } + + public async Task>> Enviar() + { + List> keyValuePairs; + object obj; + try + { + List> keyValuePairs1 = this.Validate(); + if (keyValuePairs1.Count <= 0) + { + CustomerData customerDatum = new CustomerData(); + customerDatum.set_Corretora(Recursos.Empresa.get_Nome()); + customerDatum.set_Name(this.Nome); + customerDatum.set_AreaCode(this.Ddd); + customerDatum.set_Number(this.Telefone); + customerDatum.set_Email(this.Email); + CustomerData customerDatum1 = customerDatum; + object[] corpo = new object[] { this.Corpo, this.IdAcesso, this.SenhaAcesso, ApplicationHelper.Versao, Recursos.Usuario.get_Id(), Recursos.Usuario.get_Login(), JsonConvert.SerializeObject(customerDatum1) }; + string str = string.Format("{0}

ID Acesso: {1}
Senha Acesso: {2}

VERSÃO DO SISTEMA: {3}
USUÁRIO SISTEMA:{4} {5}

{6}

", corpo); + CustomerAttendance customerAttendance = new CustomerAttendance(); + customerAttendance.set_CustomerData(customerDatum1); + customerAttendance.set_Subject(this.Assunto); + customerAttendance.set_Body(str); + ObservableCollection arquivosAnexados = this.ArquivosAnexados; + customerAttendance.set_Attachments(arquivosAnexados.Select((Gestor.Model.Domain.Common.ArquivoDigital x) => { + Attachment attachment = new Attachment(); + attachment.set_Description(x.get_Descricao()); + attachment.set_Extension(x.get_Extensao()); + attachment.set_File(x.get_Arquivo()); + return attachment; + }).ToList()); + this.LimparComponentes(); + this.SelecionaAtendimento(); + if (await Connection.Post("Attendance/Send", customerAttendance) == null) + { + obj = null; + } + else + { + obj = new List>(); + ((List>)obj).Add(new KeyValuePair("fail", "")); + } + keyValuePairs = (List>)obj; + } + else + { + keyValuePairs = keyValuePairs1; + } + } + catch (Exception exception) + { + keyValuePairs = new List>() + { + new KeyValuePair("fail", "") + }; + } + return keyValuePairs; + } + + private async void HabilitarAtendimento(Gestor.Model.API.HorarioAtendimento horario) + { + bool id; + string str; + if (horario == null || horario.get_Autorizado()) + { + AtendimentosViewModel atendimentosViewModel = this; + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + id = usuario.get_Id() > (long)0; + } + else + { + id = false; + } + atendimentosViewModel.EnableButtons = id; + } + else + { + base.EnableButtons = false; + if (horario.get_InicioDia().HasValue) + { + string[] strArrays = new string[] { " de ", horario.get_InicioDia().DiaDaSemana(), " à ", horario.get_FimDia().DiaDaSemana(), ", das ", horario.get_InicioHora(), "hs às ", horario.get_FimHora(), "hs" }; + str = string.Concat(strArrays); + } + else + { + string[] inicioHora = new string[] { " das ", horario.get_InicioHora(), "hs às ", horario.get_FimHora(), "hs" }; + str = string.Concat(inicioHora); + } + string str1 = str; + string[] newLine = new string[] { "Prezado Cliente,", Environment.NewLine, Environment.NewLine, "Informamos Nosso horário de atendimento e recepção dos mesmos é ", str1, ".", Environment.NewLine, "Infelizmente não realizamos agendamento de data/hora de atendimento, por gentileza realize a solicitação dentro do horário comercial que retornaremos a você." }; + await base.ShowMessage(string.Concat(newLine), "OK", "", false); + } + } + + private async void InitialLoad() + { + base.IsEnabled = false; + this.HorarioAtendimento = await Connection.Get("Attendance", true, false); + this.HabilitarAtendimento(this.HorarioAtendimento); + base.IsEnabled = true; + } + + public void LimparComponentes() + { + this.Nome = Recursos.Usuario.get_Nome(); + this.Ddd = Recursos.Usuario.get_Prefixo(); + this.Telefone = Recursos.Usuario.get_Telefone(); + this.Email = Recursos.Usuario.get_Email(); + this.Assunto = null; + this.IdAcesso = null; + this.SenhaAcesso = null; + this.Corpo = string.Empty; + this.ArquivosAnexados = new ObservableCollection(); + } + + private void LoadCombo() + { + this.Status = new List() + { + "PENDENTES", + "FINALIZADOS" + }; + } + + public void SelecionaAtendimento() + { + if (this.Atendimentos != null && this.Atendimentos.Count > 0) + { + this.SelectedAtendimento = this.Atendimentos[0]; + } + this.AtendimentoVisibility = Visibility.Visible; + this.EnvioEmailVisibility = Visibility.Collapsed; + } + + public List> Validate() + { + List> keyValuePairs = ValidationHelper.AddValue(); + if (string.IsNullOrWhiteSpace(this.Nome)) + { + ValidationHelper.AddValue(keyValuePairs, "Nome", Messages.get_Obrigatorio(), true); + } + if (string.IsNullOrWhiteSpace(this.Ddd)) + { + ValidationHelper.AddValue(keyValuePairs, "Ddd", Messages.get_Obrigatorio(), true); + } + else if (!ValidationHelper.ValidacaoPrefixo(this.Ddd)) + { + ValidationHelper.AddValue(keyValuePairs, "Ddd", Messages.get_Invalido(), true); + } + if (string.IsNullOrWhiteSpace(this.Telefone)) + { + ValidationHelper.AddValue(keyValuePairs, "Telefone", Messages.get_Obrigatorio(), true); + } + else if (!ValidationHelper.ValidacaoTelefone(this.Telefone)) + { + ValidationHelper.AddValue(keyValuePairs, "Telefone", Messages.get_Invalido(), true); + } + if (string.IsNullOrWhiteSpace(this.Email)) + { + ValidationHelper.AddValue(keyValuePairs, "Email", Messages.get_Obrigatorio(), true); + } + else if (!ValidationHelper.ValidacaoEmail(this.Email)) + { + ValidationHelper.AddValue(keyValuePairs, "Email", Messages.get_Invalido(), true); + } + if (string.IsNullOrWhiteSpace(this.Corpo)) + { + ValidationHelper.AddValue(keyValuePairs, "Corpo", Messages.get_Obrigatorio(), true); + } + if (string.IsNullOrWhiteSpace(this.Assunto)) + { + ValidationHelper.AddValue(keyValuePairs, "Assunto", Messages.get_Obrigatorio(), true); + } + return keyValuePairs; + } + + private async void WorkOnSelectedAtendimento(Atendimento value) + { + if (value != null) + { + this.WebBody = await this._ajudaServico.BuscarCorpoAtendimentos(value.IdAtendimento); + } + } + + public async void WorkOnSelectedStatus(string value) + { + this.Atendimentos = await this._ajudaServico.BuscarAtendimentos(value); + this.SelecionaAtendimento(); + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/BoletosNotasViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/BoletosNotasViewModel.cs new file mode 100644 index 0000000..6f2e250 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/BoletosNotasViewModel.cs @@ -0,0 +1,122 @@ +using Gestor.Application.Model.Ajuda; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.ViewModels.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.ViewModels.Drawer.Ajuda +{ + public class BoletosNotasViewModel : BaseViewModel + { + private readonly AjudaServico _ajudaServico; + + private bool _carregando; + + private List _boletos; + + private string _boletoDisponivel; + + private List _status; + + public string BoletoDisponivel + { + get + { + return this._boletoDisponivel; + } + set + { + this._boletoDisponivel = value; + base.OnPropertyChanged("BoletoDisponivel"); + } + } + + public List Boletos + { + get + { + return this._boletos; + } + set + { + this._boletos = value; + base.OnPropertyChanged("Boletos"); + } + } + + public bool Carregando + { + get + { + return this._carregando; + } + set + { + this._carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + base.OnPropertyChanged("Carregando"); + } + } + + public List Status + { + get + { + return this._status; + } + set + { + this._status = value; + base.OnPropertyChanged("Status"); + } + } + + public BoletosNotasViewModel() + { + this._ajudaServico = new AjudaServico(); + this.LoadCombos(); + this.BoletoDisponivel = "Disponível para impressão a partir de\n10 (dez) dias antes do vencimento"; + } + + private void LoadCombos() + { + this.Status = new List() + { + "PENDENTES", + "BAIXADOS" + }; + } + + public async void WorkOnSelectedStatus(string value) + { + List list; + this.Carregando = true; + this.Boletos = new List(); + List boletos = await this._ajudaServico.BuscarBoletosNotas(value); + BoletosNotasViewModel boletosNotasViewModel = this; + if (value == "BAIXADOS") + { + List boletos1 = boletos; + IEnumerable hasValue = + from x in boletos1 + where x.Pagamento.HasValue + select x; + list = ( + from x in hasValue + orderby x.Pagamento descending + select x).ToList(); + } + else + { + list = boletos; + } + boletosNotasViewModel.Boletos = list; + this.Carregando = false; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/ContratosViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/ContratosViewModel.cs new file mode 100644 index 0000000..fe46bb4 --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/ContratosViewModel.cs @@ -0,0 +1,112 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Model.Ajuda; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.License; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Gestor.Application.ViewModels.Drawer.Ajuda +{ + public class ContratosViewModel : BaseViewModel + { + private readonly AjudaServico _ajudaServico; + + private bool _carregando; + + private List _contratos; + + private Licenca _selectedContrato; + + public bool Carregando + { + get + { + return this._carregando; + } + set + { + this._carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + base.OnPropertyChanged("Carregando"); + } + } + + public List Contratos + { + get + { + return this._contratos; + } + set + { + this._contratos = value; + base.OnPropertyChanged("Contratos"); + } + } + + public Licenca SelectedContrato + { + get + { + return this._selectedContrato; + } + set + { + this._selectedContrato = value; + this.WorkOnSelectedContrato(value); + base.OnPropertyChanged("SelectedContrato"); + } + } + + public ContratosViewModel() + { + this._ajudaServico = new AjudaServico(); + this.Contratos = LicenseHelper.Produtos; + } + + internal async void WorkOnSelectedContrato(Licenca value) + { + Contrato contrato = await this._ajudaServico.BuscarContrato(value.get_Produto()); + if (!string.IsNullOrEmpty(contrato.HtmlContrato) || contrato.IdModulo != (long)7) + { + if (string.IsNullOrEmpty(contrato.HtmlContrato) && contrato.IdModulo != (long)7) + { + contrato = await this._ajudaServico.BuscarContrato(1); + } + string empty = string.Empty; + LicenseHelper.Produtos.ForEach((Licenca x) => empty = string.Concat(empty, (string.IsNullOrEmpty(empty) ? ValidationHelper.GetDescription(x.get_Produto()) : string.Concat("/ ", ValidationHelper.GetDescription(x.get_Produto()))))); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<NOME>]", Recursos.Empresa.get_Nome()); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<ENDERECO>]", Recursos.Empresa.get_Endereco()); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<CIDADE>]", Recursos.Empresa.get_Cidade()); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<CNPJ>]", Recursos.Empresa.get_Documento()); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<NS>]", Recursos.Empresa.get_Serial()); + string htmlContrato = contrato.HtmlContrato; + DateTime date = Funcoes.GetNetworkTime().Date; + contrato.HtmlContrato = htmlContrato.Replace("[<DATA>]", date.ToString("dd/MM/yyyy")); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<VALOR>]", "Conforme Mensalidade"); + contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<OUTROS>]", empty.Replace("*", "")); + string tempPath = Path.GetTempPath(); + string str = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (new Regex(string.Concat("[", Regex.Escape(string.Concat(new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars()))), "]"))).Replace(ValidationHelper.GetDescription(value.get_Produto()), ""), Funcoes.GetNetworkTime()); + StreamWriter streamWriter = new StreamWriter(str, true, Encoding.UTF8); + streamWriter.Write(contrato.HtmlContrato); + streamWriter.Close(); + Process.Start(str); + } + else + { + Process.Start(string.Format("https://aggilizador.com.br/Contrato.aspx?id={0}", ApplicationHelper.IdFornecedor)); + } + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs new file mode 100644 index 0000000..8ee9f0b --- /dev/null +++ b/Codemerx/Gestor.Application/ViewModels/Drawer/Ajuda/InstalacaoViewModel.cs @@ -0,0 +1,281 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Model.Ajuda; +using Gestor.Application.Servicos.Ajuda; +using Gestor.Application.ViewModels.Generic; +using Gestor.Common.Validation; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Gestor.Model.License; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace Gestor.Application.ViewModels.Drawer.Ajuda +{ + public class InstalacaoViewModel : BaseViewModel + { + private readonly AjudaServico _ajudaServico; + + private bool _enableExclusao; + + private bool _mostrarAggilizador; + + private string _infoGestor; + + private string _infoAggilizador; + + private bool _carregando; + + private List _agger; + + private ObservableCollection _aggerFiltrado; + + private List _aggilizador; + + public List Agger + { + get + { + return this._agger; + } + set + { + this._agger = value; + base.OnPropertyChanged("Agger"); + } + } + + public ObservableCollection AggerFiltrado + { + get + { + return this._aggerFiltrado; + } + set + { + this._aggerFiltrado = value; + base.OnPropertyChanged("AggerFiltrado"); + } + } + + public List Aggilizador + { + get + { + return this._aggilizador; + } + set + { + this._aggilizador = value; + base.OnPropertyChanged("Aggilizador"); + } + } + + public bool Carregando + { + get + { + return this._carregando; + } + set + { + this._carregando = value; + base.IsEnabled = !value; + base.EnableMenu = !value; + base.OnPropertyChanged("Carregando"); + } + } + + public bool EnableExclusao + { + get + { + return this._enableExclusao; + } + set + { + this._enableExclusao = value; + base.OnPropertyChanged("EnableExclusao"); + } + } + + public string InfoAggilizador + { + get + { + return this._infoAggilizador; + } + set + { + this._infoAggilizador = value; + base.OnPropertyChanged("InfoAggilizador"); + } + } + + public string InfoGestor + { + get + { + return this._infoGestor; + } + set + { + this._infoGestor = value; + base.OnPropertyChanged("InfoGestor"); + } + } + + public AutoCompleteFilterPredicate InstalacaoItemFilter + { + get + { + AutoCompleteFilterPredicate u003cu003e9_370 = InstalacaoViewModel.u003cu003ec.u003cu003e9__37_0; + if (u003cu003e9_370 == null) + { + u003cu003e9_370 = new AutoCompleteFilterPredicate(InstalacaoViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { + if (((Gestor.Application.Model.Ajuda.Instalacao)obj).Maquina.ToUpper().Contains(searchText.ToUpper()) || ((Gestor.Application.Model.Ajuda.Instalacao)obj).Usuario.ToUpper().Contains(searchText.ToUpper())) + { + return true; + } + return ((Gestor.Application.Model.Ajuda.Instalacao)obj).DataIntalacao.ToString().Contains(searchText.ToUpper()); + }); + InstalacaoViewModel.u003cu003ec.u003cu003e9__37_0 = u003cu003e9_370; + } + return u003cu003e9_370; + } + } + + public bool MostrarAggilizador + { + get + { + return this._mostrarAggilizador; + } + set + { + this._mostrarAggilizador = value; + base.OnPropertyChanged("MostrarAggilizador"); + } + } + + public InstalacaoViewModel() + { + Usuario usuario = Recursos.Usuario; + if (usuario != null) + { + id = usuario.get_Id() > (long)0; + } + else + { + id = false; + } + this._enableExclusao = id; + base(); + bool id; + this._ajudaServico = new AjudaServico(); + this.LoadInstalacoes(); + } + + public async void Excluir(long id) + { + if (await this._ajudaServico.ExcluirInstalacao(id)) + { + this.LoadInstalacoes(); + } + } + + internal async Task> Filtrar(string value) + { + List instalacaos = await Task.Run>(() => this.FiltrarInstalacao(value)); + return instalacaos; + } + + public List FiltrarInstalacao(string filter) + { + this.AggerFiltrado = (string.IsNullOrWhiteSpace(filter) ? new ObservableCollection(this.Agger) : new ObservableCollection(this.Agger.Where((Gestor.Application.Model.Ajuda.Instalacao x) => { + if (ValidationHelper.RemoveDiacritics(x.Maquina.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter)) || ValidationHelper.RemoveDiacritics(x.Usuario.Trim()).ToUpper().Contains(ValidationHelper.RemoveDiacritics(filter))) + { + return true; + } + return x.DataIntalacao.ToString().Contains(ValidationHelper.RemoveDiacritics(filter)); + }))); + return this.AggerFiltrado.ToList(); + } + + private async void LoadInstalacoes() + { + int? nullable; + List instalacaos; + int? nullable1; + int? nullable2; + string str; + this.Carregando = true; + ObservableCollection observableCollection = await this._ajudaServico.BuscarLicencas(); + InstalacaoViewModel list = this; + ObservableCollection observableCollection1 = observableCollection; + list.Agger = ( + from x in observableCollection1 + where !string.IsNullOrEmpty(x.IdGerenciador) + select x).ToList(); + this.AggerFiltrado = new ObservableCollection(this.Agger); + InstalacaoViewModel instalacaoViewModel = this; + List produtos = LicenseHelper.Produtos; + if (produtos.Any((Licenca x) => x.get_Produto() == 81)) + { + instalacaos = new List(); + } + else + { + ObservableCollection observableCollection2 = observableCollection; + instalacaos = ( + from x in observableCollection2 + where !string.IsNullOrEmpty(x.IdAggilizador) + select x).ToList(); + } + instalacaoViewModel.Aggilizador = instalacaos; + InstalacaoViewModel instalacaoViewModel1 = this; + object count = this.Agger.Count; + List licencas = LicenseHelper.Produtos; + Licenca licenca = licencas.FirstOrDefault((Licenca x) => x.get_Produto() == 1); + if (licenca != null) + { + nullable1 = new int?(licenca.get_Quantidade()); + } + else + { + nullable = null; + nullable1 = nullable; + } + instalacaoViewModel1.InfoGestor = string.Format("{0} LICENÇAS INSTALADAS DE {1} LICENÇAS CONTRATADAS.", count, nullable1); + InstalacaoViewModel instalacaoViewModel2 = this; + if (this.Aggilizador.Count > 0) + { + object obj = this.Aggilizador.Count; + List produtos1 = LicenseHelper.Produtos; + Licenca licenca1 = produtos1.FirstOrDefault((Licenca x) => x.get_Produto() == 81); + if (licenca1 != null) + { + nullable2 = new int?(licenca1.get_Quantidade()); + } + else + { + nullable = null; + nullable2 = nullable; + } + str = string.Format("{0} LICENÇAS INSTALADAS DE {1} LICENÇAS CONTRATADAS.", obj, nullable2); + } + else + { + str = ""; + } + instalacaoViewModel2.InfoAggilizador = str; + this.MostrarAggilizador = this.Aggilizador.Count > 0; + this.Carregando = false; + } + } +} \ No newline at end of file -- cgit v1.2.3