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); }
private OP_REQUEST Get_op_request(Dictionary <string, SOURCE> sources, Dictionary <string, DATABASE> databases, XmlElement e_operation, string type) { string securities_file = Get_child(e_operation, "securities_file", "securities_file").InnerText; XmlElement e_start = Get_child(e_operation, "start_date"); XmlElement e_end = Get_child(e_operation, "end_date"); XmlElement e_today_included = Get_child(e_operation, "today_included"); XmlElement e_periodicity = Get_child(e_operation, "periodicity"); string source = Get_child(e_operation, "source", "operation/source").InnerText; if (!sources.ContainsKey(source)) { throw new CONFIGURATION_ERROR("unknown source: " + source); } string database = Get_child(e_operation, "database", "operation/database").InnerText; if (!databases.ContainsKey(database)) { throw new CONFIGURATION_ERROR("unknown database: " + database); } string table = Get_child(e_operation, "table", "table").InnerText; bool update = false; XmlElement e_update = Get_child(e_operation, "update"); if (e_update != null && e_update.InnerText == "true") { update = true; } string column_security = "security"; XmlElement e_column_security = Get_child(e_operation, "column_security"); if (e_column_security != null) { column_security = e_column_security.InnerText; } string column_date = "date"; XmlElement e_column_date = Get_child(e_operation, "column_date"); if (e_column_date != null) { column_date = e_column_date.InnerText; } XmlElement e_requests = Get_child(e_operation, "requests", "requests"); XmlElement[] el_request = Get_children(e_requests, "request", "request"); RQ_INFO[] rq_infos = new RQ_INFO[el_request.Length]; for (int i = 0; i < el_request.Length; i++) { XmlElement e_request = el_request[i]; string[] securities; try { securities = System.IO.File.ReadAllLines(securities_file); } catch (Exception) { throw new CONFIGURATION_ERROR("could not read file: " + securities_file); } XmlElement e_fields = Get_child(e_request, "fields", "fields"); XmlElement[] el_field = Get_children(e_fields, "field", "field"); FIELD[] fields = new FIELD[el_field.Length + 2]; for (int j = 0; j < fields.Length; j++) { fields[j] = new FIELD(); } fields[0].name = "security"; fields[0].column = column_security; fields[1].name = "date"; fields[1].column = column_date; for (int j = 0; j < el_field.Length; j++) { fields[2 + j].name = Get_child(el_field[j], "name", "field/name").InnerText; fields[2 + j].column = Get_child(el_field[j], "column", "column").InnerText; } List <REQUEST_PARAM> request_params = new List <REQUEST_PARAM>(); if (e_start != null) { request_params.Add(new REQUEST_PARAM("startDate", e_start.InnerText)); } if (e_end != null) { if (e_end.InnerText == "" && (e_today_included == null || e_today_included.InnerText == "false")) { Console.WriteLine("LA"); Console.ReadLine(); string end_default = DateTime.Today.AddDays(-1).ToString("yyyyMMdd"); request_params.Add(new REQUEST_PARAM("endDate", end_default)); } else { Console.WriteLine("ICI"); Console.ReadLine(); request_params.Add(new REQUEST_PARAM("endDate", e_end.InnerText)); } } if (e_periodicity != null) { request_params.Add(new REQUEST_PARAM("periodicitySelection", e_periodicity.InnerText)); } XmlElement e_options = Get_child(e_request, "options"); if (e_options != null) { XmlElement[] el_option = Get_children(e_options, "option"); foreach (XmlElement e_option in el_option) { string name = Get_child(e_option, "name", "option/name").InnerText; string value = Get_child(e_option, "value", "option/value").InnerText; request_params.Add(new REQUEST_PARAM(name, value)); } } rq_infos[i] = new RQ_INFO(securities, fields, request_params.ToArray()); } if (type == "histo1") { return(new OP_HISTO1(type, sources[source], databases[database], table, rq_infos, update)); } else { return(new OP_REQUEST(type, sources[source], databases[database], table, rq_infos, update)); } }