summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.ViewModels.Drawer/LogEmailViewModel.cs
blob: 5086554fe7c691a6e94cdeaf0f7b10c981e53d5f (plain)
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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos;
using Gestor.Application.ViewModels.Generic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Configuracoes;
using Gestor.Model.Domain.Ferramentas;
using Gestor.Model.Domain.Seguros;

namespace Gestor.Application.ViewModels.Drawer;

public class LogEmailViewModel : BaseSegurosViewModel
{
	private readonly LogServico _servico;

	private Visibility _visibilityDetalhesLog = (Visibility)1;

	private bool _mostrarMensagem;

	private ObservableCollection<LogEmail> _logs = new ObservableCollection<LogEmail>();

	private LogEmail _selectedLog;

	private List<TupleList> _lists = new List<TupleList>();

	public Visibility VisiblityDetalhesLog
	{
		get
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return _visibilityDetalhesLog;
		}
		set
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_visibilityDetalhesLog = value;
			OnPropertyChanged("VisiblityDetalhesLog");
		}
	}

	public bool MostrarMensagem
	{
		get
		{
			return _mostrarMensagem;
		}
		set
		{
			_mostrarMensagem = value;
			OnPropertyChanged("MostrarMensagem");
		}
	}

	public ObservableCollection<LogEmail> Logs
	{
		get
		{
			return _logs;
		}
		set
		{
			_logs = value;
			OnPropertyChanged("Logs");
		}
	}

	public LogEmail SelectedLog
	{
		get
		{
			return _selectedLog;
		}
		set
		{
			_selectedLog = value;
			List<TupleList> lists = SelectedLog.CriarLogEmail();
			Lists = lists;
			OnPropertyChanged("SelectedLog");
		}
	}

	public List<TupleList> Lists
	{
		get
		{
			return _lists;
		}
		set
		{
			_lists = value;
			OnPropertyChanged("Lists");
		}
	}

	public LogEmailViewModel(TipoTela tela, long id, bool singleMode)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		_servico = new LogServico();
		VisiblityDetalhesLog = (Visibility)(!Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 55));
		Seleciona(tela, id, singleMode);
	}

	private async void Seleciona(TipoTela tela, long id, bool singleMode)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		Loading(isLoading: true);
		if (singleMode)
		{
			Logs = await _servico.FindById(id);
		}
		else
		{
			Logs = await _servico.FindByEntity(tela, id);
		}
		if (Logs.Count > 0)
		{
			SelectedLog = Logs[0];
		}
		else
		{
			MostrarMensagem = true;
		}
		Loading(isLoading: false);
	}

	public void Imprimir()
	{
		string text = "<html><head><style type='text/css'>@page{size: A4; margin: 0cm}</style><title>LOGS</title><link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css' integrity='sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh' crossorigin='anonymous'></head><body><div align='center'><font size='5px' face='Arial' style='font-weight: 900;'>LOG ENVIO DE E-MAIL</font>";
		foreach (TupleList list in Lists)
		{
			foreach (Tuple<string, string, string> tuple in list.Tuples)
			{
				if (tuple == list.Tuples.First())
				{
					text += "<table border='1' style='border-collapse: collapse; page-break-inside: avoid'><tr style='height: 45px;'><td style='width: 220px; text-align: center;'><font size='3px' face='Arial' style='font-weight: 700;'>DESCRIÇÃO</font></td><td style='width: 240px; text-align:center;'><font size='3px' face='Arial' style='font-weight: 700'>E-MAIL ENVIADO</font></td>";
					text += "</tr></table>";
				}
				bool flag = tuple.Item1.Contains("$");
				text = text + "<table border='1' style='border-collapse: collapse; page-break-inside: avoid; border-TOP: none'><tr style='height: 30px;'><td style='width: 220px'><font size='2px' face='Arial' style='font-weight: " + (flag ? "900" : "700") + "; padding-left: 5px'>" + tuple.Item1.Replace(" ", "&nbsp;").Replace("$", "") + "</font></td><td style='width: 240px'><font size='2px' face='Arial' style='padding-left: 5px'>" + tuple.Item2 + "</font></td>";
				text += "</tr></table>";
			}
		}
		text += "</div><script src='https://code.jquery.com/jquery-3.4.1.slim.min.js' integrity='sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n' crossorigin='anonymous'></script><script src = 'https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js' integrity = 'sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo' crossorigin = 'anonymous' ></script ><script src = 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js' integrity = 'sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6' crossorigin = 'anonymous' ></script > </body></html>";
		string tempPath = Path.GetTempPath();
		string text2 = $"{tempPath}{(object)(TipoExtrato)0}_{Funcoes.GetNetworkTime():ddMMyyyyhhmmss}.html";
		StreamWriter streamWriter = new StreamWriter(text2, append: true, Encoding.UTF8);
		streamWriter.Write(text);
		streamWriter.Close();
		Process.Start(text2);
	}
}