summaryrefslogtreecommitdiff
path: root/server/src/pracrodaopgsql.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/pracrodaopgsql.cc')
-rw-r--r--server/src/pracrodaopgsql.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc
index 14cb9c1..5a08e3a 100644
--- a/server/src/pracrodaopgsql.cc
+++ b/server/src/pracrodaopgsql.cc
@@ -97,6 +97,21 @@ std::string PracroDAOPgsql::newSessionId()
pqxx::result::const_iterator ri = R.begin();
if(ri != R.end()) {
DEBUG(db, "New session id: %s\n", (*ri)[0].c_str());
+ /*
+ std::string ts;
+ ts = "INSERT INTO commits (patientid, template, version,"
+ " \"timestamp\", uid, status) VALUES ("
+ " '" + W.esc(transaction.cpr) + "', "
+ " '" + W.esc(commit.templ) + "', "
+ " '" + "1.0" + "', "
+ " '" + W.esc(timestamp.str()) + "', "
+ " '" + W.esc(sessionid) + "', "
+ " 'active' "
+ ");"
+ ;
+ DEBUG(sql, "Query: %s\n", ts.c_str());
+ pqxx::result R = W.exec(ts);
+ */
return (*ri)[0].c_str();
}
ERR(db, "No pgsql connection\n");
@@ -477,6 +492,24 @@ void PracroDAOPgsql::discard(std::string sessionid)
}
}
+bool PracroDAOPgsql::active(std::string sessionid)
+{
+ std::string ts = "SELECT status FROM commits WHERE uid='"+sessionid+"';";
+ pqxx::work W(*conn);
+ pqxx::result R = W.exec(ts);
+ pqxx::result::const_iterator ri = R.begin();
+ if(ri != R.end()) {
+ std::string status = (*ri)[0].c_str();
+ if(status == "idle") {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ return false;
+}
+
#endif/*WITHOUT_DB*/
#ifdef TEST_PRACRODAOPGSQL