Tengo una x cantidad de documentos en un directorio de Lucene, uso la implementacion de .Net Core, version 8.4, necesito mediante una frase o string, que la consulta me coincida con cualquier campo del documento, no que de la manera que se hacerlo ahora, necesito especificar cada termino por cada campo, cuando pudiera perfectamente existir una manera de simplificarlo.
Tag: Los
es posible guardar en una base de datos (sql server) los resultados numéricos que se generen en un ciclo?
como por ejemplo un ciclo que genere el resultado de la tabla de multiplicar del 2 y los resultados guardarlos en una base de datos, o pasar los datos de un arreglo a una base de datos?
javascript – Problema para guardar los datos de un formulario en un Array
Estoy haciendo un formulario y quiero pasar los datos de los input a un Array de objetos , el tema es que cuando quiero pasar los datos del input me guardan siempre el ultimo valor para todas las posiciones del array , un ejemplo del problema:
var vector=()
Dato 1:
Nombre: pablo
Dato 2:
nombre:Daniel
Dato 4:
Nombre: Javier
// vector muestra : {nombre javier ,nombre: javier , nombre:javier}
codigo javascript:
var formulario=document.getElementById("form");
var addButton=document.getElementById("boton");
var baseDatos=();
function Persona(nombre,edad,dni,profesion){
this.nombre=nombre;
this.edad=edad;
this.dni=dni;
this.profesion=profesion;
}
function agregar(){
baseDatos.push(miPersona);
alert("agregado");
}
function guardarDatos()
{
localStorage.setItem("datos", JSON.stringify(baseDatos));
}
var nombre=document.getElementById("nombre");
var edad=document.getElementById("edad");
var dni=document.getElementById("dni");
var profesion=document.getElementById("profesion");
miPersona=new Persona(nombre,edad,dni,profesion);
addButton.onclick=agregar;
Codigo html:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="" method="" enctype="" id="form">
<div>
<label for="">Ingrese nombre:</label>
<input type="text" id="nombre">
<label for="">Ingrese Edad:</label>
<input type="text" id="edad">
<label for="">Ingrese profesion:</label>
<input type="text" id="profesion">
<label for="">Ingrese dni:</label>
<input type="text" id="dni">
<button type="button" id="boton" >Add</button>
</div>
<input type="submit">
</form>
<script src="https://es.stackoverflow.com/js/registro.js"></script>
</body>
</html>
Como obtener de una lista de objetos A los objetos que faltan o que no estan en una lista B en C#
Hola tengo una lista de objetos del siguiente modelo:
public partial class ArticuloSC
{
(JsonProperty("CLASIFICACION 1"))
public object Clasificacion1 { get; set; }
(JsonProperty("COSTO PROMEDIO"))
public object CostoPromedio { get; set; }
(JsonProperty("DESCRIPCION"))
public string() Descripcion { get; set; }
(JsonProperty("ARTICULO"))
public string Articulo { get; set; }
(JsonProperty("CLASIFICACION 2"))
public object Clasificacion2 { get; set; }
(JsonProperty("PRECIO"))
public object Precio { get; set; }
}
Y otra lista de objetos del siguiente modelo:
public class ArticuloFC
{
public object categoryId { get; set; }
public object cost { get; set; }
public DateTime? dateCreated { get; set; }
public object dateDeleted { get; set; }
public DateTime? dateUpdated { get; set; }
public bool deleted { get; set; }
public string description { get; set; }
public object extId { get; set; }
public object familyId { get; set; }
public int? id { get; set; }
public object maxDiscount { get; set; }
public string model { get; set; }
public bool notAvailable { get; set; }
public int? permissionLevel { get; set; }
public object price { get; set; }
public bool readOnly { get; set; }
public int? salesRepIdCreated { get; set; }
public object salesRepIdDeleted { get; set; }
public int? salesRepIdUpdated { get; set; }
public object stock { get; set; }
}
Lo único que tienen en común estas clases es el campo o la propiedad extId y Articulo. Entonces lo que quiero es que teniendo la lista de ArticuloSC, poder saber cuales artículos por medio del campo Articulo hacen falta o no estan en la lista de ArticuloFC.
Hasta el momento lo estoy intentando de esta forma:
//Obtengo los que ya existen en las 2 listas
var existentes =(from A in articulos
join FC in articuloFCs
on A.Articulo equals FC.extId
select A.Articulo).ToList();
//Luego obtengo los que no estan descartando los que ya estan
var inexistentes =(from A in articulos
where !existentes.Contains(A.Articulo)
select A.Articulo).ToList();
Sin embargo cuando reviso la lista de inexistentes obtengo códigos que ya estan en la lista de los existentes. Como puedo obtener en los inexistentes solamente los que de verdad no estan en la lista de existentes los cuales se unen por un join?
Para explicarme mejor. Yo voy a tener en la lista de ArticuloSC artículos que ya existen en la lista de ArticuloFC pero también voy a tener artículos en la lista de ArticuloSC, artículos que todavía no existen en la lista de ArticuloFC y esos son precisamente los que necesito identificar.
¿Cómo pasar referencias a los elementos de un diccionario en C#?
¿Es posible pasar pasar referencias a los elementos de un diccionario?
Estoy intentando hacer lo siguiente:
//--------------------------------------------------
public class AnimationsNames
{
public const string idle = "idle";
}
//--------------------------------------------------
public class AnimationChecker
{
public static bool isFinished;
}
//--------------------------------------------------
public class AnimationsControler
{
public static bool isIdle;
public class Pair<T1, T2>
{
public T1 first;
public T2 second;
public Pair(ref T1 first, ref T2 second)
{
this.first = first;
this.second = second;
}
}
public Dictionary<string, Pair<bool,bool>> tirggerAnimations;
public AnimationsControler()
{
tirggerAnimations = new Dictionary<string, Pair<bool, bool>>();
tirggerAnimations.Add(AnimationsNames.idle, new Pair<bool, bool>(ref AnimationsChecker.isFinished, ref isIdle));
}
void CheckTriggerAnimations()
{
foreach(string key in tirggerAnimations.Keys)
{
if(tirggerAnimations(key).first && tirggerAnimations(key).second)
{
animator.SetTrigger(key);
}
}
}
}
//--------------------------------------------------
Me gustaría poder pasar las referencias de las siguientes variables al diccionario:
AnimationsChecker.isFinished, isIdle
Ya que si solamente se me pasan los valores la función CheckTriggerAnimations() no funciona correctamente.
He intentado usar ref colocandolo en todos los sitios posibles pero no hay manera.
¿Alguna forma de poder hacer esto?
Gracias!!
java – No se reflejan los mensajes de error en la vista Thymeleaf
Estoy intentando enviar unos mensajes a la vista con Thymeleaf si toma los mensajes pero no me los envia a la vista ósea no se reflejan en el HTML.
Mi Clase CUsuarioVO tiene los atribitos con sus get y set
@Pattern(regexp = "(0-9)*", message = "LA CUENTA DEFAULT ES INVALIDA")
@Size(min = 0, max = 2)
private String cuentaDefault;
public String getCuentaDefault() {
return cuentaDefault;
}
public void setCuentaDefault(String cuentaDefault) {
this.cuentaDefault = cuentaDefault;
}
Mi controlador el cual envia con el atributo form los atributus de la clase CUsuarioVO.
Cuando en el post no cumple con la expresión regular entra en el result.hasErrors() pero no me envia los mensajes de error que tiene el atributo cuentaDefault si envia el alert de se agrego o no se agro pero el mensaje de la variable cuentaDefault no llega a la vista
@GetMapping("/home") // Method get envia a view home
public String showForm(Model model) {
model.addAttribute("form", new CUsuarioVO());
return "home";
}
@PostMapping("/guardar") // Recibe parametros del objeto y los asigna
public String checkPersonInfo(@ModelAttribute @Valid CUsuarioVO usvo, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors() == true) {
model.addAttribute("alert", "No se agrego");
model.addAttribute("form", usvo);
return "home";
}
model.addAttribute("form", usvo);
model.addAttribute("alert", "Se agrego");
return "home";
}
Y mi html es asi:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<form action="#" th:action="@{/guardar}" th:object="${form}"
method="post">
<div class="form-group col-lg-2">
<label>cuentaDefault</label> <input class="form-control" type="text"
th:field="*{cuentaDefault}" id="cuentaDefault"
placeholder="cuentaDefault">
<div th:if="${#fields.hasErrors('cuentaDefault')}"
th:errors="*{cuentaDefault}" class="form-text"></div>
</div>
<button type="submit">Submits</button>
<div th:text="${alert}"></div>
</form>
</body>
</html>
typescript – traer una lista de los archivos en un servidor
Estoy haciendo una conexion a mi servidor ftp mediante typescript lo cual funciona, pero no entiendo aun como listar los archivos o carpetas y mostrarmelos por consola, aqui esta mi codigo
const ftp = require("basic-ftp");
async function example() {
console.log('llamando al metodo example');
const client = new ftp.Client(0)
client.ftp.verbose = true
try {
await client.access({
host: '********',
port: '*******',
username: '*****',
password: '*****',
secure: true
})
console.log(await client.list());
await client.uploadFromuploadFrom("README.md", "README_FTP.md")
await client.downloadTo("README_COPY.md", "README_FTP.md")
}
catch (err) {
console.log(err)
}
client.close()
}
example();
typescript – Undefined, a la hora de acceder a los valores de un token
Estoy haciendo un ejercicio para aprender a usar Tokens. El token se genera perfectamente, pero cuando intento acceder a la funcion de logearme con ese usuario, me pierde los datos en una parte de la funciona verificar token.
Estoy usando Typescript, tengo el mismo ejercicio hecho con JS y me funciona perfectamente, creo que puedo estar cometiendo un error a la hora de construir la interface Payload.
Aqui os dejo mi codigo de la funcion en donde esta el error:
export const verifyToken = (req: Request, res: Response, next: NextFunction) => {
const token = req.header('auth-token');
if(!token) {
return res.status(401).json({
msg: 'Acceso denegado'
});
};
const payload = jwt.verify(token, process.env.TOKEN_SECRET || 'secret_token') as IPayload;
console.log(payload)
req.userId = payload._id;
console.log(payload._id)
next();
};
Como veis tengo un console.log(payload), donde ahí si que todavía estoy recibiendo toda la data,os dejo aqui mismo el resultado en consola. Le he quitado numeros al token, por si alguien se da cuenta.
{
(1) data: {
(1) role: 'USER',
(1) status: true,
(1) _id: '60312e74daed1017c89d3035',
(1) name: 'gggg',
(1) surname: 'gggg',
(1) age: 3,
(1) email: 'd@d',
(1) password: '$2b$10$arF.tnr7KSgWgHpvdS7FmOZ84l6.tXONVtte0',
(1) date: '2021-02-20T15:44:52.384Z',
(1) __v: 0
(1) },
(1) iat: 16138989,
(1) exp: 16164909
(1) }
En el siguiente console.log(payload._id), ya me dice que esta undefined. Es aquí donde esta perdiendo toda la tada, justo despues del console.log anterior.
Os dejo mi configuracion de la interface IPayload
export interface IPayload {
_id: string;
iat: number;
exp: number;
}
Y tambien esta configurado todo para que Typescript me de como valido el userId al ser requerido.
Muchas gracias a todos, si falta algo mas por subir, diganme.
php – tomar nombre sin tener el id ni pasar los datos
que tal estoy tratando de buscar la forma la cual pueda agregar un insert a mi tabla
ejemplo
si un usuario no se a registrdo en la tablaa postuleo
este habilita un boton al hacerlo solo
se preciona y se mandapero me marca error de nombrevacante y esque yo hago la consulta la cual me trae el id de usuario de mi tabla usuarios y es diferente la tabla postuleo muestro lo que llevo de codigo
es como ineed
codigo
<?php
$resultado = mysqli_query($link,"SELECT COUNT(*) AS total FROM postuleo Where id_usuario='" . $_SESSION('usuario') ."' AND nombrevacante='$nombrevacante' ");
$row = mysqli_fetch_assoc($resultado);
if($row('total') == '0'){
echo "<center><a class='btn btn-info btn-lg' href='verpost.php?id=".$fila2("id")."' alt='edit'>Postularse</a>";
if(isset($_GET('user'))){
$user = $_GET('user');
$query1 = "SELECT * FROM useros WHERE usuario =".$user;
if($result = mysqli_query($link, $query1)){
while($usuarioe = mysqli_fetch_assoc($result)){
$id = $usuarioe('id');
$nombres = $usuarioe('nombres');
$apellido = $usuarioe('apellido');
$fecha_nacimiento = $usuarioe('fecha_nacimiento');
$usuario = $usuarioe('usuario');
$clave = $usuarioe('clave');
$queryos = "SELECT * FROM vacantes WHERE id =".$id;
$dlk = mysqli_query($link, $queryos);
$fila= mysqli_fetch_array ($dlk);
$now = date('Y-m-d H:i:s');
$sql="INSERT INTO POSTULEO (nombre1, id_usuario,id_vacante, horapostulacion, nombrevacante)
VALUES ('".$usuarioe("nombres") ."','".$fila('id')."','".$fila('id')."','$now','".$usuarioe('id')."')";
var_dump($sql);
}
}
}
}else{
echo "<center><a class='btn btn-info btn-lg' disabled alt='edit'>Ya Postulado!</a>";
}
?>
quiero que me inserte datos en la tabla postuleo
el problema es que tomo el id usuario desde un update
HostEONS Special for LEB: Free DA + Blesta on a 1GB Ryzen from $3/mo in Los Angeles! Double your bandwidth, too!
Kapil from HostEONS contacted us to post an offer – welcome, Kapil!
He’s been in the IT industry since 1998. HostEONS is a Singapore-based company that offers KVM, OpenVZ, shared reseller, and dedicated hosting services.
This offer is for Los Angeles:
- Get a 1GB VPS with 15GB space, 1TB bandwidth, and free DirectAdmin Standard for $3/mo on annual or $4/mo if you pay monthly!
- Or step up to a 2GB with 30GB of disk and 2TB of bandwidth for $6/mo on annual or $8/mo if you pay monthly!
But wait, there’s more! Some very cool bonuses:
- Open a ticket (see below for details) after purchase and they will double your bandwidth!
- Use a coupon code (see below fore details) to get a free DirectAdmin server license!
- Free Blesta
- Free Windows 2019 License on Annual Payments with Ryzen 2 and larger packages
Pretty cool stuff!
Kapil shared a little more about HostEONS:
“HostEONS Pte. Ltd. is a hosting company that provides various hosting services like – VPS Hosting (Premium Ryzen KVM VPS, Budget KVM VPS with RAID 10 SSD, OpenVZ 7 based VPS in 5 locations – Los Angeles, Las Vegas, New York, Jacksonville, Dallas), Shared Web Hosting with Direct Admin, LiteSpeed, CloudLinux and more, Reseller Web Hosting also with DA, LiteSpeed, Cloud Linux etc.. Dedicated Servers, Domain Registration. We have 24×7 Support, we understand how important hosting services are for our clients hence we answer all support tickets as soon as possible, average ticket resolution time is 1 hour. Our VPS as well as Shared Web Hosting orders are processed and setup instantly upon payment and we accept a large variety of payment methods to make it easier for our clients to pay.”
Their WHOIS is public and they are registered in Singapore (Registration No. 201806413N). You can find their TOS on their website and you can pay with Credit/Debit Card (Stripe), PayPal, AliPay, UnionPay, BitCoin, WebMoney, Perfect Money, Yandex, Bank Wire Transfer, OXXO Mexico, Boleto Brasil, PayTM India, and Netbanking India.
Remember that the LEB community would love to hear about your experience in the comments section below!
Now read more to see the offers!
Special Offers
- Use coupon DA to get a free upgrade to Direct Admin Standard License
- Submit a support ticket with subject “LEB Double Bandwidth Offer” and HostEONS will double your bandwidth/data transfer.
- Free Blesta License
- Free Windows 2019 License on Annual Payments with Ryzen 2 and larger packages
RYZEN 1
|
RYZEN 2 |
NETWORK INFO
InterNAP – Los Angeles, CA, USA
Test IPv4: 103.114.160.160
Test IPv6: 2402:d0c0:0:26::7cbe
HOST NODE SPECIFICATIONS
-
Ryzen 3900X
-
128GB RAM
-
2x 2TB NVME
-
RAID1
-
10 Gbps uplink
Please let us know if you have any questions/comments and enjoy!