-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan.cpp
More file actions
64 lines (53 loc) · 2.24 KB
/
Copy pathscan.cpp
File metadata and controls
64 lines (53 loc) · 2.24 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "scan.h"
void scan::find()
{
QDir dir(w->path);
QStringList dirictory = dir.entryList(QStringList());
QString lastDir = dirictory[dirictory.count()-1];
qDebug() << "Сканирование директории: "+lastDir;
qDebug()<< "\n\n\n\nЗапуск сканирования\n################# ";
line =0;
for (int i=0;i<w->count; i++) {
QDir dir(w->path+"/"+lastDir+"/_protocol/_terminals/");
QStringList dirictoryTerminal = dir.entryList(QStringList());
foreach(QString terminalFolder, dirictoryTerminal){
if (terminalFolder.contains(w->terminals[i].ID)){
QFile file(w->path+"/"+lastDir+"/_protocol/_terminals/"+terminalFolder+"/"+"Trace.txt");
if (file.exists()){
emit send(pars(&file, w->terminals[i].LINE),i);
file.close();
w->terminals[i].LINE=line;
}
}
}
}
}
QString scan::pars(QFile *file, int line){
QString logDate="";
QString logTime="";
QByteArray str = QByteArray::fromHex("cde5eff0e0e2e8ebfcedeee520f1eeeee1f9e5ede8e5204b4f4e5f544d5f484f53544b4e4620eef220d3cad2d121");
int line_i = 0;
qDebug()<<line;
if (file->open(QIODevice::ReadOnly)){
while(!file->atEnd()){
if(line_i<line){
str=file->readLine();
line_i++;
continue;
}
// Перекодировка из UTF8 в win125
str=file->readLine();
QTextCodec *codec = QTextCodec::codecForName("Windows-1251");
QString strf = codec->toUnicode(str);
// обрезаем лишнее из строки
QString newStr = strf.left(str.indexOf(';'));
// Ищем строку с датой и временим
if (newStr.contains("Время сообщения (UTC): ")){
logTime = newStr.remove("Время сообщения (UTC): ");
}
line_i++;
}
this->line=line_i;
}
return logTime;
}