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 _status = new List { "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 _usuariosFiltro; private ObservableCollection _usuarios; private ObservableCollection _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 _tarefas; private Tarefa _selectedTarefa; private ObservableCollection _telefones; private long _cancelTarefa; private ObservableCollection _tarefasFiltradas = new ObservableCollection(); private string _filtro = ""; private ObservableCollection _filtroTarefa = new ObservableCollection(); 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 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 UsuariosFiltro { get { return _usuariosFiltro; } set { _usuariosFiltro = value; OnPropertyChanged("UsuariosFiltro"); } } public ObservableCollection Usuarios { get { return _usuarios; } set { _usuarios = value; OnPropertyChanged("Usuarios"); } } public ObservableCollection 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 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 Telefones { get { return _telefones; } set { _telefones = value; OnPropertyChanged("Telefones"); } } public ObservableCollection 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 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 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(list); TiposTarefa = new ObservableCollection(Recursos.TiposTarefa.Where((TipoDeTarefa x) => x.Ativo).ToList()); SelectedUsuarioFiltro = ((IEnumerable)UsuariosFiltro).FirstOrDefault((Func)((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(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(); return; } SelectedUsuario = ((value.Usuario != null) ? ((IEnumerable)Usuarios).FirstOrDefault((Func)((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() : ((value.Responsaveis == null) ? new ObservableCollection() : new ObservableCollection(value.Responsaveis))); if (!base.Responsaveis.Any()) { TarefaBIViewModel tarefaBIViewModel = this; Tarefa obj = value; tarefaBIViewModel.Responsaveis = ((((obj != null) ? obj.Usuario : null) == null) ? new ObservableCollection() : new ObservableCollection((IEnumerable)(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(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((await ClienteServico.BuscarTelefonesAsync(value.IdCliente)).Where((ClienteTelefone x) => ValidationHelper.ValidacaoTelefone(((TelefoneBase)x).Numero)).Select((Func)((ClienteTelefone x) => new TelefoneBase { Tipo = ((TelefoneBase)x).Tipo, Id = ((DomainBase)x).Id, Numero = ((TelefoneBase)x).Numero, Prefixo = ((TelefoneBase)x).Prefixo })).ToList()); } else { Telefones = new ObservableCollection(); } return; } Prospeccao val = await new ProspeccaoServico().BuscarProspeccao(value.IdEntidade); Telefones = new ObservableCollection(); 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 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>> 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> 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("Anotações", "OBRIGATÓRIO")); } if (list.Count > 0) { return list; } SelectedTarefa.Anotacoes = Funcoes.AdicionarLog(SelectedTarefa.Anotacoes); SelectedTarefa.Descricao = SelectedTarefa.Anotacoes + "

" + Descricao + "

"; SelectedTarefa.DescricaoInterna = (string.IsNullOrWhiteSpace(SelectedTarefa.AnotacoesInternas) ? HistoricoInterno : (SelectedTarefa.AnotacoesInternas + "

" + HistoricoInterno + "

")); 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)TarefasFiltradas).FirstOrDefault((Func)((Tarefa x) => ((DomainBase)x).Id == id)) ?? TarefasFiltradas.FirstOrDefault(); return null; } public async Task Cancelar() { if (_cancelTarefa != 0L) { long id = _cancelTarefa; await CarregarTarefas(); SelectedTarefa = ((IEnumerable)TarefasFiltradas).FirstOrDefault((Func)((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 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(Filtrar()); SelectedTarefa = TarefasFiltradas.FirstOrDefault(); } private List Filtrar() { List 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(); } 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)Usuarios).FirstOrDefault((Func)((Usuario u) => ((DomainBase)u).Id == ((DomainBase)x.Usuario).Id))); }); } private void CarregarUsuarios() { Usuarios = new ObservableCollection((from x in Recursos.Usuarios where (Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 36) || x.IdEmpresa == Recursos.Usuario.IdEmpresa) && !x.Excluido 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 = " TAREFA
"; text += "
"; text += "

"; text += "TAREFA


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

CLIENTE: " + SelectedTarefa.Cliente + "

REFERÊNCIA: " + SelectedTarefa.Referencia + "

TÍTULO: " + SelectedTarefa.Titulo + "

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

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

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

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

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

RESPONSÁVEIS VINCULADOS

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

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

"; text += "

"; } text += "

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

ANOTAÇÕES

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

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

"; text += "

"; } return text + "
"; } }