aboutsummaryrefslogtreecommitdiff
path: root/client/HandleMessage.cpp
blob: aa73828a87541e8e75a3be2bf08fb69bcf25d985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 ";
    QStringList data;
    QStringList 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);
}