<%pre> #include #include #include #include std::string createInstallationSelector(tntdb::Connection& conn) { std::stringstream out; tntdb::Result res = conn.select("SELECT c.name, i.id, i.description FROM customer c INNER JOIN installation i ON c.id = i.customerid"); out << "\n"; return out.str(); } <%config> dburl; <%session scope="global"> std::string userName; bool isAdmin; <{ if (userName.size() == 0) { reply.setHeader("Location", "index"); return HTTP_MOVED_TEMPORARILY; } }> <&header title="Send configuration"> <{ tntdb::Connection conn = tntdb::connect(dburl); std::ostream& out = reply.out(); if (qparam.param("command").size() > 0) { std::string command = qparam.param("command"); std::string installation = (command == "2" ? qparam.param("installation") : "null"); std::stringstream sql; sql << "INSERT INTO command (created,commandid, installationid) "; sql << "VALUES (now(), " << command << ", " << installation << ")"; conn.execute( sql.str() ); } }>

Send configuration

Send Commands
<$$ createInstallationSelector( conn ) $>
<{ ////////////////////////////////////////////////////////////////////////////////////// // Command Log /* commandid 1 -> Send to all * commandid 2 -> Send to one */ std::string query; query += "SELECT name,description,date_trunc('second',created) AS created, date_trunc('second', executed) AS executed,commandid,installationid "; query += "FROM command "; query += "LEFT JOIN installation ON command.installationid = installation.id "; query += "LEFT JOIN customer ON installation.customerid = customer.id "; query += "ORDER BY created DESC "; tntdb::Result res = conn.select(query); out << "

Command history

\n"; out << ""; out << "\n"; for (int i=0; i"; out << ""; out << "\n"; out << "\n"; } }>
 Created  Executed Command
" << res[i].getString(2) << "" << res[i].getString(3) << ""; switch ( res[i].getInt(4) ) { case 1: out << "Send configuration to All"; break; case 2: out << "Send configuration to " << res[i].getString(0) << " :: " << res[i].getString(1) << ""; break; default: out << "Unknown command"; break; } out << "
<&footer>