Primer push
This commit is contained in:
108
Antifraude.Net/GestionaDenunciasAN/Models/DenunciasGestiona.cs
Normal file
108
Antifraude.Net/GestionaDenunciasAN/Models/DenunciasGestiona.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
|
||||
namespace GestionaDenunciasAN.Models
|
||||
{
|
||||
public class DenunciasGestiona
|
||||
{
|
||||
// Propiedades existentes
|
||||
public int Id_RegistroDenuncia { get; set; }
|
||||
public int Id_Denuncia { get; set; }
|
||||
public DateTime Fecha { get; set; }
|
||||
public string Expediente_Gestiona { get; set; }
|
||||
public int Id_Persona_Gestiona { get; set; }
|
||||
public string Etiqueta { get; set; }
|
||||
public string Estado { get; set; }
|
||||
public string Tipo_Denuncia { get; set; }
|
||||
public string? Nombre { get; set; }
|
||||
public string? Apellidos { get; set; }
|
||||
public string? Sexo { get; set; }
|
||||
public string? Dni { get; set; }
|
||||
public string Asunto { get; set; }
|
||||
public string A_Quien_Denuncia { get; set; }
|
||||
public string Descripcion_Denuncia { get; set; }
|
||||
public string Denunciado_Ante_Inst { get; set; }
|
||||
public string? Modalidad_Informacion { get; set; }
|
||||
public string Lugar_Hechos { get; set; }
|
||||
public DateTime Fecha_Hechos { get; set; }
|
||||
public string? Notificacion_Preferencia { get; set; }
|
||||
public string? Notificacion_Electronica { get; set; }
|
||||
public string? Correo_Electronico { get; set; }
|
||||
public string? Notificacion_Sms { get; set; }
|
||||
public bool Condiciones { get; set; }
|
||||
public string? Comments { get; set; }
|
||||
|
||||
// Nuevas propiedades
|
||||
public string NombreDenuncia { get; set; }
|
||||
public string EstadoDenuncia { get; set; }
|
||||
public string ArchivoElegido { get; set; }
|
||||
public DateTime FechaSubidaAGestiona { get; set; } // Nueva propiedad
|
||||
|
||||
// Constructor por defecto
|
||||
public DenunciasGestiona()
|
||||
{
|
||||
}
|
||||
|
||||
// Constructor parametrizado que inicializa todos los campos, incluida la nueva propiedad
|
||||
public DenunciasGestiona(
|
||||
int idRegistroDenuncia,
|
||||
int idDenuncia,
|
||||
DateTime fecha,
|
||||
string expedienteGestiona,
|
||||
int idPersonaGestiona,
|
||||
string etiqueta,
|
||||
string estado,
|
||||
string tipoDenuncia,
|
||||
string? nombre,
|
||||
string? apellidos,
|
||||
string? sexo,
|
||||
string? dni,
|
||||
string asunto,
|
||||
string aQuienDenuncia,
|
||||
string descripcionDenuncia,
|
||||
string denunciadoAnteInst,
|
||||
string? modalidadInformacion,
|
||||
string lugarHechos,
|
||||
DateTime fechaHechos,
|
||||
string? notificacionPreferencia,
|
||||
string? notificacionElectronica,
|
||||
string? correoElectronico,
|
||||
string? notificacionSms,
|
||||
bool condiciones,
|
||||
string? comments,
|
||||
string nombreDenuncia,
|
||||
string estadoDenuncia,
|
||||
string archivoElegido,
|
||||
DateTime fechaSubidaAGestiona)
|
||||
{
|
||||
Id_RegistroDenuncia = idRegistroDenuncia;
|
||||
Id_Denuncia = idDenuncia;
|
||||
Fecha = fecha;
|
||||
Expediente_Gestiona = expedienteGestiona;
|
||||
Id_Persona_Gestiona = idPersonaGestiona;
|
||||
Etiqueta = etiqueta;
|
||||
Estado = estado;
|
||||
Tipo_Denuncia = tipoDenuncia;
|
||||
Nombre = nombre;
|
||||
Apellidos = apellidos;
|
||||
Sexo = sexo;
|
||||
Dni = dni;
|
||||
Asunto = asunto;
|
||||
A_Quien_Denuncia = aQuienDenuncia;
|
||||
Descripcion_Denuncia = descripcionDenuncia;
|
||||
Denunciado_Ante_Inst = denunciadoAnteInst;
|
||||
Modalidad_Informacion = modalidadInformacion;
|
||||
Lugar_Hechos = lugarHechos;
|
||||
Fecha_Hechos = fechaHechos;
|
||||
Notificacion_Preferencia = notificacionPreferencia;
|
||||
Notificacion_Electronica = notificacionElectronica;
|
||||
Correo_Electronico = correoElectronico;
|
||||
Notificacion_Sms = notificacionSms;
|
||||
Condiciones = condiciones;
|
||||
Comments = comments;
|
||||
NombreDenuncia = nombreDenuncia;
|
||||
EstadoDenuncia = estadoDenuncia;
|
||||
ArchivoElegido = archivoElegido;
|
||||
FechaSubidaAGestiona = fechaSubidaAGestiona;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
namespace GestionaDenunciasAN.Models
|
||||
{
|
||||
public class FicherosDenuncias
|
||||
{
|
||||
// Id del fichero
|
||||
public int Id_Fichero { get; set; }
|
||||
|
||||
// Id del tipo de fichero
|
||||
public int Id_Tipo { get; set; }
|
||||
|
||||
// Descripción del fichero (puede ser nula)
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
// Fecha de creación del fichero
|
||||
public DateTime Fecha { get; set; }
|
||||
|
||||
// Observaciones
|
||||
public string Observaciones { get; set; }
|
||||
|
||||
// Id de la denuncia al que está asociado (FK)
|
||||
public int Id_Denuncia { get; set; }
|
||||
|
||||
// NombreCarpeta_NombreFichero
|
||||
public string NombreFichero { get; set; }
|
||||
|
||||
// Fichero completo en formato byte array (BLOB)
|
||||
public byte[] Fichero { get; set; }
|
||||
|
||||
// Constructor por defecto
|
||||
public FicherosDenuncias()
|
||||
{
|
||||
}
|
||||
|
||||
// Constructor parametrizado que inicializa todos los campos
|
||||
public FicherosDenuncias(
|
||||
int id_Fichero,
|
||||
int id_Tipo,
|
||||
string? descripcion,
|
||||
DateTime fecha,
|
||||
string observaciones,
|
||||
int id_Denuncia,
|
||||
string nombreFichero,
|
||||
byte[] fichero)
|
||||
{
|
||||
Id_Fichero = id_Fichero;
|
||||
Id_Tipo = id_Tipo;
|
||||
Descripcion = descripcion;
|
||||
Fecha = fecha;
|
||||
Observaciones = observaciones;
|
||||
Id_Denuncia = id_Denuncia;
|
||||
NombreFichero = nombreFichero;
|
||||
Fichero = fichero;
|
||||
}
|
||||
}
|
||||
}
|
||||
62
Antifraude.Net/GestionaDenunciasAN/Models/UserState.cs
Normal file
62
Antifraude.Net/GestionaDenunciasAN/Models/UserState.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
namespace GestionaDenunciasAN.Models
|
||||
{
|
||||
public class UserState
|
||||
{
|
||||
private readonly object _lock = new object();
|
||||
private string _token;
|
||||
private string _NombreUsu;
|
||||
private bool _Mostrar;
|
||||
|
||||
public string Token
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _token;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_token = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public string NombreUsu
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _NombreUsu;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_NombreUsu = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Mostrar
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _Mostrar;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_Mostrar = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
158
Antifraude.Net/GestionaDenunciasAN/Models/Utilidades.cs
Normal file
158
Antifraude.Net/GestionaDenunciasAN/Models/Utilidades.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq.Expressions;
|
||||
using Serialize.Linq.Serializers;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace GestionaDenunciasAN.Models
|
||||
{
|
||||
public class Utilidades
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static IConfiguration Conf { get; set; }
|
||||
public static string urlSwagger()
|
||||
{
|
||||
Conf = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
string swagger = Conf.GetSection("SwaggerCC").Value;
|
||||
return swagger;
|
||||
}
|
||||
public static string urlSwagger2()
|
||||
{
|
||||
Conf = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
string swagger = Conf.GetSection("SwaggerVB").Value;
|
||||
return swagger;
|
||||
}
|
||||
|
||||
public static HttpClient ObtenerCliente(String token, IHttpClientFactory clientFactory)
|
||||
{
|
||||
var client = clientFactory.CreateClient();
|
||||
client.BaseAddress = new Uri(Utilidades.urlSwagger());
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
public static async Task<T> ObtenerObjeto<T>(HttpClient cliente, String uri)
|
||||
{
|
||||
var response = await cliente.GetAsync(uri);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var resultContent = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<T>(resultContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
public static async Task<T> ObtenerObjeto<T>(HttpClient cliente, String uri, Expression filtro)
|
||||
{
|
||||
var serializer = new ExpressionSerializer(new Serialize.Linq.Serializers.JsonSerializer());
|
||||
var serializedExpression = serializer.SerializeText(filtro);
|
||||
|
||||
var jsonContent = JsonConvert.SerializeObject(new { Expression = serializedExpression });
|
||||
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
|
||||
var response = await cliente.PostAsync(uri, content);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var resultContent = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<T>(resultContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<T> NuevoObjeto<T>(HttpClient cliente, String uri, T objeto)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Limpiar propiedades de navegación
|
||||
VaciarPropiedadesDeNavegacion(objeto);
|
||||
|
||||
var response = await cliente.PostAsJsonAsync(uri, objeto);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var resultContent = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<T>(resultContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var mess = ex.ToString();
|
||||
return default(T);
|
||||
}
|
||||
|
||||
}
|
||||
public static async Task<T> ActualizarObjeto<T>(HttpClient cliente, String uri, T objeto)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Limpiar propiedades de navegación
|
||||
VaciarPropiedadesDeNavegacion(objeto);
|
||||
|
||||
// Realizar la solicitud PUT
|
||||
var response = await cliente.PutAsJsonAsync(uri, objeto);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var resultContent = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<T>(resultContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Error al actualizar: {response.StatusCode}, {await response.Content.ReadAsStringAsync()}");
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var mess = ex.ToString();
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
// Método para limpiar las propiedades de navegación
|
||||
private static void VaciarPropiedadesDeNavegacion<T>(T objeto)
|
||||
{
|
||||
// Obtener todas las propiedades del objeto
|
||||
var propiedades = typeof(T).GetProperties();
|
||||
|
||||
foreach (var propiedad in propiedades)
|
||||
{
|
||||
// Verificar si la propiedad es de tipo de navegación
|
||||
if (propiedad.PropertyType.IsClass && propiedad.PropertyType != typeof(string))
|
||||
{
|
||||
// Vaciar la propiedad estableciéndola en null
|
||||
if (propiedad.CanWrite)
|
||||
{
|
||||
propiedad.SetValue(objeto, null);
|
||||
Console.WriteLine($"Propiedad de navegación '{propiedad.Name}' vaciada.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user