summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.BI/TarefaBIViewModel.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.BI/TarefaBIViewModel.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels.BI/TarefaBIViewModel.cs')
-rw-r--r--Decompiler/Gestor.Application.ViewModels.BI/TarefaBIViewModel.cs1146
1 files changed, 1146 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels.BI/TarefaBIViewModel.cs b/Decompiler/Gestor.Application.ViewModels.BI/TarefaBIViewModel.cs
new file mode 100644
index 0000000..03d23df
--- /dev/null
+++ b/Decompiler/Gestor.Application.ViewModels.BI/TarefaBIViewModel.cs
@@ -0,0 +1,1146 @@
+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 System.Windows.Controls;
+using Gestor.Application.Actions;
+using Gestor.Application.Drawers;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.Application.Views.Generic;
+using Gestor.Application.Views.Seguros;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Configuracoes;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.MalaDireta;
+using Gestor.Model.Domain.Seguros;
+using Gestor.Model.Helper;
+
+namespace Gestor.Application.ViewModels.BI;
+
+public class TarefaBIViewModel : BaseTarefaViewModel
+{
+ private bool _enableAlterarTarefa = true;
+
+ private bool _administrador;
+
+ private DateTime _inicio = Funcoes.GetNetworkTime().Date.AddDays(-4.0);
+
+ private DateTime _fim = Funcoes.GetNetworkTime().Date.AddDays(4.0);
+
+ private List<string> _status = new List<string>
+ {
+ "TODAS AS TAREFAS",
+ ValidationHelper.GetDescription((Enum)(object)(StatusTarefa)0),
+ ValidationHelper.GetDescription((Enum)(object)(StatusTarefa)2)
+ };
+
+ private string _selectedStatus;
+
+ private Visibility _isVisibleCliente = (Visibility)2;
+
+ private Visibility _isVisibleApolice = (Visibility)2;
+
+ private Visibility _isVisibleArquivoDigital = (Visibility)2;
+
+ private Visibility _isVisibleSinistro = (Visibility)2;
+
+ private ObservableCollection<Usuario> _usuariosFiltro;
+
+ private ObservableCollection<Usuario> _usuarios;
+
+ private ObservableCollection<TipoDeTarefa> _tiposTarefa;
+
+ private TipoDeTarefa _selectedTipoTarefa;
+
+ private Usuario _selectedUsuarioFiltro = new Usuario();
+
+ private Usuario _selectedUsuario = new Usuario();
+
+ private DateTime _dataAgendamento = Funcoes.GetNetworkTime();
+
+ private DateTime _horaAgendamento = Funcoes.GetNetworkTime();
+
+ private bool _isAnotacoes = true;
+
+ private string _descricao = "";
+
+ private string _historicoInterno = "";
+
+ private ObservableCollection<Tarefa> _tarefas;
+
+ private Tarefa _selectedTarefa;
+
+ private ObservableCollection<TelefoneBase> _telefones;
+
+ private long _cancelTarefa;
+
+ private ObservableCollection<Tarefa> _tarefasFiltradas = new ObservableCollection<Tarefa>();
+
+ private string _filtro = "";
+
+ private ObservableCollection<string> _filtroTarefa = new ObservableCollection<string>();
+
+ private GridLength _columnUsuarioPrincipal = new GridLength(1.0, (GridUnitType)2);
+
+ private GridLength _columnUsuarios = new GridLength(0.0, (GridUnitType)1);
+
+ private new TarefaServico Servico { get; }
+
+ private ClienteServico ClienteServico { get; }
+
+ public override bool EnableAlterarTarefa
+ {
+ get
+ {
+ return _enableAlterarTarefa;
+ }
+ set
+ {
+ _enableAlterarTarefa = _alterarPermissEnabled && value;
+ OnPropertyChanged("EnableAlterarTarefa");
+ }
+ }
+
+ public bool Administrador
+ {
+ get
+ {
+ return _administrador;
+ }
+ set
+ {
+ _administrador = value;
+ OnPropertyChanged("Administrador");
+ }
+ }
+
+ public DateTime Inicio
+ {
+ get
+ {
+ return _inicio;
+ }
+ set
+ {
+ _inicio = value;
+ CarregaTarefas();
+ OnPropertyChanged("Inicio");
+ }
+ }
+
+ public DateTime Fim
+ {
+ get
+ {
+ return _fim;
+ }
+ set
+ {
+ _fim = value;
+ CarregaTarefas();
+ OnPropertyChanged("Fim");
+ }
+ }
+
+ public List<string> Status
+ {
+ get
+ {
+ return _status;
+ }
+ set
+ {
+ _status = value;
+ CarregaTarefas();
+ OnPropertyChanged("Status");
+ }
+ }
+
+ public string SelectedStatus
+ {
+ get
+ {
+ return _selectedStatus;
+ }
+ set
+ {
+ _selectedStatus = value;
+ CarregaTarefas();
+ OnPropertyChanged("SelectedStatus");
+ }
+ }
+
+ public Visibility IsVisibleCliente
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleCliente;
+ }
+ 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)
+ _isVisibleCliente = value;
+ OnPropertyChanged("IsVisibleCliente");
+ }
+ }
+
+ public Visibility IsVisibleApolice
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleApolice;
+ }
+ 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)
+ _isVisibleApolice = value;
+ OnPropertyChanged("IsVisibleApolice");
+ }
+ }
+
+ public Visibility IsVisibleArquivoDigital
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleArquivoDigital;
+ }
+ 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)
+ _isVisibleArquivoDigital = value;
+ OnPropertyChanged("IsVisibleArquivoDigital");
+ }
+ }
+
+ public Visibility IsVisibleSinistro
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _isVisibleSinistro;
+ }
+ 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)
+ _isVisibleSinistro = value;
+ OnPropertyChanged("IsVisibleSinistro");
+ }
+ }
+
+ public ObservableCollection<Usuario> UsuariosFiltro
+ {
+ get
+ {
+ return _usuariosFiltro;
+ }
+ set
+ {
+ _usuariosFiltro = value;
+ OnPropertyChanged("UsuariosFiltro");
+ }
+ }
+
+ 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 TipoDeTarefa SelectedTipoTarefa
+ {
+ get
+ {
+ return _selectedTipoTarefa;
+ }
+ set
+ {
+ _selectedTipoTarefa = value;
+ OnPropertyChanged("SelectedTipoTarefa");
+ }
+ }
+
+ public Usuario SelectedUsuarioFiltro
+ {
+ get
+ {
+ return _selectedUsuarioFiltro;
+ }
+ set
+ {
+ _selectedUsuarioFiltro = value;
+ CarregaTarefas();
+ OnPropertyChanged("SelectedUsuarioFiltro");
+ }
+ }
+
+ public Usuario SelectedUsuario
+ {
+ get
+ {
+ return _selectedUsuario;
+ }
+ set
+ {
+ _selectedUsuario = value;
+ OnPropertyChanged("SelectedUsuario");
+ }
+ }
+
+ 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 bool IsAnotacoes
+ {
+ get
+ {
+ return _isAnotacoes;
+ }
+ set
+ {
+ _isAnotacoes = value;
+ OnPropertyChanged("IsAnotacoes");
+ }
+ }
+
+ public string Descricao
+ {
+ get
+ {
+ return _descricao;
+ }
+ set
+ {
+ _descricao = value;
+ OnPropertyChanged("Descricao");
+ }
+ }
+
+ public string HistoricoInterno
+ {
+ get
+ {
+ return _historicoInterno;
+ }
+ set
+ {
+ _historicoInterno = value;
+ OnPropertyChanged("HistoricoInterno");
+ }
+ }
+
+ public ObservableCollection<Tarefa> Tarefas
+ {
+ get
+ {
+ return _tarefas;
+ }
+ set
+ {
+ _tarefas = value;
+ OnPropertyChanged("Tarefas");
+ }
+ }
+
+ public override Tarefa SelectedTarefa
+ {
+ get
+ {
+ return _selectedTarefa;
+ }
+ set
+ {
+ _cancelTarefa = ((value != null) ? ((DomainBase)value).Id : 0);
+ WorkOnSelectedTarefa(value);
+ VerificarEnables((value != null) ? new long?(((DomainBase)value).Id) : null);
+ _selectedTarefa = value;
+ ValidaPermissaoParaEditarTarefa();
+ OnPropertyChanged("SelectedTarefa");
+ }
+ }
+
+ public ObservableCollection<TelefoneBase> Telefones
+ {
+ get
+ {
+ return _telefones;
+ }
+ set
+ {
+ _telefones = value;
+ OnPropertyChanged("Telefones");
+ }
+ }
+
+ public ObservableCollection<Tarefa> TarefasFiltradas
+ {
+ get
+ {
+ return _tarefasFiltradas;
+ }
+ set
+ {
+ _tarefasFiltradas = value;
+ base.IsVisible = (Visibility)((value.Count <= 0) ? 2 : 0);
+ OnPropertyChanged("TarefasFiltradas");
+ }
+ }
+
+ public string Filtro
+ {
+ get
+ {
+ return _filtro;
+ }
+ set
+ {
+ _filtro = value;
+ OnPropertyChanged("Filtro");
+ }
+ }
+
+ public ObservableCollection<string> FiltroTarefa
+ {
+ get
+ {
+ return _filtroTarefa;
+ }
+ set
+ {
+ _filtroTarefa = value;
+ OnPropertyChanged("FiltroTarefa");
+ }
+ }
+
+ public GridLength ColumnUsuarioPrincipal
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _columnUsuarioPrincipal;
+ }
+ 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)
+ _columnUsuarioPrincipal = value;
+ OnPropertyChanged("ColumnUsuarioPrincipal");
+ }
+ }
+
+ public GridLength ColumnUsuarios
+ {
+ get
+ {
+ //IL_0001: Unknown result type (might be due to invalid IL or missing references)
+ return _columnUsuarios;
+ }
+ 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)
+ _columnUsuarios = value;
+ OnPropertyChanged("ColumnUsuarios");
+ }
+ }
+
+ public TarefaBIViewModel()
+ {
+ //IL_0089: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0090: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0097: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ae: Expected O, but got Unknown
+ //IL_00af: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b9: Expected O, but got Unknown
+ //IL_0118: Unknown result type (might be due to invalid IL or missing references)
+ //IL_011d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_012d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0132: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01d2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01dd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01ea: Expected O, but got Unknown
+ Servico = new TarefaServico();
+ ClienteServico = new ClienteServico();
+ Administrador = ((DomainBase)Recursos.Usuario).Id == 0L || Recursos.Usuario.Administrador;
+ CarregarUsuarios();
+ List<Usuario> list = (from x in Recursos.Usuarios
+ where (Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 36) || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && !x.Excluido
+ orderby x.Nome
+ select x).ToList();
+ list.Insert(0, new Usuario
+ {
+ Nome = "TODOS OS USUÁRIOS",
+ Id = 0L
+ });
+ UsuariosFiltro = new ObservableCollection<Usuario>(list);
+ TiposTarefa = new ObservableCollection<TipoDeTarefa>(Recursos.TiposTarefa.Where((TipoDeTarefa x) => x.Ativo).ToList());
+ SelectedUsuarioFiltro = ((IEnumerable<Usuario>)UsuariosFiltro).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == ((DomainBase)Recursos.Usuario).Id)) ?? UsuariosFiltro.FirstOrDefault();
+ SelectedStatus = Status[1];
+ CarregaTarefas(permissoes: true);
+ }
+
+ public async void CarregaTarefas(bool permissoes = false)
+ {
+ if (permissoes)
+ {
+ await PermissaoTela((TipoTela)38);
+ Alterar(alterar: false);
+ }
+ await CarregarTarefas();
+ }
+
+ public async Task CarregarTarefas()
+ {
+ ColumnUsuarioPrincipal = new GridLength(1.0, (GridUnitType)2);
+ ColumnUsuarios = new GridLength(0.0, (GridUnitType)1);
+ Filtro = string.Empty;
+ TarefaServico servico = Servico;
+ Usuario selectedUsuarioFiltro = SelectedUsuarioFiltro;
+ Tarefas = new ObservableCollection<Tarefa>(from x in await servico.BuscarTarefas((selectedUsuarioFiltro != null) ? ((DomainBase)selectedUsuarioFiltro).Id : 0, Inicio, Fim, (SelectedStatus == "TODAS AS TAREFAS") ? null : new bool?(SelectedStatus != "PENDENTE"))
+ where (int)x.Entidade != 1
+ orderby x.Agendamento
+ select x);
+ TarefasFiltradas = Tarefas;
+ SelectedTarefa = TarefasFiltradas.FirstOrDefault();
+ if (FiltroTarefa.Count > 0)
+ {
+ FiltrarTarefa();
+ }
+ }
+
+ private async void WorkOnSelectedTarefa(Tarefa value)
+ {
+ if (value == null)
+ {
+ base.Responsaveis = new ObservableCollection<ResponsavelTarefa>();
+ return;
+ }
+ SelectedUsuario = ((value.Usuario != null) ? ((IEnumerable<Usuario>)Usuarios).FirstOrDefault((Func<Usuario, bool>)((Usuario x) => ((DomainBase)x).Id == ((DomainBase)value.Usuario).Id)) : null);
+ DataAgendamento = value.Agendamento;
+ HoraAgendamento = value.Agendamento;
+ Descricao = value.Descricao;
+ HistoricoInterno = value.DescricaoInterna;
+ base.Responsaveis = ((value == null) ? new ObservableCollection<ResponsavelTarefa>() : ((value.Responsaveis == null) ? new ObservableCollection<ResponsavelTarefa>() : new ObservableCollection<ResponsavelTarefa>(value.Responsaveis)));
+ if (!base.Responsaveis.Any())
+ {
+ TarefaBIViewModel tarefaBIViewModel = this;
+ Tarefa obj = value;
+ tarefaBIViewModel.Responsaveis = ((((obj != null) ? obj.Usuario : null) == null) ? new ObservableCollection<ResponsavelTarefa>() : new ObservableCollection<ResponsavelTarefa>((IEnumerable<ResponsavelTarefa>)(object)new ResponsavelTarefa[1]
+ {
+ new ResponsavelTarefa
+ {
+ Usuario = value.Usuario
+ }
+ }));
+ }
+ if (value.TipoDeTarefa != 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());
+ }
+ }
+ SelectedTipoTarefa = value.TipoDeTarefa;
+ IsVisibleCliente = (Visibility)2;
+ IsVisibleApolice = (Visibility)2;
+ IsVisibleSinistro = (Visibility)2;
+ IsVisibleArquivoDigital = (Visibility)2;
+ TipoTarefa entidade = value.Entidade;
+ switch ((int)entidade)
+ {
+ case 2:
+ IsVisibleCliente = (Visibility)0;
+ IsVisibleArquivoDigital = (Visibility)0;
+ break;
+ case 0:
+ case 3:
+ IsVisibleCliente = (Visibility)0;
+ IsVisibleApolice = (Visibility)0;
+ IsVisibleArquivoDigital = (Visibility)0;
+ break;
+ case 4:
+ IsVisibleCliente = (Visibility)0;
+ IsVisibleApolice = (Visibility)0;
+ IsVisibleSinistro = (Visibility)0;
+ IsVisibleArquivoDigital = (Visibility)0;
+ break;
+ }
+ entidade = value.Entidade;
+ if ((int)entidade != 5)
+ {
+ if ((int)entidade != 8)
+ {
+ Telefones = new ObservableCollection<TelefoneBase>((await ClienteServico.BuscarTelefonesAsync(value.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
+ {
+ Telefones = new ObservableCollection<TelefoneBase>();
+ }
+ return;
+ }
+ Prospeccao val = await new ProspeccaoServico().BuscarProspeccao(value.IdEntidade);
+ Telefones = new ObservableCollection<TelefoneBase>();
+ if (val != null && val.Telefone1 != null)
+ {
+ Telefones.Add(new TelefoneBase
+ {
+ Tipo = (TipoTelefone)(val.Telefone1.StartsWith("9") ? 3 : 7),
+ Numero = val.Telefone1,
+ Prefixo = val.Prefixo1
+ });
+ }
+ if (val != null && val.Telefone2 != null)
+ {
+ Telefones.Add(new TelefoneBase
+ {
+ Tipo = (TipoTelefone)(val.Telefone2.StartsWith("9") ? 3 : 7),
+ Numero = val.Telefone2,
+ Prefixo = val.Prefixo2
+ });
+ }
+ }
+
+ public async void Abrir(TipoTarefa tipo)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ switch ((int)tipo)
+ {
+ case 2:
+ ((Window)new HosterWindow((ContentControl)(object)new ClienteView(await CarregaCliente(SelectedTarefa.IdCliente), lockInsert: true), "CADASTRO DE CLIENTES - " + SelectedTarefa.Cliente)).Show();
+ break;
+ case 3:
+ ((Window)new HosterWindow((ContentControl)(object)new ApoliceView(await CarregaApoliceParcela(SelectedTarefa.IdEntidade), lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + SelectedTarefa.Cliente + " - " + SelectedTarefa.Referencia)).Show();
+ break;
+ case 0:
+ {
+ long num = SelectedTarefa.IdEntidade;
+ if ((int)SelectedTarefa.Entidade == 4)
+ {
+ Sinistro obj = await CarregaSinistroApolice(SelectedTarefa.IdEntidade);
+ long? obj2;
+ if (obj == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ ControleSinistro controleSinistro = obj.ControleSinistro;
+ if (controleSinistro == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Item item = controleSinistro.Item;
+ if (item == null)
+ {
+ obj2 = null;
+ }
+ else
+ {
+ Documento documento = item.Documento;
+ obj2 = ((documento != null) ? new long?(((DomainBase)documento).Id) : null);
+ }
+ }
+ }
+ long? num2 = obj2;
+ num = num2.GetValueOrDefault();
+ }
+ if (num != 0L)
+ {
+ ((Window)new HosterWindow((ContentControl)(object)new ApoliceView(await CarregaApolice(num), lockInsert: true, invoke: false, (AcessoApolice)0, 0L), "CADASTRO DE APÓLICES - " + SelectedTarefa.Cliente)).Show();
+ }
+ break;
+ }
+ case 4:
+ {
+ Sinistro val = await CarregaSinistroApolice(SelectedTarefa.IdEntidade);
+ if (val == null)
+ {
+ await ShowMessage("SINISTRO NÃO ENCONTRADO!");
+ }
+ else
+ {
+ ((Window)new HosterWindow((ContentControl)(object)new SinistroView(val.ControleSinistro.Item, attached: false), "CADASTRO DE SINISTROS - " + SelectedTarefa.Cliente + " - " + SelectedTarefa.Referencia)).Show();
+ }
+ break;
+ }
+ case 1:
+ break;
+ }
+ }
+
+ public async Task<MalaDireta> CriarMalaDireta(TipoTarefa tipo)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ switch ((int)tipo)
+ {
+ case 8:
+ return null;
+ case 2:
+ {
+ Cliente cliente = await CarregaCliente(SelectedTarefa.IdCliente);
+ return new MalaDireta
+ {
+ Cliente = cliente,
+ Tela = (TipoTela)1
+ };
+ }
+ case 3:
+ {
+ Documento val3 = await CarregaApoliceParcela(SelectedTarefa.IdEntidade);
+ return new MalaDireta
+ {
+ Cliente = val3.Controle.Cliente,
+ Apolice = val3,
+ Tela = (TipoTela)5
+ };
+ }
+ case 0:
+ {
+ Documento val2 = await CarregaApolice(SelectedTarefa.IdEntidade);
+ return new MalaDireta
+ {
+ Cliente = val2.Controle.Cliente,
+ Apolice = val2,
+ Tela = (TipoTela)2
+ };
+ }
+ case 4:
+ {
+ Sinistro val = await CarregaSinistroApolice(SelectedTarefa.IdEntidade);
+ return new MalaDireta
+ {
+ Cliente = val.ControleSinistro.Item.Documento.Controle.Cliente,
+ Apolice = val.ControleSinistro.Item.Documento,
+ Sinistro = val,
+ Tela = (TipoTela)7
+ };
+ }
+ case 5:
+ {
+ Prospeccao prospeccao = await CarregarProspeccao(SelectedTarefa.IdEntidade);
+ return new MalaDireta
+ {
+ Prospeccao = prospeccao,
+ Tela = (TipoTela)33
+ };
+ }
+ default:
+ return null;
+ }
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar(string titulo)
+ {
+ if (SelectedTarefa == null)
+ {
+ return null;
+ }
+ 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;
+ }
+ 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();
+ string text = Funcoes.GetText(SelectedTarefa.Anotacoes);
+ string text2 = Funcoes.GetText(SelectedTarefa.AnotacoesInternas);
+ if (string.IsNullOrEmpty(text) && string.IsNullOrEmpty(text2))
+ {
+ list.Add(new KeyValuePair<string, string>("Anotações", "OBRIGATÓRIO"));
+ }
+ if (list.Count > 0)
+ {
+ return list;
+ }
+ SelectedTarefa.Anotacoes = Funcoes.AdicionarLog(SelectedTarefa.Anotacoes);
+ SelectedTarefa.Descricao = SelectedTarefa.Anotacoes + " <p> " + Descricao + " </p>";
+ SelectedTarefa.DescricaoInterna = (string.IsNullOrWhiteSpace(SelectedTarefa.AnotacoesInternas) ? HistoricoInterno : (SelectedTarefa.AnotacoesInternas + " <p> " + HistoricoInterno + " </p>"));
+ SelectedTarefa.TipoDeTarefa = SelectedTipoTarefa;
+ SelectedTarefa.Titulo = titulo;
+ SelectedTarefa = await Servico.Salvar(SelectedTarefa);
+ if (!Servico.Sucesso)
+ {
+ return null;
+ }
+ long id = ((DomainBase)SelectedTarefa).Id;
+ await CarregarTarefas();
+ SelectedTarefa = ((IEnumerable<Tarefa>)TarefasFiltradas).FirstOrDefault((Func<Tarefa, bool>)((Tarefa x) => ((DomainBase)x).Id == id)) ?? TarefasFiltradas.FirstOrDefault();
+ return null;
+ }
+
+ public async Task Cancelar()
+ {
+ if (_cancelTarefa != 0L)
+ {
+ long id = _cancelTarefa;
+ await CarregarTarefas();
+ SelectedTarefa = ((IEnumerable<Tarefa>)TarefasFiltradas).FirstOrDefault((Func<Tarefa, bool>)((Tarefa x) => ((DomainBase)x).Id == id));
+ Alterar(alterar: false);
+ }
+ }
+
+ public async Task Excluir()
+ {
+ Tarefa selectedTarefa = SelectedTarefa;
+ if (selectedTarefa != null && ((DomainBase)selectedTarefa).Id == 0)
+ {
+ return;
+ }
+ TarefaBIViewModel tarefaBIViewModel = this;
+ string[] obj = new string[5] { "DESEJA REALMENTE EXCLUIR A TAREFA ", null, null, null, null };
+ Tarefa selectedTarefa2 = SelectedTarefa;
+ obj[1] = ((selectedTarefa2 != null) ? selectedTarefa2.Titulo : null);
+ obj[2] = "?";
+ obj[3] = Environment.NewLine;
+ obj[4] = "ESSE PROCEDIMENTO É IRREVERSÍVEL";
+ if (await tarefaBIViewModel.ShowMessage(string.Concat(obj), "SIM", "NÃO"))
+ {
+ if (!(await Servico.Excluir(((DomainBase)SelectedTarefa).Id)))
+ {
+ Alterar(alterar: false);
+ return;
+ }
+ await CarregarTarefas();
+ Gestor.Application.Actions.Actions.AtualizaTrilhas?.Invoke();
+ Alterar(alterar: false);
+ }
+ }
+
+ public async Task<Tarefa> ConcluirTarefa(Tarefa tarefa)
+ {
+ if (!(await ValidaPermissaoParaEditarTarefa()))
+ {
+ await ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EDITAR ESSA TAREFA!");
+ return null;
+ }
+ return await Servico.Salvar(tarefa);
+ }
+
+ public void FiltrarTarefa()
+ {
+ TarefasFiltradas = new ObservableCollection<Tarefa>(Filtrar());
+ SelectedTarefa = TarefasFiltradas.FirstOrDefault();
+ }
+
+ private List<Tarefa> Filtrar()
+ {
+ List<Tarefa> tarefas = Tarefas.ToList();
+ FiltroTarefa.ToList().ForEach(delegate(string f)
+ {
+ tarefas = tarefas.Where((Tarefa x) => ValidationHelper.RemoveDiacritics(x.Titulo).ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)) || ValidationHelper.RemoveDiacritics(x.Cliente).ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)) || ValidationHelper.RemoveDiacritics(x.Referencia).ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)) || x.Agendamento.ToString("d").ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)) || ((DomainBase)x).Id.ToString().Contains(ValidationHelper.RemoveDiacritics(f)) || (x.TipoDeTarefa != null && ValidationHelper.RemoveDiacritics(x.TipoDeTarefa.Nome).ToUpper().Contains(ValidationHelper.RemoveDiacritics(f))) || (x.Usuario != null && x.Usuario.Nome.ToUpper().Contains(ValidationHelper.RemoveDiacritics(f)))).ToList();
+ });
+ return tarefas;
+ }
+
+ public void AdcionarFiltro()
+ {
+ if (!string.IsNullOrEmpty(Filtro))
+ {
+ if (FiltroTarefa == null)
+ {
+ FiltroTarefa = new ObservableCollection<string>();
+ }
+ FiltroTarefa.Add(Filtro);
+ Filtro = string.Empty;
+ FiltrarTarefa();
+ }
+ }
+
+ public void ExcluirFiltro(string filtro)
+ {
+ FiltroTarefa.Remove(filtro);
+ FiltrarTarefa();
+ }
+
+ public async void AbrirArquivoDigital()
+ {
+ if (SelectedTarefa.IdEntidade == 0L)
+ {
+ return;
+ }
+ FiltroArquivoDigital filtro = new FiltroArquivoDigital();
+ TipoTarefa entidade = SelectedTarefa.Entidade;
+ switch ((int)entidade)
+ {
+ case 8:
+ return;
+ case 2:
+ {
+ if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)1).Consultar)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)1) + ".");
+ return;
+ }
+ Cliente val2 = await CarregaCliente(SelectedTarefa.IdCliente);
+ filtro.Id = ((DomainBase)val2).Id;
+ filtro.Tipo = (TipoArquivoDigital)1;
+ filtro.Parente = val2;
+ break;
+ }
+ case 3:
+ {
+ if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)3).Consultar)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)3) + ".");
+ return;
+ }
+ Parcela val5 = await CarregaParcela(SelectedTarefa.IdEntidade);
+ filtro.Id = ((DomainBase)val5).Id;
+ filtro.Tipo = (TipoArquivoDigital)3;
+ filtro.Parente = val5;
+ filtro.IdApolice = ((DomainBase)val5.Documento).Id;
+ break;
+ }
+ case 0:
+ {
+ if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)2).Consultar)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)2) + ".");
+ return;
+ }
+ Documento val3 = await CarregaApolice(SelectedTarefa.IdEntidade);
+ filtro.Id = ((DomainBase)val3).Id;
+ filtro.Tipo = (TipoArquivoDigital)2;
+ filtro.Parente = val3;
+ break;
+ }
+ case 4:
+ {
+ if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)5).Consultar)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)5) + ".");
+ return;
+ }
+ Sinistro val4 = await CarregaSinistroApolice(SelectedTarefa.IdEntidade);
+ filtro.Id = ((DomainBase)val4).Id;
+ filtro.Tipo = (TipoArquivoDigital)5;
+ filtro.Parente = val4;
+ filtro.IdApolice = ((DomainBase)val4.ControleSinistro.Item.Documento).Id;
+ break;
+ }
+ case 5:
+ {
+ if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)11).Consultar)
+ {
+ await ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)11) + ".");
+ return;
+ }
+ Prospeccao val = await CarregarProspeccao(SelectedTarefa.IdEntidade);
+ filtro.Id = ((DomainBase)val).Id;
+ filtro.Tipo = (TipoArquivoDigital)11;
+ filtro.Parente = val;
+ break;
+ }
+ }
+ ShowDrawer(new ArquivoDigitalDrawer(filtro), 0, close: false);
+ }
+
+ public async Task AlterarTarefa()
+ {
+ if (SelectedTarefa == null)
+ {
+ return;
+ }
+ if (!(await ValidaPermissaoParaEditarTarefa()))
+ {
+ await ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EXCLUIR ESSA TAREFA!");
+ return;
+ }
+ CarregarUsuarios();
+ Alterar(alterar: true);
+ ColumnUsuarioPrincipal = (base.EnableFields ? new GridLength(0.0, (GridUnitType)1) : new GridLength(1.0, (GridUnitType)2));
+ ColumnUsuarios = (base.EnableFields ? new GridLength(1.0, (GridUnitType)2) : new GridLength(0.0, (GridUnitType)1));
+ ListaUsuariosResponsaveis();
+ base.HasResponsaveis = true;
+ SelectedUsuario = null;
+ base.Responsaveis.ToList().ForEach(delegate(ResponsavelTarefa x)
+ {
+ Usuarios.Remove(((IEnumerable<Usuario>)Usuarios).FirstOrDefault((Func<Usuario, bool>)((Usuario u) => ((DomainBase)u).Id == ((DomainBase)x.Usuario).Id)));
+ });
+ }
+
+ 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
+ orderby x.Nome
+ select x).ToList());
+ }
+
+ public async Task AdcionarResponsavel()
+ {
+ if (!(await ValidaPermissaoParaEditarTarefa()))
+ {
+ await ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EXCLUIR ESSA TAREFA!");
+ }
+ else if (SelectedUsuario != null)
+ {
+ base.Responsaveis.Add(new ResponsavelTarefa
+ {
+ Usuario = SelectedUsuario,
+ IdTarefa = ((DomainBase)SelectedTarefa).Id
+ });
+ Usuarios.Remove(SelectedUsuario);
+ SelectedUsuario = null;
+ }
+ }
+
+ 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);
+ }
+
+ 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>";
+ }
+}