24 float age(
int Mnbr = 0);
46 bool set_scale(
string scale_type,
int ac,
int val);
117 the_age = the_age + (tmNow.tm_mon -
birth_date.tm_mon) / 12 + Mnbr / 12;
137 sSQL =
"SELECT investor_id, user_name, first_name, last_name, birth_date, currency, simulate_till_age FROM " +
oConfig.
tbl_prefix +
"_investors WHERE investor_id = " + uid +
";";
140 sql::Connection *con;
141 sql::Statement *stmt;
145 driver = get_driver_instance();
149 con->setSchema(
db.
db);
151 stmt = con->createStatement();
152 res = stmt->executeQuery(sSQL);
166 currency = res->getString(
"currency");
176 catch (sql::SQLException &e) {
179 cout <<
"# ERR: SQLException in " << __FILE__;
180 cout <<
"(" << __FUNCTION__ <<
") on line " << __LINE__ << endl;
181 cout <<
"# ERR: " << e.what();
182 cout <<
" (MySQL error code: " << e.getErrorCode();
183 cout <<
", SQLState: " << e.getSQLState() <<
" )" << endl;
184 cout <<
"[[" << sSQL <<
"]]*get*";
188 if (EXIT_SUCCESS == 0)
202 return (
int) round((theAge - this->
age(0)) * 12);
214 return to_string(this->
age() + month_nbr / 12);
225 s +=
" last_name = '" +
last_name +
"', ";
228 s +=
" currency = '" +
currency +
"' ";
229 s +=
" WHERE investor_id = " + to_string(
investor_id) +
";";
231 debug_info +=
"<br>" + s;
251 sSQL =
"SELECT investor_id, user_name, first_name, last_name, birth_date, simulate_till_age, currency FROM " +
oConfig.
tbl_prefix +
"_investors WHERE user_name = '" + uid +
"' && AES_DECRYPT(password,'" + password +
hh.
c_salt +
"') = '" + password +
"';";
try{
253 sql::Connection *con;
254 sql::Statement *stmt;
258 driver = get_driver_instance();
262 con->setSchema(
db.
db);
264 stmt = con->createStatement();
265 res = stmt->executeQuery(sSQL);
278 currency = res->getString(
"currency");
288 catch (sql::SQLException &e) {
291 cout <<
"# ERR: SQLException in " << __FILE__;
292 cout <<
"(" << __FUNCTION__ <<
") on line " << __LINE__ << endl;
293 cout <<
"# ERR: " << e.what();
294 cout <<
" (MySQL error code: " << e.getErrorCode();
295 cout <<
", SQLState: " << e.getSQLState() <<
" )" << endl;
299 if (EXIT_SUCCESS == 0)
316 s =
"INSERT INTO " +
oConfig.
tbl_prefix +
"_investors (user_name, first_name, last_name, password, birth_date, simulate_till_age, currency) ";
321 debug_info +=
"<br>" + s;
345 string s =
"SELECT investor_id FROM " +
oConfig.
tbl_prefix +
"_investors WHERE investor_id = " + to_string(iid) +
";";
347 if ((
db.
res->next()))
366 float denom, sumExp = 0;
377 if (sumExp <= 2) max_exposure[3] = max((
float)0.2, (
float)max_exposure[3]);
388 while (
db.
res->next())
407 if (scale_type ==
"experience")
experience[ac] = val;
408 if (scale_type ==
"knowledge")
knowledge[ac] = val;
409 if (scale_type ==
"desirability")
desirability[ac] = val;
423 s =
"INSERT INTO " +
oConfig.
tbl_prefix +
"_preferences (investor, asset_class, experience, knowledge, desirability, max_exposure) VALUES ";
426 if (i > 1) s = s +
", ";
const string db_host
Database.
string dateStr2Age(string the_date)
std::map< int, int > desirability
string currency
the default currency for that customer
std::map< int, int > knowledge
#define NBR_ASSET_CLASSES
the nunmber of asset classes (not dynamically updated!)
string error_message
global message variables
int age2monthNbr(float theAge)
const string tbl_prefix
tables start with "" + oConfig.tbl_prefix + "_" if the prefix is eg. "tbl" then we have "tbl_invesotr...
tm get_tm(int monthNbr=0)
global functions
string tm2DateStr(tm tmDate)
void set_max_exposure()
sets the max_exposure vector based on the experience, knowledge and desirability
std::map< int, int > experience
html_helper hh
own c++ classes
#define MIN_SCALE
the minimum of the scale (1) (on a scale from 1 to 5)
bool save_preferences()
sets the experience, knowledge and desirability vectors
int get_from_db(string investorID, string password)
bool set_scale(string scale_type, int ac, int val)
int dateStr2Mnbr(string dStr)
std::map< int, float > max_exposure
the maximum exposure per asset class
unordered_map< string, string > t_errMsg
void dateStr2tm(string dStr, tm *target_tm)
void load_preferences()
sets the experience, knowledge and desirability vectors
config oConfig
mysql connection mysql connector from dev.mysql.com
int load_from_db(string investorID)
#define MAX_SCALE
the maximum value for the scale (5) (on a scale from 1 to 5)
#define DEFAULT_SCALE
the default value to use for preferences (on a scale from 1 to 5)