using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Threading; using Gestor.Application.Componentes; using Gestor.Application.Helpers; using Gestor.Application.Servicos; using Gestor.Application.ViewModels.Drawer; 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 MaterialDesignThemes.Wpf; using Xceed.Wpf.AvalonDock.Controls; namespace Gestor.Application.Drawers; public class TarefaDrawer : UserControl, IComponentConnector, IStyleConnector { internal ProgressBar ProgressBar; internal TextBlock TitleBox; internal DatePicker AgendamentoBox; internal ToggleButton AtivoBox; internal RadioButton AnotacoesButton; internal RadioButton AnotacoesInternasButton; internal WebEditor Anotacoes; internal WebEditor Historico; internal WebEditor AnotacoesInternas; internal WebEditor HistoricoInterno; internal DatePicker ConclusaoBox; internal ComboBox CboResponsavel; internal Snackbar Snackbar; private bool _contentLoaded; private TarefaDrawerViewModel ViewModel { get; } public TarefaDrawer(Tarefa tarefa, bool enableMenu = true) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) ViewModel = new TarefaDrawerViewModel(tarefa, enableMenu); ((FrameworkElement)this).DataContext = ViewModel; InitializeComponent(); Dispatcher dispatcher = ((DispatcherObject)this).Dispatcher; if (dispatcher != null) { dispatcher.BeginInvoke((DispatcherPriority)7, (Delegate)new Action(ContentLoad)); } ViewModel.RegistrarAcao($"ACESSOU TAREFA DE {((tarefa != null) ? ValidationHelper.GetDescription((Enum)(object)tarefa.Entidade) : null)} DO DOCUMENTO DE ID \"{((tarefa != null) ? new long?(tarefa.IdEntidade) : null)}\"", (tarefa != null) ? tarefa.IdEntidade : 0, (TipoTela)38, string.Format("TIPO DE TAREFA: {0}{1}\nID DOCUMENTO: {2}", (tarefa != null) ? ValidationHelper.GetDescription((Enum)(object)tarefa.Entidade) : null, (tarefa == null || tarefa.IdCliente != 0) ? $"\nID CLIENTE: {((tarefa != null) ? new long?(tarefa.IdCliente) : null)}" : "", (tarefa != null) ? new long?(tarefa.IdEntidade) : null)); } private void ContentLoad() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown ((ToggleButton)AnotacoesButton).IsChecked = ViewModel.IsAnotacoes; ((ToggleButton)AnotacoesInternasButton).IsChecked = !ViewModel.IsAnotacoes; ((ToggleButton)AnotacoesButton).Checked += new RoutedEventHandler(Anotacoes_OnChecked); ((ToggleButton)AnotacoesInternasButton).Checked += new RoutedEventHandler(AnotacoesInternas_OnChecked); } private void Anotacoes_OnChecked(object sender, RoutedEventArgs e) { ViewModel.IsAnotacoes = true; } private void AnotacoesInternas_OnChecked(object sender, RoutedEventArgs e) { ViewModel.IsAnotacoes = false; } private void Validar() { if (ViewModel.SelectedTarefa != null) { ViewModel.SelectedTarefa.AgendamentoRetroativo = Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 45); List> errorMessages = ViewModel.SelectedTarefa.Validate(); ((DependencyObject)(object)this).ValidateFields(errorMessages, focusField: false); } } private async void ExcluirTarefa_OnClick(object sender, RoutedEventArgs e) { Grid val = Extentions.FindVisualAncestor((DependencyObject)(Button)sender); ListBox val2 = Extentions.FindVisualAncestor((DependencyObject)(object)val); Tarefa item = (Tarefa)((ItemsControl)val2).Items[((CollectionView)((ItemsControl)val2).Items).IndexOf(((FrameworkElement)val).DataContext)]; if (!(await ViewModel.ValidaPermissaoParaExcluirTarefa(item))) { await ViewModel.ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EXCLUIR ESSA TAREFA"); } else if (await ViewModel.Excluir(item)) { ToggleSnackBar("TAREFA EXCLUÍDA COM SUCESSO."); } } public void ToggleSnackBar(string message, bool active = true) { ((ContentControl)Snackbar.Message).Content = message; Snackbar.IsActive = active; if (active) { Task.Factory.StartNew(CloseSlackBar); } } private void CloseSlackBar() { Thread.Sleep(5000); Dispatcher dispatcher = ((DispatcherObject)ProgressBar).Dispatcher; if (dispatcher != null) { dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate { ToggleSnackBar("", active: false); }); } } private void IncluirTarefa_OnClick(object sender, RoutedEventArgs e) { ((ToggleButton)AnotacoesButton).IsChecked = true; Anotacoes.Initialize(); AnotacoesInternas.Initialize(); ViewModel.Incluir(); Validar(); } private async void MenuList_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { ListBox val = (ListBox)sender; if (((Selector)val).SelectedItem != null) { ViewModel.TituloTarefas = ((Selector)val).SelectedItem.ToString().Replace("System.Windows.Controls.ListBoxItem: ", ""); await ViewModel.CarregarTarefas(((Selector)val).SelectedIndex); } } private void Status_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 ComboBox val = (ComboBox)sender; if (val != null && ((Selector)val).SelectedItem != null) { ViewModel.Concluido = (int)(StatusTarefa)((Selector)val).SelectedItem == 2; if ((int)(StatusTarefa)((Selector)val).SelectedItem == 2) { ConclusaoBox.SelectedDate = ViewModel.SelectedTarefa.Conclusao ?? Funcoes.GetNetworkTime(); } } } private async void SalvarTarefa_OnClick(object sender, RoutedEventArgs e) { ViewModel.Carregando = true; ViewModel.SelectedTarefa.Anotacoes = Anotacoes.GetHtml(); ViewModel.SelectedTarefa.AnotacoesInternas = AnotacoesInternas.GetHtml(); List> list = await ViewModel.Salvar(Anotacoes.GetText(), AnotacoesInternas.GetText()); bool num = list == null || list.Count == 0; ViewModel.Carregando = false; if (num) { ToggleSnackBar("TAREFA SALVA COM SUCESSO."); ViewModel.Alterar(alterar: false); Anotacoes.Initialize(); AnotacoesInternas.Initialize(); } else { await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); } } private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) { Snackbar.IsActive = false; } private void Fechar_OnClick(object sender, RoutedEventArgs e) { ViewModel.CloseDrawer(); } private void Alterar_OnClick(object sender, RoutedEventArgs e) { ViewModel.AlterarTarefa(); Anotacoes.Initialize(); Validar(); } private void CopyTelefoneToClipBoard_Click(object sender, RoutedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Button val = (Button)sender; if (((FrameworkElement)val).DataContext != null) { object dataContext = ((FrameworkElement)val).DataContext; TelefoneBase val2 = (TelefoneBase)((dataContext is TelefoneBase) ? dataContext : null); if (val2 != null) { (val2.Prefixo + ValidationHelper.OnlyNumber(val2.Numero)).CopyToClipboard(); ToggleSnackBar("COPIADO - " + val2.Prefixo + ValidationHelper.OnlyNumber(val2.Numero)); } } } private async void WhatsAppMessage_Click(object sender, RoutedEventArgs e) { Button val = (Button)sender; if (((FrameworkElement)val).DataContext != null) { object dataContext = ((FrameworkElement)val).DataContext; TelefoneBase val2 = (TelefoneBase)((dataContext is TelefoneBase) ? dataContext : null); if (val2 != null && !((val2.Tipo.HasValue && (int)val2.Tipo.GetValueOrDefault() == 8) ? (val2.Prefixo + val2.Numero).Clear() : ("55" + val2.Prefixo + val2.Numero.Clear())).EnviarWhatsapp()) { await ViewModel.ShowMessage("HOUVE UM PROBLEMA AO ABRIR LINK DO WHATSAPP, O LINK FOI COPIADO EM SUA MAQUINA, BASTA ABRIR O NAVEGADOR DE INTERNET E COLAR NA BARRA DE ENDEREÇOS"); } } } private async void Cancelar_OnClick(object sender, RoutedEventArgs e) { await ViewModel.Cancelar(); Anotacoes.Initialize(); AnotacoesInternas.Initialize(); } private void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) DatePicker val = (DatePicker)sender; val.Text = ValidationHelper.FormatDate(val.Text); } private void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((DatePicker)sender).SelectedDate = Funcoes.GetNetworkTime().Date; } private void AdicionarResponsavel_OnClick(object sender, RoutedEventArgs e) { ViewModel.AdcionarResponsavel(); } private async void ExcluirResponsavel_OnClick(object sender, RoutedEventArgs e) { Chip chip = (Chip)((sender is Chip) ? sender : null); if (chip == null) { return; } if (!(await ViewModel.ValidaPermissaoParaEditarTarefa())) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA EXCLUIR RESPONSÁVEL."); return; } ResponsavelTarefa val = (ResponsavelTarefa)((FrameworkElement)chip).DataContext; if (val != null) { ViewModel.Responsaveis.Remove(val); ViewModel.Usuarios.Add(val.Usuario); ViewModel.Usuarios = new ObservableCollection(ViewModel.Usuarios.OrderBy((Usuario x) => x.Nome)); } } private async void AnexoTarefa_OnClick(object sender, RoutedEventArgs e) { if (!new PermissaoArquivoDigitalServico().BuscarPermissao(Recursos.Usuario, (TipoArquivoDigital)15).Consultar) { await ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE " + ValidationHelper.GetDescription((Enum)(object)(TipoArquivoDigital)15) + "."); return; } Button val = (Button)sender; if (((FrameworkElement)val).DataContext != null) { Tarefa val2 = (Tarefa)((FrameworkElement)val).DataContext; FiltroArquivoDigital filtro = new FiltroArquivoDigital { Id = ((DomainBase)val2).Id, Tipo = (TipoArquivoDigital)15, Parente = val2 }; ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtro), 0, close: false); } } private void InxlusaoAnexoTarefa_OnClick(object sender, RoutedEventArgs e) { ViewModel.ArquivosAnexados = new ObservableCollection(ViewModel.ArquivosFinais); ViewModel.ShowDrawer(new InclusaoArquivoDigitalDrawer(ViewModel), 0, close: false); } private void Imprimir_OnClick(object sender, RoutedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Button val = (Button)sender; if (((FrameworkElement)val).DataContext != null) { Tarefa val2 = (Tarefa)((FrameworkElement)val).DataContext; if (((DomainBase)val2).Id != 0L) { ViewModel.SelectedTarefa = val2; ViewModel.Print(); } } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (!_contentLoaded) { _contentLoaded = true; Uri uri = new Uri("/Gestor.Application;component/drawers/tarefadrawer.xaml", UriKind.Relative); Application.LoadComponent((object)this, uri); } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] internal Delegate _CreateDelegate(Type delegateType, string handler) { return Delegate.CreateDelegate(delegateType, this, handler); } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] void IComponentConnector.Connect(int connectionId, object target) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown switch (connectionId) { case 1: ProgressBar = (ProgressBar)target; break; case 2: ((Selector)(ListBox)target).SelectionChanged += new SelectionChangedEventHandler(MenuList_OnSelectionChanged); break; case 3: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(Fechar_OnClick); break; case 4: TitleBox = (TextBlock)target; break; case 7: ((MenuItem)target).Click += new RoutedEventHandler(IncluirTarefa_OnClick); break; case 8: ((MenuItem)target).Click += new RoutedEventHandler(Alterar_OnClick); break; case 9: ((MenuItem)target).Click += new RoutedEventHandler(SalvarTarefa_OnClick); break; case 10: ((MenuItem)target).Click += new RoutedEventHandler(Cancelar_OnClick); break; case 11: ((MenuItem)target).Click += new RoutedEventHandler(InxlusaoAnexoTarefa_OnClick); break; case 15: AgendamentoBox = (DatePicker)target; ((UIElement)AgendamentoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus); ((Control)AgendamentoBox).MouseDoubleClick += new MouseButtonEventHandler(DataAtual_OnDoubleClick); break; case 16: AtivoBox = (ToggleButton)target; break; case 17: AnotacoesButton = (RadioButton)target; break; case 18: AnotacoesInternasButton = (RadioButton)target; break; case 19: Anotacoes = (WebEditor)target; break; case 20: Historico = (WebEditor)target; break; case 21: AnotacoesInternas = (WebEditor)target; break; case 22: HistoricoInterno = (WebEditor)target; break; case 23: ((Selector)(ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(Status_OnSelectionChanged); break; case 24: ConclusaoBox = (DatePicker)target; ((UIElement)ConclusaoBox).LostKeyboardFocus += new KeyboardFocusChangedEventHandler(DatePicker_OnLostKeyboardFocus); ((Control)ConclusaoBox).MouseDoubleClick += new MouseButtonEventHandler(DataAtual_OnDoubleClick); break; case 25: CboResponsavel = (ComboBox)target; break; case 26: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarResponsavel_OnClick); break; case 28: Snackbar = (Snackbar)target; break; case 29: ((SnackbarMessage)target).ActionClick += new RoutedEventHandler(SnackbarMessage_ActionClick); break; default: _contentLoaded = true; break; } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] void IStyleConnector.Connect(int connectionId, object target) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown switch (connectionId) { case 5: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(CopyTelefoneToClipBoard_Click); break; case 6: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(WhatsAppMessage_Click); break; case 12: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirTarefa_OnClick); break; case 13: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AnexoTarefa_OnClick); break; case 14: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(Imprimir_OnClick); break; case 27: ((Chip)target).DeleteClick += new RoutedEventHandler(ExcluirResponsavel_OnClick); break; } } }