diff --git a/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor b/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor index af1319d..ba27f0d 100644 --- a/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor +++ b/HerramientaCASA/Components/Layout/ConfiguracionLayout.razor @@ -8,6 +8,7 @@ @inject ProtectedLocalStorage ProtectedLocalStore @inject UserState userState @inject IJSRuntime JS +@using bdHerramientaCACOA.db @@ -43,8 +44,10 @@ - - + + @* *@ + +
- @* *@ +
@@ -376,7 +376,6 @@ public async Task imprimir() { - var cssPath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Content", "Site.css"); var cssContent = await File.ReadAllTextAsync(cssPath); @@ -389,15 +388,18 @@ - {contenidoHtml} + {contenidoHtml} "; + var logoByte = bd.ficheros.First(x => x.NombreFichero.Contains("LogoColegio2")).Fichero; - var arrayPDF = PdfService.GenerarPdf(fullHtml); + string logo64 = Convert.ToBase64String(logoByte); + + var arrayPDF = PdfService.GenerarPdf(fullHtml, logo64); string base64Pdf = Convert.ToBase64String(arrayPDF); - await JSA.InvokeVoidAsync("descargarPdf", "SimulacionHerramientaCASA_"+ DateTime.Now , base64Pdf); + await JSA.InvokeVoidAsync("descargarPdf", "SimulacionHerramientaCASA_" + DateTime.Now , base64Pdf); } } diff --git a/HerramientaCASA/Components/Pages/HerramientaURBAN.razor b/HerramientaCASA/Components/Pages/HerramientaURBAN.razor index 1c95574..e40b8e1 100644 --- a/HerramientaCASA/Components/Pages/HerramientaURBAN.razor +++ b/HerramientaCASA/Components/Pages/HerramientaURBAN.razor @@ -54,7 +54,7 @@
- @* *@ +
@@ -372,7 +372,11 @@ "; - var arrayPDF = PdfService.GenerarPdf(fullHtml); + var logoByte = bd.ficheros.First(x => x.NombreFichero.Contains("LogoColegio2")).Fichero; + + string logo64 = Convert.ToBase64String(logoByte); + + var arrayPDF = PdfService.GenerarPdf(fullHtml, logo64); string base64Pdf = Convert.ToBase64String(arrayPDF); diff --git a/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor b/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor index cd7c6be..1a51347 100644 --- a/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor +++ b/HerramientaCASA/Components/Pages/Imprimir/HerramientaCASAImprimir.razor @@ -1,4 +1,6 @@ -
+ + +
@* ENCABEZADO DE LA PAGINA *@
diff --git a/HerramientaCASA/Components/Pages/Licitaciones.razor b/HerramientaCASA/Components/Pages/Licitaciones.razor index 0d42e8b..1dc7285 100644 --- a/HerramientaCASA/Components/Pages/Licitaciones.razor +++ b/HerramientaCASA/Components/Pages/Licitaciones.razor @@ -54,7 +54,7 @@
- @* *@ +
@@ -540,7 +540,11 @@ "; - var arrayPDF = PdfService.GenerarPdf(fullHtml); + var logoByte = bd.ficheros.First(x => x.NombreFichero.Contains("LogoColegio2")).Fichero; + + string logo64 = Convert.ToBase64String(logoByte); + + var arrayPDF = PdfService.GenerarPdf(fullHtml, logo64); string base64Pdf = Convert.ToBase64String(arrayPDF); diff --git a/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor b/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor index 174a6f2..f270e1a 100644 --- a/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor +++ b/HerramientaCASA/Components/Pages/LicitacionesURBAN.razor @@ -611,7 +611,11 @@ "; - var arrayPDF = PdfService.GenerarPdf(fullHtml); + var logoByte = bd.ficheros.First(x => x.NombreFichero.Contains("LogoColegio2")).Fichero; + + string logo64 = Convert.ToBase64String(logoByte); + + var arrayPDF = PdfService.GenerarPdf(fullHtml, logo64); string base64Pdf = Convert.ToBase64String(arrayPDF); diff --git a/HerramientaCASA/Components/Pages/Login/Denegado.razor b/HerramientaCASA/Components/Pages/Login/Denegado.razor index fb9997c..160797b 100644 --- a/HerramientaCASA/Components/Pages/Login/Denegado.razor +++ b/HerramientaCASA/Components/Pages/Login/Denegado.razor @@ -13,7 +13,9 @@
- + @* *@ + +

Acceso Denegado


@@ -22,12 +24,27 @@ Por favor vuelva a acceder desde la web

- Ir a la web del CACOA + @textoURL
@code { + public tsHerramientasCACOA bd; + private byte[] logoColegioArray = []; + + private string urlWeb = ""; + private string textoURL = ""; + + protected override async Task OnInitializedAsync() + { + bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); + logoColegioArray = bd.ficheros.First(x => x.NombreFichero == "LogoColegio").Fichero; + + var datosURL = bd.enumeraciones.First(x => x.Codigo.Contains("CW.URLWEBCOLEGIO")); + urlWeb = datosURL.ValorAlfabetico1; + textoURL = datosURL.ValorAlfabetico2; + } } diff --git a/HerramientaCASA/Components/Pages/Login/Login.razor b/HerramientaCASA/Components/Pages/Login/Login.razor index 97bf5ca..8c4ad46 100644 --- a/HerramientaCASA/Components/Pages/Login/Login.razor +++ b/HerramientaCASA/Components/Pages/Login/Login.razor @@ -1,6 +1,7 @@ @page "/" @using HerramientaCASA.Model @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage +@using Microsoft.EntityFrameworkCore @inject ProtectedLocalStorage ProtectedLocalStore @rendermode InteractiveServer @layout LoginLayout @@ -14,7 +15,9 @@
- + @* *@ + +

Acceso a la Herramienta


@@ -57,7 +60,7 @@ private string mensajeError = ""; private bool recuerda = false; - + private byte[] logoColegioArray = []; @@ -65,6 +68,7 @@ { bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); + logoColegioArray = bd.ficheros.Where(x => x.NombreFichero == "LogoColegio").Select(x => x.Fichero).First(); await ProtectedLocalStore.SetAsync("idUsuario", 0); await ProtectedLocalStore.SetAsync("EsAdmin", false); @@ -85,6 +89,12 @@ } } + + private async void logoColegio() + { + + } + private async void checkCambiado(bool e) { recuerda = e; diff --git a/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor b/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor index 1511488..125293b 100644 --- a/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor +++ b/HerramientaCASA/Components/Pages/Login/NuevoAcceso.razor @@ -12,8 +12,8 @@
- -

Crear Clave de acceso

+ +

Crear Clave de acceso


Se va a generar una clave de acceso para acceder a la herramienta, tenga en cuenta que como no se almacena ningún dato de caracter personal le recomendamos que guarde la clave y contraseña para poder utilizarla.

@@ -32,10 +32,13 @@ private string? nuevaPassword = ""; public tsHerramientasCACOA bd; private string mensajeError = ""; + private byte[] logoColegioArray = []; + protected override void OnInitialized() { bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false); + logoColegioArray = bd.ficheros.Where(x => x.NombreFichero == "LogoColegio").Select(x => x.Fichero).First(); diff --git a/HerramientaCASA/Program.cs b/HerramientaCASA/Program.cs index 3ee0920..7a53743 100644 --- a/HerramientaCASA/Program.cs +++ b/HerramientaCASA/Program.cs @@ -6,6 +6,7 @@ using HerramientaCASA.Components; using HerramientaCASA.Model; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; +using Microsoft.AspNetCore.Mvc; using System.Globalization; using System.Runtime.InteropServices; diff --git a/HerramientaCASA/ServicioPDF.cs b/HerramientaCASA/ServicioPDF.cs index ee11694..729760d 100644 --- a/HerramientaCASA/ServicioPDF.cs +++ b/HerramientaCASA/ServicioPDF.cs @@ -1,5 +1,6 @@ using DinkToPdf; using DinkToPdf.Contracts; +using DocumentFormat.OpenXml.Packaging; using System.Text; namespace HerramientaCASA { @@ -12,11 +13,15 @@ namespace HerramientaCASA _converter = converter; } - public byte[] GenerarPdf(string html) + public byte[] GenerarPdf(string html, string logoBase64) { - var doc = new HtmlToPdfDocument() + var headerPath = Path.Combine(Path.GetTempPath(), $"header_{Guid.NewGuid()}.html"); + File.WriteAllText(headerPath, rellenarHeader(logoBase64)); + try { - GlobalSettings = { + var doc = new HtmlToPdfDocument() + { + GlobalSettings = { PaperSize = PaperKind.A4, Orientation = Orientation.Portrait, Margins= new MarginSettings @@ -27,21 +32,58 @@ namespace HerramientaCASA Bottom = 10 }, }, - Objects = { + Objects = { new ObjectSettings() { HtmlContent = html, HeaderSettings = new HeaderSettings { - HtmUrl = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Imprimir", "HeaderImprimir.html") - } + HtmUrl = headerPath + }, + } } - }; + }; - return _converter.Convert(doc); + return _converter.Convert(doc); + } + finally + { + if (headerPath != null && File.Exists(headerPath)) + { + File.Delete(headerPath); + } + } + } + private string rellenarHeader(string logoBase64) + { + string html = ""; + html = $"\r\n" + + $"\r\n" + + $"\r\n" + + $"\r\n" + + $"\r\n"+ + $"\r\n"+ + $"\r\n" + + $"
\r\n"+ + $"\r\n" + + $" \r\n"+ + $"\r\n"+ + $"\r\n"+ + $"\r\n"+ + $"
\r\n" + + $"Image\r\n" + + $"\r\n"+ + $"Costes Asociados a los Servicios de Arquitectura - CASA\r\n"+ + $"
\r\n"+ + $"
\r\n"+ + $"\r\n"+ + $""; + + return html; + } // /// // /// Convierte HTML a PDF (bytes) usando HtmlRenderer.PdfSharpCore, inyectando site.css. diff --git a/HerramientaCASA/appsettings.json b/HerramientaCASA/appsettings.json index 38cf559..0481f63 100644 --- a/HerramientaCASA/appsettings.json +++ b/HerramientaCASA/appsettings.json @@ -8,8 +8,14 @@ "ConnectionStrings": { //"WriteConnection": "Server=localhost;Port=22222;Database=herramientascacoa;User Id=cacoa;Password=cacoa2018-;", //"ReadOnlyConnection": "Server=localhost;Port=22222;Database=herramientascacoa;User Id=cacoa;Password=cacoa2018-;" + + // CONEXIÓN CACOA "WriteConnection": "Server=77.229.174.85;Port=22222;Database=herramientascacoa;User Id=cacoa;Password=cacoa2018-;", "ReadOnlyConnection": "Server=77.229.174.85;Port=22222;Database=herramientascacoa;User Id=cacoa;Password=cacoa2018-;" + + // CONEXIÓN COACYLE + //"WriteConnection": "Server=77.229.174.85;Port=22222;Database=herramientascoacyle;User Id=cacoa;Password=cacoa2018-;", + //"ReadOnlyConnection": "Server=77.229.174.85;Port=22222;Database=herramientascoacyle;User Id=cacoa;Password=cacoa2018-;" }, "AllowedHosts": "*" } diff --git a/HerramientaCASA/wwwroot/Imprimir/HeaderImprimir.html b/HerramientaCASA/wwwroot/Imprimir/HeaderImprimir.html index ef4c241..4d0e7af 100644 --- a/HerramientaCASA/wwwroot/Imprimir/HeaderImprimir.html +++ b/HerramientaCASA/wwwroot/Imprimir/HeaderImprimir.html @@ -1,10 +1,10 @@  - + - +
@@ -18,4 +18,10 @@
- \ No newline at end of file + + + \ No newline at end of file