public static settings read_settings(core c, db_provider conn) { return(new settings(conn.dt_table(c.config.get_query("lib-base.get-settings").text) .Rows.Cast <DataRow>().Select(r => new setting((int)r["setting_id"] , (string)r["setting_name"], db_provider.str_val(r["setting_var"]) , db_provider.str_val(r["machine_name"]))).ToList())); }
public static DataTable dt_query(string name, string[,] fields = null) { db_provider conn = null; try { conn = Program.open_conn(); return(conn.dt_table(_c.parse_query(name, fields))); } catch { return(null); } finally { if (conn != null) { conn.close_conn(); } } }
public void load_doc(string doc_key, string vars_key, xml_doc doc, db_provider conn, Dictionary <string, object> keys = null, bool for_pg = false) { string var_key = !string.IsNullOrEmpty(vars_key) ? vars_key + "." : ""; // sql-select if (doc.exists("//sql-select")) { foreach (xml_node s in doc.nodes("//sql-select")) { xml_node ref_node = s; foreach (DataRow r in conn.dt_table(_core.parse(s.get_attr("qry"), keys)).Rows) { foreach (xml_node n in _core.parse_nodes(s.clone_childs(s), keys, r)) { ref_node = ref_node.add_after(n); } } } while (true) { xml_node s = doc.node("//sql-select"); if (!s.remove()) { break; } } } // aggiungo string nkey = ""; try { foreach (xml_node var in doc.nodes("/config//folders/folder")) { nkey = var_key + var.get_attr("name"); _folders.Add(nkey, new folder(doc_key, nkey, _core.parse(var.get_val()), for_pg)); } } catch (Exception ex) { throw new Exception("chiave folders.'" + nkey + "' - " + ex.Message); } nkey = ""; try { foreach (xml_node tbl in doc.nodes("/config//tables/table")) { nkey = var_key + tbl.get_attr("name"); _tables.Add(nkey, new table(doc_key, nkey, tbl, for_pg)); } } catch (Exception ex) { throw new Exception("chiave tables.'" + nkey + "' - " + ex.Message); } nkey = ""; try { foreach (xml_node tbl in doc.nodes("/config/html-blocks/html-block")) { nkey = var_key + tbl.get_attr("name"); html_block b = new html_block(doc_key, nkey, tbl.text, for_pg); foreach (xml_node f in tbl.nodes("cond")) { b.add_cond(f.get_attr("name"), f.text); } _html_blocks.Add(nkey, b); } } catch (Exception ex) { throw new Exception("chiave html-blocks.'" + nkey + "' - " + ex.Message); } nkey = ""; try { foreach (xml_node qry in doc.nodes("/config//queries/*")) { if (qry.name == "query") { nkey = var_key + qry.get_attr("name"); query q = new query(doc_key, nkey, qry.text, qry.get_attr("des"), for_pg); foreach (xml_node f in qry.nodes("cond")) { q.add_cond(f.get_attr("name"), f.text); } _queries.Add(nkey, q); } else if (qry.name == "query_do") { nkey = var_key + qry.get_attr("name"); _queries.Add(nkey, new query(doc_key, nkey, qry.get_attr("des"), for_pg) { tp = query.tp_query.do_while, text_do = qry.sub_node("do").text, text_while = qry.sub_node("while").text }); } else if (qry.name == "queries") { nkey = var_key + qry.get_attr("name"); query q = new query(doc_key, nkey, qry.get_attr("des"), for_pg); _queries.Add(nkey, q); foreach (xml_node q2 in qry.nodes("*")) { if (q2.name == "query") { q.add_query(q2.text); } else if (q2.name == "exec_query") { foreach (string q3 in _queries[q2.get_attr("name")].queries) { q.add_query(q3); } } } } } } catch (Exception ex) { throw new Exception("chiave queries.'" + nkey + "' - " + ex.Message); } }