--- trunk/tntnet/dynamic/critical.ecpp 2007/11/27 17:08:11 71 +++ trunk/tntnet/dynamic/critical.ecpp 2007/12/05 14:39:35 159 @@ -3,6 +3,7 @@ #include #include #include + <%config> @@ -11,10 +12,90 @@ <&header title="Critical systems"> +

Critical systems

+ <{ -tntdb::Connection conn; -conn = tntdb::connect(dburl); //letting exceptions flow up and to tntnet and let it display an error message +reply.setHeader("Refresh", "120"); + +tntdb::Connection conn = tntdb::connect(dburl); + + +std::string query1; +query1 += "SELECT c.name, i.description, i.id, i.commerror "; +query1 += "FROM installation i INNER JOIN customer c "; +query1 += "ON i.customerid = c.id"; + + +tntdb::Result inst_res = conn.select(query1); + + +std::string query2; +query2 += "SELECT temperature,flamedetector,conveyorerror,powerfailure "; +query2 += "FROM logtable "; +query2 += "WHERE installationnr = :v1 "; +query2 += "ORDER BY messagenr DESC,logtime DESC "; +query2 += "LIMIT 1"; + + +tntdb::Statement st = conn.prepare(query2); + +std::ostream& out = reply.out(); + +bool hasCritical = false; + +for (unsigned i=0; i 0) + { + temperature = res[0].getInt(0); + flameDetector = res[0].getBool(1); + conveyorError = res[0].getBool(2); + powerFailure = res[0].getBool(3); + } + + if (commerror || temperature > 90 || flameDetector == false || conveyorError || powerFailure) + { + out << "" << inst_res[i].getString(0) << " : " << inst_res[i].getString(1) << "
\n"; + out << "
    "; + + if (temperature > 90) + out << "
  • High temperature
  • \n"; + + if (commerror) + out << "
  • Communication error
  • \n"; + + if (flameDetector == false) + out << "
  • No flames
  • \n"; + + if (conveyorError) + out << "
  • Conveyor error
  • \n"; + + if (powerFailure) + out << "
  • Power failure
  • \n"; + + out << "
\n"; + + hasCritical = true; + } +} + +if (hasCritical == false) +{ + out << "No critical installations found\n"; +} }>