From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../ViewModels/Drawer/LogEmailViewModel.cs | 163 +++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs (limited to 'Gestor.Application/ViewModels/Drawer/LogEmailViewModel.cs') 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 _logs = new ObservableCollection(); + + private LogEmail _selectedLog; + + private List _lists = new List(); + + public List Lists + { + get + { + return this._lists; + } + set + { + this._lists = value; + base.OnPropertyChanged("Lists"); + } + } + + public ObservableCollection 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 c) => c.get_Configuracao() == 55) ? Visibility.Visible : Visibility.Hidden); + this.Seleciona(tela, id, singleMode); + } + + public void Imprimir() + { + string str = "LOGS
LOG ENVIO DE E-MAIL"; + foreach (TupleList list in this.Lists) + { + foreach (Tuple tuple in list.get_Tuples()) + { + if (tuple == list.get_Tuples().First>()) + { + str = string.Concat(str, ""); + str = string.Concat(str, "
DESCRIÇÃOE-MAIL ENVIADO
"); + } + bool flag = tuple.Item1.Contains("$"); + string[] item2 = new string[] { str, ""; + str = string.Concat(item2); + str = string.Concat(str, "
"; + item2[4] = tuple.Item1.Replace(" ", " ").Replace("$", ""); + item2[5] = ""; + item2[6] = tuple.Item2; + item2[7] = "
"); + } + } + str = string.Concat(str, "
"); + 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 -- cgit v1.2.3