From b5322d74d1839c4af490f5c7297e439a8433ba9b Mon Sep 17 00:00:00 2001 From: NielsCoding Date: Sat, 29 Oct 2022 21:38:47 +0200 Subject: merging TCPcode with main QT code --- client/HandleMessage.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 client/HandleMessage.cpp (limited to 'client/HandleMessage.cpp') diff --git a/client/HandleMessage.cpp b/client/HandleMessage.cpp new file mode 100644 index 0000000..f7f14f4 --- /dev/null +++ b/client/HandleMessage.cpp @@ -0,0 +1,47 @@ +#include "HandleMessage.h" + + +HandleMessage::HandleMessage(QObject *parent) : QObject(parent) +{ + +} + +QString HandleMessage::ParseMessage(const QString Msg , int totalRecords ) +{ + QString message= Msg.section('\n',2,(3+totalRecords)); + + return message; + +} + +void HandleMessage::ParseToSQL(QString input) +{ + QSqlQuery queryInsertData; + QString output = "INSERT INTO `WSdb`.`tblMain` () VALUES "; + QVector data; + QVector list = input.split("\n"); + for (int i = 0; i < list.size(); ++i) { + + output += "("; + + data=list[i].split(","); + + for (int j = 1; j < data.size(); ++j) { + bool valid; + output.append(QString::number(data[j].toInt(&valid, 16))); + if (j <= data[j].size()) { + output.append(","); + } + + } + output.append(")"); + + if (i+1 < list.size()){ + output.append(","); + } + } + queryInsertData.exec(output); +} + + + -- cgit v1.2.3 From c821f53c45b6705e9e5362d331936c1d4280a163 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 30 Oct 2022 09:21:32 +0100 Subject: finish merge --- client/HandleMessage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client/HandleMessage.cpp') diff --git a/client/HandleMessage.cpp b/client/HandleMessage.cpp index f7f14f4..aa73828 100644 --- a/client/HandleMessage.cpp +++ b/client/HandleMessage.cpp @@ -18,8 +18,8 @@ void HandleMessage::ParseToSQL(QString input) { QSqlQuery queryInsertData; QString output = "INSERT INTO `WSdb`.`tblMain` () VALUES "; - QVector data; - QVector list = input.split("\n"); + QStringList data; + QStringList list = input.split("\n"); for (int i = 0; i < list.size(); ++i) { output += "("; -- cgit v1.2.3