--- trunk/tntnet/dynamic/adm_send_config.ecpp 2007/12/02 17:12:00 123 +++ trunk/tntnet/dynamic/adm_send_config.ecpp 2007/12/02 19:32:52 124 @@ -3,6 +3,26 @@ #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> @@ -30,7 +50,97 @@ 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>