agregado procesos y bd clases

This commit is contained in:
2026-04-28 11:52:16 +02:00
parent 59a774c397
commit cd2e8b8530
251 changed files with 56881 additions and 49 deletions

View File

@@ -0,0 +1,16 @@
{
"ExtendedData": {
"inputs": [
"../../../../../../tecnosis.tfs/Comun/itsm/Web References/es.itsoft.sm/Envios.wsdl"
],
"collectionTypes": [
"System.Array",
"System.Collections.Generic.Dictionary`2"
],
"namespaceMappings": [
"*, es.itsoft.sm"
],
"targetFramework": "net8.0",
"typeReuseMode": "All"
}
}

File diff suppressed because it is too large Load Diff

14
itsm/itsm.csproj Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="8.*" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="8.*" />
<PackageReference Include="System.ServiceModel.Primitives" Version="8.*" />
<PackageReference Include="tsUtilidades" Version="1.1.10" />
</ItemGroup>
</Project>

80
itsm/sms.cs Normal file
View File

@@ -0,0 +1,80 @@
using System.Net.Http.Headers;
using System.Text;
using System.Text.RegularExpressions;
using tsUtilidades.Extensiones;
namespace itsm
{
public class sms
{
public static bool IsUnicodeSms(string message)
{
string ms2 = Regex.Replace(message, @"[^\u0000-\u007F]", string.Empty);
return ms2 != message;
}
public static async Task<string> Enviarsms(string tlfDestino, string mensaje, string apiKey)
{
try
{
// Validación del teléfono (asumiendo que tienes el método de extensión)
if (!tlfDestino.EsNumeroTelefonoMovilEspañolValido())
throw new Exception("TELEFONO_INVALIDO");
int icodingscheme = 0;
if (mensaje.Length < 71)
{
icodingscheme = 8;
}
else
{
// Limpieza de caracteres para mensajes largos
mensaje = mensaje.Replace("á", "a")
.Replace("Á", "A")
.Replace("é", "e")
.Replace("É", "E")
.Replace("í", "i")
.Replace("Í", "I")
.Replace("ó", "o")
.Replace("Ó", "O")
.Replace("ú", "u")
.Replace("Ú", "U")
.Replace("Ü", "U")
.Replace("ü", "u")
.Replace("Ñ", "N")
.Replace("ñ", "n")
.Replace("€", "Eur.");
if (IsUnicodeSms(mensaje))
throw new Exception("El mensaje tiene más de 70 caracteres y es unicode");
}
if (mensaje.Length > 160)
throw new Exception("El mensaje tiene más de 160 caracteres");
string url = $"https://sms.itsoft.es/SIC/cxfservices/httpapi/Send?text=" + mensaje+"&to=" +tlfDestino;
var client = new HttpClient();
var credenciales = Convert.ToBase64String(Encoding.UTF8.GetBytes(apiKey));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credenciales);
// Realizamos la petición GET de forma asíncrona
var response = await client.GetAsync(url);
var result = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
throw new Exception($"Error Desconocido. Respuesta del servicio: {result}");
}
return result;
}
catch (Exception ex)
{
// En C# Throw; mantiene el stack trace original si solo quieres relanzar
throw new Exception(ex.Message, ex);
}
}
}
}