-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBConnection.h
62 lines (56 loc) · 2.35 KB
/
DBConnection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef DBCONNECTION_H
#define DBCONNECTION_H
#include <mysql_driver.h>
#include <mysql_connection.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <memory>
#include <string>
#include <vector>
#include <stdexcept>
#include "Campaign.h"
#include "ParsedCall.h"
#include "ParsedAgent.h"
#include "ParsedConfBridge.h"
#include "ParsedQueueOperations.h"
class DBConnection
{
public:
DBConnection();
~DBConnection();
std::shared_ptr<sql::Connection> getConnection();
std::vector<std::string> getCampaigns(u_long serverId);
Campaign getCampaignByName(const std::string &name);
std::vector<std::string> getCampaignSettings(u_long campaigId, u_long serverId);
std::vector<std::string> getCampaignFilters(u_long campaignId, u_long serverId);
std::vector<u_long> getCampaignAgents(u_long campaignId, u_long serverId);
std::vector<ParsedAgent> getAllAgents(u_long serverId);
u_long getQueueIdByCode(const std::string &campaignCode, u_long serverId);
u_long getConfBridgeIdForAgent(u_long agentId, u_long serverId);
std::vector<ParsedConfBridge> getAllConfBridges(u_long serverId);
std::vector<ParsedConfBridge> getQueueConfBridges(u_long serverId, std::string &queueName);
ParsedQueueOperations fetchAbnStats(const std::string &queueName, u_long serverId, int resetHours = 3);
bool updateAbnStats(const std::string &queueName, u_long serverId, const ParsedQueueOperations &queueOperations);
int getAvailableAgentBridges(const std::string &queueName, u_long serverId);
std::vector<ParsedCall> fetchAllCalls(u_long serverId);
ParsedCall insertCall(const ParsedCall &call);
bool updateCall(const ParsedCall &call);
int getLinesDialing(const std::string &queueName, u_long serverId);
std::vector<std::pair<std::string, std::string>> selectLeads(const std::string &query);
bool executeUpdate(const std::string &query);
std::shared_ptr<sql::PreparedStatement> prepareStatement(const std::string &query)
{
return std::shared_ptr<sql::PreparedStatement>(conn->prepareStatement(query));
}
private:
sql::mysql::MySQL_Driver *driver;
std::shared_ptr<sql::Connection> conn;
std::string host;
std::string port;
std::string user;
std::string password;
std::string database;
void connect();
};
#endif // DBCONNECTION_H