예제 #1
0
파일: configuration.cs 프로젝트: fbonnin/42
        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);
        }
예제 #2
0
 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);
 }
예제 #3
0
파일: op_request.cs 프로젝트: fbonnin/42
 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;
 }
예제 #4
0
파일: op_histo1.cs 프로젝트: fbonnin/42
        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);
        }
예제 #5
0
파일: op_request.cs 프로젝트: fbonnin/42
 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;
             }
         }
     }
 }
예제 #6
0
 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)
 {
 }