update Mi 17. Jun 21:01:01 CEST 2020

This commit is contained in:
Robert Richter 2020-06-17 21:01:01 +02:00
parent 45a95cee38
commit 8008e86320
4 changed files with 13 additions and 13 deletions

View File

@ -31,7 +31,7 @@ module.exports = function (io, sql, app_cfg, remote_api, saver) {
// nur speichern wenn app_id nicht eigenen globalen app_id entspricht // nur speichern wenn app_id nicht eigenen globalen app_id entspricht
if (app_id != app_cfg.global.app_id) { if (app_id != app_cfg.global.app_id) {
saver.save_new_waip(data, remote_ip, app_id); saver.save_new_waip(data, remote_ip, app_id);
sql.db_log('API', 'Neuer Wachalarm von ' + remote_ip + ': ' + data); sql.db_log('API', 'Neuer Wachalarm von ' + remote_ip + ': ' + JSON.stringify(data));
}; };
}); });
@ -43,7 +43,7 @@ module.exports = function (io, sql, app_cfg, remote_api, saver) {
if (app_id != app_cfg.global.app_id) { if (app_id != app_cfg.global.app_id) {
saver.save_new_rmld(data, remote_ip, app_id, function (result) { saver.save_new_rmld(data, remote_ip, app_id, function (result) {
if (!result) { if (!result) {
sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + remote_ip + ': ' + data); sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + remote_ip + ': ' + JSON.stringify(data));
}; };
}); });
}; };
@ -88,7 +88,7 @@ module.exports = function (io, sql, app_cfg, remote_api, saver) {
if (app_id != app_cfg.global.app_id) { if (app_id != app_cfg.global.app_id) {
// nicht erwuenschte Daten ggf. enfernen (Datenschutzoption) // nicht erwuenschte Daten ggf. enfernen (Datenschutzoption)
saver.save_new_waip(data, app_cfg.endpoint.host, app_id); saver.save_new_waip(data, app_cfg.endpoint.host, app_id);
sql.db_log('API', 'Neuer Wachalarm von ' + app_cfg.endpoint.host + ': ' + data); sql.db_log('API', 'Neuer Wachalarm von ' + app_cfg.endpoint.host + ': ' + JSON.stringify(data));
}; };
}); });

View File

@ -32,7 +32,7 @@ module.exports = function (app_cfg, sql, waip, uuidv4, io, remote_api) {
steps: app_cfg.global.circumcircle, steps: app_cfg.global.circumcircle,
units: 'kilometers' units: 'kilometers'
}) })
waip_data.ortsdaten.wgs84_area = JSON.stringify(new_buffer); waip_data.ortsdaten.wgs84_area = new_buffer;
}; };
// pruefen, ob vielleicht schon ein Einsatz mit einer UUID gespeichert ist // pruefen, ob vielleicht schon ein Einsatz mit einer UUID gespeichert ist
sql.db_einsatz_get_uuid_by_enr(waip_data.einsatzdaten.nummer, function (waip_uuid) { sql.db_einsatz_get_uuid_by_enr(waip_data.einsatzdaten.nummer, function (waip_uuid) {
@ -92,12 +92,13 @@ module.exports = function (app_cfg, sql, waip, uuidv4, io, remote_api) {
// Funktion um zu pruefen, ob Nachricht im JSON-Format ist // Funktion um zu pruefen, ob Nachricht im JSON-Format ist
function isValidJSON(text) { function isValidJSON(text) {
try { if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
JSON.parse(text); //the json is ok
return true; return true;
} catch (error) { } else {
//the json is not ok
return false; return false;
} };
}; };
function validate_waip(data, callback) { function validate_waip(data, callback) {

View File

@ -10,7 +10,6 @@ module.exports = function (db, app_cfg) {
function db_einsatz_speichern(content, callback) { function db_einsatz_speichern(content, callback) {
// Einsatzdaten verarbeiten // Einsatzdaten verarbeiten
console.log(content.ortsdaten.wgs84_area);
db.run(`INSERT OR REPLACE INTO waip_einsaetze ( db.run(`INSERT OR REPLACE INTO waip_einsaetze (
id, uuid, einsatznummer, alarmzeit, einsatzart, stichwort, sondersignal, besonderheiten, ort, ortsteil, strasse, objekt, objektnr, objektart, wachenfolge, wgs84_x, wgs84_y, wgs84_area) id, uuid, einsatznummer, alarmzeit, einsatzart, stichwort, sondersignal, besonderheiten, ort, ortsteil, strasse, objekt, objektnr, objektart, wachenfolge, wgs84_x, wgs84_y, wgs84_area)
VALUES ( VALUES (
@ -31,7 +30,7 @@ module.exports = function (db, app_cfg) {
\'` + content.ortsdaten.wachfolge + `\', \'` + content.ortsdaten.wachfolge + `\',
\'` + content.ortsdaten.wgs84_x + `\', \'` + content.ortsdaten.wgs84_x + `\',
\'` + content.ortsdaten.wgs84_y + `\', \'` + content.ortsdaten.wgs84_y + `\',
\'` + content.ortsdaten.wgs84_area + `\')`, \'` + JSON.stringify(content.ortsdaten.wgs84_area) + `\')`,
function (err) { function (err) {
if (err == null) { if (err == null) {
// letzte Einsatz-ID ermitteln // letzte Einsatz-ID ermitteln

View File

@ -20,7 +20,7 @@ module.exports = function (app_cfg, sql, saver) {
function send_message(message) { function send_message(message) {
udp_server.send(message, 0, message.length, app_cfg.global.udpport, 'localhost', function (err, bytes) { udp_server.send(message, 0, message.length, app_cfg.global.udpport, 'localhost', function (err, bytes) {
if (err) throw err; if (err) throw err;
sql.db_log('UDP-Testalarm an Localhost (Port ' + app_cfg.global.udpport + ') gesendet.'); sql.db_log('WAIP', 'UDP-Testalarm an localhost:' + app_cfg.global.udpport + ') gesendet.');
}); });
}; };