private void saveConfig(object sender, RoutedEventArgs e) { VerificacionComprobantes.Service.ConfigurationServer configServer = VerificacionComprobantes.Service.ConfigurationServer.Instance; VerificacionComprobantes.Service.ConfigurationServer.Configuration config = new VerificacionComprobantes.Service.ConfigurationServer.Configuration(); config.Email.Server = smtp.Text; config.Email.Port = port.Text; config.Email.User = user.Text; config.Email.Password = pass.Password; config.Email.Header = header.Text; config.Email.Template = templateChooser.Text; config.Email.CC = ccEmails.Text; config.Email.Sender = remitente.Text; XLSDataSource.ColumnMappings.SHEETS = config.Sheet.Sheets = solapas.Text; XLSDataSource.ColumnMappings.FECHA = config.Sheet.Date = fecha.Text; XLSDataSource.ColumnMappings.OPERATION = config.Sheet.Operation = noperacion.Text; XLSDataSource.ColumnMappings.VOUCHER = config.Sheet.Voucher = voucher.Text; XLSDataSource.ColumnMappings.NAME = config.Sheet.Name = nombre.Text; XLSDataSource.ColumnMappings.TOTAL = config.Sheet.Total = total.Text; configServer.Store(config); }
private void updateConfigurationScreen(VerificacionComprobantes.Service.ConfigurationServer.Configuration config) { if (config == null) { return; } if (!string.IsNullOrEmpty(config.Email.Server)) { smtp.Text = config.Email.Server; } if (!string.IsNullOrEmpty(config.Email.Port)) { port.Text = config.Email.Port; } if (!string.IsNullOrEmpty(config.Email.User)) { user.Text = config.Email.User; } if (!string.IsNullOrEmpty(config.Email.Password)) { pass.Password = config.Email.Password; } if (!string.IsNullOrEmpty(config.Email.Header)) { header.Text = config.Email.Header; } if (!string.IsNullOrEmpty(config.Email.Sender)) { remitente.Text = config.Email.Sender; } if (!string.IsNullOrEmpty(config.Email.CC)) { ccEmails.Text = config.Email.CC; } if (!string.IsNullOrEmpty(config.Email.Template)) { templateChooser.Text = config.Email.Template; } if (!string.IsNullOrEmpty(config.Sheet.Sheets)) { XLSDataSource.ColumnMappings.SHEETS = solapas.Text = config.Sheet.Sheets; } if (!string.IsNullOrEmpty(config.Sheet.Date)) { XLSDataSource.ColumnMappings.FECHA = fecha.Text = config.Sheet.Date; } if (!string.IsNullOrEmpty(config.Sheet.Operation)) { XLSDataSource.ColumnMappings.OPERATION = noperacion.Text = config.Sheet.Operation; } if (!string.IsNullOrEmpty(config.Sheet.Voucher)) { XLSDataSource.ColumnMappings.VOUCHER = voucher.Text = config.Sheet.Voucher; } if (!string.IsNullOrEmpty(config.Sheet.Name)) { XLSDataSource.ColumnMappings.NAME = nombre.Text = config.Sheet.Name; } if (!string.IsNullOrEmpty(config.Sheet.Total)) { XLSDataSource.ColumnMappings.TOTAL = total.Text = config.Sheet.Total; } }
private void sendEmail(object sender, RoutedEventArgs e) { VerificacionComprobantes.Service.ConfigurationServer configServer = VerificacionComprobantes.Service.ConfigurationServer.Instance; VerificacionComprobantes.Service.ConfigurationServer.Configuration config = configServer.getConfiguration(); if (string.IsNullOrEmpty(config.Email.Server)) { //logger.Buffer.Text += "No esta configurado el servidor de emails\n"; return; } VerificacionComprobantes.Service.StorageService <VerificacionComprobantes.Model.Person> service = new VerificacionComprobantes.Service.StorageService <VerificacionComprobantes.Model.Person>(); VerificacionComprobantes.Model.Person person = service.Query(LiteDB.Query.EQ("Name", ((ListBoxItem)foundPerson.SelectedItem).Content.ToString()), "personas").First(); if (person == null) { return; } System.Globalization.TextInfo textInfo = new System.Globalization.CultureInfo("es-AR", false).TextInfo; var html = new HtmlAgilityPack.HtmlDocument(); html.Load(@templateChooser.Text); var document = html.DocumentNode; document.QuerySelector("#nombre").InnerHtml = textInfo.ToTitleCase(person.Name); foreach (VerificacionComprobantes.Model.Operation operation in person.Operations) { if (string.IsNullOrEmpty(operation.Voucher)) { var row = HtmlAgilityPack.HtmlNode.CreateNode("<tr>"); var cell = HtmlAgilityPack.HtmlNode.CreateNode("<td style='border: 1px solid #ddd; padding: 8px;'>"); cell.InnerHtml = operation.FacturationDate; row.AppendChild(cell); cell = HtmlAgilityPack.HtmlNode.CreateNode("<td style='border: 1px solid #ddd; padding: 8px;'>"); cell.InnerHtml = operation.Total; row.AppendChild(cell); cell = HtmlAgilityPack.HtmlNode.CreateNode("<td style='border: 1px solid #ddd; padding: 8px;'>"); cell.InnerHtml = operation.Entity; row.AppendChild(cell); document.QuerySelector("#pendientes").AppendChild(row); } } document.QuerySelector("#firmante").InnerHtml = remitente.Text; VerificacionComprobantes.Service.EmailServer server = new VerificacionComprobantes.Service.EmailServer(); server.Send("*****@*****.**", ccEmails.Text, config.Email.Header, html.DocumentNode.OuterHtml); }