28 #ifndef __CAACCOUNTINGDBINTERFACE__
29 #define __CAACCOUNTINGDBINTERFACE__
36 #define MAX_DB_CONNECTIONS 3
37 #define PG_PROTOCOL_VERSION_3 3
39 #define RESULT_FORMAT_TEXT 0
41 #define PREPARED_STMT_NAME_STORE_CC "storeCCStatement"
42 #define PREPARED_STMT_QUERY_STORE_CC \
43 "UPDATE COSTCONFIRMATIONS SET BYTES = $1::bigint, XMLCC = $2::varchar(2000), SETTLED = $3::integer WHERE ACCOUNTNUMBER = $4::bigint AND CASCADE = $5::varchar(200)"
44 #define PREPARED_STMT_PARAMS_STORE_CC 5
46 #define STMT_CLEAR_ACCOUNT_STATUS "DELETE FROM ACCOUNTSTATUS WHERE ACCOUNTNUMBER = '%llu'"
197 #ifdef PG_PROTO_VERSION_3
198 char *m_pStoreCCStmt;
unsigned long long thread_id_t
Type of an ID for a thread which can be used to identify the current and other threads.
SINT32 storePrepaidAmount(UINT64 accountNumber, SINT32 prepaidBytes, UINT8 *cascadeId)
static CAAccountingDBInterface * getConnection()
static CAAccountingDBInterface * ms_pDBConnectionPool[]
SINT32 __clearAccountStatus(UINT64 a_accountNumber)
SINT32 __storePrepaidAmount(UINT64 accountNumber, SINT32 prepaidBytes, UINT8 *cascadeId)
SINT32 initDBConnection()
Initiates the database connection.
SINT32 checkCountAllQuery(UINT8 *a_query, UINT32 &r_count)
Takes and executes a query that counts databae records and tests if the result is valid.
SINT32 __markAsSettled(UINT64 accountNumber, UINT8 *cascadeId, UINT64 a_transferredBytes)
Marks this account as settled.
SINT32 storeCostConfirmation(CAXMLCostConfirmation &cc, UINT8 *ccCascade)
Creates the tables we need in the DB.
SINT32 clearAccountStatus(UINT64 a_accountNumber)
bool checkConnectionStatus()
Checks if the connection still exists and tries to reconnect if not.
~CAAccountingDBInterface()
Destructor.
SINT32 __getCostConfirmation(UINT64 accountNumber, UINT8 *cascadeId, CAXMLCostConfirmation **pCC, bool &a_bSettled)
Gets the latest cost confirmation stored for the given user account.
static volatile UINT64 ms_threadWaitNr
SINT32 __storeCostConfirmation(CAXMLCostConfirmation &cc, UINT8 *ccCascade)
stores a cost confirmation in the DB
CAAccountingDBInterface()
Constructor.
SINT32 __getAccountStatus(UINT64 a_accountNumber, UINT32 &a_statusCode)
SINT32 __checkCountAllQuery(UINT8 *a_query, UINT32 &r_count)
SINT32 __getPrepaidAmount(UINT64 accountNumber, UINT8 *cascadeId, bool a_bDelete)
static SINT32 releaseConnection(CAAccountingDBInterface *dbIf)
static CAConditionVariable * ms_pConnectionAvailable
SINT32 getCostConfirmation(UINT64 accountNumber, UINT8 *cascadeId, CAXMLCostConfirmation **pCC, bool &a_bSettled)
SINT32 getAccountStatus(UINT64 a_accountNumber, UINT32 &a_statusCode)
SINT32 __deleteCC(UINT64 accountNumber, UINT8 *cascadeId)
PGconn * m_dbConn
connection to postgreSQL database
SINT32 __getUnsettledCostConfirmations(CAXMLCostConfirmation ***resultCCs, UINT8 *cascadeId, UINT32 *nrOfCCs, UINT32 a_maxCCs)
Fills the CAQueue with pointer to all non-settled cost confirmations.
SINT32 __storeAccountStatus(UINT64 a_accountNumber, UINT32 a_statusCode)
SINT32 deleteCC(UINT64 accountNumber, UINT8 *cascadeId)
if the BI reports an error while trying to settle a CC, this will be called to delete it from the dat...
PGresult * monitored_PQexec(PGconn *conn, const char *query)
static volatile UINT64 ms_nextThreadNr
SINT32 getUnsettledCostConfirmations(CAXMLCostConfirmation ***resultCCs, UINT8 *cascadeId, UINT32 *nrOfCCs, UINT32 a_maxCCs)
Fills the CAQueue with all non-settled cost confirmations.
SINT32 storeAccountStatus(UINT64 a_accountNumber, UINT32 a_statusCode)
SINT32 markAsSettled(UINT64 accountNumber, UINT8 *cascadeId, UINT64 a_transferredBytes)
Marks this account as settled.
SINT32 getPrepaidAmount(UINT64 accountNumber, UINT8 *cascadeId, bool a_bDelete)
SINT32 terminateDBConnection()
Terminates the database connection.
volatile thread_id_t m_owner
CAMutex * m_pConnectionMutex
This is the AI (accounting instance or abrechnungsinstanz in german) class.