diff --git a/ApiDatosGuadex/ApiDatosGuadex.http b/ApiDatosGuadex/ApiDatosGuadex.http
new file mode 100644
index 0000000..c1bc024
--- /dev/null
+++ b/ApiDatosGuadex/ApiDatosGuadex.http
@@ -0,0 +1,6 @@
+@ApiExcelGuadex_HostAddress = http://localhost:5188
+
+GET {{ApiExcelGuadex_HostAddress}}/weatherforecast/
+Accept: application/json
+
+###
diff --git a/ApiDatosGuadex/ApiDatosSanchoToro.csproj b/ApiDatosGuadex/ApiDatosSanchoToro.csproj
new file mode 100644
index 0000000..aa31b75
--- /dev/null
+++ b/ApiDatosGuadex/ApiDatosSanchoToro.csproj
@@ -0,0 +1,28 @@
+
+
+
+ SAK
+ SAK
+ SAK
+ SAK
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ApiDatosGuadex/Controllers/HomeController.cs b/ApiDatosGuadex/Controllers/HomeController.cs
new file mode 100644
index 0000000..c97bd9f
--- /dev/null
+++ b/ApiDatosGuadex/Controllers/HomeController.cs
@@ -0,0 +1,88 @@
+using ApiDatosGuadex.Models;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using System.Data.Common;
+using bdGrupoSanchoToro.dbcontext;
+using bdGrupoSanchoToro;
+
+namespace ApiDatosGuadex.Controllers
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public class HomeController : Controller
+ {
+ //metodo
+ [HttpGet("lee")]
+ public IActionResult LeeSQL(string bd, string sqlh)
+ {
+ // bdGestionGuadex.Utilidades.AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Otros, "Inicio Log",null);
+ Response.ContentType = "text/plain";
+ try
+ {
+
+ DbConnection? db = null;
+
+ switch (bd.ToLower())
+ {
+ case "sanchotoro":
+ {
+ db = tscGrupoSanchoToro.NuevoContexto().Database.GetDbConnection();
+ break;
+ }
+ //case "guadex":
+ // {
+ // db = tscGrupoSanchoToro.NuevoContexto().Database.GetDbConnection();
+ // break;
+ // }
+
+ }
+ // string res = tsUtilidades.bbdd.LeeMysql(db, sqlh);
+ string res = tsUtilidades.bbdd.LeeMysql(db, sqlh);
+
+
+ // termiancion en CRLF
+ res = res.Replace("\n", "\r\n");
+
+ return Content(res, "text/plain", System.Text.Encoding.UTF8);
+ }
+ catch (Exception ex)
+ {
+ bdGrupoSanchoToro.db.Utilidades.AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Fallo, "Error en LeeSQL", ex.Message, ex);
+ return Content($"Error: {ex.Message}\r\n", "text/plain", System.Text.Encoding.UTF8);
+ }
+
+ }
+ public IActionResult EjeSQL(string bd, string sqlh)
+ {
+ Response.ContentType = "text/plain";
+ try
+ {
+ DbConnection? db = null;
+ switch (bd.ToLower())
+ {
+ case "sanchotoro":
+ {
+ db = tscGrupoSanchoToro.NuevoContexto().Database.GetDbConnection();
+ break;
+ }
+ //case "guadex":
+ // {
+ // db = bdGuadex.tscGuadex.NuevoContexto().Database.GetDbConnection();
+ // break;
+ // }
+ }
+ string res = tsUtilidades.bbdd.EjeMySqlHex(db, sqlh);
+
+ // terminacion en CRLF
+ res = res.Replace("\n", "\r\n");
+
+ return Content(res, "text/plain", System.Text.Encoding.UTF8);
+ }
+ catch (Exception ex)
+ {
+ bdGrupoSanchoToro.db.Utilidades.AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Fallo, "Error en EjeSQL", ex.Message, ex);
+ return Content($"Error: {ex.Message}\r\n", "text/plain", System.Text.Encoding.UTF8);
+ }
+ }
+ }
+}
diff --git a/ApiDatosGuadex/Filtros/FiltroAutenticacionBasica.cs b/ApiDatosGuadex/Filtros/FiltroAutenticacionBasica.cs
new file mode 100644
index 0000000..2c7e328
--- /dev/null
+++ b/ApiDatosGuadex/Filtros/FiltroAutenticacionBasica.cs
@@ -0,0 +1,39 @@
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+
+namespace ApiDatosGuadex.Filtros
+{
+ public class FiltroAutenticacionBasica : Attribute, IAuthorizationFilter
+ {
+ private readonly string _usuarioPermitido;
+ private readonly string _contrasenaPermitida;
+
+ public FiltroAutenticacionBasica(IConfiguration configuration)
+ {
+ var authSettings = configuration.GetSection("Authentication");
+ _usuarioPermitido = authSettings["Username"];
+ _contrasenaPermitida = authSettings["Password"];
+ }
+
+ public void OnAuthorization(AuthorizationFilterContext contexto)
+ {
+ var encabezadoAutorizacion = contexto.HttpContext.Request.Headers["Authorization"].ToString();
+
+ if (string.IsNullOrEmpty(encabezadoAutorizacion) || !encabezadoAutorizacion.StartsWith("Basic "))
+ {
+ contexto.Result = new UnauthorizedResult();
+ return;
+ }
+
+ var credencialesCodificadas = encabezadoAutorizacion.Substring("Basic ".Length).Trim();
+ var credencialesDecodificadas = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(credencialesCodificadas));
+
+ var partes = credencialesDecodificadas.Split(':');
+ if (partes.Length != 2 || partes[0] != _usuarioPermitido || partes[1] != _contrasenaPermitida)
+ {
+ contexto.Result = new UnauthorizedResult();
+ }
+ }
+ }
+}
diff --git a/ApiDatosGuadex/Models/MensajeViewModel.cs b/ApiDatosGuadex/Models/MensajeViewModel.cs
new file mode 100644
index 0000000..149fab4
--- /dev/null
+++ b/ApiDatosGuadex/Models/MensajeViewModel.cs
@@ -0,0 +1,7 @@
+namespace ApiDatosGuadex.Models
+{
+ public class MensajeViewModel
+ {
+ public string Mensaje { get; set; }
+ }
+}
diff --git a/ApiDatosGuadex/Program.cs b/ApiDatosGuadex/Program.cs
new file mode 100644
index 0000000..93128e9
--- /dev/null
+++ b/ApiDatosGuadex/Program.cs
@@ -0,0 +1,38 @@
+using ApiDatosGuadex.Filtros;
+
+var builder = WebApplication.CreateBuilder(args);
+
+// Agregar servicios al contenedor
+builder.Services.AddControllersWithViews();
+
+// Registrar el filtro de autenticación como servicio
+builder.Services.AddScoped();
+
+// Agregar Swagger
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+
+var app = builder.Build();
+
+// Configuración del pipeline de solicitudes HTTP
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.UseHttpsRedirection();
+
+app.UseStaticFiles();
+
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.MapControllerRoute(
+ name: "default",
+ pattern: "{controller=Home}/{action=Index}/{id?}");
+
+
+app.Run();
diff --git a/ApiDatosGuadex/Properties/launchSettings.json b/ApiDatosGuadex/Properties/launchSettings.json
new file mode 100644
index 0000000..a375176
--- /dev/null
+++ b/ApiDatosGuadex/Properties/launchSettings.json
@@ -0,0 +1,41 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:12379",
+ "sslPort": 44309
+ }
+ },
+ "profiles": {
+ "http": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "http://localhost:5188",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "https": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7029;http://localhost:5188",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/ApiDatosGuadex/Views/Home/EjeSQL.cshtml b/ApiDatosGuadex/Views/Home/EjeSQL.cshtml
new file mode 100644
index 0000000..2d085ce
--- /dev/null
+++ b/ApiDatosGuadex/Views/Home/EjeSQL.cshtml
@@ -0,0 +1,3 @@
+@ViewData["Mensaje"]
+
+
diff --git a/ApiDatosGuadex/Views/Home/LeeSQL.cshtml b/ApiDatosGuadex/Views/Home/LeeSQL.cshtml
new file mode 100644
index 0000000..b540dd5
--- /dev/null
+++ b/ApiDatosGuadex/Views/Home/LeeSQL.cshtml
@@ -0,0 +1,4 @@
+@ViewData["Mensaje"]
+
+
+
diff --git a/ApiDatosGuadex/appsettings.Development.json b/ApiDatosGuadex/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/ApiDatosGuadex/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/ApiDatosGuadex/appsettings.json b/ApiDatosGuadex/appsettings.json
new file mode 100644
index 0000000..4afc965
--- /dev/null
+++ b/ApiDatosGuadex/appsettings.json
@@ -0,0 +1,13 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*",
+ "Authentication": {
+ "Username": "guadex",
+ "Password": "tsguadex..-"
+ }
+}