changes in logging with sqlite-db
This commit is contained in:
@@ -30,6 +30,7 @@ using namespace std;
|
|||||||
|
|
||||||
Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0), mySqliteLogDb(0)
|
Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0), mySqliteLogDb(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
myW->setLog(this);
|
myW->setLog(this);
|
||||||
myStyle = myW->getMyGameTableStyle();
|
myStyle = myW->getMyGameTableStyle();
|
||||||
|
|
||||||
@@ -54,7 +55,9 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
|
|||||||
|
|
||||||
if(myConfig->readConfigInt("LogOnOff")) {
|
if(myConfig->readConfigInt("LogOnOff")) {
|
||||||
//if write logfiles is enabled
|
//if write logfiles is enabled
|
||||||
|
|
||||||
QDir logDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
|
QDir logDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
|
||||||
|
|
||||||
if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) {
|
if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) {
|
||||||
|
|
||||||
myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
|
myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
|
||||||
@@ -115,7 +118,7 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
|
|||||||
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
sql += ",Seat_" + QString("%1").arg(i);
|
sql += ",Seat_" + QString("%1").arg(i);
|
||||||
}
|
}
|
||||||
sql += ")";
|
sql += ",Winner_Seat INTEGER)";
|
||||||
if(!query.exec(sql)) {
|
if(!query.exec(sql)) {
|
||||||
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
||||||
}
|
}
|
||||||
@@ -157,9 +160,7 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zu alte Dateien löschen!!!
|
//Zu alte Dateien löschen!!!
|
||||||
@@ -190,8 +191,9 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cout << "Log directory doesn't exist. Cannot create log files";
|
||||||
}
|
}
|
||||||
else { cout << "Log directory doesn't exist. Cannot create log files"; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +278,7 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
|
|||||||
if(myConfig->readConfigInt("LogOnOff")) {
|
if(myConfig->readConfigInt("LogOnOff")) {
|
||||||
//if write logfiles is enabled
|
//if write logfiles is enabled
|
||||||
|
|
||||||
int i;
|
// int i;
|
||||||
|
|
||||||
logFileStreamString += "<table><tr><td width=\"600\" align=\"center\"><hr noshade size=\"3\"><b>Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"</b></td><td></td></tr></table>";
|
logFileStreamString += "<table><tr><td width=\"600\" align=\"center\"><hr noshade size=\"3\"><b>Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"</b></td><td></td></tr></table>";
|
||||||
logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"</br>";
|
logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"</br>";
|
||||||
@@ -294,41 +296,55 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
|
|||||||
// bei Beginn eines Games
|
// bei Beginn eines Games
|
||||||
if(handID == 1) {
|
if(handID == 1) {
|
||||||
sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
|
sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
|
||||||
for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
|
||||||
sql += ",Seat_" + QString::number(i,10);
|
sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10);
|
||||||
}
|
}
|
||||||
|
// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
// sql += ",Seat_" + QString::number(i,10);
|
||||||
|
// }
|
||||||
sql += ") VALUES (";
|
sql += ") VALUES (";
|
||||||
sql += QString::number(gameID,10) + ",";
|
sql += QString::number(gameID,10) + ",";
|
||||||
sql += QString::number(myW->getSession()->getCurrentGame()->getStartCash(),10) + ",";
|
sql += QString::number(myW->getSession()->getCurrentGame()->getStartCash(),10) + ",";
|
||||||
sql += QString::number(myW->getSession()->getCurrentGame()->getStartSmallBlind(),10) + ",";
|
sql += QString::number(myW->getSession()->getCurrentGame()->getStartSmallBlind(),10) + ",";
|
||||||
sql += QString::number(myW->getSession()->getCurrentGame()->getDealerPosition(),10);
|
sql += QString::number(myW->getSession()->getCurrentGame()->getDealerPosition(),10);
|
||||||
for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) {
|
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
|
||||||
if((*it_c)->getMyActiveStatus()) {
|
|
||||||
sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
|
sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
|
||||||
} else {
|
|
||||||
sql += ",NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) {
|
||||||
|
// if((*it_c)->getMyActiveStatus()) {
|
||||||
|
// sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
|
||||||
|
// } else {
|
||||||
|
// sql += ",NULL";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
sql += ")";
|
sql += ")";
|
||||||
if(!query.exec(sql)) {
|
if(!query.exec(sql)) {
|
||||||
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "INSERT INTO Hand (HandID,GameID";
|
sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount";
|
||||||
for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
|
||||||
sql += ",Seat_" + QString("%1").arg(i) + "_Cash";
|
sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10) + "_Cash";
|
||||||
}
|
}
|
||||||
|
// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
|
||||||
|
// sql += ",Seat_" + QString("%1").arg(i) + "_Cash";
|
||||||
|
// }
|
||||||
sql += ") VALUES (";
|
sql += ") VALUES (";
|
||||||
sql += QString::number(handID,10);
|
sql += QString::number(handID,10);
|
||||||
sql += "," + QString::number(gameID,10);
|
sql += "," + QString::number(gameID,10);
|
||||||
for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) {
|
sql += "," + QString::number(currentHand->getSmallBlind(),10);
|
||||||
if((*it_c)->getMyActiveStatus()) {
|
sql += "," + QString::number(currentHand->getSmallBlind()*2,10);
|
||||||
|
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
|
||||||
sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
|
sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
|
||||||
} else {
|
|
||||||
sql += ",NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) {
|
||||||
|
// if((*it_c)->getMyActiveStatus()) {
|
||||||
|
// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
|
||||||
|
// } else {
|
||||||
|
// sql += ",NULL";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
sql += ")";
|
sql += ")";
|
||||||
|
|
||||||
if(!query.exec(sql)) {
|
if(!query.exec(sql)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user