alsmanager_lib 2.0.86 → 2.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules.js +303 -36
- package/package.json +1 -1
package/lib/modules.js
CHANGED
|
@@ -3224,36 +3224,6 @@ function queryDeviceStatus(db_used, id_device, date_ref) {
|
|
|
3224
3224
|
return query;
|
|
3225
3225
|
}
|
|
3226
3226
|
//End Get Device Status
|
|
3227
|
-
// Insert device status
|
|
3228
|
-
function updateDeviceStatusSQLite(id_device) {
|
|
3229
|
-
var query = "update device_usage set date_end = date('now') ";
|
|
3230
|
-
query += "where id_device = " + id_device + " and date_status = (select max(date_status) from device_usage where id_device = " + id_device + ")";
|
|
3231
|
-
return query;
|
|
3232
|
-
}
|
|
3233
|
-
function updateDeviceStatusMySQL(id_device) {
|
|
3234
|
-
var query = "update device_usage set date_end = CURDATE() ";
|
|
3235
|
-
query += "where id_device = :id_device and date_status = (select max(date_status) from device_usage where id_device = :id_device)";
|
|
3236
|
-
return query;
|
|
3237
|
-
}
|
|
3238
|
-
function updateDeviceStatus(db_used, id_device) {
|
|
3239
|
-
var query = "";
|
|
3240
|
-
if (db_used) {
|
|
3241
|
-
switch (db_used) {
|
|
3242
|
-
case 'SQLITE':
|
|
3243
|
-
query = updateDeviceStatusSQLite(id_device);
|
|
3244
|
-
break;
|
|
3245
|
-
case 'MYSQL':
|
|
3246
|
-
query = updateDeviceStatusMySQL(id_device);
|
|
3247
|
-
break;
|
|
3248
|
-
case 'MYSQL2':
|
|
3249
|
-
query = updateDeviceStatusSQLite(id_device);
|
|
3250
|
-
break;
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
return query;
|
|
3254
|
-
}
|
|
3255
|
-
|
|
3256
|
-
// end manage updateDevicesStatus
|
|
3257
3227
|
// Manage insertDeviceStatus
|
|
3258
3228
|
function insertDeviceStatusSQLite(id_device, dev_status, start_date) {
|
|
3259
3229
|
var query = "insert into device_usage (date_status, id_device, status) ";
|
|
@@ -3315,7 +3285,40 @@ function insertDeviceStatus(db_used, id_device, dev_status, start_date) {
|
|
|
3315
3285
|
return query;
|
|
3316
3286
|
}
|
|
3317
3287
|
//end insert device status
|
|
3288
|
+
// Remove device status
|
|
3289
|
+
function removeDeviceStatusSQLite(id_device, dev_status) {
|
|
3290
|
+
var query = "delete from device_usage ";
|
|
3291
|
+
query += "where id_device = " + id_device + " and date_status = ";
|
|
3292
|
+
query += "(select max(date_status) from device_usage where id_device = " + id_device +") ";
|
|
3293
|
+
query += "and status = " + dev_status;
|
|
3294
|
+
return query;
|
|
3295
|
+
}
|
|
3296
|
+
function removeDeviceStatusMySQL(id_device, dev_status) {
|
|
3297
|
+
var query = "delete from device_usage ";
|
|
3298
|
+
query += "where id_device = :id_device and date_status = ";
|
|
3299
|
+
query += "(select max(date_status) from device_usage where id_device = :id_device) ";
|
|
3300
|
+
query += "and status = :dev_status";
|
|
3301
|
+
return query;
|
|
3302
|
+
}
|
|
3303
|
+
function removeDeviceStatus(db_used, id_device, dev_status) {
|
|
3304
|
+
var query = "";
|
|
3305
|
+
if (db_used) {
|
|
3306
|
+
switch (db_used) {
|
|
3307
|
+
case 'SQLITE':
|
|
3308
|
+
query = removeDeviceStatusSQLite(id_device, dev_status);
|
|
3309
|
+
break;
|
|
3310
|
+
case 'MYSQL':
|
|
3311
|
+
query = removeDeviceStatusMySQL(id_device, dev_status);
|
|
3312
|
+
break;
|
|
3313
|
+
case 'MYSQL2':
|
|
3314
|
+
query = removeDeviceStatusSQLite(id_device, dev_status);
|
|
3315
|
+
break;
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
return query;
|
|
3319
|
+
}
|
|
3318
3320
|
|
|
3321
|
+
// end manage updateDevicesStatus
|
|
3319
3322
|
|
|
3320
3323
|
//Insert Device
|
|
3321
3324
|
function insertDeviceSQLite(dev) {
|
|
@@ -9222,7 +9225,7 @@ function queryFunzioneByPlaceAndFloor(db_used, id_place, piano) {
|
|
|
9222
9225
|
|
|
9223
9226
|
|
|
9224
9227
|
function querySitesSQLite(place, piano, funzione) {
|
|
9225
|
-
var query = "SELECT sd.id_site as id, s.id_place as Plesso, sd.name as Nome, s.mark as Codice, s.floor as Piano, sd.type as Funzione from site_destinations sd";
|
|
9228
|
+
var query = "SELECT DISTINCT sd.id_site as id, s.id_place as Plesso, sd.name as Nome, s.mark as Codice, s.floor as Piano, sd.type as Funzione from site_destinations sd";
|
|
9226
9229
|
query += " LEFT JOIN sites s ON s.id = sd.id_site"
|
|
9227
9230
|
query += " where date('now') >= sd.date_start and date('now') <= sd.date_end";
|
|
9228
9231
|
|
|
@@ -9260,7 +9263,7 @@ function querySitesMySQL(place, piano, funzione) {
|
|
|
9260
9263
|
}
|
|
9261
9264
|
|
|
9262
9265
|
function querySitesMySQL2(place, piano, funzione) {
|
|
9263
|
-
var query = "SELECT sd.id_site as id, s.id_place as Plesso, sd.name as Nome, s.mark as Codice, s.floor as Piano, sd.type as Funzione from site_destinations sd";
|
|
9266
|
+
var query = "SELECT DISTINCT sd.id_site as id, s.id_place as Plesso, sd.name as Nome, s.mark as Codice, s.floor as Piano, sd.type as Funzione from site_destinations sd";
|
|
9264
9267
|
query += " LEFT JOIN sites s ON s.id = sd.id_site"
|
|
9265
9268
|
query += " where CURDATE() >= sd.date_start and CURDATE() <= sd.date_end";
|
|
9266
9269
|
|
|
@@ -9363,7 +9366,7 @@ function getSitesFromDevice(db_used, id_device, prec_pos) {
|
|
|
9363
9366
|
//End Sites by devices
|
|
9364
9367
|
//Sites from device with date
|
|
9365
9368
|
function getSitesWithDatesFromDeviceSQLite(id_device) {
|
|
9366
|
-
var query = "SELECT ds.date_in as 'Data inizio', ds.date_out as 'Data fine', sd.id_place as Plesso, s.mark as Sigla, sd.name as Destinazione from device_site ds ";
|
|
9369
|
+
var query = "SELECT DISTINCT ds.date_in as 'Data inizio', ds.date_out as 'Data fine', sd.id_place as Plesso, s.mark as Sigla, sd.name as Destinazione from device_site ds ";
|
|
9367
9370
|
query += "join site_destinations sd on sd.id_site = ds.id_site ";
|
|
9368
9371
|
query += "join sites s on s.id = sd.id_site ";
|
|
9369
9372
|
query += "where ds.id_device = " + id_device;
|
|
@@ -9372,7 +9375,7 @@ function getSitesWithDatesFromDeviceSQLite(id_device) {
|
|
|
9372
9375
|
}
|
|
9373
9376
|
|
|
9374
9377
|
function getSitesWithDatesFromDeviceMySQL(id_device) {
|
|
9375
|
-
var query = "SELECT ds.date_in as 'Data inizio', ds.date_out as 'Data fine', sd.id_place as Plesso, s.mark as Sigla, sd.name as Destinazione from device_site ds ";
|
|
9378
|
+
var query = "SELECT DISTINCT ds.date_in as 'Data inizio', ds.date_out as 'Data fine', sd.id_place as Plesso, s.mark as Sigla, sd.name as Destinazione from device_site ds ";
|
|
9376
9379
|
query += "join site_destinations sd on sd.id_site = ds.id_site ";
|
|
9377
9380
|
query += "join sites s on s.id = sd.id_site ";
|
|
9378
9381
|
query += "where ds.id_device = :id_device ";
|
|
@@ -11095,6 +11098,262 @@ function exportDBSQL(db_used, db_path, dump_path, dump_filename) {
|
|
|
11095
11098
|
return query;
|
|
11096
11099
|
}
|
|
11097
11100
|
//end ExportDB
|
|
11101
|
+
// Manage template models
|
|
11102
|
+
function getConnectionsFromTemplateSQLite(dev_model, dev_manifacturer, dev_type) {
|
|
11103
|
+
var query = "select dm_conn_type, dm_conn_protocol, dm_conn_number, dm_conn_verse from tpl_model_connectors ";
|
|
11104
|
+
query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
|
|
11105
|
+
return query;
|
|
11106
|
+
}
|
|
11107
|
+
|
|
11108
|
+
function getConnectionsFromTemplateMySQL(dev_model, dev_manifacturer, dev_type) {
|
|
11109
|
+
var query = "select dm_conn_type, dm_conn_protocol, dm_conn_number, dm_conn_verse from tpl_model_connectors ";
|
|
11110
|
+
query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
|
|
11111
|
+
return query;
|
|
11112
|
+
}
|
|
11113
|
+
|
|
11114
|
+
function getConnectionsFromTemplate(db_used, dev_model, dev_manifacturer, dev_type) {
|
|
11115
|
+
var query = "";
|
|
11116
|
+
if (db_used) {
|
|
11117
|
+
switch (db_used) {
|
|
11118
|
+
case 'SQLITE':
|
|
11119
|
+
query = getConnectionsFromTemplateSQLite(dev_model, dev_manifacturer, dev_type);
|
|
11120
|
+
break;
|
|
11121
|
+
case 'MYSQL':
|
|
11122
|
+
query = getConnectionsFromTemplateMySQL(dev_model, dev_manifacturer, dev_type);
|
|
11123
|
+
break;
|
|
11124
|
+
case 'MYSQL2':
|
|
11125
|
+
query = getConnectionsFromTemplateSQLite(dev_model, dev_manifacturer, dev_type);
|
|
11126
|
+
break;
|
|
11127
|
+
}
|
|
11128
|
+
}
|
|
11129
|
+
return query;
|
|
11130
|
+
}
|
|
11131
|
+
|
|
11132
|
+
function insertConnectionsToTemplateSQLite(dev_model, dev_manifacturer, dev_type, conn_obj) {
|
|
11133
|
+
var query = "insert into tpl_model_connectors (device_type, device_manifacturer, device_model, conn_type, conn_protocol, conn_number, conn_verse) values ";
|
|
11134
|
+
query += "('" + dev_type + "', '" + dev_manifacturer + "', '" + dev_model + "', "
|
|
11135
|
+
query += conn_obj.tipo + ", " + conn_obj.protocollo + ", " + conn_obj.numero + ", '" + conn_obj.verso + "')";
|
|
11136
|
+
return query;
|
|
11137
|
+
}
|
|
11138
|
+
|
|
11139
|
+
function insertConnectionsToTemplateMySQL(dev_model, dev_manifacturer, dev_type, conn_obj) {
|
|
11140
|
+
var query = "insert into tpl_model_connectors (device_type, device_manifacturer, device_model, conn_type, conn_protocol, conn_number, conn_verse) values ";
|
|
11141
|
+
query += "(:dev_type, :dev_manifacturer, :dev_model, "
|
|
11142
|
+
query += ":tipo, :protocollo, :numero, :verso)";
|
|
11143
|
+
return query;
|
|
11144
|
+
}
|
|
11145
|
+
|
|
11146
|
+
function insertConnectionsToTemplate(db_used, dev_model, dev_manifacturer, dev_type, conn_obj) {
|
|
11147
|
+
var query = "";
|
|
11148
|
+
if (db_used) {
|
|
11149
|
+
switch (db_used) {
|
|
11150
|
+
case 'SQLITE':
|
|
11151
|
+
query = insertConnectionsToTemplateSQLite(dev_model, dev_manifacturer, dev_type, conn_obj);
|
|
11152
|
+
break;
|
|
11153
|
+
case 'MYSQL':
|
|
11154
|
+
query = insertConnectionsToTemplateMySQL(dev_model, dev_manifacturer, dev_type, conn_obj);
|
|
11155
|
+
break;
|
|
11156
|
+
case 'MYSQL2':
|
|
11157
|
+
query = insertConnectionsToTemplateSQLite(dev_model, dev_manifacturer, dev_type, conn_obj);
|
|
11158
|
+
break;
|
|
11159
|
+
}
|
|
11160
|
+
}
|
|
11161
|
+
return query;
|
|
11162
|
+
}
|
|
11163
|
+
|
|
11164
|
+
|
|
11165
|
+
function updateConnectionsToTemplateSQLite(dev_model, dev_manifacturer, dev_type, conn_obj) {
|
|
11166
|
+
var query = "update tpl_model_connectors "
|
|
11167
|
+
query += "set conn_type = " + conn_obj.tipo + ", ";
|
|
11168
|
+
query += "conn_protocol = " + conn_obj.protocollo + ", ";
|
|
11169
|
+
query += "conn_number = " + conn_obj.numero + ", ";
|
|
11170
|
+
query += "conn_verse = '" + conn_obj.verso + "' ";
|
|
11171
|
+
query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
|
|
11172
|
+
}
|
|
11173
|
+
|
|
11174
|
+
function updateConnectionsToTemplateMySQL(dev_model, dev_manifacturer, dev_type, conn_obj) {
|
|
11175
|
+
var query = "update tpl_model_connectors "
|
|
11176
|
+
query += "set conn_type = :tipo, ";
|
|
11177
|
+
query += "conn_protocol = :protocollo, ";
|
|
11178
|
+
query += "conn_number = :numero, ";
|
|
11179
|
+
query += "conn_verse = :verso ";
|
|
11180
|
+
query += "where device_type = :dev_type and device_manifacturer = :dev_manifacturer and device_model = :dev_model";
|
|
11181
|
+
}
|
|
11182
|
+
|
|
11183
|
+
function updateConnectionsToTemplate(db_used, dev_model, dev_manifacturer, dev_type, conn_obj) {
|
|
11184
|
+
var query = "";
|
|
11185
|
+
if (db_used) {
|
|
11186
|
+
switch (db_used) {
|
|
11187
|
+
case 'SQLITE':
|
|
11188
|
+
query = updateConnectionsToTemplateSQLite(dev_model, dev_manifacturer, dev_type, conn_obj);
|
|
11189
|
+
break;
|
|
11190
|
+
case 'MYSQL':
|
|
11191
|
+
query = updateConnectionsToTemplateMySQL(dev_model, dev_manifacturer, dev_type, conn_obj);
|
|
11192
|
+
break;
|
|
11193
|
+
case 'MYSQL2':
|
|
11194
|
+
query = updateConnectionsToTemplateSQLite(dev_model, dev_manifacturer, dev_type, conn_obj);
|
|
11195
|
+
break;
|
|
11196
|
+
}
|
|
11197
|
+
}
|
|
11198
|
+
return query;
|
|
11199
|
+
}
|
|
11200
|
+
|
|
11201
|
+
function removeConnectorFromTemplateSQLite(dev_model, dev_manifacturer, dev_type) {
|
|
11202
|
+
var query = "delete from tpl_model_connectors ";
|
|
11203
|
+
query += "where device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
|
|
11204
|
+
return query;
|
|
11205
|
+
}
|
|
11206
|
+
|
|
11207
|
+
function removeConnectorFromTemplateMySQL(dev_model, dev_manifacturer, dev_type) {
|
|
11208
|
+
var query = "delete from tpl_model_connectors ";
|
|
11209
|
+
query += "where device_type = :dev_type and device_manifacturer = :dev_manifacturer and device_model = :dev_model";
|
|
11210
|
+
return query;
|
|
11211
|
+
}
|
|
11212
|
+
function removeConnectorFromTemplate(db_used, dev_model, dev_manifacturer, dev_type) {
|
|
11213
|
+
var query = "";
|
|
11214
|
+
if (db_used) {
|
|
11215
|
+
switch (db_used) {
|
|
11216
|
+
case 'SQLITE':
|
|
11217
|
+
query = removeConnectorFromTemplateSQLite(dev_model, dev_manifacturer, dev_type);
|
|
11218
|
+
break;
|
|
11219
|
+
case 'MYSQL':
|
|
11220
|
+
query = removeConnectorFromTemplateMySQL(dev_model, dev_manifacturer, dev_type);
|
|
11221
|
+
break;
|
|
11222
|
+
case 'MYSQL2':
|
|
11223
|
+
query = removeConnectorFromTemplateSQLite(dev_model, dev_manifacturer, dev_type);
|
|
11224
|
+
break;
|
|
11225
|
+
}
|
|
11226
|
+
}
|
|
11227
|
+
return query;
|
|
11228
|
+
}
|
|
11229
|
+
|
|
11230
|
+
function insertConnectionsToTemplateFromIdDeviceSQLite(id_device) {
|
|
11231
|
+
var query = "insert into tpl_model_connectors (device_type, device_manifacturer, device_model, dm_conn_type, dm_conn_protocol, dm_conn_number, dm_conn_verse) ";
|
|
11232
|
+
query += "select d.type, d.manifacturer, d.model, dc.conn_type, dc.conn_protocol, dc.conn_number, dc.conn_verse from devices d ";
|
|
11233
|
+
query += "left join device_connectors dc on d.id = dc.id_device ";
|
|
11234
|
+
query += "where dc.id is not null and d.id = " + id_device + " ";
|
|
11235
|
+
query += "and (select count(*) from tpl_model_connectors where device_type = d.type ";
|
|
11236
|
+
query += "and device_manifacturer = d.manifacturer ";
|
|
11237
|
+
query += "and device_model = d.model ";
|
|
11238
|
+
query += "and dm_conn_type = dc.conn_type ";
|
|
11239
|
+
query += "and dm_conn_protocol = dc.conn_protocol ";
|
|
11240
|
+
query += "and dm_conn_verse = dc.conn_verse) = 0";
|
|
11241
|
+
return query;
|
|
11242
|
+
}
|
|
11243
|
+
|
|
11244
|
+
function insertConnectionsToTemplateFromIdDeviceMySQL(id_device) {
|
|
11245
|
+
var query = "insert into tpl_model_connectors (device_type, device_manifacturer, device_model, dm_conn_type, dm_conn_protocol, dm_conn_number, dm_conn_verse) ";
|
|
11246
|
+
query += "select d.type, d.manifacturer, d.model, dc.conn_type, dc.conn_protocol, dc.conn_number, dc.conn_verse from devices d ";
|
|
11247
|
+
query += "left join device_connectors dc on d.id = dc.id_device ";
|
|
11248
|
+
query += "where dc.id is not null and d.id = :id_device";
|
|
11249
|
+
query += "and (select count(*) from tpl_model_connectors where device_type = d.type ";
|
|
11250
|
+
query += "and device_manifacturer = d.manifacturer ";
|
|
11251
|
+
query += "and device_model = d.model ";
|
|
11252
|
+
query += "and dm_conn_type = dc.conn_type ";
|
|
11253
|
+
query += "and dm_conn_protocol = dc.conn_protocol ";
|
|
11254
|
+
query += "and dm_conn_verse = dc.conn_verse) = 0";
|
|
11255
|
+
return query;
|
|
11256
|
+
}
|
|
11257
|
+
|
|
11258
|
+
function insertConnectionsToTemplateFromIdDevice(db_used, id_device) {
|
|
11259
|
+
var query = "";
|
|
11260
|
+
if (db_used) {
|
|
11261
|
+
switch (db_used) {
|
|
11262
|
+
case 'SQLITE':
|
|
11263
|
+
query = insertConnectionsToTemplateFromIdDeviceSQLite(id_device);
|
|
11264
|
+
break;
|
|
11265
|
+
case 'MYSQL':
|
|
11266
|
+
query = insertConnectionsToTemplateFromIdDeviceMySQL(id_device);
|
|
11267
|
+
break;
|
|
11268
|
+
case 'MYSQL2':
|
|
11269
|
+
query = insertConnectionsToTemplateFromIdDeviceSQLite(id_device);
|
|
11270
|
+
break;
|
|
11271
|
+
}
|
|
11272
|
+
}
|
|
11273
|
+
return query;
|
|
11274
|
+
}
|
|
11275
|
+
|
|
11276
|
+
function existConnectionTemplateSQLite(dev_model, dev_manifacturer, dev_type) {
|
|
11277
|
+
var query = "select count(*) as num from tpl_model_connectors ";
|
|
11278
|
+
query += "device_type = '" + dev_type + "' and device_manifacturer = '" + dev_manifacturer + "' and device_model = '" + dev_model + "'";
|
|
11279
|
+
return query;
|
|
11280
|
+
}
|
|
11281
|
+
|
|
11282
|
+
function existConnectionTemplateMySQL(dev_model, dev_manifacturer, dev_type) {
|
|
11283
|
+
var query = "select count(*) as num from tpl_model_connectors ";
|
|
11284
|
+
query += "where device_type = :dev_type and device_manifacturer = :dev_manifacturer and device_model = :dev_model";
|
|
11285
|
+
return query;
|
|
11286
|
+
}
|
|
11287
|
+
function existConnectionTemplate(dev_model, dev_manifacturer, dev_type) {
|
|
11288
|
+
var query = "";
|
|
11289
|
+
if (db_used) {
|
|
11290
|
+
switch (db_used) {
|
|
11291
|
+
case 'SQLITE':
|
|
11292
|
+
query = existConnectionTemplateSQLite(dev_model, dev_manifacturer, dev_type);
|
|
11293
|
+
break;
|
|
11294
|
+
case 'MYSQL':
|
|
11295
|
+
query = existConnectionTemplateMySQL(dev_model, dev_manifacturer, dev_type);
|
|
11296
|
+
break;
|
|
11297
|
+
case 'MYSQL2':
|
|
11298
|
+
query = existConnectionTemplateSQLite(dev_model, dev_manifacturer, dev_type);
|
|
11299
|
+
break;
|
|
11300
|
+
}
|
|
11301
|
+
}
|
|
11302
|
+
return query;
|
|
11303
|
+
}
|
|
11304
|
+
|
|
11305
|
+
|
|
11306
|
+
|
|
11307
|
+
function insertConnectionsFromTemplateIntoDeviceSQLite(id_dev_ref) {
|
|
11308
|
+
var query = "insert into device_connectors (id_device, conn_type, conn_protocol, conn_number, conn_verse) ";
|
|
11309
|
+
query += "select d.id, tmc.dm_conn_type, tmc.dm_conn_protocol, tmc.dm_conn_number, tmc.dm_conn_verse from tpl_model_connectors tmc ";
|
|
11310
|
+
query += "join devices d on d.type = tmc.device_type ";
|
|
11311
|
+
query += "and d.type = tmc.device_type ";
|
|
11312
|
+
query += "and d.manifacturer = tmc.device_manifacturer ";
|
|
11313
|
+
query += "and d.model = tmc.device_model ";
|
|
11314
|
+
query += "where d.id = " + id_dev_ref + " ";
|
|
11315
|
+
query += "and (select count(*) from device_connectors where id_device = d.id ";
|
|
11316
|
+
query += "and conn_type = tmc.dm_conn_type ";
|
|
11317
|
+
query += "and conn_protocol = tmc.dm_conn_protocol ";
|
|
11318
|
+
query += "and conn_verse = tmc.dm_conn_verse) = 0";
|
|
11319
|
+
return query;
|
|
11320
|
+
}
|
|
11321
|
+
|
|
11322
|
+
function insertConnectionsFromTemplateIntoDeviceMySQL(id_dev_ref) {
|
|
11323
|
+
var query = "insert into device_connectors (id_device, conn_type, conn_protocol, conn_number, conn_verse) ";
|
|
11324
|
+
query += "select d.id, tmc.dm_conn_type, tmc.dm_conn_protocol, tmc.dm_conn_number, tmc.dm_conn_verse from tpl_model_connectors tmc ";
|
|
11325
|
+
query += "join devices d on d.type = tmc.device_type ";
|
|
11326
|
+
query += "and d.type = tmc.device_type ";
|
|
11327
|
+
query += "and d.manifacturer = tmc.device_manifacturer ";
|
|
11328
|
+
query += "and d.model = tmc.device_model ";
|
|
11329
|
+
query += "where d.id = :id_device ";
|
|
11330
|
+
query += "and (select count(*) from device_connectors where id_device = d.id ";
|
|
11331
|
+
query += "and conn_type = tmc.dm_conn_type ";
|
|
11332
|
+
query += "and conn_protocol = tmc.dm_conn_protocol ";
|
|
11333
|
+
query += "and conn_verse = tmc.dm_conn_verse) = 0";
|
|
11334
|
+
return query;
|
|
11335
|
+
}
|
|
11336
|
+
|
|
11337
|
+
function insertConnectionsFromTemplateIntoDevice(db_used, id_dev_ref) {
|
|
11338
|
+
var query = "";
|
|
11339
|
+
if (db_used) {
|
|
11340
|
+
switch (db_used) {
|
|
11341
|
+
case 'SQLITE':
|
|
11342
|
+
query = insertConnectionsFromTemplateIntoDeviceSQLite(id_dev_ref);
|
|
11343
|
+
break;
|
|
11344
|
+
case 'MYSQL':
|
|
11345
|
+
query = insertConnectionsFromTemplateIntoDeviceMySQL(id_dev_ref);
|
|
11346
|
+
break;
|
|
11347
|
+
case 'MYSQL2':
|
|
11348
|
+
query = insertConnectionsFromTemplateIntoDeviceSQLite(id_dev_ref);
|
|
11349
|
+
break;
|
|
11350
|
+
}
|
|
11351
|
+
}
|
|
11352
|
+
return query;
|
|
11353
|
+
}
|
|
11354
|
+
|
|
11355
|
+
// End Manage template models
|
|
11356
|
+
|
|
11098
11357
|
// Exports
|
|
11099
11358
|
|
|
11100
11359
|
module.exports = {
|
|
@@ -11115,8 +11374,8 @@ module.exports = {
|
|
|
11115
11374
|
getDevicesCounterBySite,
|
|
11116
11375
|
getDevicesCounterByPlace,
|
|
11117
11376
|
queryDeviceStatus,
|
|
11118
|
-
updateDeviceStatus,
|
|
11119
11377
|
insertDeviceStatus,
|
|
11378
|
+
removeDeviceStatus,
|
|
11120
11379
|
getDevicesSelectByPlace,
|
|
11121
11380
|
queryLastDeviceId,
|
|
11122
11381
|
queryOSList,
|
|
@@ -11373,6 +11632,14 @@ module.exports = {
|
|
|
11373
11632
|
createConsegnaDoc,
|
|
11374
11633
|
createConsegnaBckDoc,
|
|
11375
11634
|
createIstruzioniStandard,
|
|
11376
|
-
exportDBSQL
|
|
11635
|
+
exportDBSQL,
|
|
11636
|
+
//
|
|
11637
|
+
getConnectionsFromTemplate,
|
|
11638
|
+
insertConnectionsToTemplate,
|
|
11639
|
+
updateConnectionsToTemplate,
|
|
11640
|
+
removeConnectorFromTemplate,
|
|
11641
|
+
insertConnectionsToTemplateFromIdDevice,
|
|
11642
|
+
existConnectionTemplate,
|
|
11643
|
+
insertConnectionsFromTemplateIntoDevice
|
|
11377
11644
|
};
|
|
11378
11645
|
// end of source
|