Esempio n. 1
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);
 }
Esempio n. 2
0
        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);
        }