summaryrefslogtreecommitdiffstats
path: root/admin
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
commitf6322a5b90065e78877ccfeaa36f698418ee7255 (patch)
tree3ee7073656b08ce178e3a53438a9d21b7f10e47f /admin
parent7a8fae67ed4b0843ae7e0f835675b87b3d1e24ca (diff)
#941 use dbi layer from RESPUESTA_CrearSoftIncremental
Diffstat (limited to 'admin')
-rw-r--r--admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp b/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp
index e3db6070..86554b44 100644
--- a/admin/Sources/Services/ogAdmServer/sources/ogAdmServer.cpp
+++ b/admin/Sources/Services/ogAdmServer/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;
}
// ________________________________________________________________________________________________________