summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs')
-rw-r--r--Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs1283
1 files changed, 1283 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs b/Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs
new file mode 100644
index 0000000..6a68199
--- /dev/null
+++ b/Codemerx/Gestor.Application/ViewModels/Drawer/TarefaDrawerViewModel.cs
@@ -0,0 +1,1283 @@
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.Servicos.Seguros;
+using Gestor.Application.ViewModels.Generic;
+using Gestor.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;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Gestor.Application.ViewModels.Drawer
+{
+ public class TarefaDrawerViewModel : BaseTarefaViewModel
+ {
+ private bool _enableMenu = true;
+
+ private GridLength _dados = new GridLength(0, GridUnitType.Pixel);
+
+ private GridLength _grid = new GridLength(1, GridUnitType.Star);
+
+ private GridLength _anotacoesLength = new GridLength(0, GridUnitType.Pixel);
+
+ private GridLength _descricaoLength = new GridLength(1, GridUnitType.Star);
+
+ private GridLength _anotacoesInternasLength = new GridLength(0, GridUnitType.Pixel);
+
+ private GridLength _descricaoInternaLength = new GridLength(1, GridUnitType.Star);
+
+ 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 Gestor.Model.Domain.Ferramentas.Tarefa _tarefa = new Gestor.Model.Domain.Ferramentas.Tarefa();
+
+ private ObservableCollection<Gestor.Model.Domain.Ferramentas.Tarefa> _tarefasFiltradas = new ObservableCollection<Gestor.Model.Domain.Ferramentas.Tarefa>();
+
+ private List<Gestor.Model.Domain.Ferramentas.Tarefa> _tarefas = new List<Gestor.Model.Domain.Ferramentas.Tarefa>();
+
+ private bool _isAnotacoes = true;
+
+ private Gestor.Model.Domain.Ferramentas.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 Gestor.Model.Domain.Common.ArquivoDigital _selectedAnexado = new Gestor.Model.Domain.Common.ArquivoDigital();
+
+ private ObservableCollection<Gestor.Model.Domain.Common.ArquivoDigital> _arquivosAnexados = new ObservableCollection<Gestor.Model.Domain.Common.ArquivoDigital>();
+
+ private List<Gestor.Model.Domain.Common.ArquivoDigital> _arquivosFinais = new List<Gestor.Model.Domain.Common.ArquivoDigital>();
+
+ private bool _inclusaoArquivoDigitalEnable = true;
+
+ public GridLength AnotacoesInternasLength
+ {
+ get
+ {
+ return this._anotacoesInternasLength;
+ }
+ set
+ {
+ this._anotacoesInternasLength = value;
+ base.OnPropertyChanged("AnotacoesInternasLength");
+ }
+ }
+
+ public GridLength AnotacoesLength
+ {
+ get
+ {
+ return this._anotacoesLength;
+ }
+ set
+ {
+ this._anotacoesLength = value;
+ base.OnPropertyChanged("AnotacoesLength");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Common.ArquivoDigital> ArquivosAnexados
+ {
+ get
+ {
+ return this._arquivosAnexados;
+ }
+ set
+ {
+ this._arquivosAnexados = value;
+ base.OnPropertyChanged("ArquivosAnexados");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Common.ArquivoDigital> ArquivosFinais
+ {
+ get
+ {
+ return this._arquivosFinais;
+ }
+ set
+ {
+ this._arquivosFinais = value;
+ base.OnPropertyChanged("ArquivosFinais");
+ }
+ }
+
+ public bool Carregando
+ {
+ get
+ {
+ return this._carregando;
+ }
+ set
+ {
+ this._carregando = value;
+ base.IsEnabled = !value;
+ base.OnPropertyChanged("Carregando");
+ }
+ }
+
+ public bool Concluido
+ {
+ get
+ {
+ return this._concluido;
+ }
+ set
+ {
+ this._concluido = value;
+ base.OnPropertyChanged("Concluido");
+ }
+ }
+
+ public GridLength Dados
+ {
+ get
+ {
+ return this._dados;
+ }
+ set
+ {
+ this._dados = value;
+ base.OnPropertyChanged("Dados");
+ }
+ }
+
+ public DateTime DataAgendamento
+ {
+ get
+ {
+ return this._dataAgendamento;
+ }
+ set
+ {
+ this._dataAgendamento = value;
+ if (this.SelectedTarefa != null)
+ {
+ this.SelectedTarefa.set_Agendamento(DateTime.Parse(string.Format("{0:d} {1:T}", value, this.SelectedTarefa.get_Agendamento())));
+ }
+ base.OnPropertyChanged("DataAgendamento");
+ }
+ }
+
+ public GridLength DescricaoInternaLength
+ {
+ get
+ {
+ return this._descricaoInternaLength;
+ }
+ set
+ {
+ this._descricaoInternaLength = value;
+ base.OnPropertyChanged("DescricaoInternaLength");
+ }
+ }
+
+ public GridLength DescricaoLength
+ {
+ get
+ {
+ return this._descricaoLength;
+ }
+ set
+ {
+ this._descricaoLength = value;
+ base.OnPropertyChanged("DescricaoLength");
+ }
+ }
+
+ public override bool EnableAlterarTarefa
+ {
+ get
+ {
+ return this._enableAlterarTarefa;
+ }
+ set
+ {
+ this._enableAlterarTarefa = this._alterarPermissEnabled & value;
+ base.OnPropertyChanged("EnableAlterarTarefa");
+ }
+ }
+
+ public GridLength Grid
+ {
+ get
+ {
+ return this._grid;
+ }
+ set
+ {
+ this._grid = value;
+ base.OnPropertyChanged("Grid");
+ }
+ }
+
+ public DateTime HoraAgendamento
+ {
+ get
+ {
+ return this._horaAgendamento;
+ }
+ set
+ {
+ this._horaAgendamento = value;
+ if (this.SelectedTarefa != null)
+ {
+ this.SelectedTarefa.set_Agendamento(DateTime.Parse(string.Format("{0:d} {1:T}", this.SelectedTarefa.get_Agendamento(), value)));
+ }
+ base.OnPropertyChanged("HoraAgendamento");
+ }
+ }
+
+ public long IdCliente
+ {
+ get;
+ set;
+ }
+
+ public bool InclusaoArquivoDigitalEnable
+ {
+ get
+ {
+ return this._inclusaoArquivoDigitalEnable;
+ }
+ set
+ {
+ this._inclusaoArquivoDigitalEnable = value;
+ base.OnPropertyChanged("InclusaoArquivoDigitalEnable");
+ }
+ }
+
+ private int Index { get; set; } = 1;
+
+ public bool IsAnotacoes
+ {
+ get
+ {
+ return this._isAnotacoes;
+ }
+ set
+ {
+ this._isAnotacoes = value;
+ base.OnPropertyChanged("IsAnotacoes");
+ }
+ }
+
+ public bool IsSelected
+ {
+ get
+ {
+ return this._isSelected;
+ }
+ set
+ {
+ this._isSelected = value;
+ base.OnPropertyChanged("IsSelected");
+ }
+ }
+
+ public bool IsVisibleDescricao
+ {
+ get
+ {
+ return this._isVisibleDescricao;
+ }
+ set
+ {
+ this._isVisibleDescricao = value;
+ base.OnPropertyChanged("IsVisibleDescricao");
+ }
+ }
+
+ public Gestor.Model.Domain.Common.ArquivoDigital SelectedAnexado
+ {
+ get
+ {
+ return this._selectedAnexado;
+ }
+ set
+ {
+ this._selectedAnexado = value;
+ base.OnPropertyChanged("SelectedAnexado");
+ }
+ }
+
+ public override Gestor.Model.Domain.Ferramentas.Tarefa SelectedTarefa
+ {
+ get
+ {
+ return this._selectedTarefa;
+ }
+ set
+ {
+ DateTime agendamento;
+ DateTime dateTime;
+ bool status;
+ ObservableCollection<ResponsavelTarefa> observableCollection;
+ bool tipoDeTarefa;
+ TipoDeTarefa tipoDeTarefa1;
+ long? nullable;
+ bool usuario;
+ ObservableCollection<ResponsavelTarefa> observableCollection1;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ this.IsSelected = value != null;
+ this._selectedTarefa = value;
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa = value;
+ if (tarefa != null)
+ {
+ agendamento = tarefa.get_Agendamento();
+ }
+ else
+ {
+ agendamento = networkTime;
+ }
+ this.DataAgendamento = agendamento;
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa1 = value;
+ if (tarefa1 != null)
+ {
+ dateTime = tarefa1.get_Agendamento();
+ }
+ else
+ {
+ dateTime = networkTime;
+ }
+ this.HoraAgendamento = dateTime;
+ this.IsVisibleDescricao = value != null;
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa2 = value;
+ if (tarefa2 != null)
+ {
+ status = tarefa2.get_Status() == 2;
+ }
+ else
+ {
+ status = false;
+ }
+ this.Concluido = status;
+ if (value == null)
+ {
+ observableCollection = new ObservableCollection<ResponsavelTarefa>();
+ }
+ else
+ {
+ observableCollection = (value.get_Responsaveis() == null ? new ObservableCollection<ResponsavelTarefa>() : new ObservableCollection<ResponsavelTarefa>(value.get_Responsaveis()));
+ }
+ base.Responsaveis = observableCollection;
+ if (!base.Responsaveis.Any<ResponsavelTarefa>())
+ {
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa3 = value;
+ if (tarefa3 != null)
+ {
+ usuario = tarefa3.get_Usuario();
+ }
+ else
+ {
+ usuario = false;
+ }
+ if (!usuario)
+ {
+ observableCollection1 = new ObservableCollection<ResponsavelTarefa>();
+ }
+ else
+ {
+ ResponsavelTarefa[] responsavelTarefaArray = new ResponsavelTarefa[1];
+ ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa();
+ responsavelTarefa.set_Usuario(value.get_Usuario());
+ responsavelTarefaArray[0] = responsavelTarefa;
+ observableCollection1 = new ObservableCollection<ResponsavelTarefa>(responsavelTarefaArray);
+ }
+ base.Responsaveis = observableCollection1;
+ }
+ if (value != null && value.get_Id() > (long)0)
+ {
+ this.AlterarTamanho(false);
+ }
+ if (value != null)
+ {
+ this.AnotacoesLength = new GridLength(0, GridUnitType.Pixel);
+ this.AnotacoesInternasLength = new GridLength(0, GridUnitType.Pixel);
+ this.DescricaoLength = (string.IsNullOrWhiteSpace(value.get_Descricao()) ? new GridLength(0, GridUnitType.Pixel) : new GridLength(1, GridUnitType.Star));
+ this.DescricaoInternaLength = (string.IsNullOrWhiteSpace(value.get_DescricaoInterna()) ? new GridLength(0, GridUnitType.Pixel) : new GridLength(1, GridUnitType.Star));
+ }
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa4 = value;
+ if (tarefa4 != null)
+ {
+ tipoDeTarefa = tarefa4.get_TipoDeTarefa();
+ }
+ else
+ {
+ tipoDeTarefa = false;
+ }
+ if (tipoDeTarefa)
+ {
+ if (!this.TiposTarefa.All<TipoDeTarefa>((TipoDeTarefa x) => x.get_Id() != value.get_Id()) || value.get_TipoDeTarefa().get_Ativo())
+ {
+ this.TiposTarefa = new ObservableCollection<TipoDeTarefa>((
+ from x in this.TiposTarefa
+ where x.get_Ativo()
+ select x).ToList<TipoDeTarefa>());
+ }
+ else
+ {
+ this.TiposTarefa.Add(value.get_TipoDeTarefa());
+ }
+ }
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa5 = value;
+ if (tarefa5 != null)
+ {
+ tipoDeTarefa1 = tarefa5.get_TipoDeTarefa();
+ }
+ else
+ {
+ tipoDeTarefa1 = null;
+ }
+ this.SelectedTipoTarefa = tipoDeTarefa1;
+ if (base.EnableIncluir || base.EnableFields || base.EnableButtons)
+ {
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa6 = value;
+ if (tarefa6 != null)
+ {
+ nullable = new long?(tarefa6.get_Id());
+ }
+ else
+ {
+ nullable = null;
+ }
+ base.VerificarEnables(nullable);
+ }
+ base.ValidaPermissaoParaEditarTarefa();
+ base.OnPropertyChanged("SelectedTarefa");
+ }
+ }
+
+ public TipoDeTarefa SelectedTipoTarefa
+ {
+ get
+ {
+ return this._selectedTipoTarefa;
+ }
+ set
+ {
+ this._selectedTipoTarefa = value;
+ base.OnPropertyChanged("SelectedTipoTarefa");
+ }
+ }
+
+ public Usuario SelectedUsuario
+ {
+ get
+ {
+ return this._selectedUsuario;
+ }
+ set
+ {
+ this._selectedUsuario = value;
+ base.OnPropertyChanged("SelectedUsuario");
+ }
+ }
+
+ private new TarefaServico Servico
+ {
+ get;
+ }
+
+ public string SubTitulo
+ {
+ get
+ {
+ return this._subTitulo;
+ }
+ set
+ {
+ this._subTitulo = value;
+ base.OnPropertyChanged("SubTitulo");
+ }
+ }
+
+ public Gestor.Model.Domain.Ferramentas.Tarefa Tarefa
+ {
+ get
+ {
+ return this._tarefa;
+ }
+ set
+ {
+ this._tarefa = value;
+ base.OnPropertyChanged("Tarefa");
+ }
+ }
+
+ public List<Gestor.Model.Domain.Ferramentas.Tarefa> Tarefas
+ {
+ get
+ {
+ return this._tarefas;
+ }
+ set
+ {
+ this._tarefas = value;
+ base.OnPropertyChanged("Tarefas");
+ }
+ }
+
+ public ObservableCollection<Gestor.Model.Domain.Ferramentas.Tarefa> TarefasFiltradas
+ {
+ get
+ {
+ return this._tarefasFiltradas;
+ }
+ set
+ {
+ this._tarefasFiltradas = value;
+ base.OnPropertyChanged("TarefasFiltradas");
+ }
+ }
+
+ public List<TelefoneBase> Telefones
+ {
+ get
+ {
+ return this._telefones;
+ }
+ set
+ {
+ this._telefones = value;
+ base.OnPropertyChanged("Telefones");
+ }
+ }
+
+ public ObservableCollection<TipoDeTarefa> TiposTarefa
+ {
+ get
+ {
+ return this._tiposTarefa;
+ }
+ set
+ {
+ this._tiposTarefa = value;
+ base.OnPropertyChanged("TiposTarefa");
+ }
+ }
+
+ public string Titulo
+ {
+ get
+ {
+ return this._titulo;
+ }
+ set
+ {
+ this._titulo = value;
+ base.OnPropertyChanged("Titulo");
+ }
+ }
+
+ public string TituloTarefas
+ {
+ get
+ {
+ return this._tituloTarefas;
+ }
+ set
+ {
+ this._tituloTarefas = value;
+ base.OnPropertyChanged("TituloTarefas");
+ }
+ }
+
+ public ObservableCollection<Usuario> Usuarios
+ {
+ get
+ {
+ return this._usuarios;
+ }
+ set
+ {
+ this._usuarios = value;
+ base.OnPropertyChanged("Usuarios");
+ }
+ }
+
+ public Visibility VisibilityMenu
+ {
+ get
+ {
+ return this._visibilityMenu;
+ }
+ set
+ {
+ this._visibilityMenu = value;
+ base.OnPropertyChanged("VisibilityMenu");
+ }
+ }
+
+ public TarefaDrawerViewModel(Gestor.Model.Domain.Ferramentas.Tarefa tarefa, bool enableMenu)
+ {
+ this.Servico = new TarefaServico();
+ this.Tarefa = tarefa;
+ this._enableMenu = enableMenu;
+ this.CarregarUsuarios();
+ this.TiposTarefa = new ObservableCollection<TipoDeTarefa>((
+ from x in Recursos.TiposTarefa
+ where x.get_Ativo()
+ select x).ToList<TipoDeTarefa>());
+ DateTime? conclusao = tarefa.get_Conclusao();
+ this.SelecionarTarefas(tarefa, new bool?(conclusao.HasValue));
+ this.TituloTarefas = (tarefa.get_Conclusao().HasValue ? "TAREFAS CONCLUÍDAS" : "TAREFAS PENDENTES");
+ base.EnableMenu = true;
+ }
+
+ public void AdcionarResponsavel()
+ {
+ if (this.SelectedUsuario == null)
+ {
+ return;
+ }
+ ObservableCollection<ResponsavelTarefa> responsaveis = base.Responsaveis;
+ ResponsavelTarefa responsavelTarefa = new ResponsavelTarefa();
+ responsavelTarefa.set_Usuario(this.SelectedUsuario);
+ responsavelTarefa.set_IdTarefa(this.SelectedTarefa.get_Id());
+ responsaveis.Add(responsavelTarefa);
+ this.Usuarios.Remove(this.SelectedUsuario);
+ this.SelectedUsuario = null;
+ }
+
+ public void AlterarTamanho(bool alterar)
+ {
+ if (!alterar)
+ {
+ if (this.TituloTarefas.Contains("TODAS"))
+ {
+ this.TituloTarefas = "TODAS TAREFAS DO CLIENTE";
+ }
+ else if (this.TituloTarefas.Contains("PENDENTES"))
+ {
+ this.TituloTarefas = "TAREFAS PENDENTES";
+ }
+ else if (this.TituloTarefas.Contains("CONCLUÍDAS"))
+ {
+ this.TituloTarefas = "TAREFAS CONCLUÍDAS";
+ }
+ }
+ this.Grid = (alterar ? new GridLength(0, GridUnitType.Star) : new GridLength(1, GridUnitType.Star));
+ this.Dados = (alterar ? new GridLength(1, GridUnitType.Star) : new GridLength(360, GridUnitType.Pixel));
+ }
+
+ public void AlterarTarefa()
+ {
+ string descricao;
+ string descricaoInterna;
+ this.CarregarUsuarios();
+ if (this.SelectedTarefa == null)
+ {
+ return;
+ }
+ this.EnableAlterarTarefa = false;
+ this.AlterarTamanho(true);
+ this.TituloTarefas = string.Concat(this.TituloTarefas, " (ALTERANDO \"", this.SelectedTarefa.get_Titulo(), "\")");
+ base.Alterar(true);
+ this.AnotacoesLength = new GridLength(1, GridUnitType.Star);
+ this.AnotacoesInternasLength = new GridLength(1, GridUnitType.Star);
+ Gestor.Model.Domain.Ferramentas.Tarefa selectedTarefa = this.SelectedTarefa;
+ if (selectedTarefa != null)
+ {
+ descricao = selectedTarefa.get_Descricao();
+ }
+ else
+ {
+ descricao = null;
+ }
+ this.DescricaoLength = (string.IsNullOrWhiteSpace(descricao) ? new GridLength(0, GridUnitType.Pixel) : new GridLength(1, GridUnitType.Star));
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa = this.SelectedTarefa;
+ if (tarefa != null)
+ {
+ descricaoInterna = tarefa.get_DescricaoInterna();
+ }
+ else
+ {
+ descricaoInterna = null;
+ }
+ this.DescricaoInternaLength = (string.IsNullOrWhiteSpace(descricaoInterna) ? new GridLength(0, GridUnitType.Pixel) : new GridLength(1, GridUnitType.Star));
+ this.TarefasFiltradas = new ObservableCollection<Gestor.Model.Domain.Ferramentas.Tarefa>()
+ {
+ this.SelectedTarefa
+ };
+ base.ListaUsuariosResponsaveis();
+ base.Responsaveis.ToList<ResponsavelTarefa>().ForEach((ResponsavelTarefa x) => this.Usuarios.Remove(x.get_Usuario()));
+ }
+
+ public async void Anexar()
+ {
+ this.InclusaoArquivoDigitalEnable = false;
+ List<Gestor.Model.Domain.Common.ArquivoDigital> arquivoDigitals = await base.AddAttachments(this.ArquivosAnexados.ToList<Gestor.Model.Domain.Common.ArquivoDigital>(), new List<Gestor.Model.Domain.Common.ArquivoDigital>());
+ await Task.Run(async () => {
+ await Task.Delay(200);
+ this.InclusaoArquivoDigitalEnable = true;
+ });
+ if (arquivoDigitals != null)
+ {
+ arquivoDigitals.AddRange(this.ArquivosAnexados);
+ this.ArquivosAnexados = new ObservableCollection<Gestor.Model.Domain.Common.ArquivoDigital>(arquivoDigitals);
+ }
+ arquivoDigitals = null;
+ }
+
+ public async Task Cancelar()
+ {
+ long id;
+ this.CarregarUsuarios();
+ this.AlterarTamanho(false);
+ Gestor.Model.Domain.Ferramentas.Tarefa selectedTarefa = this.SelectedTarefa;
+ if (selectedTarefa != null)
+ {
+ id = selectedTarefa.get_Id();
+ }
+ else
+ {
+ id = (long)0;
+ }
+ long num = id;
+ await this.CarregarTarefas(this.Index);
+ base.Alterar(false);
+ await base.ValidaPermissaoParaEditarTarefa();
+ if (num != 0)
+ {
+ this.SelectedTarefa = this.TarefasFiltradas.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Tarefa>((Gestor.Model.Domain.Ferramentas.Tarefa x) => x.get_Id() == num);
+ }
+ }
+
+ public async void CarregarInformacoes(Gestor.Model.Domain.Ferramentas.Tarefa tarefa)
+ {
+ string str;
+ string str1;
+ ClienteServico clienteServico = new ClienteServico();
+ TarefaDrawerViewModel tarefaDrawerViewModel = this;
+ str = (tarefa.get_IdEntidade() != 0 ? "TODAS AS TAREFAS PENDENTES DO CLIENTE" : "");
+ tarefaDrawerViewModel.SubTitulo = str;
+ this.IdCliente = tarefa.get_IdCliente();
+ this.Titulo = tarefa.get_Cliente();
+ ObservableCollection<ClienteTelefone> observableCollection = await clienteServico.BuscarTelefonesAsync(tarefa.get_IdCliente());
+ TarefaDrawerViewModel list = this;
+ ObservableCollection<ClienteTelefone> observableCollection1 = observableCollection;
+ IEnumerable<ClienteTelefone> clienteTelefones =
+ from x in observableCollection1
+ where Gestor.Model.Helper.ValidationHelper.ValidacaoTelefone(x.get_Numero())
+ select x;
+ list.Telefones = clienteTelefones.Select<ClienteTelefone, TelefoneBase>((ClienteTelefone x) => {
+ TelefoneBase telefoneBase = new TelefoneBase();
+ telefoneBase.set_Tipo(x.get_Tipo());
+ telefoneBase.set_Id(x.get_Id());
+ telefoneBase.set_Numero(x.get_Numero());
+ telefoneBase.set_Prefixo(x.get_Prefixo());
+ return telefoneBase;
+ }).ToList<TelefoneBase>();
+ if (tarefa.get_IdEntidade() != 0)
+ {
+ TipoTarefa entidade = tarefa.get_Entidade();
+ if (entidade == null)
+ {
+ Documento documento = await (new ApoliceServico()).BuscarApoliceAsync(tarefa.get_IdEntidade(), false, false);
+ this.IdCliente = documento.get_Controle().get_Cliente().get_Id();
+ this.Titulo = documento.get_Controle().get_Cliente().get_Nome();
+ TarefaDrawerViewModel tarefaDrawerViewModel1 = this;
+ if (documento.get_Tipo() != 0 || string.IsNullOrWhiteSpace(documento.get_Apolice()))
+ {
+ str1 = (documento.get_Tipo() > 0 ? string.Concat("APÓLICE NÚMERO ", documento.get_Apolice(), " ENDOSSO ", documento.get_Endosso()) : string.Concat("PROPOSTA NÚMERO ", documento.get_Proposta()));
+ }
+ else
+ {
+ str1 = string.Concat("APÓLICE NÚMERO ", documento.get_Apolice());
+ }
+ tarefaDrawerViewModel1.SubTitulo = str1;
+ observableCollection = await clienteServico.BuscarTelefonesAsync(documento.get_Controle().get_Cliente().get_Id());
+ TarefaDrawerViewModel list1 = this;
+ ObservableCollection<ClienteTelefone> observableCollection2 = observableCollection;
+ IEnumerable<ClienteTelefone> clienteTelefones1 =
+ from x in observableCollection2
+ where Gestor.Model.Helper.ValidationHelper.ValidacaoTelefone(x.get_Numero())
+ select x;
+ list1.Telefones = clienteTelefones1.Select<ClienteTelefone, TelefoneBase>((ClienteTelefone x) => {
+ TelefoneBase telefoneBase = new TelefoneBase();
+ telefoneBase.set_Tipo(x.get_Tipo());
+ telefoneBase.set_Id(x.get_Id());
+ telefoneBase.set_Numero(x.get_Numero());
+ telefoneBase.set_Prefixo(x.get_Prefixo());
+ return telefoneBase;
+ }).ToList<TelefoneBase>();
+ }
+ else if (entidade == 4)
+ {
+ Sinistro sinistro = await (new SinistroServico()).BuscarSinistro(tarefa.get_IdEntidade());
+ if (sinistro != null)
+ {
+ this.IdCliente = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Id();
+ this.Titulo = sinistro.get_ControleSinistro().get_Item().get_Documento().get_Controle().get_Cliente().get_Nome();
+ this.SubTitulo = string.Concat("SINISTRO ", sinistro.get_Numero(), " ITEM ", sinistro.get_ItemSinistrado());
+ observableCollection = await clienteServico.BuscarTelefonesAsync(this.IdCliente);
+ TarefaDrawerViewModel list2 = this;
+ ObservableCollection<ClienteTelefone> observableCollection3 = observableCollection;
+ IEnumerable<ClienteTelefone> clienteTelefones2 =
+ from x in observableCollection3
+ where Gestor.Model.Helper.ValidationHelper.ValidacaoTelefone(x.get_Numero())
+ select x;
+ list2.Telefones = clienteTelefones2.Select<ClienteTelefone, TelefoneBase>((ClienteTelefone x) => {
+ TelefoneBase telefoneBase = new TelefoneBase();
+ telefoneBase.set_Tipo(x.get_Tipo());
+ telefoneBase.set_Id(x.get_Id());
+ telefoneBase.set_Numero(x.get_Numero());
+ telefoneBase.set_Prefixo(x.get_Prefixo());
+ return telefoneBase;
+ }).ToList<TelefoneBase>();
+ }
+ else
+ {
+ clienteServico = null;
+ return;
+ }
+ }
+ }
+ clienteServico = null;
+ }
+
+ public async Task CarregarTarefas(int index)
+ {
+ List<Gestor.Model.Domain.Ferramentas.Tarefa> tarefas;
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa;
+ if (this.Tarefa.get_IdEntidade() != 0)
+ {
+ this.Carregando = true;
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa1 = new Gestor.Model.Domain.Ferramentas.Tarefa();
+ tarefa1.set_Cliente(this.Tarefa.get_Cliente());
+ tarefa1.set_IdCliente(this.Tarefa.get_IdCliente());
+ tarefa1.set_Entidade(this.Tarefa.get_Entidade());
+ tarefa1.set_IdEntidade(this.Tarefa.get_IdEntidade());
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa2 = tarefa1;
+ this.Index = index;
+ int num = index;
+ if (num == 1)
+ {
+ this.CarregarInformacoes(tarefa2);
+ tarefas = await this.Servico.BuscarTarefas(this.Tarefa.get_Entidade(), this.Tarefa.get_IdEntidade(), new bool?(false));
+ }
+ else if (num == 2)
+ {
+ tarefa2.set_Entidade(2);
+ this.CarregarInformacoes(tarefa2);
+ tarefas = await this.Servico.BuscarTarefasCliente(this.Tarefa.get_IdCliente());
+ }
+ else
+ {
+ this.CarregarInformacoes(tarefa2);
+ tarefas = await this.Servico.BuscarTarefas(this.Tarefa.get_Entidade(), this.Tarefa.get_IdEntidade(), new bool?(true));
+ }
+ TarefaDrawerViewModel list = this;
+ List<Gestor.Model.Domain.Ferramentas.Tarefa> tarefas1 = tarefas;
+ list.Tarefas = (
+ from x in tarefas1
+ orderby x.get_Agendamento() descending
+ select x).ToList<Gestor.Model.Domain.Ferramentas.Tarefa>();
+ this.TarefasFiltradas = new ObservableCollection<Gestor.Model.Domain.Ferramentas.Tarefa>(this.Tarefas);
+ TarefaDrawerViewModel tarefaDrawerViewModel = this;
+ if (this.TarefasFiltradas == null || this.TarefasFiltradas.Count == 0)
+ {
+ tarefa = null;
+ }
+ else
+ {
+ tarefa = (tarefa2.get_Id() != 0 ? this.TarefasFiltradas.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Tarefa>((Gestor.Model.Domain.Ferramentas.Tarefa x) => x.get_Id() == tarefa2.get_Id()) : this.TarefasFiltradas.First<Gestor.Model.Domain.Ferramentas.Tarefa>());
+ }
+ tarefaDrawerViewModel.SelectedTarefa = tarefa;
+ this.Carregando = false;
+ }
+ }
+
+ public async Task CarregarTarefas(Gestor.Model.Domain.Ferramentas.Tarefa tarefa, bool? concluido)
+ {
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa1;
+ this.Carregando = true;
+ if (tarefa.get_IdEntidade() != 0)
+ {
+ List<Gestor.Model.Domain.Ferramentas.Tarefa> tarefas = await this.Servico.BuscarTarefas(tarefa.get_Entidade(), tarefa.get_IdEntidade(), concluido);
+ TarefaDrawerViewModel list = this;
+ List<Gestor.Model.Domain.Ferramentas.Tarefa> tarefas1 = tarefas;
+ list.Tarefas = (
+ from x in tarefas1
+ orderby x.get_Agendamento()
+ select x).ToList<Gestor.Model.Domain.Ferramentas.Tarefa>();
+ this.TarefasFiltradas = new ObservableCollection<Gestor.Model.Domain.Ferramentas.Tarefa>(this.Tarefas);
+ TarefaDrawerViewModel tarefaDrawerViewModel = this;
+ if (this.TarefasFiltradas == null || this.TarefasFiltradas.Count == 0)
+ {
+ tarefa1 = null;
+ }
+ else
+ {
+ tarefa1 = (tarefa.get_Id() != 0 ? this.TarefasFiltradas.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Tarefa>((Gestor.Model.Domain.Ferramentas.Tarefa x) => x.get_Id() == tarefa.get_Id()) : this.TarefasFiltradas.First<Gestor.Model.Domain.Ferramentas.Tarefa>());
+ }
+ tarefaDrawerViewModel.SelectedTarefa = tarefa1;
+ }
+ else if (tarefa.get_Id() > (long)0)
+ {
+ this.SelectedTarefa = await this.Servico.BuscarTarefa(tarefa.get_Id());
+ }
+ this.Carregando = false;
+ }
+
+ private void CarregarUsuarios()
+ {
+ this.Usuarios = new ObservableCollection<Usuario>(Recursos.Usuarios.Where<Usuario>((Usuario x) => {
+ if (!Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema c) => c.get_Configuracao() == 36) && x.get_IdEmpresa() != Recursos.Usuario.get_IdEmpresa() || x.get_Excluido())
+ {
+ return false;
+ }
+ long? permissaoAggilizador = x.get_PermissaoAggilizador();
+ long num = (long)4;
+ return !(permissaoAggilizador.GetValueOrDefault() == num & permissaoAggilizador.HasValue);
+ }).OrderBy<Usuario, string>((Usuario x) => x.get_Nome()).ToList<Usuario>());
+ }
+
+ public void Delete(Gestor.Model.Domain.Common.ArquivoDigital arquivo)
+ {
+ if (this.SelectedAnexado == null)
+ {
+ return;
+ }
+ Gestor.Model.Domain.Common.ArquivoDigital arquivoDigital = this.ArquivosAnexados.First<Gestor.Model.Domain.Common.ArquivoDigital>((Gestor.Model.Domain.Common.ArquivoDigital x) => x.get_Descricao() == arquivo.get_Descricao());
+ this.ArquivosAnexados.Remove(arquivoDigital);
+ this.ArquivosAnexados = new ObservableCollection<Gestor.Model.Domain.Common.ArquivoDigital>(this.ArquivosAnexados);
+ }
+
+ public async void Editar(IndiceArquivoDigital arquivo)
+ {
+ if (arquivo != null && arquivo.get_IdArquivoDigital() != 0)
+ {
+ await this.ArquivoDigitalServico.Save(arquivo);
+ }
+ }
+
+ public async Task<bool> Excluir(Gestor.Model.Domain.Ferramentas.Tarefa item)
+ {
+ bool flag;
+ string titulo;
+ if (this.VisibilityMenu != Visibility.Collapsed)
+ {
+ string[] strArrays = new string[] { "DESEJA REALMENTE EXCLUIR A TAREFA ", item.get_Titulo(), "?", Environment.NewLine, "ESSE PROCEDIMENTO É IRREVERSÍVEL" };
+ if (await base.ShowMessage(string.Concat(strArrays), "SIM", "NÃO", false))
+ {
+ titulo = item.get_Titulo();
+ long id = item.get_Id();
+ if (await this.Servico.Excluir(item.get_Id()))
+ {
+ base.RegistrarAcao("EXCLUIU TAREFA", item.get_Id(), new TipoTela?(38), string.Format("TAREFA \"{0}\", ID: {1}", titulo, id));
+ await this.CarregarTarefas(this.Index);
+ base.Alterar(false);
+ flag = true;
+ }
+ else
+ {
+ base.Alterar(false);
+ flag = true;
+ }
+ }
+ else
+ {
+ flag = false;
+ }
+ }
+ else
+ {
+ await base.ShowMessage("NÃO É POSSÍVEL EXCLUIR TAREFA PELO RELATÓRIO!", "OK", "", false);
+ flag = false;
+ }
+ titulo = null;
+ return flag;
+ }
+
+ public string GerarHtml()
+ {
+ string nome;
+ string str = "<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'>";
+ str = string.Concat(str, "<br>");
+ str = string.Concat(str, "<table border='0' width='999'><td height='20' width='999' bgcolor='black'><h4 style='text-align: center; color: white; background-color: black'>");
+ str = string.Concat(str, "TAREFA</h4></td></table><br>");
+ str = string.Concat(str, "<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;
+ string[] cliente = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ int num1 = num;
+ num = num1 + 1;
+ cliente[2] = (num1 % 2 == 0 ? "WhiteSmoke" : "White");
+ cliente[3] = "'><p align='left'><b>CLIENTE: </b>";
+ cliente[4] = this.SelectedTarefa.get_Cliente();
+ cliente[5] = "</p></td></tr>";
+ str = string.Concat(cliente);
+ string[] referencia = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ int num2 = num;
+ num = num2 + 1;
+ referencia[2] = (num2 % 2 == 0 ? "WhiteSmoke" : "White");
+ referencia[3] = "'><p align='left'><b>REFERÊNCIA: </b>";
+ referencia[4] = this.SelectedTarefa.get_Referencia();
+ referencia[5] = "</p></td></tr>";
+ str = string.Concat(referencia);
+ string[] titulo = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ int num3 = num;
+ num = num3 + 1;
+ titulo[2] = (num3 % 2 == 0 ? "WhiteSmoke" : "White");
+ titulo[3] = "'><p align='left'><b>TÍTULO: </b>";
+ titulo[4] = this.SelectedTarefa.get_Titulo();
+ titulo[5] = "</p></td></tr>";
+ str = string.Concat(titulo);
+ string[] strArrays = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ int num4 = num;
+ num = num4 + 1;
+ strArrays[2] = (num4 % 2 == 0 ? "WhiteSmoke" : "White");
+ strArrays[3] = "'><p align='left'><b>AGENDAMENTO: </b>";
+ DateTime agendamento = this.SelectedTarefa.get_Agendamento();
+ strArrays[4] = agendamento.ToString();
+ strArrays[5] = "</p></td></tr>";
+ str = string.Concat(strArrays);
+ string[] nome1 = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ int num5 = num;
+ num = num5 + 1;
+ nome1[2] = (num5 % 2 == 0 ? "WhiteSmoke" : "White");
+ nome1[3] = "'><p align='left'><b>RESPONSÁVEL PRINCIPAL: </b>";
+ nome1[4] = this.SelectedTarefa.get_Usuario().get_Nome();
+ nome1[5] = "</p></td></tr>";
+ str = string.Concat(nome1);
+ string[] description = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ int num6 = num;
+ num = num6 + 1;
+ description[2] = (num6 % 2 == 0 ? "WhiteSmoke" : "White");
+ description[3] = "'><p align='left'><b>STATUS: </b>";
+ description[4] = Gestor.Common.Validation.ValidationHelper.GetDescription(this.SelectedTarefa.get_Status());
+ description[5] = "</p></td></tr>";
+ str = string.Concat(description);
+ string[] strArrays1 = new string[] { str, "<tr><td width='333' bgcolor='", null, null, null, null };
+ strArrays1[2] = (num % 2 == 0 ? "WhiteSmoke" : "White");
+ strArrays1[3] = "'><p align='left'><b>TIPO DE TAREFA: </b>";
+ TipoDeTarefa selectedTipoTarefa = this.SelectedTipoTarefa;
+ if (selectedTipoTarefa != null)
+ {
+ nome = selectedTipoTarefa.get_Nome();
+ }
+ else
+ {
+ nome = null;
+ }
+ strArrays1[4] = nome;
+ strArrays1[5] = "</p></td></tr>";
+ str = string.Concat(strArrays1);
+ str = string.Concat(str, "</font></table>");
+ if (base.Responsaveis != null && base.Responsaveis.Count > 0)
+ {
+ str = string.Concat(str, "<h2>RESPONSÁVEIS VINCULADOS</h2>");
+ str = string.Concat(str, "<br>");
+ str = string.Concat(str, "<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> strs = new List<string>();
+ foreach (ResponsavelTarefa responsavei in base.Responsaveis)
+ {
+ strs.Add(responsavei.get_Usuario().get_Nome().Trim().ToUpper());
+ }
+ str = string.Concat(str, "<tr><td width='333'><p align='left'>", string.Join(", ", strs), "</p></td></tr>");
+ str = string.Concat(str, "</font></table>");
+ str = string.Concat(str, "<br><br>");
+ }
+ str = string.Concat(str, "<br><br>");
+ if (this.SelectedTarefa.get_Descricao() != null)
+ {
+ str = string.Concat(str, "<h2>ANOTAÇÕES</h2>");
+ str = string.Concat(str, "<br>");
+ str = string.Concat(str, "<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 %)'>");
+ str = string.Concat(str, "<tr><td width='333'><p align='left'>", this.SelectedTarefa.get_Descricao().Replace("<BODY>", "").Replace("</BODY>", ""), "</p></td></tr>");
+ str = string.Concat(str, "</font></table>");
+ str = string.Concat(str, "<br><br>");
+ }
+ str = string.Concat(str, "</div></body>");
+ return str;
+ }
+
+ public async Task Incluir()
+ {
+ TarefaDrawerViewModel observableCollection = this;
+ observableCollection.CarregarUsuarios();
+ observableCollection.Responsaveis = new ObservableCollection<ResponsavelTarefa>();
+ TarefaDrawerViewModel tarefaDrawerViewModel = observableCollection;
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa = new Gestor.Model.Domain.Ferramentas.Tarefa();
+ tarefa.set_IdCliente(observableCollection.IdCliente);
+ tarefa.set_Cliente(observableCollection.Titulo);
+ tarefa.set_Referencia(observableCollection.SubTitulo);
+ tarefa.set_Entidade(observableCollection.Tarefa.get_Entidade());
+ tarefa.set_IdEntidade(observableCollection.Tarefa.get_IdEntidade());
+ tarefa.set_Trilha(observableCollection.Tarefa.get_Trilha());
+ tarefa.set_Status(0);
+ tarefa.set_Agendamento(Funcoes.GetNetworkTime().AddHours(1));
+ tarefa.set_UsuarioCadastro(Recursos.Usuario);
+ ObservableCollection<Usuario> usuarios = observableCollection.Usuarios;
+ tarefa.set_Usuario(usuarios.FirstOrDefault<Usuario>((Usuario x) => x.get_Id() == Recursos.Usuario.get_Id()));
+ tarefa.set_Restrito(new bool?(false));
+ tarefa.set_Responsaveis(observableCollection.Responsaveis.ToList<ResponsavelTarefa>());
+ tarefaDrawerViewModel.SelectedTarefa = tarefa;
+ observableCollection.ArquivosFinais = new List<Gestor.Model.Domain.Common.ArquivoDigital>();
+ observableCollection.AlterarTamanho(true);
+ observableCollection.TituloTarefas = string.Concat(observableCollection.TituloTarefas, " (INCLUINDO)");
+ observableCollection.Alterar(true);
+ observableCollection.AnotacoesLength = new GridLength(1, GridUnitType.Star);
+ observableCollection.AnotacoesInternasLength = new GridLength(1, GridUnitType.Star);
+ observableCollection.DescricaoLength = new GridLength(0, GridUnitType.Pixel);
+ observableCollection.DescricaoInternaLength = new GridLength(0, GridUnitType.Pixel);
+ observableCollection.EnableAlterarTarefa = false;
+ }
+
+ public void LimparAnexos()
+ {
+ this.ArquivosAnexados = new ObservableCollection<Gestor.Model.Domain.Common.ArquivoDigital>();
+ }
+
+ public void Print()
+ {
+ string str = this.GerarHtml();
+ string tempPath = Path.GetTempPath();
+ string str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (TipoTela)38, Funcoes.GetNetworkTime());
+ StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8);
+ streamWriter.Write(str);
+ streamWriter.Close();
+ Process.Start(str1);
+ base.RegistrarAcao("IMPRIMIU A TAREFA", this.SelectedTarefa.get_Id(), new TipoTela?(38), string.Format("TAREFA \"{0}\", ID: {1}", this.SelectedTarefa.get_Titulo(), this.SelectedTarefa.get_Id()));
+ }
+
+ public async Task<List<KeyValuePair<string, string>>> Salvar(string anotacoes, string anotacoesInternas)
+ {
+ List<KeyValuePair<string, string>> keyValuePairs;
+ Usuario usuario;
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
+ if (configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 45) && this.SelectedTarefa.get_Status() != 2 && this.SelectedTarefa.get_Agendamento() < networkTime)
+ {
+ this.SelectedTarefa.set_Agendamento(networkTime);
+ }
+ if (this.SelectedTarefa.get_Status() == 2)
+ {
+ this.SelectedTarefa.set_Conclusao(new DateTime?(networkTime));
+ }
+ if (this.SelectedTarefa.get_Status() == null)
+ {
+ this.SelectedTarefa.set_Conclusao(null);
+ }
+ this.SelectedTarefa.set_Responsaveis(base.Responsaveis.ToList<ResponsavelTarefa>());
+ Gestor.Model.Domain.Ferramentas.Tarefa selectedTarefa = this.SelectedTarefa;
+ ResponsavelTarefa responsavelTarefa = base.Responsaveis.FirstOrDefault<ResponsavelTarefa>();
+ if (responsavelTarefa != null)
+ {
+ usuario = responsavelTarefa.get_Usuario();
+ }
+ else
+ {
+ usuario = null;
+ }
+ selectedTarefa.set_Usuario(usuario);
+ Gestor.Model.Domain.Ferramentas.Tarefa tarefa = this.SelectedTarefa;
+ List<ConfiguracaoSistema> configuracaoSistemas = Recursos.Configuracoes;
+ tarefa.set_AgendamentoRetroativo(configuracaoSistemas.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 45));
+ List<KeyValuePair<string, string>> keyValuePairs1 = this.SelectedTarefa.Validate();
+ if (this.SelectedTarefa.get_Descricao() == null && string.IsNullOrWhiteSpace(anotacoes) && string.IsNullOrWhiteSpace(anotacoesInternas))
+ {
+ keyValuePairs1.Add(new KeyValuePair<string, string>("ANOTAÇÕES", "OBRIGATÓRIO"));
+ }
+ if (keyValuePairs1.Count <= 0)
+ {
+ if (!string.IsNullOrWhiteSpace(anotacoes))
+ {
+ this.SelectedTarefa.set_Anotacoes(Funcoes.AdicionarLog(this.SelectedTarefa.get_Anotacoes()));
+ this.SelectedTarefa.set_Descricao(string.Concat(this.SelectedTarefa.get_Anotacoes(), " <p> ", this.SelectedTarefa.get_Descricao(), " </p>"));
+ }
+ if (!string.IsNullOrWhiteSpace(anotacoesInternas))
+ {
+ this.SelectedTarefa.set_AnotacoesInternas(Funcoes.AdicionarLog(this.SelectedTarefa.get_AnotacoesInternas()));
+ this.SelectedTarefa.set_DescricaoInterna(string.Concat(this.SelectedTarefa.get_AnotacoesInternas(), " <p> ", this.SelectedTarefa.get_DescricaoInterna(), " </p>"));
+ }
+ this.SelectedTarefa.set_TipoDeTarefa(this.SelectedTipoTarefa);
+ bool id = this.SelectedTarefa.get_Id() == (long)0;
+ this.SelectedTarefa = await this.Servico.Salvar(this.SelectedTarefa);
+ string str = (id ? "INCLUIU" : "ALTEROU");
+ base.RegistrarAcao(string.Concat(str, " TAREFA"), this.SelectedTarefa.get_Id(), new TipoTela?(38), string.Format("TAREFA \"{0}\", ID: {1}", this.SelectedTarefa.get_Titulo(), this.SelectedTarefa.get_Id()));
+ if (id)
+ {
+ foreach (Gestor.Model.Domain.Common.ArquivoDigital arquivosFinai in this.ArquivosFinais)
+ {
+ arquivosFinai.set_IdTarefa(this.SelectedTarefa.get_Id());
+ }
+ await this.ArquivoDigitalServico.Insert(this.ArquivosFinais);
+ }
+ if (this.Servico.Sucesso)
+ {
+ long num = this.SelectedTarefa.get_Id();
+ await this.CarregarTarefas(this.Index);
+ this.SelectedTarefa = this.TarefasFiltradas.FirstOrDefault<Gestor.Model.Domain.Ferramentas.Tarefa>((Gestor.Model.Domain.Ferramentas.Tarefa x) => x.get_Id() == num);
+ keyValuePairs = null;
+ }
+ else
+ {
+ keyValuePairs = null;
+ }
+ }
+ else
+ {
+ keyValuePairs = keyValuePairs1;
+ }
+ return keyValuePairs;
+ }
+
+ public void SalvarAnexos()
+ {
+ this.ArquivosFinais = this.ArquivosAnexados.ToList<Gestor.Model.Domain.Common.ArquivoDigital>();
+ }
+
+ public async void SelecionarTarefas(Gestor.Model.Domain.Ferramentas.Tarefa tarefa, bool? concluido)
+ {
+ await base.PermissaoTela(38);
+ this.CarregarInformacoes(tarefa);
+ await this.CarregarTarefas(tarefa, concluido);
+ if (tarefa.get_Id() != 0 && !this._enableMenu)
+ {
+ this.VisibilityMenu = Visibility.Collapsed;
+ }
+ }
+ }
+} \ No newline at end of file