summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2019-11-26 12:23:23 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-03-04 14:55:01 +0100
commitf482bda9d26fc577b9f2458147270331efab0666 (patch)
tree48f0609a5c984a148fdeb016bc3b72dec6597abc
parent9cc156c65ab04c8b9d23def4b06ea84af92c68a4 (diff)
#941 use dbi layer from RESPUESTA_CrearSoftIncremental
-rw-r--r--sources/ogAdmServer.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp
index e3db607..86554b4 100644
--- a/sources/ogAdmServer.cpp
+++ b/sources/ogAdmServer.cpp
@@ -1658,25 +1658,16 @@ static bool RESPUESTA_CrearImagenBasica(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;
int ifs;
- char msglog[LONSTD],sqlstr[LONSQL];
+ const char *msglog;
struct og_dbi *dbi;
-
- 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_result result;
dbi = og_dbi_open(&dbi_config);
if (!dbi) {
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
__func__, __LINE__);
- db.Close();
return false;
}
@@ -1694,37 +1685,49 @@ static bool RESPUESTA_CrearSoftIncremental(TRAMA* ptrTrama, struct og_client *cl
par = copiaParametro("par",ptrTrama);
/* 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(ido);
liberaMemoria(par);
- if (!db.Execute(sqlstr, tbl)) {
- db.GetErrorErrStr(msglog);
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
__func__, __LINE__, msglog);
+ og_dbi_close(dbi);
return false;
}
- if (!tbl.Get("idperfilsoft", ifs)) { // Toma dato
- tbl.GetErrorErrStr(msglog); // Error al acceder al registro
- og_info(msglog);
+ if (!dbi_result_next_row(result)) {
+ syslog(LOG_ERR,
+ "software profile does not exist in database (%s:%d)\n",
+ __func__, __LINE__);
+ dbi_result_free(result);
+ og_dbi_close(dbi);
return false;
}
+ ifs = dbi_result_get_uint(result, "idperfilsoft");
+ dbi_result_free(result);
/* Actualizar los datos de la imagen */
- idf = copiaParametro("idf",ptrTrama);
- sprintf(sqlstr,"UPDATE imagenes SET idperfilsoft=%d WHERE idimagen=%s",ifs,idf);
+ idf = copiaParametro("idf", ptrTrama);
+ result = dbi_conn_queryf(dbi->conn,
+ "UPDATE imagenes SET idperfilsoft=%d WHERE idimagen=%s",
+ ifs, idf);
liberaMemoria(idf);
- if (!db.Execute(sqlstr, tbl)) {
- db.GetErrorErrStr(msglog);
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
__func__, __LINE__, msglog);
+ og_dbi_close(dbi);
return false;
}
+ dbi_result_free(result);
+
og_dbi_close(dbi);
- db.Close(); // Cierra conexión
+
return true;
}
// ________________________________________________________________________________________________________