EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CalendarDB Class Reference

#include "CalendarDB.h"

Static Public Member Functions

static void DeleteEvent (uint32 eventID)
 
static uint32 SaveSystemEvent (uint32 ownerID, uint32 creatorID, int64 startDateTime, uint8 autoEventType, std::string title, std::string description, bool important=false)
 
static void SaveEventResponse (uint32 charID, Call_SendEventResponse &args)
 
static void UpdateEventParticipants (Call_UpdateEventParticipants &args)
 
static PyRepSaveNewEvent (uint32 ownerID, Call_CreateEventWithInvites &args)
 
static PyRepSaveNewEvent (uint32 ownerID, uint32 creatorID, Call_CreateEvent &args)
 
static PyRepGetEventList (uint32 ownerID, uint32 month, uint32 year)
 
static PyRepGetEventDetails (uint32 eventID)
 
static PyRepGetResponsesToEvent (uint32 eventID)
 
static PyRepGetResponsesForCharacter (uint32 charID)
 

Detailed Description

Definition at line 16 of file CalendarDB.h.

Member Function Documentation

void CalendarDB::DeleteEvent ( uint32  eventID)
static

Definition at line 33 of file CalendarDB.cpp.

References sDatabase.

34 {
35  DBerror err;
36  sDatabase.RunQuery(err, "UPDATE sysCalendarEvents SET isDeleted = 1 WHERE eventID = %u", eventID);
37 }
#define sDatabase
Definition: dbcore.h:199
Definition: dbcore.h:39
PyRep * CalendarDB::GetEventDetails ( uint32  eventID)
static

Definition at line 202 of file CalendarDB.cpp.

References DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), DBResultRow::GetText(), sDatabase, and PyDict::SetItemString().

203 {
204  if (eventID == 0)
205  return nullptr;
206 
207  DBQueryResult res;
208  if (!sDatabase.RunQuery(res,
209  "SELECT ownerID, creatorID, eventText"
210  " FROM sysCalendarEvents WHERE eventID = %u", eventID))
211  {
212  codelog(DATABASE__ERROR, "Error in GetEventList query: %s", res.error.c_str());
213  return nullptr;
214  }
215 
216  DBResultRow row;
217  if (!res.GetRow(row))
218  return nullptr;
219 
220  PyDict* dict = new PyDict();
221  dict->SetItemString("eventID", new PyInt(eventID));
222  dict->SetItemString("ownerID", new PyInt(row.GetInt(0)));
223  dict->SetItemString("creatorID", new PyInt(row.GetInt(1)));
224  dict->SetItemString("eventText", new PyString(row.GetText(2)));
225 
226  return new PyObject("util.KeyVal", dict);
227 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
Python string.
Definition: PyRep.h:430
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
Python's dictionary.
Definition: PyRep.h:719
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
Python object.
Definition: PyRep.h:826
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
DBerror error
Definition: dbcore.h:69
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

PyRep * CalendarDB::GetEventList ( uint32  ownerID,
uint32  month,
uint32  year 
)
static

Definition at line 162 of file CalendarDB.cpp.

References PyList::AddItem(), Calendar::Flag::Automated, DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetBool(), DBResultRow::GetInt(), DBResultRow::GetInt64(), DBQueryResult::GetRow(), DBQueryResult::GetRowCount(), DBResultRow::GetText(), DBResultRow::IsNull(), PyStatic, sDatabase, and PyDict::SetItemString().

163 {
164  if (ownerID == 0)
165  return nullptr;
166 
167  DBQueryResult res;
168  if (!sDatabase.RunQuery(res,
169  "SELECT eventID, ownerID, eventDateTime, dateModified, eventDuration, importance, eventTitle, flag,"
170  " autoEventType, isDeleted"
171  " FROM sysCalendarEvents WHERE ownerID = %u AND month = %u AND year = %u", ownerID, month, year))
172  {
173  codelog(DATABASE__ERROR, "Error in GetEventList query: %s", res.error.c_str());
174  return nullptr;
175  }
176 
177  if (res.GetRowCount() < 1)
178  return nullptr;
179 
180  DBResultRow row;
181  PyList* list = new PyList();
182  while (res.GetRow(row)) {
183  PyDict* dict = new PyDict();
184  dict->SetItemString("eventID", new PyInt(row.GetInt(0)));
185  dict->SetItemString("ownerID", new PyInt(row.GetInt(1)));
186  dict->SetItemString("eventDateTime", new PyLong(row.GetInt64(2)));
187  dict->SetItemString("dateModified", row.IsNull(3) ? PyStatic.NewNone() : new PyLong(row.GetInt64(3)));
188  dict->SetItemString("eventDuration", row.IsNull(4) ? PyStatic.NewNone() : new PyInt(row.GetInt(4)));
189  dict->SetItemString("importance", new PyBool(row.GetBool(5)));
190  dict->SetItemString("eventTitle", new PyString(row.GetText(6)));
191  dict->SetItemString("flag", new PyInt(row.GetInt(7)));
192  // client patch to allow non-corp automated events for ram jobs
193  if (row.GetInt(7) == Calendar::Flag::Automated)
194  dict->SetItemString("autoEventType", new PyInt(row.GetInt(8)));
195  dict->SetItemString("isDeleted", new PyBool(row.GetBool(9)));
196  list->AddItem(new PyObject("util.KeyVal", dict));
197  }
198 
199  return list;
200 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
Python string.
Definition: PyRep.h:430
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
Python's dictionary.
Definition: PyRep.h:719
void AddItem(PyRep *i)
Definition: PyRep.h:701
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
Python boolean.
Definition: PyRep.h:323
const char * c_str() const
Definition: dbcore.h:48
Python object.
Definition: PyRep.h:826
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209
bool IsNull(uint32 index) const
Definition: dbcore.h:102
DBerror error
Definition: dbcore.h:69
size_t GetRowCount()
Definition: dbcore.h:72
int64 GetInt64(uint32 index) const
Definition: dbcore.cpp:670
Python list.
Definition: PyRep.h:639
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812
Python long integer.
Definition: PyRep.h:261

Here is the call graph for this function:

PyRep * CalendarDB::GetResponsesForCharacter ( uint32  charID)
static

Definition at line 237 of file CalendarDB.cpp.

References PyList::AddItem(), DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), sDatabase, and PyDict::SetItemString().

238 {
239  DBQueryResult res;
240  if (!sDatabase.RunQuery(res,"SELECT eventID, response FROM sysCalendarResponses WHERE charID = %u", charID)) {
241  codelog(DATABASE__ERROR, "Error in GetEventList query: %s", res.error.c_str());
242  return nullptr;
243  }
244 
245  DBResultRow row;
246  PyList *list = new PyList();
247  while (res.GetRow(row)) {
248  // list char response for each event
249  PyDict* dict = new PyDict();
250  dict->SetItemString("eventID", new PyInt(row.GetInt(0)));
251  dict->SetItemString("status", new PyInt(row.GetInt(1)));
252  list->AddItem(new PyObject("util.KeyVal", dict));
253  }
254 
255  return list;
256 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
Python's dictionary.
Definition: PyRep.h:719
void AddItem(PyRep *i)
Definition: PyRep.h:701
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
Python object.
Definition: PyRep.h:826
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
DBerror error
Definition: dbcore.h:69
Python list.
Definition: PyRep.h:639
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

PyRep * CalendarDB::GetResponsesToEvent ( uint32  eventID)
static

Definition at line 258 of file CalendarDB.cpp.

References PyList::AddItem(), DBerror::c_str(), codelog, DBQueryResult::error, DBResultRow::GetInt(), DBQueryResult::GetRow(), sDatabase, and PyDict::SetItemString().

259 {
260  DBQueryResult res;
261  if (!sDatabase.RunQuery(res,"SELECT charID, response FROM sysCalendarResponses WHERE eventID = %u", eventID)) {
262  codelog(DATABASE__ERROR, "Error in GetEventList query: %s", res.error.c_str());
263  return nullptr;
264  }
265 
266  DBResultRow row;
267  PyList *list = new PyList();
268  while (res.GetRow(row)) {
269  // list char response for each event
270  PyDict* dict = new PyDict();
271  dict->SetItemString("characterID", new PyInt(row.GetInt(0)));
272  dict->SetItemString("status", new PyInt(row.GetInt(1)));
273  list->AddItem(new PyObject("util.KeyVal", dict));
274  }
275 
276  return list;
277 }
#define sDatabase
Definition: dbcore.h:199
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
Python's dictionary.
Definition: PyRep.h:719
void AddItem(PyRep *i)
Definition: PyRep.h:701
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
Python object.
Definition: PyRep.h:826
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
DBerror error
Definition: dbcore.h:69
Python list.
Definition: PyRep.h:639
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812

Here is the call graph for this function:

void CalendarDB::SaveEventResponse ( uint32  charID,
Call_SendEventResponse &  args 
)
static

Definition at line 229 of file CalendarDB.cpp.

References sDatabase.

230 {
231  DBerror err;
232  sDatabase.RunQuery(err,
233  "INSERT INTO `sysCalendarResponses`(`eventID`, `charID`, `response`)"
234  " VALUES (%u, %u, %u)", args.eventID, charID, args.response);
235 }
#define sDatabase
Definition: dbcore.h:199
* args
Definition: dbcore.h:39
PyRep * CalendarDB::SaveNewEvent ( uint32  ownerID,
Call_CreateEventWithInvites &  args 
)
static

Definition at line 40 of file CalendarDB.cpp.

References PyList::begin(), DBerror::c_str(), codelog, GetTimeParts(), EvE::TimeParts::month, Calendar::Flag::Personal, PyStatic, sDatabase, and EvE::TimeParts::year.

41 {
43  data = GetTimeParts(args.startDateTime);
44 
45  DBerror err;
46  if (!args.invitees->empty()) {
47  bool comma(false);
48  std::ostringstream str;
49  PyList* list(args.invitees->AsList());
50  PyList::const_iterator itr = list->begin(), end = list->end();
51  while (itr != end) {
52  if (comma) {
53  str << ",";
54  } else {
55  comma = true;
56  }
57  str << *itr;
58  ++itr;
59  }
60 
61  sDatabase.RunQuery(err,
62  "INSERT INTO `sysCalendarInvitees`(`eventID`, `inviteeList`)"
63  " VALUES %s", str.str().c_str());
64  }
65 
66  uint32 eventID(0);
67  if (args.duration) {
68  if (!sDatabase.RunQueryLID(err, eventID,
69  "INSERT INTO sysCalendarEvents(ownerID, creatorID, eventDateTime, eventDuration, importance,"
70  " eventTitle, eventText, flag, month, year)"
71  " VALUES (%u, %u, %li, %u, %u, '%s', '%s', %u, %u, %u)",
72  ownerID, ownerID, args.startDateTime, args.duration, args.important, args.title.c_str(),
73  args.description.c_str(), Calendar::Flag::Personal, data.month, data.year))
74  {
75  codelog(DATABASE__ERROR, "Error in SaveNewEvent query: %s", err.c_str());
76  return PyStatic.NewZero();
77  }
78  } else {
79  if (!sDatabase.RunQueryLID(err, eventID,
80  "INSERT INTO sysCalendarEvents(ownerID, creatorID, eventDateTime, importance,"
81  " eventTitle, eventText, flag, month, year)"
82  " VALUES (%u, %u, %li, %u, '%s', '%s', %u, %u, %u)",
83  ownerID, ownerID, args.startDateTime, args.important, args.title.c_str(),
84  args.description.c_str(), Calendar::Flag::Personal, data.month, data.year))
85  {
86  codelog(DATABASE__ERROR, "Error in SaveNewEvent query: %s", err.c_str());
87  return PyStatic.NewZero();
88  }
89  }
90 
91  return new PyInt(eventID);
92 }
#define sDatabase
Definition: dbcore.h:199
const_iterator begin() const
Definition: PyRep.h:660
storage_type::const_iterator const_iterator
Definition: PyRep.h:644
* args
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209
unsigned __int32 uint32
Definition: eve-compat.h:50
EvE::TimeParts GetTimeParts(int64 filetime)
Definition: utils_time.cpp:157
Definition: dbcore.h:39
Python list.
Definition: PyRep.h:639

Here is the call graph for this function:

PyRep * CalendarDB::SaveNewEvent ( uint32  ownerID,
uint32  creatorID,
Call_CreateEvent &  args 
)
static

Definition at line 95 of file CalendarDB.cpp.

References Calendar::Flag::Alliance, Calendar::Flag::Automated, DBerror::c_str(), Calendar::Flag::CCP, codelog, Calendar::Flag::Corp, GetTimeParts(), Calendar::Flag::Invalid, IsAlliance, IsCharacterID, IsCorp, EvE::TimeParts::month, Calendar::Flag::Personal, PyStatic, sDatabase, and EvE::TimeParts::year.

96 {
98  if (IsCharacterID(ownerID)) {
100  } else if (IsCorp(ownerID)) { // this would also be Automated for pos fuel
101  flag = Calendar::Flag::Corp;
102  } else if (IsAlliance(ownerID)) {
104  } else if (ownerID == 1) {
105  flag = Calendar::Flag::CCP;
106  } else {
108  }
109 
111  data = GetTimeParts(args.startDateTime);
112 
113  uint32 eventID(0);
114  DBerror err;
115  if (args.duration) {
116  if (!sDatabase.RunQueryLID(err, eventID,
117  "INSERT INTO sysCalendarEvents(ownerID, creatorID, eventDateTime, eventDuration, importance,"
118  " eventTitle, eventText, flag, month, year)"
119  " VALUES (%u, %u, %li, %u, %u, '%s', '%s', %u, %u, %u)",
120  ownerID, creatorID, args.startDateTime, args.duration, args.important,
121  args.title.c_str(), args.description.c_str(), flag, data.month, data.year))
122  {
123  codelog(DATABASE__ERROR, "Error in SaveNewEvent query: %s", err.c_str());
124  return PyStatic.NewZero();
125  }
126  } else {
127  if (!sDatabase.RunQueryLID(err, eventID,
128  "INSERT INTO sysCalendarEvents(ownerID, creatorID, eventDateTime, importance,"
129  " eventTitle, eventText, flag, month, year)"
130  " VALUES (%u, %u, %li, %u, '%s', '%s', %u, %u, %u)",
131  ownerID, creatorID, args.startDateTime, args.important,
132  args.title.c_str(), args.description.c_str(), flag, data.month, data.year))
133  {
134  codelog(DATABASE__ERROR, "Error in SaveNewEvent query: %s", err.c_str());
135  return PyStatic.NewZero();
136  }
137  }
138 
139  return new PyInt(eventID);
140 }
unsigned __int8 uint8
Definition: eve-compat.h:46
#define sDatabase
Definition: dbcore.h:199
* args
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209
#define IsCharacterID(itemID)
Definition: EVE_Defines.h:206
unsigned __int32 uint32
Definition: eve-compat.h:50
#define IsCorp(itemID)
Definition: EVE_Defines.h:234
EvE::TimeParts GetTimeParts(int64 filetime)
Definition: utils_time.cpp:157
#define IsAlliance(itemID)
Definition: EVE_Defines.h:244
Definition: dbcore.h:39

Here is the call graph for this function:

uint32 CalendarDB::SaveSystemEvent ( uint32  ownerID,
uint32  creatorID,
int64  startDateTime,
uint8  autoEventType,
std::string  title,
std::string  description,
bool  important = false 
)
static

Definition at line 143 of file CalendarDB.cpp.

References Calendar::Flag::Automated, DBerror::c_str(), GetTimeParts(), EvE::TimeParts::month, sDatabase, and EvE::TimeParts::year.

145 {
147  data = GetTimeParts(startDateTime);
148 
149  uint32 eventID(0);
150  DBerror err;
151  sDatabase.RunQueryLID(err, eventID,
152  "INSERT INTO sysCalendarEvents(ownerID, creatorID, eventDateTime, autoEventType,"
153  " eventTitle, eventText, flag, month, year, importance)"
154  " VALUES (%u, %u, %li, %u, '%s', '%s', %u, %u, %u, %u)",
155  ownerID, creatorID, startDateTime, autoEventType, title.c_str(), description.c_str(),
156  Calendar::Flag::Automated, data.month, data.year, important?1:0);
157 
158  return eventID;
159 }
#define sDatabase
Definition: dbcore.h:199
const char * c_str() const
Definition: dbcore.h:48
unsigned __int32 uint32
Definition: eve-compat.h:50
EvE::TimeParts GetTimeParts(int64 filetime)
Definition: utils_time.cpp:157
Definition: dbcore.h:39

Here is the call graph for this function:

void CalendarDB::UpdateEventParticipants ( Call_UpdateEventParticipants &  args)
static

Definition at line 279 of file CalendarDB.cpp.

280 {
281  DBerror err;
282 }
Definition: dbcore.h:39

The documentation for this class was generated from the following files: