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 |
|
|
19 |
|
reply.setHeader("Refresh", "120"); |
|
//std::vector<CriticalInstallation> criticals; |
|
20 |
|
|
21 |
tntdb::Connection conn = tntdb::connect(dburl); |
tntdb::Connection conn = tntdb::connect(dburl); |
22 |
|
|
|
/* |
|
|
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"))); |
|
|
}*/ |
|
|
|
|
23 |
|
|
24 |
std::string query1; |
std::string query1; |
25 |
query1 += "SELECT c.name, i.description, i.id "; |
query1 += "SELECT c.name, i.description, i.id "; |
30 |
tntdb::Result inst_res = conn.select(query1); |
tntdb::Result inst_res = conn.select(query1); |
31 |
|
|
32 |
|
|
|
|
|
33 |
std::string query2; |
std::string query2; |
34 |
query2 += "SELECT commerror,temperature,flamedetector,conveyorerror,powerfailure "; |
query2 += "SELECT commerror,temperature,flamedetector,conveyorerror,powerfailure "; |
35 |
query2 += "FROM logtable "; |
query2 += "FROM logtable "; |
43 |
|
|
44 |
std::ostream& out = reply.out(); |
std::ostream& out = reply.out(); |
45 |
|
|
46 |
for (int i=0; i<inst_res.size(); i++) |
bool hasCritical = false; |
47 |
|
|
48 |
|
for (unsigned i=0; i<inst_res.size(); i++) |
49 |
{ |
{ |
50 |
int id = inst_res[i].getInt(2); |
int id = inst_res[i].getInt(2); |
51 |
st.clear(); |
st.clear(); |
83 |
|
|
84 |
out << "</ul>\n"; |
out << "</ul>\n"; |
85 |
|
|
86 |
|
hasCritical = true; |
87 |
} |
} |
88 |
} |
} |
89 |
} |
} |
90 |
|
|
91 |
|
if (hasCritical == false) |
92 |
|
{ |
93 |
|
out << "<i>No critical installations found</i>\n"; |
94 |
|
} |
95 |
|
|
96 |
}> |
}> |
97 |
|
|
98 |
<&footer> |
<&footer> |