public Dictionary <string, DATABASE> Get_databases() { Dictionary <string, DATABASE> result = new Dictionary <string, DATABASE>(); XmlElement e_databases = Get_child(e_configuration, "databases", "databases"); XmlElement[] database_list = Get_children(e_databases, "database", "databases/database"); foreach (XmlElement e_database in database_list) { string id = Get_child(e_database, "id", "database/id").InnerText; string type = Get_child(e_database, "type", "database/type").InnerText; DATABASE database = null; switch (type) { case "mysql": string host = Get_child(e_database, "host", "database/host").InnerText; string name = Get_child(e_database, "name", "database/name").InnerText; string user = Get_child(e_database, "user", "database/user").InnerText; string password = Get_child(e_database, "password", "database/password").InnerText; database = new DB_MYSQL(host, name, user, password); break; } result.Add(id, database); } return(result); }
protected override object[][] Process_request_result(ref FIELD[] fields, Dictionary <string, object>[] request_result) { FIELD[] old_fields = fields; fields = new FIELD[old_fields.Length + 1]; fields[0] = new FIELD(); fields[0].name = "ID"; fields[0].column = "ID"; for (int j = 0; j < old_fields.Length; j++) { fields[j + 1] = old_fields[j]; } object[][] result = new object[request_result.Length][]; for (int i = 0; i < request_result.Length; i++) { Dictionary <string, object> values = request_result[i]; if (values.ContainsKey("security")) { values["security"] = Get_short_ticker((string)values["security"]); } if (values.ContainsKey("CHG_PCT_1D")) { values["CHG_PCT_1D"] = Get_chg((string)values["CHG_PCT_1D"]); } values.Add("ID", DATABASE.Value_to_string(values["security"]) + DATABASE.Value_to_string(values["date"])); result[i] = new object[fields.Length]; for (int j = 0; j < fields.Length; j++) { result[i][j] = DATABASE.Value_to_string(values[fields[j].name]); } } return(result); }
public OP_REQUEST(string type, SOURCE source, DATABASE database, string table, RQ_INFO[] rq_infos, bool update) { this.type = type; this.source = source; this.database = database; this.table = table; this.rq_infos = rq_infos; }
protected override string Get_query(FIELD[] fields, Dictionary <string, object>[] request_result) { string result = ""; foreach (Dictionary <string, object> values in request_result) { if (values.ContainsKey("security")) { values["security"] = Get_short_ticker((string)values["security"]); } if (values.ContainsKey("CHG_PCT_1D")) { values["CHG_PCT_1D"] = Get_chg((string)values["CHG_PCT_1D"]); } string query = "INSERT INTO " + table + " (ID, "; for (int i = 0; i < fields.Length; i++) { query += fields[i].column; if (i < fields.Length - 1) { query += ", "; } } query += ") VALUES (" + "'" + DATABASE.Value_to_string(values["security"]) + DATABASE.Value_to_string(values["date"]) + "'" + ", "; for (int i = 0; i < fields.Length; i++) { query += "'" + DATABASE.Value_to_string(values[fields[i].name]) + "'"; if (i < fields.Length - 1) { query += ", "; } } query += ") ON DUPLICATE KEY UPDATE "; for (int i = 0; i < fields.Length; i++) { query += fields[i].column + " = " + "'" + DATABASE.Value_to_string(values[fields[i].name]) + "'"; if (i < fields.Length - 1) { query += ", "; } } query += ";"; result += query; } return(result); }
public OP_REQUEST(string type, SOURCE source, DATABASE database, string table, RQ_INFO[] rq_infos, bool update) { this.type = type; this.source = source; this.database = database; this.table = table; this.rq_infos = rq_infos; this.update = update; foreach (RQ_INFO rq_info in rq_infos) { foreach (FIELD field in rq_info.fields) { if (field.name == "security") { column_security = field.column; } } } }
public OP_HISTO1(string type, SOURCE source, DATABASE database, string table, RQ_INFO[] rq_infos, bool update) : base(type, source, database, table, rq_infos, update) { }