4 |
#include <tntdb/result.h> |
#include <tntdb/result.h> |
5 |
#include <tntdb/row.h> |
#include <tntdb/row.h> |
6 |
|
|
|
//#include <vector> |
|
|
#include <sstream> |
|
|
|
|
|
/* |
|
|
class CriticalInstallation |
|
|
{ |
|
|
public: |
|
|
CriticalInstallation() {} |
|
|
CriticalInstallation(int i, std::string m) : id(i), message(m) {} |
|
|
int id; |
|
|
std::string message; |
|
|
};*/ |
|
|
|
|
7 |
</%pre> |
</%pre> |
8 |
|
|
9 |
<%config> |
<%config> |
16 |
|
|
17 |
<{ |
<{ |
18 |
|
|
|
|
|
|
//std::vector<CriticalInstallation> criticals; |
|
|
|
|
19 |
tntdb::Connection conn = tntdb::connect(dburl); |
tntdb::Connection conn = tntdb::connect(dburl); |
20 |
|
|
|
/* |
|
|
tntdb::Result res = conn.select("SELECT id FROM installation WHERE commerror = true"); |
|
|
for (int i=0; i<res.size(); ++i) |
|
|
{ |
|
|
criticals.push_back(CriticalInstallation(res[i].getInt(0), std::string("Communication Error"))); |
|
|
}*/ |
|
|
|
|
21 |
|
|
22 |
std::string query1; |
std::string query1; |
23 |
query1 += "SELECT c.name, i.description, i.id "; |
query1 += "SELECT c.name, i.description, i.id "; |
28 |
tntdb::Result inst_res = conn.select(query1); |
tntdb::Result inst_res = conn.select(query1); |
29 |
|
|
30 |
|
|
|
|
|
31 |
std::string query2; |
std::string query2; |
32 |
query2 += "SELECT commerror,temperature,flamedetector,conveyorerror,powerfailure "; |
query2 += "SELECT commerror,temperature,flamedetector,conveyorerror,powerfailure "; |
33 |
query2 += "FROM logtable "; |
query2 += "FROM logtable "; |
41 |
|
|
42 |
std::ostream& out = reply.out(); |
std::ostream& out = reply.out(); |
43 |
|
|
44 |
for (int i=0; i<inst_res.size(); i++) |
bool hasCritical = false; |
45 |
|
|
46 |
|
for (unsigned i=0; i<inst_res.size(); i++) |
47 |
{ |
{ |
48 |
int id = inst_res[i].getInt(2); |
int id = inst_res[i].getInt(2); |
49 |
st.clear(); |
st.clear(); |
81 |
|
|
82 |
out << "</ul>\n"; |
out << "</ul>\n"; |
83 |
|
|
84 |
|
hasCritical = true; |
85 |
} |
} |
86 |
} |
} |
87 |
} |
} |
88 |
|
|
89 |
|
if (hasCritical == false) |
90 |
|
{ |
91 |
|
out << "<i>No critical installations found</i>\n"; |
92 |
|
} |
93 |
|
|
94 |
}> |
}> |
95 |
|
|
96 |
<&footer> |
<&footer> |