From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Gestor.Application/Drawers/TarefaDrawer.cs | 631 +++++++++++++++++++++ 1 file changed, 631 insertions(+) create mode 100644 Codemerx/Gestor.Application/Drawers/TarefaDrawer.cs (limited to 'Codemerx/Gestor.Application/Drawers/TarefaDrawer.cs') diff --git a/Codemerx/Gestor.Application/Drawers/TarefaDrawer.cs b/Codemerx/Gestor.Application/Drawers/TarefaDrawer.cs new file mode 100644 index 0000000..13b9bac --- /dev/null +++ b/Codemerx/Gestor.Application/Drawers/TarefaDrawer.cs @@ -0,0 +1,631 @@ +using Gestor.Application.Componentes; +using Gestor.Application.Helpers; +using Gestor.Application.Servicos; +using Gestor.Application.ViewModels.Drawer; +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 MaterialDesignThemes.Wpf; +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.Runtime.CompilerServices; +using System.Threading; +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.Threading; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.Drawers +{ + public class TarefaDrawer : UserControl, IComponentConnector, IStyleConnector + { + internal System.Windows.Controls.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 MaterialDesignThemes.Wpf.Snackbar Snackbar; + + private bool _contentLoaded; + + private TarefaDrawerViewModel ViewModel + { + get; + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + internal Delegate _CreateDelegate(Type delegateType, string handler) + { + return Delegate.CreateDelegate(delegateType, this, handler); + } + + public TarefaDrawer(Tarefa tarefa, bool enableMenu = true) + { + long? nullable; + long? nullable1; + object description; + long? nullable2; + long? nullable3; + object obj; + object obj1; + long num; + this.ViewModel = new TarefaDrawerViewModel(tarefa, enableMenu); + base.DataContext = this.ViewModel; + this.InitializeComponent(); + System.Windows.Threading.Dispatcher dispatcher = base.Dispatcher; + if (dispatcher != null) + { + dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(this.ContentLoad)); + } + else + { + } + TarefaDrawerViewModel viewModel = this.ViewModel; + if (tarefa != null) + { + description = ValidationHelper.GetDescription(tarefa.get_Entidade()); + } + else + { + description = null; + } + if (tarefa != null) + { + nullable1 = new long?(tarefa.get_IdEntidade()); + } + else + { + nullable = null; + nullable1 = nullable; + } + string str = string.Format("ACESSOU TAREFA DE {0} DO DOCUMENTO DE ID \"{1}\"", description, nullable1); + num = (tarefa != null ? tarefa.get_IdEntidade() : (long)0); + TipoTela? nullable4 = new TipoTela?(38); + if (tarefa != null) + { + obj = ValidationHelper.GetDescription(tarefa.get_Entidade()); + } + else + { + obj = null; + } + if ((tarefa != null ? tarefa.get_IdCliente() != (long)0 : true)) + { + if (tarefa != null) + { + nullable2 = new long?(tarefa.get_IdCliente()); + } + else + { + nullable = null; + nullable2 = nullable; + } + obj1 = string.Format("\nID CLIENTE: {0}", nullable2); + } + else + { + obj1 = ""; + } + if (tarefa != null) + { + nullable3 = new long?(tarefa.get_IdEntidade()); + } + else + { + nullable = null; + nullable3 = nullable; + } + viewModel.RegistrarAcao(str, num, nullable4, string.Format("TIPO DE TAREFA: {0}{1}\nID DOCUMENTO: {2}", obj, obj1, nullable3)); + } + + private void AdicionarResponsavel_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AdcionarResponsavel(); + } + + private void Alterar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.AlterarTarefa(); + this.Anotacoes.Initialize(null); + this.Validar(); + } + + private async void AnexoTarefa_OnClick(object sender, RoutedEventArgs e) + { + if ((new PermissaoArquivoDigitalServico()).BuscarPermissao(Recursos.Usuario, 15).get_Consultar()) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + Tarefa dataContext = (Tarefa)button.DataContext; + FiltroArquivoDigital filtroArquivoDigital = new FiltroArquivoDigital(); + filtroArquivoDigital.set_Id(dataContext.get_Id()); + filtroArquivoDigital.set_Tipo(15); + filtroArquivoDigital.set_Parente(dataContext); + this.ViewModel.ShowDrawer(new ArquivoDigitalDrawer(filtroArquivoDigital), 0, false); + } + } + else + { + await this.ViewModel.ShowMessage(string.Concat("VOCÊ NÃO POSSUI PERMISSÃO PARA ACESSAR\nARQUIVO DIGITAL DE ", ValidationHelper.GetDescription((TipoArquivoDigital)15), "."), "OK", "", false); + } + } + + private void Anotacoes_OnChecked(object sender, RoutedEventArgs e) + { + this.ViewModel.IsAnotacoes = true; + } + + private void AnotacoesInternas_OnChecked(object sender, RoutedEventArgs e) + { + this.ViewModel.IsAnotacoes = false; + } + + private async void Cancelar_OnClick(object sender, RoutedEventArgs e) + { + await this.ViewModel.Cancelar(); + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + } + + private void CloseSlackBar() + { + Thread.Sleep(5000); + System.Windows.Threading.Dispatcher dispatcher = this.ProgressBar.Dispatcher; + if (dispatcher == null) + { + return; + } + dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => this.ToggleSnackBar("", false))); + } + + private void ContentLoad() + { + this.AnotacoesButton.IsChecked = new bool?(this.ViewModel.IsAnotacoes); + this.AnotacoesInternasButton.IsChecked = new bool?(!this.ViewModel.IsAnotacoes); + this.AnotacoesButton.Checked += new RoutedEventHandler(this.Anotacoes_OnChecked); + this.AnotacoesInternasButton.Checked += new RoutedEventHandler(this.AnotacoesInternas_OnChecked); + } + + private void CopyTelefoneToClipBoard_Click(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext != null) + { + TelefoneBase dataContext = button.DataContext as TelefoneBase; + if (dataContext != null) + { + string.Concat(dataContext.get_Prefixo(), ValidationHelper.OnlyNumber(dataContext.get_Numero())).CopyToClipboard(); + this.ToggleSnackBar(string.Concat("COPIADO - ", dataContext.get_Prefixo(), ValidationHelper.OnlyNumber(dataContext.get_Numero())), true); + return; + } + } + } + + private void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e) + { + ((DatePicker)sender).SelectedDate = new DateTime?(Funcoes.GetNetworkTime().Date); + } + + private void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) + { + DatePicker datePicker = (DatePicker)sender; + datePicker.Text = ValidationHelper.FormatDate(datePicker.Text); + } + + private async void ExcluirResponsavel_OnClick(object sender, RoutedEventArgs e) + { + Chip chip = sender as Chip; + if (chip != null) + { + if (await this.ViewModel.ValidaPermissaoParaEditarTarefa()) + { + ResponsavelTarefa dataContext = (ResponsavelTarefa)chip.DataContext; + if (dataContext != null) + { + this.ViewModel.Responsaveis.Remove(dataContext); + this.ViewModel.Usuarios.Add(dataContext.get_Usuario()); + TarefaDrawerViewModel viewModel = this.ViewModel; + ObservableCollection usuarios = this.ViewModel.Usuarios; + viewModel.Usuarios = new ObservableCollection( + from x in usuarios + orderby x.get_Nome() + select x); + } + } + else + { + await this.ViewModel.ShowMessage("VOCÊ NÃO POSSUI PERMISSÃO PARA EXCLUIR RESPONSÁVEL.", "OK", "", false); + } + } + chip = null; + } + + private async void ExcluirTarefa_OnClick(object sender, RoutedEventArgs e) + { + Grid grid = Extentions.FindVisualAncestor((Button)sender); + ListBox listBox = Extentions.FindVisualAncestor(grid); + Tarefa item = (Tarefa)listBox.Items[listBox.Items.IndexOf(grid.DataContext)]; + if (!await this.ViewModel.ValidaPermissaoParaExcluirTarefa(item)) + { + await this.ViewModel.ShowMessage("VOCÊ NÃO TEM PERMISSÃO PARA EXCLUIR ESSA TAREFA", "OK", "", false); + } + else if (await this.ViewModel.Excluir(item)) + { + this.ToggleSnackBar("TAREFA EXCLUÍDA COM SUCESSO.", true); + } + item = null; + } + + private void Fechar_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.CloseDrawer(); + } + + private void Imprimir_OnClick(object sender, RoutedEventArgs e) + { + Button button = (Button)sender; + if (button.DataContext == null) + { + return; + } + Tarefa dataContext = (Tarefa)button.DataContext; + if (dataContext.get_Id() == 0) + { + return; + } + this.ViewModel.SelectedTarefa = dataContext; + this.ViewModel.Print(); + } + + private void IncluirTarefa_OnClick(object sender, RoutedEventArgs e) + { + this.AnotacoesButton.IsChecked = new bool?(true); + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + this.ViewModel.Incluir(); + this.Validar(); + } + + [DebuggerNonUserCode] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + public void InitializeComponent() + { + if (this._contentLoaded) + { + return; + } + this._contentLoaded = true; + System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/drawers/tarefadrawer.xaml", UriKind.Relative)); + } + + private void InxlusaoAnexoTarefa_OnClick(object sender, RoutedEventArgs e) + { + this.ViewModel.ArquivosAnexados = new ObservableCollection(this.ViewModel.ArquivosFinais); + this.ViewModel.ShowDrawer(new InclusaoArquivoDigitalDrawer(this.ViewModel), 0, false); + } + + private async void MenuList_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ListBox listBox = (ListBox)sender; + if (listBox.SelectedItem != null) + { + this.ViewModel.TituloTarefas = listBox.SelectedItem.ToString().Replace("System.Windows.Controls.ListBoxItem: ", ""); + await this.ViewModel.CarregarTarefas(listBox.SelectedIndex); + } + } + + private async void SalvarTarefa_OnClick(object sender, RoutedEventArgs e) + { + bool flag; + this.ViewModel.Carregando = true; + this.ViewModel.SelectedTarefa.set_Anotacoes(this.Anotacoes.GetHtml()); + this.ViewModel.SelectedTarefa.set_AnotacoesInternas(this.AnotacoesInternas.GetHtml()); + List> keyValuePairs = await this.ViewModel.Salvar(this.Anotacoes.GetText(), this.AnotacoesInternas.GetText()); + flag = (keyValuePairs == null ? true : keyValuePairs.Count == 0); + this.ViewModel.Carregando = false; + if (!flag) + { + await this.ViewModel.ShowMessage(keyValuePairs, this.ViewModel.ErroCamposInvalidos, "OK", ""); + } + else + { + this.ToggleSnackBar("TAREFA SALVA COM SUCESSO.", true); + this.ViewModel.Alterar(false); + this.Anotacoes.Initialize(null); + this.AnotacoesInternas.Initialize(null); + } + } + + private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e) + { + this.Snackbar.set_IsActive(false); + } + + private void Status_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox comboBox = (ComboBox)sender; + if (comboBox == null || comboBox.SelectedItem == null) + { + return; + } + this.ViewModel.Concluido = (StatusTarefa)comboBox.SelectedItem == 2; + if ((StatusTarefa)comboBox.SelectedItem == 2) + { + DatePicker conclusaoBox = this.ConclusaoBox; + DateTime? conclusao = this.ViewModel.SelectedTarefa.get_Conclusao(); + conclusaoBox.SelectedDate = new DateTime?((conclusao.HasValue ? conclusao.GetValueOrDefault() : Funcoes.GetNetworkTime())); + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) + { + switch (connectionId) + { + case 1: + { + this.ProgressBar = (System.Windows.Controls.ProgressBar)target; + return; + } + case 2: + { + ((ListBox)target).SelectionChanged += new SelectionChangedEventHandler(this.MenuList_OnSelectionChanged); + return; + } + case 3: + { + ((Button)target).Click += new RoutedEventHandler(this.Fechar_OnClick); + return; + } + case 4: + { + this.TitleBox = (TextBlock)target; + return; + } + case 5: + case 6: + case 12: + case 13: + case 14: + case 27: + { + this._contentLoaded = true; + return; + } + case 7: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.IncluirTarefa_OnClick); + return; + } + case 8: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Alterar_OnClick); + return; + } + case 9: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.SalvarTarefa_OnClick); + return; + } + case 10: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.Cancelar_OnClick); + return; + } + case 11: + { + ((MenuItem)target).Click += new RoutedEventHandler(this.InxlusaoAnexoTarefa_OnClick); + return; + } + case 15: + { + this.AgendamentoBox = (DatePicker)target; + this.AgendamentoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.AgendamentoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 16: + { + this.AtivoBox = (ToggleButton)target; + return; + } + case 17: + { + this.AnotacoesButton = (RadioButton)target; + return; + } + case 18: + { + this.AnotacoesInternasButton = (RadioButton)target; + return; + } + case 19: + { + this.Anotacoes = (WebEditor)target; + return; + } + case 20: + { + this.Historico = (WebEditor)target; + return; + } + case 21: + { + this.AnotacoesInternas = (WebEditor)target; + return; + } + case 22: + { + this.HistoricoInterno = (WebEditor)target; + return; + } + case 23: + { + ((ComboBox)target).SelectionChanged += new SelectionChangedEventHandler(this.Status_OnSelectionChanged); + return; + } + case 24: + { + this.ConclusaoBox = (DatePicker)target; + this.ConclusaoBox.LostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.DatePicker_OnLostKeyboardFocus); + this.ConclusaoBox.MouseDoubleClick += new MouseButtonEventHandler(this.DataAtual_OnDoubleClick); + return; + } + case 25: + { + this.CboResponsavel = (ComboBox)target; + return; + } + case 26: + { + ((Button)target).Click += new RoutedEventHandler(this.AdicionarResponsavel_OnClick); + return; + } + case 28: + { + this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target; + return; + } + case 29: + { + ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick)); + return; + } + default: + { + this._contentLoaded = true; + return; + } + } + } + + [DebuggerNonUserCode] + [EditorBrowsable(EditorBrowsableState.Never)] + [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] + void System.Windows.Markup.IStyleConnector.Connect(int connectionId, object target) + { + if (connectionId <= 6) + { + if (connectionId == 5) + { + ((Button)target).Click += new RoutedEventHandler(this.CopyTelefoneToClipBoard_Click); + return; + } + if (connectionId != 6) + { + return; + } + ((Button)target).Click += new RoutedEventHandler(this.WhatsAppMessage_Click); + return; + } + switch (connectionId) + { + case 12: + { + ((Button)target).Click += new RoutedEventHandler(this.ExcluirTarefa_OnClick); + return; + } + case 13: + { + ((Button)target).Click += new RoutedEventHandler(this.AnexoTarefa_OnClick); + return; + } + case 14: + { + ((Button)target).Click += new RoutedEventHandler(this.Imprimir_OnClick); + return; + } + default: + { + if (connectionId == 27) + { + break; + } + else + { + return; + } + } + } + ((Chip)target).add_DeleteClick(new RoutedEventHandler(this.ExcluirResponsavel_OnClick)); + } + + public void ToggleSnackBar(string message, bool active = true) + { + this.Snackbar.get_Message().Content = message; + this.Snackbar.set_IsActive(active); + if (!active) + { + return; + } + Task.Factory.StartNew(new Action(this.CloseSlackBar)); + } + + private void Validar() + { + if (this.ViewModel.SelectedTarefa == null) + { + return; + } + this.ViewModel.SelectedTarefa.set_AgendamentoRetroativo(Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 45)); + List> keyValuePairs = this.ViewModel.SelectedTarefa.Validate(); + this.ValidateFields(keyValuePairs, false); + } + + private async void WhatsAppMessage_Click(object sender, RoutedEventArgs e) + { + string str; + Button button = (Button)sender; + if (button.DataContext != null) + { + TelefoneBase dataContext = button.DataContext as TelefoneBase; + if (dataContext != null) + { + str = (!dataContext.get_Tipo().HasValue || dataContext.get_Tipo().GetValueOrDefault() != 8 ? string.Concat("55", dataContext.get_Prefixo(), dataContext.get_Numero().Clear()) : string.Concat(dataContext.get_Prefixo(), dataContext.get_Numero()).Clear()); + if (!str.EnviarWhatsapp(null)) + { + await this.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", "OK", "", false); + } + return; + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3