1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
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<Usuario> usuarios = this.ViewModel.Usuarios;
viewModel.Usuarios = new ObservableCollection<Usuario>(
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<Grid>((Button)sender);
ListBox listBox = Extentions.FindVisualAncestor<ListBox>(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<Gestor.Model.Domain.Common.ArquivoDigital>(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<KeyValuePair<string, string>> 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>((ConfiguracaoSistema x) => x.get_Configuracao() == 45));
List<KeyValuePair<string, string>> 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;
}
}
}
}
}
|