using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using Gestor.Application.Helpers; using Gestor.Application.ViewModels.BI; using Gestor.Application.Views.Generic; using Gestor.Model.Common; using Gestor.Model.Domain.Ferramentas; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.Seguros; namespace Gestor.Application.Views.BI; public class NotasView : BaseUserControl, IComponentConnector, IStyleConnector { internal ProgressBar ProgressRing; private bool _contentLoaded; public NotasViewModel ViewModel { get; set; } public NotasView() { ViewModel = new NotasViewModel(); ((FrameworkElement)this).DataContext = ViewModel; InitializeComponent(); } private static object GetDataFromListBox(ItemsControl source, Point point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) IInputElement obj = ((UIElement)source).InputHitTest(point); UIElement val = (UIElement)(object)((obj is UIElement) ? obj : null); if (val == null) { return null; } object obj2 = DependencyProperty.UnsetValue; while (obj2 == DependencyProperty.UnsetValue) { if (val != null) { obj2 = source.ItemContainerGenerator.ItemFromContainer((DependencyObject)(object)val); if (obj2 == DependencyProperty.UnsetValue) { DependencyObject parent = VisualTreeHelper.GetParent((DependencyObject)(object)val); val = (UIElement)(object)((parent is UIElement) ? parent : null); } if (val == source) { return null; } } } if (obj2 == DependencyProperty.UnsetValue) { return null; } return obj2; } private async void AdicionarNota_OnClick(object sender, RoutedEventArgs e) { await ViewModel.AdicionarNota(); } private async void ListBox_OnPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { ListBox val = (ListBox)sender; object dataFromListBox = GetDataFromListBox((ItemsControl)(object)val, ((MouseEventArgs)e).GetPosition((IInputElement)(object)val)); if (dataFromListBox != null) { Tarefa val2 = new Tarefa(); DomainBase.Copy(val2, (Tarefa)dataFromListBox); val2.UsuariosVinculados = val2.Responsaveis?.Select((ResponsavelTarefa x) => x.Usuario).ToList(); await AbrirNota(val2, (int)val2.Entidade == 1, (int)val2.Entidade == 1); } } private async Task AbrirNota(Tarefa data, bool notaBool = false, bool agendamento = false) { while (true) { Tarefa nota = await ViewModel.ShowTarefaDialog(data, notaBool, agendamento); if (nota == null) { return; } if (nota.Usuario == null) { nota.Usuario = nota.UsuariosVinculados.FirstOrDefault(); } List responsaveis = ((IEnumerable)nota.UsuariosVinculados).Select((Func)((Usuario x) => new ResponsavelTarefa { IdTarefa = ((DomainBase)nota).Id, Usuario = x })).ToList(); nota.Responsaveis = responsaveis; ViewModel.Loading(isLoading: true); List> list = await ViewModel.Salvar(nota); ViewModel.Loading(isLoading: false); if (list == null || list.Count == 0) { break; } await ViewModel.ShowMessage(list, ViewModel.ErroCamposInvalidos, "OK"); } ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO."); await ViewModel.CarregarNotas(); } private async void NotaConcluida_OnClick(object sender, RoutedEventArgs e) { object dataContext = ((FrameworkElement)(Button)sender).DataContext; Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null); if (val != null) { val.Conclusao = Funcoes.GetNetworkTime(); val.Status = (StatusTarefa)2; await ViewModel.SalvarNota(val); await ViewModel.CarregarNotas(); } } private void ToggleNotasConcluidas_OnClick(object sender, RoutedEventArgs e) { ViewModel.ToggleNotasConcluidas(); } private async void ExcluirNota_OnClick(object sender, RoutedEventArgs e) { object dataContext = ((FrameworkElement)(Button)sender).DataContext; Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null); if (val != null) { await ViewModel.ExcluirNota(val); await ViewModel.CarregarNotas(); } } private async void SarvarNota_OnClick(object sender, RoutedEventArgs e) { object dataContext = ((FrameworkElement)(Button)sender).DataContext; Tarefa val = (Tarefa)((dataContext is Tarefa) ? dataContext : null); if (val != null) { ViewModel.Loading(isLoading: true); List> list = await ViewModel.Salvar(val); ViewModel.Loading(isLoading: false); if (list == null || list.Count == 0) { ViewModel.ToggleSnackBar("NOTA SALVA COM SUCESSO."); } else { await ViewModel.CarregarNotas(); } } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (!_contentLoaded) { _contentLoaded = true; Uri uri = new Uri("/Gestor.Application;component/views/bi/notasview.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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown switch (connectionId) { case 1: ProgressRing = (ProgressBar)target; break; case 2: ((Control)(ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(ListBox_OnPreviewMouseDoubleClick); break; case 6: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(AdicionarNota_OnClick); break; case 7: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(ToggleNotasConcluidas_OnClick); break; case 8: ((Control)(ListBox)target).PreviewMouseDoubleClick += new MouseButtonEventHandler(ListBox_OnPreviewMouseDoubleClick); break; default: _contentLoaded = true; break; } } [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [EditorBrowsable(EditorBrowsableState.Never)] void IStyleConnector.Connect(int connectionId, object target) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown switch (connectionId) { case 3: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirNota_OnClick); break; case 4: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(NotaConcluida_OnClick); break; case 5: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(SarvarNota_OnClick); break; case 9: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(ExcluirNota_OnClick); break; case 10: ((ButtonBase)(Button)target).Click += new RoutedEventHandler(SarvarNota_OnClick); break; case 6: case 7: case 8: break; } } }