alsmanager_lib 2.0.96 → 2.0.98

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 CHANGED
@@ -2712,6 +2712,56 @@ function getDevicesSelect(db_used, search_type, inv_code, dev_type, marca, dev_m
2712
2712
  return query;
2713
2713
  }
2714
2714
  // End Device select
2715
+ // Select by idDoc
2716
+ function getDevicesByIdDocSQLite(id_doc) {
2717
+ var query = "SELECT DISTINCT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2718
+ query += "case ";
2719
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
2720
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
2721
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
2722
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
2723
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
2724
+ query += "end as Codice ";
2725
+ query += "from devices d ";
2726
+ query += "left join device_doc dd on d.id = dd.id_device ";
2727
+ query += "where dd.id = " + id_doc + " ";
2728
+ query += "order by d.inv_ict3_number, d.inv_tn_number, d.inv_tndigit_number, d.serial_no";
2729
+ return query;
2730
+ }
2731
+
2732
+ function getDevicesByIdDocMySQL(id_doc) {
2733
+ var query = "SELECT DISTINCT d.id, d.type as Tipo, d.manifacturer as Marca, d.model as Modello, ";
2734
+ query += "case ";
2735
+ query += "when d.inv_ict3_number != '' and d.inv_ict3_number is not null then d.inv_ict3_number ";
2736
+ query += "when d.inv_pnrr_number != '' and d.inv_pnrr_number is not null then d.inv_pnrr_number ";
2737
+ query += "when d.inv_tn_number != '' and d.inv_tn_number is not null then concat(d.inv_tn_number,'(TN)') ";
2738
+ query += "when d.inv_tndigit_number != '' and d.inv_tndigit_number is not null then concat(d.inv_tndigit_number,'(TNDigit)') ";
2739
+ query += "when d.serial_no != '' and d.serial_no is not null then concat(d.serial_no,'(S/N)') ";
2740
+ query += "end as Codice ";
2741
+ query += "from devices d ";
2742
+ query += "left join device_doc dd on d.id = dd.id_device ";
2743
+ query += "where dd.id = " + id_doc + " ";
2744
+ query += "order by d.inv_ict3_number, d.inv_tn_number, d.inv_tndigit_number, d.serial_no";
2745
+ return query;
2746
+ }
2747
+
2748
+ function getDevicesByIdDoc(db_used, id_doc) {
2749
+ var query = "";
2750
+ if (db_used) {
2751
+ switch (db_used) {
2752
+ case 'SQLITE':
2753
+ query = getDevicesByIdDocSQLite(id_doc);
2754
+ break;
2755
+ case 'MYSQL':
2756
+ query = getDevicesByIdDocMySQL(id_doc);
2757
+ break;
2758
+ case 'MYSQL2':
2759
+ query = getDevicesByIdDocSQLite(id_doc);
2760
+ break;
2761
+ }
2762
+ }
2763
+ return query;
2764
+ }
2715
2765
  // Device Select by site
2716
2766
  function getDevicesSelectBySiteSQLite(id_site, dev_type) {
2717
2767
  var query = "select distinct d.id, d.type as Tipo, d.manifacturer as Marca, d.model as modello, ";
@@ -8504,6 +8554,65 @@ function queryDocumentoMotivo() {
8504
8554
  return "select scopo, descrizione from documento_scopo order by scopo";
8505
8555
  }
8506
8556
 
8557
+
8558
+ function selectDocumentsSQLite(tipo, anno_emissione) {
8559
+ var where_clause = "";
8560
+ var query = "select id, tipo, anno, descrizione, data_emissione, riferimento, nome_originale from documenti ";
8561
+ if (tipo || anno_emissione) {
8562
+ where_clause = "where ";
8563
+ if (tipo) {
8564
+ where_clause += "tipo = '" + tipo + "' ";
8565
+ if (anno_emissione) {
8566
+ where_clause += " and ";
8567
+ }
8568
+ }
8569
+ if (anno_emissione){
8570
+ where_clause += "anno = " + anno_emissione + " ";
8571
+ }
8572
+ }
8573
+ query += where_clause;
8574
+ query += "order by data_emissione desc";
8575
+ return query;
8576
+ }
8577
+
8578
+ function selectDocumentsMySQL(tipo, anno_emissione) {
8579
+ var where_clause = "";
8580
+ var query = "select id, tipo, anno, descrizione, data_emissione, riferimento, nome_originale from documenti ";
8581
+ if (tipo || anno_emissione) {
8582
+ where_clause = "where ";
8583
+ if (tipo) {
8584
+ where_clause += "tipo = :tipo ";
8585
+ if (anno_emissione) {
8586
+ where_clause += " and ";
8587
+ }
8588
+ }
8589
+ if (anno_emissione){
8590
+ where_clause += "anno = :anno_emissione ";
8591
+ }
8592
+ }
8593
+ query += where_clause;
8594
+ query += "order by data_emissione desc";
8595
+ return query;
8596
+ }
8597
+
8598
+ function selectDocuments(db_used, tipo, anno_emissione) {
8599
+ var query = "";
8600
+ if (db_used) {
8601
+ switch (db_used) {
8602
+ case 'SQLITE':
8603
+ query = selectDocumentsSQLite(tipo, anno_emissione);
8604
+ break;
8605
+ case 'MYSQL':
8606
+ query = selectDocumentsMySQL(tipo, anno_emissione);
8607
+ break;
8608
+ case 'MYSQL2':
8609
+ query = selectDocumentsSQLite(tipo, anno_emissione);
8610
+ break;
8611
+ }
8612
+ }
8613
+ return query;
8614
+ }
8615
+
8507
8616
  function selectDocumentiComboSQLite(tipo, anno_emissione) {
8508
8617
  var where_clause = "";
8509
8618
  var query = "select id, concat(tipo, ' - ', descrizione, ' - ', data_emissione, ' - ', riferimento) as doc from documenti ";
@@ -8564,68 +8673,70 @@ function selectDocumentiCombo(db_used, tipo, anno_emissione) {
8564
8673
 
8565
8674
 
8566
8675
 
8567
- function insertDocumentoSQLite(descrizione, tipo, data_emissione, riferimento, file_name) {
8568
- var query = "insert into documenti (descrizione, tipo, data_emissione, riferimento, file_name) values ";
8569
- query += "('" + descrizione + "', '" + tipo + "', '" + data_emissione + "', '" + riferimento + "', '" + file_name + "')";
8676
+ function insertDocumentoSQLite(descrizione, tipo, anno, data_emissione, riferimento, file_name) {
8677
+ var query = "insert into documenti (descrizione, tipo, anno, data_emissione, riferimento, nome_originale) values ";
8678
+ query += "('" + descrizione + "', '" + tipo + "', " + anno + ", '" + data_emissione + "', '" + riferimento + "', '" + file_name + "')";
8570
8679
  return query;
8571
8680
  }
8572
- function insertDocumentoMySQL(descrizione, tipo, data_emissione, riferimento, file_name) {
8573
- var query = "insert into documenti (descrizione, tipo, data_emissione, riferimento, file_name) values ";
8574
- query += "(:descrizione, :tipo, :data_emissione, :riferimento, :file_name)";
8681
+ function insertDocumentoMySQL(descrizione, tipo, anno, data_emissione, riferimento, file_name) {
8682
+ var query = "insert into documenti (descrizione, tipo, anno, data_emissione, riferimento, nome_originale) values ";
8683
+ query += "(:descrizione, :tipo, :anno, :data_emissione, :riferimento, :file_name)";
8575
8684
  return query;
8576
8685
  }
8577
- function insertDocumento(db_used, descrizione, tipo, data_emissione, riferimento, file_name) {
8686
+ function insertDocumento(db_used, descrizione, tipo, anno, data_emissione, riferimento, file_name) {
8578
8687
  var query = "";
8579
8688
  if (db_used) {
8580
8689
  switch (db_used) {
8581
8690
  case 'SQLITE':
8582
- query = insertDocumentoSQLite(descrizione, tipo, data_emissione, riferimento, file_name);
8691
+ query = insertDocumentoSQLite(descrizione, tipo, anno, data_emissione, riferimento, file_name);
8583
8692
  break;
8584
8693
  case 'MYSQL':
8585
- query = insertDocumentoMySQL(descrizione, tipo, data_emissione, riferimento, file_name);
8694
+ query = insertDocumentoMySQL(descrizione, tipo, anno, data_emissione, riferimento, file_name);
8586
8695
  break;
8587
8696
  case 'MYSQL2':
8588
- query = insertDocumentoSQLite(descrizione, tipo, data_emissione, riferimento, file_name);
8697
+ query = insertDocumentoSQLite(descrizione, tipo, anno, data_emissione, riferimento, file_name);
8589
8698
  break;
8590
8699
  }
8591
8700
  }
8592
8701
  return query;
8593
8702
  }
8594
8703
 
8595
- function updateDocumentoSQLite(id_doc, descrizione, tipo, data_emissione, riferimento, file_name) {
8704
+ function updateDocumentoSQLite(id_doc, descrizione, tipo, anno, data_emissione, riferimento, file_name) {
8596
8705
  var query = "update documenti set ";
8597
8706
  query += "descrizione = '" + descrizione + "', ";
8598
8707
  query += "tipo = " + tipo + "', ";
8708
+ query += "anno = " + anno + "', ";
8599
8709
  query += "data_emissione = '" + data_emissione + "',";
8600
8710
  query += "riferimento = '" + riferimento + "', ";
8601
- query += "file_name = '" + file_name + "' ";
8711
+ query += "nome_originale = '" + file_name + "' ";
8602
8712
  query += "where id = " + id_doc;
8603
8713
  return query;
8604
8714
  }
8605
8715
 
8606
- function updateDocumentoMySQL(id_doc, descrizione, tipo, data_emissione, riferimento, file_name) {
8716
+ function updateDocumentoMySQL(id_doc, descrizione, tipo, anno, data_emissione, riferimento, file_name) {
8607
8717
  var query = "update documenti set ";
8608
- query += "descrizione = '" + descrizione + "', ";
8609
- query += "tipo = " + tipo + "', ";
8610
- query += "data_emissione = '" + data_emissione + "',";
8611
- query += "riferimento = '" + riferimento + "', ";
8612
- query += "file_name = '" + file_name + "' ";
8613
- query += "where id = " + id_doc;
8718
+ query += "descrizione = :descrizione, ";
8719
+ query += "tipo = :tipo, ";
8720
+ query += "anno = :anno, ";
8721
+ query += "data_emissione = :data_emissione,";
8722
+ query += "riferimento = :riferimento, ";
8723
+ query += "nome_originale = :file_name ";
8724
+ query += "where id = :id_doc";
8614
8725
  return query;
8615
8726
  }
8616
8727
 
8617
- function updateDocumento(db_used, id_doc, descrizione, tipo, data_emissione, riferimento, file_name) {
8728
+ function updateDocumento(db_used, id_doc, descrizione, tipo, anno, data_emissione, riferimento, file_name) {
8618
8729
  var query = "";
8619
8730
  if (db_used) {
8620
8731
  switch (db_used) {
8621
8732
  case 'SQLITE':
8622
- query = updateDocumentoSQLite(id_doc, descrizione, tipo, data_emissione, riferimento, file_name);
8733
+ query = updateDocumentoSQLite(id_doc, descrizione, tipo, anno, data_emissione, riferimento, file_name);
8623
8734
  break;
8624
8735
  case 'MYSQL':
8625
- query = updateDocumentoMySQL(id_doc, descrizione, tipo, data_emissione, riferimento, file_name);
8736
+ query = updateDocumentoMySQL(id_doc, descrizione, tipo, anno, data_emissione, riferimento, file_name);
8626
8737
  break;
8627
8738
  case 'MYSQL2':
8628
- query = updateDocumentoSQLite(id_doc, descrizione, tipo, data_emissione, riferimento, file_name);
8739
+ query = updateDocumentoSQLite(id_doc, descrizione, tipo, anno, data_emissione, riferimento, file_name);
8629
8740
  break;
8630
8741
  }
8631
8742
  }
@@ -11900,6 +12011,7 @@ module.exports = {
11900
12011
  queryDeviceModelsByFilter,
11901
12012
  getDevicesSelectByRelated,
11902
12013
  getDevicesSelect,
12014
+ getDevicesByIdDoc,
11903
12015
  getDevicesSelectBySite,
11904
12016
  queryDeviceById,
11905
12017
  queryDeviceByIdentificativo,
@@ -12043,6 +12155,7 @@ module.exports = {
12043
12155
  insertDocumentoDevice,
12044
12156
  removeDocumentoDevice,
12045
12157
  selectDocumentoById,
12158
+ selectDocuments,
12046
12159
  selectDocumentiCombo,
12047
12160
  insertDocumento,
12048
12161
  updateDocumento,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  ".": "./lib/modules.js",
5
5
  "./dbconn": "./lib/dbconn.js"
6
6
  },
7
- "version": "2.0.96",
7
+ "version": "2.0.98",
8
8
  "description": "Funzioni per ALSManager",
9
9
  "license": "ISC",
10
10
  "author": "Luca Cattani",
@@ -0,0 +1,59 @@
1
+ import platform
2
+ import psutil
3
+ import socket
4
+ import re
5
+ import uuid
6
+ import cpuinfo
7
+
8
+ #Computer network name
9
+ print(f"Computer network name: {platform.node()}")
10
+
11
+ #Machine type
12
+ print(f"Machine type: {platform.machine()}")
13
+
14
+ #Processor type
15
+ print(f"Processor type: {platform.processor()}")
16
+
17
+ #Platfrom type
18
+ print(f"Platform type: {platform.platform()}")
19
+
20
+ #Operating system
21
+ print(f"OS: {platform.system()}")
22
+
23
+ #Operating Release
24
+ print(f"OS Release: {platform.release()}")
25
+
26
+ #Operating Release
27
+ print(f"OS Version: {platform.version()}")
28
+
29
+ # Physical cores
30
+ print(f"Number of physical cores: {psutil.cpu_count(logical=False)}")
31
+
32
+ # CPU Freq
33
+ print(f"Current freq.: {psutil.cpu_freq().current}")
34
+ print(f"Min freq.: {psutil.cpu_freq().min}")
35
+ print(f"Current freq.: {psutil.cpu_freq().max}")
36
+ print(f"Current CPU util.: {psutil.cpu_percent(interval=1)}")
37
+ print(f"Current freq.: {psutil.cpu_percent(interval=1, percpu=True)}")
38
+
39
+ #RAM Usage
40
+ print(f"Total RAM Installed: {psutil.virtual_memory().total}")
41
+ print(f"Available RAM: {psutil.virtual_memory().available}")
42
+ print(f"Used RAM: {psutil.virtual_memory().used}")
43
+ print(f"RAM usage: {psutil.virtual_memory().percent}%")
44
+
45
+ #IP Address
46
+ print(f"Hosname: {socket.gethostname()}")
47
+ print(f"IP Address: {socket.gethostbyname(socket.gethostname())}")
48
+ print("MAC Address:", ":".join(re.findall('..', "%012x" % uuid.getnode())).upper())
49
+ print(f"Processor : {platform.processor()}")
50
+
51
+ #Discover Win32
52
+ print(f"Win32 Edition: {platform.win32_edition()}")
53
+ print(f"Win32 Arch: {platform.architecture()}")
54
+ #cpuinfo
55
+ #print(f"CpuInfo: {cpuinfo.get_cpu_info()}")
56
+ print(f"CpuInfo: {cpuinfo.get_cpu_info()['brand_raw']}")
57
+
58
+
59
+