-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbProcess.h
112 lines (97 loc) · 2.45 KB
/
dbProcess.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include <iostream>
#include <string>
#include <queue>
#include <QVariant>
#include <tableManager.h>
#include "js.h"
#include "aggHelper.h"
using namespace std;
class processObject
{
string user;
string passWord;
string JS;
string result;
public:
processObject(string user,string passWord,string JS){
this->user=user;
this->passWord=passWord;
this->JS=JS;
}
processObject(){}
void setUser(const string& username){
this->user=username;
}
string getUser()const{
return user;
}
void setPassword(const string& password){
this->passWord=passWord;
}
string getPassWord()const{
return passWord;
}
void setJS(const string& JS){
this->JS=JS;
}
string getJS()const{
return JS;
}
void setResult(const string& result){
this->result=result;
}
string getResult()const{
return result;
}
};
class dbProcess
{
static table* countTable;
public:
static queue<processObject> processQueue;
static queue<processObject> correspondQueue;
static void setCount(table* table)
{
table->setSystemManage();
countTable=table;
}
static bool checkCount(const processObject& obj){
string userName=obj.getUser();
string passWord=obj.getPassWord();
vector<int> countVec=countTable->find({"(x=='"+userName+"')","(x=='"+passWord+"')"});
if(countVec.empty()){
return false;
}
return true;
}
static void processRequst(){
if(processQueue.empty()){
return;
}
processObject tmpProcess=processQueue.front();
processQueue.pop();
tableManager::setcurOperatUser(tmpProcess.getUser());
if(checkCount(tmpProcess)==false){
tmpProcess.setResult("Account password error");
}
else
{
QString mistake;
QVariant varResult=JSEval(QString::fromStdString(tmpProcess.getJS()),"eval",&mistake,AddJSVM());
if(varResult==NULL)
{
tmpProcess.setResult(mistake.toStdString());
}
else
{
tmpProcess.setResult(varResult.toString().toStdString());
}
}
correspondQueue.push(tmpProcess);
tableManager::tablemanager->doManage();
#ifdef autoRecovery
manageContain::reset();
#endif
}
};