mirror of https://git.48k.eu/ogserver
#941 use dbi layer from RESPUESTA_CrearSoftIncremental
parent
9cc156c65a
commit
f482bda9d2
|
@ -1658,25 +1658,16 @@ static bool RESPUESTA_CrearImagenBasica(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cli)
|
static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cli)
|
||||||
{
|
{
|
||||||
Database db;
|
|
||||||
Table tbl;
|
|
||||||
char *iph,*par,*ido,*idf;
|
char *iph,*par,*ido,*idf;
|
||||||
int ifs;
|
int ifs;
|
||||||
char msglog[LONSTD],sqlstr[LONSQL];
|
const char *msglog;
|
||||||
struct og_dbi *dbi;
|
struct og_dbi *dbi;
|
||||||
|
dbi_result result;
|
||||||
if (!db.Open(usuario, pasguor, datasource, catalog)) {
|
|
||||||
db.GetErrorErrStr(msglog);
|
|
||||||
syslog(LOG_ERR, "cannot open connection database (%s:%d) %s\n",
|
|
||||||
__func__, __LINE__, msglog);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbi = og_dbi_open(&dbi_config);
|
dbi = og_dbi_open(&dbi_config);
|
||||||
if (!dbi) {
|
if (!dbi) {
|
||||||
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
db.Close();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1694,37 +1685,49 @@ static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cl
|
||||||
par = copiaParametro("par",ptrTrama);
|
par = copiaParametro("par",ptrTrama);
|
||||||
|
|
||||||
/* Toma identificador del perfilsoftware creado por el inventario de software */
|
/* Toma identificador del perfilsoftware creado por el inventario de software */
|
||||||
sprintf(sqlstr,"SELECT idperfilsoft FROM ordenadores_particiones WHERE idordenador=%s AND numpar=%s",ido,par);
|
result = dbi_conn_queryf(dbi->conn,
|
||||||
|
"SELECT idperfilsoft FROM ordenadores_particiones WHERE idordenador=%s AND numpar=%s",
|
||||||
|
ido, par);
|
||||||
liberaMemoria(iph);
|
liberaMemoria(iph);
|
||||||
liberaMemoria(ido);
|
liberaMemoria(ido);
|
||||||
liberaMemoria(par);
|
liberaMemoria(par);
|
||||||
|
|
||||||
if (!db.Execute(sqlstr, tbl)) {
|
if (!result) {
|
||||||
db.GetErrorErrStr(msglog);
|
dbi_conn_error(dbi->conn, &msglog);
|
||||||
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
||||||
__func__, __LINE__, msglog);
|
__func__, __LINE__, msglog);
|
||||||
|
og_dbi_close(dbi);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!tbl.Get("idperfilsoft", ifs)) { // Toma dato
|
if (!dbi_result_next_row(result)) {
|
||||||
tbl.GetErrorErrStr(msglog); // Error al acceder al registro
|
syslog(LOG_ERR,
|
||||||
og_info(msglog);
|
"software profile does not exist in database (%s:%d)\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
dbi_result_free(result);
|
||||||
|
og_dbi_close(dbi);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
ifs = dbi_result_get_uint(result, "idperfilsoft");
|
||||||
|
dbi_result_free(result);
|
||||||
|
|
||||||
/* Actualizar los datos de la imagen */
|
/* Actualizar los datos de la imagen */
|
||||||
idf = copiaParametro("idf", ptrTrama);
|
idf = copiaParametro("idf", ptrTrama);
|
||||||
sprintf(sqlstr,"UPDATE imagenes SET idperfilsoft=%d WHERE idimagen=%s",ifs,idf);
|
result = dbi_conn_queryf(dbi->conn,
|
||||||
|
"UPDATE imagenes SET idperfilsoft=%d WHERE idimagen=%s",
|
||||||
|
ifs, idf);
|
||||||
liberaMemoria(idf);
|
liberaMemoria(idf);
|
||||||
|
|
||||||
if (!db.Execute(sqlstr, tbl)) {
|
if (!result) {
|
||||||
db.GetErrorErrStr(msglog);
|
dbi_conn_error(dbi->conn, &msglog);
|
||||||
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
|
||||||
__func__, __LINE__, msglog);
|
__func__, __LINE__, msglog);
|
||||||
|
og_dbi_close(dbi);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
dbi_result_free(result);
|
||||||
|
|
||||||
og_dbi_close(dbi);
|
og_dbi_close(dbi);
|
||||||
db.Close(); // Cierra conexión
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// ________________________________________________________________________________________________________
|
// ________________________________________________________________________________________________________
|
||||||
|
|
Loading…
Reference in New Issue