summaryrefslogtreecommitdiff
path: root/Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs')
-rw-r--r--Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs163
1 files changed, 163 insertions, 0 deletions
diff --git a/Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs b/Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs
new file mode 100644
index 0000000..8a71635
--- /dev/null
+++ b/Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs
@@ -0,0 +1,163 @@
+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;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Gestor.Application.ViewModels.Drawer
+{
+ public class LogEmailViewModel : BaseSegurosViewModel
+ {
+ private readonly LogServico _servico;
+
+ private Visibility _visibilityDetalhesLog = Visibility.Hidden;
+
+ private bool _mostrarMensagem;
+
+ private ObservableCollection<LogEmail> _logs = new ObservableCollection<LogEmail>();
+
+ private LogEmail _selectedLog;
+
+ private List<TupleList> _lists = new List<TupleList>();
+
+ public List<TupleList> Lists
+ {
+ get
+ {
+ return this._lists;
+ }
+ set
+ {
+ this._lists = value;
+ base.OnPropertyChanged("Lists");
+ }
+ }
+
+ public ObservableCollection<LogEmail> Logs
+ {
+ get
+ {
+ return this._logs;
+ }
+ set
+ {
+ this._logs = value;
+ base.OnPropertyChanged("Logs");
+ }
+ }
+
+ public bool MostrarMensagem
+ {
+ get
+ {
+ return this._mostrarMensagem;
+ }
+ set
+ {
+ this._mostrarMensagem = value;
+ base.OnPropertyChanged("MostrarMensagem");
+ }
+ }
+
+ public LogEmail SelectedLog
+ {
+ get
+ {
+ return this._selectedLog;
+ }
+ set
+ {
+ this._selectedLog = value;
+ this.Lists = this.SelectedLog.CriarLogEmail();
+ base.OnPropertyChanged("SelectedLog");
+ }
+ }
+
+ public Visibility VisiblityDetalhesLog
+ {
+ get
+ {
+ return this._visibilityDetalhesLog;
+ }
+ set
+ {
+ this._visibilityDetalhesLog = value;
+ base.OnPropertyChanged("VisiblityDetalhesLog");
+ }
+ }
+
+ public LogEmailViewModel(TipoTela tela, long id, bool singleMode)
+ {
+ this._servico = new LogServico();
+ this.VisiblityDetalhesLog = (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema c) => c.get_Configuracao() == 55) ? Visibility.Visible : Visibility.Hidden);
+ this.Seleciona(tela, id, singleMode);
+ }
+
+ public void Imprimir()
+ {
+ string str = "<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 this.Lists)
+ {
+ foreach (Tuple<string, string, string> tuple in list.get_Tuples())
+ {
+ if (tuple == list.get_Tuples().First<Tuple<string, string, string>>())
+ {
+ str = string.Concat(str, "<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>");
+ str = string.Concat(str, "</tr></table>");
+ }
+ bool flag = tuple.Item1.Contains("$");
+ string[] item2 = new string[] { str, "<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: ", null, null, null, null, null, null };
+ item2[2] = (flag ? "900" : "700");
+ item2[3] = "; padding-left: 5px'>";
+ item2[4] = tuple.Item1.Replace(" ", "&nbsp;").Replace("$", "");
+ item2[5] = "</font></td><td style='width: 240px'><font size='2px' face='Arial' style='padding-left: 5px'>";
+ item2[6] = tuple.Item2;
+ item2[7] = "</font></td>";
+ str = string.Concat(item2);
+ str = string.Concat(str, "</tr></table>");
+ }
+ }
+ str = string.Concat(str, "</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 str1 = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, (TipoExtrato)0, Funcoes.GetNetworkTime());
+ StreamWriter streamWriter = new StreamWriter(str1, true, Encoding.UTF8);
+ streamWriter.Write(str);
+ streamWriter.Close();
+ Process.Start(str1);
+ }
+
+ private async void Seleciona(TipoTela tela, long id, bool singleMode)
+ {
+ base.Loading(true);
+ if (!singleMode)
+ {
+ this.Logs = await this._servico.FindByEntity(tela, id);
+ }
+ else
+ {
+ this.Logs = await this._servico.FindById(id);
+ }
+ if (this.Logs.Count <= 0)
+ {
+ this.MostrarMensagem = true;
+ }
+ else
+ {
+ this.SelectedLog = this.Logs[0];
+ }
+ base.Loading(false);
+ }
+ }
+} \ No newline at end of file