summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.Drawer/TarefaDrawerViewModel.cs1064
1 files changed, 1064 insertions, 0 deletions
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<Tarefa> _tarefasFiltradas = new ObservableCollection<Tarefa>();
+
+ private List<Tarefa> _tarefas = new List<Tarefa>();
+
+ private bool _isAnotacoes = true;
+
+ private Tarefa _selectedTarefa;
+
+ private ObservableCollection<Usuario> _usuarios;
+
+ private ObservableCollection<TipoDeTarefa> _tiposTarefa;
+
+ private List<TelefoneBase> _telefones;
+
+ private DateTime _dataAgendamento = Funcoes.GetNetworkTime();
+
+ private DateTime _horaAgendamento = Funcoes.GetNetworkTime();
+
+ private Usuario _selectedUsuario;
+
+ private TipoDeTarefa _selectedTipoTarefa;
+
+ private ArquivoDigital _selectedAnexado = new ArquivoDigital();
+
+ private ObservableCollection<ArquivoDigital> _arquivosAnexados = new ObservableCollection<ArquivoDigital>();
+
+ private List<ArquivoDigital> _arquivosFinais = new List<ArquivoDigital>();
+
+ 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<Tarefa> TarefasFiltradas
+ {
+ get
+ {
+ return _tarefasFiltradas;
+ }
+ set
+ {
+ _tarefasFiltradas = value;
+ OnPropertyChanged("TarefasFiltradas");
+ }
+ }
+
+ public List<Tarefa> 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<ResponsavelTarefa>() : ((value.Responsaveis == null) ? new ObservableCollection<ResponsavelTarefa>() : new ObservableCollection<ResponsavelTarefa>(value.Responsaveis)));
+ if (!base.Responsaveis.Any())
+ {
+ Tarefa obj4 = value;
+ base.Responsaveis = ((((obj4 != null) ? obj4.Usuario : null) == null) ? new ObservableCollection<ResponsavelTarefa>() : new ObservableCollection<ResponsavelTarefa>((IEnumerable<ResponsavelTarefa>)(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<TipoDeTarefa>(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<Usuario> Usuarios
+ {
+ get
+ {
+ return _usuarios;
+ }
+ set
+ {
+ _usuarios = value;
+ OnPropertyChanged("Usuarios");
+ }
+ }
+
+ public ObservableCollection<TipoDeTarefa> TiposTarefa
+ {
+ get
+ {
+ return _tiposTarefa;
+ }
+ set
+ {
+ _tiposTarefa = value;
+ OnPropertyChanged("TiposTarefa");
+ }
+ }
+
+ public List<TelefoneBase> 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<ArquivoDigital> ArquivosAnexados
+ {
+ get
+ {
+ return _arquivosAnexados;
+ }
+ set
+ {
+ _arquivosAnexados = value;
+ OnPropertyChanged("ArquivosAnexados");
+ }
+ }
+
+ public List<ArquivoDigital> 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<TipoDeTarefa>(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<Usuario>((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, TelefoneBase>)((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, TelefoneBase>)((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, TelefoneBase>)((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<Tarefa> 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<Tarefa>(Tarefas);
+ SelectedTarefa = (Tarefa)((TarefasFiltradas == null || TarefasFiltradas.Count == 0) ? null : ((((DomainBase)tarefa).Id != 0L) ? ((object)((IEnumerable<Tarefa>)TarefasFiltradas).FirstOrDefault((Func<Tarefa, bool>)((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<Tarefa>(Tarefas);
+ SelectedTarefa = (Tarefa)((TarefasFiltradas == null || TarefasFiltradas.Count == 0) ? null : ((((DomainBase)tarefa).Id != 0L) ? ((object)((IEnumerable<Tarefa>)TarefasFiltradas).FirstOrDefault((Func<Tarefa, bool>)((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<ResponsavelTarefa>();
+ 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<Usuario>)Usuarios).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == ((DomainBase)Recursos.Usuario).Id)),
+ Restrito = false,
+ Responsaveis = base.Responsaveis.ToList()
+ };
+ ArquivosFinais = new List<ArquivoDigital>();
+ 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<List<KeyValuePair<string, string>>> 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<KeyValuePair<string, string>> list = SelectedTarefa.Validate();
+ if (SelectedTarefa.Descricao == null && string.IsNullOrWhiteSpace(anotacoes) && string.IsNullOrWhiteSpace(anotacoesInternas))
+ {
+ list.Add(new KeyValuePair<string, string>("ANOTAÇÕES", "OBRIGATÓRIO"));
+ }
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ if (!string.IsNullOrWhiteSpace(anotacoes))
+ {
+ SelectedTarefa.Anotacoes = Funcoes.AdicionarLog(SelectedTarefa.Anotacoes);
+ SelectedTarefa.Descricao = SelectedTarefa.Anotacoes + " <p> " + SelectedTarefa.Descricao + " </p>";
+ }
+ if (!string.IsNullOrWhiteSpace(anotacoesInternas))
+ {
+ SelectedTarefa.AnotacoesInternas = Funcoes.AdicionarLog(SelectedTarefa.AnotacoesInternas);
+ SelectedTarefa.DescricaoInterna = SelectedTarefa.AnotacoesInternas + " <p> " + SelectedTarefa.DescricaoInterna + " </p>";
+ }
+ 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<Tarefa>)TarefasFiltradas).FirstOrDefault((Func<Tarefa, bool>)((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<Tarefa> { 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<Tarefa>)TarefasFiltradas).FirstOrDefault((Func<Tarefa, bool>)((Tarefa x) => ((DomainBase)x).Id == id));
+ }
+ }
+
+ public async Task<bool> 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<ArquivoDigital>(ArquivosAnexados);
+ }
+ }
+
+ public async void Anexar()
+ {
+ InclusaoArquivoDigitalEnable = false;
+ List<ArquivoDigital> arquivos = await AddAttachments(ArquivosAnexados.ToList(), new List<ArquivoDigital>());
+ await Task.Run(async delegate
+ {
+ await Task.Delay(200);
+ InclusaoArquivoDigitalEnable = true;
+ });
+ if (arquivos != null)
+ {
+ arquivos.AddRange(ArquivosAnexados);
+ ArquivosAnexados = new ObservableCollection<ArquivoDigital>(arquivos);
+ }
+ }
+
+ public void SalvarAnexos()
+ {
+ ArquivosFinais = ArquivosAnexados.ToList();
+ }
+
+ public void LimparAnexos()
+ {
+ ArquivosAnexados = new ObservableCollection<ArquivoDigital>();
+ }
+
+ 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 = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><meta http-equiv='Content-Language' content='pt-br'><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=yes'><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'><style type='text/css' media='print'>@page{ size: A4;} body; -webkit-print-color-adjust: exact; }</style><title> TAREFA </title></head><body bgcolor='#FFFFFF'><div align='center'>";
+ text += "<br>";
+ text += "<table border='0' width='999'><td height='20' width='999' bgcolor='black'><h4 style='text-align: center; color: white; background-color: black'>";
+ text += "TAREFA</h4></td></table><br>";
+ text += "<table border='1' bordercolor='#ededed' width='999'><font face='Verdana' style='font-size: 4pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'>";
+ int num = 0;
+ text = text + "<tr><td width='333' bgcolor='" + ((num++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>CLIENTE: </b>" + SelectedTarefa.Cliente + "</p></td></tr>";
+ text = text + "<tr><td width='333' bgcolor='" + ((num++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>REFERÊNCIA: </b>" + SelectedTarefa.Referencia + "</p></td></tr>";
+ text = text + "<tr><td width='333' bgcolor='" + ((num++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>TÍTULO: </b>" + SelectedTarefa.Titulo + "</p></td></tr>";
+ text = text + "<tr><td width='333' bgcolor='" + ((num++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>AGENDAMENTO: </b>" + SelectedTarefa.Agendamento.ToString() + "</p></td></tr>";
+ text = text + "<tr><td width='333' bgcolor='" + ((num++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>RESPONSÁVEL PRINCIPAL: </b>" + SelectedTarefa.Usuario.Nome + "</p></td></tr>";
+ text = text + "<tr><td width='333' bgcolor='" + ((num++ % 2 == 0) ? "WhiteSmoke" : "White") + "'><p align='left'><b>STATUS: </b>" + ValidationHelper.GetDescription((Enum)(object)SelectedTarefa.Status) + "</p></td></tr>";
+ string[] obj = new string[6]
+ {
+ text,
+ "<tr><td width='333' bgcolor='",
+ (num % 2 == 0) ? "WhiteSmoke" : "White",
+ "'><p align='left'><b>TIPO DE TAREFA: </b>",
+ null,
+ null
+ };
+ TipoDeTarefa selectedTipoTarefa = SelectedTipoTarefa;
+ obj[4] = ((selectedTipoTarefa != null) ? selectedTipoTarefa.Nome : null);
+ obj[5] = "</p></td></tr>";
+ text = string.Concat(obj);
+ text += "</font></table>";
+ if (base.Responsaveis != null && base.Responsaveis.Count > 0)
+ {
+ text += "<h2>RESPONSÁVEIS VINCULADOS</h2>";
+ text += "<br>";
+ text += "<table border='1'bordercolor='#cfcfcf' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'>";
+ List<string> list = new List<string>();
+ foreach (ResponsavelTarefa responsavei in base.Responsaveis)
+ {
+ list.Add(responsavei.Usuario.Nome.Trim().ToUpper());
+ }
+ text = text + "<tr><td width='333'><p align='left'>" + string.Join(", ", list) + "</p></td></tr>";
+ text += "</font></table>";
+ text += "<br><br>";
+ }
+ text += "<br><br>";
+ if (SelectedTarefa.Descricao != null)
+ {
+ text += "<h2>ANOTAÇÕES</h2>";
+ text += "<br>";
+ text += "<table border='1'bordercolor='#cfcfcf' width='999'><font face='Verdana' style='font-size: 12pt; position: absolute; top: 50 %; -moz-transform: translateY(-50 %); -webkit-transform: translateY(-50 %); transform: translateY(-50 %)'>";
+ text = text + "<tr><td width='333'><p align='left'>" + SelectedTarefa.Descricao.Replace("<BODY>", "").Replace("</BODY>", "") + "</p></td></tr>";
+ text += "</font></table>";
+ text += "<br><br>";
+ }
+ return text + "</div></body>";
+ }
+}